2 * Functions for working with the Flattened Device Tree data format
4 * Copyright 2009 Benjamin Herrenschmidt, IBM Corp
5 * benh@kernel.crashing.org
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation.
13 #include <linux/of_fdt.h>
15 struct boot_param_header *initial_boot_params;
17 char *find_flat_dt_string(u32 offset)
19 return ((char *)initial_boot_params) +
20 initial_boot_params->off_dt_strings + offset;
24 * of_scan_flat_dt - scan flattened tree blob and call callback on each.
25 * @it: callback function
26 * @data: context data pointer
28 * This function is used to scan the flattened device-tree, it is
29 * used to extract the memory information at boot before we can
32 int __init of_scan_flat_dt(int (*it)(unsigned long node,
33 const char *uname, int depth,
37 unsigned long p = ((unsigned long)initial_boot_params) +
38 initial_boot_params->off_dt_struct;
43 u32 tag = *((u32 *)p);
47 if (tag == OF_DT_END_NODE) {
55 if (tag == OF_DT_PROP) {
58 if (initial_boot_params->version < 0x10)
59 p = _ALIGN(p, sz >= 8 ? 8 : 4);
64 if (tag != OF_DT_BEGIN_NODE) {
65 pr_err("Invalid tag %x in flat device tree!\n", tag);
70 p = _ALIGN(p + strlen(pathp) + 1, 4);
71 if ((*pathp) == '/') {
73 for (lp = NULL, np = pathp; *np; np++)
79 rc = it(p, pathp, depth, data);