[openfirmware] r1076 - cpu/x86/pc/olpc
svn at openfirmware.info
svn at openfirmware.info
Fri Jan 23 20:45:08 CET 2009
Author: wmb
Date: 2009-01-23 20:45:08 +0100 (Fri, 23 Jan 2009)
New Revision: 1076
Added:
cpu/x86/pc/olpc/iflash.fth
cpu/x86/pc/olpc/usbpwr.fth
Log:
Biosload build - Checked in olpc/iflash.fth and olpc/usbpwr.fth,
needed by "biosload/config-olpc.fth" build version.
Added: cpu/x86/pc/olpc/iflash.fth
===================================================================
--- cpu/x86/pc/olpc/iflash.fth (rev 0)
+++ cpu/x86/pc/olpc/iflash.fth 2009-01-23 19:45:08 UTC (rev 1076)
@@ -0,0 +1,71 @@
+\ Reflasher that merges Insyde BIOS with manufacturing data
+
+h# 300 constant /mfg-data-merge
+mfg-data-end-offset /mfg-data-merge - constant mfg-data-merge-offset
+
+: $get-insyde ( filename$ -- )
+ $read-open
+ flash-buf /flash ifd @ fgets ( len )
+ ifd @ fclose
+
+ /flash <> abort" Image file is the wrong length"
+
+ flash-buf mfg-data-merge-offset + /mfg-data-merge 0 bskip ( residue )
+ abort" Firmware image has data in the manufacturing data block"
+
+ true to file-loaded?
+;
+
+: merge-mfg-data ( -- )
+ flash-base mfg-data-merge-offset +
+ flash-buf mfg-data-merge-offset +
+ /mfg-data-merge move
+;
+
+: get-insyde ( ["filename"] -- )
+ parse-word ( adr len )
+ dup 0= if 2drop " u:\insyde.rom" then ( adr len )
+ ." Reading " 2dup type cr ( adr len )
+ $get-insyde
+;
+
+: write-insyde ( -- )
+ flash-buf /flash 0 write-flash-range
+;
+
+: ireflash ( -- ) \ Flash from data already in memory
+ ?file
+ flash-write-enable
+
+ merge-mfg-data
+
+ write-insyde
+
+ spi-us d# 20 < if
+ ['] verify catch if
+ ." Verify failed. Retrying once" cr
+ spi-identify
+ write-insyde
+ verify
+ then
+ flash-write-disable
+ else
+ .verify-msg
+ then
+;
+
+: iflash ( ["filename"] -- ) get-insyde ?enough-power ireflash ;
+
+: save-insyde ( -- )
+ " u:\insyde.rom" $write-open
+
+ \ Get the FLASH data into a buffer, slowly to avoid locking out the EC
+ slow-flash-read
+
+ \ Zap the manufacturing data
+ flash-buf mfg-data-merge-offset + /mfg-data-merge 0 fill
+
+ flash-buf /flash ofd @ fputs
+
+ ofd @ fclose
+;
Added: cpu/x86/pc/olpc/usbpwr.fth
===================================================================
--- cpu/x86/pc/olpc/usbpwr.fth (rev 0)
+++ cpu/x86/pc/olpc/usbpwr.fth 2009-01-23 19:45:08 UTC (rev 1076)
@@ -0,0 +1,27 @@
+purpose: Bounce USB power to reset devices
+
+\ This is used by the biosload build for OLPC to reset USB
+\ devices. Insyde BIOS / GeodeROM leaves some USB sticks in
+\ funny state in which reads fail. Power cycling fixes them.
+
+: power-cycle-usb ( -- )
+ " /pci/usb at f,4" open-dev >r \ OHCI controller
+
+ \ Configure the OHCI controller for global power switching
+ " hc-rh-desa@" r@ $call-method ( desA )
+ h# 300 invert and ( desA' )
+ " hc-rh-desa!" r@ $call-method ( desA )
+
+ \ Turn off the power from the OHCI point of view, leaving the
+ \ EHCI in control (the power switches are the logical OR
+ \ of the OHCI and EHCI controls)
+ 1 " hc-rh-stat!" r@ $call-method
+ r> close-dev
+ d# 100 ms
+
+ " /pci/usb at f,5" open-dev ( ih ) \ EHCI controller
+ 4 0 do 0 i " portsc!" 4 pick $call-method loop ( ih )
+ d# 100 ms
+ 4 0 do i " power-port" 3 pick $call-method loop ( ih )
+ close-dev
+;
More information about the openfirmware
mailing list