public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Jerry Van Baren <gerald.vanbaren@smiths-aerospace.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] libfdt release?
Date: Fri, 12 Oct 2007 07:58:28 -0400	[thread overview]
Message-ID: <470F6164.6010601@smiths-aerospace.com> (raw)
In-Reply-To: <20071012042811.GK21056@localhost.localdomain>

David Gibson wrote:
> On Thu, Oct 11, 2007 at 07:35:45PM -0400, Jerry Van Baren wrote:

[snip]

>>>>> * Add some utilities to manipulate the reserved memory map. (think
>>>>> your recent patch my cover that)
>>>> Should do.
>>>>
>>>>> * libfdt: Make fdt_check_header() public
>>>> Hrm.  Why?
>>> Jerry?
>> Because we needed to check the validity of the header outside of libfdt 
>> and decide whether we wanted to use the blob or not.
> 
> That seems reasonable.  I'll look at exporting that.  Although.. I'm a
> little surprised that u-boot doesn't just to an fdt_open_into() as the
> first thing, which would include the check.

Yes, that would be the alternative, but fdt_open_into() potentially 
changes things (copies the blob) and doing an fdt_open_into() just to 
check the validity of the header is not intuitive.

While it is true that, by giving the same start and end address, you can 
avoid doing the actual copy, it isn't obvious that the read/write 
doesn't actually occur if source == dest... the code goes through all 
the motions and relies on the underlying memory utility library to short 
circuit the actual operation.  If the underlying memory utility library 
*doesn't* short circuit the operation, we could have severe problems 
with blobs that are burned into flash (potential write protection 
exceptions).

I submit that is a lot of ugly to avoid a simple export of an already 
existing, useful, function.

>>>>> * libfdt: Enhanced and published fdt_next_tag()
>>>> Hrm.  I'm not categorically opposed to publishing fdt_next_tag(), but
>>>> I'm disinclined to do so without good reason.
>>> Jerry?
>>>
>>> Hopefully Jerry will comment on why the additions were made to u-boot.
>> I needed it to implement my u-boot "fdt print" command, to step through 
>> the tags so I could print them out in a human readable format (it 
>> actually is dtc-input-compatible and, in most cases, matches the 
>> original dtc input source code).
> 
> Hrm, I see.  For debugging purposes, essentially.
> 
> I have been thinking for some time that I needed to add user-accesible
> traversal functions - I just haven't managed to come up with an
> interface I like, yet.

More than debugging purposes, the "fdt print" command is extremely 
useful for the u-boot command line to see what you have to start with, 
figure out what parameters need to be modified, and format a correct 
string to do the modification.  This is doubly important when the blob 
was created /n/ steps before you got it (a board manufacturer, reseller, 
or some poor luser) and you have no clue what the blob is to start with.

It would be very useful for the kernel as well, to implement the /proc 
blob display.  Again, on the face of it, your "debugging purposes" would 
apply, but it is essential debugging, not nicety debugging.  I suspect 
kernel developers are going to be a lot happier getting an ascii dump of 
/proc/fdt/asciiblob (sorry, forgot where it lives) than a mime encoded 
binary lump that they then have to decode (only to find out that the 
poor luser didn't dd or mime encode it properly).

In common/cmd_fdt.c line 551 (line 601 is where the traversal starts) 
you can see how I used it to walk through the blob:
<http://www.denx.de/cgi-bin/gitweb.cgi?p=u-boot.git;a=blob;f=common/cmd_fdt.c;h=571b8f14d56f3bc97dcd49eb8465cfdc9988d786;hb=HEAD#l551>

IMHO it is an ideal user-accessible traversal function.  It is simple 
yet sufficient.  It does what you need with very little fuss required of 
the user, yet it can be used in lots of unexpected ways (that's a *good* 
thing here).  For instance, in my "print" example, I add a looping 
construct with a nesting depth variable and viola, an elegant print 
function that can start anywhere in the blob, print out a syntactically 
correct ASCII representation, etc. etc.

Thanks,
gvb

  parent reply	other threads:[~2007-10-12 11:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <006E3CAD-11CB-4892-8BDB-9866677F371D@freescale.com>
     [not found] ` <20071010061458.GA6135@localhost.localdomain>
     [not found]   ` <912BB32E-FD7D-4CBC-AE3D-3D358E97DECB@freescale.com>
     [not found]     ` <20071011041239.GF14873@localhost.localdomain>
     [not found]       ` <9917D225-2082-4900-BFD4-96490EA88C42@freescale.com>
2007-10-11 23:35         ` [U-Boot-Users] libfdt release? Jerry Van Baren
2007-10-11 23:56           ` Detlev Zundel
2007-10-12  4:28           ` David Gibson
2007-10-12  7:16             ` Wolfgang Grandegger
2007-10-15  3:20               ` David Gibson
2007-10-12 11:58             ` Jerry Van Baren [this message]
2007-10-15  4:12               ` David Gibson
2007-10-15 18:30                 ` Kumar Gala
2007-10-15 18:51                   ` Jerry Van Baren
2007-10-15 19:03                     ` Kumar Gala
2007-10-15 19:23                       ` Jerry Van Baren
2007-10-15 21:50                         ` Kumar Gala
2007-10-15 19:21                   ` Wolfgang Grandegger
2007-10-16  2:44                     ` David Gibson
2007-10-16  7:03                       ` Wolfgang Grandegger
2007-10-16  7:19                         ` David Gibson
2007-10-23 14:39                 ` Kumar Gala
2007-10-23 23:51                   ` David Gibson

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=470F6164.6010601@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