1 \ *****************************************************************************
2 \ * Copyright (c) 2004, 2011 IBM Corporation
3 \ * All rights reserved.
4 \ * This program and the accompanying materials
5 \ * are made available under the terms of the BSD License
6 \ * which accompanies this distribution, and is available at
7 \ * http://www.opensource.org/licenses/bsd-license.php
10 \ * IBM Corporation - initial implementation
11 \ ****************************************************************************/
13 : strequal ( str1 len1 str2 len2 -- flag )
14 rot dup rot = IF comp 0= ELSE 2drop drop 0 THEN ;
18 \ The root of the device tree and some of its kids.
21 \ The following properties have been provided by the FDT from QEMU already,
22 \ so we do not have to create them on our own:
24 \ " QEMU" encode-string s" model" property
25 \ 2 encode-int s" #address-cells" property
26 \ 2 encode-int s" #size-cells" property
27 \ s" chrp" device-type
31 \ See 3.6.5, and the PowerPC OF binding document.
33 s" mmu" 2dup device-name device-type
34 0 0 s" translations" property
44 \ Fixup timebase frequency from device-tree
46 " /cpus/@0" find-device
47 " timebase-frequency" get-node get-package-property IF
50 decode-int to tb-frequency 2drop
62 : populate-vios ( -- )
63 \ Populate the /vdevice children with their methods
64 \ WARNING: Quite a few SLOFisms here like get-node, set-node, ...
66 ." Populating /vdevice methods" cr
67 " /vdevice" find-device get-node child
72 dup " compatible" rot get-package-property 0 = IF
74 2dup " hvterm1" strequal IF
75 " vio-hvterm.fs" included
77 2dup " IBM,v-scsi" strequal IF
78 " vio-vscsi.fs" included
80 2dup " IBM,l-lan" strequal IF
81 " vio-veth.fs" included
83 2dup " qemu,spapr-nvram" strequal IF
84 " rtas-nvram.fs" included
101 #include "pci-scan.fs"
103 : populate-pci-busses ( -- )
104 \ Populate the /pci* children with their methods
105 " /" find-device get-node child
110 dup " name" rot get-package-property 0 = IF
111 drop dup from-cstring
112 2dup s" pci" strequal IF
113 s" pci-phb.fs" included
127 : check-patch-kernel-sc1 ( -- )
128 \ At this point we can try our best to patch the kernel. This function
129 \ gets called from the "quiesce" call that kernels execute before they
130 \ take over the system.
132 \ Here we know that ciregs->r4 contains the return address that gets us
133 \ back into enter_prom inside the guest kernel.
134 \ We assume that within a range of +- 16MB of that pointer all sc 1
135 \ instructions inside of that kernel reside.
137 \ test_ins (instruction that tells us the kernel's endianness; we use the
138 \ return address back into the kernel here.)
140 \ test_ins + 16MB (end of search range)
142 \ MAX(test_ins - 16MB, 0) (start of search range)
143 dup 2000000 < IF 0 ELSE dup 2000000 - THEN
149 ' check-patch-kernel-sc1 add-quiesce-xt
151 \ Add rtas cleanup last
152 ' rtas-quiesce add-quiesce-xt
168 s" /cpus/@0" open-dev encode-int s" cpu" set-chosen
169 s" /memory@0" open-dev encode-int s" memory" set-chosen
176 s" /openprom" find-device
177 s" SLOF," slof-build-id here swap rmove here slof-build-id nip $cat encode-string s" model" property
178 0 0 s" relative-addressing" property
181 s" /aliases" find-device
186 s" /mmu" open-dev encode-int s" mmu" set-chosen
188 #include "available.fs"
192 #include <term-io.fs>