[SLOF] [PATCH slof v5 3/6] fdt: Pass the resulting device tree to QEMU
aik at ozlabs.ru
Wed Oct 18 20:34:57 AEDT 2017
On 18/10/17 20:24, Segher Boessenkool wrote:
> 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 :-)
I need either:
- a variable for the unit address or
- a word to get it ("chosen-cpu-unit").
They both are better be defined nearby set-chosen-cpu. But fdt.fs is parsed
If I do not use "defer", then it cannot be "chosen-cpu-unit" as it is going
to look weird - "set" is defined in one place and "get" - in another. If I
define chosen-cpu-ihandle in fdt.fs - this is better but still inconsistent
and I won't be able to use "chosen-cpu-unit" in fdt.fs anyway.
My choice was to do "defer chosen-cpu-unit" but you are opposing it which
makes me think I am missing something, again :)
More information about the SLOF