mirror of
https://gitlab.com/qemu-project/openbios.git
synced 2024-02-13 08:34:06 +08:00
IEEE-1275 spec compliance. This patch implements the following: 1) Fix bootpath/bootargs handling so that default values are read from NVRAM, and allow multiple space-separated values to be specified. 2) With correct bootargs handling in place, move the ELF loader over to the new libopenbios unified loaders. 3) Remove all the loader code from all architecture directories sine we don't need it anymore. 4) Simplify the boot word so it invokes platform-specific code where required, then calls load and go as per the specification. Tested on all my available images for SPARC32, SPARC64 and PPC, and compile-tested on x86. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@siriusit.co.uk> git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@828 f158a5a8-5612-0410-a976-696ce0be7e32
238 lines
3.7 KiB
Forth
238 lines
3.7 KiB
Forth
\ 7.6 Client Program Debugging command group
|
|
|
|
|
|
\ 7.6.1 Registers display
|
|
|
|
: ctrace ( -- )
|
|
;
|
|
|
|
: .registers ( -- )
|
|
;
|
|
|
|
: .fregisters ( -- )
|
|
;
|
|
|
|
\ to ( param [old-name< >] -- )
|
|
|
|
|
|
\ 7.6.2 Program download and execute
|
|
|
|
struct ( saved-program-state )
|
|
/n field >sps.entry
|
|
/n field >sps.file-size
|
|
/n field >sps.file-type
|
|
constant saved-program-state.size
|
|
create saved-program-state saved-program-state.size allot
|
|
|
|
variable state-valid
|
|
0 state-valid !
|
|
|
|
variable file-size
|
|
|
|
: !load-size file-size ! ;
|
|
|
|
: load-size file-size @ ;
|
|
|
|
|
|
\ File types identified by (init-program)
|
|
|
|
0 constant elf-boot
|
|
1 constant elf
|
|
2 constant bootinfo
|
|
3 constant xcoff
|
|
4 constant pe
|
|
5 constant aout
|
|
10 constant fcode
|
|
11 constant forth
|
|
|
|
|
|
: init-program ( -- )
|
|
\ Call down to the lower level for relocation etc.
|
|
s" (init-program)" $find if
|
|
execute
|
|
else
|
|
s" Unable to locate (init-program)!" type cr
|
|
then
|
|
;
|
|
|
|
: (encode-bootpath) ( "{params}<cr>" -- bootpath-str bootpath-len)
|
|
\ Parse the current input buffer of a load/boot command and set both
|
|
\ the bootargs and bootpath properties as appropriate.
|
|
cr
|
|
|
|
\ bootpath
|
|
bl parse dup 0= if
|
|
|
|
\ None specified. As per IEEE-1275 specification, search through each value
|
|
\ in boot-device and use the first that returns a valid ihandle on open.
|
|
s" boot-device" $find drop execute
|
|
bl left-split
|
|
begin
|
|
dup
|
|
while
|
|
2dup s" Trying " type type s" ..." type cr
|
|
2dup open-dev ?dup if
|
|
close-dev
|
|
2swap drop 0 \ Fake end of string so we exit loop
|
|
else
|
|
2drop
|
|
bl left-split
|
|
then
|
|
repeat
|
|
2drop
|
|
else
|
|
0 0 2swap \ Fake (empty) parse string
|
|
then
|
|
|
|
\ Set the bootpath property
|
|
2dup encode-string
|
|
" /chosen" (find-dev) if
|
|
" bootpath" rot (property)
|
|
then
|
|
|
|
\ bootargs
|
|
linefeed parse dup 0= if
|
|
\ None specified, use default from nvram
|
|
2drop s" boot-file" $find drop execute
|
|
then
|
|
|
|
\ Set the bootargs property
|
|
encode-string
|
|
" /chosen" (find-dev) if
|
|
" bootargs" rot (property)
|
|
then
|
|
|
|
\ Remove the remaining string
|
|
2swap 2drop
|
|
;
|
|
|
|
: $load ( devstr len )
|
|
open-dev ( ihandle )
|
|
dup 0= if
|
|
drop
|
|
exit
|
|
then
|
|
dup >r
|
|
" load-base" evaluate swap ( load-base ihandle )
|
|
dup ihandle>phandle " load" rot find-method ( xt 0|1 )
|
|
if swap call-package !load-size else cr ." Cannot find load for this package" 2drop then
|
|
r> close-dev
|
|
init-program
|
|
;
|
|
|
|
: load ( "{params}<cr>" -- )
|
|
(encode-bootpath)
|
|
$load
|
|
;
|
|
|
|
: dir ( "{paths}<cr>" -- )
|
|
linefeed parse
|
|
split-path-device
|
|
open-dev dup 0= if
|
|
drop
|
|
exit
|
|
then
|
|
-rot 2 pick
|
|
" dir" rot ['] $call-method catch
|
|
if
|
|
3drop
|
|
cr ." Cannot find dir for this package"
|
|
then
|
|
close-dev
|
|
;
|
|
|
|
: go ( -- )
|
|
state-valid @ not if
|
|
s" No valid state has been set by load or init-program" type cr
|
|
exit
|
|
then
|
|
|
|
\ Call the architecture-specific code to launch the client image
|
|
s" (go)" $find if
|
|
execute
|
|
else
|
|
." go is not yet implemented"
|
|
2drop
|
|
then
|
|
;
|
|
|
|
|
|
\ 7.6.3 Abort and resume
|
|
|
|
\ already defined !?
|
|
\ : go ( -- )
|
|
\ ;
|
|
|
|
|
|
\ 7.6.4 Disassembler
|
|
|
|
: dis ( addr -- )
|
|
;
|
|
|
|
: +dis ( -- )
|
|
;
|
|
|
|
\ 7.6.5 Breakpoints
|
|
: .bp ( -- )
|
|
;
|
|
|
|
: +bp ( addr -- )
|
|
;
|
|
|
|
: -bp ( addr -- )
|
|
;
|
|
|
|
: --bp ( -- )
|
|
;
|
|
|
|
: bpoff ( -- )
|
|
;
|
|
|
|
: step ( -- )
|
|
;
|
|
|
|
: steps ( n -- )
|
|
;
|
|
|
|
: hop ( -- )
|
|
;
|
|
|
|
: hops ( n -- )
|
|
;
|
|
|
|
\ already defined
|
|
\ : go ( -- )
|
|
\ ;
|
|
|
|
: gos ( n -- )
|
|
;
|
|
|
|
: till ( addr -- )
|
|
;
|
|
|
|
: return ( -- )
|
|
;
|
|
|
|
: .breakpoint ( -- )
|
|
;
|
|
|
|
: .step ( -- )
|
|
;
|
|
|
|
: .instruction ( -- )
|
|
;
|
|
|
|
|
|
\ 7.6.6 Symbolic debugging
|
|
: .adr ( addr -- )
|
|
;
|
|
|
|
: sym ( "name< >" -- n )
|
|
;
|
|
|
|
: sym>value ( addr len -- addr len false | n true )
|
|
;
|
|
|
|
: value>sym ( n1 -- n1 false | n2 addr len true )
|
|
;
|