[SLOF] [PATCH slof v5 3/6] fdt: Pass the resulting device tree to QEMU
Alexey Kardashevskiy
aik at ozlabs.ru
Wed Oct 18 13:45:43 AEDT 2017
On 17/10/17 20:48, Segher Boessenkool wrote:
> 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?
May be chosen-cpu>unit or chosen-cpu-unit ?
>
>> +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? 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.
--
Alexey
More information about the SLOF
mailing list