Update device tree returned by CAS hypercall

Add device tree parsing code and setting properties.

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
diff --git a/board-qemu/slof/fdt.fs b/board-qemu/slof/fdt.fs
index 13f7ead..fc40449 100644
--- a/board-qemu/slof/fdt.fs
+++ b/board-qemu/slof/fdt.fs
@@ -344,5 +344,53 @@
    drop
    device-end
 ;
+
+: fdt-fix-cas-node ( start -- end )
+    recursive
+    fdt-next-tag dup OF_DT_BEGIN_NODE <> IF
+	." Error " cr
+	-1 throw
+    THEN drop
+    fdt-fetch-unit
+    dup 0 = IF drop drop " /" THEN
+    40 left-parse-string
+    2swap ?dup 0 <> IF
+	nip
+	1 + + \ Add the string len +@
+    ELSE
+	drop
+    THEN
+    fdt-debug IF ." Setting node: " 2dup type cr THEN
+    find-node ?dup 0 <> IF set-node  THEN
+    fdt-debug IF ." Current  now: " pwd cr THEN
+    BEGIN
+	fdt-next-tag dup OF_DT_END_NODE <>
+    WHILE
+	dup OF_DT_PROP = IF
+	    fdt-debug IF ." Found property " cr THEN
+	    drop dup		( drop tag, dup addr     : a1 a1 )
+	    dup l@ dup rot 4 +	( fetch size, stack is   : a1 s s a2)
+	    dup l@ swap 4 +	( fetch nameid, stack is : a1 s s i a3 )
+	    rot			( we now have: a1 s i a3 s )
+	    fdt-encode-prop rot	( a1 s pa ps i)
+	    fdt-fetch-string		( a1 s pa ps na ns )
+	    property
+	    fdt-debug IF ." Setting property done " cr THEN
+	    + 8 + 3 + fffffffc and
+	ELSE dup OF_DT_BEGIN_NODE = IF
+		drop			( drop tag )
+		4 -
+		fdt-fix-cas-node
+		get-parent set-node
+		fdt-debug IF ." Returning back " pwd cr THEN
+	    ELSE
+		." Error " cr
+		drop -1 throw
+	    THEN
+	THEN
+    REPEAT
+    drop \ drop tag
+;
+
 s" /" find-node fdt-fix-phandles
 
diff --git a/slof/fs/archsupport.fs b/slof/fs/archsupport.fs
index 4d18c74..6964620 100644
--- a/slof/fs/archsupport.fs
+++ b/slof/fs/archsupport.fs
@@ -1,18 +1,32 @@
-4096 VALUE size
+\ *****************************************************************************
+\ * Copyright (c) 2011 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ *     IBM Corporation - initial implementation
+\ ****************************************************************************/
+
+1000 VALUE size
 : ibm,client-architecture-support         ( vec -- err? )
     \ Store require parameters in nvram
     \ to come back to right boot device
-
     \ Allocate memory for H_CALL
     size alloc-mem                        ( vec memaddr )
-    swap over
-    \ FIXME: convert memaddr to phys
-    size                                  ( memaddr vec memaddr size )
+    swap over size                        ( memaddr vec memaddr size )
     \ make h_call to hypervisor
-    hv-cas 0= IF
-	." hv-cas succeeded " cr
-	\ Make required changes
-	FALSE
+    hv-cas 0= IF                          ( memaddr )
+	dup @ 1 >= IF                     \ Version number >= 1
+	    \ Make required changes
+	    " /" find-node set-node
+	    dup 4 + fdt-init
+	    fdt-check-header
+	    fdt-struct fdt-fix-cas-node
+	THEN
+	drop FALSE
     ELSE
 	." hv-cas failed  " TRUE
     THEN