[SLOF] [PATCH slof v5 3/6] fdt: Pass the resulting device tree to QEMU

Segher Boessenkool segher at kernel.crashing.org
Tue Oct 17 20:48:19 AEDT 2017


On Tue, Oct 17, 2017 at 02:12:39PM +1100, Alexey Kardashevskiy wrote:
> On 16/10/17 23:27, Segher Boessenkool wrote:
> > You can of course choose to not keep the phandle or ihandle around,
> > instead just the unit address, for example.
> > 
> > The point is to use find-node etc. instead of find-device etc. -- easier
> > to use and it does not clobber the current packages, etc.  And, of course,
> > don't read /chosen data back from the device tree.
> 
> Oh, ok.
> So I assume there is a better way of getting "reg" as well rather than
> reading the property, like "chosen-cpu-phandle @ >unit"?

That should work fine here.

> This is my draft, need "defer" as fdt.fs is included before tree.fs:
> 
> 
> diff --git a/board-qemu/slof/fdt.fs b/board-qemu/slof/fdt.fs
> index f27cd1b..9ae2e4b 100644
> --- a/board-qemu/slof/fdt.fs
> +++ b/board-qemu/slof/fdt.fs
> @@ -624,14 +624,7 @@ VARIABLE fdt-ms \ debug only
>      drop +
>  ;
> 
> -: 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?

> +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).  There's no need for DEFER -- just define the
variable before you first use it :-)


Segher


More information about the SLOF mailing list