From 4a43719a7738712811d822ca8125427b27a55cdc Mon Sep 17 00:00:00 2001 From: Grant Likely Date: Mon, 24 Sep 2007 09:05:31 -0600 Subject: [BUILD] conditionally compile common/cmd_*.c in common/Makefile Modify common/Makefile to conditionally compile the cmd_*.c files based on the board config. Signed-off-by: Grant Likely --- common/cmd_fdt.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'common/cmd_fdt.c') diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c index 571b8f14d5..f18c583854 100644 --- a/common/cmd_fdt.c +++ b/common/cmd_fdt.c @@ -28,9 +28,6 @@ #include #include #include - -#ifdef CONFIG_OF_LIBFDT - #include #include #include @@ -692,5 +689,3 @@ U_BOOT_CMD( " fdt print /cpus \"#address-cells\"\n" " fdt set /cpus \"#address-cells\" \"[00 00 00 01]\"\n" ); - -#endif /* CONFIG_OF_LIBFDT */ -- cgit v1.2.1 From f738b4a75998f42a7408defadc9baac7a31c92db Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Thu, 25 Oct 2007 16:15:07 -0500 Subject: Make no options to fdt print default to '/' Signed-off-by: Kumar Gala --- common/cmd_fdt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'common/cmd_fdt.c') diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c index f18c583854..b665bd6c6a 100644 --- a/common/cmd_fdt.c +++ b/common/cmd_fdt.c @@ -229,6 +229,7 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) char *pathp; /* path */ char *prop; /* property */ int ret; /* return value */ + static char root[2] = "/"; /* * list is an alias for print, but limited to 1 level @@ -241,7 +242,10 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) * Get the starting path. The root node is an oddball, * the offset is zero and has no name. */ - pathp = argv[2]; + if (argc == 2) + pathp = root; + else + pathp = argv[2]; if (argc > 3) prop = argv[3]; else -- cgit v1.2.1 From 8d04f02f6224e6983f4812ea4da704950ec8539c Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Wed, 24 Oct 2007 11:04:22 -0500 Subject: Update libfdt from device tree compiler (dtc) Update libfdt to commit 8eaf5e358366017aa2e846c5038d1aa19958314e from the device tree compiler (dtc) project. Signed-off-by: Kumar Gala --- common/cmd_fdt.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'common/cmd_fdt.c') diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c index b665bd6c6a..d84c6f09ac 100644 --- a/common/cmd_fdt.c +++ b/common/cmd_fdt.c @@ -162,12 +162,12 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) pathp = argv[2]; nodep = argv[3]; - nodeoffset = fdt_find_node_by_path (fdt, pathp); + nodeoffset = fdt_path_offset (fdt, pathp); if (nodeoffset < 0) { /* * Not found or something else bad happened. */ - printf ("libfdt fdt_find_node_by_path() returned %s\n", + printf ("libfdt fdt_path_offset() returned %s\n", fdt_strerror(nodeoffset)); return 1; } @@ -202,12 +202,12 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) prop = argv[3]; newval = argv[4]; - nodeoffset = fdt_find_node_by_path (fdt, pathp); + nodeoffset = fdt_path_offset (fdt, pathp); if (nodeoffset < 0) { /* * Not found or something else bad happened. */ - printf ("libfdt fdt_find_node_by_path() returned %s\n", + printf ("libfdt fdt_path_offset() returned %s\n", fdt_strerror(nodeoffset)); return 1; } @@ -266,12 +266,12 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) * Get the path. The root node is an oddball, the offset * is zero and has no name. */ - nodeoffset = fdt_find_node_by_path (fdt, argv[2]); + nodeoffset = fdt_path_offset (fdt, argv[2]); if (nodeoffset < 0) { /* * Not found or something else bad happened. */ - printf ("libfdt fdt_find_node_by_path() returned %s\n", + printf ("libfdt fdt_path_offset() returned %s\n", fdt_strerror(nodeoffset)); return 1; } @@ -567,13 +567,14 @@ static int fdt_print(char *pathp, char *prop, int depth) uint32_t tag; /* tag */ int len; /* length of the property */ int level = 0; /* keep track of nesting level */ + const struct fdt_property *prop1; - nodeoffset = fdt_find_node_by_path (fdt, pathp); + nodeoffset = fdt_path_offset (fdt, pathp); if (nodeoffset < 0) { /* * Not found or something else bad happened. */ - printf ("libfdt fdt_find_node_by_path() returned %s\n", + printf ("libfdt fdt_path_offset() returned %s\n", fdt_strerror(nodeoffset)); return 1; } @@ -606,9 +607,10 @@ static int fdt_print(char *pathp, char *prop, int depth) offstack[0] = nodeoffset; while(level >= 0) { - tag = fdt_next_tag(fdt, nodeoffset, &nextoffset, &pathp); + tag = fdt_next_tag(fdt, nodeoffset, &nextoffset); switch(tag) { case FDT_BEGIN_NODE: + pathp = fdt_offset_ptr(fdt, nodeoffset, 1); if(level <= depth) printf("%s%s {\n", &tabs[MAX_LEVEL - level], pathp); @@ -629,6 +631,8 @@ static int fdt_print(char *pathp, char *prop, int depth) } break; case FDT_PROP: + prop1 = fdt_offset_ptr(fdt, nodeoffset, sizeof(*prop1)); + pathp = fdt_string(fdt, fdt32_to_cpu(prop1->nameoff)); nodep = fdt_getprop (fdt, offstack[level], pathp, &len); if (len < 0) { printf ("libfdt fdt_getprop(): %s\n", -- cgit v1.2.1 From dbaf07ce620aab249e3502b20a986234a6af1d3a Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Wed, 21 Nov 2007 14:07:46 -0600 Subject: Fix warnings from import of libfdt cmd_fdt.c: In function fdt_print: cmd_fdt.c:586: warning: assignment discards qualifiers from pointer target type cmd_fdt.c:613: warning: assignment discards qualifiers from pointer target type cmd_fdt.c:635: warning: assignment discards qualifiers from pointer target type cmd_fdt.c:636: warning: assignment discards qualifiers from pointer target type Signed-off-by: Kumar Gala --- common/cmd_fdt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'common/cmd_fdt.c') diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c index d84c6f09ac..362d39d3ae 100644 --- a/common/cmd_fdt.c +++ b/common/cmd_fdt.c @@ -44,7 +44,7 @@ DECLARE_GLOBAL_DATA_PTR; static int fdt_valid(void); static int fdt_parse_prop(char *pathp, char *prop, char *newval, char *data, int *len); -static int fdt_print(char *pathp, char *prop, int depth); +static int fdt_print(const char *pathp, char *prop, int depth); /* * Flattened Device Tree command, see the help for parameter definitions. @@ -555,13 +555,13 @@ static void print_data(const void *data, int len) * Recursively print (a portion of) the fdt. The depth parameter * determines how deeply nested the fdt is printed. */ -static int fdt_print(char *pathp, char *prop, int depth) +static int fdt_print(const char *pathp, char *prop, int depth) { static int offstack[MAX_LEVEL]; static char tabs[MAX_LEVEL+1] = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"; - void *nodep; /* property node pointer */ + const void *nodep; /* property node pointer */ int nodeoffset; /* node offset from libfdt */ int nextoffset; /* next node offset from libfdt */ uint32_t tag; /* tag */ -- cgit v1.2.1 From 9162352817579840d7802da6d85872b3ca003c97 Mon Sep 17 00:00:00 2001 From: Gerald Van Baren Date: Thu, 22 Nov 2007 17:23:23 -0500 Subject: Fix fdt printing for updated libfdt Also improve printing (adopt dtc v1 "c style" hex format), whitespace cleanup. Signed-off-by: Gerald Van Baren --- common/cmd_fdt.c | 50 +++++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 23 deletions(-) (limited to 'common/cmd_fdt.c') diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c index 362d39d3ae..629c9b413e 100644 --- a/common/cmd_fdt.c +++ b/common/cmd_fdt.c @@ -75,7 +75,7 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) /* * Optional new length */ - len = simple_strtoul(argv[3], NULL, 16); + len = simple_strtoul(argv[3], NULL, 16); if (len < fdt_totalsize(fdt)) { printf ("New length %d < existing length %d, " "ignoring.\n", @@ -522,21 +522,21 @@ static void print_data(const void *data, int len) switch (len) { case 1: /* byte */ - printf("<%02x>", (*(u8 *) data) & 0xff); + printf("<0x%02x>", (*(u8 *) data) & 0xff); break; case 2: /* half-word */ - printf("<%04x>", be16_to_cpu(*(u16 *) data) & 0xffff); + printf("<0x%04x>", be16_to_cpu(*(u16 *) data) & 0xffff); break; case 4: /* word */ - printf("<%08x>", be32_to_cpu(*(u32 *) data) & 0xffffffffU); + printf("<0x%08x>", be32_to_cpu(*(u32 *) data) & 0xffffffffU); break; case 8: /* double-word */ #if __WORDSIZE == 64 - printf("<%016llx>", be64_to_cpu(*(uint64_t *) data)); + printf("<0x%016llx>", be64_to_cpu(*(uint64_t *) data)); #else - printf("<%08x ", be32_to_cpu(*(u32 *) data) & 0xffffffffU); + printf("<0x%08x ", be32_to_cpu(*(u32 *) data) & 0xffffffffU); data += 4; - printf("%08x>", be32_to_cpu(*(u32 *) data) & 0xffffffffU); + printf("0x%08x>", be32_to_cpu(*(u32 *) data) & 0xffffffffU); #endif break; default: /* anything else... hexdump */ @@ -557,7 +557,6 @@ static void print_data(const void *data, int len) */ static int fdt_print(const char *pathp, char *prop, int depth) { - static int offstack[MAX_LEVEL]; static char tabs[MAX_LEVEL+1] = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"; @@ -567,7 +566,7 @@ static int fdt_print(const char *pathp, char *prop, int depth) uint32_t tag; /* tag */ int len; /* length of the property */ int level = 0; /* keep track of nesting level */ - const struct fdt_property *prop1; + const struct fdt_property *fdt_prop; nodeoffset = fdt_path_offset (fdt, pathp); if (nodeoffset < 0) { @@ -604,48 +603,52 @@ static int fdt_print(const char *pathp, char *prop, int depth) * The user passed in a node path and no property, * print the node and all subnodes. */ - offstack[0] = nodeoffset; - while(level >= 0) { tag = fdt_next_tag(fdt, nodeoffset, &nextoffset); switch(tag) { case FDT_BEGIN_NODE: - pathp = fdt_offset_ptr(fdt, nodeoffset, 1); - if(level <= depth) + pathp = fdt_get_name(fdt, nodeoffset, NULL); + if (level <= depth) { + if (pathp == NULL) + pathp = "/* NULL pointer error */"; + if (*pathp == '\0') + pathp = "/"; /* root is nameless */ printf("%s%s {\n", &tabs[MAX_LEVEL - level], pathp); + } level++; - offstack[level] = nodeoffset; if (level >= MAX_LEVEL) { - printf("Aaaiii nested too deep. " - "Aborting.\n"); + printf("Nested too deep, aborting.\n"); return 1; } break; case FDT_END_NODE: level--; - if(level <= depth) + if (level <= depth) printf("%s};\n", &tabs[MAX_LEVEL - level]); if (level == 0) { level = -1; /* exit the loop */ } break; case FDT_PROP: - prop1 = fdt_offset_ptr(fdt, nodeoffset, sizeof(*prop1)); - pathp = fdt_string(fdt, fdt32_to_cpu(prop1->nameoff)); - nodep = fdt_getprop (fdt, offstack[level], pathp, &len); + fdt_prop = fdt_offset_ptr(fdt, nodeoffset, + sizeof(*fdt_prop)); + pathp = fdt_string(fdt, + fdt32_to_cpu(fdt_prop->nameoff)); + len = fdt32_to_cpu(fdt_prop->len); + nodep = fdt_prop->data; if (len < 0) { printf ("libfdt fdt_getprop(): %s\n", fdt_strerror(len)); return 1; } else if (len == 0) { /* the property has no value */ - if(level <= depth) + if (level <= depth) printf("%s%s;\n", &tabs[MAX_LEVEL - level], pathp); } else { - if(level <= depth) { + if (level <= depth) { printf("%s%s=", &tabs[MAX_LEVEL - level], pathp); @@ -655,11 +658,12 @@ static int fdt_print(const char *pathp, char *prop, int depth) } break; case FDT_NOP: + printf("/* NOP */\n", &tabs[MAX_LEVEL - level]); break; case FDT_END: return 1; default: - if(level <= depth) + if (level <= depth) printf("Unknown tag 0x%08X\n", tag); return 1; } -- cgit v1.2.1