0 > boot hd:\list.of
load-size=773 adler32=f9324f0c
evaluating Forth source
ok
0 > list
\ "list.of" -- Outputs current or most recently loaded file as text
\ to Open Firmware display. Attempts to recover old text
\ if deallocated. Translates LF to CRLF line endings.
( Also provides an alternative to the value word 'actual-load-size' )
( which is hidden when environment var fcode-debug? in default state)
\
%r25 %r28 DO \ search fcode table
i @ 18 - @ 10616374 ( 10"act" ) = IF \ quick-find probable match
i @ 17 - " actual-load-size" comp \ verify match
0= IF ( found )
" old-load-size" i @ (is-user-word) LEAVE \ dictionary alias
THEN
THEN
i %r25 4- = IF
." list: installation failed: essential resource not located"
\ compile will terminate with "old-load-size not found"
THEN
4 +LOOP
\
0 value was-mapped-out ( bool = "most recently loaded file dealloc'd")
\
: dump-as-text ( end start --) ( displays LF line-endings as CRLF )
DO
i c@ dup linefeed = IF carret emit THEN ( insert CR before LF )
dup carret = IF drop ELSE emit THEN ( LF but not CR copied thru)
exit? if leave then
LOOP
;
\
: list ( -- )
\ " old-load-size" $find INVERT ABORT" actual-load-size not avail."
\ drop ( this & prev line redundant. compile fails on same cond. )
load-base cpeek invert to was-mapped-out \ any ram at virt address?
was-mapped-out IF
\ assumes dealloc'd file in load-area remains undisturbed in memory
load-base dup old-load-size 10 " /cpus/PowerPC,G4" " map"
execute-device-method
INVERT ABORT" Unable to recover previously loaded text "
ELSE drop THEN ( discard result of cpeek used to probe virt addr )
cr load-base old-load-size + load-base dump-as-text
was-mapped-out IF
load-base old-load-size " /cpus/PowerPC,G4" " unmap"
execute-device-method
INVERT IF ." WARNING: Failed to restore prior memory map " THEN
THEN
;