1
\ *****************************************************************************
2
\ * Copyright (c) 2004, 2008 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
#include <rtas/rtas-init.fs>
14
#include <rtas/rtas-cpu.fs>
15
#include <rtas/rtas-reboot.fs>
16
#include <rtas/rtas-flash.fs>
17
#include <rtas/rtas-vpd.fs>
20
: (get-flashside) ( -- flashside ) rtas-get-flashside ;
22
' (get-flashside) to get-flashside
24
\ remember the current flashside
25
get-flashside to flashside?
28
: (set-flashside) ( flashside -- status )
29
dup rtas-set-flashside = IF 0 ELSE -1 THEN
32
' (set-flashside) to set-flashside
34
: rtas-ibm-read-pci-config ( size puid bus devfn off -- x )
35
[ s" ibm,read-pci-config" rtas-get-token ] LITERAL rtas-cb rtas>token l!
36
4 rtas-cb rtas>nargs l!
37
2 rtas-cb rtas>nret l!
38
swap 8 lshift or swap 10 lshift or rtas-cb rtas>args0 l!
39
dup 20 rshift rtas-cb rtas>args1 l!
40
ffffffff and rtas-cb rtas>args2 l!
46
: rtas-fetch-cpus ( mask -- status )
47
[ s" rtas-fetch-slaves" rtas-get-token ] LITERAL rtas-cb rtas>token l!
48
1 rtas-cb rtas>nargs l!
49
1 rtas-cb rtas>nret l!
51
0 rtas-cb rtas>args1 l!
56
: rtas-stop-bootwatchdog ( -- status )
57
[ s" rtas-stop-bootwatchdog" rtas-get-token ] LITERAL rtas-cb rtas>token l!
58
0 rtas-cb rtas>nargs l!
59
1 rtas-cb rtas>nret l!
64
: rtas-set-bootwatchdog ( seconds -- )
65
[ s" rtas-set-bootwatchdog" rtas-get-token ] LITERAL rtas-cb rtas>token l!
66
1 rtas-cb rtas>nargs l!
67
0 rtas-cb rtas>nret l!
72
' rtas-set-bootwatchdog to set-watchdog
74
: rtas-dump-flash ( offset cnt -- )
75
[ s" rtas-dump-flash" rtas-get-token ] LITERAL rtas-cb rtas>token l!
76
2 rtas-cb rtas>nargs l!
77
0 rtas-cb rtas>nret l!
83
\ load-base wird in slof/fs/base.fs gesetzt... nicht überschreiben
84
\ 2000000 CONSTANT load-base
91
\ set length of block list
94
0000000000000000 blist 8 + !
96
load-base 0 + blist 10 + !
98
load-base 80000 + blist 20 + !
100
load-base 100000 + blist 30 + !
102
load-base 180000 + blist 40 + !
106
80000 constant _block_size
109
\ set length of block list
110
\ length of flashfs at load-base is at offset 30... get it...
112
\ calculate the number of blocks we need
114
\ total number of blocks is 2 (for header and block_list extension + (number of blocks for flashfs * 2 (1 for address 1 for length))
116
\ set version ( in first byte only )
119
0000000000000000 blist 8 + !
120
\ length of flashfs at load-base is at offset 30... get it...
122
\ i define one block to be 64K, so calculate the number of blocks we need and loop over them
123
_block_size / 1 + 0 do
124
load-base _block_size i * + \ which position of load-base to store
125
blist 10 + \ at what offset of blist ( 0x8 + for header 0x8 + for extension )
126
i 10 * + \ for each loop we have done 0x10 +
129
_block_size i * - \ remaining length
131
IF \ is the remaining length > block size
132
drop _block_size \ then store the block size as length
134
\ do nothing (store remaining length)
136
blist 10 + \ store the length at
137
i 10 * + \ correct blist offset
138
8 + \ + 8 (we have stored address, now the length)
145
: build-blocklist-v0_old
150
load-base 0 + blist 8 + !
152
load-base 80000 + blist 18 + !
154
load-base 100000 + blist 28 + !
156
load-base 180000 + blist 38 + !
161
\ set length of block list
162
\ length of flashfs at load-base is at offset 30... get it...
164
\ calculate the number of blocks we need
166
\ total number of blocks is 1 (for header + (number of blocks for flashfs * 2 (1 for address 1 for length))
168
\ length of flashfs at load-base is at offset 30... get it...
170
\ i define one block to be 64K, so calculate the number of blocks we need and loop over them
171
_block_size / 1 + 0 do
172
load-base _block_size i * + \ which position of load-base to store
173
blist 8 + \ at what offset of blist ( 0x8 + for header)
174
i 10 * + \ for each loop we have done 0x10 +
177
_block_size i * - \ remaining length
179
IF \ is the remaining length > block size
180
drop _block_size \ then store the block size as length
182
\ do nothing (store remaining length)
184
blist 8 + \ store the length at
185
i 10 * + \ correct blist offset
186
8 + \ + 8 (we have stored address, now the length)
194
blist rtas-ibm-update-flash-64-and-reboot
199
blist rtas-ibm-update-flash-64-and-reboot
202
: rtas-ibm-update-flash-64 ( block-list -- status )
203
[ s" ibm,update-flash-64" rtas-get-token ] LITERAL rtas-cb rtas>token l!
204
2 rtas-cb rtas>nargs l!
205
1 rtas-cb rtas>nret l!
206
rtas-cb rtas>args0 l!
207
\ special unofficial parameter: if this is set to 1, the rtas function will not check, wether
208
\ we are on the perm side... this is needed for "update-flash -c" to work...
209
1 rtas-cb rtas>args1 l!
211
rtas-cb rtas>args2 l@
215
: flash-write ( image-address -- status)
216
load-base >r to load-base build-blocklist-v0
217
blist rtas-ibm-update-flash-64
218
r> to load-base 0= IF true ELSE false THEN
221
: commit 1 rtas-ibm-manage-flash-image ;
222
: reject 0 rtas-ibm-manage-flash-image ;
224
: rtas-ibm-validate-flash-image ( image-to-commit -- status )
225
[ s" ibm,validate-flash-image" rtas-get-token ] LITERAL rtas-cb rtas>token l!
226
2 rtas-cb rtas>nargs l!
227
2 rtas-cb rtas>nret l!
228
rtas-cb rtas>args0 l!
230
rtas-cb rtas>args1 l@
233
: rtas-get-blade-descr ( address size -- len status )
234
[ s" rtas-get-blade-descr" rtas-get-token ] LITERAL rtas-cb rtas>token l!
235
2 rtas-cb rtas>nargs l!
236
2 rtas-cb rtas>nret l!
237
rtas-cb rtas>args1 l!
238
rtas-cb rtas>args0 l!
240
rtas-cb rtas>args2 l@
241
rtas-cb rtas>args3 l@