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

Alexey Kardashevskiy aik at ozlabs.ru
Mon Oct 16 18:32:17 AEDT 2017


On 16/10/17 18:18, Segher Boessenkool wrote:
> Hi Alexey,
> 
> On Mon, Oct 16, 2017 at 04:16:50PM +1100, Alexey Kardashevskiy wrote:
>> +: fdt-skip-string ( cur -- cur )
>> +    BEGIN
>> +        dup c@
>> +    WHILE
>> +        1+
>> +    REPEAT
>> +    4 + -4 and
>> +;
> 
> You could use ZCOUNT, like:
> 
> : fdt-skip-string ( addr -- addr )  zcount + char+  4 #aligned ;
> 
> 
>> +: fdt-begin-node ( name namelen -- )
>> +    OF_DT_BEGIN_NODE fdt-l,
>> +    2dup 1 = swap c@ [char] / = and IF 2drop s" " THEN \ is it '/'?
> 
> 2dup s" /" str= IF 2drop s" " THEN
> 
> 
> But you probably shouldn't test for name "/" at all: the problem is that
> the FDT doesn't allow anything in "name" for the root node?  So pass
> the phandle (instead of the name string), test for *that*, and do the
> node>qname in here.  Like:
> 
> : fdt-begin-node ( phandle -- )
>     OF_DT_BEGIN_NODE fdt-l,
>     dup device-tree @ = IF drop s" " ELSE node>qname THEN
>     fdt-ztr,
>     fdt-align
> ;
> 
> 
> Here, have a tag :-)
> 
> Reviewed-by: Segher Boessenkool <segher at kernel.crashing.org>

Yay, thanks for the help with this.

v6 is still coming though for this (so I'll add your suggestions too):



diff --git a/board-qemu/slof/fdt.fs b/board-qemu/slof/fdt.fs
index 90e4f1c..d151031 100644
--- a/board-qemu/slof/fdt.fs
+++ b/board-qemu/slof/fdt.fs
@@ -631,6 +631,15 @@ 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
+;
+
 : fdt-flatten-tree ( -- tree )
     1 to fdt-debug

@@ -676,7 +685,7 @@ VARIABLE fdt-ms \ debug only
     /fdth               r@ >fdth_rsvmap_off l!
     11                  r@ >fdth_version l!
     10                  r@ >fdth_compat_vers l!
-    0                   r@ >fdth_boot_cpu l!
+    fdt-boot-cpu        r@ >fdth_boot_cpu l!
     over                r@ >fdth_string_size l!
     2 pick              r@ >fdth_struct_size l!
                                     ( struct-len strings-len total-len r:
fdt )
@@ -693,8 +702,8 @@ VARIABLE fdt-ms \ debug only
     drop

     \ Free temporary blobs
-    fdtfl-struct @ 200000 free-mem
-    fdtfl-strings @ 200000 free-mem
+    fdtfl-struct @ 100000 free-mem
+    fdtfl-strings @ 100000 free-mem




-- 
Alexey


More information about the SLOF mailing list