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 #include <fcode/evaluator.fs>
218 \ rtas-config is not used
219 0 CONSTANT rtas-config
223 s" update_flash.fs" included
225 cpu-mask @ rtas-fetch-cpus drop
227 : of-start-cpu rtas-start-cpu ;
230 ' rtas-system-reboot to reboot
232 : other-firmware rtas-get-flashside 0= IF 1 ELSE 0 THEN rtas-set-flashside reboot ;
233 : disable-boot-watchdog rtas-stop-bootwatchdog drop ;
234 ' disable-boot-watchdog to disable-watchdog
237 false value debug-boot?
239 \ for JS21/Bimini try to detect BMC... if kcs (io @ca8) status is not ff...
240 u4? IF ca8 4 + io-c@ ff = IF false to bmc? true to debug-boot? THEN THEN
244 \ Hook to help loading our secondary boot loader.
245 DEFER disk-read ( lba cnt addr -- )
248 create vpd-cb 24 allot
249 create vpd-bootlist 4 allot
251 #include "ipmi-vpd.fs"
253 #include <quiesce.fs>
255 #include <usb/usb-static.fs>
257 #include <scsi-loader.fs>
262 : .system-information ( -- )
264 s" SYSTEM INFORMATION" type cr
265 s" Processor = " type s" cpu" get-chosen IF
266 drop l@ >r pvr@ s" pvr>name" r> $call-method type
267 s" @ " type cpu-frequency d# 1000000 /
268 decimal . hex s" MHz" type
269 THEN cr s" I/O Bridge = " type u3? IF
270 s" U3" ELSE s" U4" THEN type
271 f8000000 rl@ 4 rshift s" (" type 1 0.r s" ." type
272 f8000000 rl@ f and 1 0.r s" )" type cr
273 s" SMP Size = " type cpu-mask @ cnt-bits 1 0.r
274 s" (" type cpu-report 8 emit s" )" type
275 cr s" Boot-Date = " type .date cr
276 s" Memory = " type s" memory" get-chosen IF
277 drop l@ s" mem-report" rot $call-method THEN
278 cr s" Board Type = " type u3? IF
279 s" JS20(GA" type planar-id 5 >= IF
280 s" 2)" ELSE s" 1)" THEN type
281 ELSE bimini? IF s" Bimini" ELSE s" JS21" THEN type THEN
282 s" (" type .vpd-machine-type [char] / emit
283 .vpd-machine-serial [char] / emit
284 .vpd-hw-revision 8 emit s" )" type cr
285 s" MFG Date = " type .vpd-manufacturer-date cr
286 s" Part No. = " type .vpd-part-number cr
287 s" FRU No. = " type .vpd-fru-number cr
288 s" FRU Serial = " type .vpd-cardprefix-serial .vpd-card-serial cr
289 s" UUID = " type .vpd-uuid cr
290 s" Flashside = " type rtas-get-flashside 0= IF
293 ." 1 (temporary)" THEN cr
296 romfs-base 38 + a type
298 slof-build-id here swap rmove
299 here slof-build-id nip type cr
300 s" Build Date = " type bdate2human type
308 takeover? not u4? and IF
309 \ if were are not in takeover mode the nvram should look
310 \ something like this:
312 \ ========================
313 \ 51 20000 ibm,CPU0log
314 \ 51 5000 ibm,CPU1log
316 \ 7f da000 <free-space>
317 \ the partition with the type 51 should have been added
318 \ by LLFW... if it does not exist then something went
319 \ wrong and we just destroy the whole thing
320 51 get-nvram-partition IF 0 0 nvram-c! ELSE 2drop THEN
325 \ dmesg/dmesg2 not available if running in takeover/ram mode or on js20
326 : dmesg ( -- ) u3? takeover? or 0= IF dmesg THEN ;
327 : dmesg2 ( -- ) u3? takeover? or 0= IF dmesg2 THEN ;
333 \ The client interface.
335 \ ELF binary file format.
337 #include <loaders.fs>
341 \ check wether a VGA device was found during pci scan, if it was
342 \ try to initialize it and create the needed device-nodes
344 100000 value biosemu-vmem-size
347 : init-vga-devices ( -- )
348 vga-device-node? 0= use-biosemu? 0= OR IF
351 s" VGA Device found: " type vga-device-node? node>path type s" initializing..." type cr
352 \ claim virtual memory for biosemu of 1MB
353 biosemu-vmem-size 4 claim to biosemu-vmem
354 \ claim memory for screen-info struct (140 bytes)
355 d# 140 4 claim to screen-info
356 \ remember current-node (it might be node 0 so we cannot use get-node)
358 \ change into vga device node
359 vga-device-node? set-node
360 \ run biosemu to initialize the vga card
361 \ s" Time before biosemu:" type .date cr
362 vga-device-node? node>path ( pathstr len )
363 s" biosemu " biosemu-vmem $cathex ( pathstr len paramstr len )
364 20 char-cat \ add a space ( pathstr len paramstr len )
365 biosemu-vmem-size $cathex \ add VMEM Size ( pathstr len paramstr len )
366 20 char-cat \ add a space ( pathstr len paramstr len )
367 2swap $cat ( paramstr+path len )
369 20 char-cat biosemu-debug $cathex \ add biosemu-debug as param
370 ( paramstr+path+biosemu-debug len )
373 ." biosemu client exec failed!" cr
374 set-node \ restore old current-node
377 \ s" Time after biosemu:" type .date cr
378 s" VGA initialization: detecting displays..." type cr
379 \ try to get info for two monitors
381 \ setup screen-info struct as input to get_vbe_info
382 s" DDC" 0 char-cat screen-info swap move \ null-terminated "DDC" as signature
383 d# 140 screen-info 4 + w! \ reserved size in bytes (see claim above)
384 i screen-info 6 + c! \ monitor number
385 \ 320 screen-info 7 + w! \ max. screen width (800)
386 500 screen-info 7 + w! \ max. screen width (1280)
387 \ following line would be the right thing to do, however environment seems not setup yet...
388 \ 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...
389 8 screen-info 9 + c! \ requested color depth (8bpp)
390 \ d# 16 screen-info 9 + c! \ requested color depth (16bpp)
391 \ execute get_vbe_info from load-base
392 \ s" Time before client exec:" type .date cr
393 \ since node>path overwrites strings created with s"
394 \ we need to call it before assembling the parameter string
395 vga-device-node? node>path ( pathstr len )
396 s" get_vbe_info " biosemu-vmem $cathex ( pathstr len paramstr len )
397 20 char-cat \ add a space ( pathstr len paramstr len )
398 biosemu-vmem-size $cathex \ add VMEM Size ( pathstr len paramstr len )
399 20 char-cat \ add a space ( pathstr len paramstr len )
400 2swap $cat ( paramstr+path len )
404 \ s" Time after client exec:" type .date cr
405 screen-info c@ 0<> AND IF
406 s" display " type i . s" found..." type
408 \ create device entry
409 get-node node>name \ get current nodes name (e.g. "vga") ( str len )
410 i \ put display-num on the stack ( str len displaynum )
411 new-device \ create new device
412 s" vga-display.fs" included
417 \ return to where we were before changing to vga device node
419 \ release the claimed memory
420 screen-info d# 140 release
421 biosemu-vmem biosemu-vmem-size release
423 s" VGA initialization done." type cr
428 : enable-framebuffer-output ( -- )
429 \ enable output on framebuffer
430 s" screen" find-alias ?dup IF
431 \ we need to open/close the screen device once
432 \ before "ticking" display-emit to emit
434 s" display-emit" $find IF
442 enable-framebuffer-output
446 \ do not let the usb scan overwrite the atapi cdrom alias
447 \ pci-cdrom-num TO cdrom-alias-num
450 : create-aliases ( -- )
451 s" net" s" net1" find-alias ?dup IF set-alias ELSE 2drop THEN
452 s" disk" s" disk0" find-alias ?dup IF set-alias ELSE 2drop THEN
453 s" cdrom" s" cdrom0" find-alias ?dup IF set-alias ELSE 2drop THEN
464 s" /ht/isa/serial@3f8" io
466 s" direct-serial?" evaluate IF s" /ht/isa/serial@2f8" io ELSE s" /ht/isa/serial@3f8" io THEN
472 \ on bimini we want to automatically enable screen and keyboard, if they are detected...
475 cr ." input available on current console input device, not switching input / output." cr
477 \ this enables the framebuffer as primary output device
478 s" screen" find-alias IF drop
480 \ at this point serial output is theoretically disabled
481 ." screen detected and set as default output device" cr
483 \ enable USB keyboard
484 s" keyboard" find-alias IF drop
486 \ at this point serial input is disabled
487 ." keyboard detected and set as default input device" cr cr cr
488 s" Press 's' to enter Open Firmware." type cr
495 cr ." The currently active flashside is: "
496 rtas-get-flashside 0= IF ." 0 (permanent)" ELSE
497 ." 1 (temporary)" THEN
500 bmc? IF disable-watchdog THEN
502 : flashsave ( "{filename}" -- rc )
503 (parse-line) dup 0> IF
504 s" netsave " \ command
505 get-flash-base $cathex \ Flash base addr
506 s" 400000 " $cat \ Flash size (4MB)
507 2swap $cat \ add parameters from (parse-line)
511 ." Usage: flashsave [bootp|dhcp,]filename[,siaddr][,ciaddr][,giaddr][,bootp-retries][,tftp-retries][,use_ci]"
516 #include <vpd-bootlist.fs>
518 \ for the blades we read the bootlist from the VPD
519 bimini? takeover? or 0= IF ['] vpd-boot-import to read-bootlist THEN
521 \ for the bimini, we try to boot from disk, if it exists,
522 \ only if "boot-device" is not set in the nvram
525 s" boot-device" evaluate swap drop ( boot-device-strlen )
527 \ no boot-device set in NVRAM, check if disk is available and set it...
528 \ clear boot-device list
530 s" disk" find-alias ?dup IF
531 \ alias found, use it as default
537 bimini? IF ['] bimini-bootlist to read-bootlist THEN
539 #include <start-up.fs>
543 cr .( Welcome to Open Firmware)
545 #include "copyright-oss.fs"
548 \ this CATCH is to ensure the code bellow always executes: boot may ABORT!
549 ' start-it CATCH drop
551 #include <history.fs>
553 ." loading shell history .. "