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
152 #include "qemu-bootlist.fs"
156 \ The client interface.
158 \ ELF binary file format.
160 #include <loaders.fs>
163 CREATE version-str 10 ALLOT
166 : dump-display-buffer
168 " SLOF **********************************************************************" terminal-write drop
170 version-str get-print-version
171 version-str @ \ start
172 version-str 8 + @ \ end
173 over - terminal-write drop
174 " Press 's' to enter Open Firmware." terminal-write drop
176 temp-ptr disp-size > IF
177 temp-ptr disp-size MOD
179 prevga-disp-buf + swap disp-size swap - terminal-write drop
180 temp-ptr disp-size MOD
181 prevga-disp-buf swap 1 - terminal-write drop
183 prevga-disp-buf temp-ptr terminal-write drop
187 : enable-framebuffer-output ( -- )
188 \ enable output on framebuffer
189 s" screen" find-alias ?dup IF
190 \ we need to open/close the screen device once
191 \ before "ticking" display-emit to emit
193 false to store-prevga?
194 s" display-emit" $find IF
203 enable-framebuffer-output
212 \ Claim remaining memory that is used by firmware:
213 romfs-base 400000 0 ' claim CATCH IF ." claim failed!" cr 2drop THEN drop
217 : set-default-console
218 s" linux,stdout-path" get-chosen IF
220 ." Using default console: " 2dup type cr
224 ." No console specified "
225 " screen" find-alias dup IF nip THEN
226 " keyboard" find-alias dup IF nip THEN
228 ." using screen & keyboard" cr
232 " hvterm" find-alias IF
237 " /openprom" find-node ?dup IF
239 ." and no default found, creating dev-null" cr
240 " dev-null.fs" included
241 " devnull-console" io
252 \ Check if we are booting a kernel passed by qemu, in which case
253 \ we skip initializing some devices
255 0 VALUE direct-ram-boot-base
256 0 VALUE direct-ram-boot-size
259 direct-ram-boot-size 0<> IF
260 ." Booting from memory..." cr
261 s" go-args 2@ " evaluate
262 direct-ram-boot-base 0
263 s" true state-valid ! " evaluate
264 s" disable-watchdog go-64" evaluate
270 : check-boot-from-ram
271 s" qemu,boot-kernel" get-chosen IF
272 decode-int -rot decode-int -rot ( n1 n2 p s )
273 decode-int -rot decode-int -rot ( n1 n2 n3 n4 p s )
275 swap 20 << or to direct-ram-boot-size
276 swap 20 << or to direct-ram-boot-base
277 ." Detected RAM kernel at " direct-ram-boot-base .
278 ." (" direct-ram-boot-size . ." bytes) "
279 \ Override the boot-command word without touching the
281 s" boot-command" $create " (boot-ram)" env-string
288 #include <start-up.fs>
290 ." " \ Clear last checkpoint
294 cr .( Welcome to Open Firmware)
296 #include "copyright-oss.fs"
299 \ this CATCH is to ensure the code bellow always executes: boot may ABORT!
300 ' start-it CATCH drop