Edit this page

herkforth openfirmware

Just some notes on how herkforth interacts with open firmware

Herkforth provides a few words to help interact with open firmware (through the Client Interface as explained in chapter 6 of the Open Firmware spec.)

Firstly, you can access the client interface with of-call:

: of-call ( [args...] num-return-args num-args service-string -- [return-args...] )

That is, you first put the arguments to pass to Open Firmware on the stack, then the number of return arguments (of the OF call) then the number of arguments (of the OF call) then the name of the OF call.

of-call passes all this to OF in the correct structure, passes control to OF, then gives you as many return values on the stack as you said the OF call would give.

Generally, you should use this word to define a word that calls a specific OF word.

Example

lets say we want to call OF's getprop. getprop takes 4 arguments (phandle, name, buffer and the buffer length) and returns one (the actual size of the property).

So we could make a wrapper function for herkforth like so:

: of-getprop 1 4 s-getprop of-call ;

(s-getprop being the string "getprop" with a null byte at the end)

Now we can call of-getprop to get the value of a property (eg the address cells property):

my-node s-addr-cells buff 64 of-getprop

See Also

how herkforth works

herkforth docs

Edit this page · home ·