[openfirmware] [commit] r1998 - cpu/arm cpu/arm/Linux cpu/arm/build cpu/arm/marvell cpu/arm/mmp2 cpu/arm/olpc/1.75 cpu/arm/olpc/1.75/build cpu/x86/pc/olpc/via dev dev/olpc/spiflash dev/usb2/hcd/ehci
repository service
svn at openfirmware.info
Tue Nov 2 06:52:26 CET 2010
Author: wmb
Date: Tue Nov 2 06:52:25 2010
New Revision: 1998
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/1998
Log:
XO-1.75 - USB is sort of working, and the ROM image uses dropin format, versioning, and is checksummed.
Added:
cpu/arm/Linux/inflate.ld
cpu/arm/build/inflate.bin (contents, props changed)
cpu/arm/olpc/1.75/fw-version.fth
cpu/arm/olpc/1.75/olpc.bth
cpu/arm/olpc/1.75/sourceurl.fth
dev/nonmmflash.fth
Modified:
cpu/arm/Linux/Makefile
cpu/arm/basefw.bth
cpu/arm/marvell/tim.fth
cpu/arm/mmp2/sspspi.fth
cpu/arm/olpc/1.75/addrs.fth
cpu/arm/olpc/1.75/build/ (props changed)
cpu/arm/olpc/1.75/build/Makefile
cpu/arm/olpc/1.75/devices.fth
cpu/arm/olpc/1.75/prefw.bth
cpu/x86/pc/olpc/via/olpc.bth
dev/olpc/spiflash/flashif.fth
dev/olpc/spiflash/spiflash.fth
dev/usb2/hcd/ehci/probe.fth
Modified: cpu/arm/Linux/Makefile
==============================================================================
--- cpu/arm/Linux/Makefile Tue Nov 2 06:34:33 2010 (r1997)
+++ cpu/arm/Linux/Makefile Tue Nov 2 06:52:25 2010 (r1998)
@@ -2,7 +2,7 @@
BP=../../..
-CFLAGS = -DARM -mlittle-endian
+CFLAGS = -O -DARM -mlittle-endian
WRTAIL = forth/wrapper
WRDIR = ${BP}/${WRTAIL}
@@ -13,7 +13,7 @@
OBJS = wrapper.o logger.o ${ZIPOBJS}
-all: forth
+all: forth inflate.bin
# Use forth when you just need to run Forth but don't care what
# native instruction set it is on.
@@ -30,6 +30,15 @@
armforth.static: ${OBJS}
${CC} ${CFLAGS} ${LFLAGS} -static -o $@ ${OBJS}
+inflate.lo: ${ZIPDIR}/inflate.c
+ ${CC} -c ${CFLAGS} -O $< -o $@
+
+inflate.o: inflate.lo
+ ${LD} -T inflate.ld $< -o $@
+
+../build/inflate.bin: inflate.o
+ objcopy -O binary $< $@
+
%.o: ${WRDIR}/%.c
${CC} -c ${CFLAGS} $< -o $@
Added: cpu/arm/Linux/inflate.ld
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/Linux/inflate.ld Tue Nov 2 06:52:25 2010 (r1998)
@@ -0,0 +1,6 @@
+SECTIONS
+{
+ . = 0x00000;
+ .text : { *(.text_inflate) }
+ .text_spare : { *(.text) }
+}
Modified: cpu/arm/basefw.bth
==============================================================================
--- cpu/arm/basefw.bth Tue Nov 2 06:34:33 2010 (r1997)
+++ cpu/arm/basefw.bth Tue Nov 2 06:52:25 2010 (r1998)
@@ -86,6 +86,12 @@
\ XXX remove the OS file commands from tools.dic
fload ${BP}/ofw/core/filecmds.fth \ File commands: dir, del, ren, etc.
+\ Defined by CPU core
+h# 1000 to pagesize
+d# 12 to pageshift
+h# 10.0000 constant /section
+h# 4000 constant /page-table
+
[ifndef] no-heads
resident dispose 0 0 set-transize \ true is suppress-transient
Added: cpu/arm/build/inflate.bin
==============================================================================
Binary file. No diff available.
Modified: cpu/arm/marvell/tim.fth
==============================================================================
--- cpu/arm/marvell/tim.fth Tue Nov 2 06:34:33 2010 (r1997)
+++ cpu/arm/marvell/tim.fth Tue Nov 2 06:52:25 2010 (r1998)
@@ -10,6 +10,8 @@
0 value image-size
0 value image-adr
+: tim$ ( -- adr len ) image-adr image-size ;
+
0 value new-image-size
: ?realloc-image ( new-size -- )
dup image-size > if ( new-size )
Modified: cpu/arm/mmp2/sspspi.fth
==============================================================================
--- cpu/arm/mmp2/sspspi.fth Tue Nov 2 06:34:33 2010 (r1997)
+++ cpu/arm/mmp2/sspspi.fth Tue Nov 2 06:52:25 2010 (r1998)
@@ -35,8 +35,6 @@
: ssp-spi-in ( -- b ) 0 ssp-spi-out-in ;
: safe-spi-start
- disable-interrupts
- ignore-power-button
ssp-spi-start
\ The following clears out some glitches so the chip will respond
\ to the ab-id command.
Modified: cpu/arm/olpc/1.75/addrs.fth
==============================================================================
--- cpu/arm/olpc/1.75/addrs.fth Tue Nov 2 06:34:33 2010 (r1997)
+++ cpu/arm/olpc/1.75/addrs.fth Tue Nov 2 06:52:25 2010 (r1998)
@@ -6,9 +6,10 @@
fb-pa constant available-ram-size
+h# 20000 constant dropin-offset \ Offset to dropin driver area in SPI FLASH
+h# 100000 constant /rom \ Total size of SPI FLASH
: (memory?) ( phys -- flag ) total-ram-size u< ;
-' (memory?) to memory?
\ OFW implementation choices
\ h# 1fe0.0000 constant fw-pa
@@ -32,9 +33,3 @@
heap-size constant initial-heap-size
h# 40.0000 constant page-table-pa
-
-\ Defined by CPU core
-h# 1000 to pagesize
-d# 12 to pageshift
-h# 10.0000 constant /section
-h# 4000 constant /page-table
Modified: cpu/arm/olpc/1.75/build/Makefile
==============================================================================
--- cpu/arm/olpc/1.75/build/Makefile Tue Nov 2 06:34:33 2010 (r1997)
+++ cpu/arm/olpc/1.75/build/Makefile Tue Nov 2 06:52:25 2010 (r1998)
@@ -1,4 +1,4 @@
-ROMNAME=ofw
+ROMNAME=olpc
BASEDIR= `(cd ../../../../..; pwd;)`
Modified: cpu/arm/olpc/1.75/devices.fth
==============================================================================
--- cpu/arm/olpc/1.75/devices.fth Tue Nov 2 06:34:33 2010 (r1997)
+++ cpu/arm/olpc/1.75/devices.fth Tue Nov 2 06:52:25 2010 (r1998)
@@ -21,7 +21,7 @@
h# 40 1 uart! \ Marvell-specific UART Enable bit
3 3 uart! \ 8 bits, no parity
7 2 uart! \ Clear and enable FIFOs
- d# 38400 baud
+ d# 115200 baud
;
fload ${BP}/forth/lib/sysuart.fth \ Set console I/O vectors to UART
@@ -100,6 +100,7 @@
fload ${BP}/dev/olpc/spiflash/flashif.fth \ Generic FLASH interface
fload ${BP}/dev/olpc/spiflash/spiif.fth \ Generic low-level SPI bus access
+
fload ${BP}/dev/olpc/spiflash/spiflash.fth \ SPI FLASH programming
: ignore-power-button ; \ XXX implement me
@@ -109,6 +110,26 @@
fload ${BP}/cpu/arm/mmp2/sspspi.fth \ Synchronous Serial Port SPI interface
+\ Create the top-level device node to access the entire boot FLASH device
+0 0 " d4035000" " /" begin-package
+ " flash" device-name
+
+ h# 10.0000 value /device
+ my-address my-space h# 100 reg
+ fload ${BP}/dev/nonmmflash.fth
+end-package
+
+\ Create a node below the top-level FLASH node to accessing the portion
+\ containing the dropin modules
+0 0 " 20000" " /flash" begin-package
+ " dropins" device-name
+
+ h# e0000 constant /device
+ fload ${BP}/dev/subrange.fth
+end-package
+
+devalias dropins /dropins
+
fload ${BP}/cpu/arm/olpc/1.75/spiui.fth \ User interface for SPI FLASH programming
\ fload ${BP}/dev/olpc/spiflash/recover.fth \ XO-to-XO SPI FLASH recovery
: ofw-fw-filename$ " disk:\boot\olpc.rom" ;
@@ -174,32 +195,33 @@
my-address my-space /regs reg
: my-map-in ( len -- adr )
my-space swap " map-in" $call-parent h# 100 + ( adr )
- 3 over h# a8 + rl! ( adr ) \ Force host mode
;
: my-map-out ( adr len -- ) swap h# 100 - swap " map-out" $call-parent ;
false constant has-dbgp-regs?
false constant needs-dummy-qh?
: grab-controller ( config-adr -- error? ) drop false ;
fload ${BP}/dev/usb2/hcd/ehci/loadpkg.fth
+ : otg-set-host-mode 3 h# a8 ehci-reg! ; \ Force host mode
+ ' otg-set-host-mode to set-host-mode
+
end-package
-: usb-power-on ( -- ) 1 gpio-set ;
-: unreset-usb-hub ( -- ) d# 146 gpio-set ;
+\ : usb-power-on ( -- ) 1 gpio-set ;
+: usb-power-on ( -- ) ; \ The EC controls the USB power
+: reset-usb-hub ( -- ) d# 146 gpio-set d# 10 ms d# 146 gpio-set ;
fload ${BP}/cpu/arm/marvell/utmiphy.fth
-: start-usb ( -- )
+: init-usb ( -- )
h# 9 h# d428285c l! \ Enable clock to USB block
- unreset-usb-hub
+ reset-usb-hub
init-usb-phy
;
-0 [if]
stand-init: Init USB Phy
\ usb-power-on \ The EC now controls the USB power
- start-usb
+ init-usb
;
-[then]
fload ${BP}/dev/olpc/mmp2camera/loadpkg.fth
Added: cpu/arm/olpc/1.75/fw-version.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/olpc/1.75/fw-version.fth Tue Nov 2 06:52:25 2010 (r1998)
@@ -0,0 +1,3 @@
+\ The overall firmware revision
+macro: FW_MAJOR A
+macro: FW_MINOR 00
Added: cpu/arm/olpc/1.75/olpc.bth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/olpc/1.75/olpc.bth Tue Nov 2 06:52:25 2010 (r1998)
@@ -0,0 +1,232 @@
+purpose: Construct the Open Firmware module collection
+
+command: &builder &this
+in: ${BP}/cpu/arm/olpc/1.75/build/fw.img
+build-now
+
+fload ${BP}/cpu/arm/olpc/1.75/fw-version.fth
+
+" macro: FW_VERSION Q4${FW_MAJOR}${FW_MINOR}" expand$ eval
+
+fload ${BP}/cpu/arm/olpc/1.75/config.fth
+
+\ Always re-create the builton.fth file when we make a new rom.img
+fload ${BP}/cpu/x86/pc/builton.bth
+fload ${BP}/cpu/arm/olpc/1.75/sourceurl.fth
+
+fload ${BP}/forth/lib/crc32.fth
+
+hex
+
+: pad-file ( location -- )
+ ofd @ fsize
+ 2dup u< abort" The ROM image is too large"
+ ?do h# ff ofd @ fputc loop
+;
+
+fload ${BP}/cpu/arm/marvell/tim.fth
+
+\ Marvel Trusted Image Module image creation script for
+\ XO-1.75 platform.
+
+tim: 00030102 0 Sky! PXA688
+flash: SPI'10
+timh: TIMH 0 d101f000
+\ Main Processor code loaded into DRAM
+image: OBMI 800 d101c000 ${BP}/cpu/arm/olpc/1.75/dummy.img
+\ Secure Processor code loaded into SRAM
+image: WTMI 1000 d1018000 /scratchbox/users/wmb/home/wmb/cforth.git/build/arm-xo-1.75/shim.img
+image: CFTH 2000 d1000000 /scratchbox/users/wmb/home/wmb/cforth.git/build/arm-xo-1.75/app.img
+\ anonymous: 20000 ${BP}/cpu/arm/olpc/1.75/build/fw.img
+reserved:
+\ fload ${BP}/cpu/arm/olpc/1.75/ddr_samsung_1g.fth
+ term:
+end-reserved
+end-tim
+
+.( --- Saving as )
+" ${FW_VERSION}.rom" expand$ 2dup lower ( adr len )
+2dup type cr ( adr len )
+$new-file
+ tim$ ofd @ fputs
+
+ dropin-offset pad-file
+
+\ Loads the set of drivers that is common to different output formats
+
+ " ${BP}/cpu/arm/build/inflate.bin" " inflate" $add-dropin
+ " fw.img" " firmware" $add-deflated-dropin
+\ " fw.img" " firmware" $add-dropin
+
+\ " ${BP}/dev/usb2/hcd/ehci/build/ehci.fc" " class0c0320" $add-deflated-dropin
+ " ${BP}/dev/usb2/device/hub/build/hub.fc" " usb,class9" $add-deflated-dropin
+ " ${BP}/dev/usb2/device/generic/build/generic.fc" " usbdevice" $add-deflated-dropin
+ " ${BP}/dev/usb2/device/net/build/usbnet.fc" " usbnet" $add-deflated-dropin
+ " ${BP}/dev/usb2/device/keyboard/build/usbkbd.fc" " usb,class3,1" $add-deflated-dropin
+ " ${BP}/dev/usb2/device/serial/build/usbserial.fc" " usbserial" $add-deflated-dropin
+ " ${BP}/dev/usb2/device/storage/build/usbstorage.fc" " usbstorage" $add-deflated-dropin
+
+
+0 [if]
+ " ${BP}/dev/mmc/sdhci/build/sdhci2.fc" " class080501" $add-deflated-dropin
+[then]
+
+0 [if]
+ " ${BP}/dev/mmc/sdhci/build/sdmmc.fc" " sdmmc" $add-deflated-dropin
+ " ${BP}/dev/mmc/sdhci/mv8686/build/mv8686.fc" " mv8686" $add-deflated-dropin
+[then]
+
+0 [if]
+ " sd8686_helper.bin" " helper_sd.bin" $add-deflated-dropin
+ " sd8686.bin" " sd8686.bin" $add-deflated-dropin
+[then]
+
+ " builton.fth" " probe-" $add-dropin
+
+0 [if]
+ " ${BP}/clients/emacs/x86/emacs" " emacs" $add-deflated-dropin
+ " ${BP}/clients/emacs/x86/emacs.rc" " emacs.rc" $add-deflated-dropin
+ " ${BP}/clients/emacs/emacs.hlp" " emacs.hlp" $add-deflated-dropin
+[then]
+
+ " ${BP}/ofw/fcode/memtest.fth" " memtest.fth" $add-deflated-dropin
+
+0 [if]
+ " ${BP}/dev/hdaudio/build/hdaudio.fc" " class040300" $add-deflated-dropin
+
+ " ${BP}/ofw/inet/telnetd.fth" " telnetd" $add-deflated-dropin
+[then]
+
+0 [if]
+\ " ${BP}/cpu/x86/pc/olpc/images/warnings.565" " warnings.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/olpc/images/lightdot.565" " lightdot.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/olpc/images/yellowdot.565" " yellowdot.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/olpc/images/darkdot.565" " darkdot.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/olpc/images/lock.565" " lock.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/olpc/images/unlock.565" " unlock.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/olpc/images/plus.565" " plus.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/olpc/images/minus.565" " minus.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/olpc/images/x.565" " x.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/olpc/images/sad.565" " sad.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/olpc/images/bigdot.565" " bigdot.565" $add-deflated-dropin
+
+ " ${BP}/cpu/x86/pc/olpc/images/check.565" " check.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/olpc/images/xogray.565" " xogray.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/olpc/images/ethernet.565" " ethernet.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/olpc/images/usbkey.565" " disk.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/olpc/images/wireless.565" " wlan.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/olpc/images/laptop.565" " int.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/olpc/images/sd.565" " ext.565" $add-deflated-dropin
+[then]
+
+0 [if]
+ " ${BP}/ofw/termemu/15x30pc.psf" " font" $add-deflated-dropin
+[then]
+
+0 [if]
+ " memtest" " memtest" $add-deflated-dropin
+[then]
+
+0 [if]
+ " verify.img" " verify" $add-deflated-dropin
+ " os.public" " ospubkey" $add-dropin \ Incompressible
+ " fw.public" " fwpubkey" $add-dropin \ Incompressible
+ " fs.public" " fspubkey" $add-dropin \ Incompressible
+ " lease.public" " leasepubkey" $add-dropin \ Incompressible
+ " developer.public" " develpubkey" $add-dropin \ Incompressible
+[then]
+ " sourceurl" " sourceurl" $add-dropin
+
+0 [if]
+ " ${BP}/cpu/x86/pc/olpc/images/Edge1-8k-EQ-Comp-Amp-Short.wav" " splash" $add-deflated-dropin
+
+ \ icons for mfg test gui
+ " testicons/play.565" " play.565" $add-deflated-dropin
+ " testicons/quit.565" " quit.565" $add-deflated-dropin
+ " testicons/cpu.565" " cpu.565" $add-deflated-dropin
+ " testicons/spi.565" " spi.565" $add-deflated-dropin
+ " testicons/ram.565" " ram.565" $add-deflated-dropin
+ " testicons/sdcard.565" " sdcard.565" $add-deflated-dropin
+ " testicons/keyboard.565" " keyboard.565" $add-deflated-dropin
+ " testicons/display.565" " display.565" $add-deflated-dropin
+ " testicons/touchpad.565" " touchpad.565" $add-deflated-dropin
+ " testicons/audio.565" " audio.565" $add-deflated-dropin
+ " testicons/usb.565" " usb.565" $add-deflated-dropin
+ " testicons/battery.565" " battery.565" $add-deflated-dropin
+ " testicons/camera.565" " camera.565" $add-deflated-dropin
+ " testicons/wifi.565" " wifi.565" $add-deflated-dropin
+ " testicons/clock.565" " clock.565" $add-deflated-dropin
+ " testicons/timer.565" " timer.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/olpc/images/bigx.di" $add-file
+ " ${BP}/cpu/x86/pc/olpc/images/bigcheck.di" $add-file
+ " ${BP}/cpu/x86/pc/olpc/images/leds.di" $add-file
+ " ${BP}/cpu/x86/pc/olpc/images/ebook.di" $add-file
+
+ " ${BP}/cpu/x86/pc/olpc/via/build/nandblaster15_rx.bin" " nb15_rx" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/olpc/via/build/nandblaster_tx.bin" " nb_tx" $add-deflated-dropin
+
+ " ${BP}/cpu/x86/pc/olpc/images/winlogo.565" " winlogo.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/olpc/images/tux.565" " tux.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/olpc/images/settings.565" " settings.565" $add-deflated-dropin
+[then]
+
+.( Dropin top is ) ofd @ fsize .x cr
+
+/rom pad-file
+
+\ Insert the revision signature
+/rom h# 40 - ofd @ fseek
+h# 10 buffer: signature
+signature h# 10 blank
+" CL1" signature swap move
+" ${FW_VERSION}" expand$ signature 6 + swap move
+" Q4${FW_MAJOR}" expand$ signature d# 13 + swap move
+signature h# 10 ofd @ fputs
+
+/l buffer: crcbuf
+/rom buffer: filebuf
+
+\ Read the entire image, compute the CRC, and store it h# 28 from the end
+0 ofd @ fseek
+filebuf /rom ofd @ fgets /rom <> abort" Can't read back image"
+0 crctab filebuf /rom ($crc) crcbuf !
+
+/rom h# 2c - ofd @ fseek
+crcbuf /l ofd @ fputs
+
+ofd @ fclose
+
+\ Creating olpc.version serves two purposes:
+\ a) It reports the firmware revision for use by external scripts
+\ b) It provides an olpc.* artifact for the builder dependency management.
+
+writing olpc.version
+" ${FW_VERSION}" expand$ 2dup lower ofd @ fputs
+ofd @ fclose
+
+
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2010 FirmWorks
+\
+\ Permission is hereby granted, free of charge, to any person obtaining
+\ a copy of this software and associated documentation files (the
+\ "Software"), to deal in the Software without restriction, including
+\ without limitation the rights to use, copy, modify, merge, publish,
+\ distribute, sublicense, and/or sell copies of the Software, and to
+\ permit persons to whom the Software is furnished to do so, subject to
+\ the following conditions:
+\
+\ The above copyright notice and this permission notice shall be
+\ included in all copies or substantial portions of the Software.
+\
+\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+\
+\ LICENSE_END
+
Modified: cpu/arm/olpc/1.75/prefw.bth
==============================================================================
--- cpu/arm/olpc/1.75/prefw.bth Tue Nov 2 06:34:33 2010 (r1997)
+++ cpu/arm/olpc/1.75/prefw.bth Tue Nov 2 06:52:25 2010 (r1998)
@@ -12,6 +12,7 @@
' noop is include-hook
fload ${BP}/cpu/arm/olpc/1.75/config.fth
+' (memory?) to memory?
: headerless ; : headers ; : headerless0 ;
Added: cpu/arm/olpc/1.75/sourceurl.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/arm/olpc/1.75/sourceurl.fth Tue Nov 2 06:52:25 2010 (r1998)
@@ -0,0 +1,8 @@
+\ Make a file containing the URL of the source code
+
+show-rebuilds? false to show-rebuilds? \ We don't need to see these commands
+
+" svn info ../../../../.. | grep URL: | cut -d ' ' -f 2 | tr \\n ' ' >sourceurl" $sh
+" svnversion -n ../../../../.. >>sourceurl" $sh
+
+to show-rebuilds?
Modified: cpu/x86/pc/olpc/via/olpc.bth
==============================================================================
--- cpu/x86/pc/olpc/via/olpc.bth Tue Nov 2 06:34:33 2010 (r1997)
+++ cpu/x86/pc/olpc/via/olpc.bth Tue Nov 2 06:52:25 2010 (r1998)
@@ -41,7 +41,7 @@
fload ${BP}/cpu/x86/pc/olpc/via/fw-version.fth
-" macro: FW_VERSION Q3${FW_MAJOR}${FW_MINOR}" expand$ eval
+" macro: FW_VERSION Q4${FW_MAJOR}${FW_MINOR}" expand$ eval
fload ${BP}/cpu/x86/pc/olpc/via/config.fth
Added: dev/nonmmflash.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ dev/nonmmflash.fth Tue Nov 2 06:52:25 2010 (r1998)
@@ -0,0 +1,168 @@
+purpose: Package for non-memory-mapped FLASH ROM device
+\ See license at end of file
+
+headerless
+0 value open-count
+0 instance value seek-ptr
+
+: clip-size ( adr len -- len' adr len' )
+ seek-ptr + /device min seek-ptr - ( adr len' )
+ tuck
+;
+: update-ptr ( len' -- len' ) dup seek-ptr + to seek-ptr ;
+
+headers
+external
+: seek ( d.offset -- status )
+ 0<> over /device u> or if drop true exit then \ Seek offset too big
+ to seek-ptr
+ false
+;
+
+: open ( -- flag )
+ \ This lets us open the node during compilation
+ standalone? 0= if true exit then
+
+ open-count dup 1+ to open-count 0= if ( )
+ flash-open ( )
+ then ( )
+ 0 to seek-ptr ( )
+ true ( true )
+;
+: close ( -- )
+ \ This lets us open the node during compilation
+ standalone? 0= if exit then
+
+ open-count dup 1- 0 max to open-count ( old-count )
+ 1 = if then
+;
+: size ( -- d.size ) /device u>d ;
+: read ( adr len -- actual )
+ clip-size ( len' adr len' )
+ seek-ptr flash-read ( len' )
+ update-ptr ( len' )
+;
+
+0 [if]
+\ Write support is complicated by the need to erase before
+\ writing and the possibly-different erase and write granularity.
+\
+\ For NOR FLASH, where you can write as many times as you want
+\ while turning 1's into 0's, the algorithm is:
+\
+\ Break the entire write range into pieces each contained in one
+\ erase unit. For each piece:
+\
+\ Compare the existing and new contents to see if the unit needs erasing
+\
+\ If no bits need to go from 0 to 1, erase is unnecessary, so just write.
+\ (It's a little more complicated if the write granularity is >1 byte.)
+\
+\ Otherwise, copy the existing contents of the erase unit to a buffer,
+\ merge in the new data, erase, then write back the buffer.
+[then]
+
+: left-in-block ( len offset -- #left )
+ \ Determine how many bytes are left in the page containing offset
+ /flash-block swap /flash-block 1- and - ( len left-in-page )
+ min ( #left )
+;
+
+0 value /tmp
+0 value 'tmp
+: must-erase? ( adr len -- flag )
+ dup to /tmp
+ /tmp alloc-mem to 'tmp ( adr len )
+ 'tmp /tmp seek-ptr flash-read ( adr len )
+ 'tmp swap 0 ?do ( adr dev-adr )
+ over i + c@ over i + c@ ( adr dev-adr new-byte old-byte )
+ \ Must erase if a bit in old-byte is 0 and that bit in new-byte is 1
+ invert and if ( adr dev-adr )
+ 'tmp /tmp free-mem ( adr dev-adr )
+ 2drop true unloop exit ( -- flag )
+ then ( adr dev-adr )
+ loop ( adr dev-adr )
+ 'tmp /tmp free-mem ( adr dev-adr )
+ 2drop false ( flag )
+;
+
+: erase+write ( adr len -- )
+ dup /flash-block = if
+ \ If we are going to overwrite the entire block, there's no need to
+ \ preserve the old data. This can only happen if we are already
+ \ aligned on an erase block boundary.
+ seek-ptr flash-erase-block ( adr len )
+ seek-ptr flash-write ( )
+ else
+ \ Allocate a buffer to save the old block contents
+ /flash-block alloc-mem >r ( adr len )
+
+ seek-ptr /flash-block round-down ( adr len block-start )
+
+ \ Copy existing data from FLASH block to the buffer
+ r@ /flash-block 2 pick flash-read ( adr len block-start )
+
+ \ Merge new bytes into the buffer
+ -rot ( block-start adr len )
+ seek-ptr /flash-block mod ( block-start adr len buf-offset )
+ r@ + swap move ( block-start )
+
+ \ Erase the block and rewrite it from the buffer
+ dup flash-erase-block ( block-start )
+ r@ /flash-block rot flash-write ( )
+
+ \ Release the buffer
+ r> /flash-block free-mem
+ then
+;
+
+: handle-block ( adr len -- adr' len' )
+ dup seek-ptr left-in-block ( adr len #left )
+ >r ( adr len r: #left )
+ over r@ must-erase? if ( adr len r: #left )
+ over r@ erase+write ( adr len r: #left )
+ else ( adr len r: #left )
+ over r@ seek-ptr flash-write ( adr len r: #left )
+ then ( adr len r: #left )
+ seek-ptr r@ + to seek-ptr ( adr len r: #left )
+ r> /string ( adr' len' )
+;
+
+: write ( adr len -- #written )
+ flash-write-enable
+ tuck ( len adr len )
+ begin dup while handle-block repeat ( len adr' remain' )
+ 2drop ( len )
+ flash-write-disable
+;
+
+\ These permit subordinate nodes for subranges of the device, for
+\ purposes like dropin driver collections, configuration variables, etc.
+1 " #address-cells" integer-property
+
+: decode-unit ( adr len -- phys ) push-hex $number if 0 then pop-base ;
+: encode-unit ( phys -- adr len ) push-hex (u.) pop-base ;
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2010 FirmWorks
+\
+\ Permission is hereby granted, free of charge, to any person obtaining
+\ a copy of this software and associated documentation files (the
+\ "Software"), to deal in the Software without restriction, including
+\ without limitation the rights to use, copy, modify, merge, publish,
+\ distribute, sublicense, and/or sell copies of the Software, and to
+\ permit persons to whom the Software is furnished to do so, subject to
+\ the following conditions:
+\
+\ The above copyright notice and this permission notice shall be
+\ included in all copies or substantial portions of the Software.
+\
+\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+\
+\ LICENSE_END
Modified: dev/olpc/spiflash/flashif.fth
==============================================================================
--- dev/olpc/spiflash/flashif.fth Tue Nov 2 06:34:33 2010 (r1997)
+++ dev/olpc/spiflash/flashif.fth Tue Nov 2 06:52:25 2010 (r1998)
@@ -1,6 +1,7 @@
\ See license at end of file
purpose: Generic interface for FLASH programming operations
+defer flash-open ( -- )
defer flash-write-enable ( -- )
defer flash-write-disable ( -- )
defer flash-write ( adr len offset -- )
Modified: dev/olpc/spiflash/spiflash.fth
==============================================================================
--- dev/olpc/spiflash/spiflash.fth Tue Nov 2 06:34:33 2010 (r1997)
+++ dev/olpc/spiflash/spiflash.fth Tue Nov 2 06:52:25 2010 (r1998)
@@ -298,12 +298,20 @@
then
;
-: spi-flash-write-enable ( -- ) spi-start spi-identify .spi-id cr ;
+
+: spi-flash-open ( -- )
+ \ One retry
+ spi-start ['] spi-identify catch if
+ spi-start spi-identify
+ then
+;
+: spi-flash-write-enable ( -- ) flash-open .spi-id cr ;
: use-spi-flash-read ( -- ) ['] read-spi-flash to flash-read ;
\ Install the SPI FLASH versions as their implementations.
: use-spi-flash ( -- )
+ ['] spi-flash-open to flash-open
['] spi-flash-write-enable to flash-write-enable
['] spi-reprogrammed to flash-write-disable
['] write-spi-flash to flash-write
Modified: dev/usb2/hcd/ehci/probe.fth
==============================================================================
--- dev/usb2/hcd/ehci/probe.fth Tue Nov 2 06:34:33 2010 (r1997)
+++ dev/usb2/hcd/ehci/probe.fth Tue Nov 2 06:52:25 2010 (r1998)
@@ -119,6 +119,9 @@
init-extra
;
+\ Some OTG controllers need to do something after reset-usb to go into host mode
+defer set-host-mode ' noop to set-host-mode
+
\ This is a sneaky way to determine if the hardware has been turned off without the software's knowledge
: suspended? ( -- flag ) asynclist@ 0= qh-ptr 0<> and ;
@@ -138,6 +141,7 @@
then
0 ehci-reg@ h# ff and to op-reg-offset
reset-usb
+ set-host-mode
do-resume
then
suspended? if do-resume then
More information about the openfirmware
mailing list