Author: wmb
Date: 2007-07-25 03:58:15 +0200 (Wed, 25 Jul 2007)
New Revision: 495
Added:
cpu/x86/pc/olpc/crypto.fth
Modified:
cpu/x86/pc/flashpkg.fth
cpu/x86/pc/olpc/config.fth
cpu/x86/pc/olpc/devices.fth
cpu/x86/pc/olpc/fw.bth
cpu/x86/pc/olpc/pcinode.fth
dev/geode/ac97/ac97.fth
dev/geode/display/gxfb.fth
dev/geode/display/gxpci.fth
dev/i8042.fth
dev/mmc/sdhci/sdhci.fth
dev/mmc/sdhci/sdmmc.fth
dev/olpc/cafecamera/cafecamera.fth
dev/olpc/cafenand/cafenand.fth
dev/pci/isa.fth
dev/pci/isaall.fth
dev/pci/isamisc.fth
dev/pcibus.fth
Log:
OLPC trac #553 - lots of device tree tweaks, mostly stuff that the
OS doesn't care about.
Modified: cpu/x86/pc/flashpkg.fth
===================================================================
--- cpu/x86/pc/flashpkg.fth 2007-07-24 20:33:58 UTC (rev 494)
+++ cpu/x86/pc/flashpkg.fth 2007-07-25 01:58:15 UTC (rev 495)
@@ -119,6 +119,7 @@
size rot 0 d- ( d.#bytes )
;
+[ifdef] flash-is-parent
\ These allow us to sub-address the FLASH device to access the PROMICE AI port
1 " #address-cells" integer-property
@@ -126,6 +127,8 @@
: encode-unit ( phys -- adr len ) push-hex (u.) pop-base ;
: map-in ( offset size -- virt ) drop device-base + ;
: map-out ( virt size -- virt ) 2drop ;
+[then]
+
\ LICENSE_BEGIN
\ Copyright (c) 2006 FirmWorks
\
Modified: cpu/x86/pc/olpc/config.fth
===================================================================
--- cpu/x86/pc/olpc/config.fth 2007-07-24 20:33:58 UTC (rev 494)
+++ cpu/x86/pc/olpc/config.fth 2007-07-25 01:58:15 UTC (rev 495)
@@ -37,7 +37,11 @@
\ create use-watch-all
\ create use-root-isa
create no-floppy-node
+create no-com2-node
+create no-lpt-node
create use-pci-isa
+create basic-isa
+create isa-dma-only
create use-null-nvram
Added: cpu/x86/pc/olpc/crypto.fth
===================================================================
--- cpu/x86/pc/olpc/crypto.fth (rev 0)
+++ cpu/x86/pc/olpc/crypto.fth 2007-07-25 01:58:15 UTC (rev 495)
@@ -0,0 +1,127 @@
+purpose: Interface to cryptographic code for firmware image validation
+\ See license at end of file
+
+h# c0000 constant crypto-base \ The address the code is linked to run at
+h# c0000 constant hasher-base \ The address the code is linked to run at
+
+variable hashlen
+d# 128 buffer: hashbuf
+
+: hash ( data$ hashname$ -- result$ )
+ " hasher" find-drop-in 0= if 4drop true exit then ( data$ hashname$ prog$ )
+ 2dup hasher-base swap move free-mem ( data$ hashname$ )
+
+ d# 128 hashlen !
+ 2>r swap hashlen hashbuf 2swap 2r> $cstr ( &reslen resbuf datalen databuf hashname-cstr )
+
+ hasher-base dup h# 10 - sp-call abort" Hash failed" drop 4drop ( )
+ hashbuf hashlen @
+;
+
+h# f value which-hashes
+: signature-bad? ( data$ sig$ -- mismatch? )
+ " crypto" find-drop-in 0= if 4drop true exit then ( data$ sig$ prog$ )
+ 2dup crypto-base swap move free-mem ( data$ sig$ )
+
+ " pubkey" find-drop-in 0= if 4drop true exit then ( data$ sig$ key$ )
+ 2>r ( data$ sig$ r: key$ )
+ swap 2swap swap ( siglen sigadr datalen dataadr r: key$ )
+ 2r@ swap 2swap ( siglen sigadr keylen keyadr datalen dataadr r: key$ )
+
+ which-hashes
+
+ crypto-base dup h# 10 - sp-call >r 3drop 4drop r> ( result r: key$ )
+ 2r> free-mem
+
+\ XXX free-mem in suspend.fth and fw.bth after find-drop-in
+\ XXX clean out dead code in usb.fth
+;
+
+1 [if]
+
+\ Check that the version is an upgrade?
+
+: >rom-name$ ( device$ -- path$ )
+ image-name-buf place ( )
+ " :\boot\olpcfw.rom" image-name-buf $cat ( )
+ image-name$
+;
+: sig-name$ ( -- path$ )
+ image-name$ + 4 - " .rom" caps-comp 0= if
+ " sig" image-name$ + 3 - swap move
+ image-name$
+ else
+ 2drop " "
+ then
+;
+: $dev-update-flash ( device$ -- )
+ >rom-name$ $get-image if exit then ( data$ )
+
+ sig-name$ $get-image if
+ ." Missing firmware update signature file: " sig-name$ type cr
+ free-mem exit
+ then ( data$ sig$ )
+
+ 2over 2over signature-bad? if ( data$ sig$ )
+ ." Firmware update image signature mismatch: " sig-name$ type cr
+ free-mem free-mem exit
+ then ( data$ sig$ )
+
+ free-mem ( data$ )
+
+ 2dup flash-buf swap move ( data$ )
+ tuck free-mem ( data-len )
+ ['] ?image-valid catch if ( x )
+ drop ." Firmware image failed sanity checks" cr ( )
+ exit
+ then ( x )
+
+ true to file-loaded?
+ reflash
+;
+[then]
+
+: getbin " usb8388.bin" find-drop-in 0= abort" No usb8388.bin" ;
+: getsig " usb8388.sig" find-drop-in 0= abort" No usb8388.sig" ;
+: tc ( -- )
+ getbin getsig
+ signature-bad? if
+ ." Signature was bad, expected good" cr
+ then
+
+ getbin over 1 swap +!
+ getsig
+ signature-bad? 0= if
+ ." Signature was good, expected bad (corrupt image)" cr
+ then
+
+ getbin
+ getsig over 40 + 1 swap +!
+ signature-bad? 0= if
+ ." Signature was good, expected bad (corrupt signature)" cr
+ then
+;
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2007 FirmWorks
+\
+\ Permission is hereby granted, free of charge, to any person obtaining
+\ a copy of this software and associated documentation files (the
+\ "Software"), to deal in the Software without restriction, including
+\ without limitation the rights to use, copy, modify, merge, publish,
+\ distribute, sublicense, and/or sell copies of the Software, and to
+\ permit persons to whom the Software is furnished to do so, subject to
+\ the following conditions:
+\
+\ The above copyright notice and this permission notice shall be
+\ included in all copies or substantial portions of the Software.
+\
+\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+\
+\ LICENSE_END
Modified: cpu/x86/pc/olpc/devices.fth
===================================================================
--- cpu/x86/pc/olpc/devices.fth 2007-07-24 20:33:58 UTC (rev 494)
+++ cpu/x86/pc/olpc/devices.fth 2007-07-25 01:58:15 UTC (rev 495)
@@ -27,9 +27,14 @@
fload ${BP}/cpu/x86/tsc.fth
stand-init:
- gx? if d# 366,666,667 else d# 433,333,333 then ( cpu-clock-hz )
+ gx? if
+ d# 366,666,667 " AMD,Geode GX"
+ else
+ d# 433,333,333 " AMD,Geode LX"
+ then ( cpu-clock-hz model$ )
- " /cpu" find-device ( cpu-clock-hz )
+ " /cpu" find-device ( cpu-clock-hz model$ )
+ " model" string-property ( cpu-clock-hz )
dup " clock-frequency" integer-property ( cpu-clock-hz )
device-end ( cpu-clock-hz )
@@ -64,12 +69,18 @@
h# 20 to vector-base0
h# 28 to vector-base1
device-end
-[then]
+warning @ warning off
+: probe-pci ( -- )
+ probe-pci
+ " /pci" " make-interrupt-map" execute-device-method drop
+;
+warning !
+
0 0 dropin-base <# u#s u#> " /" begin-package
" flash" device-name
-[ifdef] addresses-assigned dropin-size [else] h# 4.0000 [then]
+ h# 10.0000
dup value /device
constant /device-phys
my-address my-space /device-phys reg
Modified: cpu/x86/pc/olpc/fw.bth
===================================================================
--- cpu/x86/pc/olpc/fw.bth 2007-07-24 20:33:58 UTC (rev 494)
+++ cpu/x86/pc/olpc/fw.bth 2007-07-25 01:58:15 UTC (rev 495)
@@ -64,6 +64,7 @@
dev /
1 encode-int " #address-cells" property
+1 encode-int " #size-cells" property
" OLPC" encode-string " architecture" property
device-end
@@ -378,6 +379,8 @@
fload ${BP}/dev/olpc/keyboard/selftest.fth \ Keyboard diagnostic
fload ${BP}/dev/olpc/touchpad/touchpad.fth \ Touchpad diagnostic
fload ${BP}/dev/olpc/kb3700/battery.fth \ Battery status reports
+fload ${BP}/cpu/x86/pc/olpc/copynand.fth
+fload ${BP}/cpu/x86/pc/olpc/crypto.fth \ Cryptographic image validation
[then]
\ Eliminate 4 second delay in install console for the case where
@@ -546,6 +549,7 @@
?start-sound
['] false to interrupt-auto-boot?
probe-usb
+ " nand" $dev-update-flash
interpreter-init
[ifndef] lx-devel
enable-power-button
@@ -573,7 +577,9 @@
quit
;
-fload ${BP}/cpu/x86/pc/olpc/copynand.fth
+: newrom
+ " flash http:\\10.20.0.109\new.rom" eval
+;
\ This helps with TeraTerm, which sends ESC-O as the arrow key prefix
also hidden also keys-forth definitions
Modified: cpu/x86/pc/olpc/pcinode.fth
===================================================================
--- cpu/x86/pc/olpc/pcinode.fth 2007-07-24 20:33:58 UTC (rev 494)
+++ cpu/x86/pc/olpc/pcinode.fth 2007-07-25 01:58:15 UTC (rev 495)
@@ -1,7 +1,7 @@
\ See license at end of file
purpose: PCI bus package
-0 [if] addresses-assigned
+0 [if]
\ Suppress PCI address assignment; use the addresses the BIOS assigned
patch false true master-probe
patch noop assign-all-addresses prober
@@ -13,6 +13,7 @@
patch or-w! my-w! find-fcode?
patch 2drop my-w! find-fcode?
[then]
+
[ifdef] addresses-assigned
\ patch false true master-probe
: nonvirtual-probe-state? ( -- flag )
@@ -61,7 +62,7 @@
[ifdef] lx-devel
" 2,3,4,5,6,7,8,9,a,b,c,d,e,f" exit
[then]
- " c,f"
+ " 1,c,f"
;
\ " c,f" dup config-string pci-probe-list
@@ -100,6 +101,45 @@
drop h# 3c + config-b@ true
;
+0 value interrupt-parent
+
+1 " #interrupt-cells" integer-property
+0 0 encode-bytes 0000.ff00 +i 0+i 0+i 7 +i " interrupt-map-mask" property
+
+: +map ( adr len dev# int-pin# int-level -- adr' len' )
+ >r >r ( $ dev# R: level pin )
+ +i ( $' R: level pin )
+ 0+i 0+i r> +i ( $' R: level )
+ interrupt-parent +i ( $' R: level )
+ r> +i 0 +i ( $' ) \ 0 is active low, level senstive for ISA
+;
+
+external
+
+: make-interrupt-map ( -- )
+ " /isa/interrupt-controller" find-package 0= if exit then to interrupt-parent
+
+ 0 0 encode-bytes ( prop$ )
+
+ h# 10000 0 do ( prop$ )
+ i h# 3d + config-b@ ( prop$ pin# )
+ dup 0<> over h# ff <> and if ( prop$ pin# )
+ i h# 3c + config-b@ ( prop$ pin# level )
+ i -rot +map ( prop$' )
+ else ( prop$ pin# )
+ drop ( prop$ )
+ then ( prop$ )
+ h# 100 +loop ( prop$ )
+ " interrupt-map" property ( )
+;
+
+also known-int-properties definitions
+\ In some systems the number of interrupt-map ints is variable,
+\ but on OLPC, the only node with an interrupt-map is PCI.
+: interrupt-map 7 ;
+: interrupt-map-mask 4 ;
+previous definitions
+
\ Just use the global versions
warning @ warning off
: config-b@ ( config-adr -- b ) config-b@ ;
Modified: dev/geode/ac97/ac97.fth
===================================================================
--- dev/geode/ac97/ac97.fth 2007-07-24 20:33:58 UTC (rev 494)
+++ dev/geode/ac97/ac97.fth 2007-07-25 01:58:15 UTC (rev 495)
@@ -12,9 +12,9 @@
d# 16 encode-int " sample-frame-size" property
\ frame-rate encode-int " input-frame-rates" property
\ frame-rate encode-int " output-frame-rates" property
-" 16bit-LE-unsigned-linear" 2dup encode-string " input-encoding-types" property
+" 16bit-LE-signed-linear" 2dup encode-string " input-encoding-types" property
encode-string " output-encoding-types" property
-" AC97,CODEC" encode-string " compatible" property
+" AD1888" encode-string " AC97,CODEC" encode-string encode+ " compatible" property
d# 128 constant /chipbase
Modified: dev/geode/display/gxfb.fth
===================================================================
--- dev/geode/display/gxfb.fth 2007-07-24 20:33:58 UTC (rev 494)
+++ dev/geode/display/gxfb.fth 2007-07-25 01:58:15 UTC (rev 495)
@@ -541,7 +541,7 @@
h# 0f color@ h# ff color! \ Set color ff to white (same as 15)
;
-: init ( -- ) \ Initializes the controller
+: init-all ( -- ) \ Initializes the controller
smb-init
map-io-regs \ Enable IO registers
init-controller \ Setup the video controller
@@ -566,7 +566,7 @@
0 0 encode-bytes " iso6429-1983-colors" property
: display-install ( -- )
- init
+ init-all
default-font set-font
/scanline bytes/pixel / #scanlines ( width height )
over char-width / over char-height / ( width height rows cols )
Modified: dev/geode/display/gxpci.fth
===================================================================
--- dev/geode/display/gxpci.fth 2007-07-24 20:33:58 UTC (rev 494)
+++ dev/geode/display/gxpci.fth 2007-07-25 01:58:15 UTC (rev 495)
@@ -30,6 +30,13 @@
: (map-frame-buffer) ( -- adr )
h# 10 h# 80.0000 map-membar
;
+
+\ This is called during probing by make-function-node
+: init ( -- )
+ " make-compatible-property" my-parent ihandle>phandle find-method if execute then
+ " make-power-property" my-parent ihandle>phandle find-method if execute then
+;
+
\ LICENSE_BEGIN
\ Copyright (c) 2006 FirmWorks
\
Modified: dev/i8042.fth
===================================================================
--- dev/i8042.fth 2007-07-24 20:33:58 UTC (rev 494)
+++ dev/i8042.fth 2007-07-25 01:58:15 UTC (rev 495)
@@ -26,7 +26,7 @@
[then]
\ 0 means the keyboard port, 1 means the aux port
-: encode-unit ( n -- adr len ) if " aux" else " " then ;
+: encode-unit ( n -- adr len ) if " aux" else " kbd" then ;
: decode-unit ( adr len -- n ) " aux" $= 0= if 0 else 1 then ;
\ Queues for distributing bytes sent from the two devices
Modified: dev/mmc/sdhci/sdhci.fth
===================================================================
--- dev/mmc/sdhci/sdhci.fth 2007-07-24 20:33:58 UTC (rev 494)
+++ dev/mmc/sdhci/sdhci.fth 2007-07-25 01:58:15 UTC (rev 495)
@@ -15,6 +15,8 @@
0 " #address-cells" integer-property
0 " #size-cells" integer-property
+" sdhci" " compatible" string-property
+
h# 4000 constant /regs
: phys+ encode-phys encode+ ;
Modified: dev/mmc/sdhci/sdmmc.fth
===================================================================
--- dev/mmc/sdhci/sdmmc.fth 2007-07-24 20:33:58 UTC (rev 494)
+++ dev/mmc/sdhci/sdmmc.fth 2007-07-25 01:58:15 UTC (rev 495)
@@ -3,6 +3,7 @@
" disk" device-name
" sdmmc" " iconname" string-property
+" block" device-type
0 instance value label-package
Modified: dev/olpc/cafecamera/cafecamera.fth
===================================================================
--- dev/olpc/cafecamera/cafecamera.fth 2007-07-24 20:33:58 UTC (rev 494)
+++ dev/olpc/cafecamera/cafecamera.fth 2007-07-25 01:58:15 UTC (rev 495)
@@ -7,6 +7,8 @@
" camera" device-name
" olpc,camera" model
" camera" device-type
+" olpc,camera" " compatible" string-property
+" OV7670" " sensor" string-property
h# 4000 constant /regs
Modified: dev/olpc/cafenand/cafenand.fth
===================================================================
--- dev/olpc/cafenand/cafenand.fth 2007-07-24 20:33:58 UTC (rev 494)
+++ dev/olpc/cafenand/cafenand.fth 2007-07-25 01:58:15 UTC (rev 495)
@@ -3,7 +3,7 @@
" nandflash" device-name
" olpc,cafenand" model
-" disk" device-type
+" olpc,cafenand" " compatible" string-property
h# 4000 constant /regs
Modified: dev/pci/isa.fth
===================================================================
--- dev/pci/isa.fth 2007-07-24 20:33:58 UTC (rev 494)
+++ dev/pci/isa.fth 2007-07-25 01:58:15 UTC (rev 495)
@@ -6,6 +6,9 @@
" isa" device-name
" isa" device-type
+2 " #address-cells" integer-property
+1 " #size-cells" integer-property
+
my-address my-space encode-phys 0 encode-int encode+ h# 0 encode-int encode+
" reg" property
Modified: dev/pci/isaall.fth
===================================================================
--- dev/pci/isaall.fth 2007-07-24 20:33:58 UTC (rev 494)
+++ dev/pci/isaall.fth 2007-07-25 01:58:15 UTC (rev 495)
@@ -3,7 +3,7 @@
fload ${BP}/dev/pci/isacom.fth \ Serial ports
-[ifndef] no-lpt
+[ifndef] no-lpt-node
0 0 " i378" " /isa" begin-package
fload ${BP}/dev/pci/isalpt.fth \ Parallel port
end-package
Modified: dev/pci/isamisc.fth
===================================================================
--- dev/pci/isamisc.fth 2007-07-24 20:33:58 UTC (rev 494)
+++ dev/pci/isamisc.fth 2007-07-25 01:58:15 UTC (rev 495)
@@ -15,7 +15,9 @@
0 1 10 encode-reg
80 1 20 encode-reg encode+
c0 1 20 encode-reg encode+
-[ifndef] isa-dma-only
+[ifdef] isa-dma-only
+ 481 1 f encode-reg encode+ \ High page registers
+[else]
[ifdef] PREP
40a 1 2 encode-reg encode+ \ AIX wants this
[else]
@@ -91,9 +93,7 @@
" pnpPNP,0" " compatible" string-property
20 1 2 encode-reg a0 1 2 encode-reg encode+
-[ifndef] basic-isa
4d0 1 2 encode-reg encode+
-[then]
" reg" property
fload ${BP}/dev/i8259.fth
Modified: dev/pcibus.fth
===================================================================
--- dev/pcibus.fth 2007-07-24 20:33:58 UTC (rev 494)
+++ dev/pcibus.fth 2007-07-25 01:58:15 UTC (rev 495)
@@ -40,8 +40,6 @@
headers
" pci" encode-string " name" property
-7 encode-int " scsi-initiator-id" property
-
\ There are no visible PCI registers
\ my-address encode-int /pci-regs encode-int encode+ " reg" property