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 \ The master file. Everything else is included into here.
25 \ Set default load-base to 0x4000
26 4000 to default-load-base
28 \ Little-endian accesses. Also known as `wrong-endian'.
29 #include <little-endian.fs>
31 : #join ( lo hi #bits -- x ) lshift or ;
32 : #split ( x #bits -- lo hi ) 2dup rshift dup >r swap lshift xor r> ;
36 : console-clean-fifo ;
38 : asm-cout 2drop drop ;
48 #include "exception.fs"
50 : mm-log-warning 2drop ;
52 : write-mm-log ( data length type -- status )
65 cistack ciregs >r1 ! \ kernel wants a stack :-)
73 #include <slof-logo.fs>
79 : .banner .slof-logo .banner ;
83 DEFER find-boot-sector ( -- )
86 \ Timebase frequency, in Hz. Start with a good default
87 \ Use device-tree later to fix it up
88 d# 512000000 VALUE tb-frequency \ default value - needed for "ms" to work
89 -1 VALUE cpu-frequency
94 #include <timebase.fs>
98 #include <fcode/evaluator.fs>
102 #include <quiesce.fs>
106 #include <usb/usb-static.fs>
110 #include <scsi-loader.fs>
123 s" qemu,boot-menu" get-chosen IF
125 ." Press F12 for boot menu." cr cr
134 \ Grab rtas from qemu
156 #include "qemu-bootlist.fs"
160 \ The client interface.
162 \ ELF binary file format.
164 #include <loaders.fs>
167 CREATE version-str 10 ALLOT
170 : dump-display-buffer
172 " SLOF **********************************************************************" terminal-write drop
174 version-str get-print-version
175 version-str @ \ start
176 version-str 8 + @ \ end
177 over - terminal-write drop
178 " Press 's' to enter Open Firmware." terminal-write drop
180 temp-ptr disp-size > IF
181 temp-ptr disp-size MOD
183 prevga-disp-buf + swap disp-size swap - terminal-write drop
184 temp-ptr disp-size MOD
185 prevga-disp-buf swap 1 - terminal-write drop
187 prevga-disp-buf temp-ptr terminal-write drop
191 : enable-framebuffer-output ( -- )
192 \ enable output on framebuffer
193 s" screen" find-alias ?dup IF
194 \ we need to open/close the screen device once
195 \ before "ticking" display-emit to emit
197 false to store-prevga?
198 s" display-emit" $find IF
207 enable-framebuffer-output
216 \ Claim remaining memory that is used by firmware:
217 romfs-base 400000 0 ' claim CATCH IF ." claim failed!" cr 2drop THEN drop
221 : set-default-console
222 s" linux,stdout-path" get-chosen IF
224 ." Using default console: " 2dup type cr
228 ." No console specified "
229 " screen" find-alias dup IF nip THEN
230 " keyboard" find-alias dup IF nip THEN
232 ." using screen & keyboard" cr
236 " hvterm" find-alias IF
241 " /openprom" find-node ?dup IF
243 ." and no default found, creating dev-null" cr
244 " dev-null.fs" included
245 " devnull-console" io
256 \ Check if we are booting a kernel passed by qemu, in which case
257 \ we skip initializing some devices
259 0 VALUE direct-ram-boot-base
260 0 VALUE direct-ram-boot-size
263 direct-ram-boot-size 0<> IF
264 ." Booting from memory..." cr
265 s" go-args 2@ " evaluate
266 direct-ram-boot-base 0
267 s" true state-valid ! " evaluate
268 s" disable-watchdog go-64" evaluate
274 : check-boot-from-ram
275 s" qemu,boot-kernel" get-chosen IF
276 decode-int -rot decode-int -rot ( n1 n2 p s )
277 decode-int -rot decode-int -rot ( n1 n2 n3 n4 p s )
279 swap 20 << or to direct-ram-boot-size
280 swap 20 << or to direct-ram-boot-base
281 ." Detected RAM kernel at " direct-ram-boot-base .
282 ." (" direct-ram-boot-size . ." bytes) "
283 \ Override the boot-command word without touching the
285 s" boot-command" $create " (boot-ram)" env-string
292 #include <start-up.fs>
294 ." " \ Clear last checkpoint
298 cr .( Welcome to Open Firmware)
300 #include "copyright-oss.fs"
303 \ this CATCH is to ensure the code bellow always executes: boot may ABORT!
304 ' start-it CATCH drop