From: Jerry Van Baren <gerald.vanbaren@smiths-aerospace.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH] of dump command
Date: Tue, 31 Oct 2006 13:41:12 -0500 [thread overview]
Message-ID: <454798C8.3060302@smiths-aerospace.com> (raw)
In-Reply-To: <20061030222251.705C0352658@atlas.denx.de>
Wow, you guys are _tough_! I'm glad you didn't grade me for CompSci 101
:-)
Three patches will follow
* vsprintf "ll" extension (pretty trivial)
* oftdump command (da meat)
* PQ2FADS changes to use the flattened OF tree (pretty trivial)
More comments embedded...
Wolfgang Denk wrote:
> Dear Grant,
>
> thanks a lot for your thorough comments.
>
> In message <528646bc0610300943j5752c2c7i9b66864ec678a86e@mail.gmail.com> you wrote:
>> These should probably be split up into separate patches. One for the
>> vsprintf 'll' support; one for the new command and one for the
>> MPC8260ADS config changes.
>
> Agreed. Eventually these are separate commits in Jerry's repo anyway.
> Jerry?
Done, patch will be submitted.
>> This is not a lot of code; and it's pretty useful stuff; maybe just
>> make it automatically built when CONFIG_OF_FLAT_TREE is defined?
>> (Rather than adding a new CONFIG_COMMANDS macro at the moment)
>
> Agreed.
Done, patch will be submitted.
>> If a new CFG_CMD_ macro set is needed; I wouldn't do it now. There is
>> still 1 bit left. :) If it needs to be changed, it might make sense
>> to audit the full list and see if there is anything that should be
>> removed.
>>
>> Wolfgang needs to weigh in on this one.
>
> I think we need a major cleanup of the config system, so I would like
> to touch as few things in this area as possible. Here, I agree with
> Grant that this should be just compiled in when OFT support is
> enabled. Probably everybody will want this.
CONFIG1_* and CFG1_CMD_* have been removed.
>>> +U_BOOT_CMD(
>>> + of, 3, 0, do_of,
>>> + "of - Open Firmware utility commands\n",
>>> + "of <addr> - Dump the address as an OF tree\n"
>>> + "of <addr> <prop> - Dump the given property\n"
>>> +);
>> I think 'of' is a bit terse. Maybe "ofinfo", "ofdump", or "ftinfo"?
>
> Additionally, I think that "of" [= Open Firmware] is wrong. It should
> be "oft" [Open Firmware Tree] at least. The command should IMHO be
> named "oftdump", but "ftdump" [FT = Flat Tree] would be ok, too.
OK, I renamed it "oftdump" (but, thanks to the beauty of Wolfgang's
minimum unique characters parsing, "of" still works ;-).
>>> + * Used by ft_dump_blob() and ft_get_prop() to build up property names
>>> + */
>>> +static char path[256], prop[256];
>> Is moving these out of ft_get_prop truly necessary? (I haven't dug
>> into the full context, but seeing this makes me scared)
>
> Me too :-)
Yes, this is ugly. The existing ft_get_prop() had the two declarations
as statics within the function declaration and I simply moved them out
so they could be re-used by ft_dump_blob(). Note that they remain
static, but they are available to ft_dump_blob() as well as
ft_get_prop() now. One alternative is to duplicate the static
declarations in both routines, but that seems extremely silly.
(I'm also not wild about the fact that the buffer lengths are fixed and
unchecked, so it is a buffer overflow vulnerability - I figure (a) I
just used existing code and (b) simply having access to u-boot is more
of a security issue than buffer overflows in u-boot.)
The problem is that the flattened OF tree only has the incremental
path/property names rather than the full name on each property (I
believe this was a version 0x10 optimization). The easiest way to match
the path/property is to build up (as you nest in) and back up (as you
unnest) the path and then do a string compare of the path/property
built-up string against the desired string. This is what the existing
ft_get_prop() did and what I extended ft_dump_blob() to do too.
I looked at least twice at doing a more clever matching and threw my
changes away because I ended up going down a blind alley. Keeping track
of the nesting and unnesting while following the tree takes some
non-trivial logic. I'm not saying that there _isn't_ a better way, but
building up the string and doing a string compare is _much_ easier and
quite likely takes less code than being clever.
>> There's still one more bit left in CFG_CMD_ALL; just use it! :)
>>
>> Or eliminate CFG_CMD_OF entirely.
>
> That's what I'd suggest.
Done.
> Thanks again, to both of you.
>
> Best regards,
>
> Wolfgang Denk
Patches to follow...
Best regards,
gvb
prev parent reply other threads:[~2006-10-31 18:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-30 11:39 [U-Boot-Users] [PATCH] of dump command Jerry Van Baren
2006-10-30 17:43 ` Grant Likely
2006-10-30 22:22 ` Wolfgang Denk
2006-10-31 18:41 ` Jerry Van Baren [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=454798C8.3060302@smiths-aerospace.com \
--to=gerald.vanbaren@smiths-aerospace.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox