[SLOF] [PATCH slof v5 3/6] fdt: Pass the resulting device tree to QEMU
Segher Boessenkool
segher at kernel.crashing.org
Wed Oct 18 20:24:24 AEDT 2017
On Wed, Oct 18, 2017 at 01:45:43PM +1100, Alexey Kardashevskiy wrote:
> On 17/10/17 20:48, Segher Boessenkool wrote:
> >> -: fdt-boot-cpu ( -- bootcpu )
> >> - s" cpu" s" /chosen" find-node get-property 0<> IF 0 EXIT THEN
> >> - decode-int
> >> - nip nip ihandle>phandle
> >> - s" reg" rot get-property 0<> IF 0 EXIT THEN
> >> - decode-int
> >> - nip nip
> >> -;
> >> +DEFER chosen-cpu
> >
> > Chosen cpu what? chosen-cpu-address maybe?
>
> May be chosen-cpu>unit or chosen-cpu-unit ?
">" means "to" so that's a bit misleading (there is no chosen-cpu as
input to this word). "chosen-cpu-unit" is fine with me.
> >> +VARIABLE chosen-cpu-phandle
> >> +VARIABLE chosen-cpu-ihandle
> >> +: set-chosen-cpu ( -- )
> >> + s" /cpus" find-node dup 0= ABORT" /cpus not found"
> >> + child dup 0= ABORT" /cpus/cpu not found"
> >> + dup chosen-cpu-phandle ! 0 0 rot open-node
> >> + dup chosen-cpu-ihandle ! encode-int s" cpu" set-chosen
> >> ;
> >
> > You can also calculate and store the address right here (and you of
> > course do not need the phandle and ihandle if you do not want them
> > for anything else).
>
> I can, I just have no good taste :) Ok, I'll store chosen-cpu-ihandle only
> and use "ihandle>phandle >unit" in "chosen-cpu>unit".
>
> > There's no need for DEFER -- just define the
> > variable before you first use it :-)
>
> Pfff. Where would I put it?
The same place as you now have the DEFER? DEFER and VARIABLE are very
much alike:
: VARIABLE CREATE 0 , ;
: DEFER CREATE POSTPONE ABORT DOES> @ EXECUTE ;
or they looks even more alike if you write this as
: VARIABLE CREATE 0 , DOES> ;
: DEFER CREATE ['] ABORT , DOES> @ EXECUTE ;
(this isn't how those words are actually implemented, it is optimised
a little, but it works essentially the same way).
> Won't it confuse future readers? :) But sure I
> can do that and define chosen-cpu-ihandle in fdt.fs, and if we decide to
> use chosen-cpu-ihandle for something else - move it, and so on.
Or even not define words for the phandle and ihandle if you don't use
them. Your choice :-)
Segher
More information about the SLOF
mailing list