xz_config.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __XZ_CONFIG_H__
  3. #define __XZ_CONFIG_H__
  4. /*
  5. * most of this is copied from lib/xz/xz_private.h, we can't use their defines
  6. * since the boot wrapper is not built in the same environment as the rest of
  7. * the kernel.
  8. */
  9. #include "types.h"
  10. #include "swab.h"
  11. static inline uint32_t swab32p(void *p)
  12. {
  13. uint32_t *q = p;
  14. return swab32(*q);
  15. }
  16. #ifdef __LITTLE_ENDIAN__
  17. #define get_le32(p) (*((uint32_t *) (p)))
  18. #define cpu_to_be32(x) swab32(x)
  19. static inline u32 be32_to_cpup(const u32 *p)
  20. {
  21. return swab32p((u32 *)p);
  22. }
  23. #else
  24. #define get_le32(p) swab32p(p)
  25. #define cpu_to_be32(x) (x)
  26. static inline u32 be32_to_cpup(const u32 *p)
  27. {
  28. return *p;
  29. }
  30. #endif
  31. static inline uint32_t get_unaligned_be32(const void *p)
  32. {
  33. return be32_to_cpup(p);
  34. }
  35. static inline void put_unaligned_be32(u32 val, void *p)
  36. {
  37. *((u32 *)p) = cpu_to_be32(val);
  38. }
  39. #define memeq(a, b, size) (memcmp(a, b, size) == 0)
  40. #define memzero(buf, size) memset(buf, 0, size)
  41. /* prevent the inclusion of the xz-preboot MM headers */
  42. #define DECOMPR_MM_H
  43. #define memmove memmove
  44. #define XZ_EXTERN static
  45. /* xz.h needs to be included directly since we need enum xz_mode */
  46. #include "../../../include/linux/xz.h"
  47. #undef XZ_EXTERN
  48. #endif