162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef __XZ_CONFIG_H__ 362306a36Sopenharmony_ci#define __XZ_CONFIG_H__ 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci/* 662306a36Sopenharmony_ci * most of this is copied from lib/xz/xz_private.h, we can't use their defines 762306a36Sopenharmony_ci * since the boot wrapper is not built in the same environment as the rest of 862306a36Sopenharmony_ci * the kernel. 962306a36Sopenharmony_ci */ 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#include "types.h" 1262306a36Sopenharmony_ci#include "swab.h" 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_cistatic inline uint32_t swab32p(void *p) 1562306a36Sopenharmony_ci{ 1662306a36Sopenharmony_ci uint32_t *q = p; 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci return swab32(*q); 1962306a36Sopenharmony_ci} 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci#ifdef __LITTLE_ENDIAN__ 2262306a36Sopenharmony_ci#define get_le32(p) (*((uint32_t *) (p))) 2362306a36Sopenharmony_ci#define cpu_to_be32(x) swab32(x) 2462306a36Sopenharmony_cistatic inline u32 be32_to_cpup(const u32 *p) 2562306a36Sopenharmony_ci{ 2662306a36Sopenharmony_ci return swab32p((u32 *)p); 2762306a36Sopenharmony_ci} 2862306a36Sopenharmony_ci#else 2962306a36Sopenharmony_ci#define get_le32(p) swab32p(p) 3062306a36Sopenharmony_ci#define cpu_to_be32(x) (x) 3162306a36Sopenharmony_cistatic inline u32 be32_to_cpup(const u32 *p) 3262306a36Sopenharmony_ci{ 3362306a36Sopenharmony_ci return *p; 3462306a36Sopenharmony_ci} 3562306a36Sopenharmony_ci#endif 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_cistatic inline uint32_t get_unaligned_be32(const void *p) 3862306a36Sopenharmony_ci{ 3962306a36Sopenharmony_ci return be32_to_cpup(p); 4062306a36Sopenharmony_ci} 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_cistatic inline void put_unaligned_be32(u32 val, void *p) 4362306a36Sopenharmony_ci{ 4462306a36Sopenharmony_ci *((u32 *)p) = cpu_to_be32(val); 4562306a36Sopenharmony_ci} 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ci#define memeq(a, b, size) (memcmp(a, b, size) == 0) 4862306a36Sopenharmony_ci#define memzero(buf, size) memset(buf, 0, size) 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_ci/* prevent the inclusion of the xz-preboot MM headers */ 5162306a36Sopenharmony_ci#define DECOMPR_MM_H 5262306a36Sopenharmony_ci#define memmove memmove 5362306a36Sopenharmony_ci#define XZ_EXTERN static 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci/* xz.h needs to be included directly since we need enum xz_mode */ 5662306a36Sopenharmony_ci#include "../../../include/linux/xz.h" 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ci#undef XZ_EXTERN 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ci#endif 61