diff options
author | Jeremy Kerr <jeremy.kerr@canonical.com> | 2010-01-30 06:14:19 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2010-02-09 10:34:10 -0500 |
commit | 087f79c48c090a2c0cd9ee45231d63290d2036d2 (patch) | |
tree | c5d96d02ed64447ce36a68fe781a73a42a8ad19d | |
parent | 337148812f97368a8ec4a69f1691e4c5ce3af494 (diff) |
of/flattree: endian-convert members of boot_param_header
The boot_param_header has big-endian fields, so change the types to
__be32, and perform endian conversion when we access them.
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
-rw-r--r-- | arch/powerpc/kernel/prom.c | 2 | ||||
-rw-r--r-- | drivers/of/fdt.c | 16 | ||||
-rw-r--r-- | include/linux/of_fdt.h | 20 |
3 files changed, 19 insertions, 19 deletions
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index 40fce1c2f33b..43c78d74ddcb 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c | |||
@@ -98,7 +98,7 @@ static void __init move_device_tree(void) | |||
98 | DBG("-> move_device_tree\n"); | 98 | DBG("-> move_device_tree\n"); |
99 | 99 | ||
100 | start = __pa(initial_boot_params); | 100 | start = __pa(initial_boot_params); |
101 | size = initial_boot_params->totalsize; | 101 | size = be32_to_cpu(initial_boot_params->totalsize); |
102 | 102 | ||
103 | if ((memory_limit && (start + size) > memory_limit) || | 103 | if ((memory_limit && (start + size) > memory_limit) || |
104 | overlaps_crashkernel(start, size)) { | 104 | overlaps_crashkernel(start, size)) { |
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 5c5f03ef7f06..18d282fefe58 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c | |||
@@ -28,7 +28,7 @@ struct boot_param_header *initial_boot_params; | |||
28 | char *find_flat_dt_string(u32 offset) | 28 | char *find_flat_dt_string(u32 offset) |
29 | { | 29 | { |
30 | return ((char *)initial_boot_params) + | 30 | return ((char *)initial_boot_params) + |
31 | initial_boot_params->off_dt_strings + offset; | 31 | be32_to_cpu(initial_boot_params->off_dt_strings) + offset; |
32 | } | 32 | } |
33 | 33 | ||
34 | /** | 34 | /** |
@@ -46,7 +46,7 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node, | |||
46 | void *data) | 46 | void *data) |
47 | { | 47 | { |
48 | unsigned long p = ((unsigned long)initial_boot_params) + | 48 | unsigned long p = ((unsigned long)initial_boot_params) + |
49 | initial_boot_params->off_dt_struct; | 49 | be32_to_cpu(initial_boot_params->off_dt_struct); |
50 | int rc = 0; | 50 | int rc = 0; |
51 | int depth = -1; | 51 | int depth = -1; |
52 | 52 | ||
@@ -66,7 +66,7 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node, | |||
66 | if (tag == OF_DT_PROP) { | 66 | if (tag == OF_DT_PROP) { |
67 | u32 sz = be32_to_cpup((__be32 *)p); | 67 | u32 sz = be32_to_cpup((__be32 *)p); |
68 | p += 8; | 68 | p += 8; |
69 | if (initial_boot_params->version < 0x10) | 69 | if (be32_to_cpu(initial_boot_params->version) < 0x10) |
70 | p = _ALIGN(p, sz >= 8 ? 8 : 4); | 70 | p = _ALIGN(p, sz >= 8 ? 8 : 4); |
71 | p += sz; | 71 | p += sz; |
72 | p = _ALIGN(p, 4); | 72 | p = _ALIGN(p, 4); |
@@ -101,7 +101,7 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node, | |||
101 | unsigned long __init of_get_flat_dt_root(void) | 101 | unsigned long __init of_get_flat_dt_root(void) |
102 | { | 102 | { |
103 | unsigned long p = ((unsigned long)initial_boot_params) + | 103 | unsigned long p = ((unsigned long)initial_boot_params) + |
104 | initial_boot_params->off_dt_struct; | 104 | be32_to_cpu(initial_boot_params->off_dt_struct); |
105 | 105 | ||
106 | while (be32_to_cpup((__be32 *)p) == OF_DT_NOP) | 106 | while (be32_to_cpup((__be32 *)p) == OF_DT_NOP) |
107 | p += 4; | 107 | p += 4; |
@@ -135,7 +135,7 @@ void *__init of_get_flat_dt_prop(unsigned long node, const char *name, | |||
135 | sz = be32_to_cpup((__be32 *)p); | 135 | sz = be32_to_cpup((__be32 *)p); |
136 | noff = be32_to_cpup((__be32 *)(p + 4)); | 136 | noff = be32_to_cpup((__be32 *)(p + 4)); |
137 | p += 8; | 137 | p += 8; |
138 | if (initial_boot_params->version < 0x10) | 138 | if (be32_to_cpu(initial_boot_params->version) < 0x10) |
139 | p = _ALIGN(p, sz >= 8 ? 8 : 4); | 139 | p = _ALIGN(p, sz >= 8 ? 8 : 4); |
140 | 140 | ||
141 | nstr = find_flat_dt_string(noff); | 141 | nstr = find_flat_dt_string(noff); |
@@ -296,7 +296,7 @@ unsigned long __init unflatten_dt_node(unsigned long mem, | |||
296 | sz = be32_to_cpup((__be32 *)(*p)); | 296 | sz = be32_to_cpup((__be32 *)(*p)); |
297 | noff = be32_to_cpup((__be32 *)((*p) + 4)); | 297 | noff = be32_to_cpup((__be32 *)((*p) + 4)); |
298 | *p += 8; | 298 | *p += 8; |
299 | if (initial_boot_params->version < 0x10) | 299 | if (be32_to_cpu(initial_boot_params->version) < 0x10) |
300 | *p = _ALIGN(*p, sz >= 8 ? 8 : 4); | 300 | *p = _ALIGN(*p, sz >= 8 ? 8 : 4); |
301 | 301 | ||
302 | pname = find_flat_dt_string(noff); | 302 | pname = find_flat_dt_string(noff); |
@@ -544,7 +544,7 @@ void __init unflatten_device_tree(void) | |||
544 | 544 | ||
545 | /* First pass, scan for size */ | 545 | /* First pass, scan for size */ |
546 | start = ((unsigned long)initial_boot_params) + | 546 | start = ((unsigned long)initial_boot_params) + |
547 | initial_boot_params->off_dt_struct; | 547 | be32_to_cpu(initial_boot_params->off_dt_struct); |
548 | size = unflatten_dt_node(0, &start, NULL, NULL, 0); | 548 | size = unflatten_dt_node(0, &start, NULL, NULL, 0); |
549 | size = (size | 3) + 1; | 549 | size = (size | 3) + 1; |
550 | 550 | ||
@@ -560,7 +560,7 @@ void __init unflatten_device_tree(void) | |||
560 | 560 | ||
561 | /* Second pass, do actual unflattening */ | 561 | /* Second pass, do actual unflattening */ |
562 | start = ((unsigned long)initial_boot_params) + | 562 | start = ((unsigned long)initial_boot_params) + |
563 | initial_boot_params->off_dt_struct; | 563 | be32_to_cpu(initial_boot_params->off_dt_struct); |
564 | unflatten_dt_node(mem, &start, NULL, &allnextp, 0); | 564 | unflatten_dt_node(mem, &start, NULL, &allnextp, 0); |
565 | if (be32_to_cpup((__be32 *)start) != OF_DT_END) | 565 | if (be32_to_cpup((__be32 *)start) != OF_DT_END) |
566 | pr_warning("Weird tag at end of tree: %08x\n", *((u32 *)start)); | 566 | pr_warning("Weird tag at end of tree: %08x\n", *((u32 *)start)); |
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index 6a35d91a53a6..0007187ab59b 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h | |||
@@ -42,19 +42,19 @@ | |||
42 | * ends when size is 0 | 42 | * ends when size is 0 |
43 | */ | 43 | */ |
44 | struct boot_param_header { | 44 | struct boot_param_header { |
45 | u32 magic; /* magic word OF_DT_HEADER */ | 45 | __be32 magic; /* magic word OF_DT_HEADER */ |
46 | u32 totalsize; /* total size of DT block */ | 46 | __be32 totalsize; /* total size of DT block */ |
47 | u32 off_dt_struct; /* offset to structure */ | 47 | __be32 off_dt_struct; /* offset to structure */ |
48 | u32 off_dt_strings; /* offset to strings */ | 48 | __be32 off_dt_strings; /* offset to strings */ |
49 | u32 off_mem_rsvmap; /* offset to memory reserve map */ | 49 | __be32 off_mem_rsvmap; /* offset to memory reserve map */ |
50 | u32 version; /* format version */ | 50 | __be32 version; /* format version */ |
51 | u32 last_comp_version; /* last compatible version */ | 51 | __be32 last_comp_version; /* last compatible version */ |
52 | /* version 2 fields below */ | 52 | /* version 2 fields below */ |
53 | u32 boot_cpuid_phys; /* Physical CPU id we're booting on */ | 53 | __be32 boot_cpuid_phys; /* Physical CPU id we're booting on */ |
54 | /* version 3 fields below */ | 54 | /* version 3 fields below */ |
55 | u32 dt_strings_size; /* size of the DT strings block */ | 55 | __be32 dt_strings_size; /* size of the DT strings block */ |
56 | /* version 17 fields below */ | 56 | /* version 17 fields below */ |
57 | u32 dt_struct_size; /* size of the DT structure block */ | 57 | __be32 dt_struct_size; /* size of the DT structure block */ |
58 | }; | 58 | }; |
59 | 59 | ||
60 | /* TBD: Temporary export of fdt globals - remove when code fully merged */ | 60 | /* TBD: Temporary export of fdt globals - remove when code fully merged */ |