blob: 21b52c15aafc0db81e5e6e185e6d4aa335c78829 [file] [log] [blame]
Oliver O'Halloranc762c692016-09-22 16:54:34 +10001#ifndef __XZ_CONFIG_H__
2#define __XZ_CONFIG_H__
3
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
10#include "types.h"
11#include "swab.h"
12
13static inline uint32_t swab32p(void *p)
14{
15 uint32_t *q = p;
16
17 return swab32(*q);
18}
19
20#ifdef __LITTLE_ENDIAN__
21#define get_le32(p) (*((uint32_t *) (p)))
Masahiro Yamada34dd8fb2019-07-05 19:01:43 +090022#define cpu_to_be32(x) swab32(x)
23static inline u32 be32_to_cpup(const u32 *p)
24{
25 return swab32p((u32 *)p);
26}
Oliver O'Halloranc762c692016-09-22 16:54:34 +100027#else
28#define get_le32(p) swab32p(p)
Masahiro Yamada34dd8fb2019-07-05 19:01:43 +090029#define cpu_to_be32(x) (x)
30static inline u32 be32_to_cpup(const u32 *p)
31{
32 return *p;
33}
Oliver O'Halloranc762c692016-09-22 16:54:34 +100034#endif
35
Masahiro Yamada34dd8fb2019-07-05 19:01:43 +090036static inline uint32_t get_unaligned_be32(const void *p)
37{
38 return be32_to_cpup(p);
39}
40
41static inline void put_unaligned_be32(u32 val, void *p)
42{
43 *((u32 *)p) = cpu_to_be32(val);
44}
45
Oliver O'Halloranc762c692016-09-22 16:54:34 +100046#define memeq(a, b, size) (memcmp(a, b, size) == 0)
47#define memzero(buf, size) memset(buf, 0, size)
48
49/* prevent the inclusion of the xz-preboot MM headers */
50#define DECOMPR_MM_H
51#define memmove memmove
52#define XZ_EXTERN static
53
54/* xz.h needs to be included directly since we need enum xz_mode */
55#include "../../../include/linux/xz.h"
56
57#undef XZ_EXTERN
58
59#endif