Plan 9 from Bell Labs’s /usr/web/sources/contrib/tristan/olpc.fth

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


\ loader stuff for plan9

\ hack for doing boot args for now...
\ later we should parse from plan9.ini
\ fill in your auth and fs ip addrs!
: bootline ( -- $s ) " " ;
: bootargs ( -- $s ) " *nomp=1"n*nodumpstack=1"n*norealmode=1"n*maxmem=0x10000000"nmouseport=ps2"nauth=10.12.8.3"nfs=10.12.8.3"nbootargs=tcp ether /dev/etherU0"n" ;

: page-round ( x -- x ) fff + fffff000 and ;
: putstr-nul ( $src targ -- ) 
    2 pick over 3 pick ( src n targ src targ n )
    move ( src n targ )
    + 0 swap c! ( src )
    drop
    ;

variable targ
variable confaddr
variable buf
variable text 
variable data
variable bss

warning off
: init-program ( -- )
    h# 1200 confaddr !
    h# 10.0000 targ !
    loaded drop buf !

    \ parse a.out header
    buf @ l@ bswap 1eb <> if exit then  \ 386 magic check
    buf @ h# 4 + l@ bswap to text
    buf @ h# 8 + l@ bswap to data
    buf @ h# c + l@ bswap to bss

    \ copy text and data and zero bss at targ
    \ we're assuming the loaded location (80.0000) does not
    \ overlap the target location (starting at 10.000).
    20 dup buf +! targ +!
    buf @ targ @ text @ move
    text @ buf +!  
    text @ targ @ + page-round targ !
    buf @ targ @ data @ move
    data @ dup buf +! targ +!
    targ @ bss @ erase

    \ XXX read plan9.ini, parse and place.
    \ for now we just put strings directly in place
    bootline confaddr @ putstr-nul
    bootargs confaddr @ h# 40 + putstr-nul

    \ copy what loader.elf does
    \ "In BIOS Data Area, emulate a 639 KB fre low memory"
    h# 7f h# 413 c!
    h# 2  h# 414 c!

    \ setup execution at our entry point with a small temp stack
    h# 10.0020 h# 9.fff0 (init-program)
    ;
warning on

dcon-unfreeze

\ if usb net isn't recognized by ofw
\ wifi your-essid
boot net:


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.