[openfirmware] [commit] r2726 - cpu/arm/olpc cpu/arm/olpc/1.75 cpu/arm/olpc/1.75/attic dev/olpc/dcon

repository service svn at openfirmware.info
Sat Dec 3 01:44:59 CET 2011


Author: wmb
Date: Sat Dec  3 01:44:58 2011
New Revision: 2726
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2726

Log:
OLPC XO-1.75 - big rearrangement, moving files from cpu/arm/olpc/1.75 up to cpu/arm/olpc, in preparation for XO-3

Added:
   cpu/arm/olpc/1.75/attic/
   cpu/arm/olpc/1.75/attic/audiosmb.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/audiosmb.fth
   cpu/arm/olpc/1.75/attic/dram-forth.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/dram-forth.fth
   cpu/arm/olpc/1.75/attic/dram-xdb.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/dram-xdb.fth
   cpu/arm/olpc/1.75/attic/dram.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/dram.fth
   cpu/arm/olpc/1.75/attic/draminit.bth
      - copied, changed from r2725, cpu/arm/olpc/1.75/draminit.bth
   cpu/arm/olpc/1.75/attic/ofw.bth
      - copied, changed from r2725, cpu/arm/olpc/1.75/ofw.bth
   cpu/arm/olpc/1.75/attic/sp.bth
      - copied, changed from r2725, cpu/arm/olpc/1.75/sp.bth
   cpu/arm/olpc/1.75/attic/xo-dram.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/xo-dram.fth
   cpu/arm/olpc/accelerometer.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/accelerometer.fth
   cpu/arm/olpc/accelerometer.txt
      - copied, changed from r2725, cpu/arm/olpc/1.75/accelerometer.txt
   cpu/arm/olpc/addrs.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/addrs.fth
   cpu/arm/olpc/alc5624.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/alc5624.fth
   cpu/arm/olpc/alc5631.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/alc5631.fth
   cpu/arm/olpc/bbedi.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/bbedi.fth
   cpu/arm/olpc/boardrev.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/boardrev.fth
   cpu/arm/olpc/build-cforth.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/cforth.bth
   cpu/arm/olpc/build-crypto.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/verify.bth
   cpu/arm/olpc/build-fw.fth
   cpu/arm/olpc/build-mcnand.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/mcastnand.bth
   cpu/arm/olpc/build-wlan.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/sd8686.bth
   cpu/arm/olpc/ecflash.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/ecflash.fth
   cpu/arm/olpc/edi.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/edi.fth
   cpu/arm/olpc/emmc.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/emmc.fth
   cpu/arm/olpc/exc7200-touchscreen.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/exc7200-touchscreen.fth
   cpu/arm/olpc/fetch-ec.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/ec.bth
   cpu/arm/olpc/getmfgdata.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/getmfgdata.fth
   cpu/arm/olpc/help.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/help.fth
   cpu/arm/olpc/lcd.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/lcd.fth
   cpu/arm/olpc/pinch.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/pinch.fth
   cpu/arm/olpc/prefw.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/prefw.bth
   cpu/arm/olpc/probemem.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/probemem.fth
   cpu/arm/olpc/rm3150-touchscreen.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/rm3150-touchscreen.fth
   cpu/arm/olpc/roller.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/roller.fth
   cpu/arm/olpc/rtc.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/rtc.fth
   cpu/arm/olpc/sdhci.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/sdhci.fth
   cpu/arm/olpc/sdregs.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/sdregs.fth
   cpu/arm/olpc/smbus.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/smbus.fth
   cpu/arm/olpc/sound.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/sound.fth
   cpu/arm/olpc/sourceurl.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/sourceurl.fth
   cpu/arm/olpc/testicons.bth
      - copied, changed from r2725, cpu/arm/olpc/1.75/testicons.bth
   cpu/arm/olpc/viaedi.fth
      - copied, changed from r2725, cpu/arm/olpc/1.75/viaedi.fth
Deleted:
   cpu/arm/olpc/1.75/accelerometer.fth
   cpu/arm/olpc/1.75/accelerometer.txt
   cpu/arm/olpc/1.75/addrs.fth
   cpu/arm/olpc/1.75/alc5624.fth
   cpu/arm/olpc/1.75/alc5631.fth
   cpu/arm/olpc/1.75/audiosmb.fth
   cpu/arm/olpc/1.75/bbedi.fth
   cpu/arm/olpc/1.75/boardrev.fth
   cpu/arm/olpc/1.75/devices.fth
   cpu/arm/olpc/1.75/dram-forth.fth
   cpu/arm/olpc/1.75/dram-xdb.fth
   cpu/arm/olpc/1.75/dram.fth
   cpu/arm/olpc/1.75/draminit.bth
   cpu/arm/olpc/1.75/dummy.img
   cpu/arm/olpc/1.75/ecflash.fth
   cpu/arm/olpc/1.75/edi.fth
   cpu/arm/olpc/1.75/emmc.fth
   cpu/arm/olpc/1.75/exc7200-touchscreen.fth
   cpu/arm/olpc/1.75/getmfgdata.fth
   cpu/arm/olpc/1.75/help.fth
   cpu/arm/olpc/1.75/lcd.fth
   cpu/arm/olpc/1.75/ofw.bth
   cpu/arm/olpc/1.75/pinch.fth
   cpu/arm/olpc/1.75/probemem.fth
   cpu/arm/olpc/1.75/rm3150-touchscreen.fth
   cpu/arm/olpc/1.75/roller.fth
   cpu/arm/olpc/1.75/rtc.fth
   cpu/arm/olpc/1.75/sdhci.fth
   cpu/arm/olpc/1.75/sdregs.fth
   cpu/arm/olpc/1.75/smbus.fth
   cpu/arm/olpc/1.75/sound.fth
   cpu/arm/olpc/1.75/sourceurl.fth
   cpu/arm/olpc/1.75/sp.bth
   cpu/arm/olpc/1.75/spiui.fth
   cpu/arm/olpc/1.75/testicons.bth
   cpu/arm/olpc/1.75/viaedi.fth
   cpu/arm/olpc/1.75/xo-dram.fth
Modified:
   cpu/arm/olpc/1.75/cforth-version.fth
   cpu/arm/olpc/1.75/cforth.bth
   cpu/arm/olpc/1.75/config.fth
   cpu/arm/olpc/1.75/ec-version.fth
   cpu/arm/olpc/1.75/ec.bth
   cpu/arm/olpc/1.75/fw-version.fth
   cpu/arm/olpc/1.75/fw.bth
   cpu/arm/olpc/1.75/mcastnand.bth
   cpu/arm/olpc/1.75/olpc.bth
   cpu/arm/olpc/1.75/prefw.bth
   cpu/arm/olpc/1.75/sd8686.bth
   cpu/arm/olpc/1.75/verify.bth
   dev/olpc/dcon/mmp2dcon.fth

Copied and modified: cpu/arm/olpc/1.75/attic/audiosmb.fth (from r2725, cpu/arm/olpc/1.75/audiosmb.fth)
==============================================================================

Copied and modified: cpu/arm/olpc/1.75/attic/dram-forth.fth (from r2725, cpu/arm/olpc/1.75/dram-forth.fth)
==============================================================================

Copied and modified: cpu/arm/olpc/1.75/attic/dram-xdb.fth (from r2725, cpu/arm/olpc/1.75/dram-xdb.fth)
==============================================================================

Copied and modified: cpu/arm/olpc/1.75/attic/dram.fth (from r2725, cpu/arm/olpc/1.75/dram.fth)
==============================================================================

Copied and modified: cpu/arm/olpc/1.75/attic/draminit.bth (from r2725, cpu/arm/olpc/1.75/draminit.bth)
==============================================================================

Copied and modified: cpu/arm/olpc/1.75/attic/ofw.bth (from r2725, cpu/arm/olpc/1.75/ofw.bth)
==============================================================================

Copied and modified: cpu/arm/olpc/1.75/attic/sp.bth (from r2725, cpu/arm/olpc/1.75/sp.bth)
==============================================================================

Copied and modified: cpu/arm/olpc/1.75/attic/xo-dram.fth (from r2725, cpu/arm/olpc/1.75/xo-dram.fth)
==============================================================================

Modified: cpu/arm/olpc/1.75/cforth-version.fth
==============================================================================
--- cpu/arm/olpc/1.75/cforth-version.fth	Fri Dec  2 23:14:43 2011	(r2725)
+++ cpu/arm/olpc/1.75/cforth-version.fth	Sat Dec  3 01:44:58 2011	(r2726)
@@ -13,3 +13,5 @@
 \ Otherwise, the source code will be will be downloaded as a tarball via gitweb.
 \ macro: CFORTH_VERSION 59859f04454bc2574ab68cf0fd76ebdbc5f26fb6
 macro: CFORTH_VERSION HEAD
+
+macro: CFORTH_BUILD_DIR cforth/build/arm-xo-1.75

Modified: cpu/arm/olpc/1.75/cforth.bth
==============================================================================
--- cpu/arm/olpc/1.75/cforth.bth	Fri Dec  2 23:14:43 2011	(r2725)
+++ cpu/arm/olpc/1.75/cforth.bth	Sat Dec  3 01:44:58 2011	(r2726)
@@ -4,39 +4,4 @@
 build-now
 
 fload ${BP}/cpu/arm/olpc/1.75/cforth-version.fth
-
-macro: CFORTH_BUILD_DIR cforth/build/arm-xo-1.75
-
-\ Don't re-fetch the cforth source, thus preventing overwrites of development modifications.
-\ If you change cforth-version.fth to specify a different cforth source version, you must
-\ manually delete the old cforth subtree.
-
-" ${CFORTH_BUILD_DIR}/Makefile" expand$ $file-exists?  0=  [if]
-   " ${CFORTH_VERSION}" expand$ " modify" $=  [if]
-      " git clone -q git+ssh://dev.laptop.org/git/users/wmb/cforth" expand$ $sh
-   [else]
-      " ${CFORTH_VERSION}" expand$ " clone" $=  [if]
-         " git clone -q git://dev.laptop.org/users/wmb/cforth" expand$ $sh
-      [else]   
-         " wget -q -O - http://dev.laptop.org/git/users/wmb/cforth/snapshot/cforth-${CFORTH_VERSION}.tar.gz | tar xfz -" expand$ $sh
-         " mv cforth-${CFORTH_VERSION} cforth" expand$ $sh
-         " wget -q -O - http://dev.laptop.org/git/users/wmb/cforth/patch | head -1 | cut -f 2 -d ' ' >>${CFORTH_BUILD_DIR}/version" expand$ $sh
-         \ " echo -n const char cforth_version[] = '""' >${CFORTH_BUILD_DIR}/cforth_version.c" expand$ $sh
-         \ " wget -q -O - http://dev.laptop.org/git/users/wmb/cforth/patch | head -1 | cut -f 2 -d ' ' >>${CFORTH_BUILD_DIR}/cforth_version.c" expand$ $sh
-         \ " echo '"";' >>${CFORTH_BUILD_DIR}/cforth_version.c" expand$ $sh
-      [then]
-   [then]
-[then]
-
-" (cd ${CFORTH_BUILD_DIR}; make --no-print-directory)" expand$ $sh
-
-\ If the above make changed either cforth.img or shim.img, copy the new one into this directory,
-\ thus triggering a rebuild of the OFW .rom file
-
-" cforth.img" modtime  " ${CFORTH_BUILD_DIR}/cforth.img" expand$ modtime <  [if]
-   " (cp ${CFORTH_BUILD_DIR}/cforth.img .)" expand$ $sh
-[then]
-
-" shim.img" modtime  " ${CFORTH_BUILD_DIR}/shim.img" expand$ modtime <  [if]
-   " (cp ${CFORTH_BUILD_DIR}/shim.img .)" expand$ $sh
-[then]
+fload ${BP}/cpu/arm/olpc/build-cforth.fth

Modified: cpu/arm/olpc/1.75/config.fth
==============================================================================
--- cpu/arm/olpc/1.75/config.fth	Fri Dec  2 23:14:43 2011	(r2725)
+++ cpu/arm/olpc/1.75/config.fth	Sat Dec  3 01:44:58 2011	(r2726)
@@ -1,11 +1,12 @@
 \ create cl2-a1
 create debug-startup
 create olpc
+create olpc-cl2
 create trust-ec-keyboard
 create use-null-nvram
 create use-elf
 
 fload ${BP}/cpu/arm/mmp2/hwaddrs.fth
-fload ${BP}/cpu/arm/olpc/1.75/addrs.fth
+fload ${BP}/cpu/arm/olpc/addrs.fth
 
 create machine-signature ," CL2"

Modified: cpu/arm/olpc/1.75/ec-version.fth
==============================================================================
--- cpu/arm/olpc/1.75/ec-version.fth	Fri Dec  2 23:14:43 2011	(r2725)
+++ cpu/arm/olpc/1.75/ec-version.fth	Sat Dec  3 01:44:58 2011	(r2726)
@@ -1,4 +1,5 @@
 \ The EC microcode
+macro: EC_PLATFORM cl2
 macro: EC_VERSION 4_0_3_06
 
 \ Alternate command for getting EC microcode, for testing new versions.

Modified: cpu/arm/olpc/1.75/ec.bth
==============================================================================
--- cpu/arm/olpc/1.75/ec.bth	Fri Dec  2 23:14:43 2011	(r2725)
+++ cpu/arm/olpc/1.75/ec.bth	Sat Dec  3 01:44:58 2011	(r2726)
@@ -4,15 +4,4 @@
 build-now
 
 fload ${BP}/cpu/arm/olpc/1.75/ec-version.fth
-
-\ If there is a GET_EC macro, use it instead of fetching the released version.
-" ${GET_EC}" expand$  nip  [if]
-   " ${GET_EC}" expand$ $sh
-[else]
-   " wget -q http://dev.laptop.org/pub/ec/cl2-${EC_VERSION}.img -O ec.img" expand$ $sh
-[then]
-
-\ This forces the creation of an ec.log file, so we don't re-fetch ec.img
-writing ec.version
-" ${EC_VERSION}"n" expand$  ofd @ fputs
-ofd @ fclose
+fload ${BP}/cpu/arm/olpc/fetch-ec.fth

Modified: cpu/arm/olpc/1.75/fw-version.fth
==============================================================================
--- cpu/arm/olpc/1.75/fw-version.fth	Fri Dec  2 23:14:43 2011	(r2725)
+++ cpu/arm/olpc/1.75/fw-version.fth	Sat Dec  3 01:44:58 2011	(r2726)
@@ -1,3 +1,4 @@
 \ The overall firmware revision
+macro: FW_PREFIX Q4
 macro: FW_MAJOR C
 macro: FW_MINOR 07

Modified: cpu/arm/olpc/1.75/fw.bth
==============================================================================
--- cpu/arm/olpc/1.75/fw.bth	Fri Dec  2 23:14:43 2011	(r2725)
+++ cpu/arm/olpc/1.75/fw.bth	Sat Dec  3 01:44:58 2011	(r2726)
@@ -7,614 +7,4 @@
 
 " fw.tag" r/w create-file drop  tag-file !
 
-hex
-\ ' $report-name is include-hook
-\ ' noop is include-hook
-
-fload ${BP}/cpu/arm/olpc/fbnums.fth
-fload ${BP}/cpu/arm/olpc/fbmsg.fth
-
-fload ${BP}/cpu/arm/olpc/1.75/devices.fth
-
-[ifndef] virtual-mode
-warning off
-: stand-init-io
-   stand-init-io
-   go-fast         \ From mmuon.fth
-;
-warning on
-[then]
-
-fload ${BP}/cpu/arm/linux.fth
-
-\ The bottom of extra-mem is the top of DMA memory.
-\ We give everything up to that address to Linux.
-: olpc-memory-limit  ( -- adr )  extra-mem-va >physical  ;
-' olpc-memory-limit to memory-limit
-
-: usb-quiet  ( -- )
-   [ ' linux-hook behavior compile, ]    \ Chain to old behavior
-   unload-crypto
-   " /usb" " reset-usb" execute-device-method drop
-;
-
-d# 9999 to arm-linux-machine-type  \ Marvell Jasper
-
-\ Add a tag describing the linear frame buffer
-: mmp-fb-tag,  ( -- )
-   8 tag-l,
-   h# 54410008 tag-l, \ ATAG_VIDEOLFB
-   d# 1200 tag-w,     \ Width
-   d#  900 tag-w,     \ Height
-   d#   24 tag-w,     \ Depth
-   d# 1200 3 * tag-w, \ Pitch
-   fb-mem-va tag-l,   \ Base address
-   d# 1200 3 *  d# 900 *  tag-l,  \ Total size - perhaps could be larger
-   5     tag-b,       \ Red size
-   d# 11 tag-b,       \ Red position
-   6     tag-b,       \ Green size
-   d#  5 tag-b,       \ Green position
-   5     tag-b,       \ Blue size
-   d#  0 tag-b,       \ Blue position
-   0     tag-b,       \ Rsvd size
-   d# 16 tag-b,       \ Rsvd position
-;
-' mmp-fb-tag, to fb-tag,
-
-\ Add a tag describing the OFW callback
-3 constant MT_DEVICE_WC
-9 constant MT_MEMORY
-: (ofw-tag,)  ( -- )
-   4 2 * 3 +    tag-l,    \ size
-   h# 41000502  tag-l,    \ ATAG_MEM
-   cif-handler  tag-l,    \ Client interface handler callback address
-
-   \ Each of these groups is a struct map_desc as defined in arch/arm/include/asm/mach/
-   extra-mem-va dup                        tag-l,  \ VA of OFW memory
-   >physical pageshift rshift              tag-l,  \ Page frame number of OFW memory
-   fw-mem-va /fw-mem +  extra-mem-va -     tag-l,  \ Size of OFW memory
-   MT_MEMORY                               tag-l,  \ Mapping type of OFW memory
-
-   fb-mem-va dup                           tag-l,  \ VA of OFW Frame Buffer
-   >physical pageshift rshift              tag-l,  \ PA of OFW Frame Buffer
-   /fb-mem                                 tag-l,  \ Size of OFW memory
-   MT_DEVICE_WC                            tag-l,  \ Mapping type of OFW frame buffer
-;
-' (ofw-tag,) to ofw-tag,
-
-false to stand-init-debug?
-\ true to stand-init-debug?
-
-: sec-trg   ( -- )      d# 73 gpio-set  ;  \ rising edge latches SPI_WP# low
-: sec-trg?  ( -- bit )  d# 73 gpio-pin@  ;
-
-alias ec-indexed-io-off sec-trg
-alias ec-indexed-io-off? sec-trg?
-alias ec-ixio-reboot ec-power-cycle  \ clears latch, brings SPI_WP# high
-
-false value secure?
-
-: protect-fw  ( -- )  secure?  if  flash-protect sec-trg  then  ;
-
-hex
-: i-key-wait  ( ms -- pressed? )
-   cr ." Type 'i' to interrupt stand-init sequence" cr   ( ms )
-   0  do
-      ukey?  if
-         ukey upc ascii I  =  if  true unloop exit  then
-      then
-      d# 1000 us  \ 1000 us is more precise than 1 ms, which is often close to 2 ms
-   loop
-   false
-;
-
-: rotate-button?  ( -- flag )  d# 15 gpio-pin@ 0=  ;
-warning @  warning off 
-: init
-\ initial-heap add-memory
-   init
-
-   standalone?  if
-      disable-interrupts
-\     d# 1000  i-key-wait  if
-      rotate-button? if
-         protect-fw
-         \ Make the frame buffer visible so CForth won't complain about OFW not starting
-         h# 8009.1100 h# 20.b190 io!
-         ." Interacting" cr  hex interact
-      then
-      \ Turn on USB power here to overlap the time with other startup actions
-      usb-power-on
-   then
-;
-warning !
-
-: (.firmware)  ( -- )
-   ." Open Firmware  "  .built  cr
-   ." Copyright 2010 FirmWorks  All Rights Reserved" cr
-;
-' (.firmware) to .firmware
-
-\ Uninstall the diag menu from the general user interface vector
-\ so exiting from emacs doesn't invoke the diag menu.
-' quit to user-interface
-fload ${BP}/cpu/x86/pc/olpc/via/mfgtest.fth
-fload ${BP}/cpu/arm/olpc/1.75/testitems.fth
-
-[ifdef] notyet
-fload ${BP}/cpu/x86/pc/olpc/via/bootmenu.fth
-[then]
-
-: screen-#lines  ( -- n )
-   screen-ih 0=  if  default-#lines exit  then
-   screen-ih  package( #lines )package
-;
-' screen-#lines to lines/page
-
-true value text-on?
-: text-off  ( -- )
-   text-on?  if
-      screen-ih remove-output
-      false to text-on?
-   then
-;
-: text-on   ( -- )
-   text-on? 0=  if
-      screen-ih add-output
-      cursor-on
-      true to text-on?
-   then
-;
-
-fload ${BP}/cpu/x86/pc/olpc/via/banner.fth
-
-devalias keyboard /ap-sp/keyboard
-devalias mouse    /ap-sp/mouse
-
-: console-start  ( -- )
-   install-mux-io
-   cursor-off
-   true to text-on?
-
-   " //null" open-dev to null-ih  \ For text-off state
-;
-: keyboard-off  ( -- )
-   keyboard-ih  if
-      keyboard-ih remove-input
-      keyboard-ih close-dev
-      0 to keyboard-ih
-   then
-;
-
-: teardown-mux-io  ( -- )
-   install-uart-io
-   text-off
-   keyboard-off
-   fallback-out-ih remove-output
-   fallback-in-ih remove-input
-   stdin off
-   stdout off
-   in-mux-ih close-dev
-   out-mux-ih close-dev
-;
-: quiesce  ( -- )
-   teardown-mux-io
-   timers-off
-   usb-quiet
-   close-ec
-   \ Change the sleep state of EC_SPI_ACK from 1 (OFW value) to 0 (Linux value)
-   d# 125 af@  h# 100 invert and  d# 125 af!
-;
-
-\ This must precede the loading of gui.fth, which chains from linux-hook's behavior
-' quiesce to linux-hook
-
-\ This must be defined after spiui.fth, otherwise spiui will choose some wrong code
-: rom-pa  ( -- adr )  mfg-data-buf mfg-data-offset -  ;  \ Fake out setwp.fth
-fload ${BP}/cpu/x86/pc/olpc/setwp.fth
-
-fload ${BP}/cpu/arm/olpc/1.75/help.fth
-fload ${BP}/cpu/x86/pc/olpc/gui.fth
-fload ${BP}/cpu/x86/pc/olpc/strokes.fth
-fload ${BP}/cpu/x86/pc/olpc/plot.fth
-fload ${BP}/cpu/arm/olpc/1.75/testinstructions.fth
-
-fload ${BP}/cpu/arm/mmp2/dramrecal.fth
-
-code halt  ( -- )  wfi   c;
-
-fload ${BP}/cpu/arm/olpc/1.75/switches.fth \ Lid and ebook switches
-fload ${BP}/cpu/arm/mmp2/rtc.fth       \ Internal RTC, used for wakeups
-fload ${BP}/cpu/arm/olpc/1.75/leds.fth     \ LEDs
-fload ${BP}/cpu/x86/pc/olpc/via/factory.fth  \ Manufacturing tools
-
-fload ${BP}/cpu/arm/olpc/1.75/accelerometer.fth
-fload ${BP}/cpu/arm/olpc/1.75/compass.fth
-
-\ Suppress long memory test at final test stage
-dev /memory
-0 value old-diag-switch?
-: not-final-test?  ( -- flag )
-   final-test?   if  false exit  then
-   smt-test?  if  false exit  then
-   old-diag-switch?
-;
-warning @ warning off
-: selftest  ( -- error? )
-   diag-switch? to old-diag-switch?
-   not-final-test?  to diag-switch?
-   selftest
-   old-diag-switch? to diag-switch?
-;
-warning !
-device-end
-
-\ When reprogramming this machine's SPI FLASH, rebooting the EC is unnecessary 
-: no-kbc-reboot  ['] noop to spi-reprogrammed  ;
-: kbc-on ;
-
-\ Pseudo device that appears in the boot order before net booting
-0 0 " " " /" begin-package
-   " prober" device-name
-   : open
-      visible
-      false
-   ;
-   : close ;
-end-package
-
-\ it seems to be difficult to get SoC wakeups from the keypad controller,
-\ so we set them up as gpio, instead.
-[ifdef] use_mmp2_keypad_control
-fload ${BP}/cpu/arm/mmp2/keypad.fth
-[ifdef] notdef  \ CForth turns on the keypad; resetting it makes it not work
-stand-init: keypad
-   keypad-on
-   8 keypad-direct-mode
-;
-[then]
-: keypad-bit  ( n keypad out-mask key-mask -- n' keypad )
-   third invert  and  if    ( n keypad out-mask )
-      rot or swap           ( n' keypad )
-   else                     ( n keypad out-mask )
-      drop                  ( n keypad )
-   then                     ( n' keypad )
-;
-[then]
-
-fload ${BP}/cpu/x86/pc/olpc/gamekeynames.fth
-
-: game-key@  ( -- n )
-   0                                        ( n )
-[ifdef] cl2-a1
-   d# 16 gpio-pin@ 0=  if  h#  80 or  then  \ O
-   d# 17 gpio-pin@ 0=  if  h#  02 or  then  \ Check
-   d# 18 gpio-pin@ 0=  if  h# 100 or  then  \ X
-   d# 19 gpio-pin@ 0=  if  h#  01 or  then  \ Square
-   d# 20 gpio-pin@ 0=  if  h#  40 or  then  \ Rotate
-[else]
-[ifdef] use_mmp2_keypad_control
-   d# 15 gpio-pin@ 0=  if  button-rotate or  then   ( n )
-   scan-keypad                              ( n keypad )
-   button-o       h# 01  keypad-bit         ( n' keypad )
-   button-check   h# 02  keypad-bit         ( n' keypad )
-   button-x       h# 04  keypad-bit         ( n' keypad )
-   button-square  h# 08  keypad-bit         ( n' keypad )
-   rocker-up      h# 10  keypad-bit         ( n' keypad )
-   rocker-right   h# 20  keypad-bit         ( n' keypad )
-   rocker-down    h# 40  keypad-bit         ( n' keypad )
-   rocker-left    h# 80  keypad-bit         ( n' keypad )
-   drop                                     ( n )
-[else]
-   d# 15 gpio-pin@ 0=  if  button-rotate  or  then
-   d# 16 gpio-pin@ 0=  if  button-o       or  then
-   d# 17 gpio-pin@ 0=  if  button-check   or  then
-   d# 18 gpio-pin@ 0=  if  button-x       or  then
-   d# 19 gpio-pin@ 0=  if  button-square  or  then
-   d# 20 gpio-pin@ 0=  if  rocker-up      or  then
-   d# 21 gpio-pin@ 0=  if  rocker-right   or  then
-   d# 22 gpio-pin@ 0=  if  rocker-down    or  then
-   d# 23 gpio-pin@ 0=  if  rocker-left    or  then
-[then]
-[then]
-;
-
-fload ${BP}/cpu/x86/pc/olpc/gamekeys.fth
-
-fload ${BP}/dev/logdev.fth
-fload ${BP}/cpu/x86/pc/olpc/disptest.fth
-dev /ap-sp/keyboard
-fload ${BP}/dev/olpc/keyboard/selftest.fth   \ Keyboard diagnostic
-device-end
-stand-init: Keyboard
-   " /ap-sp/keyboard" " set-keyboard-type" execute-device-method drop
-;
-dev /ap-sp/mouse
-fload ${BP}/dev/olpc/touchpad/syntpad.fth    \ Touchpad diagnostic
-device-end
-fload ${BP}/cpu/x86/pc/olpc/gridmap.fth      \ Gridded display tools
-fload ${BP}/cpu/x86/pc/olpc/via/copynand.fth
-\ fload ${BP}/cpu/arm/olpc/1.75/exc7200-touchscreen.fth    \ Touchscreen driver and diagnostic
-fload ${BP}/cpu/arm/olpc/1.75/rm3150-touchscreen.fth    \ Touchscreen driver and diagnostic
-fload ${BP}/cpu/arm/olpc/1.75/roller.fth     \ Accelerometer test
-
-\ fload ${BP}/cpu/arm/olpc/1.75/pinch.fth  \ Touchscreen gestures
-\ : pinch  " pinch" screen-ih $call-method  ;
-
-: emacs  ( -- )
-   false to already-go?
-   boot-getline to boot-file   " rom:emacs" $boot
-;
-defer rm-go-hook  \ Not used, but makes security happy
-: tsc@  ( -- d.ticks )  timer0@ u>d  ;
-d# 6500 constant ms-factor
-
-\ idt1338 rtc and ram address map
-\     00 -> 0f  rtc
-\     10 -> 3f  cmos
-
-: >rtc  ( index -- rtc-address )  h# 3f and  h# 10 +  ;
-
-: cmos@  ( index -- data )
-   >rtc " rtc@" clock-node @  ( index adr len ih )
-   ['] $call-method catch  if  4drop 0  then
-;
-: cmos!  ( data index -- )
-   >rtc " rtc!" clock-node @  ( data index adr len ih )
-   ['] $call-method catch  if  2drop 3drop  then
-;
-
-\ cmos address map
-\     80 audio volume
-\     81 audio volume
-\     82 alternate boot
-\     83 xid
-
-: dimmer  ( -- )  screen-ih  if  " dimmer" screen-ih $call-method  then  ;
-: brighter  ( -- )  screen-ih  if  " brighter" screen-ih $call-method  then  ;
-
-fload ${BP}/cpu/x86/pc/olpc/sound.fth
-fload ${BP}/cpu/x86/pc/olpc/guardrtc.fth
-fload ${BP}/cpu/x86/pc/olpc/security.fth
-2 to bundle-suffix
-
-stand-init: xid
-   h# 83 cmos@  dup 1+  h# 83 cmos!   ( n )
-   d# 24 lshift               ( new-xid )
-   " dev /obp-tftp  to rpc-xid  dend" evaluate
-;
-
-: pre-setup-for-linux  ( -- )
-   [ ' linux-pre-hook behavior compile, ]    \ Chain to old behavior
-   sound-end
-;
-' pre-setup-for-linux to linux-pre-hook
-
-: show-temperature  ( -- )  space cpu-temperature .d  ;
-fload ${BP}/cpu/arm/bootascall.fth
-create use-thinmac
-fload ${BP}/cpu/x86/pc/olpc/wifichannel.fth
-fload ${BP}/cpu/x86/pc/olpc/via/nbtx.fth
-fload ${BP}/cpu/x86/pc/olpc/via/nbrx.fth
-fload ${BP}/cpu/x86/pc/olpc/via/blockfifo.fth
-
-alias fast-hash crypto-hash   \ fast-hash uses acceleration when available
-fload ${BP}/cpu/x86/pc/olpc/via/fsupdate.fth
-fload ${BP}/cpu/x86/pc/olpc/via/fsverify.fth
-devalias fsdisk int:0
-
-\ create pong-use-touchscreen
-fload ${BP}/ofw/gui/ofpong.fth
-fload ${BP}/cpu/x86/pc/olpc/life.fth
-
-" u:\boot\olpc.fth ext:\boot\olpc.fth int:\boot\olpc.fth ext:\zimage /prober /usb/ethernet /usb/wlan"
-   ' boot-device  set-config-string-default
-
-\needs ramdisk  " " d# 128 config-string ramdisk
-" "   ' boot-file      set-config-string-default   \ Let the boot script set the cmdline
-
-2 config-int auto-boot-countdown
-
-\ Eliminate 4 second delay in install console for the case where
-\ there is no keyboard.  The delay is unnecessary because the screen
-\ does not go blank when the device is closed.
-patch drop ms install-console
-
-alias reboot bye
-
-alias crcgen drop  ( crc byte -- crc' )
-
-\ Dictionary growth size for the ARM Image Format header
-\ 1 section   before origin  section table
-h# 10.0000      h# 8000 -      h# 4000 -      dictionary-size !
-
-fload ${BP}/cpu/arm/saverom.fth  \ Save the dictionary for standalone startup
-
-fload ${BP}/ofw/core/countdwn.fth	\ Startup countdown
-
-fload ${BP}/dev/hdaudio/noiseburst.fth  \ audio-test support package
-
-\ Because visible doesn't work sometimes when calling back from Linux
-dev /client-services  patch noop visible enter  dend
-
-: interpreter-init  ( -- )
-   hex
-   warning on
-   only forth also definitions
-
-   install-alarm
-
-   page-mode
-   #line off
-
-\   .built cr
-;
-
-
-: factory-test?  ( -- flag )
-   \ TS is the "test station" tag, whose value is set to "SHIP" at the
-   \ end of manufacturing test.
-   " TS" find-tag  if         ( adr len )
-      ?-null  " SHIP" $=  0=  ( in-factory? )
-   else                       ( )
-      \ Missing TS tag is treated as not in factory test
-      false
-   then                       ( in-factory? )
-;
-
-: ?sound  ( -- )
-   \ Suppress the jingle if a game key is pressed, because we don't want
-   \ the jingle to interfere with diags and stuff
-   -1 game-key?  if  exit  then
-   ['] sound catch drop
-;
-
-: ?games  ( -- )
-   rocker-right game-key?  if
-      protect-fw
-      time&date 5drop 1 and  if
-         ['] pong guarded
-      else
-         ['] life-demo guarded
-      then
-      power-off
-   then
-;
-: ?diags  ( -- )
-   rocker-left game-key?  if
-      protect-fw
-      text-on  ['] gamekey-auto-menu guarded
-      ." Tests complete - powering off" cr  d# 5000 ms  power-off
-   then
-;
-
-: ?fs-update  ( -- )
-   button-check button-x or  button-o or  button-square or   ( mask )
-   game-key-mask =  if  protect-fw try-fs-update  then
-;
-
-fload ${BP}/cpu/arm/mmp2/clocks.fth
-
-: startup  ( -- )
-   standalone?  0=  if  exit  then
-
-   block-exceptions
-   no-page
-
-   ?factory-mode
-
-   disable-user-aborts
-   console-start
-
-   read-game-keys
-
-   factory-test? 0=  if  text-off  then
-
-   " probe-" do-drop-in
-
-   show-child
-
-   update-ec-flash?  if
-      ['] ?enough-power catch  ?dup  if  ( error )
-	 show-no-power
-	 .error
-	 ." Skipping EC reflash, not enough power" cr
-	 d# 1000 ms
-      else
-	 show-reflash
-	 ['] show-reflash-dot to edi-progress
-	 update-ec-flash
-      then
-   then
-
-   install-alarm
-   ?sound
-
-   ?games
-
-   ['] false to interrupt-auto-boot?
-[ifdef] probe-usb
-   factory-test?  if  d# 1000 ms  then  \ Extra USB probe delay in the factory
-   probe-usb
-   report-disk
-   report-keyboard
-[then]
-   " probe+" do-drop-in
-
-   interpreter-init
-
-   ?diags
-   ?fs-update
-
-   factory-test? 0=  if  secure-startup  then
-   unblock-exceptions
-   ['] (interrupt-auto-boot?) to interrupt-auto-boot?
-
-   ?usb-keyboard
-
-   auto-banner?  if  banner  then
-
-   auto-boot
-
-   frozen? text-on? 0=  and  ( no-banner? )
-   unfreeze visible cursor-on ( no-banner? )
-   if  banner  then  \ Reissue banner if it was suppressed
-
-   blue-letters ." Type 'help' for more information." black-letters cancel
-   cr cr
-
-   enable-user-aborts
-   stop-sound   
-   quit
-;
-
-: newrom
-   " flash! http:\\192.168.200.200\new.rom" eval
-;
-: newec
-   " flash-ec http:\\192.168.200.200\ecimage.bin" eval
-;
-: qz
-   " qz" $essid  " http:\\qz\" included  \ qa test bed scripting, james cameron
-;
-: urom  " flash! u:\new.rom" eval  ;
-: uec   " flash-ec! u:\ecimage.bin" eval  ;
-: erom  " flash! ext:\new.rom" eval  ;
-: no-usb-delay  " dev /usb  false to delay?  dend"  evaluate  ;
-: null-fsdisk
-   " dev /null : write-blocks-start 3drop ; : write-blocks-finish ; dend" evaluate
-   " devalias fsdisk //null" evaluate
-;
-
-tag-file @ fclose  tag-file off
-
-.( --- Saving fw.dic ...)
-" fw.dic" $save-forth cr
-
-fload ${BP}/cpu/arm/mmp2/rawboot.fth
-
-.( --- Saving fw.img --- )  cr " fw.img" $save-rom
-
-\ 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
+fload ${BP}/cpu/arm/olpc/build-fw.fth

Modified: cpu/arm/olpc/1.75/mcastnand.bth
==============================================================================
--- cpu/arm/olpc/1.75/mcastnand.bth	Fri Dec  2 23:14:43 2011	(r2725)
+++ cpu/arm/olpc/1.75/mcastnand.bth	Sat Dec  3 01:44:58 2011	(r2726)
@@ -4,20 +4,4 @@
 build-now
 
 fload ${BP}/cpu/arm/olpc/1.75/mcnand-version.fth
-
-" ${MCNAND_VERSION}" expand$ " test" $=  [if]
-   " multicast-nand/Makefile" $file-exists?  0=  [if]
-      " git clone -q git+ssh://dev.laptop.org/git/users/wmb/multicast-nand" expand$ $sh
-   [then]
-[else]   
-   " rm -rf multicast-nand" $sh
-   " wget -q -O - http://dev.laptop.org/git/users/wmb/multicast-nand/snapshot/multicast-nand-${MCNAND_VERSION}.tar.gz | tar xfz -" expand$ $sh
-   " mv multicast-nand-${MCNAND_VERSION} multicast-nand" expand$ $sh
-[then]
-
-" (cd multicast-nand; make BPDIR=../../../../../.. OFW_CPU=arm nandblaster15_rx.bin nandblaster_tx.bin; cp nandblaster15_rx.bin nandblaster_tx.bin ..)" expand$ $sh
-
-\ This forces the creation of a .log file, so we don't re-fetch
-writing mcastnand.version
-" ${MCNAND_VERSION}"n" expand$  ofd @ fputs
-ofd @ fclose
+fload ${BP}/cpu/arm/olpc/build-mcnand.fth

Modified: cpu/arm/olpc/1.75/olpc.bth
==============================================================================
--- cpu/arm/olpc/1.75/olpc.bth	Fri Dec  2 23:14:43 2011	(r2725)
+++ cpu/arm/olpc/1.75/olpc.bth	Sat Dec  3 01:44:58 2011	(r2726)
@@ -21,13 +21,13 @@
 
 fload ${BP}/cpu/arm/olpc/1.75/fw-version.fth
 
-" macro: FW_VERSION Q4${FW_MAJOR}${FW_MINOR}" expand$ eval
+" macro: FW_VERSION ${FW_PREFIX}${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}/cpu/arm/olpc/sourceurl.fth
 
 fload ${BP}/forth/lib/crc32.fth
 
@@ -48,13 +48,11 @@
 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
+image: OBMI      800 d101c000 ${BP}/cpu/arm/olpc/dummy.img
 \ Secure Processor code loaded into SRAM
 image: WTMI     1000 d1018000 shim.img
 image: CFTH     2000 d1000000 cforth.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
@@ -152,8 +150,8 @@
    " ${BP}/cpu/x86/pc/olpc/images/leds.di"      $add-file
    " ${BP}/cpu/x86/pc/olpc/images/ebook.di"     $add-file
 
-   " ${BP}/cpu/arm/olpc/1.75/build/nandblaster15_rx.bin" " nb15_rx"  $add-deflated-dropin
-   " ${BP}/cpu/arm/olpc/1.75/build/nandblaster_tx.bin"   " nb_tx"    $add-deflated-dropin
+   " nandblaster15_rx.bin" " nb15_rx"  $add-deflated-dropin
+   " nandblaster_tx.bin"   " nb_tx"    $add-deflated-dropin
 0 [if]
    " ${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
@@ -173,7 +171,7 @@
 signature h# 10 blank
 machine-signature count   signature         swap move
 " ${FW_VERSION}" expand$  signature     6 + swap move
-" Q4${FW_MAJOR}" expand$  signature d# 13 + swap move
+" ${FW_PREFIX}${FW_MAJOR}" expand$  signature d# 13 + swap move
 signature h# 10  ofd @ fputs
 
 /l buffer: crcbuf

Modified: cpu/arm/olpc/1.75/prefw.bth
==============================================================================
--- cpu/arm/olpc/1.75/prefw.bth	Fri Dec  2 23:14:43 2011	(r2725)
+++ cpu/arm/olpc/1.75/prefw.bth	Sat Dec  3 01:44:58 2011	(r2726)
@@ -5,254 +5,9 @@
 command: &armforth &dictionary &this
 build-now
 
+\ This line must be in this file instead of in prefw.fth so the definitions
+\ in config.fth will be tagged.
 " prefw.tag" r/w create-file drop  tag-file !
 
-hex
-\ ' $report-name is include-hook
-' noop is include-hook
-
 fload ${BP}/cpu/arm/olpc/1.75/config.fth
-
-: headerless ;  : headers  ;  : headerless0 ;
-
-' (quit) to quit
-
-: \Tags [compile] \  ; immediate
-: \NotTags [compile] \  ; immediate
-
-def-load-base ' load-base set-config-int-default
-
-true ' fcode-debug? set-config-int-default
-
-[ifdef] serial-console
-" com1" ' output-device set-config-string-default
-" com1" ' input-device set-config-string-default
-[then]
-
-fload ${BP}/ofw/core/memlist.fth	\ Resource list common routines
-fload ${BP}/ofw/core/showlist.fth	\ Linked list display tool
-
-\ Memory management services
-[ifdef] virtual-mode
-fload ${BP}/ofw/core/clntmem1.fth	\ client services for memory
-[else]
-fload ${BP}/ofw/core/clntphy1.fth	\ client services for memory
-defer page-table-va
-: >physical  ( va -- pa )
-   dup  d# 20 rshift             ( va section-index )
-   page-table-va swap la+  l@    ( va pte )
-   h# fffff invert and           ( va pa-base )
-   swap h# fffff and  or         ( pa )
-;
-[then]
-
-fload ${BP}/cpu/arm/mmp2/rootnode.fth	\ Root node mapping - physical mode
-
-fload ${BP}/ofw/core/allocph1.fth	\ S Physical memory allocator
-fload ${BP}/ofw/core/availpm.fth	\ Available memory list
-
-dev /
-   " olpc,XO-1.75" model
-   " OLPC" encode-string  " architecture" property
-\ The clock frequency of the root bus may be irrelevant, since the bus is internal to the SOC
-\    d# 1,000,000,000 " clock-frequency" integer-property
-device-end
-
-: (cpu-arch  ( -- adr len )
-   " architecture" ['] root-node  get-package-property  drop
-   get-encoded-string
-;
-' (cpu-arch to cpu-arch
-
-[ifndef] virtual-mode
-fload ${BP}/cpu/arm/mmp2/mmuon.fth
-[then]
-fload ${BP}/cpu/arm/olpc/1.75/probemem.fth	\ Memory probing
-
-stand-init: Probing memory
-   " probe" memory-node @ $call-method
-;
-
-[ifdef] virtual-mode
-fload ${BP}/cpu/arm/loadvmem.fth	\ /mmu node
-stand-init: MMU
-   " /mmu" open-dev mmu-node !
-;
-fload ${BP}/ofw/core/initdict.fth	\ Dynamic dictionary allocation
-fload ${BP}/arch/arm/loadarea.fth	\ Allocate and map program load area
-[then]
-
-\ XXX should be elsewhere
-dev /client-services
-: chain  ( len args entry size virt -- )
-   release                                       ( len args entry )
-   h# 8000 alloc-mem h# 8000 +  (init-program)   ( len args )
-   to r1  to r2
-   go
-;
-device-end
-
-fload ${BP}/cpu/arm/crc32.fth		\ Assembly language Zip CRC calculation
-fload ${BP}/forth/lib/crc32.fth		\ High-level portion of CRC calculation
-
-[ifdef] resident-packages
-
-\needs unix-seconds>  fload ${BP}/ofw/fs/unixtime.fth	\ Unix time calculation
-support-package: ext2-file-system
-   fload ${BP}/ofw/fs/ext2fs/ext2fs.fth	\ Linux file system
-end-support-package
-
-[ifdef] jffs2-support
-\needs unix-seconds>  fload ${BP}/ofw/fs/unixtime.fth	\ Unix time calculation
-support-package: jffs2-file-system
-   fload ${BP}/ofw/fs/jffs2/jffs2.fth	\ Journaling flash file system 2
-end-support-package
-[then]
-
-support-package: zip-file-system
-   fload ${BP}/ofw/fs/zipfs.fth		\ Zip file system
-end-support-package
-[then]
-
-fload ${BP}/ofw/core/osfile.fth		\ For testing
-
-\ Load file format handlers
-
-: call32 ;
-
-fload ${BP}/ofw/core/allocsym.fth    \ Allocate memory for symbol table
-fload ${BP}/ofw/core/symcif.fth
-fload ${BP}/ofw/core/symdebug.fth
-: release-load-area  ( boundary-adr -- )  drop  ;
-
-[ifdef] use-elf
-fload ${BP}/ofw/elf/elf.fth
-fload ${BP}/ofw/elf/elfdebug.fth
-[ifdef] virtual-mode
-\ Depends on the assumption that physical memory is mapped 1:1 already
-: (elf-map-in) ( va size -- )  0 mem-claim  drop  ;
-[else]
-: (elf-map-in)  ( va size -- )  2drop  ;
-[then]
-' (elf-map-in) is elf-map-in
-[then]
-
-\ Reboot and re-entry code
-fload ${BP}/ofw/core/reboot.fth		\ Restart the client program
-fload ${BP}/ofw/core/reenter.fth	\ Various entries into Forth
-
-headerless
-[ifdef] virtual-mode
-: (initial-heap)  ( -- adr len )  sp0 @ ps-size -  dict-limit  tuck -  ;
-[else]
-   \ : (initial-heap)  ( -- adr len )  RAMtop heap-size  ;
-: (initial-heap)  ( -- adr len )  limit heap-size  ;
-[then]
-' (initial-heap) is initial-heap
-headers
-
-" /openprom" find-device
-   " FirmWorks,3.0" encode-string " model" property
-device-end
-
-[ifdef] virtual-mode
-fload ${BP}/cpu/arm/mmusetup.fth	\ Initial values for MMU lists
-[then]
-
-: background-rgb  ( -- r g b )  h# ff h# ff h# ff  ;
-
-fload ${BP}/forth/lib/selstr.fth
-
-fload ${BP}/cpu/arm/mmp2/socregs.fth   \ MMP2 registers used by many functional units
-
-fload ${BP}/cpu/arm/mmp2/hash.fth      \ Hashes - SHA1, SHA-256, MD5
-fload ${BP}/cpu/x86/pc/olpc/crypto.fth \ Cryptographic image validation
-fload ${BP}/cpu/x86/pc/olpc/lzip.fth   \ Access zip images from memory
-
-fload ${BP}/ofw/inet/loadtcp.fth
-
-support-package: http
-   fload ${BP}/ofw/inet/http.fth	\ HTTP client
-end-support-package
-
-support-package: cifs
-   fload ${BP}/ofw/fs/cifs/loadpkg.fth
-end-support-package
-devalias smb tcp//cifs
-devalias cifs tcp//cifs
-: op  " select smb:\\test:testxxx at 10.20.0.14\XTest\hello.txt" eval ;
-: dsmb  " dir smb:\\test:testxxx at 10.20.0.14\XTest\" eval ;
-
-[ifdef] notyet
-fload ${BP}/cpu/arm/olpc/1.75/memtest.fth
-[then]
-
-fload ${BP}/ofw/wifi/wifi-cfg.fth
-support-package: supplicant
-fload ${BP}/ofw/wifi/loadpkg.fth
-end-support-package
-
-: olpc-ssids  ( -- $ )  " OLPCOFW"  ;
-' olpc-ssids to default-ssids
-
-fload ${BP}/ofw/inet/sntp.fth
-: olpc-ntp-servers  ( -- )
-   " DHCP time 172.18.0.1 0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org"
-;
-' olpc-ntp-servers to ntp-servers
-: ntp-time&date  ( -- s m h d m y )
-   ntp-timestamp  abort" Can't contact NTP server"
-   ntp>time&date
-;
-: .clock  ( -- )
-   time&date .date space .time  ."  UTC" cr
-;
-: ntp-set-clock  ( -- )
-   ntp-time&date  " set-time"  clock-node @ $call-method
-   .clock
-;
-
-[ifdef] use-ppp
-fload ${BP}/ofw/ppp/loadppp.fth
-[then]
-
-" dhcp" ' ip-address  set-config-string-default
-
-fload ${BP}/ofw/gui/bmptools.fth
-fload ${BP}/dev/null.fth
-fload ${BP}/ofw/core/bailout.fth
-
-true ' local-mac-address? set-config-int-default
-[ifdef] resident-packages
-support-package: nfs
-   fload ${BP}/ofw/fs/nfs/loadpkg.fth
-end-support-package
-[then]
-devalias nfs net//obp-tftp:last//nfs
-
-\ This helps with TeraTerm, which sends ESC-O as the arrow key prefix
-also hidden also keys-forth definitions
-warning @  warning off
-: esc-o  key lastchar !  [""] esc-[ do-command  ;
-warning !
-previous previous definitions
-
-\ GUI
-false value gui-safeboot?
-
-: 2tuck  ( d1 d2 -- d2 d1 d2 )  2swap 2over  ;
-false value fru-test?
-: user-ok  "ok"  ;  \ This is supposed to check for authorization
-true value user-mode?
-
-fload ${BP}/ofw/gui/loadmenu.fth
-\ fload ${BP}/ofw/gui/insticon.fth
-
-\ Uninstall the diag menu from the general user interface vector
-\ so exiting from emacs doesn't invoke the diag menu.
-' quit to user-interface
-
-tag-file @ fclose  tag-file off
-
-.( --- Saving prefw.dic ...)
-" prefw.dic" $save-forth cr
+fload ${BP}/cpu/arm/olpc/prefw.fth

Modified: cpu/arm/olpc/1.75/sd8686.bth
==============================================================================
--- cpu/arm/olpc/1.75/sd8686.bth	Fri Dec  2 23:14:43 2011	(r2725)
+++ cpu/arm/olpc/1.75/sd8686.bth	Sat Dec  3 01:44:58 2011	(r2726)
@@ -3,35 +3,6 @@
 command: &builder &this
 build-now
 
-\needs to-file       fload ${BP}/forth/lib/tofile.fth
-\needs $md5sum-file  fload ${BP}/forth/lib/md5file.fth
-
 fload ${BP}/cpu/arm/olpc/1.75/wlan-version.fth
 
-" macro: WLAN_FILE lbtf_sdio-${WLAN_VERSION}" expand$ eval
-
-" ${GET_WLAN}" expand$  nip  [if]
-   " ${GET_WLAN}" expand$ $sh
-[else]
-" rm -f sd8686.bin sd8686_helper.bin" expand$ $sh
-
-" wget -q http://dev.laptop.org/pub/firmware/libertas/thinfirm/${WLAN_FILE}.bin" expand$ $sh
-" wget -q http://dev.laptop.org/pub/firmware/libertas/thinfirm/${WLAN_FILE}.bin.md5" expand$ $sh
-
-to-file md5string  "  "  " ${WLAN_FILE}.bin" expand$ $md5sum-file
-" cmp md5string ${WLAN_FILE}.bin.md5" expand$ $sh
-
-" cp ${WLAN_FILE}.bin sd8686.bin" expand$ $sh
-
-" wget -q http://dev.laptop.org/pub/firmware/libertas/sd8686_helper.bin" expand$ $sh
-" wget -q http://dev.laptop.org/pub/firmware/libertas/sd8686_helper.bin.md5" expand$ $sh
-to-file md5string  " *" " sd8686_helper.bin" $md5sum-file
-" cmp md5string sd8686_helper.bin.md5" expand$ $sh
-
-" rm ${WLAN_FILE}.bin.md5 sd8686_helper.bin.md5 md5string" expand$ $sh
-[then]
-
-\ This forces the creation of a .log file, so we don't re-fetch
-writing sd8686.version
-" ${WLAN_VERSION}"n" expand$  ofd @ fputs
-ofd @ fclose
+fload ${BP}/cpu/arm/olpc/build-wlan.fth

Modified: cpu/arm/olpc/1.75/verify.bth
==============================================================================
--- cpu/arm/olpc/1.75/verify.bth	Fri Dec  2 23:14:43 2011	(r2725)
+++ cpu/arm/olpc/1.75/verify.bth	Sat Dec  3 01:44:58 2011	(r2726)
@@ -3,26 +3,5 @@
 command: &builder &this
 build-now
 
-\needs to-file       fload ${BP}/forth/lib/tofile.fth
-\needs $md5sum-file  fload ${BP}/forth/lib/md5file.fth
-
 fload ${BP}/cpu/arm/olpc/1.75/crypto-version.fth
-
-" wget -q http://dev.laptop.org/pub/firmware/crypto/${KEYS}/os.public        -O os.public"        expand$ $sh
-" wget -q http://dev.laptop.org/pub/firmware/crypto/${KEYS}/fw.public        -O fw.public"        expand$ $sh
-" wget -q http://dev.laptop.org/pub/firmware/crypto/${KEYS}/fs.public        -O fs.public"        expand$ $sh
-" wget -q http://dev.laptop.org/pub/firmware/crypto/${KEYS}/lease.public     -O lease.public"     expand$ $sh
-" wget -q http://dev.laptop.org/pub/firmware/crypto/${KEYS}/developer.public -O developer.public" expand$ $sh
-" wget -q http://dev.laptop.org/pub/firmware/crypto/bios_verify-${CRYPTO_VERSION}.img" expand$ $sh
-" wget -q http://dev.laptop.org/pub/firmware/crypto/bios_verify-${CRYPTO_VERSION}.img.md5" expand$ $sh
-
-to-file md5string  " *"  " bios_verify-${CRYPTO_VERSION}.img" expand$ $md5sum-file
-" cmp md5string bios_verify-${CRYPTO_VERSION}.img.md5" expand$ $sh
-
-" cp bios_verify-${CRYPTO_VERSION}.img verify.img" expand$ $sh
-" rm bios_verify-${CRYPTO_VERSION}.img.md5 md5string" expand$ $sh
-
-\ This forces the creation of an verify.log file, so we don't re-fetch
-writing verify.version
-" ${CRYPTO_VERSION}"n" expand$  ofd @ fputs
-ofd @ fclose
+fload ${BP}/cpu/arm/olpc/build-crypto.fth

Copied and modified: cpu/arm/olpc/accelerometer.fth (from r2725, cpu/arm/olpc/1.75/accelerometer.fth)
==============================================================================

Copied and modified: cpu/arm/olpc/accelerometer.txt (from r2725, cpu/arm/olpc/1.75/accelerometer.txt)
==============================================================================

Copied and modified: cpu/arm/olpc/addrs.fth (from r2725, cpu/arm/olpc/1.75/addrs.fth)
==============================================================================

Copied and modified: cpu/arm/olpc/alc5624.fth (from r2725, cpu/arm/olpc/1.75/alc5624.fth)
==============================================================================

Copied and modified: cpu/arm/olpc/alc5631.fth (from r2725, cpu/arm/olpc/1.75/alc5631.fth)
==============================================================================

Copied and modified: cpu/arm/olpc/bbedi.fth (from r2725, cpu/arm/olpc/1.75/bbedi.fth)
==============================================================================

Copied and modified: cpu/arm/olpc/boardrev.fth (from r2725, cpu/arm/olpc/1.75/boardrev.fth)
==============================================================================

Copied and modified: cpu/arm/olpc/build-cforth.fth (from r2725, cpu/arm/olpc/1.75/cforth.bth)
==============================================================================
--- cpu/arm/olpc/1.75/cforth.bth	Fri Dec  2 23:14:43 2011	(r2725, copy source)
+++ cpu/arm/olpc/build-cforth.fth	Sat Dec  3 01:44:58 2011	(r2726)
@@ -1,11 +1,6 @@
-purpose: Fetch and compile CForth for the Security Processor
+purpose: Common instructions for fetching and building CForth
 
-command: &builder &this
-build-now
-
-fload ${BP}/cpu/arm/olpc/1.75/cforth-version.fth
-
-macro: CFORTH_BUILD_DIR cforth/build/arm-xo-1.75
+\ The macros CFORTH_VERSION and CFORTH_BUILD_DIR must be set externally
 
 \ Don't re-fetch the cforth source, thus preventing overwrites of development modifications.
 \ If you change cforth-version.fth to specify a different cforth source version, you must

Copied and modified: cpu/arm/olpc/build-crypto.fth (from r2725, cpu/arm/olpc/1.75/verify.bth)
==============================================================================
--- cpu/arm/olpc/1.75/verify.bth	Fri Dec  2 23:14:43 2011	(r2725, copy source)
+++ cpu/arm/olpc/build-crypto.fth	Sat Dec  3 01:44:58 2011	(r2726)
@@ -1,13 +1,10 @@
-purpose: Fetch the Crypto code and keys
+purpose: Common code for fetching and building the crypto support code
 
-command: &builder &this
-build-now
+\ The macro CRYPTO_VERSION must be defined externally
 
 \needs to-file       fload ${BP}/forth/lib/tofile.fth
 \needs $md5sum-file  fload ${BP}/forth/lib/md5file.fth
 
-fload ${BP}/cpu/arm/olpc/1.75/crypto-version.fth
-
 " wget -q http://dev.laptop.org/pub/firmware/crypto/${KEYS}/os.public        -O os.public"        expand$ $sh
 " wget -q http://dev.laptop.org/pub/firmware/crypto/${KEYS}/fw.public        -O fw.public"        expand$ $sh
 " wget -q http://dev.laptop.org/pub/firmware/crypto/${KEYS}/fs.public        -O fs.public"        expand$ $sh

Added: cpu/arm/olpc/build-fw.fth
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ cpu/arm/olpc/build-fw.fth	Sat Dec  3 01:44:58 2011	(r2726)
@@ -0,0 +1,1021 @@
+purpose: Common code for build OFW Forth dictionaries for OLPC ARM platforms
+\ See license at end of file
+
+hex
+\ ' $report-name is include-hook
+\ ' noop is include-hook
+
+fload ${BP}/cpu/arm/olpc/fbnums.fth
+fload ${BP}/cpu/arm/olpc/fbmsg.fth
+
+fload ${BP}/dev/omap/diaguart.fth	\ OMAP UART
+
+h# 18000 +io to uart-base		\ UART3 base address on MMP2
+\ h# 30000 +io to uart-base		\ UART1 base address on MMP2
+d# 26000000 to uart-clock-frequency
+
+\ CForth has already set up the serial port
+: inituarts  ( -- )  ;
+
+fload ${BP}/forth/lib/sysuart.fth	\ Set console I/O vectors to UART
+
+0 value keyboard-ih
+
+fload ${BP}/ofw/core/muxdev.fth          \ I/O collection/distribution device
+
+\ Install the simple UART driver from the standalone I/O init chain
+warning off
+: stand-init-io  ( -- )
+   stand-init-io
+   inituarts  install-uart-io
+;
+warning on
+
+[ifdef] use-null-nvram
+\ For not storing configuration variable changes across reboots ...
+\ This is useful for "turnkey" systems where configurability would
+\ increase support costs.
+
+fload ${BP}/cpu/x86/pc/nullnv.fth
+stand-init: Null-NVRAM
+   " /null-nvram" open-dev  to nvram-node
+   ['] init-config-vars catch drop
+;
+[then]
+
+[ifdef] use-flash-nvram
+\ For configuration variables stored in a sector of the boot FLASH ...
+
+\ Create a node below the top-level FLASH node to access the portion
+\ containing the configuration variables.
+0 0  " d0000"  " /flash" begin-package
+   " nvram" device-name
+
+   h# 10000 constant /device
+   fload ${BP}/dev/subrange.fth
+end-package
+
+stand-init: NVRAM
+   " /nvram" open-dev  to nvram-node
+   ['] init-config-vars catch drop
+;
+[then]
+
+\ Create a pseudo-device that presents the dropin modules as a filesystem.
+fload ${BP}/ofw/fs/dropinfs.fth
+
+\ This devalias lets us say, for example, "dir rom:"
+devalias rom     /dropin-fs
+
+fload ${BP}/cpu/x86/pc/cpunode.fth  \ The PC CPU node is actually fairly generic
+
+: cpu-mhz  ( -- n )
+   " /cpu at 0" find-package drop	( phandle )
+   " clock-frequency" rot get-package-property  if  0 exit  then  ( adr )
+   decode-int nip nip  d# 1000000 /  
+;
+
+
+fload ${BP}/cpu/arm/mmp2/timer.fth
+fload ${BP}/cpu/arm/mmp2/twsi.fth
+fload ${BP}/cpu/arm/mmp2/mfpr.fth
+fload ${BP}/cpu/arm/mmp2/gpio.fth
+
+: init-stuff
+   acgr-clocks-on
+   init-timers
+   init-twsi
+;
+warning @ warning off
+: stand-init-io
+   stand-init-io
+   init-stuff
+;
+warning !
+
+fload ${BP}/cpu/arm/mmp2/irq.fth
+
+fload ${BP}/cpu/arm/mmp2/watchdog.fth	\ reset-all using watchdog timer
+
+0 0  " d4018000"  " /" begin-package  \ UART3
+   fload ${BP}/cpu/arm/mmp2/uart.fth
+end-package
+devalias com1 /uart
+: com1  " com1"  ;
+' com1 is fallback-device   
+
+0 0  " d4030000"  " /" begin-package  \ UART1
+   fload ${BP}/cpu/arm/mmp2/uart.fth
+end-package
+devalias com2 /uart
+: com2  " com2"  ;
+
+\needs md5init  fload ${BP}/ofw/ppp/md5.fth                \ MD5 hash
+
+fload ${BP}/cpu/arm/olpc/smbus.fth         \ Bit-banged SMBUS (I2C) using GPIOs
+
+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
+
+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}/dev/olpc/confirm.fth             \ Selftest interaction modalities
+fload ${BP}/cpu/arm/olpc/getmfgdata.fth      \ Get manufacturing data
+fload ${BP}/cpu/x86/pc/olpc/mfgdata.fth      \ Manufacturing data
+fload ${BP}/cpu/x86/pc/olpc/mfgtree.fth      \ Manufacturing data in device tree
+
+fload ${BP}/dev/olpc/kb3700/eccmds.fth
+: stand-power-off  ( -- )  ec-power-off  begin wfi again  ;
+' stand-power-off to power-off
+
+: olpc-reset-all  ( -- )
+   " screen" " dcon-off" ['] execute-device-method catch if
+      2drop 2drop
+   then
+   ec-power-cycle
+   begin  wfi  again
+;
+' olpc-reset-all to reset-all
+stand-init:
+   ['] reset-all to bye
+;
+
+fload ${BP}/dev/olpc/kb3700/batstat.fth      \ Battery status reports
+fload ${BP}/cpu/arm/olpc/boardrev.fth        \ Board revision decoding
+
+false constant tethered?                     \ We only support reprogramming our own FLASH
+
+: hdd-led-off     ( -- )  d# 10 gpio-clr  ;
+: hdd-led-on      ( -- )  d# 10 gpio-set  ;
+: hdd-led-toggle  ( -- )  d# 10 gpio-pin@  if  hdd-led-off  else  hdd-led-on  then  ;
+
+fload ${BP}/cpu/arm/olpc/bbedi.fth
+fload ${BP}/cpu/arm/olpc/edi.fth
+
+load-base constant flash-buf
+
+fload ${BP}/cpu/arm/olpc/ecflash.fth
+
+: ec-spi-reprogrammed   ( -- )
+   edi-spi-start
+   set-ec-reboot
+   unreset-8051
+;
+
+: ignore-power-button  ( -- )
+   edi-spi-start
+   ['] reset-8051 catch if
+      ['] reset-8051 catch if ." Write Protected EC" cr then
+   then
+   use-ssp-spi
+   ['] ec-spi-reprogrammed to spi-reprogrammed
+;
+: flash-vulnerable(  ( -- )
+   ols-off
+   ignore-power-button
+   hdd-led-on
+   disable-interrupts
+;
+: )flash-vulnerable  ( -- )
+   enable-interrupts
+   hdd-led-off
+   d# 850 ms  \ allow time for 8051 to finish reset and power us down
+;
+: fs-vulnerable(  ( -- )
+   ols-off
+   hdd-led-on
+;
+: )fs-vulnerable  ( -- )
+   hdd-led-off
+   ols-on
+;
+
+fload ${BP}/dev/olpc/spiflash/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"  ;
+' ofw-fw-filename$ to fw-filename$
+
+0 0  " d420b000"  " /" begin-package
+   " display" name
+\+ olpc-cl2   fload ${BP}/cpu/arm/olpc/1.75/lcdcfg.fth
+\+ olpc-cl3   fload ${BP}/cpu/arm/olpc/3.0/lcdcfg.fth
+
+   fload ${BP}/cpu/arm/olpc/lcd.fth
+\+ olpc-cl2   fload ${BP}/dev/olpc/dcon/mmp2dcon.fth        \ DCON control
+   defer convert-color ' noop to convert-color
+   defer pixel*
+   defer pixel+
+   defer pixel!
+
+   : color!  ( r g b index -- )  4drop  ;
+   : color@  ( index -- r g b )  drop 0 0 0  ;
+
+   fload ${BP}/dev/video/common/rectangle16.fth     \ Rectangular graphics
+
+   depth d# 24 =  [if]
+      code 3a+  ( adr n -- n' )
+         pop  r0,sp
+         inc  tos,#3
+         add  tos,tos,r0
+      c;
+      code rgb888!  ( n adr -- )
+         pop   r0,sp
+         strb  r0,[tos]
+         mov   r0,r0,lsr #8
+         strb  r0,[tos,#1]
+         mov   r0,r0,lsr #8
+         strb  r0,[tos,#2]
+         pop   tos,sp
+      c;
+      ' 3* to pixel*
+      ' 3a+ to pixel+
+      ' rgb888! to pixel!
+      ' noop to convert-color
+   [else]
+      ' /w* to pixel*
+      ' wa+ to pixel+
+      ' w!  to pixel!
+      ' argb>565-pixel to convert-color
+   [then]
+
+   : display-on
+      init-xo-display  \ Turns on DCON etc
+      frame-buffer-adr  hdisp vdisp * >bytes  h# ffffffff lfill
+      init-lcd
+   ;
+   : map-frame-buffer  ( -- )
+      \ We use fb-mem-va directly instead of calling map-in on the physical address
+      \ because the physical address changes with the total memory size.  The early
+      \ assembly language startup code establishes the mapping.
+      fb-mem-va to frame-buffer-adr
+   ;
+   " display"                      device-type
+   " ISO8859-1" encode-string    " character-set" property
+   0 0  encode-bytes  " iso6429-1983-colors"  property
+
+   \ Used as temporary storage for images by $get-image
+   : graphmem  ( -- adr )  dimensions * pixel*  fb-mem-va +  ;
+
+   : display-install  ( -- )
+      map-frame-buffer
+      display-on
+      default-font set-font
+      width  height                           ( width height )
+      over char-width / over char-height /    ( width height rows cols )
+      /scanline depth fb-install              ( )
+   ;
+
+   : display-remove  ( -- )  ;
+   : display-selftest  ( -- failed? )  false  ;
+
+   ' display-install  is-install
+   ' display-remove   is-remove
+   ' display-selftest is-selftest
+end-package
+
+devalias screen /display
+   
+devalias keyboard /keyboard
+
+create 15x30pc  " ${BP}/ofw/termemu/15x30pc.psf" $file,
+' 15x30pc to romfont
+
+fload ${BP}/cpu/arm/olpc/sdhci.fth
+\- cl2-a1 fload ${BP}/cpu/arm/olpc/emmc.fth
+
+devalias int /sd/disk at 3
+devalias ext /sd/disk at 1
+devalias net /wlan  \ XXX should report-net in case of USB Ethernet
+
+fload ${BP}/dev/olpc/kb3700/spicmd.fth
+fload ${BP}/cpu/arm/olpc/spcmd.fth
+
+: wlan-reset  ( -- )  d# 58 gpio-clr  d# 20 ms  d# 58 gpio-set  ;
+
+\ Create the alias unless it already exists
+: $?devalias  ( alias$ value$ -- )
+   2over  not-alias?  if  $devalias exit  then  ( alias$ value$ alias$ )
+   2drop 4drop
+;
+
+: ?report-device  ( alias$ pathname$ -- )
+   2dup  locate-device  0=  if  ( alias$ pathname$ phandle )
+      drop                      ( alias$ pathname$ )
+      2over 2over $?devalias    ( alias$ pathname$ )
+   then                         ( alias$ pathname$ )
+   4drop                        ( )
+;
+
+: report-disk  ( -- )
+   " disk"  " /usb/disk" ?report-device
+;
+
+: report-keyboard  ( -- )
+   \ Prefer direct-attached
+   " usb-keyboard"  " /usb/keyboard" ?report-device  \ USB 2   (keyboard behind a hub)
+;
+
+\ If there is a USB ethernet adapter, use it as the default net device.
+\ We can't use ?report-device here because we already have net aliased
+\ to /wlan, and ?report-device won't override an existing alias.
+: report-net  ( -- )
+   " /usb/ethernet" 2dup locate-device  0=  if  ( name$ phandle )
+      drop                                      ( name$ )
+
+      \ Don't recreate the alias if it is already correct
+      " net" aliased?  if                       ( name$ existing-name$ )
+         2over $=  if                           ( name$ )
+            2drop exit                          ( -- )
+         then                                   ( name$ )
+      then                                      ( name$ )
+
+      " net" 2swap $devalias                    ( )
+   else                                         ( name$ )
+      2drop                                     ( )
+   then
+;
+
+fload ${BP}/cpu/arm/marvell/utmiphy.fth
+
+\+ olpc-cl2 fload ${BP}/cpu/arm/olpc/1.75/usb.fth
+\+ olpc-cl3 fload ${BP}/cpu/arm/olpc/3.0/usb.fth
+
+fload ${BP}/dev/olpc/mmp2camera/loadpkg.fth
+
+fload ${BP}/cpu/arm/firfilter.fth
+
+fload ${BP}/cpu/x86/adpcm.fth            \ ADPCM decoding
+d# 32 is playback-volume
+
+fload ${BP}/cpu/arm/olpc/sound.fth
+fload ${BP}/cpu/arm/olpc/rtc.fth
+stand-init: RTC
+   " /rtc" open-dev  clock-node !
+;
+
+warning @ warning off
+: stand-init
+   stand-init
+   root-device
+      model-name$   2dup model     ( name$ )
+      " OLPC " encode-bytes  2swap encode-string  encode+  " banner-name" property
+      board-revision " board-revision-int" integer-property
+\+ olpc-cl2  " olpc,xo-1.75" " compatible" string-property
+\+ olpc-cl3  " olpc,xo-3.0"  " compatible" string-property
+
+      \ The "1-" removes the null byte
+      " SN" find-tag  if  1-  else  " Unknown"  then  " serial-number" string-property
+
+      ec-api-ver@ " ec-version" integer-property
+
+      ['] ec-name$  catch  0=  if  " ec-name" string-property  then
+      ['] ec-date$  catch  0=  if  " ec-date" string-property  then
+      ['] ec-user$  catch  0=  if  " ec-user" string-property  then
+   dend
+
+   " /openprom" find-device
+      flash-open  pad d# 16  2dup  h# fffc0  flash-read  ( adr len )
+      " model" string-property
+
+      " sourceurl" find-drop-in  if  " source-url" string-property  then
+   dend
+;
+
+warning !
+
+stand-init: More memory
+   extra-mem-va /extra-mem add-memory
+;
+
+fload ${BP}/cpu/arm/mmp2/thermal.fth
+fload ${BP}/cpu/arm/mmp2/fuse.fth
+
+[ifndef] virtual-mode
+warning off
+: stand-init-io
+   stand-init-io
+   go-fast         \ From mmuon.fth
+;
+warning on
+[then]
+
+fload ${BP}/cpu/arm/linux.fth
+
+\ The bottom of extra-mem is the top of DMA memory.
+\ We give everything up to that address to Linux.
+: olpc-memory-limit  ( -- adr )  extra-mem-va >physical  ;
+' olpc-memory-limit to memory-limit
+
+: usb-quiet  ( -- )
+   [ ' linux-hook behavior compile, ]    \ Chain to old behavior
+   unload-crypto
+   " /usb" " reset-usb" execute-device-method drop
+;
+
+d# 9999 to arm-linux-machine-type  \ Marvell Jasper
+
+\ Add a tag describing the linear frame buffer
+: mmp-fb-tag,  ( -- )
+   8 tag-l,
+   h# 54410008 tag-l, \ ATAG_VIDEOLFB
+   d# 1200 tag-w,     \ Width
+   d#  900 tag-w,     \ Height
+   d#   24 tag-w,     \ Depth
+   d# 1200 3 * tag-w, \ Pitch
+   fb-mem-va tag-l,   \ Base address
+   d# 1200 3 *  d# 900 *  tag-l,  \ Total size - perhaps could be larger
+   5     tag-b,       \ Red size
+   d# 11 tag-b,       \ Red position
+   6     tag-b,       \ Green size
+   d#  5 tag-b,       \ Green position
+   5     tag-b,       \ Blue size
+   d#  0 tag-b,       \ Blue position
+   0     tag-b,       \ Rsvd size
+   d# 16 tag-b,       \ Rsvd position
+;
+' mmp-fb-tag, to fb-tag,
+
+\ Add a tag describing the OFW callback
+3 constant MT_DEVICE_WC
+9 constant MT_MEMORY
+: (ofw-tag,)  ( -- )
+   4 2 * 3 +    tag-l,    \ size
+   h# 41000502  tag-l,    \ ATAG_MEM
+   cif-handler  tag-l,    \ Client interface handler callback address
+
+   \ Each of these groups is a struct map_desc as defined in arch/arm/include/asm/mach/
+   extra-mem-va dup                        tag-l,  \ VA of OFW memory
+   >physical pageshift rshift              tag-l,  \ Page frame number of OFW memory
+   fw-mem-va /fw-mem +  extra-mem-va -     tag-l,  \ Size of OFW memory
+   MT_MEMORY                               tag-l,  \ Mapping type of OFW memory
+
+   fb-mem-va dup                           tag-l,  \ VA of OFW Frame Buffer
+   >physical pageshift rshift              tag-l,  \ PA of OFW Frame Buffer
+   /fb-mem                                 tag-l,  \ Size of OFW memory
+   MT_DEVICE_WC                            tag-l,  \ Mapping type of OFW frame buffer
+;
+' (ofw-tag,) to ofw-tag,
+
+false to stand-init-debug?
+\ true to stand-init-debug?
+
+: sec-trg   ( -- )      d# 73 gpio-set  ;  \ rising edge latches SPI_WP# low
+: sec-trg?  ( -- bit )  d# 73 gpio-pin@  ;
+
+alias ec-indexed-io-off sec-trg
+alias ec-indexed-io-off? sec-trg?
+alias ec-ixio-reboot ec-power-cycle  \ clears latch, brings SPI_WP# high
+
+false value secure?
+
+: protect-fw  ( -- )  secure?  if  flash-protect sec-trg  then  ;
+
+hex
+: i-key-wait  ( ms -- pressed? )
+   cr ." Type 'i' to interrupt stand-init sequence" cr   ( ms )
+   0  do
+      ukey?  if
+         ukey upc ascii I  =  if  true unloop exit  then
+      then
+      d# 1000 us  \ 1000 us is more precise than 1 ms, which is often close to 2 ms
+   loop
+   false
+;
+
+: rotate-button?  ( -- flag )  d# 15 gpio-pin@ 0=  ;
+warning @  warning off 
+: init
+\ initial-heap add-memory
+   init
+
+   standalone?  if
+      disable-interrupts
+\     d# 1000  i-key-wait  if
+      rotate-button? if
+         protect-fw
+         \ Make the frame buffer visible so CForth won't complain about OFW not starting
+         h# 8009.1100 h# 20.b190 io!
+         ." Interacting" cr  hex interact
+      then
+      \ Turn on USB power here to overlap the time with other startup actions
+      usb-power-on
+   then
+;
+warning !
+
+: (.firmware)  ( -- )
+   ." Open Firmware  "  .built  cr
+   ." Copyright 2010 FirmWorks  All Rights Reserved" cr
+;
+' (.firmware) to .firmware
+
+\ Uninstall the diag menu from the general user interface vector
+\ so exiting from emacs doesn't invoke the diag menu.
+' quit to user-interface
+fload ${BP}/cpu/x86/pc/olpc/via/mfgtest.fth
+\+ olpc-cl3 fload ${BP}/cpu/arm/olpc/3.0/testitems.fth
+\+ olpc-cl2 fload ${BP}/cpu/arm/olpc/1.75/testitems.fth
+
+[ifdef] notyet
+fload ${BP}/cpu/x86/pc/olpc/via/bootmenu.fth
+[then]
+
+: screen-#lines  ( -- n )
+   screen-ih 0=  if  default-#lines exit  then
+   screen-ih  package( #lines )package
+;
+' screen-#lines to lines/page
+
+true value text-on?
+: text-off  ( -- )
+   text-on?  if
+      screen-ih remove-output
+      false to text-on?
+   then
+;
+: text-on   ( -- )
+   text-on? 0=  if
+      screen-ih add-output
+      cursor-on
+      true to text-on?
+   then
+;
+
+fload ${BP}/cpu/x86/pc/olpc/via/banner.fth
+
+devalias keyboard /ap-sp/keyboard
+devalias mouse    /ap-sp/mouse
+
+: console-start  ( -- )
+   install-mux-io
+   cursor-off
+   true to text-on?
+
+   " //null" open-dev to null-ih  \ For text-off state
+;
+: keyboard-off  ( -- )
+   keyboard-ih  if
+      keyboard-ih remove-input
+      keyboard-ih close-dev
+      0 to keyboard-ih
+   then
+;
+
+: teardown-mux-io  ( -- )
+   install-uart-io
+   text-off
+   keyboard-off
+   fallback-out-ih remove-output
+   fallback-in-ih remove-input
+   stdin off
+   stdout off
+   in-mux-ih close-dev
+   out-mux-ih close-dev
+;
+: quiesce  ( -- )
+   teardown-mux-io
+   timers-off
+   usb-quiet
+   close-ec
+   \ Change the sleep state of EC_SPI_ACK from 1 (OFW value) to 0 (Linux value)
+   d# 125 af@  h# 100 invert and  d# 125 af!
+;
+
+\ This must precede the loading of gui.fth, which chains from linux-hook's behavior
+' quiesce to linux-hook
+
+\ This must be defined after spiui.fth, otherwise spiui will choose some wrong code
+: rom-pa  ( -- adr )  mfg-data-buf mfg-data-offset -  ;  \ Fake out setwp.fth
+fload ${BP}/cpu/x86/pc/olpc/setwp.fth
+
+fload ${BP}/cpu/arm/olpc/help.fth
+fload ${BP}/cpu/x86/pc/olpc/gui.fth
+fload ${BP}/cpu/x86/pc/olpc/strokes.fth
+fload ${BP}/cpu/x86/pc/olpc/plot.fth
+\+ olpc-cl3 fload ${BP}/cpu/arm/olpc/3.0/testinstructions.fth
+\+ olpc-cl2 fload ${BP}/cpu/arm/olpc/1.75/testinstructions.fth
+
+fload ${BP}/cpu/arm/mmp2/dramrecal.fth
+
+code halt  ( -- )  wfi   c;
+
+\+ olpc-cl3 fload ${BP}/cpu/arm/olpc/3.0/switches.fth  \ Switches
+\+ olpc-cl2 fload ${BP}/cpu/arm/olpc/1.75/switches.fth \ Lid and ebook switches
+fload ${BP}/cpu/arm/mmp2/rtc.fth       \ Internal RTC, used for wakeups
+\+ olpc-cl3 fload ${BP}/cpu/arm/olpc/3.0/leds.fth     \ LEDs
+\+ olpc-cl2 fload ${BP}/cpu/arm/olpc/3.0/leds.fth     \ LEDs
+fload ${BP}/cpu/x86/pc/olpc/via/factory.fth  \ Manufacturing tools
+
+fload ${BP}/cpu/arm/olpc/accelerometer.fth
+\+ olpc-cl2 fload ${BP}/cpu/arm/olpc/1.75/compass.fth
+
+\ Suppress long memory test at final test stage
+dev /memory
+0 value old-diag-switch?
+: not-final-test?  ( -- flag )
+   final-test?   if  false exit  then
+   smt-test?  if  false exit  then
+   old-diag-switch?
+;
+warning @ warning off
+: selftest  ( -- error? )
+   diag-switch? to old-diag-switch?
+   not-final-test?  to diag-switch?
+   selftest
+   old-diag-switch? to diag-switch?
+;
+warning !
+device-end
+
+\ When reprogramming this machine's SPI FLASH, rebooting the EC is unnecessary 
+: no-kbc-reboot  ['] noop to spi-reprogrammed  ;
+: kbc-on ;
+
+\ Pseudo device that appears in the boot order before net booting
+0 0 " " " /" begin-package
+   " prober" device-name
+   : open
+      visible
+      false
+   ;
+   : close ;
+end-package
+
+\ it seems to be difficult to get SoC wakeups from the keypad controller,
+\ so we set them up as gpio, instead.
+[ifdef] use_mmp2_keypad_control
+fload ${BP}/cpu/arm/mmp2/keypad.fth
+[ifdef] notdef  \ CForth turns on the keypad; resetting it makes it not work
+stand-init: keypad
+   keypad-on
+   8 keypad-direct-mode
+;
+[then]
+: keypad-bit  ( n keypad out-mask key-mask -- n' keypad )
+   third invert  and  if    ( n keypad out-mask )
+      rot or swap           ( n' keypad )
+   else                     ( n keypad out-mask )
+      drop                  ( n keypad )
+   then                     ( n' keypad )
+;
+[then]
+
+fload ${BP}/cpu/x86/pc/olpc/gamekeynames.fth
+
+: game-key@  ( -- n )
+   0                                        ( n )
+[ifdef] cl2-a1
+   d# 16 gpio-pin@ 0=  if  h#  80 or  then  \ O
+   d# 17 gpio-pin@ 0=  if  h#  02 or  then  \ Check
+   d# 18 gpio-pin@ 0=  if  h# 100 or  then  \ X
+   d# 19 gpio-pin@ 0=  if  h#  01 or  then  \ Square
+   d# 20 gpio-pin@ 0=  if  h#  40 or  then  \ Rotate
+[else]
+[ifdef] use_mmp2_keypad_control
+   d# 15 gpio-pin@ 0=  if  button-rotate or  then   ( n )
+   scan-keypad                              ( n keypad )
+   button-o       h# 01  keypad-bit         ( n' keypad )
+   button-check   h# 02  keypad-bit         ( n' keypad )
+   button-x       h# 04  keypad-bit         ( n' keypad )
+   button-square  h# 08  keypad-bit         ( n' keypad )
+   rocker-up      h# 10  keypad-bit         ( n' keypad )
+   rocker-right   h# 20  keypad-bit         ( n' keypad )
+   rocker-down    h# 40  keypad-bit         ( n' keypad )
+   rocker-left    h# 80  keypad-bit         ( n' keypad )
+   drop                                     ( n )
+[else]
+   d# 15 gpio-pin@ 0=  if  button-rotate  or  then
+   d# 16 gpio-pin@ 0=  if  button-o       or  then
+   d# 17 gpio-pin@ 0=  if  button-check   or  then
+   d# 18 gpio-pin@ 0=  if  button-x       or  then
+   d# 19 gpio-pin@ 0=  if  button-square  or  then
+   d# 20 gpio-pin@ 0=  if  rocker-up      or  then
+   d# 21 gpio-pin@ 0=  if  rocker-right   or  then
+   d# 22 gpio-pin@ 0=  if  rocker-down    or  then
+   d# 23 gpio-pin@ 0=  if  rocker-left    or  then
+[then]
+[then]
+;
+
+fload ${BP}/cpu/x86/pc/olpc/gamekeys.fth
+
+fload ${BP}/dev/logdev.fth
+fload ${BP}/cpu/x86/pc/olpc/disptest.fth
+dev /ap-sp/keyboard
+fload ${BP}/dev/olpc/keyboard/selftest.fth   \ Keyboard diagnostic
+device-end
+stand-init: Keyboard
+   " /ap-sp/keyboard" " set-keyboard-type" execute-device-method drop
+;
+dev /ap-sp/mouse
+fload ${BP}/dev/olpc/touchpad/syntpad.fth    \ Touchpad diagnostic
+device-end
+fload ${BP}/cpu/x86/pc/olpc/gridmap.fth      \ Gridded display tools
+fload ${BP}/cpu/x86/pc/olpc/via/copynand.fth
+\ fload ${BP}/cpu/arm/olpc/exc7200-touchscreen.fth    \ Touchscreen driver and diagnostic
+fload ${BP}/cpu/arm/olpc/rm3150-touchscreen.fth    \ Touchscreen driver and diagnostic
+fload ${BP}/cpu/arm/olpc/roller.fth     \ Accelerometer test
+
+\ fload ${BP}/cpu/arm/olpc/pinch.fth  \ Touchscreen gestures
+\ : pinch  " pinch" screen-ih $call-method  ;
+
+: emacs  ( -- )
+   false to already-go?
+   boot-getline to boot-file   " rom:emacs" $boot
+;
+defer rm-go-hook  \ Not used, but makes security happy
+: tsc@  ( -- d.ticks )  timer0@ u>d  ;
+d# 6500 constant ms-factor
+
+\ idt1338 rtc and ram address map
+\     00 -> 0f  rtc
+\     10 -> 3f  cmos
+
+: >rtc  ( index -- rtc-address )  h# 3f and  h# 10 +  ;
+
+: cmos@  ( index -- data )
+   >rtc " rtc@" clock-node @  ( index adr len ih )
+   ['] $call-method catch  if  4drop 0  then
+;
+: cmos!  ( data index -- )
+   >rtc " rtc!" clock-node @  ( data index adr len ih )
+   ['] $call-method catch  if  2drop 3drop  then
+;
+
+\ cmos address map
+\     80 audio volume
+\     81 audio volume
+\     82 alternate boot
+\     83 xid
+
+: dimmer  ( -- )  screen-ih  if  " dimmer" screen-ih $call-method  then  ;
+: brighter  ( -- )  screen-ih  if  " brighter" screen-ih $call-method  then  ;
+
+fload ${BP}/cpu/x86/pc/olpc/sound.fth
+fload ${BP}/cpu/x86/pc/olpc/guardrtc.fth
+fload ${BP}/cpu/x86/pc/olpc/security.fth
+2 to bundle-suffix
+
+stand-init: xid
+   h# 83 cmos@  dup 1+  h# 83 cmos!   ( n )
+   d# 24 lshift               ( new-xid )
+   " dev /obp-tftp  to rpc-xid  dend" evaluate
+;
+
+: pre-setup-for-linux  ( -- )
+   [ ' linux-pre-hook behavior compile, ]    \ Chain to old behavior
+   sound-end
+;
+' pre-setup-for-linux to linux-pre-hook
+
+: show-temperature  ( -- )  space cpu-temperature .d  ;
+fload ${BP}/cpu/arm/bootascall.fth
+create use-thinmac
+fload ${BP}/cpu/x86/pc/olpc/wifichannel.fth
+fload ${BP}/cpu/x86/pc/olpc/via/nbtx.fth
+fload ${BP}/cpu/x86/pc/olpc/via/nbrx.fth
+fload ${BP}/cpu/x86/pc/olpc/via/blockfifo.fth
+
+alias fast-hash crypto-hash   \ fast-hash uses acceleration when available
+fload ${BP}/cpu/x86/pc/olpc/via/fsupdate.fth
+fload ${BP}/cpu/x86/pc/olpc/via/fsverify.fth
+devalias fsdisk int:0
+
+\ create pong-use-touchscreen
+fload ${BP}/ofw/gui/ofpong.fth
+fload ${BP}/cpu/x86/pc/olpc/life.fth
+
+" u:\boot\olpc.fth ext:\boot\olpc.fth int:\boot\olpc.fth ext:\zimage /prober /usb/ethernet /usb/wlan"
+   ' boot-device  set-config-string-default
+
+\needs ramdisk  " " d# 128 config-string ramdisk
+" "   ' boot-file      set-config-string-default   \ Let the boot script set the cmdline
+
+2 config-int auto-boot-countdown
+
+\ Eliminate 4 second delay in install console for the case where
+\ there is no keyboard.  The delay is unnecessary because the screen
+\ does not go blank when the device is closed.
+patch drop ms install-console
+
+alias reboot bye
+
+alias crcgen drop  ( crc byte -- crc' )
+
+\ Dictionary growth size for the ARM Image Format header
+\ 1 section   before origin  section table
+h# 10.0000      h# 8000 -      h# 4000 -      dictionary-size !
+
+fload ${BP}/cpu/arm/saverom.fth  \ Save the dictionary for standalone startup
+
+fload ${BP}/ofw/core/countdwn.fth	\ Startup countdown
+
+fload ${BP}/dev/hdaudio/noiseburst.fth  \ audio-test support package
+
+\ Because visible doesn't work sometimes when calling back from Linux
+dev /client-services  patch noop visible enter  dend
+
+: interpreter-init  ( -- )
+   hex
+   warning on
+   only forth also definitions
+
+   install-alarm
+
+   page-mode
+   #line off
+
+\   .built cr
+;
+
+
+: factory-test?  ( -- flag )
+   \ TS is the "test station" tag, whose value is set to "SHIP" at the
+   \ end of manufacturing test.
+   " TS" find-tag  if         ( adr len )
+      ?-null  " SHIP" $=  0=  ( in-factory? )
+   else                       ( )
+      \ Missing TS tag is treated as not in factory test
+      false
+   then                       ( in-factory? )
+;
+
+: ?sound  ( -- )
+   \ Suppress the jingle if a game key is pressed, because we don't want
+   \ the jingle to interfere with diags and stuff
+   -1 game-key?  if  exit  then
+   ['] sound catch drop
+;
+
+: ?games  ( -- )
+   rocker-right game-key?  if
+      protect-fw
+      time&date 5drop 1 and  if
+         ['] pong guarded
+      else
+         ['] life-demo guarded
+      then
+      power-off
+   then
+;
+: ?diags  ( -- )
+   rocker-left game-key?  if
+      protect-fw
+      text-on  ['] gamekey-auto-menu guarded
+      ." Tests complete - powering off" cr  d# 5000 ms  power-off
+   then
+;
+
+: ?fs-update  ( -- )
+   button-check button-x or  button-o or  button-square or   ( mask )
+   game-key-mask =  if  protect-fw try-fs-update  then
+;
+
+fload ${BP}/cpu/arm/mmp2/clocks.fth
+
+: startup  ( -- )
+   standalone?  0=  if  exit  then
+
+   block-exceptions
+   no-page
+
+   ?factory-mode
+
+   disable-user-aborts
+   console-start
+
+   read-game-keys
+
+   factory-test? 0=  if  text-off  then
+
+   " probe-" do-drop-in
+
+   show-child
+
+   update-ec-flash?  if
+      ['] ?enough-power catch  ?dup  if  ( error )
+	 show-no-power
+	 .error
+	 ." Skipping EC reflash, not enough power" cr
+	 d# 1000 ms
+      else
+	 show-reflash
+	 ['] show-reflash-dot to edi-progress
+	 update-ec-flash
+      then
+   then
+
+   install-alarm
+   ?sound
+
+   ?games
+
+   ['] false to interrupt-auto-boot?
+[ifdef] probe-usb
+   factory-test?  if  d# 1000 ms  then  \ Extra USB probe delay in the factory
+   probe-usb
+   report-disk
+   report-keyboard
+[then]
+   " probe+" do-drop-in
+
+   interpreter-init
+
+   ?diags
+   ?fs-update
+
+   factory-test? 0=  if  secure-startup  then
+   unblock-exceptions
+   ['] (interrupt-auto-boot?) to interrupt-auto-boot?
+
+   ?usb-keyboard
+
+   auto-banner?  if  banner  then
+
+   auto-boot
+
+   frozen? text-on? 0=  and  ( no-banner? )
+   unfreeze visible cursor-on ( no-banner? )
+   if  banner  then  \ Reissue banner if it was suppressed
+
+   blue-letters ." Type 'help' for more information." black-letters cancel
+   cr cr
+
+   enable-user-aborts
+   stop-sound   
+   quit
+;
+
+: newrom
+   " flash! http:\\192.168.200.200\new.rom" eval
+;
+: newec
+   " flash-ec http:\\192.168.200.200\ecimage.bin" eval
+;
+: qz
+   " qz" $essid  " http:\\qz\" included  \ qa test bed scripting, james cameron
+;
+: urom  " flash! u:\new.rom" eval  ;
+: uec   " flash-ec! u:\ecimage.bin" eval  ;
+: erom  " flash! ext:\new.rom" eval  ;
+: no-usb-delay  " dev /usb  false to delay?  dend"  evaluate  ;
+: null-fsdisk
+   " dev /null : write-blocks-start 3drop ; : write-blocks-finish ; dend" evaluate
+   " devalias fsdisk //null" evaluate
+;
+
+tag-file @ fclose  tag-file off
+
+.( --- Saving fw.dic ...)
+" fw.dic" $save-forth cr
+
+fload ${BP}/cpu/arm/mmp2/rawboot.fth
+
+.( --- Saving fw.img --- )  cr " fw.img" $save-rom
+
+\ 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

Copied and modified: cpu/arm/olpc/build-mcnand.fth (from r2725, cpu/arm/olpc/1.75/mcastnand.bth)
==============================================================================
--- cpu/arm/olpc/1.75/mcastnand.bth	Fri Dec  2 23:14:43 2011	(r2725, copy source)
+++ cpu/arm/olpc/build-mcnand.fth	Sat Dec  3 01:44:58 2011	(r2726)
@@ -1,9 +1,6 @@
-purpose: Fetch and compile the multicast NAND reflash program
+purpose: Common code for fetching and building the NANDblaster support code
 
-command: &builder &this
-build-now
-
-fload ${BP}/cpu/arm/olpc/1.75/mcnand-version.fth
+\ The macro MCNAND_VERSION must be set externally
 
 " ${MCNAND_VERSION}" expand$ " test" $=  [if]
    " multicast-nand/Makefile" $file-exists?  0=  [if]

Copied and modified: cpu/arm/olpc/build-wlan.fth (from r2725, cpu/arm/olpc/1.75/sd8686.bth)
==============================================================================
--- cpu/arm/olpc/1.75/sd8686.bth	Fri Dec  2 23:14:43 2011	(r2725, copy source)
+++ cpu/arm/olpc/build-wlan.fth	Sat Dec  3 01:44:58 2011	(r2726)
@@ -1,13 +1,10 @@
-purpose: Fetch the firmware for the Marvell 8686 wireless LAN module
+purpose: Common code for fetching and building the WLAN microcode
 
-command: &builder &this
-build-now
+\ The macro WLAN_VERSION, and optionally GET_WLAN, must be defined externally
 
 \needs to-file       fload ${BP}/forth/lib/tofile.fth
 \needs $md5sum-file  fload ${BP}/forth/lib/md5file.fth
 
-fload ${BP}/cpu/arm/olpc/1.75/wlan-version.fth
-
 " macro: WLAN_FILE lbtf_sdio-${WLAN_VERSION}" expand$ eval
 
 " ${GET_WLAN}" expand$  nip  [if]

Copied and modified: cpu/arm/olpc/ecflash.fth (from r2725, cpu/arm/olpc/1.75/ecflash.fth)
==============================================================================
--- cpu/arm/olpc/1.75/ecflash.fth	Fri Dec  2 23:14:43 2011	(r2725, copy source)
+++ cpu/arm/olpc/ecflash.fth	Sat Dec  3 01:44:58 2011	(r2726)
@@ -7,7 +7,8 @@
 char 3 value expected-ec-version
 [else]
 h# 8000 value /ec-flash
-char 4 value expected-ec-version
+\+ olpc-cl2 char 4 value expected-ec-version
+\+ olpc-cl3 char 5 value expected-ec-version
 [then]
 
 : check-signature  ( adr -- )

Copied and modified: cpu/arm/olpc/edi.fth (from r2725, cpu/arm/olpc/1.75/edi.fth)
==============================================================================

Copied and modified: cpu/arm/olpc/emmc.fth (from r2725, cpu/arm/olpc/1.75/emmc.fth)
==============================================================================

Copied and modified: cpu/arm/olpc/exc7200-touchscreen.fth (from r2725, cpu/arm/olpc/1.75/exc7200-touchscreen.fth)
==============================================================================

Copied and modified: cpu/arm/olpc/fetch-ec.fth (from r2725, cpu/arm/olpc/1.75/ec.bth)
==============================================================================
--- cpu/arm/olpc/1.75/ec.bth	Fri Dec  2 23:14:43 2011	(r2725, copy source)
+++ cpu/arm/olpc/fetch-ec.fth	Sat Dec  3 01:44:58 2011	(r2726)
@@ -1,15 +1,12 @@
-purpose: Fetch the EC (Embedded Controller, i.e. KB3700) microcode
+purpose: Common code for fetching the EC microcode
 
-command: &builder &this
-build-now
-
-fload ${BP}/cpu/arm/olpc/1.75/ec-version.fth
+\ The macros EC_PLATFORM, EC_VERSION, and optionally GET_EC, must be defined externally
 
 \ If there is a GET_EC macro, use it instead of fetching the released version.
 " ${GET_EC}" expand$  nip  [if]
    " ${GET_EC}" expand$ $sh
 [else]
-   " wget -q http://dev.laptop.org/pub/ec/cl2-${EC_VERSION}.img -O ec.img" expand$ $sh
+   " wget -q http://dev.laptop.org/pub/ec/${EC_PLATFORM}-${EC_VERSION}.img -O ec.img" expand$ $sh
 [then]
 
 \ This forces the creation of an ec.log file, so we don't re-fetch ec.img

Copied and modified: cpu/arm/olpc/getmfgdata.fth (from r2725, cpu/arm/olpc/1.75/getmfgdata.fth)
==============================================================================

Copied and modified: cpu/arm/olpc/help.fth (from r2725, cpu/arm/olpc/1.75/help.fth)
==============================================================================

Copied and modified: cpu/arm/olpc/lcd.fth (from r2725, cpu/arm/olpc/1.75/lcd.fth)
==============================================================================

Copied and modified: cpu/arm/olpc/pinch.fth (from r2725, cpu/arm/olpc/1.75/pinch.fth)
==============================================================================

Copied and modified: cpu/arm/olpc/prefw.fth (from r2725, cpu/arm/olpc/1.75/prefw.bth)
==============================================================================
--- cpu/arm/olpc/1.75/prefw.bth	Fri Dec  2 23:14:43 2011	(r2725, copy source)
+++ cpu/arm/olpc/prefw.fth	Sat Dec  3 01:44:58 2011	(r2726)
@@ -1,18 +1,9 @@
-purpose: Build OFW Forth dictionary for OLPC XO-1.75
-\ See license at end of file
-
-dictionary: ${BP}/cpu/arm/build/basefw.dic
-command: &armforth &dictionary &this
-build-now
-
-" prefw.tag" r/w create-file drop  tag-file !
+purpose: Common code for building the "prefw.dic" intermediate dictionary
 
 hex
 \ ' $report-name is include-hook
 ' noop is include-hook
 
-fload ${BP}/cpu/arm/olpc/1.75/config.fth
-
 : headerless ;  : headers  ;  : headerless0 ;
 
 ' (quit) to quit
@@ -67,7 +58,7 @@
 [ifndef] virtual-mode
 fload ${BP}/cpu/arm/mmp2/mmuon.fth
 [then]
-fload ${BP}/cpu/arm/olpc/1.75/probemem.fth	\ Memory probing
+fload ${BP}/cpu/arm/olpc/probemem.fth	\ Memory probing
 
 stand-init: Probing memory
    " probe" memory-node @ $call-method
@@ -183,10 +174,6 @@
 : op  " select smb:\\test:testxxx at 10.20.0.14\XTest\hello.txt" eval ;
 : dsmb  " dir smb:\\test:testxxx at 10.20.0.14\XTest\" eval ;
 
-[ifdef] notyet
-fload ${BP}/cpu/arm/olpc/1.75/memtest.fth
-[then]
-
 fload ${BP}/ofw/wifi/wifi-cfg.fth
 support-package: supplicant
 fload ${BP}/ofw/wifi/loadpkg.fth

Copied and modified: cpu/arm/olpc/probemem.fth (from r2725, cpu/arm/olpc/1.75/probemem.fth)
==============================================================================

Copied and modified: cpu/arm/olpc/rm3150-touchscreen.fth (from r2725, cpu/arm/olpc/1.75/rm3150-touchscreen.fth)
==============================================================================

Copied and modified: cpu/arm/olpc/roller.fth (from r2725, cpu/arm/olpc/1.75/roller.fth)
==============================================================================

Copied and modified: cpu/arm/olpc/rtc.fth (from r2725, cpu/arm/olpc/1.75/rtc.fth)
==============================================================================

Copied and modified: cpu/arm/olpc/sdhci.fth (from r2725, cpu/arm/olpc/1.75/sdhci.fth)
==============================================================================
--- cpu/arm/olpc/1.75/sdhci.fth	Fri Dec  2 23:14:43 2011	(r2725, copy source)
+++ cpu/arm/olpc/sdhci.fth	Sat Dec  3 01:44:58 2011	(r2726)
@@ -2,7 +2,7 @@
 
 0 0  " d4280000"  " /"  begin-package
 
-   fload ${BP}/cpu/arm/olpc/1.75/sdregs.fth
+   fload ${BP}/cpu/arm/olpc/sdregs.fth
    fload ${BP}/dev/mmc/sdhci/sdhci.fth
 
    d# 1 to power-off-time  \ A2 and A3 have turn-off clamps
@@ -21,12 +21,12 @@
    : gpio-power-off  ( -- )  d# 36 slot - gpio-clr  sdhci-card-power-off  ;
    ' gpio-power-off to card-power-off
 
-   new-device
-      1 encode-int " reg" property
-      fload ${BP}/dev/mmc/sdhci/sdmmc.fth
-      fload ${BP}/dev/mmc/sdhci/selftest.fth
-      " external" " slot-name" string-property
-   finish-device
+\+ olpc-cl2   new-device
+\+ olpc-cl2      1 encode-int " reg" property
+\+ olpc-cl2      fload ${BP}/dev/mmc/sdhci/sdmmc.fth
+\+ olpc-cl2      fload ${BP}/dev/mmc/sdhci/selftest.fth
+\+ olpc-cl2      " external" " slot-name" string-property
+\+ olpc-cl2   finish-device
 
    new-device
       2 encode-int " reg" property

Copied and modified: cpu/arm/olpc/sdregs.fth (from r2725, cpu/arm/olpc/1.75/sdregs.fth)
==============================================================================

Copied and modified: cpu/arm/olpc/smbus.fth (from r2725, cpu/arm/olpc/1.75/smbus.fth)
==============================================================================

Copied and modified: cpu/arm/olpc/sound.fth (from r2725, cpu/arm/olpc/1.75/sound.fth)
==============================================================================
--- cpu/arm/olpc/1.75/sound.fth	Fri Dec  2 23:14:43 2011	(r2725, copy source)
+++ cpu/arm/olpc/sound.fth	Sat Dec  3 01:44:58 2011	(r2726)
@@ -241,7 +241,7 @@
 ;
 
 [ifdef] cl2-a1
-fload ${BP}/cpu/arm/olpc/1.75/alc5624.fth  \ Realtek ALC5624 CODEC
+fload ${BP}/cpu/arm/olpc/alc5624.fth  \ Realtek ALC5624 CODEC
 [else]
 d# 97 constant headphone-jack
 d# 96 constant external-mic
@@ -249,7 +249,7 @@
 : headphones-inserted?  ( -- flag )  headphone-jack pin-sense?  ;
 : microphone-inserted?  ( -- flag )  external-mic pin-sense?  ;
 
-fload ${BP}/cpu/arm/olpc/1.75/alc5631.fth  \ Realtek ALC5631Q CODEC
+fload ${BP}/cpu/arm/olpc/alc5631.fth  \ Realtek ALC5631Q CODEC
 [then]
    
 d# 48000 value sample-rate
@@ -583,7 +583,7 @@
 fload ${BP}/forth/lib/tones.fth
 fload ${BP}/dev/geode/ac97/selftest.fth
 
-false value force-internal-mic?  \ Can't be implemented on XO-1.75
+false value force-internal-mic?  \ Can't be implemented on OLPC boards
 2 value #channels
 
 : input-test-settings  ( -- )  ;

Copied and modified: cpu/arm/olpc/sourceurl.fth (from r2725, cpu/arm/olpc/1.75/sourceurl.fth)
==============================================================================

Copied and modified: cpu/arm/olpc/testicons.bth (from r2725, cpu/arm/olpc/1.75/testicons.bth)
==============================================================================

Copied and modified: cpu/arm/olpc/viaedi.fth (from r2725, cpu/arm/olpc/1.75/viaedi.fth)
==============================================================================

Modified: dev/olpc/dcon/mmp2dcon.fth
==============================================================================
--- dev/olpc/dcon/mmp2dcon.fth	Fri Dec  2 23:14:43 2011	(r2725)
+++ dev/olpc/dcon/mmp2dcon.fth	Sat Dec  3 01:44:58 2011	(r2726)
@@ -222,8 +222,8 @@
 : init-xo-display  ( -- )
    smb-init
 
-   dcon-load
-   dcon-enable  ( maybe-set-cmos )
+\ Unnecessary because CForth has already done it
+\   dcon-load  dcon-enable  ( maybe-set-cmos )
    \ dcon-enable leaves mode set to 69 - 40:antialias, 20:swizzle, 8:backlight on, 1:passthru off
 ;
 : dcon-power-on   ( -- )  1 h# 26 ec-cmd-b!  ;



More information about the openfirmware mailing list