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

How edit user ram using G4 Mac's Open Firmware line editor

10 views
Skip to first unread message

Tinkerer Atlarge

unread,
Sep 15, 2010, 7:05:29 AM9/15/10
to
A lot of space is taken up listing "Intraline editing" commands in the IEEE
1275-1994 Open Firmware documentation and other lists of Open Firmware
commands. Unfortunately those documents provide no guidance regarding how or
where such editing ability might be useful.

As near as I can gather its only supported use in Macintosh Open Firmware is
providing the User Interface with its ability to buffer the forth command
line, and for editing the optional nvram script.

However it can be easily coerced into editing areas of user ram as well. The
secret is to temporarily replace the "(edit)" or equivalent internal
function's parameters with pointers to the block of memory you want to edit.

The very simple editor does have multiple limitations, but at least it makes
it possible to edit text within user memory without having to rely on forth
'c!' and 'move' commands. If necessary, you can insert linefeeds into the
text being edited by quoting them. (ctrl-q ctrl-j will insert a single
linefeed after the cursor).

Below is a demonstration of how I adapted the internal editor to such use on
one of my eMacs. It does not work on my other eMac whose "(edit)" word
appears to have been substantially restructured without changing its
functionality. However the procedure is so straightforward, you should have
no trouble adapting it to your own powerpc mac's version of Open Firmware
using a similar approach.

\ "edit.of" 14-Sep-2010
\ Make use of Open Firmware's line editor to edit areas of user ram
( Suits Open Firmware 2003 build. Needs nvram fcode-debug? = true )
( Uses same editor which accepts commands at the forth user prompt)
( Has multi-line capability, but can only edit one line at a time.)
( Inserts CRs not CRLFs thus output suitable for 'dump' not 'type')
( Quits silently if buffer length exceeded. Cursor, Return and BS )
( keys work normally. Ctrl-L will dump edited portion of buffer to)
( screen as text while still in editor. Ctrl-C will end session. )
( See IEEE Std 1275-1994 p.73 for more ctrl and esc editing codes.)

\ 200 buffer: ownbuf \ more flexible if you nominate your own

: edit ( buffer-addr buffer-size -- )
\ re-assign editing buffer in user ram, saving system values on stack
\ This version incompatible if editor's value words not recognized.
ed-bfr-size -rot ( normal-size own-addr own-size )
to ed-bfr-size ( nml-size own-addr )
ed-bfr -rot ( nml-addr nml-size own-addr )
to ed-bfr ( nml-addr nml-size )
ed-bfr-ptr ( nml-addr nml-size nml-bfr-ptr )
ed-bfr to ed-bfr-ptr ( nml-addr nml-size nml-bfr-ptr )
ed-bfr-len ( nml-addr nml-size nml-bfr-ptr nml-len )
0 to ed-bfr-len \ empty buffer; edit this for 'resume' function
cr \ make screen agree with variable
ed-left-margin ( nml-addr nml-size nml-bfr-ptr nml-len nml-marg)
0 to ed-left-margin \ no prompt

true (edit) ( true = multi-line; false = single-line )
\ ctrl-c to exit editor

\ restore editor's parameters allowing it to resume normal role
to ed-left-margin
to ed-bfr-len
to ed-bfr-ptr
to ed-bfr-size
to ed-bfr
;

0 new messages