Commit 087f79c4 authored by Jeremy Kerr's avatar Jeremy Kerr Committed by Grant Likely

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: default avatarJeremy Kerr <jeremy.kerr@canonical.com>
Signed-off-by: default avatarGrant Likely <grant.likely@secretlab.ca>
parent 33714881
...@@ -98,7 +98,7 @@ static void __init move_device_tree(void) ...@@ -98,7 +98,7 @@ static void __init move_device_tree(void)
DBG("-> move_device_tree\n"); DBG("-> move_device_tree\n");
start = __pa(initial_boot_params); start = __pa(initial_boot_params);
size = initial_boot_params->totalsize; size = be32_to_cpu(initial_boot_params->totalsize);
if ((memory_limit && (start + size) > memory_limit) || if ((memory_limit && (start + size) > memory_limit) ||
overlaps_crashkernel(start, size)) { overlaps_crashkernel(start, size)) {
......
...@@ -28,7 +28,7 @@ struct boot_param_header *initial_boot_params; ...@@ -28,7 +28,7 @@ struct boot_param_header *initial_boot_params;
char *find_flat_dt_string(u32 offset) char *find_flat_dt_string(u32 offset)
{ {
return ((char *)initial_boot_params) + return ((char *)initial_boot_params) +
initial_boot_params->off_dt_strings + offset; be32_to_cpu(initial_boot_params->off_dt_strings) + offset;
} }
/** /**
...@@ -46,7 +46,7 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node, ...@@ -46,7 +46,7 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
void *data) void *data)
{ {
unsigned long p = ((unsigned long)initial_boot_params) + unsigned long p = ((unsigned long)initial_boot_params) +
initial_boot_params->off_dt_struct; be32_to_cpu(initial_boot_params->off_dt_struct);
int rc = 0; int rc = 0;
int depth = -1; int depth = -1;
...@@ -66,7 +66,7 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node, ...@@ -66,7 +66,7 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
if (tag == OF_DT_PROP) { if (tag == OF_DT_PROP) {
u32 sz = be32_to_cpup((__be32 *)p); u32 sz = be32_to_cpup((__be32 *)p);
p += 8; p += 8;
if (initial_boot_params->version < 0x10) if (be32_to_cpu(initial_boot_params->version) < 0x10)
p = _ALIGN(p, sz >= 8 ? 8 : 4); p = _ALIGN(p, sz >= 8 ? 8 : 4);
p += sz; p += sz;
p = _ALIGN(p, 4); p = _ALIGN(p, 4);
...@@ -101,7 +101,7 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node, ...@@ -101,7 +101,7 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
unsigned long __init of_get_flat_dt_root(void) unsigned long __init of_get_flat_dt_root(void)
{ {
unsigned long p = ((unsigned long)initial_boot_params) + unsigned long p = ((unsigned long)initial_boot_params) +
initial_boot_params->off_dt_struct; be32_to_cpu(initial_boot_params->off_dt_struct);
while (be32_to_cpup((__be32 *)p) == OF_DT_NOP) while (be32_to_cpup((__be32 *)p) == OF_DT_NOP)
p += 4; p += 4;
...@@ -135,7 +135,7 @@ void *__init of_get_flat_dt_prop(unsigned long node, const char *name, ...@@ -135,7 +135,7 @@ void *__init of_get_flat_dt_prop(unsigned long node, const char *name,
sz = be32_to_cpup((__be32 *)p); sz = be32_to_cpup((__be32 *)p);
noff = be32_to_cpup((__be32 *)(p + 4)); noff = be32_to_cpup((__be32 *)(p + 4));
p += 8; p += 8;
if (initial_boot_params->version < 0x10) if (be32_to_cpu(initial_boot_params->version) < 0x10)
p = _ALIGN(p, sz >= 8 ? 8 : 4); p = _ALIGN(p, sz >= 8 ? 8 : 4);
nstr = find_flat_dt_string(noff); nstr = find_flat_dt_string(noff);
...@@ -296,7 +296,7 @@ unsigned long __init unflatten_dt_node(unsigned long mem, ...@@ -296,7 +296,7 @@ unsigned long __init unflatten_dt_node(unsigned long mem,
sz = be32_to_cpup((__be32 *)(*p)); sz = be32_to_cpup((__be32 *)(*p));
noff = be32_to_cpup((__be32 *)((*p) + 4)); noff = be32_to_cpup((__be32 *)((*p) + 4));
*p += 8; *p += 8;
if (initial_boot_params->version < 0x10) if (be32_to_cpu(initial_boot_params->version) < 0x10)
*p = _ALIGN(*p, sz >= 8 ? 8 : 4); *p = _ALIGN(*p, sz >= 8 ? 8 : 4);
pname = find_flat_dt_string(noff); pname = find_flat_dt_string(noff);
...@@ -544,7 +544,7 @@ void __init unflatten_device_tree(void) ...@@ -544,7 +544,7 @@ void __init unflatten_device_tree(void)
/* First pass, scan for size */ /* First pass, scan for size */
start = ((unsigned long)initial_boot_params) + start = ((unsigned long)initial_boot_params) +
initial_boot_params->off_dt_struct; be32_to_cpu(initial_boot_params->off_dt_struct);
size = unflatten_dt_node(0, &start, NULL, NULL, 0); size = unflatten_dt_node(0, &start, NULL, NULL, 0);
size = (size | 3) + 1; size = (size | 3) + 1;
...@@ -560,7 +560,7 @@ void __init unflatten_device_tree(void) ...@@ -560,7 +560,7 @@ void __init unflatten_device_tree(void)
/* Second pass, do actual unflattening */ /* Second pass, do actual unflattening */
start = ((unsigned long)initial_boot_params) + start = ((unsigned long)initial_boot_params) +
initial_boot_params->off_dt_struct; be32_to_cpu(initial_boot_params->off_dt_struct);
unflatten_dt_node(mem, &start, NULL, &allnextp, 0); unflatten_dt_node(mem, &start, NULL, &allnextp, 0);
if (be32_to_cpup((__be32 *)start) != OF_DT_END) if (be32_to_cpup((__be32 *)start) != OF_DT_END)
pr_warning("Weird tag at end of tree: %08x\n", *((u32 *)start)); pr_warning("Weird tag at end of tree: %08x\n", *((u32 *)start));
......
...@@ -42,19 +42,19 @@ ...@@ -42,19 +42,19 @@
* ends when size is 0 * ends when size is 0
*/ */
struct boot_param_header { struct boot_param_header {
u32 magic; /* magic word OF_DT_HEADER */ __be32 magic; /* magic word OF_DT_HEADER */
u32 totalsize; /* total size of DT block */ __be32 totalsize; /* total size of DT block */
u32 off_dt_struct; /* offset to structure */ __be32 off_dt_struct; /* offset to structure */
u32 off_dt_strings; /* offset to strings */ __be32 off_dt_strings; /* offset to strings */
u32 off_mem_rsvmap; /* offset to memory reserve map */ __be32 off_mem_rsvmap; /* offset to memory reserve map */
u32 version; /* format version */ __be32 version; /* format version */
u32 last_comp_version; /* last compatible version */ __be32 last_comp_version; /* last compatible version */
/* version 2 fields below */ /* version 2 fields below */
u32 boot_cpuid_phys; /* Physical CPU id we're booting on */ __be32 boot_cpuid_phys; /* Physical CPU id we're booting on */
/* version 3 fields below */ /* version 3 fields below */
u32 dt_strings_size; /* size of the DT strings block */ __be32 dt_strings_size; /* size of the DT strings block */
/* version 17 fields below */ /* version 17 fields below */
u32 dt_struct_size; /* size of the DT structure block */ __be32 dt_struct_size; /* size of the DT structure block */
}; };
/* TBD: Temporary export of fdt globals - remove when code fully merged */ /* TBD: Temporary export of fdt globals - remove when code fully merged */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment