mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-14 11:26:43 +07:00
2fa4341074
When unaligned accesses are required for uncompressing a kernel (such as for LZO decompression on ARM in a patch that follows), including <linux/kernel.h> causes issues as it brings in a lot of things that are not available in the decompression environment. linux/kernel.h brings at least: extern int console_printk[]; extern const char hex_asc[]; which causes errors at link-time as they are not available when compiling the pre-boot environement. There are also a few others: arch/arm/boot/compressed/misc.o: In function `valid_user_regs': arch/arm/include/asm/ptrace.h:158: undefined reference to `elf_hwcap' arch/arm/boot/compressed/misc.o: In function `console_silent': include/linux/kernel.h:292: undefined reference to `console_printk' arch/arm/boot/compressed/misc.o: In function `console_verbose': include/linux/kernel.h:297: undefined reference to `console_printk' arch/arm/boot/compressed/misc.o: In function `pack_hex_byte': include/linux/kernel.h:360: undefined reference to `hex_asc' arch/arm/boot/compressed/misc.o: In function `hweight_long': include/linux/bitops.h:45: undefined reference to `hweight32' arch/arm/boot/compressed/misc.o: In function `__cmpxchg_local_generic': include/asm-generic/cmpxchg-local.h:21: undefined reference to `wrong_size_cmpxchg' include/asm-generic/cmpxchg-local.h:42: undefined reference to `wrong_size_cmpxchg' arch/arm/boot/compressed/misc.o: In function `__xchg': arch/arm/include/asm/system.h:309: undefined reference to `__bad_xchg' However, those files apparently use nothing from <linux/kernel.h>, all they need is the declaration of types such as u32 or u64, so <linux/types.h> should be enough Signed-off-by: Albin Tonnerre <albin.tonnerre@free-electrons.com> Cc: Sam Ravnborg <sam@ravnborg.org> Cc: Russell King <rmk@arm.linux.org.uk> Cc: Ingo Molnar <mingo@elte.hu> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Phillip Lougher <phillip@lougher.demon.co.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
71 lines
1.4 KiB
C
71 lines
1.4 KiB
C
#ifndef _LINUX_UNALIGNED_BE_BYTESHIFT_H
|
|
#define _LINUX_UNALIGNED_BE_BYTESHIFT_H
|
|
|
|
#include <linux/types.h>
|
|
|
|
static inline u16 __get_unaligned_be16(const u8 *p)
|
|
{
|
|
return p[0] << 8 | p[1];
|
|
}
|
|
|
|
static inline u32 __get_unaligned_be32(const u8 *p)
|
|
{
|
|
return p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
|
|
}
|
|
|
|
static inline u64 __get_unaligned_be64(const u8 *p)
|
|
{
|
|
return (u64)__get_unaligned_be32(p) << 32 |
|
|
__get_unaligned_be32(p + 4);
|
|
}
|
|
|
|
static inline void __put_unaligned_be16(u16 val, u8 *p)
|
|
{
|
|
*p++ = val >> 8;
|
|
*p++ = val;
|
|
}
|
|
|
|
static inline void __put_unaligned_be32(u32 val, u8 *p)
|
|
{
|
|
__put_unaligned_be16(val >> 16, p);
|
|
__put_unaligned_be16(val, p + 2);
|
|
}
|
|
|
|
static inline void __put_unaligned_be64(u64 val, u8 *p)
|
|
{
|
|
__put_unaligned_be32(val >> 32, p);
|
|
__put_unaligned_be32(val, p + 4);
|
|
}
|
|
|
|
static inline u16 get_unaligned_be16(const void *p)
|
|
{
|
|
return __get_unaligned_be16((const u8 *)p);
|
|
}
|
|
|
|
static inline u32 get_unaligned_be32(const void *p)
|
|
{
|
|
return __get_unaligned_be32((const u8 *)p);
|
|
}
|
|
|
|
static inline u64 get_unaligned_be64(const void *p)
|
|
{
|
|
return __get_unaligned_be64((const u8 *)p);
|
|
}
|
|
|
|
static inline void put_unaligned_be16(u16 val, void *p)
|
|
{
|
|
__put_unaligned_be16(val, p);
|
|
}
|
|
|
|
static inline void put_unaligned_be32(u32 val, void *p)
|
|
{
|
|
__put_unaligned_be32(val, p);
|
|
}
|
|
|
|
static inline void put_unaligned_be64(u64 val, void *p)
|
|
{
|
|
__put_unaligned_be64(val, p);
|
|
}
|
|
|
|
#endif /* _LINUX_UNALIGNED_BE_BYTESHIFT_H */
|