diff options
author | H. Peter Anvin <hpa@linux.intel.com> | 2012-03-28 16:11:36 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2012-03-28 16:11:36 -0400 |
commit | a9aff3eaaf0966c2a1bb3717d811363d81e52c76 (patch) | |
tree | b442c3d554ff83529deb1783996f6359aebf07ab | |
parent | e47bb0bda46bf50f81671db502d0c903e0a32604 (diff) | |
parent | a51f4047758d2bcd099ea113b833ed380f4024ba (diff) |
Merge branch x86/build into x86/efi and fix up arch/x86/boot/tools/build.c
Reason for merge:
The updates to the EFI boot stub generation conflicted with the
changes to properly use the get/put_unaligned_le*() macros to
generate images.
This merge commit completes the conversion in
arch/x86/boot/tools/build.c including the places in the code
which had been changed on the x86/efi branch.
Resolved Conflicts:
arch/x86/boot/tools/build.c
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r-- | arch/x86/boot/Makefile | 5 | ||||
-rw-r--r-- | arch/x86/boot/compressed/Makefile | 1 | ||||
-rw-r--r-- | arch/x86/boot/compressed/mkpiggy.c | 11 | ||||
-rw-r--r-- | arch/x86/boot/compressed/relocs.c | 6 | ||||
-rw-r--r-- | arch/x86/boot/tools/build.c | 47 | ||||
-rw-r--r-- | tools/include/tools/be_byteshift.h | 70 | ||||
-rw-r--r-- | tools/include/tools/le_byteshift.h | 70 | ||||
-rw-r--r-- | tools/usb/Makefile | 2 | ||||
-rw-r--r-- | tools/usb/ffs-test.c | 29 |
9 files changed, 172 insertions, 69 deletions
diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile index 95365a82b6a..3e02148bb77 100644 --- a/arch/x86/boot/Makefile +++ b/arch/x86/boot/Makefile | |||
@@ -37,8 +37,9 @@ setup-y += video-bios.o | |||
37 | targets += $(setup-y) | 37 | targets += $(setup-y) |
38 | hostprogs-y := mkcpustr tools/build | 38 | hostprogs-y := mkcpustr tools/build |
39 | 39 | ||
40 | HOST_EXTRACFLAGS += $(LINUXINCLUDE) | 40 | HOSTCFLAGS_mkcpustr.o := -I$(srctree)/arch/$(SRCARCH)/include |
41 | 41 | HOST_EXTRACFLAGS += -I$(objtree)/include -I$(srctree)/tools/include \ | |
42 | -include $(srctree)/include/linux/kconfig.h | ||
42 | $(obj)/cpu.o: $(obj)/cpustr.h | 43 | $(obj)/cpu.o: $(obj)/cpustr.h |
43 | 44 | ||
44 | quiet_cmd_cpustr = CPUSTR $@ | 45 | quiet_cmd_cpustr = CPUSTR $@ |
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile index b123b9a8f5b..fd55a2ff3ad 100644 --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile | |||
@@ -22,6 +22,7 @@ LDFLAGS := -m elf_$(UTS_MACHINE) | |||
22 | LDFLAGS_vmlinux := -T | 22 | LDFLAGS_vmlinux := -T |
23 | 23 | ||
24 | hostprogs-y := mkpiggy | 24 | hostprogs-y := mkpiggy |
25 | HOST_EXTRACFLAGS += -I$(srctree)/tools/include | ||
25 | 26 | ||
26 | VMLINUX_OBJS = $(obj)/vmlinux.lds $(obj)/head_$(BITS).o $(obj)/misc.o \ | 27 | VMLINUX_OBJS = $(obj)/vmlinux.lds $(obj)/head_$(BITS).o $(obj)/misc.o \ |
27 | $(obj)/string.o $(obj)/cmdline.o $(obj)/early_serial_console.o \ | 28 | $(obj)/string.o $(obj)/cmdline.o $(obj)/early_serial_console.o \ |
diff --git a/arch/x86/boot/compressed/mkpiggy.c b/arch/x86/boot/compressed/mkpiggy.c index 46a82388243..958a641483d 100644 --- a/arch/x86/boot/compressed/mkpiggy.c +++ b/arch/x86/boot/compressed/mkpiggy.c | |||
@@ -29,14 +29,7 @@ | |||
29 | #include <stdio.h> | 29 | #include <stdio.h> |
30 | #include <string.h> | 30 | #include <string.h> |
31 | #include <inttypes.h> | 31 | #include <inttypes.h> |
32 | 32 | #include <tools/le_byteshift.h> | |
33 | static uint32_t getle32(const void *p) | ||
34 | { | ||
35 | const uint8_t *cp = p; | ||
36 | |||
37 | return (uint32_t)cp[0] + ((uint32_t)cp[1] << 8) + | ||
38 | ((uint32_t)cp[2] << 16) + ((uint32_t)cp[3] << 24); | ||
39 | } | ||
40 | 33 | ||
41 | int main(int argc, char *argv[]) | 34 | int main(int argc, char *argv[]) |
42 | { | 35 | { |
@@ -69,7 +62,7 @@ int main(int argc, char *argv[]) | |||
69 | } | 62 | } |
70 | 63 | ||
71 | ilen = ftell(f); | 64 | ilen = ftell(f); |
72 | olen = getle32(&olen); | 65 | olen = get_unaligned_le32(&olen); |
73 | fclose(f); | 66 | fclose(f); |
74 | 67 | ||
75 | /* | 68 | /* |
diff --git a/arch/x86/boot/compressed/relocs.c b/arch/x86/boot/compressed/relocs.c index 89bbf4e4d05..d3c0b027766 100644 --- a/arch/x86/boot/compressed/relocs.c +++ b/arch/x86/boot/compressed/relocs.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #define USE_BSD | 10 | #define USE_BSD |
11 | #include <endian.h> | 11 | #include <endian.h> |
12 | #include <regex.h> | 12 | #include <regex.h> |
13 | #include <tools/le_byteshift.h> | ||
13 | 14 | ||
14 | static void die(char *fmt, ...); | 15 | static void die(char *fmt, ...); |
15 | 16 | ||
@@ -605,10 +606,7 @@ static void emit_relocs(int as_text) | |||
605 | fwrite("\0\0\0\0", 4, 1, stdout); | 606 | fwrite("\0\0\0\0", 4, 1, stdout); |
606 | /* Now print each relocation */ | 607 | /* Now print each relocation */ |
607 | for (i = 0; i < reloc_count; i++) { | 608 | for (i = 0; i < reloc_count; i++) { |
608 | buf[0] = (relocs[i] >> 0) & 0xff; | 609 | put_unaligned_le32(relocs[i], buf); |
609 | buf[1] = (relocs[i] >> 8) & 0xff; | ||
610 | buf[2] = (relocs[i] >> 16) & 0xff; | ||
611 | buf[3] = (relocs[i] >> 24) & 0xff; | ||
612 | fwrite(buf, 4, 1, stdout); | 610 | fwrite(buf, 4, 1, stdout); |
613 | } | 611 | } |
614 | } | 612 | } |
diff --git a/arch/x86/boot/tools/build.c b/arch/x86/boot/tools/build.c index 2aeab3dc9e5..45963889891 100644 --- a/arch/x86/boot/tools/build.c +++ b/arch/x86/boot/tools/build.c | |||
@@ -29,18 +29,18 @@ | |||
29 | #include <stdarg.h> | 29 | #include <stdarg.h> |
30 | #include <sys/types.h> | 30 | #include <sys/types.h> |
31 | #include <sys/stat.h> | 31 | #include <sys/stat.h> |
32 | #include <sys/sysmacros.h> | ||
33 | #include <unistd.h> | 32 | #include <unistd.h> |
34 | #include <fcntl.h> | 33 | #include <fcntl.h> |
35 | #include <sys/mman.h> | 34 | #include <sys/mman.h> |
36 | #include <asm/boot.h> | 35 | #include <tools/le_byteshift.h> |
37 | 36 | ||
38 | typedef unsigned char u8; | 37 | typedef unsigned char u8; |
39 | typedef unsigned short u16; | 38 | typedef unsigned short u16; |
40 | typedef unsigned long u32; | 39 | typedef unsigned int u32; |
41 | 40 | ||
42 | #define DEFAULT_MAJOR_ROOT 0 | 41 | #define DEFAULT_MAJOR_ROOT 0 |
43 | #define DEFAULT_MINOR_ROOT 0 | 42 | #define DEFAULT_MINOR_ROOT 0 |
43 | #define DEFAULT_ROOT_DEV (DEFAULT_MAJOR_ROOT << 8 | DEFAULT_MINOR_ROOT) | ||
44 | 44 | ||
45 | /* Minimal number of setup sectors */ | 45 | /* Minimal number of setup sectors */ |
46 | #define SETUP_SECT_MIN 5 | 46 | #define SETUP_SECT_MIN 5 |
@@ -159,7 +159,7 @@ int main(int argc, char ** argv) | |||
159 | die("read-error on `setup'"); | 159 | die("read-error on `setup'"); |
160 | if (c < 1024) | 160 | if (c < 1024) |
161 | die("The setup must be at least 1024 bytes"); | 161 | die("The setup must be at least 1024 bytes"); |
162 | if (buf[510] != 0x55 || buf[511] != 0xaa) | 162 | if (get_unaligned_le16(&buf[510]) != 0xAA55) |
163 | die("Boot block hasn't got boot flag (0xAA55)"); | 163 | die("Boot block hasn't got boot flag (0xAA55)"); |
164 | fclose(file); | 164 | fclose(file); |
165 | 165 | ||
@@ -171,8 +171,7 @@ int main(int argc, char ** argv) | |||
171 | memset(buf+c, 0, i-c); | 171 | memset(buf+c, 0, i-c); |
172 | 172 | ||
173 | /* Set the default root device */ | 173 | /* Set the default root device */ |
174 | buf[508] = DEFAULT_MINOR_ROOT; | 174 | put_unaligned_le16(DEFAULT_ROOT_DEV, &buf[508]); |
175 | buf[509] = DEFAULT_MAJOR_ROOT; | ||
176 | 175 | ||
177 | fprintf(stderr, "Setup is %d bytes (padded to %d bytes).\n", c, i); | 176 | fprintf(stderr, "Setup is %d bytes (padded to %d bytes).\n", c, i); |
178 | 177 | ||
@@ -192,18 +191,15 @@ int main(int argc, char ** argv) | |||
192 | 191 | ||
193 | /* Patch the setup code with the appropriate size parameters */ | 192 | /* Patch the setup code with the appropriate size parameters */ |
194 | buf[0x1f1] = setup_sectors-1; | 193 | buf[0x1f1] = setup_sectors-1; |
195 | buf[0x1f4] = sys_size; | 194 | put_unaligned_le32(sys_size, &buf[0x1f4]); |
196 | buf[0x1f5] = sys_size >> 8; | ||
197 | buf[0x1f6] = sys_size >> 16; | ||
198 | buf[0x1f7] = sys_size >> 24; | ||
199 | 195 | ||
200 | #ifdef CONFIG_EFI_STUB | 196 | #ifdef CONFIG_EFI_STUB |
201 | file_sz = sz + i + ((sys_size * 16) - sz); | 197 | file_sz = sz + i + ((sys_size * 16) - sz); |
202 | 198 | ||
203 | pe_header = *(unsigned int *)&buf[0x3c]; | 199 | pe_header = get_unaligned_le32(&buf[0x3c]); |
204 | 200 | ||
205 | /* Size of image */ | 201 | /* Size of image */ |
206 | *(unsigned int *)&buf[pe_header + 0x50] = file_sz; | 202 | put_unaligned_le32(file_sz, &buf[pe_header + 0x50]); |
207 | 203 | ||
208 | /* | 204 | /* |
209 | * Subtract the size of the first section (512 bytes) which | 205 | * Subtract the size of the first section (512 bytes) which |
@@ -213,42 +209,42 @@ int main(int argc, char ** argv) | |||
213 | file_sz -= 512; | 209 | file_sz -= 512; |
214 | 210 | ||
215 | /* Size of code */ | 211 | /* Size of code */ |
216 | *(unsigned int *)&buf[pe_header + 0x1c] = file_sz; | 212 | put_unaligned_le32(file_sz, &buf[pe_header + 0x1c]); |
217 | 213 | ||
218 | #ifdef CONFIG_X86_32 | 214 | #ifdef CONFIG_X86_32 |
219 | /* Address of entry point */ | 215 | /* Address of entry point */ |
220 | *(unsigned int *)&buf[pe_header + 0x28] = i; | 216 | put_unaligned_le32(i, &buf[pe_header + 0x28]); |
221 | 217 | ||
222 | /* .text size */ | 218 | /* .text size */ |
223 | *(unsigned int *)&buf[pe_header + 0xb0] = file_sz; | 219 | put_unaligned_le32(file_sz, &buf[pe_header + 0xb0]); |
224 | 220 | ||
225 | /* .text vma */ | 221 | /* .text vma */ |
226 | *(unsigned int *)&buf[pe_header + 0xb4] = 0x200; | 222 | put_unaligned_le32(0x200, &buf[pe_header + 0xb4]); |
227 | 223 | ||
228 | /* .text size of initialised data */ | 224 | /* .text size of initialised data */ |
229 | *(unsigned int *)&buf[pe_header + 0xb8] = file_sz; | 225 | put_unaligned_le32(file_sz, &buf[pe_header + 0xb8]); |
230 | 226 | ||
231 | /* .text file offset */ | 227 | /* .text file offset */ |
232 | *(unsigned int *)&buf[pe_header + 0xbc] = 0x200; | 228 | put_unaligned_le32(0x200, &buf[pe_header + 0xbc]); |
233 | #else | 229 | #else |
234 | /* | 230 | /* |
235 | * Address of entry point. startup_32 is at the beginning and | 231 | * Address of entry point. startup_32 is at the beginning and |
236 | * the 64-bit entry point (startup_64) is always 512 bytes | 232 | * the 64-bit entry point (startup_64) is always 512 bytes |
237 | * after. | 233 | * after. |
238 | */ | 234 | */ |
239 | *(unsigned int *)&buf[pe_header + 0x28] = i + 512; | 235 | put_unaligned_le32(i + 512, &buf[pe_header + 0x28]); |
240 | 236 | ||
241 | /* .text size */ | 237 | /* .text size */ |
242 | *(unsigned int *)&buf[pe_header + 0xc0] = file_sz; | 238 | put_unaligned_le32(file_sz, &buf[pe_header + 0xc0]); |
243 | 239 | ||
244 | /* .text vma */ | 240 | /* .text vma */ |
245 | *(unsigned int *)&buf[pe_header + 0xc4] = 0x200; | 241 | put_unaligned_le32(0x200, &buf[pe_header + 0xc4]); |
246 | 242 | ||
247 | /* .text size of initialised data */ | 243 | /* .text size of initialised data */ |
248 | *(unsigned int *)&buf[pe_header + 0xc8] = file_sz; | 244 | put_unaligned_le32(file_sz, &buf[pe_header + 0xc8]); |
249 | 245 | ||
250 | /* .text file offset */ | 246 | /* .text file offset */ |
251 | *(unsigned int *)&buf[pe_header + 0xcc] = 0x200; | 247 | put_unaligned_le32(0x200, &buf[pe_header + 0xcc]); |
252 | #endif /* CONFIG_X86_32 */ | 248 | #endif /* CONFIG_X86_32 */ |
253 | #endif /* CONFIG_EFI_STUB */ | 249 | #endif /* CONFIG_EFI_STUB */ |
254 | 250 | ||
@@ -269,8 +265,9 @@ int main(int argc, char ** argv) | |||
269 | } | 265 | } |
270 | 266 | ||
271 | /* Write the CRC */ | 267 | /* Write the CRC */ |
272 | fprintf(stderr, "CRC %lx\n", crc); | 268 | fprintf(stderr, "CRC %x\n", crc); |
273 | if (fwrite(&crc, 1, 4, stdout) != 4) | 269 | put_unaligned_le32(crc, buf); |
270 | if (fwrite(buf, 1, 4, stdout) != 4) | ||
274 | die("Writing CRC failed"); | 271 | die("Writing CRC failed"); |
275 | 272 | ||
276 | close(fd); | 273 | close(fd); |
diff --git a/tools/include/tools/be_byteshift.h b/tools/include/tools/be_byteshift.h new file mode 100644 index 00000000000..f4912e2668b --- /dev/null +++ b/tools/include/tools/be_byteshift.h | |||
@@ -0,0 +1,70 @@ | |||
1 | #ifndef _TOOLS_BE_BYTESHIFT_H | ||
2 | #define _TOOLS_BE_BYTESHIFT_H | ||
3 | |||
4 | #include <linux/types.h> | ||
5 | |||
6 | static inline __u16 __get_unaligned_be16(const __u8 *p) | ||
7 | { | ||
8 | return p[0] << 8 | p[1]; | ||
9 | } | ||
10 | |||
11 | static inline __u32 __get_unaligned_be32(const __u8 *p) | ||
12 | { | ||
13 | return p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3]; | ||
14 | } | ||
15 | |||
16 | static inline __u64 __get_unaligned_be64(const __u8 *p) | ||
17 | { | ||
18 | return (__u64)__get_unaligned_be32(p) << 32 | | ||
19 | __get_unaligned_be32(p + 4); | ||
20 | } | ||
21 | |||
22 | static inline void __put_unaligned_be16(__u16 val, __u8 *p) | ||
23 | { | ||
24 | *p++ = val >> 8; | ||
25 | *p++ = val; | ||
26 | } | ||
27 | |||
28 | static inline void __put_unaligned_be32(__u32 val, __u8 *p) | ||
29 | { | ||
30 | __put_unaligned_be16(val >> 16, p); | ||
31 | __put_unaligned_be16(val, p + 2); | ||
32 | } | ||
33 | |||
34 | static inline void __put_unaligned_be64(__u64 val, __u8 *p) | ||
35 | { | ||
36 | __put_unaligned_be32(val >> 32, p); | ||
37 | __put_unaligned_be32(val, p + 4); | ||
38 | } | ||
39 | |||
40 | static inline __u16 get_unaligned_be16(const void *p) | ||
41 | { | ||
42 | return __get_unaligned_be16((const __u8 *)p); | ||
43 | } | ||
44 | |||
45 | static inline __u32 get_unaligned_be32(const void *p) | ||
46 | { | ||
47 | return __get_unaligned_be32((const __u8 *)p); | ||
48 | } | ||
49 | |||
50 | static inline __u64 get_unaligned_be64(const void *p) | ||
51 | { | ||
52 | return __get_unaligned_be64((const __u8 *)p); | ||
53 | } | ||
54 | |||
55 | static inline void put_unaligned_be16(__u16 val, void *p) | ||
56 | { | ||
57 | __put_unaligned_be16(val, p); | ||
58 | } | ||
59 | |||
60 | static inline void put_unaligned_be32(__u32 val, void *p) | ||
61 | { | ||
62 | __put_unaligned_be32(val, p); | ||
63 | } | ||
64 | |||
65 | static inline void put_unaligned_be64(__u64 val, void *p) | ||
66 | { | ||
67 | __put_unaligned_be64(val, p); | ||
68 | } | ||
69 | |||
70 | #endif /* _TOOLS_BE_BYTESHIFT_H */ | ||
diff --git a/tools/include/tools/le_byteshift.h b/tools/include/tools/le_byteshift.h new file mode 100644 index 00000000000..c99d45a68bd --- /dev/null +++ b/tools/include/tools/le_byteshift.h | |||
@@ -0,0 +1,70 @@ | |||
1 | #ifndef _TOOLS_LE_BYTESHIFT_H | ||
2 | #define _TOOLS_LE_BYTESHIFT_H | ||
3 | |||
4 | #include <linux/types.h> | ||
5 | |||
6 | static inline __u16 __get_unaligned_le16(const __u8 *p) | ||
7 | { | ||
8 | return p[0] | p[1] << 8; | ||
9 | } | ||
10 | |||
11 | static inline __u32 __get_unaligned_le32(const __u8 *p) | ||
12 | { | ||
13 | return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24; | ||
14 | } | ||
15 | |||
16 | static inline __u64 __get_unaligned_le64(const __u8 *p) | ||
17 | { | ||
18 | return (__u64)__get_unaligned_le32(p + 4) << 32 | | ||
19 | __get_unaligned_le32(p); | ||
20 | } | ||
21 | |||
22 | static inline void __put_unaligned_le16(__u16 val, __u8 *p) | ||
23 | { | ||
24 | *p++ = val; | ||
25 | *p++ = val >> 8; | ||
26 | } | ||
27 | |||
28 | static inline void __put_unaligned_le32(__u32 val, __u8 *p) | ||
29 | { | ||
30 | __put_unaligned_le16(val >> 16, p + 2); | ||
31 | __put_unaligned_le16(val, p); | ||
32 | } | ||
33 | |||
34 | static inline void __put_unaligned_le64(__u64 val, __u8 *p) | ||
35 | { | ||
36 | __put_unaligned_le32(val >> 32, p + 4); | ||
37 | __put_unaligned_le32(val, p); | ||
38 | } | ||
39 | |||
40 | static inline __u16 get_unaligned_le16(const void *p) | ||
41 | { | ||
42 | return __get_unaligned_le16((const __u8 *)p); | ||
43 | } | ||
44 | |||
45 | static inline __u32 get_unaligned_le32(const void *p) | ||
46 | { | ||
47 | return __get_unaligned_le32((const __u8 *)p); | ||
48 | } | ||
49 | |||
50 | static inline __u64 get_unaligned_le64(const void *p) | ||
51 | { | ||
52 | return __get_unaligned_le64((const __u8 *)p); | ||
53 | } | ||
54 | |||
55 | static inline void put_unaligned_le16(__u16 val, void *p) | ||
56 | { | ||
57 | __put_unaligned_le16(val, p); | ||
58 | } | ||
59 | |||
60 | static inline void put_unaligned_le32(__u32 val, void *p) | ||
61 | { | ||
62 | __put_unaligned_le32(val, p); | ||
63 | } | ||
64 | |||
65 | static inline void put_unaligned_le64(__u64 val, void *p) | ||
66 | { | ||
67 | __put_unaligned_le64(val, p); | ||
68 | } | ||
69 | |||
70 | #endif /* _TOOLS_LE_BYTESHIFT_H */ | ||
diff --git a/tools/usb/Makefile b/tools/usb/Makefile index 8b704af1434..396d6c44e9d 100644 --- a/tools/usb/Makefile +++ b/tools/usb/Makefile | |||
@@ -3,7 +3,7 @@ | |||
3 | CC = $(CROSS_COMPILE)gcc | 3 | CC = $(CROSS_COMPILE)gcc |
4 | PTHREAD_LIBS = -lpthread | 4 | PTHREAD_LIBS = -lpthread |
5 | WARNINGS = -Wall -Wextra | 5 | WARNINGS = -Wall -Wextra |
6 | CFLAGS = $(WARNINGS) -g $(PTHREAD_LIBS) | 6 | CFLAGS = $(WARNINGS) -g $(PTHREAD_LIBS) -I../include |
7 | 7 | ||
8 | all: testusb ffs-test | 8 | all: testusb ffs-test |
9 | %: %.c | 9 | %: %.c |
diff --git a/tools/usb/ffs-test.c b/tools/usb/ffs-test.c index b9c79863169..384f47a5727 100644 --- a/tools/usb/ffs-test.c +++ b/tools/usb/ffs-test.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <sys/stat.h> | 36 | #include <sys/stat.h> |
37 | #include <sys/types.h> | 37 | #include <sys/types.h> |
38 | #include <unistd.h> | 38 | #include <unistd.h> |
39 | #include <tools/le_byteshift.h> | ||
39 | 40 | ||
40 | #include "../../include/linux/usb/functionfs.h" | 41 | #include "../../include/linux/usb/functionfs.h" |
41 | 42 | ||
@@ -47,34 +48,6 @@ | |||
47 | #define le32_to_cpu(x) le32toh(x) | 48 | #define le32_to_cpu(x) le32toh(x) |
48 | #define le16_to_cpu(x) le16toh(x) | 49 | #define le16_to_cpu(x) le16toh(x) |
49 | 50 | ||
50 | static inline __u16 get_unaligned_le16(const void *_ptr) | ||
51 | { | ||
52 | const __u8 *ptr = _ptr; | ||
53 | return ptr[0] | (ptr[1] << 8); | ||
54 | } | ||
55 | |||
56 | static inline __u32 get_unaligned_le32(const void *_ptr) | ||
57 | { | ||
58 | const __u8 *ptr = _ptr; | ||
59 | return ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24); | ||
60 | } | ||
61 | |||
62 | static inline void put_unaligned_le16(__u16 val, void *_ptr) | ||
63 | { | ||
64 | __u8 *ptr = _ptr; | ||
65 | *ptr++ = val; | ||
66 | *ptr++ = val >> 8; | ||
67 | } | ||
68 | |||
69 | static inline void put_unaligned_le32(__u32 val, void *_ptr) | ||
70 | { | ||
71 | __u8 *ptr = _ptr; | ||
72 | *ptr++ = val; | ||
73 | *ptr++ = val >> 8; | ||
74 | *ptr++ = val >> 16; | ||
75 | *ptr++ = val >> 24; | ||
76 | } | ||
77 | |||
78 | 51 | ||
79 | /******************** Messages and Errors ***********************************/ | 52 | /******************** Messages and Errors ***********************************/ |
80 | 53 | ||