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
\ The master file. Everything else is included into here.
19
\ as early as possible we want to know if it is js20, js21 or bimini
20
\ u3 = js20; u4 = js21/bimini
21
\ the difference if bimini or js21 will be done later depending if
22
\ obsidian or citrine is found
23
\ f8000000 is probably the place of the u3/u4 version
24
f8000000 rl@ CONSTANT uni-n-version
25
uni-n-version 4 rshift dup 3 = CONSTANT u3? 4 = CONSTANT u4?
26
\ if (f4000682 >> 4) == 1... it is a bimini...
27
f4000682 rb@ 4 rshift 1 = CONSTANT bimini?
29
\ to decide wether vga initialisation using bios emulation should be attempted,
30
\ we need to know wether a vga-device was found during pci-scan.
31
\ If it is found, this value will be set to the device's phandle
32
0 value vga-device-node?
34
\ planar-id reads back GPIO 29 30 31 and returns it as one value
35
\ if planar-id >= 5 it should be GA2 else it is GA1 (JS20 only)
36
defer planar-id ( -- planar-id )
38
: (planar-id) ( -- planar-id)
39
\ default implementation of planar-id just returns 8
40
\ the highest possible planar id for JS20 is 7
44
' (planar-id) to planar-id
51
\ XXX: Enable first UART on JS20, scripts forget to do this. Sigh.
52
3 7 siocfg! 1 30 siocfg!
60
\ Little-endian accesses. Also known as `wrong-endian'.
61
#include <little-endian.fs>
63
\ do not free-mem if address is not within the heap
64
\ workaround for NVIDIA card
65
: free-mem ( addr len -- )
66
over heap-start heap-end within IF
73
: #join ( lo hi #bits -- x ) lshift or ;
74
: #split ( x #bits -- lo hi ) 2dup rshift dup >r swap lshift xor r> ;
80
: console-clean-fifo ;
84
: asm-cout 2drop drop ;
94
\ disable the nvram logging until we know if we are
95
\ running from ram/takeover/js20 or in normal mode on js21
96
: (nvramlog-write-byte) drop ;
97
' (nvramlog-write-byte) to nvramlog-write-byte
99
#include "exception.fs"
101
: mm-log-warning 2drop ;
103
: write-mm-log ( data length type -- status )
113
\ Input line editing.
120
cistack ciregs >r1 ! \ kernel wants a stack :-)
127
\ 1 temp; 0 perm; let's default to temp
130
\ claim the memory used by copy of the flash
132
romfs-base dup flash-image-size 0 claim drop
135
s" bootinfo" romfs-lookup drop c + l@ CONSTANT start-addr
136
start-addr flash-addr <> CONSTANT takeover?
138
takeover? u3? or 0= IF
139
\ we want nvram logging to work
140
['] .nvramlog-write-byte to nvramlog-write-byte
145
u4? IF f8002100 rl@ 0= ELSE false THEN ?INCLUDE u4-mem.fs
150
\ change nvram-size to 8000 for GA1 blades
157
\ potentially coming from phype
159
\ takeover on JS21 is using some nvram area
160
\ which might be available
161
\ on JS20 the nvram is too small and
162
\ we just overwrite the nvram
163
sec-nvram-base to nvram-base
165
sec-nvram-size to nvram-size
166
\ in takeover mode the nvram is probably not mapped
167
\ to the exact location where the nvram starts
168
\ doing a small check to see if we have a partition
169
\ starting with 70; this test is far from perfect but
170
\ takeover is not the most common mode of running slof
171
nvram-base rb@ 70 <> IF 0 nvram-base rb! THEN
176
#include <slof-logo.fs>
179
: .banner .slof-logo .banner ;
181
\ Get the secondary CPUs into our own spinloop.
182
f8000050 rl@ CONSTANT master-cpu
183
\ cr .( The master cpu is #) master-cpu .
186
: get-slave ( n -- online? )
187
0 3ff8 ! 18 lshift 30000000 or 48003f02 over l! icbi 10000 0 DO LOOP 3ff8 @ ;
188
: mark-online ( n -- ) 1 swap lshift cpu-mask @ or cpu-mask ! ;
189
: get-slaves 40 0 DO i get-slave IF i mark-online THEN LOOP ;
191
cpu-mask @ 40 0 DO dup 1 and IF ." #" i . THEN 1 rshift LOOP drop
195
master-cpu mark-online get-slaves
197
DEFER disable-watchdog ( -- )
198
DEFER find-boot-sector ( -- )
202
\ Timebase frequency, in Hz.
203
\ -1 VALUE tb-frequency
204
d# 14318378 VALUE tb-frequency \ default value - needed for "ms" to work
205
-1 VALUE cpu-frequency
210
#include <timebase.fs>
214
\ rtas-config is not used
215
0 CONSTANT rtas-config
219
s" update_flash.fs" included
221
cpu-mask @ rtas-fetch-cpus drop
223
: of-start-cpu rtas-start-cpu ;
226
' rtas-system-reboot to reboot
228
: other-firmware rtas-get-flashside 0= IF 1 ELSE 0 THEN rtas-set-flashside reboot ;
229
: disable-boot-watchdog rtas-stop-bootwatchdog drop ;
230
' disable-boot-watchdog to disable-watchdog
233
false value debug-boot?
235
\ for JS21/Bimini try to detect BMC... if kcs (io @ca8) status is not ff...
236
u4? IF ca8 4 + io-c@ ff = IF false to bmc? true to debug-boot? THEN THEN
240
\ Hook to help loading our secondary boot loader.
241
DEFER disk-read ( lba cnt addr -- )
244
create vpd-cb 24 allot
245
create vpd-bootlist 4 allot
247
#include "ipmi-vpd.fs"
249
#include <quiesce.fs>
251
#include <usb/usb-static.fs>
253
#include <scsi-loader.fs>
258
: .system-information ( -- )
260
s" SYSTEM INFORMATION" type cr
261
s" Processor = " type s" cpu" get-chosen IF
262
drop l@ >r pvr@ s" pvr>name" r> $call-method type
263
s" @ " type cpu-frequency d# 1000000 /
264
decimal . hex s" MHz" type
265
THEN cr s" I/O Bridge = " type u3? IF
266
s" U3" ELSE s" U4" THEN type
267
f8000000 rl@ 4 rshift s" (" type 1 0.r s" ." type
268
f8000000 rl@ f and 1 0.r s" )" type cr
269
s" SMP Size = " type cpu-mask @ cnt-bits 1 0.r
270
s" (" type cpu-report 8 emit s" )" type
271
cr s" Boot-Date = " type .date cr
272
s" Memory = " type s" memory" get-chosen IF
273
drop l@ s" mem-report" rot $call-method THEN
274
cr s" Board Type = " type u3? IF
275
s" JS20(GA" type planar-id 5 >= IF
276
s" 2)" ELSE s" 1)" THEN type
277
ELSE bimini? IF s" Bimini" ELSE s" JS21" THEN type THEN
278
s" (" type .vpd-machine-type [char] / emit
279
.vpd-machine-serial [char] / emit
280
.vpd-hw-revision 8 emit s" )" type cr
281
s" MFG Date = " type .vpd-manufacturer-date cr
282
s" Part No. = " type .vpd-part-number cr
283
s" FRU No. = " type .vpd-fru-number cr
284
s" FRU Serial = " type .vpd-cardprefix-serial .vpd-card-serial cr
285
s" UUID = " type .vpd-uuid cr
286
s" Flashside = " type rtas-get-flashside 0= IF
289
." 1 (temporary)" THEN cr
292
romfs-base 38 + a type
294
slof-build-id here swap rmove
295
here slof-build-id nip type cr
296
s" Build Date = " type bdate2human type
304
takeover? not u4? and IF
305
\ if were are not in takeover mode the nvram should look
306
\ something like this:
308
\ ========================
309
\ 51 20000 ibm,CPU0log
310
\ 51 5000 ibm,CPU1log
312
\ 7f da000 <free-space>
313
\ the partition with the type 51 should have been added
314
\ by LLFW... if it does not exist then something went
315
\ wrong and we just destroy the whole thing
316
51 get-nvram-partition IF 0 0 nvram-c! ELSE 2drop THEN
321
\ dmesg/dmesg2 not available if running in takeover/ram mode or on js20
322
: dmesg ( -- ) u3? takeover? or 0= IF dmesg THEN ;
323
: dmesg2 ( -- ) u3? takeover? or 0= IF dmesg2 THEN ;
329
\ The client interface.
331
\ ELF binary file format.
333
#include <loaders.fs>
337
\ check wether a VGA device was found during pci scan, if it was
338
\ try to initialize it and create the needed device-nodes
340
100000 value biosemu-vmem-size
343
: init-vga-devices ( -- )
344
vga-device-node? 0= use-biosemu? 0= OR IF
347
s" VGA Device found: " type vga-device-node? node>path type s" initializing..." type cr
348
\ claim virtual memory for biosemu of 1MB
349
biosemu-vmem-size 4 claim to biosemu-vmem
350
\ claim memory for screen-info struct (140 bytes)
351
d# 140 4 claim to screen-info
352
\ remember current-node (it might be node 0 so we cannot use get-node)
354
\ change into vga device node
355
vga-device-node? set-node
356
\ run biosemu to initialize the vga card
357
\ s" Time before biosemu:" type .date cr
358
vga-device-node? node>path ( pathstr len )
359
s" biosemu " biosemu-vmem $cathex ( pathstr len paramstr len )
360
20 char-cat \ add a space ( pathstr len paramstr len )
361
biosemu-vmem-size $cathex \ add VMEM Size ( pathstr len paramstr len )
362
20 char-cat \ add a space ( pathstr len paramstr len )
363
2swap $cat ( paramstr+path len )
365
20 char-cat biosemu-debug $cathex \ add biosemu-debug as param
366
( paramstr+path+biosemu-debug len )
369
." biosemu client exec failed!" cr
370
set-node \ restore old current-node
373
\ s" Time after biosemu:" type .date cr
374
s" VGA initialization: detecting displays..." type cr
375
\ try to get info for two monitors
377
\ setup screen-info struct as input to get_vbe_info
378
s" DDC" 0 char-cat screen-info swap move \ null-terminated "DDC" as signature
379
d# 140 screen-info 4 + w! \ reserved size in bytes (see claim above)
380
i screen-info 6 + c! \ monitor number
381
\ 320 screen-info 7 + w! \ max. screen width (800)
382
500 screen-info 7 + w! \ max. screen width (1280)
383
\ following line would be the right thing to do, however environment seems not setup yet...
384
\ screen-#columns char-width * 500 min 280 max screen-info 7 + w! \ max. screen width, calculated from environment variable screen-#columns, but max. 1280, min. 640...
385
8 screen-info 9 + c! \ requested color depth (8bpp)
386
\ d# 16 screen-info 9 + c! \ requested color depth (16bpp)
387
\ execute get_vbe_info from load-base
388
\ s" Time before client exec:" type .date cr
389
\ since node>path overwrites strings created with s"
390
\ we need to call it before assembling the parameter string
391
vga-device-node? node>path ( pathstr len )
392
s" get_vbe_info " biosemu-vmem $cathex ( pathstr len paramstr len )
393
20 char-cat \ add a space ( pathstr len paramstr len )
394
biosemu-vmem-size $cathex \ add VMEM Size ( pathstr len paramstr len )
395
20 char-cat \ add a space ( pathstr len paramstr len )
396
2swap $cat ( paramstr+path len )
400
\ s" Time after client exec:" type .date cr
401
screen-info c@ 0<> AND IF
402
s" display " type i . s" found..." type
404
\ create device entry
405
get-node node>name \ get current nodes name (e.g. "vga") ( str len )
406
i \ put display-num on the stack ( str len displaynum )
407
new-device \ create new device
408
s" vga-display.fs" included
413
\ return to where we were before changing to vga device node
415
\ release the claimed memory
416
screen-info d# 140 release
417
biosemu-vmem biosemu-vmem-size release
419
s" VGA initialization done." type cr
424
: enable-framebuffer-output ( -- )
425
\ enable output on framebuffer
426
s" screen" find-alias ?dup IF
427
\ we need to open/close the screen device once
428
\ before "ticking" display-emit to emit
430
s" display-emit" $find IF
438
enable-framebuffer-output
442
\ do not let the usb scan overwrite the atapi cdrom alias
443
\ pci-cdrom-num TO cdrom-alias-num
446
: create-aliases ( -- )
447
s" net" s" net1" find-alias ?dup IF set-alias ELSE 2drop THEN
448
s" disk" s" disk0" find-alias ?dup IF set-alias ELSE 2drop THEN
449
s" cdrom" s" cdrom0" find-alias ?dup IF set-alias ELSE 2drop THEN
460
s" /ht/isa/serial@3f8" io
462
s" direct-serial?" evaluate IF s" /ht/isa/serial@2f8" io ELSE s" /ht/isa/serial@3f8" io THEN
468
\ on bimini we want to automatically enable screen and keyboard, if they are detected...
471
cr ." input available on current console input device, not switching input / output." cr
473
\ this enables the framebuffer as primary output device
474
s" screen" find-alias IF drop
476
\ at this point serial output is theoretically disabled
477
." screen detected and set as default output device" cr
479
\ enable USB keyboard
480
s" keyboard" find-alias IF drop
482
\ at this point serial input is disabled
483
." keyboard detected and set as default input device" cr cr cr
484
s" Press 's' to enter Open Firmware." type cr
491
cr ." The currently active flashside is: "
492
rtas-get-flashside 0= IF ." 0 (permanent)" ELSE
493
." 1 (temporary)" THEN
496
bmc? IF disable-watchdog THEN
498
: flashsave ( "{filename}" -- rc )
499
(parse-line) dup 0> IF
500
s" netsave " \ command
501
get-flash-base $cathex \ Flash base addr
502
s" 400000 " $cat \ Flash size (4MB)
503
2swap $cat \ add parameters from (parse-line)
507
." Usage: flashsave [bootp|dhcp,]filename[,siaddr][,ciaddr][,giaddr][,bootp-retries][,tftp-retries][,use_ci]"
512
#include <vpd-bootlist.fs>
514
\ for the blades we read the bootlist from the VPD
515
bimini? takeover? or 0= IF ['] vpd-boot-import to read-bootlist THEN
517
\ for the bimini, we try to boot from disk, if it exists,
518
\ only if "boot-device" is not set in the nvram
521
s" boot-device" evaluate swap drop ( boot-device-strlen )
523
\ no boot-device set in NVRAM, check if disk is available and set it...
524
\ clear boot-device list
526
s" disk" find-alias ?dup IF
527
\ alias found, use it as default
533
bimini? IF ['] bimini-bootlist to read-bootlist THEN
535
#include <start-up.fs>
539
cr .( Welcome to Open Firmware)
541
#include "copyright-oss.fs"
544
\ this CATCH is to ensure the code bellow always executes: boot may ABORT!
545
' start-it CATCH drop
547
#include <history.fs>
549
." loading shell history .. "