1 #ifndef __ASM_SH_UNALIGNED_SH4A_H
2 #define __ASM_SH_UNALIGNED_SH4A_H
22 #include <linux/types.h>
23 #include <asm/byteorder.h>
25 static inline u16 sh4a_get_unaligned_cpu16(
const u8 *
p)
27 #ifdef __LITTLE_ENDIAN
28 return p[0] | p[1] << 8;
30 return p[0] << 8 | p[1];
52 static inline u64 sh4a_get_unaligned_cpu64(
const u8 *p)
54 #ifdef __LITTLE_ENDIAN
55 return (
u64)sh4a_get_unaligned_cpu32(p + 4) << 32 |
56 sh4a_get_unaligned_cpu32(p);
58 return (
u64)sh4a_get_unaligned_cpu32(p) << 32 |
59 sh4a_get_unaligned_cpu32(p + 4);
63 static inline u16 get_unaligned_le16(
const void *p)
78 static inline u16 get_unaligned_be16(
const void *p)
93 static inline void nonnative_put_le16(
u16 val,
u8 *p)
99 static inline void nonnative_put_le32(
u32 val,
u8 *p)
101 nonnative_put_le16(val, p);
102 nonnative_put_le16(val >> 16, p + 2);
105 static inline void nonnative_put_le64(
u64 val,
u8 *p)
107 nonnative_put_le32(val, p);
108 nonnative_put_le32(val >> 32, p + 4);
111 static inline void nonnative_put_be16(
u16 val,
u8 *p)
117 static inline void nonnative_put_be32(
u32 val,
u8 *p)
119 nonnative_put_be16(val >> 16, p);
120 nonnative_put_be16(val, p + 2);
123 static inline void nonnative_put_be64(
u64 val,
u8 *p)
125 nonnative_put_be32(val >> 32, p);
126 nonnative_put_be32(val, p + 4);
129 static inline void put_unaligned_le16(
u16 val,
void *p)
131 #ifdef __LITTLE_ENDIAN
132 __put_unaligned_cpu16(val, p);
134 nonnative_put_le16(val, p);
140 #ifdef __LITTLE_ENDIAN
141 __put_unaligned_cpu32(val, p);
143 nonnative_put_le32(val, p);
149 #ifdef __LITTLE_ENDIAN
150 __put_unaligned_cpu64(val, p);
152 nonnative_put_le64(val, p);
156 static inline void put_unaligned_be16(
u16 val,
void *p)
159 __put_unaligned_cpu16(val, p);
161 nonnative_put_be16(val, p);
168 __put_unaligned_cpu32(val, p);
170 nonnative_put_be32(val, p);
177 __put_unaligned_cpu64(val, p);
179 nonnative_put_be64(val, p);
190 #ifdef __LITTLE_ENDIAN
191 # define get_unaligned __get_unaligned_le
192 # define put_unaligned __put_unaligned_le
194 # define get_unaligned __get_unaligned_be
195 # define put_unaligned __put_unaligned_be