Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

A LIST command for G4 Macintosh Open Firmware

19 views
Skip to first unread message

Tinkerer Atlarge

unread,
Sep 11, 2010, 1:12:46 AM9/11/10
to
Below is a screen dump of booting "list.of" from a G4 powerpc Mac's internal
hd, then using it to list itself. To use, paste everything starting with the
first backslash below into a plain text file (don't use TextEdit) and save
it in your powerpc Mac's root directory. For more info about this program
and its usage see parallel thread "Resurrecting the G4 Macintosh as a
vintage computer".

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
;

0 new messages