1 \ *****************************************************************************
2 \ * Copyright (c) 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 \ ****************************************************************************/
31 /l C * field rtas>args
33 CONSTANT /rtas-control-block
35 CREATE rtas-cb /rtas-control-block allot
36 rtas-cb /rtas-control-block erase
43 \ Locate qemu RTAS, remove the linux,... properties we really don't
44 \ want them to stick around
48 : find-qemu-rtas ( -- )
49 " /rtas" find-device get-node to rtas-node
51 " linux,rtas-base" rtas-node get-package-property IF
54 " linux,rtas-base" delete-property
56 " rtas-size" rtas-node get-package-property IF
60 " linux,rtas-entry" rtas-node get-package-property IF
61 rtas-base to rtas-entry
64 " linux,rtas-entry" delete-property
67 \ ." RTAS found, base=" rtas-base . ." size=" rtas-size . cr
69 \ Patch the RTAS blob with our sc1 patcher if necessary
81 rtas-cb rtas-base 0 rtas-entry call-c drop
84 : rtas-get-token ( str len -- token | 0 )
85 rtas-node get-package-property IF 0 ELSE drop l@ THEN
88 #include <rtas/rtas-reboot.fs>
89 #include <rtas/rtas-cpu.fs>
91 : rtas-set-tce-bypass ( unit enable -- )
92 " ibm,set-tce-bypass" rtas-get-token rtas-cb rtas>token l!
93 2 rtas-cb rtas>nargs l!
94 0 rtas-cb rtas>nret l!
100 : rtas-quiesce ( -- )
101 " quiesce" rtas-get-token rtas-cb rtas>token l!
102 0 rtas-cb rtas>nargs l!
103 0 rtas-cb rtas>nret l!
110 : rtas-do-config-@ ( config-addr size -- value)
111 \ We really want to cache this !
112 " ibm,read-pci-config" rtas-get-token rtas-cb rtas>token l!
113 4 rtas-cb rtas>nargs l!
114 2 rtas-cb rtas>nret l!
115 ( addr size ) rtas-cb rtas>args3 l!
116 puid ffffffff and rtas-cb rtas>args2 l!
117 puid 20 rshift rtas-cb rtas>args1 l!
118 ( addr ) rtas-cb rtas>args0 l!
120 rtas-cb rtas>args4 l@ dup IF
121 \ Do not warn on error as this is part of the
122 \ normal PCI probing pass
125 drop rtas-cb rtas>args5 l@
129 : rtas-do-config-! ( value config-addr size )
130 \ We really want to cache this !
131 " ibm,write-pci-config" rtas-get-token rtas-cb rtas>token l!
132 5 rtas-cb rtas>nargs l!
133 1 rtas-cb rtas>nret l!
134 ( value addr size ) rtas-cb rtas>args3 l!
135 puid ffffffff and rtas-cb rtas>args2 l!
136 puid 20 rshift rtas-cb rtas>args1 l!
137 ( value addr ) rtas-cb rtas>args0 l!
138 ( value ) rtas-cb rtas>args4 l!
140 rtas-cb rtas>args5 l@ dup IF
141 ." RTAS write config err " . cr
145 : rtas-config-b@ ( config-addr -- value )
146 1 rtas-do-config-@ ff and
148 : rtas-config-b! ( value config-addr -- )
151 : rtas-config-w@ ( config-addr -- value )
152 2 rtas-do-config-@ ffff and
154 : rtas-config-w! ( value config-addr -- )
157 : rtas-config-l@ ( config-addr -- value )
158 4 rtas-do-config-@ ffffffff and
160 : rtas-config-l! ( value config-addr -- )
164 : of-start-cpu rtas-start-cpu ;
167 ' rtas-system-reboot to reboot
169 \ Methods of the rtas node proper
175 : instantiate-rtas ( adr -- entry )
176 dup rtas-base swap rtas-size move
177 dup rtas-entry rtas-base - +
178 2dup hv-rtas-update dup 0 <> IF
179 \ Ignore hcall not implemented error, print error otherwise
180 dup -2 <> IF ." HV-RTAS-UPDATE error: " . cr ELSE drop THEN