Add a oftdump (open firmware flattened tree dump) command.
PATCH 1/1 Add a oftdump (open firmware flattened tree dump) command.
Add a oftdump (open firmware flattened tree dump) command.
Git repository:
<http://www.cideas.us/cgi-bin/gitweb.cgi?p=u-boot/u-boot-of-cmd.git;a=summary>
Branch: of-cmd
<http://www.cideas.us/cgi-bin/gitweb.cgi?p=u-boot/u-boot-of-cmd.git;a=shortlog;h=of-cmd>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 0001-Add-a-oftdump-open-firmware-flattened-tree-dump-command.txt
Url: http://lists.denx.de/pipermail/u-boot/attachments/20061031/e9c3e3d9/attachment.txt
PATCH 1/1 Add a oftdump (open firmware flattened tree dump) command.
Quoted 9 lines · Jerry Van Baren
Add a oftdump (open firmware flattened tree dump) command.
Git repository:
<http://www.cideas.us/cgi-bin/gitweb.cgi?p=u-boot/u-boot-of-cmd.git;a=summary>Branch: of-cmd
<http://www.cideas.us/cgi-bin/gitweb.cgi?p=u-boot/u-boot-of-cmd.git;a=shortlog;h=of-cmd>Signed-off-by Jerry Van Baren <[email protected]>
Not that I have any authority on this, but I'm going to NAK it (for right now). Others may disagree.
The global statics really bother me, and I'll take a look myself if there is a better way. Give me a few days.
Cheers,
g.
Quoted 287 lines
Quoted 3 lines
From
20328071e132c40c662ffb2a07460144841b9e1aMon Sep 17 00:00:00 2001From: Jerry Van Baren <[email protected]>
Date: Mon, 30 Oct 2006 21:47:02 -0500
Subject: [PATCH] Add a oftdump (open firmware flattened tree dump) command.--- common/Makefile | 2 +- common/cmd_bootm.c | 2 -- common/cmd_oftdump.c | 58 +++++++++++++++++++++++++++++++++++++++++++++ common/ft_build.c | 65 ++++++++++++++++++++++++++++++++++++++++++-------- include/ft_build.h | 2 +- 5 files changed, 114 insertions(+), 15 deletions(-)common/Makefile +1
-1@@ -37,7 +37,7 @@ COBJS = main.o ACEX1K.o altera.o bedbug. cmd_i2c.o cmd_ide.o cmd_immap.o cmd_itest.o cmd_jffs2.o \ cmd_load.o cmd_log.o \ cmd_mem.o cmd_mii.o cmd_misc.o cmd_mmc.o \ - cmd_nand.o cmd_net.o cmd_nvedit.o \ + cmd_nand.o cmd_net.o cmd_nvedit.o cmd_oftdump.o \ cmd_pci.o cmd_pcmcia.o cmd_portio.o \ cmd_reginfo.o cmd_reiser.o cmd_scsi.o cmd_spi.o cmd_universe.o \ cmd_usb.o cmd_vfd.o \common/cmd_bootm.c +0
-2@@ -950,7 +950,6 @@ #else /* CONFIG_OF_FLAT_TREE */ }ft_setup (of_flat_tree, kbd, initrd_start, initrd_end); -/* ft_dump_blob(of_flat_tree); */ #if defined(CFG_INIT_RAM_LOCK ) && !defined(CONFIG_E500 )unlock_ram_in_cache ();@@ -968,7 +967,6 @@ #endif cmd_start, cmd_end); else {ft_setup (of_flat_tree, kbd, initrd_start, initrd_end); -/* ft_dump_blob(of_flat_tree); */ (*kernel) ((bd_t *)of_flat_tree, (ulong )kernel,0 ,0 ,0 ); }#endif /* CONFIG_OF_FLAT_TREE */ common/cmd_oftdump.c new file +58
-0@@ -0,0 +1,58 @@ +/* +* (C) Copyright 2006 +* Gerald Van Baren, Custom IDEAS, vanbaren at cideas.com. +* +* See file CREDITS for list of people who contributed to this +* project. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +*/ + +/* +* Misc functions +*/ +#include <common.h> +#include <command.h> +#include <ft_build.h> + +#ifdef CONFIG_OF_FLAT_TREE + +int do_oftdump (cmd_tbl_t *cmdtp,int flag,int argc,char *argv[]) +{ +void *p = (void *)simple_strtoul (argv[1 ],NULL ,16 ); + +if (argc <2 ) { +printf ("Usage:\n%s\n" , cmdtp->usage); +return 1 ; + }else if (argc ==2 ) { +ft_dump_blob (p,"/" ); + }else { +ft_dump_blob (p, argv[2 ]); + } + +return 0 ; +} + + +U_BOOT_CMD ( + oftdump,3 ,0 , do_oftdump, +"oftdump - Open Firmware flattened tree dump\n" , +"oftdump <addr> - Dump the whole OF flattened tree\n" +"oftdump <addr> <prop> - Dump the given OF property\n" +); + +#endif /* CONFIG_OF_FLAT_TREE */ +common/ft_build.c +54
-11@@ -233,10 +233,19 @@ static void print_data(const void *data,printf (" = <%04x>" ,be16_to_cpu (*(u16 *) data) &0xffff );break ;case 4 :/* word */ -printf (" = <%x>" ,be32_to_cpu (*(u32 *) data) &0xffffffffU ); +printf (" = <%08x>" ,be32_to_cpu (*(u32 *) data) &0xffffffffU );break ;case 8 :/* double-word */ -printf (" = <%qx>" ,be64_to_cpu (*(uint64_t *) data)); +/* +* If 64 bit printing is supported, use it. +*/ +#ifdef CFG_64BIT_VSPRINTF +printf (" = <%016llx>" ,be64_to_cpu (*(uint64_t *) data)); +#else +printf (" = <%08x" ,be32_to_cpu (*(u32 *) data) &0xffffffffU ); + data +=sizeof (u32); +printf (" %08x>" ,be32_to_cpu (*(u32 *) data) &0xffffffffU ); +#endif break ;default :/* anything else... hexdump */ printf (" = [" );@@ -248,7 +257,12 @@ static void print_data(const void *data, } } -void ft_dump_blob (const void *bphp) +/* +* Used by ft_dump_blob() and ft_get_prop() to build up property names +*/ +static char path[256 ], prop[256 ]; + +void ft_dump_blob (const void *bphp,const char *propname) {const struct boot_param_header *bph = bphp; const uint64_t *p_rsvmap = (const uint64_t *)@@ -260,17 +274,22 @@ void ft_dump_blob(const void *bphp)u32 tag;const u32 *p;const char *s, *t; +char *ss;int depth, sz, shift; +int found;int i;uint64_t addr, size;if (be32_to_cpu (bph->magic) !=OF_DT_HEADER ) {/* not valid tree */ +printf ("Not a valid tree.\n" );return ; } depth =0 ; shift =4 ; + found =0 ; +strcpy (path,"/" );for (i =0 ;; i++) { addr =be64_to_cpu (p_rsvmap[i *2 ]);@@ -290,7 +309,17 @@ void ft_dump_blob(const void *bphp) s = (const char *)p; p = (u32 *)_ALIGN ((unsigned long )p +strlen (s) +1 ,4 ); -printf ("%*s%s {\n" , depth * shift,"" , s); +strcat (path, s); +if (found || (strcmp (path, propname) ==0 )) { + found++; +if (depth ==0 ) +printf ("/ {\n" ); +else +printf ("%*s%s {\n" , depth * shift,"" , s); + } +/* The root path is already there as "/" */ +if (depth !=0 ) +strcat (path,"/" ); depth++;continue ;@@ -299,7 +328,16 @@ void ft_dump_blob(const void *bphp)if (tag ==OF_DT_END_NODE ) { depth--; -printf ("%*s};\n" , depth * shift,"" ); + path[strlen (path) -1 ] ='\0' ; + ss =strrchr (path,'/' ); +if (ss !=NULL ) + ss[1 ] ='\0' ; + +if (found) { +printf ("%*s};\n" , depth * shift,"" ); +if (found-- ==0 ) +return ;/* request done */ + }continue ; }@@ -317,9 +355,15 @@ void ft_dump_blob(const void *bphp) s = (const char *)p_strings +be32_to_cpu (*p++); t = (const char *)p; p = (const u32 *)_ALIGN ((unsigned long )p + sz,4 ); -printf ("%*s%s" , depth * shift,"" , s); -print_data (t, sz); -printf (";\n" ); + +strcpy (prop, path); +strcat (prop, s); + +if (found || (strcmp (prop, propname) ==0 )) { +printf ("%*s%s" , depth * shift,"" , s); +print_data (t, sz); +printf (";\n" ); + } } }@@ -349,7 +393,6 @@ void *ft_get_prop(void *bphp, const charchar *s, *t;char *ss;int sz; -static char path[256 ], prop[256 ]; path[0 ] ='\0' ;@@ -478,7 +521,7 @@ #endif#ifdef DEBUG printf ("recieved oftree\n" ); -ft_dump_blob (blob); +ft_dump_blob (blob,"/" );#endif ft_init_cxt (&cxt, blob);@@ -585,7 +628,7 @@ #endif#ifdef DEBUG printf ("final OF-tree\n" ); -ft_dump_blob (blob); +ft_dump_blob (blob,"/" ); #endif }#endif include/ft_build.h +1
-2@@ -58,7 +58,7 @@ void ft_add_rsvmap(struct ft_cxt *cxt, uvoid ft_setup (void *blob,bd_t * bd,ulong initrd_start,ulong initrd_end); -void ft_dump_blob (const void *bphp); +void ft_dump_blob (const void *bphp,const char *propname);void ft_merge_blob (struct ft_cxt *cxt,void *blob);void *ft_get_prop (void *bphp,const char *propname,int *szp); --1.4.1.1
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642_______________________________________________
U-Boot-Users mailing list
U-Boot-Users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/u-boot-users
Signature · 4 lines
Grant Likely, B.Sc. P.Eng. Secret Lab Technologies Ltd. grant.likely at secretlab.ca (403) 399-0195
PATCH 1/1 Add a oftdump (open firmware flattened tree dump) command.
Quoted 13 lines · Grant Likely
Quoted 11 lines · Jerry Van Baren
Add a oftdump (open firmware flattened tree dump) command.
Git repository:
<http://www.cideas.us/cgi-bin/gitweb.cgi?p=u-boot/u-boot-of-cmd.git;a=summary>Branch: of-cmd
<http://www.cideas.us/cgi-bin/gitweb.cgi?p=u-boot/u-boot-of-cmd.git;a=shortlog;h=of-cmd>Signed-off-by Jerry Van Baren <[email protected]>
Quoted 8 lines
Not that I have any authority on this, but I'm going to NAK it (for right now). Others may disagree.
The global statics really bother me, and I'll take a look myself if there is a better way. Give me a few days.
Cheers,
g.
Hi Grant,
Global static is a oxymoron, they are "global" only in the ft_build.c file starting at ft_dump_blob() and going to the end of the file. I suspect what you are concerned about is the shared aspect, which isn't a problem in u-boot since it is single threaded.
There are three choices:
1) "Global statics" - easiest and least memory use, but makes Good Engineers[tm] queasy.
2) "Duplicate" the arrays (currently 2x256, becomes 4x256) as statics inside the two functions - uses 2x the memory with no benefit (still makes Good Engineers[tm] queasy, just a different queasy).
3) More clever matching on the parameter string vs. the OF blob where the string is built up - I bailed out on this, but it is the best solution.
I know your type, you are just challenging me to actually do #3. ;-)
Best regards,
gvb
PATCH 1/1 Add a oftdump (open firmware flattened tree dump) command.
Quoted 11 lines · Jerry Van Baren
Quoted 1 line · Grant Likely
On 10/31/06, Jerry Van Baren <[email protected]> wrote:
There are three choices:
1) "Global statics" - easiest and least memory use, but makes Good Engineers[tm] queasy.
2) "Duplicate" the arrays (currently 2x256, becomes 4x256) as statics inside the two functions - uses 2x the memory with no benefit (still makes Good Engineers[tm] queasy, just a different queasy).
3) More clever matching on the parameter string vs. the OF blob where the string is built up - I bailed out on this, but it is the best solution.
Quoted 1 line
I know your type, you are just challenging me to actually do #3. ;-)
I see your ;-) and raise you a :-P
g.
Signature · 4 lines
Grant Likely, B.Sc. P.Eng. Secret Lab Technologies Ltd. grant.likely at secretlab.ca (403) 399-0195