Ephemerboot/Open Firmware/ramboot

1 line
2.9 KiB
Plaintext
Raw Normal View History

2019-03-29 16:35:52 +00:00
<CHRP-BOOT> <COMPATIBLE> MacRISC </COMPATIBLE> <DESCRIPTION> Pre-bootloader clips visible RAM to allocate a RAM disk. </DESCRIPTION> <BOOT-SCRIPT> hex 70.0.74.77.a unselect-dev " /options" find-package drop constant _options " /memory" find-package drop constant _memory 2.00000 constant reboot-reserved-space : boot-tbxj " &device;:&partition;,"(5c):tbxj" 2dup open-dev if $boot then ." RAMBoot: Deferring to selected physical disk. 2drop mac-boot ; struct 4 field &gt;next-run 4 field &gt;start-addr 4 field &gt;byte-count constant /phys-run variable first-phys-run first-phys-run " reg" _memory get-package-property drop begin ( run addr len ) dup while decode-int &gt;r ( run addr len ) rot ( addr len run ) /phys-run alloc-mem dup &gt;r ( addr len run newrun ) swap ! ( addr len ) r&gt; ( addr len newrun ) r&gt; over &gt;start-addr ! ( addr len newrun ) -rot decode-int &gt;r ( newrun addr len ) rot ( addr len newrun ) r&gt; over &gt;byte-count ! dup &gt;start-addr @ ." Encoded range " . dup &gt;byte-count @ ." , " . cr &gt;next-run -rot repeat 2drop off first-phys-run @ begin dup &gt;next-run @ ?dup while nip repeat &gt;r r@ &gt;byte-count @ reboot-reserved-space - dup r@ &gt;byte-count ! r&gt; &gt;start-addr @ + constant reserved-run-start 0 first-phys-run @ begin tuck &gt;byte-count @ + swap &gt;next-run @ ?dup 0= until constant total-ram " ramboot-disk-size" _options get-package-property if ." RAMBoot: could not get prefs from NVRAM" boot-tbxj then \ decode-int decode-string $number drop constant disk-ram 2drop : encode-int+ encode-int encode+ ; : encode-start &gt;start-addr @ encode-int+ ; : encode-count &gt;byte-count @ encode-int+ ; 0 0 encode-bytes total-ram disk-ram - dup 0&lt; if 3drop ." RAMBoot: specified size larger than installed memory." boot-tbxj then first-phys-run @ begin ( addr len rem run ) tuck &gt;byte-count @ ( addr len run rem count ) over &lt; while ( addr len run rem ) &gt;r &gt;r ( addr len ) r@ encode-start r@ encode-count r&gt; r&gt; ( addr len run rem ) over &gt;byte-count @ - swap ( addr len rem run ) &gt;next-run @ repeat swap &gt;r -rot ( rem addr len ) r@ encode-start 2 pick encode-int+ reserved-run-start encode-int+ reboot-reserved-space encode-int+ " /memory" find-device " reg" 2dup delete-property property unselect-dev ( rem ) ." done with /memory" cr dup r@ &gt;start-addr @ + encode-int rot ( addr len rem ) r@ &gt;byte-count @ swap - ?dup 0&lt;&gt; if encode-int+ else 2drop 0 0 encode-bytes then r&gt; &gt;next-run @ ( addr len run ) begin ?dup while &gt;r r@ encode-start r@ encode-count r&gt; &gt;next-run @ repeat " /chosen" find-device " ramboot-phys-ranges" property unselect-dev " /options" find-device " ramboot-checksum" _options get-package-property 0= if " ramboot-checksum" 2dup delete-property property then unselect-dev boot-tbxj </BOOT-SCRIPT> </CHRP-BOOT>