Author: wmb Date: Fri Nov 5 19:56:34 2010 New Revision: 2015 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2015
Log: Q4A04 - Manufacturing data support, switch to 16bpp mode, added back a lot of features that were omitted for early testing.
Added: cpu/arm/olpc/1.75/getmfgdata.fth cpu/x86/pc/olpc/getmfgdata.fth Modified: cpu/arm/fb8-ops.fth cpu/arm/olpc/1.75/addrs.fth cpu/arm/olpc/1.75/devices.fth cpu/arm/olpc/1.75/fw-version.fth cpu/arm/olpc/1.75/fw.bth cpu/arm/olpc/1.75/lcd.fth cpu/arm/olpc/1.75/lcdcfg.fth cpu/arm/olpc/1.75/olpc.bth cpu/arm/olpc/1.75/prefw.bth cpu/arm/olpc/1.75/spiui.fth cpu/x86/pc/olpc/addrs.fth cpu/x86/pc/olpc/devices.fth cpu/x86/pc/olpc/gridmap.fth cpu/x86/pc/olpc/life.fth cpu/x86/pc/olpc/mfgdata.fth cpu/x86/pc/olpc/setwp.fth cpu/x86/pc/olpc/via/addrs.fth cpu/x86/pc/olpc/via/devices.fth cpu/x86/pc/olpc/via/recover.fth dev/olpc/spiflash/recover.fth dev/olpc/spiflash/spiflash.fth dev/olpc/spiflash/spiui.fth dev/video/common/rectangle16.fth ofw/gui/ofpong.fth
Modified: cpu/arm/fb8-ops.fth ============================================================================== --- cpu/arm/fb8-ops.fth Fri Nov 5 19:51:45 2010 (r2014) +++ cpu/arm/fb8-ops.fth Fri Nov 5 19:56:34 2010 (r2015) @@ -43,12 +43,13 @@ ldmia sp!,{r1,r2,r3,r4,r5,tos} \ r0:bg-colour r1:fg-colour r2:bytes/line r3:height r4:width r5:adr
+ add r4,r4,r4 \ Byte count instead of pixel count begin cmp r3,#0 > while mov r6,#0 begin - cmp r4,r6 \ more pixels/line? + cmp r4,r6 \ more bytes/line? > while ldrh r7,[r5,r6] \ get pixel colour at adr+offset cmp r7,r0 @@ -70,13 +71,13 @@ \ r0:scratch r1:fg-colour r2:bytes/line r3:height r4:width r5:adr \ r6 bytes/line, r7 scratch, r8 scratch, tos bg-color
- add r4,r4,r4, lsl #1 \ Multiply width by 4 to get bytes + add r4,r4,r4, lsl #1 \ Multiply width by 3 to get bytes begin cmp r3,#0 > while mov r6,#0 begin - cmp r4,r6 \ more pixels/line? + cmp r4,r6 \ more bytes on this line? > while add r0,r5,r6 \ r0 points to the pixel ldrb r7,[r0] \ Start reading a 3-byte pixel @@ -125,14 +126,14 @@ > while mov r6,#0 begin - cmp r4,r6 \ more pixels/line? + cmp r4,r6 \ more bytes on this line? > while - ldr r7,[r5,r6] \ get pixel colour at adr+offset + ldr r7,[r5,r6,lsl #2] \ get pixel colour at adr+offset cmp r7,r0 - streq r1,[r5,r6] + streq r1,[r5,r6,lsl #2] cmp r7,r1 - streq r0,[r5,r6] - inc r6,#4 + streq r0,[r5,r6,lsl #2] + inc r6,#1 repeat add r5,r5,r2 dec r3,#1 @@ -197,9 +198,10 @@ and r0,r8,#7 rsb r0,r0,#8 movs r0,r9,asr r0 - strcsh r1,[r3,r8] - strcch tos,[r3,r8] - inc r8,#2 + mov r0,r8,lsl #1 + strcsh r1,[r3,r0] + strcch tos,[r3,r0] + inc r8,#1 repeat add r7,r7,r6 \ new font-line add r3,r3,r2 \ new screen-line
Modified: cpu/arm/olpc/1.75/addrs.fth ============================================================================== --- cpu/arm/olpc/1.75/addrs.fth Fri Nov 5 19:51:45 2010 (r2014) +++ cpu/arm/olpc/1.75/addrs.fth Fri Nov 5 19:56:34 2010 (r2015) @@ -6,8 +6,16 @@
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 +h# 20000 constant dropin-offset \ Offset to dropin driver area in SPI FLASH +[ifdef] use-flash-nvram +h# d.0000 constant nvram-offset +[then] + +h# e.0000 constant mfg-data-offset \ Offset to manufacturing data area in SPI FLASH +h# f.0000 constant mfg-data-end-offset \ Offset to end of manufacturing data area in SPI FLASH +h# f.ffd8 constant crc-offset + +h# 10.0000 constant /rom \ Total size of SPI FLASH
: (memory?) ( phys -- flag ) total-ram-size u< ;
Modified: cpu/arm/olpc/1.75/devices.fth ============================================================================== --- cpu/arm/olpc/1.75/devices.fth Fri Nov 5 19:51:45 2010 (r2014) +++ cpu/arm/olpc/1.75/devices.fth Fri Nov 5 19:56:34 2010 (r2015) @@ -45,6 +45,15 @@ \ 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@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 @@ -53,14 +62,11 @@ \ fload ${BP}/cpu/arm/olpc/1.75/boardtwsi.fth fload ${BP}/cpu/arm/olpc/1.75/boardgpio.fth : init-stuff -\ set-camera-domain-voltage acgr-clocks-on init-mfprs set-gpio-directions init-timers init-twsi -\ power-on-dsi -\ power-on-sd ; stand-init: init-stuff @@ -85,19 +91,6 @@
\needs md5init fload ${BP}/ofw/ppp/md5.fth \ MD5 hash
- -[ifdef] notyet -fload ${BP}/dev/olpc/confirm.fth \ Selftest interaction modalities -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}/cpu/x86/pc/olpc/kbdtype.fth \ Export keyboard type - -fload ${BP}/dev/olpc/kb3700/battery.fth \ Battery status reports -[else] -: confirm-selftest? ( -- flag ) false ; \ XXX implement me -: find-tag ( adr len -- false | value$ true ) 2drop false ; -[then] - fload ${BP}/dev/olpc/spiflash/flashif.fth \ Generic FLASH interface
fload ${BP}/dev/olpc/spiflash/spiif.fth \ Generic low-level SPI bus access @@ -106,7 +99,6 @@
: ignore-power-button ; \ XXX implement me : ssp-spi-reprogrammed ; -: ?erased ( adr len -- flag ) 2drop true ; : ?enough-power ( -- ) ;
fload ${BP}/cpu/arm/mmp2/sspspi.fth \ Synchronous Serial Port SPI interface @@ -131,7 +123,18 @@
devalias dropins /dropins
-fload ${BP}/cpu/arm/olpc/1.75/spiui.fth \ User interface for SPI FLASH programming +fload ${BP}/dev/olpc/confirm.fth \ Selftest interaction modalities +fload ${BP}/cpu/arm/olpc/1.75/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 + +[ifdef] notyet +fload ${BP}/dev/olpc/kb3700/battery.fth \ Battery status reports +[then] + +false constant tethered? \ We only support reprogramming our own FLASH + +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$ @@ -143,6 +146,32 @@ fload ${BP}/cpu/arm/olpc/1.75/lcd.fth fload ${BP}/cpu/arm/olpc/1.75/dconsmb.fth \ SMB access to DCON chip - bitbanged fload ${BP}/dev/olpc/dcon/mmp2dcon.fth \ DCON control + defer pixel* + defer pixel+ + defer pixel! + 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! + [else] + ' /w* to pixel* + ' wa+ to pixel+ + ' w! to pixel! + [then]
: display-on init-xo-display \ Turns on DCON @@ -180,8 +209,6 @@ create 15x30pc " ${BP}/ofw/termemu/15x30pc.psf" $file, ' 15x30pc to romfont
-\ fload ${BP}/ofw/termemu/cp881-16.fth - fload ${BP}/cpu/arm/olpc/1.75/sdhci.fth
devalias int /sd@d4281000/disk
Modified: cpu/arm/olpc/1.75/fw-version.fth ============================================================================== --- cpu/arm/olpc/1.75/fw-version.fth Fri Nov 5 19:51:45 2010 (r2014) +++ cpu/arm/olpc/1.75/fw-version.fth Fri Nov 5 19:56:34 2010 (r2015) @@ -1,3 +1,3 @@ \ The overall firmware revision macro: FW_MAJOR A -macro: FW_MINOR 03 +macro: FW_MINOR 04
Modified: cpu/arm/olpc/1.75/fw.bth ============================================================================== --- cpu/arm/olpc/1.75/fw.bth Fri Nov 5 19:51:45 2010 (r2014) +++ cpu/arm/olpc/1.75/fw.bth Fri Nov 5 19:56:34 2010 (r2015) @@ -90,6 +90,19 @@ ; ' (.firmware) to .firmware
+\ fload ${BP}/cpu/x86/pc/olpc/via/banner.fth + +patch merge-rect-565 merge-rect merge-cursor \ Hack since we do all our user-level graphics in 565 +patch merge-rect-565 merge-rect merge-cursor \ Hack since we do all our user-level graphics in 565 + +[ifdef] notyet +\ 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/x86/pc/olpc/via/bootmenu.fth +[then] + : screen-#lines ( -- n ) screen-ih 0= if default-#lines exit then screen-ih package( #lines )package @@ -111,17 +124,44 @@ then ;
+fload ${BP}/cpu/x86/pc/olpc/via/banner.fth + fload ${BP}/cpu/x86/pc/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 + +\ Pseudo device that appears in the boot order before net booting +0 0 " " " /" begin-package + " prober" device-name + : open + visible + false + ; + : close ; +end-package
+fload ${BP}/dev/logdev.fth [ifdef] notyet -fload ${BP}/cpu/x86/pc/olpc/gamekeys.fth +fload ${BP}/dev/olpc/keyboard/selftest.fth \ Keyboard diagnostic +fload ${BP}/dev/olpc/touchpad/touchpad.fth \ Touchpad diagnostic +[then] +fload ${BP}/cpu/x86/pc/olpc/gridmap.fth \ Gridded display tools +fload ${BP}/cpu/x86/pc/olpc/via/copynand.fth
+[ifdef] notyet +fload ${BP}/cpu/x86/pc/olpc/gamekeys.fth : emacs ( -- ) false to already-go? boot-getline to boot-file " rom:emacs" $boot ; +defer rm-go-hook \ Not used, but makes security happy +fload ${BP}/cpu/x86/pc/olpc/security.fth + +[then]
fload ${BP}/ofw/gui/ofpong.fth +[ifdef] notyet fload ${BP}/cpu/x86/pc/olpc/life.fth [then]
Added: cpu/arm/olpc/1.75/getmfgdata.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/arm/olpc/1.75/getmfgdata.fth Fri Nov 5 19:56:34 2010 (r2015) @@ -0,0 +1,17 @@ +purpose: Get the manufacturing data into memory where it can be manipulated + +/flash-block buffer: mfg-data-buf + +: get-mfg-data ( -- ) + flash-open + mfg-data-buf /flash-block mfg-data-offset flash-read +; + +0 value mfg-data-read? +: mfg-data-top ( -- adr ) + mfg-data-read? 0= if + get-mfg-data + true to mfg-data-read? + then + mfg-data-buf /flash-block + +;
Modified: cpu/arm/olpc/1.75/lcd.fth ============================================================================== --- cpu/arm/olpc/1.75/lcd.fth Fri Nov 5 19:51:45 2010 (r2014) +++ cpu/arm/olpc/1.75/lcd.fth Fri Nov 5 19:56:34 2010 (r2015) @@ -9,7 +9,7 @@ h# 19 pmua-disp-clk-sel + h# d428284c l! h# 1b pmua-disp-clk-sel + h# d428284c l!
- 0 h# 190 lcd! \ Disable LCD DMA controller + 0 h# 190 lcd! \ Disable LCD DMA controller fb-pa h# f4 lcd! \ Frame buffer area 0 0 h# f8 lcd! \ Frame buffer area 1 hdisp bytes/pixel * h# fc lcd! \ Pitch in bytes @@ -26,7 +26,8 @@ h# 2000000d h# 1b8 lcd! \ Dumb panel controller - 18 bit RGB666 on LDD[17:0] h# 01330133 h# 13c lcd! \ Panel VSYNC Pulse Pixel Edge Control clkdiv h# 1a8 lcd! \ Clock divider - h# 08021100 h# 190 lcd! \ DMA CTRL 0 - enable DMA, 24 bpp mode +\ h# 08021100 h# 190 lcd! \ DMA CTRL 0 - enable DMA, 24 bpp mode + h# 08001100 h# 190 lcd! \ DMA CTRL 0 - enable DMA, 16 bpp mode ;
: normal-hsv ( -- )
Modified: cpu/arm/olpc/1.75/lcdcfg.fth ============================================================================== --- cpu/arm/olpc/1.75/lcdcfg.fth Fri Nov 5 19:51:45 2010 (r2014) +++ cpu/arm/olpc/1.75/lcdcfg.fth Fri Nov 5 19:56:34 2010 (r2015) @@ -14,9 +14,15 @@ : hfp ( -- n ) htotal hdisp - hsync - hbp - ; \ 24 : vfp ( -- n ) vtotal vdisp - vsync - vbp - ; \ 4
+0 [if] 3 constant #lanes 3 constant bytes/pixel d# 24 constant bpp +[else] +2 constant #lanes +2 constant bytes/pixel +d# 16 constant bpp +[then]
: >bytes ( pixels -- chunks ) bytes/pixel * ; : >chunks ( pixels -- chunks ) >bytes #lanes / ;
Modified: cpu/arm/olpc/1.75/olpc.bth ============================================================================== --- cpu/arm/olpc/1.75/olpc.bth Fri Nov 5 19:51:45 2010 (r2014) +++ cpu/arm/olpc/1.75/olpc.bth Fri Nov 5 19:56:34 2010 (r2015) @@ -196,7 +196,7 @@ filebuf /rom ofd @ fgets /rom <> abort" Can't read back image" 0 crctab filebuf /rom ($crc) crcbuf !
-/rom h# 28 - ofd @ fseek +crc-offset ofd @ fseek crcbuf /l ofd @ fputs
ofd @ fclose
Modified: cpu/arm/olpc/1.75/prefw.bth ============================================================================== --- cpu/arm/olpc/1.75/prefw.bth Fri Nov 5 19:51:45 2010 (r2014) +++ cpu/arm/olpc/1.75/prefw.bth Fri Nov 5 19:56:34 2010 (r2015) @@ -255,6 +255,7 @@ 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?
Modified: cpu/arm/olpc/1.75/spiui.fth ============================================================================== --- cpu/arm/olpc/1.75/spiui.fth Fri Nov 5 19:51:45 2010 (r2014) +++ cpu/arm/olpc/1.75/spiui.fth Fri Nov 5 19:56:34 2010 (r2015) @@ -8,83 +8,7 @@
h# 4000 constant /chunk \ Convenient sized piece for progress reports
-[ifdef] use-flash-nvram -h# d.0000 constant nvram-offset -[then] - -[ifdef] mfg-data-top -h# e.0000 constant mfg-data-offset mfg-data-offset /flash-block + constant mfg-data-end-offset -: mfg-data-range ( -- adr len ) mfg-data-top dup last-mfg-data tuck - ; - -[ifdef] $call-method -: make-sn-name ( -- filename$ ) - " SN" find-tag 0= abort" No serial number in mfg data" ( sn$ ) - dup if ( sn$ ) - 2dup + 1- c@ 0= if ( sn$ ) - 1- ( sn$' ) \ Remove Null - then ( sn$ ) - then ( sn$ ) - d# 11 over - dup 0> if ( sn$' #excess ) - /string ( sn$' ) \ Keep last 11 characters - else ( sn$' #excess ) - drop ( sn$ ) - then ( sn$ ) - - " disk:" "temp place ( sn$' ) - - dup 8 > if ( sn$ ) - over 8 "temp $cat ( sn$ ) - 8 /string ( sn$' ) - " ." "temp $cat ( sn$ ) - then ( sn$ ) - "temp $cat ( ) - "temp count ( filename$ ) -; - -: save-mfg-data ( -- ) - make-sn-name ( name$ ) - ." Creating " 2dup type cr - $create-file ( ihandle ) - dup 0= abort" Can't create file" >r ( r: ihandle ) - mfg-data-range " write" r@ $call-method ( r: ihandle ) - r> close-dev -; -: restore-mfg-data ( "filename" -- ) - reading - ifd @ fsize dup /flash-block > if ( len ) - drop ifd @ fclose ( ) - true abort" File is too big" - then ( len ) - mfg-data-buf swap ( adr len ) - 2dup ifd @ fgets drop ( adr len ) - ifd @ fclose - - flash-write-enable - mfg-data-offset flash-erase-block ( adr len ) - mfg-data-end-offset over - ( adr len offset ) - flash-write ( ) - flash-write-disable ( ) -; -[then] - -: ?move-mfg-data ( -- ) - ." Merging existing manufacturing data" cr - - tethered? if - \ Read the manufacturing data from the other FLASH - flash-buf mfg-data-offset + /flash-block mfg-data-offset flash-read - exit - then - - \ Copy the entire block containing the manufacturing data into the - \ memory buffer. This make verification easier. - - mfg-data-top /flash-block - ( src-adr ) - flash-buf mfg-data-offset + ( src-adr dst-adr ) - /flash-block move ( ) -; -[then]
: write-flash-range ( adr end-offset start-offset -- ) ." Writing" cr @@ -118,6 +42,16 @@ ;
+\ Perform a series of sanity checks on the new firmware image. + +: check-firmware-image ( adr len -- adr len ) + dup /flash <> abort" Wrong image length" ( adr len ) + 2dup + h# 40 - ( adr len signature-adr ) + dup " CL1" comp abort" No firmware signature" ( adr len signature-adr ) + ." Firmware: " h# 10 type ( adr len ) + \ XXX add some more sanity checks +; + [ifdef] load-base : flash-buf load-base ; : mfg-data-buf load-base /flash + ; @@ -127,14 +61,12 @@ [then] 0 value file-loaded?
-h# 28 constant crc-offset \ From end - : crc ( adr len -- crc ) 0 crctab 2swap ($crc) ;
: ?crc ( -- ) ." Checking integrity ..." cr
- flash-buf /flash + crc-offset - ( crc-adr ) + flash-buf crc-offset + ( crc-adr ) dup l@ >r ( crc-adr r: crc ) -1 over l! ( crc-adr r: crc )
@@ -152,14 +84,12 @@
?crc
-[ifdef] mfg-data-offset flash-buf mfg-data-offset + /flash-block ['] ?erased catch abort" Firmware image has data in the manufacturing data block" [ifdef] use-flash-nvram flash-buf nvram-offset + /flash-block ['] ?erased catch abort" Firmware image has data in the NVRAM block" [then] -[then] ;
: $get-file ( "filename" -- ) @@ -192,7 +122,76 @@
: verify ( -- ) ?file flash-buf /flash 0 verify-flash-range ;
-[ifdef] mfg-data-offset +: mfg-data-range ( -- adr len ) mfg-data-top dup last-mfg-data tuck - ; + +[ifdef] $call-method +: make-sn-name ( -- filename$ ) + " SN" find-tag 0= abort" No serial number in mfg data" ( sn$ ) + dup if ( sn$ ) + 2dup + 1- c@ 0= if ( sn$ ) + 1- ( sn$' ) \ Remove Null + then ( sn$ ) + then ( sn$ ) + d# 11 over - dup 0> if ( sn$' #excess ) + /string ( sn$' ) \ Keep last 11 characters + else ( sn$' #excess ) + drop ( sn$ ) + then ( sn$ ) + + " disk:" "temp place ( sn$' ) + + dup 8 > if ( sn$ ) + over 8 "temp $cat ( sn$ ) + 8 /string ( sn$' ) + " ." "temp $cat ( sn$ ) + then ( sn$ ) + "temp $cat ( ) + "temp count ( filename$ ) +; + +: save-mfg-data ( -- ) + make-sn-name ( name$ ) + ." Creating " 2dup type cr + $create-file ( ihandle ) + dup 0= abort" Can't create file" >r ( r: ihandle ) + mfg-data-range " write" r@ $call-method ( r: ihandle ) + r> close-dev +; +: restore-mfg-data ( "filename" -- ) + reading + ifd @ fsize dup /flash-block > if ( len ) + drop ifd @ fclose ( ) + true abort" File is too big" + then ( len ) + mfg-data-buf swap ( adr len ) + 2dup ifd @ fgets drop ( adr len ) + ifd @ fclose + + flash-write-enable + mfg-data-offset flash-erase-block ( adr len ) + mfg-data-end-offset over - ( adr len offset ) + flash-write ( ) + flash-write-disable ( ) +; +[then] + +: ?move-mfg-data ( -- ) + ." Merging existing manufacturing data" cr + + tethered? if + \ Read the manufacturing data from the other FLASH + flash-buf mfg-data-offset + /flash-block mfg-data-offset flash-read + exit + then + + \ Copy the entire block containing the manufacturing data into the + \ memory buffer. This make verification easier. + + mfg-data-top /flash-block - ( src-adr ) + flash-buf mfg-data-offset + ( src-adr dst-adr ) + /flash-block move ( ) +; + : verify-firmware ( -- ) [ifdef] use-flash-nvram flash-buf nvram-offset 0 verify-flash-range \ Verify first part @@ -214,14 +213,6 @@
flash-buf mfg-data-end-offset + /flash mfg-data-end-offset write-flash-range \ Write last part ; -[else] -: verify-firmware ( -- ) - flash-buf /flash 0 verify-flash-range \ Verify entire FLASH -; -: write-firmware ( -- ) - flash-buf /flash 0 write-flash-range \ Write entire FLASH -; -[then]
: .verify-msg ( -- ) ." Type verify if you want to verify the data just written." cr @@ -233,9 +224,7 @@ ?file flash-write-enable
-[ifdef] ?move-mfg-data ?move-mfg-data -[then]
write-firmware
@@ -264,7 +253,6 @@ : flash ( ["filename"] -- ) get-file ?enough-power reflash ; : flash! ( ["filename"] -- ) get-file reflash ;
-0 [if] \ This is a slower version of "rom-va flash-buf /flash lmove" \ It works around the problem that continuous CPU access to the \ SPI FLASH starves the EC of instruction fetch cycles, often @@ -290,7 +278,7 @@ flash-buf mfg-data-offset + /flash-block h# ff fill
\ Get the CRC and then replace it with -1 - flash-buf /flash + crc-offset - dup l@ swap + flash-buf crc-offset + dup l@ swap -1 swap l!
flash-buf /flash crc <> @@ -298,19 +286,8 @@ ; device-end [then] -[then]
0 [if] -\ Perform a series of sanity checks on the new firmware image. - -: check-firmware-image ( adr len -- adr len ) - dup /flash <> abort" Wrong image length" ( adr len ) - 2dup + h# 40 - ( adr len signature-adr ) - dup " CL1" comp abort" No firmware signature" ( adr len signature-adr ) - ." Firmware: " h# 10 type ( adr len ) - \ XXX add some more sanity checks -; - \ Erase the first block containing the EC microcode. This is dangerous...
: erase-ec ( -- ) 0 flash-erase-block ;
Modified: cpu/x86/pc/olpc/addrs.fth ============================================================================== --- cpu/x86/pc/olpc/addrs.fth Fri Nov 5 19:51:45 2010 (r2014) +++ cpu/x86/pc/olpc/addrs.fth Fri Nov 5 19:56:34 2010 (r2015) @@ -71,6 +71,14 @@ h# 3e constant cmos-alarm-month \ Offset of month alarm in CMOS h# 32 constant cmos-century \ Offset of century byte in CMOS
+[ifdef] use-flash-nvram +h# d.0000 constant nvram-offset +[then] + +h# e.0000 constant mfg-data-offset \ Offset to manufacturing data area in SPI FLASH +h# f.0000 constant mfg-data-end-offset \ Offset to end of manufacturing data area in SPI FLASH +h# f.ffd0 constant crc-offset + fload ${BP}/cpu/x86/pc/virtaddr.fth [ifndef] virtual-mode h# ff80.0000 to fw-virt-base \ Override the usual setting; we use an MSR to double-map some memory up high
Modified: cpu/x86/pc/olpc/devices.fth ============================================================================== --- cpu/x86/pc/olpc/devices.fth Fri Nov 5 19:51:45 2010 (r2014) +++ cpu/x86/pc/olpc/devices.fth Fri Nov 5 19:56:34 2010 (r2015) @@ -304,6 +304,7 @@ ;
fload ${BP}/dev/olpc/confirm.fth \ Selftest interaction modalities +fload ${BP}/cpu/x86/pc/olpc/getmfgdata.fth \ Low-level access to 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}/cpu/x86/pc/olpc/kbdtype.fth \ Export keyboard type
Added: cpu/x86/pc/olpc/getmfgdata.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/x86/pc/olpc/getmfgdata.fth Fri Nov 5 19:56:34 2010 (r2015) @@ -0,0 +1,11 @@ +\ Mfg data is in a block by itself. +/flash-block buffer: mfg-data-buf + +\ Read mfg data from FLASH to RAM +: get-mfg-data ( -- ) + rom-pa mfg-data-offset + mfg-data-buf /flash-block lmove +; + +: mfg-data-top ( -- adr ) + flash-base mfg-data-end-offset + +;
Modified: cpu/x86/pc/olpc/gridmap.fth ============================================================================== --- cpu/x86/pc/olpc/gridmap.fth Fri Nov 5 19:51:45 2010 (r2014) +++ cpu/x86/pc/olpc/gridmap.fth Fri Nov 5 19:56:34 2010 (r2015) @@ -35,6 +35,7 @@
: show-state ( eblock# state -- ) swap >loc glyph-w glyph-h do-fill ;
+[ifdef] 386-assembler code map-color ( color24 -- color565 ) bx pop bx ax mov 3 # ax shr h# 1f # ax and \ Blue in correct place @@ -42,6 +43,22 @@ 8 # bx shr h# f800 # bx and bx ax or \ Red, green and blue in place ax push c; +[then] +[ifdef] arm-assembler +code map-color ( color24 -- color565 ) + mov r0,tos,lsr #3 + and r0,r0,#0x1f \ Blue + + mov r1,tos,lsr #5 + and r1,r1,#0x7e0 + orr r0,r0,r1 \ Green + + mov tos,tos,lsr #8 + and tos,tos,#0xf800 + orr tos,tos,r0 \ Red +c; +[then] + : show-color ( eblock# color32 -- ) map-color show-state ;
dev screen : erase-screen erase-screen ; dend
Modified: cpu/x86/pc/olpc/life.fth ============================================================================== --- cpu/x86/pc/olpc/life.fth Fri Nov 5 19:51:45 2010 (r2014) +++ cpu/x86/pc/olpc/life.fth Fri Nov 5 19:56:34 2010 (r2015) @@ -35,6 +35,7 @@
\needs xy+ : xy+ ( x1 y1 x2 y2 -- x3 y3 ) rot + -rot + swap ;
+[ifdef] 386-assembler code sumcell ( adr -- sum ) bx pop ax ax xor @@ -49,7 +50,29 @@
ax push c; - +[then] +[ifdef] arm-assembler +code sumcell ( adr -- sum ) + mov r0,#0 + ldrb r1,[tos, `lf_width negate`] + add r0,r0,r1 + ldrb r1,[tos, `lf_width 1- negate`] + add r0,r0,r1 + ldrb r1,[tos, `lf_width 1+ negate`] + add r0,r0,r1 + ldrb r1,[tos, #-1] + add r0,r0,r1 + ldrb r1,[tos, #1] + add r0,r0,r1 + ldrb r1,[tos, `lf_width`] + add r0,r0,r1 + ldrb r1,[tos, `lf_width 1-`] + add r0,r0,r1 + ldrb r1,[tos, `lf_width 1+`] + add r0,r0,r1 + mov r0,tos +c; +[then]
: +sum ( i j +i +j -- i j ) 2over xy+ ( i j i' j' )
Modified: cpu/x86/pc/olpc/mfgdata.fth ============================================================================== --- cpu/x86/pc/olpc/mfgdata.fth Fri Nov 5 19:51:45 2010 (r2014) +++ cpu/x86/pc/olpc/mfgdata.fth Fri Nov 5 19:56:34 2010 (r2015) @@ -44,11 +44,6 @@ true ( adr data$ name-adr true ) ;
-\ Mfg data is in a block by itself. -: mfg-data-top ( -- adr ) - flash-base h# f.0000 + -; - : (find-tag) ( name$ top-adr -- false | data$ true ) -rot drop >r ( adr r: name-adr ) begin another-tag? while ( adr' data$ tname-adr r: name-adr )
Modified: cpu/x86/pc/olpc/setwp.fth ============================================================================== --- cpu/x86/pc/olpc/setwp.fth Fri Nov 5 19:51:45 2010 (r2014) +++ cpu/x86/pc/olpc/setwp.fth Fri Nov 5 19:56:34 2010 (r2015) @@ -28,11 +28,6 @@
\ Set and clear the write-protect tag by copying, erasing, rewriting
-\ Read mfg data from FLASH to RAM -: get-mfg-data ( -- ) - rom-pa mfg-data-offset + mfg-data-buf /flash-block lmove -; - : (put-mfg-data) mfg-data-buf mfg-data-end-offset mfg-data-offset write-flash-range ;
Modified: cpu/x86/pc/olpc/via/addrs.fth ============================================================================== --- cpu/x86/pc/olpc/via/addrs.fth Fri Nov 5 19:51:45 2010 (r2014) +++ cpu/x86/pc/olpc/via/addrs.fth Fri Nov 5 19:56:34 2010 (r2015) @@ -103,6 +103,15 @@ h# 7e constant cmos-alarm-month \ Offset of month alarm in CMOS h# 7f constant cmos-century \ Offset of century byte in CMOS
+ +[ifdef] use-flash-nvram +h# d.0000 constant nvram-offset +[then] + +h# e.0000 constant mfg-data-offset \ Offset to manufacturing data area in SPI FLASH +h# f.0000 constant mfg-data-end-offset \ Offset to end of manufacturing data area in SPI FLASH +h# f.ffd4 constant crc-offset + fload ${BP}/cpu/x86/pc/virtaddr.fth
Modified: cpu/x86/pc/olpc/via/devices.fth ============================================================================== --- cpu/x86/pc/olpc/via/devices.fth Fri Nov 5 19:51:45 2010 (r2014) +++ cpu/x86/pc/olpc/via/devices.fth Fri Nov 5 19:56:34 2010 (r2015) @@ -281,6 +281,7 @@ ;
fload ${BP}/dev/olpc/confirm.fth \ Selftest interaction modalities +fload ${BP}/cpu/x86/pc/olpc/getmfgdata.fth \ Low-level access to 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}/cpu/x86/pc/olpc/kbdtype.fth \ Export keyboard type @@ -288,7 +289,6 @@ fload ${BP}/dev/olpc/kb3700/battery.fth \ Battery status reports
fload ${BP}/dev/olpc/spiflash/spiui.fth \ User interface for SPI FLASH programming -h# 2c to crc-offset fload ${BP}/cpu/x86/pc/olpc/via/recover.fth \ XO-to-XO SPI FLASH recovery
: ofw-fw-filename$ " disk:\boot\olpc.rom" ;
Modified: cpu/x86/pc/olpc/via/recover.fth ============================================================================== --- cpu/x86/pc/olpc/via/recover.fth Fri Nov 5 19:51:45 2010 (r2014) +++ cpu/x86/pc/olpc/via/recover.fth Fri Nov 5 19:56:34 2010 (r2015) @@ -16,7 +16,7 @@
: clone ( -- ) ." Getting a copy of this machine's FLASH" cr - slow-flash-read + safe-flash-read true to file-loaded?
(tethered-flash)
Modified: dev/olpc/spiflash/recover.fth ============================================================================== --- dev/olpc/spiflash/recover.fth Fri Nov 5 19:51:45 2010 (r2014) +++ dev/olpc/spiflash/recover.fth Fri Nov 5 19:56:34 2010 (r2015) @@ -30,7 +30,7 @@
: clone ( -- ) ." Getting a copy of this machine's FLASH" cr - slow-flash-read + safe-flash-read true to file-loaded?
(serial-flash)
Modified: dev/olpc/spiflash/spiflash.fth ============================================================================== --- dev/olpc/spiflash/spiflash.fth Fri Nov 5 19:51:45 2010 (r2014) +++ dev/olpc/spiflash/spiflash.fth Fri Nov 5 19:56:34 2010 (r2015) @@ -278,7 +278,7 @@ ." If you power cycle and try again, it will probably work the next time." cr abort endof - ( default ) ." Unsupported SPI FLASH ID " dup .x cr abort + ( default ) true abort" Unsupported SPI FLASH ID" endcase to write-spi-flash 0 spi-write-status \ Turn off write protect bits
Modified: dev/olpc/spiflash/spiui.fth ============================================================================== --- dev/olpc/spiflash/spiui.fth Fri Nov 5 19:51:45 2010 (r2014) +++ dev/olpc/spiflash/spiui.fth Fri Nov 5 19:56:34 2010 (r2015) @@ -8,13 +8,6 @@
h# 4000 constant /chunk \ Convenient sized piece for progress reports
-[ifdef] use-flash-nvram -h# d.0000 constant nvram-offset -[then] - -h# e.0000 constant mfg-data-offset -mfg-data-offset /flash-block + constant mfg-data-end-offset - : write-flash-range ( adr end-offset start-offset -- ) ." Writing" cr ?do ( adr ) @@ -24,7 +17,7 @@ \ Just write if reading is slow true ( adr must-write? ) else ( adr ) - dup /flash-block i flash-verify ( adr must-write? ) + dup /flash-block i flash-verify ( adr must-write? ) then ( adr must-write? )
if @@ -59,21 +52,18 @@
[ifdef] load-base : flash-buf load-base ; -: mfg-data-buf load-base /flash + ; [else] /flash buffer: flash-buf -/flash-block buffer: mfg-data-buf [then] -0 value file-loaded?
-h# 30 constant crc-offset \ From end (modified in devices.fth for XO 1.5) +0 value file-loaded?
: crc ( adr len -- crc ) 0 crctab 2swap ($crc) ;
: ?crc ( -- ) ." Checking integrity ..." cr
- flash-buf /flash + crc-offset - ( crc-adr ) + flash-buf crc-offset + ( crc-adr ) dup l@ >r ( crc-adr r: crc ) -1 over l! ( crc-adr r: crc )
@@ -129,8 +119,6 @@
: verify ( -- ) ?file flash-buf /flash 0 verify-flash-range ;
-: mfg-data-range ( -- adr len ) mfg-data-top dup last-mfg-data tuck - ; - [ifdef] $call-method : make-sn-name ( -- filename$ ) " SN" find-tag 0= abort" No serial number in mfg data" ( sn$ ) @@ -161,14 +149,16 @@ ." Creating " 2dup type cr $create-file ( ihandle ) dup 0= abort" Can't create file" >r ( r: ihandle ) - mfg-data-range " write" r@ $call-method ( r: ihandle ) + mfg-data-buf /flash-block ( adr len r: ihandle ) + 2dup mfg-data-offset flash-read ( adr len r: ihandle ) + " write" r@ $call-method ( r: ihandle ) r> close-dev ; : restore-mfg-data ( "filename" -- ) reading - ifd @ fsize dup /flash-block > if ( len ) + ifd @ fsize dup /flash-block <> if ( len ) drop ifd @ fclose ( ) - true abort" File is too big" + true abort" File is the wrong size - should be 65536 bytes" then ( len ) mfg-data-buf swap ( adr len ) 2dup ifd @ fgets drop ( adr len ) @@ -176,29 +166,11 @@
flash-write-enable mfg-data-offset flash-erase-block ( adr len ) - mfg-data-end-offset over - ( adr len offset ) - flash-write ( ) + mfg-data-offset flash-write ( ) flash-write-disable ( ) ; [then]
-: ?move-mfg-data ( -- ) - ." Merging existing manufacturing data" cr - - tethered? if - \ Read the manufacturing data from the other FLASH - flash-buf mfg-data-offset + /flash-block mfg-data-offset flash-read - exit - then - - \ Copy the entire block containing the manufacturing data into the - \ memory buffer. This make verification easier. - - mfg-data-top /flash-block - ( src-adr ) - flash-buf mfg-data-offset + ( src-adr dst-adr ) - /flash-block move ( ) -; - : verify-firmware ( -- ) [ifdef] use-flash-nvram flash-buf nvram-offset 0 verify-flash-range \ Verify first part @@ -231,8 +203,6 @@ ?file flash-write-enable
- ?move-mfg-data - write-firmware
spi-us d# 20 < if @@ -260,12 +230,14 @@ : flash ( ["filename"] -- ) get-file ?enough-power reflash ; : flash! ( ["filename"] -- ) get-file reflash ;
+[ifdef] rom-pa \ This is a slower version of "rom-va flash-buf /flash lmove" \ It works around the problem that continuous CPU access to the \ SPI FLASH starves the EC of instruction fetch cycles, often -\ causing it to turn off the system. +\ causing it to turn off the system. This is only a problem +\ for systems where the CPU and EC share the SPI FLASH. 0 value rom-va -: slow-flash-read ( -- ) +: safe-flash-read ( -- ) rom-pa /flash root-map-in to rom-va /flash 0 do rom-va i + flash-buf i + h# 1.0000 lmove @@ -273,6 +245,11 @@ h# 1.0000 +loop rom-va /flash root-map-out 0 to rom-va ; +[else] +: safe-flash-read ( -- ) + flash-buf /flash 0 flash-read +; +[then]
[ifdef] dev dev /flash @@ -280,12 +257,12 @@ .mfg-data cr
." Checking SPI FLASH CRC ..." - slow-flash-read + safe-flash-read \ Replace the manufacturing data block with all FF flash-buf mfg-data-offset + /flash-block h# ff fill
\ Get the CRC and then replace it with -1 - flash-buf /flash + crc-offset - dup l@ swap + flash-buf crc-offset + dup l@ swap -1 swap l!
flash-buf /flash crc <>
Modified: dev/video/common/rectangle16.fth ============================================================================== --- dev/video/common/rectangle16.fth Fri Nov 5 19:51:45 2010 (r2014) +++ dev/video/common/rectangle16.fth Fri Nov 5 19:56:34 2010 (r2015) @@ -3,6 +3,80 @@
external
+[ifdef] arm-assembler +code 565>argb-pixel ( 565 -- argb ) + mov r0,tos,lsr #11 + mov r0,r0,lsl #19 \ Red + orr r0,r0,#0x70000 + + mov r1,tos,lsl #27 + mov r1,r1,lsr #24 + orr r1,r1,#0x7 + orr r0,r0,r1 \ Blue + + mov tos,tos,lsl #21 + mov tos,tos,lsr #26 + mov tos,tos,lsl #10 + orr tos,tos,#0x300 + + orr tos,tos,r0 + orr tos,tos,#0xff000000 +c; +code 565>argb ( src dst #pixels -- ) + mov r2,tos + ldmia sp!,{r0,r1,tos} \ r0:dst, r1:src, r2:#pixels + + begin + ldrh r3,[r1] + inc r1,#2 + + mov r4,r3,lsr #11 + mov r4,r4,lsl #19 \ Red + orr r4,r4,#0x70000 + + mov r5,r3,lsl #27 + mov r5,r5,lsr #24 + orr r5,r5,#0x7 + orr r4,r4,r5 \ Blue + + mov r3,r3,lsl #21 + mov r3,r3,lsr #26 + mov r3,r3,lsl #10 + orr r3,r3,#0x300 + + orr r3,r3,r4 + orr r3,r3,#0xff000000 + + str r3,[r0],#4 + decs r2,#1 + 0= until +c; +code argb>565-pixel ( argb -- 565 ) + ax pop + ax bx mov d# 19 # bx shr d# 11 # bx shl \ Red + ax dx mov d# 24 # dx shl d# 27 # dx shr dx bx or \ Blue + d# 16 # ax shl d# 26 # ax shr d# 5 # ax shl bx ax or \ Green + ax push +c; + +code argb>565 ( src dst #pixels -- ) + cx pop + di 0 [sp] xchg + si 4 [sp] xchg + + begin + ax lods + ax bx mov d# 19 # bx shr d# 11 # bx shl \ Red + ax dx mov d# 24 # dx shl d# 27 # dx shr dx bx or \ Blue + d# 16 # ax shl d# 26 # ax shr d# 5 # ax shl bx ax or \ Green + op: ax stos + loopa + + di pop + si pop +c; +[then] +[ifdef] 386-assembler code 565>argb-pixel ( 565 -- argb ) ax pop ax bx mov d# 11 # bx shr d# 19 # bx shl \ Red @@ -53,6 +127,7 @@ di pop si pop c; +[then]
: rectangle-setup ( x y w h -- wb fbadr h ) swap depth * 3 rshift swap ( x y wbytes h )
Modified: ofw/gui/ofpong.fth ============================================================================== --- ofw/gui/ofpong.fth Fri Nov 5 19:51:45 2010 (r2014) +++ ofw/gui/ofpong.fth Fri Nov 5 19:56:34 2010 (r2015) @@ -69,7 +69,7 @@ get-msecs to grandseed ;
-: random ( -- n ) grandseed 16807 * 17 + abs to grandseed grandseed 1000 mod ; +: random1k ( -- n ) grandseed 16807 * 17 + abs to grandseed grandseed 1000 mod ; : unscale ( n -- n ) pscale 2/ + pscale / ; : calcbatx ( n -- x ) screenw ballsize 3 * - * ballsize + ; : paintrect ( c pixx pixy pixw pixh -- ) " fill-rectangle" $call-screen ; @@ -236,16 +236,16 @@
: resetball ( -- ) 500 to ballstop - screenw ballsize - 2 / pscale * ballx pscale mod + random + to ballx - screenh ballsize - 2 / pscale * bally pscale mod + random + to bally + screenw ballsize - 2 / pscale * ballx pscale mod + random1k + to ballx + screenh ballsize - 2 / pscale * bally pscale mod + random1k + to bally
- random screenw pscale * * 2000000 / to balldx - random screenh pscale * * 2000000 / to balldy - balldx screenw pscale * 3000 / + to balldx - balldy screenh pscale * 6000 / + to balldy + random1k screenw pscale * * 2000000 / to balldx + random1k screenh pscale * * 2000000 / to balldy + balldx screenw pscale * 3000 / + to balldx + balldy screenh pscale * 6000 / + to balldy
- random 500 < if balldx negate to balldx then - random 500 < if balldy negate to balldy then + random1k 500 < if balldx negate to balldx then + random1k 500 < if balldy negate to balldy then ;
: initvalues ( -- ) @@ -391,11 +391,11 @@ then
ballx reflect_left_x > if - balldx abs random 50 / + to balldx + balldx abs random1k 50 / + to balldx
leftbaty bally - unscale dup 0 batsize between if - batsize 2 / - random * 2 / batsize / 25 / balldy + to balldy + batsize 2 / - random1k * 2 / batsize / 25 / balldy + to balldy else drop then @@ -417,11 +417,11 @@ then
ballx reflect_right_x < if - balldx abs random 50 / + negate to balldx + balldx abs random1k 50 / + negate to balldx
rightbaty bally - unscale dup 0 batsize between if - batsize 2 / - random * 2 / batsize / 25 / balldy + to balldy + batsize 2 / - random1k * 2 / batsize / 25 / balldy + to balldy else drop then
openfirmware@openfirmware.info