Author: wmb
Date: Tue Nov 29 01:26:22 2011
New Revision: 2707
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2707
Log:
Initial revision of Newton files
Added:
cpu/x86/pc/newton/
cpu/x86/pc/newton/addrs.fth
cpu/x86/pc/newton/build/
cpu/x86/pc/newton/build/Makefile
cpu/x86/pc/newton/config.fth
cpu/x86/pc/newton/coskernel.fth
cpu/x86/pc/newton/disptest.fth
cpu/x86/pc/newton/fw.bth
cpu/x86/pc/newton/ofw.bth
cpu/x86/pc/newton/pcinode.fth
cpu/x86/pc/newton/probemem.fth
cpu/x86/pc/newton/reset.bth
cpu/x86/pc/newton/spiui.fth
cpu/x86/pc/newton/start.bth
cpu/x86/pc/newton/testicons.bth
cpu/x86/pc/newton/testicons.tgz
cpu/x86/pc/newton/testitems.fth
cpu/x86/pc/newton/usb.fth
cpu/x86/pc/newton/vstest.fth
cpu/x86/pc/newton/yuv2rgb.fth
Added: cpu/x86/pc/newton/addrs.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/x86/pc/newton/addrs.fth Tue Nov 29 01:26:22 2011 (r2707)
@@ -0,0 +1,56 @@
+\ See license at end of file
+purpose: Establish address and I/O configuration definitions
+
+\ Dropin-base is where the set of dropin modules, the verbatim
+\ image of what is stored in ROM or on disk, ends up in memory.
+\ If OFW is in FLASH, dropin-base can just be the FLASH address.
+\ If OFW is pulled in from disk, dropin-base is where the very
+\ early startup code - the first few instructions in the image -
+\ copies it to get it out of the way of things like OS load areas.
+
+h# 198.0000 constant dropin-base \ Location of payload in RAM
+dropin-base h# 20 + constant ResetBase \ Location of "reset" dropin in RAM
+h# 8.0000 constant dropin-size
+
+\needs fw-pa h# 0f00.0000 constant fw-pa \ OFW dictionary location
+\needs /fw-ram h# 20.0000 constant /fw-ram
+
+\needs heap-base h# 0f20.0000 constant heap-base \ Dynamic allocation heap
+\needs heap-size h# 20.0000 constant heap-size
+
+\needs dma-base h# 0ee0.0000 constant dma-base \ DMA heap
+\needs dma-size h# 20.0000 constant dma-size
+
+\ Where OFW initially loads an OS that is is going to boot
+
+h# 100.0000 constant def-load-base \ Convenient for initrd
+
+fload ${BP}/cpu/x86/pc/virtaddr.fth
+
+[ifdef] virtual-mode
+h# 3 constant pte-control \ Page table entry attributes
+[then]
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2006 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
Added: cpu/x86/pc/newton/build/Makefile
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/x86/pc/newton/build/Makefile Tue Nov 29 01:26:22 2011 (r2707)
@@ -0,0 +1,35 @@
+OS := $(shell uname)
+
+CPUDIR=../../..
+BASEDIR := $(shell cd ${CPUDIR}/../..; pwd;)
+TAGFILES= ${CPUDIR}/build/*.tag *.tag
+CLIENTDIR=${BASEDIR}/clients
+CLIENTPROGS=
+
+all: ofw.elf tags
+
+fw.tag: ofw.elf
+
+tags: fw.tag
+ @${BASEDIR}/forth/lib/toctags ${BASEDIR} ${TAGFILES}
+
+ofw.elf: FORCE build ../../../build/inflate.bin ${CLIENTPROGS}
+ ./build $@
+
+../../../${OS}/forth:
+ @make -C ../../../${OS} forth
+
+../../../build/inflate.bin:
+ @make -C ../../../build inflate.bin
+
+build: ../../../${OS}/forth
+ @ln -sf ../../../${OS}/forth build
+
+clean:
+ rm -f *.dic *.log headers *~ *.elf *.di *.img builton.fth build *.rom *.version *.bin *.tag tags
+
+clean-all: clean
+ @make -C ../../../build clean
+ @make -C ../../../${OS} clean
+
+.PHONY: FORCE clean all clean-all
Added: cpu/x86/pc/newton/config.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/x86/pc/newton/config.fth Tue Nov 29 01:26:22 2011 (r2707)
@@ -0,0 +1,69 @@
+purpose: Configuration setting for OFW as a Coreboot payload on Samsung "Newton" Chromebook
+\ See license at end of file
+
+\ h# e0401000 constant mem-uart-base
+
+create coreboot-loaded
+create coreboot-qemu
+\ create debug-startup
+
+create use-timestamp-counter
+create use-tsc-timing
+
+\ create use-vesa
+create use-ega
+\ create serial-console
+
+\ In virtual mode, OFW runs with the MMU on. The advantages are
+\ that OFW can automatically locate itself out of the way, at the
+\ top of physical memory, it can dynamically allocate exactly as
+\ much physical memory as it needs, and it can remain alive after
+\ the OS starts. The disadvantage is that it is more confusing -
+\ you always have to be aware of the distinction between virtual
+\ and physical addresses.
+
+\ If you use virtual mode for Linux, you can debug past
+\ the point where Linux starts using the MMU. It is not strictly
+\ necessary to use virtual mode if you just want to boot Linux
+\ and then have OFW disappear.
+
+\ create virtual-mode
+
+\ linux-support includes a bzImage file-format handler
+\ and ext2 filesystem support
+
+create linux-support
+
+\ create pseudo-nvram
+create resident-packages
+create addresses-assigned \ Don't reassign PCI addresses
+create no-floppy-node
+create no-lpt-node
+create no-com1-node
+create no-com2-node
+
+fload ${BP}/cpu/x86/pc/newton/addrs.fth
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2011 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
Added: cpu/x86/pc/newton/coskernel.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/x86/pc/newton/coskernel.fth Tue Nov 29 01:26:22 2011 (r2707)
@@ -0,0 +1,47 @@
+
+h# 10000 constant /kbuf
+0 value kbuf
+
+: alloc-kbuf ( -- ) /kbuf alloc-mem to kbuf ;
+: free-kbuf ( -- ) kbuf /kbuf free-mem 0 to kbuf ;
+
+: get-kparams ( name$ -- )
+ open-dev ?dup 0= if exit then >r ( r: ih )
+ kbuf /kbuf " read" r@ $call-method ( r: ih )
+ r> close-dev
+;
+
+: .keydata ( adr len -- )
+ over 6 cdump ( adr len )
+ ." ... " ( adr len )
+ 2dup + 6 - 6 cdump ( adr len )
+ nip ." (0x" .x ." bytes)" cr ( )
+;
+
+: .signature ( adr -- )
+ dup x@ x>u ( adr offset )
+ over + ( adr sig-adr )
+ swap x@ x>u ( sig-adr sig-len )
+ .keydata ( )
+;
+
+string-array algorithm-names
+," RSA1024 SHA1"
+," RSA1024 SHA256"
+," RSA1024 SHA512"
+," RSA2048 SHA1"
+," RSA2048 SHA256"
+," RSA2048 SHA512"
+," RSA4096 SHA1"
+," RSA4096 SHA256"
+," RSA4096 SHA512"
+," RSA8192 SHA1"
+," RSA8192 SHA256"
+," RSA8192 SHA512"
+end-string-array
+
+: .key ( adr -- )
+ dup .signature ( adr )
+ ." Ver " over h# 18 + x@ x>u .x ( adr )
+ h# 10 + x@ x>u algorithm-names count type ( )
+;
Added: cpu/x86/pc/newton/disptest.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/x86/pc/newton/disptest.fth Tue Nov 29 01:26:22 2011 (r2707)
@@ -0,0 +1,236 @@
+purpose: Display test
+\ See license at end of file
+
+\needs final-test? 0 value final-test?
+\needs smt-test? 0 value smt-test?
+
+dev /display
+
+d# 100 constant bar-int
+h# 7 constant test-colors16-mask
+create test-colors16
+\ white magenta yellow red green blue cyan black
+ ffff w, f81f w, ffe0 w, f800 w, 07e0 w, 001f w, 07ff w, 0000 w,
+
+: fill-rect ( -- ) " fill-rectangle" $call-screen ;
+: dimens ( -- w h ) " dimensions" $call-screen ;
+: ht ( -- h ) " height" $call-screen ;
+: wth ( -- w ) " width" $call-screen ;
+
+: whole-screen ( -- x y w h ) 0 0 dimens ;
+
+: black-screen ( -- ) 0 whole-screen fill-rect ;
+
+: test-color16 ( n -- color )
+ test-colors16 swap bar-int / test-colors16-mask and wa+ w@
+;
+: .horizontal-bars16 ( -- )
+ dimens ( width height )
+ 0 ?do ( width )
+ i test-color16 0 i 3 pick bar-int fill-rect
+ bar-int +loop drop
+;
+: .vertical-bars16 ( -- )
+ dimens ( width height )
+ swap 0 ?do ( height )
+ i test-color16 i 0 bar-int 4 pick fill-rect
+ bar-int +loop drop
+;
+
+instance variable rn \ Random number
+d# 5,000 constant burnin-time \ 5 seconds
+
+: random ( -- n )
+ rn @ d# 1103515245 * d# 12345 + h# 7FFFFFFF and dup rn !
+;
+
+: randomize-color ( -- c )
+ random h# 1f and d# 11 <<
+ random h# 3f and d# 5 << or
+ random h# 1f and or
+;
+: randomize-xy ( -- x y )
+ dimens ( width height )
+ random 3ff and min swap ( y width )
+ random 7ff and min swap ( x y )
+;
+: randomize-wh ( x y -- w h )
+ dimens ( x y width height )
+ rot - -rot ( max-h x width )
+ swap - swap ( max-w max-h )
+ randomize-xy ( max-w max-h w h )
+ rot min -rot min swap ( w' h' )
+;
+: .random-rect ( -- )
+ randomize-color ( c )
+ randomize-xy ( c x y )
+ 2dup randomize-wh ( c x y w h )
+ " fill-rectangle" $call-screen ( )
+;
+
+: random-selftest ( -- )
+ get-msecs rn !
+ get-msecs burnin-time + ( limit )
+ begin
+ get-msecs over u< ( limit reached? )
+ while ( limit )
+ .random-rect ( limit )
+ key? if key 2drop exit then
+ repeat ( limit )
+ drop
+;
+
+0 value xbias
+0 value ybias
+0 value hstripe
+0 value vstripe
+: set-stripes ( -- )
+ wth d# 256 / to hstripe
+ ht d# 256 / to vstripe
+ wth hstripe d# 256 * - to xbias
+ ht vstripe d# 256 * - to ybias
+;
+: half-bias ( -- ) xbias 2/ to xbias ybias 2/ to ybias ;
+: gvsr ( -- )
+ set-stripes half-bias black-screen ( )
+ d# 256 0 do ( )
+ d# 256 0 do ( )
+ i j 0 rgb>565 ( color )
+ hstripe i * xbias + ( color x )
+ vstripe j * ybias + ( color x y )
+ hstripe vstripe ( color x y w h )
+ fill-rect
+ loop
+ loop
+;
+: gvsb ( -- )
+ set-stripes half-bias black-screen ( )
+ d# 256 0 do ( )
+ d# 256 0 do ( )
+ 0 j i rgb>565 ( color )
+ hstripe i * xbias + ( color x )
+ vstripe j * ybias + ( color x y )
+ hstripe vstripe ( color x y )
+ fill-rect
+ loop
+ loop
+;
+: hgradient ( -- )
+ set-stripes black-screen ( )
+ d# 256 0 do ( )
+ i i i rgb>565 ( color )
+ hstripe i * xbias + 0 ( color x y )
+ hstripe ht ( color x y sw h )
+ fill-rect ( )
+ loop ( )
+;
+
+: vgradient ( -- )
+ set-stripes black-screen ( )
+ d# 256 0 do ( )
+ i i i rgb>565 ( color )
+ 0 vstripe i * ybias + ( color x y )
+ wth vstripe ( color x y w sh )
+ fill-rect ( )
+ loop ( )
+;
+
+
+h# ff h# ff h# ff rgb>565 constant white-color
+
+: hline ( y -- ) >r white-color 0 r> wth 1 fill-rect ;
+: vline ( y -- ) >r white-color r> 0 1 ht fill-rect ;
+
+: crosshatch ( -- )
+ black-screen
+ ht 0 do i hline d# 10 +loop
+ wth 0 do i vline d# 10 +loop
+;
+: short-wait ( -- ) smt-test? if d# 250 ms else d# 500 ms then ;
+: brightness-ramp ( -- )
+ 0 h# 0f do i bright! short-wait -1 +loop
+ backlight-off short-wait backlight-on
+ h# f bright!
+;
+
+: red-screen ( -- )
+ load-base whole-screen " read-rectangle" $call-screen
+ h# ff 00 00 rgb>565 whole-screen fill-rect
+ d# 1000 ms
+ load-base whole-screen fill-rect
+;
+: hold-time ( -- )
+ smt-test? if
+ d# 500 ms
+ else
+ final-test? if d# 500 ms else d# 1000 ms then
+ then
+;
+
+: hold-time2 ( -- )
+ smt-test? if
+ d# 500 ms
+ else
+ final-test? if key drop then
+ d# 1000 ms
+ then
+;
+: wait ( -- )
+ hold-time
+\ 0 set-source \ Freeze image
+ hold-time
+\ 1 set-source \ Unfreeze image
+ hold-time2
+;
+
+warning @ warning off
+: selftest ( -- error? )
+ depth d# 16 < if false exit then
+ smt-test? 0= if
+ .horizontal-bars16 wait
+ .vertical-bars16 wait
+ then
+ gvsr wait
+ gvsb wait
+ hgradient wait
+ vgradient wait
+ crosshatch wait
+ brightness-ramp
+
+ smt-test? 0= if
+ burnin-time d# 5000 > if
+ ." Press a key to stop early." cr
+ d# 1000 ms
+ then
+ random-selftest
+ then
+
+ confirm-selftest?
+;
+warning !
+
+device-end
+
+\ 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
Added: cpu/x86/pc/newton/fw.bth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/x86/pc/newton/fw.bth Tue Nov 29 01:26:22 2011 (r2707)
@@ -0,0 +1,351 @@
+\ See license at end of file
+purpose: Build Open Firmware core
+
+dictionary: ${BP}/cpu/x86/build/basefw.dic
+command: &x86forth &dictionary &this
+in: builton.fth
+build-now
+
+" fw.tag" r/w create-file drop tag-file !
+
+hex
+\ ' $report-name is include-hook
+
+fload ${BP}/cpu/x86/pc/newton/config.fth
+
+: headerless ; : headers ; : headerless0 ;
+
+' (quit) to quit
+
+: \Tags [compile] \ ; immediate
+: \NotTags [compile] \ ; immediate
+
+: RAMbase ( -- adr ) fw-virt-base ;
+: RAMtop ( -- adr ) RAMbase /fw-ram + ;
+
+h# 00.0000 value dp-loc \ Set in patchboot
+: stacktop ( -- adr ) RAMtop ;
+: dict-limit ( -- adr ) RAMtop h# 06.0000 - ;
+
+\ XXX What we should do is pass in the top address in SP, and have
+\ boot.fth allocate the user area by subtracting user-size. But
+\ we need some way of finding it again for exception re-entry.
+\ prom-main-task is used in arch/pc/boot.fth . The constant
+\ value is wired into the assembly code
+stacktop user-size - ( fw-virt-base - ) constant prom-main-task \ user area for main task
+
+0 value load-limit \ Top address of area at load-base
+' 2drop to sync-cache
+
+def-load-base ' load-base set-config-int-default
+
+true ' fcode-debug? set-config-int-default
+\ false ' auto-boot? set-config-int-default
+
+" com1" ' output-device set-config-string-default
+" com1" ' input-device set-config-string-default
+
+\ XXX should be loaded by basefw.bth
+fload ${BP}/cpu/x86/initpgm.fth \ Basic boot handler
+fload ${BP}/cpu/x86/msr.fth \ Access to machine specific registers
+
+: (cpu-arch ( -- adr len )
+ " architecture" ['] root-node get-package-property drop
+ get-encoded-string
+;
+' (cpu-arch to cpu-arch
+
+h# 1000 to pagesize
+d# 12 to pageshift
+
+dev /
+1 encode-int " #address-cells" property
+1 encode-int " #size-cells" property
+" Samsung Chromebook Series 5" model
+" PC" encode-string " architecture" property
+
+\ XXX figure out bus frequency. How?
+\ d# 33,333,333 " clock-frequency" integer-property
+device-end
+
+\ 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
+[then]
+fload ${BP}/ofw/core/memlist.fth \ Resource list common routines
+fload ${BP}/ofw/core/showlist.fth \ Linked list display tool
+fload ${BP}/ofw/core/allocph1.fth \ S Physical memory allocator
+fload ${BP}/ofw/core/availpm.fth \ Available memory list
+fload ${BP}/ofw/core/allocmor.fth \ Secondary allocator
+
+fload ${BP}/cpu/x86/pc/rootnode.fth \ Platform-specific root node changes
+dev / " Samsung Chromebook Series 5" " banner-name" string-property dend
+
+fload ${BP}/cpu/x86/pc/isaio.fth
+fload ${BP}/dev/pci/configm1.fth \ Generic PCI configuration access
+
+fload ${BP}/cpu/x86/pc/newton/probemem.fth \ Memory probing
+
+[ifdef] virtual-mode
+fload ${BP}/cpu/x86/loadvmem.fth \ /mmu node
+stand-init: MMU
+ " /mmu" open-dev mmu-node !
+;
+fload ${BP}/cpu/x86/pc/initdict.fth \ Dynamic dictionary allocation
+[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 %ebx to %ecx
+ go
+;
+device-end
+
+fload ${BP}/cpu/x86/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
+
+support-package: zip-file-system
+ fload ${BP}/ofw/fs/zipfs.fth \ Zip file system
+end-support-package
+
+support-package: dropin-file-system
+ fload ${BP}/ofw/fs/dropinfs.fth \ Dropin file system
+end-support-package
+[then]
+
+\ 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 ;
+
+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
+
+\ Reboot and re-entry code
+fload ${BP}/cpu/x86/pc/reboot.fth \ Restart the client program
+fload ${BP}/cpu/x86/pc/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 ) heap-base 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/x86/pc/mmusetup.fth \ Initial values for MMU lists
+[then]
+
+fload ${BP}/cpu/x86/pc/rmtools.fth
+
+fload ${BP}/cpu/x86/pc/newton/devices.fth
+
+true ' local-mac-address? set-config-int-default
+fload ${BP}/ofw/inet/loadtcp.fth
+
+[ifdef] resident-packages
+support-package: nfs
+ fload ${BP}/ofw/fs/nfs/loadpkg.fth
+end-support-package
+[then]
+devalias nfs net//obp-tftp:last//nfs
+
+support-package: http
+ fload ${BP}/ofw/inet/http.fth \ HTTP client
+end-support-package
+
+fload ${BP}/ofw/wifi/wifi-cfg.fth
+support-package: supplicant
+fload ${BP}/ofw/wifi/loadpkg.fth
+end-support-package
+
+fload ${BP}/cpu/x86/pc/boot.fth
+fload ${BP}/cpu/x86/pc/linux.fth
+
+hex
+\ If there is a PCI ethernet adapter, use it as the default net device,
+\ otherwise use any ethernet that can be found in the device tree.
+: report-net ( -- )
+ " /pci/ethernet" 2dup find-package if ( name$ phandle )
+ drop ( name$ )
+ else ( name$ )
+ 2drop " /ethernet" ( name$' )
+ then ( name$ )
+ " net" 2swap $devalias ( )
+;
+
+fload ${BP}/cpu/x86/pc/newton/usb.fth
+
+fload ${BP}/ofw/gui/bmptools.fth
+fload ${BP}/ofw/gui/loadmenu.fth
+d# 1024 d# 768 to max-xy
+patch noop set-menu-colors setup-graphics
+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
+fload ${BP}/cpu/x86/pc/olpc/via/mfgtest.fth
+fload ${BP}/dev/olpc/confirm.fth
+: bright! ( level -- ) drop ;
+: backlight-on ( -- ) ;
+: backlight-off ( -- ) ;
+[ifdef] use-vesa
+fload ${BP}/cpu/x86/pc/newton/disptest.fth
+[then]
+fload ${BP}/cpu/x86/pc/newton/yuv2rgb.fth \ YUV2 to RGB conversion
+fload ${BP}/cpu/x86/pc/newton/vstest.fth \ Video stream test helpers
+
+false to stand-init-debug?
+\ true to stand-init-debug?
+
+hex
+stand-init-debug? [if]
+warning @ warning off
+: init
+\ initial-heap add-memory
+ init
+
+ standalone? if
+ cr ." Type 'i' to interrupt stand-init sequence" cr
+ d# 1000 ms
+ key? if
+ key upc ascii I = if ." Interacting" cr hex interact then
+ then
+ then
+\ cr0@ h# 9fff.ffff and cr0! \ enable L1 and L2 caches
+;
+warning !
+[then]
+
+: (.firmware) ( -- )
+ ." Open Firmware " .built cr
+ ." Copyright 1999 FirmWorks All Rights Reserved" cr
+;
+' (.firmware) to .firmware
+
+: linux-logo ( -- )
+ " penguin.txt" find-drop-in if page type then
+;
+
+: probe-all ( -- )
+ " probe-" do-drop-in
+ probe-pci
+\ report-pci-fb
+ silent-probe-usb
+\ " show-devs /pci" eval begin again
+;
+
+\ This reduces processor use when waiting for a key. It helps
+\ a lot when running on an emulator.
+: c1-idle ( -- ) interrupts-enabled? if halt then ;
+' c1-idle to stdin-idle
+
+: startup ( -- )
+ standalone? 0= if exit then
+
+ use-nvramrc? if nvramrc safe-evaluate then
+
+ auto-banner? if
+ " Probing" ?type probe-all
+ install-mux-io
+[ifndef] serial-console
+ fallback-in-ih remove-input
+ fallback-out-ih remove-output
+[then]
+ banner
+ ?usb-keyboard
+ show-usb
+ then
+
+ hex
+ warning on
+ only forth also definitions
+
+ install-alarm
+
+ #line off
+
+ ." Open Firmware demonstration version by FirmWorks" cr
+
+ ." See "
+ blue-letters ." http://wiki.laptop.org/go/Forth_Lessons" black-letters
+ cr cr
+ ." Type menu to run diagnostics" cr
+
+ quit
+;
+
+fload ${BP}/cpu/x86/pc/watchall.fth
+
+alias crcgen drop ( crc byte -- crc' )
+fload ${BP}/cpu/x86/pc/saveabs.fth
+
+fload ${BP}/forth/lib/selstr.fth
+
+\needs ramdisk " " d# 128 config-string ramdisk
+" console=tty0 console=ttyS0,115200" ' boot-file set-config-string-default
+
+" dhcp" ' ip-address set-config-string-default
+
+: stand-init-io
+ stand-init-io
+;
+
+tag-file @ fclose tag-file off
+
+.( SAVING FW.dic ...)
+" fw.dic" $save-forth cr
+
+.( Saving fw.img ...)
+" fw.img" RAMbase save-abs-rom cr
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2011 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
Added: cpu/x86/pc/newton/ofw.bth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/x86/pc/newton/ofw.bth Tue Nov 29 01:26:22 2011 (r2707)
@@ -0,0 +1,78 @@
+purpose: Construct the final OFW image
+
+command: &builder &this
+in: reset.di
+in: start.di
+in: ${BP}/cpu/x86/pc/newton/build/paging.di
+in: fw.img
+in: ${BP}/dev/usb2/hcd/ohci/build/ohci.fc
+in: ${BP}/dev/usb2/hcd/uhci/build/uhci.fc
+in: ${BP}/dev/usb2/hcd/ehci/build/ehci.fc
+in: ${BP}/dev/usb2/device/hub/build/hub.fc
+in: ${BP}/dev/usb2/device/net/build/usbnet.fc
+in: ${BP}/dev/usb2/device/serial/build/usbserial.fc
+in: ${BP}/dev/usb2/device/storage/build/usbstorage.fc
+in: ${BP}/dev/usb2/device/keyboard/build/usbkbd.fc
+in: ${BP}/dev/usb2/device/webcam/build/webcam.fc
+in: ${BP}/dev/pci/build/pcibridg.fc
+in: ${BP}/dev/ide/build/leghier.fc
+in: testicons.bin
+
+build-now
+
+fload ${BP}/cpu/x86/pc/newton/config.fth
+
+\ Always re-create the builton.fth file when we make a new rom.img
+fload ${BP}/cpu/x86/pc/builton.bth
+
+hex
+
+.( --- Saving as ofw.elf - Coreboot payload format) cr
+fload ${BP}/cpu/x86/pc/elfhdr.fth
+writing ofw.elf
+elf-header /elf-header ofd @ fputs
+
+ " reset.di" $add-file
+ " start.di" $add-file
+ " paging.di" $add-file
+
+ " ${BP}/cpu/x86/build/inflate.bin" " inflate" $add-dropin
+
+ " fw.img" " firmware" $add-deflated-dropin
+\ " fw.img" " firmware" $add-dropin
+
+ " ${BP}/dev/pci/build/pcibridg.fc" " class060400" $add-deflated-dropin
+ " ${BP}/dev/ide/build/leghier.fc" " class01018a" $add-deflated-dropin
+
+ " ${BP}/dev/usb2/hcd/ehci/build/ehci.fc" " class0c0320" $add-deflated-dropin
+ " ${BP}/dev/usb2/hcd/uhci/build/uhci.fc" " class0c0300" $add-deflated-dropin
+
+ " ${BP}/dev/usb2/device/hub/build/hub.fc" " usb,class9" $add-dropin
+ " ${BP}/dev/usb2/device/keyboard/build/usbkbd.fc" " usb,class3,1" $add-dropin
+ " ${BP}/dev/usb2/device/net/build/usbnet.fc" " usbnet" $add-deflated-dropin
+ " ${BP}/dev/usb2/device/serial/build/usbserial.fc" " usbserial" $add-deflated-dropin
+ " ${BP}/dev/usb2/device/storage/build/usbstorage.fc" " usbstorage" $add-deflated-dropin
+ " ${BP}/dev/usb2/device/webcam/build/webcam.fc" " usb,classe,3,0" $add-dropin
+
+ " builton.fth" " probe-" $add-dropin
+ " ${BP}/ofw/fcode/memtest.fth" " memtest.fth" $add-deflated-dropin
+ " ${BP}/ofw/inet/telnetd.fth" " telnetd" $add-deflated-dropin
+ " ${BP}/ofw/termemu/15x30pc.psf" " font" $add-deflated-dropin
+
+ " ${BP}/cpu/x86/pc/newton/build/testicons/audio.565" " audio.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/newton/build/testicons/clock.565" " clock.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/newton/build/testicons/cpu.565" " cpu.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/newton/build/testicons/display.565" " display.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/newton/build/testicons/play.565" " play.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/newton/build/testicons/quit.565" " quit.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/newton/build/testicons/ram.565" " ram.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/newton/build/testicons/spi.565" " spi.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/newton/build/testicons/timer.565" " timer.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/newton/build/testicons/usb.565" " usb.565" $add-deflated-dropin
+ " ${BP}/cpu/x86/pc/newton/build/testicons/wifi.565" " wifi.565" $add-deflated-dropin
+
+ ofd @ fsize pad ! \ file size; store in memory for convenience below
+ h# 44 ofd @ fseek \ Seek to file size field; see elfhdr.bth
+ pad 4 ofd @ fputs \ Patch file size
+ pad 4 ofd @ fputs \ Patch memory size
+ofd @ fclose
Added: cpu/x86/pc/newton/pcinode.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/x86/pc/newton/pcinode.fth Tue Nov 29 01:26:22 2011 (r2707)
@@ -0,0 +1,85 @@
+\ See license at end of file
+purpose: PCI bus package
+
+\ XXX need slot-names property
+[ifdef] notdef
+h# 1000 encode-int " slave-only" property
+h# 1800 encode-int \ Mask of implemented add-in slots
+" PCI-1" encode-string encode+
+" PCI-2" encode-string encode+
+" PCI-3" encode-string encode+
+
+" slot-names" property
+[then]
+
+also forth definitions
+
+" 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,10,11,12,13,14,15,16,17,18,19,1a,1b,1c,1d,1e,1f"
+ dup config-string pci-probe-list
+
+previous definitions
+
+h# 1000.0000 to first-mem \ Avoid RAM at low addresses
+h# 2000.0000 to mem-space-top
+h# 0000.8000 to first-io \ Avoid mappings established by BIOS
+
+\ Configuration mechanism #1 as defined in the PCI spec.
+: config-setup ( config-adr -- vaddr )
+ \ Bit 31 ("enable") must be 1, bits 30:24 ("reserved") must be 0,
+ \ bits 1:0 must be 0.
+ dup h# ff.fffc and h# 8000.0000 or h# cf8 pl! ( config-adr )
+
+ 3 and h# cfc + \ Merge in the byte selector bits
+;
+
+: config-b@ ( config-adr -- b ) config-setup pc@ ;
+: config-w@ ( config-adr -- w ) config-setup pw@ ;
+: config-l@ ( config-adr -- l ) config-setup pl@ ;
+: config-b! ( b config-adr -- ) config-setup pc! ;
+: config-w! ( w config-adr -- ) config-setup pw! ;
+: config-l! ( l config-adr -- ) config-setup pl! ;
+
+: init ( -- ) ;
+
+\ Determine the parent interrupt information (the "interrupt line" in PCI
+\ parlance) from the child's "interrupt pin" and the child's address,
+\ returning "int-line true" if the child's interrupt line register should
+\ be set or "false" otherwise.
+: assign-int-line ( phys.hi.func INTx -- irq true )
+ \ Reiterate the value that is already in the int line register,
+ \ which was presumably placed there by the BIOS
+ drop h# 3c + config-b@ true
+;
+
+\ The io-base handling really ought to be in the root node, but
+\ that would require more changes than I'm willing to do at present.
+warning @ warning off
+: map-out ( vaddr size -- )
+ over io-base u>= if 2drop exit then ( vaddr size )
+ map-out ( )
+;
+warning !
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2011 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
Added: cpu/x86/pc/newton/probemem.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/x86/pc/newton/probemem.fth Tue Nov 29 01:26:22 2011 (r2707)
@@ -0,0 +1,70 @@
+\ See license at end of file
+purpose: Create memory node properties and lists
+
+dev /memory
+
+: /ram ( -- #bytes ) 0 h# b0 config-w@ wljoin ; \ Base of stolen memory
+: usable-ramtop ( -- n ) h# ac config-l@ ; \ Top of usable DRAM
+
+: release-range ( start-adr end-adr -- ) over - release ;
+
+: probe ( -- )
+ 0 /ram reg \ Report extant memory
+
+ \ Release some of the first meg, between the page tables and the DOS hole,
+ \ for use as DMA memory.
+ mem-info-pa 2 la+ l@ h# a.0000 release-range \ Below DOS hole
+
+ h# 10.0000 fw-pa release-range
+ fw-pa /fw-ram + heap-base heap-size + umax usable-ramtop release-range
+;
+
+[ifndef] 8u.h
+: 8u.h ( n -- ) push-hex (.8) type pop-base ;
+[then]
+: .chunk ( adr len -- ) ." Testing memory at: " swap 8u.h ." size " 8u.h cr ;
+defer test-s3 ( -- error? ) ' false is test-s3
+: selftest ( -- error? )
+ " available" get-my-property if ." No available property" cr true exit then
+ ( adr len )
+ begin ?dup while
+ 2 decode-ints swap ( rem$ chunk$ )
+ 2dup .chunk ( rem$ chunk$ )
+ \ We maintain a 1-1 convenience mapping so explicit mapping is unnecessary
+ memory-test-suite if 2drop true exit then ( rem$ )
+ repeat drop
+
+ test-s3
+;
+
+device-end
+
+also forth definitions
+stand-init: Probing memory
+ " probe" memory-node @ $call-method
+;
+previous definitions
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2011 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
Added: cpu/x86/pc/newton/reset.bth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/x86/pc/newton/reset.bth Tue Nov 29 01:26:22 2011 (r2707)
@@ -0,0 +1,97 @@
+\ See license at end of file
+purpose: Dropin dispatcher for i386
+
+command: &builder &this
+build-now
+
+fload ${BP}/cpu/x86/pc/newton/config.fth
+
+\needs start-assembling fload ${BP}/cpu/x86/asmtools.fth
+\needs write-dropin fload ${BP}/forth/lib/mkdropin.fth
+
+fload ${BP}/cpu/x86/mmuparam.fth
+
+hex
+
+fload ${BP}/cpu/x86/pc/finddi.fth \ find-dropin and other tools
+fload ${BP}/cpu/x86/pc/port80.fth \ Port 80 output
+
+h# 3e.0000 constant inflate-base
+h# 30.0000 constant workspace
+
+start-assembling
+
+label my-entry
+ e9 c, 0 , \ To be patched later
+end-code
+
+[ifdef] debug-startup
+fload ${BP}/cpu/x86/pc/dot.fth \ Numeric output
+[then]
+
+fload ${BP}/cpu/x86/pc/ramfind.fth \ find-dropin
+
+label startup
+ h# 10 port80
+ cli cld
+
+ h# 11 port80
+\ h# 80 h# 70 # isa-c! \ Disable NMI
+\ h# 71 # al in \ Why do we do this?
+
+[ifdef] debug-startup
+\ init-com1
+
+carret report
+linefeed report
+ascii F report
+ascii o report
+ascii r report
+[then]
+
+ h# 12 port80
+ " start" $find-dropin, \ Assemble call to find-dropin with literal arg
+ \ What should we do it this fails? Perhaps call a default routine
+ \ to try to initialize com1 and display a message?
+ \ For now, we assume success
+
+ d# 32 # ax add \ Skip dropin header
+ ax call \ Execute the dropin
+ h# 13 port80
+
+ fload ${BP}/cpu/x86/pc/resetend.fth
+end-code
+
+also 386-assembler
+startup my-entry put-branch
+previous
+
+end-assembling
+
+writing reset.di
+asm-base here over - 0 " reset" write-dropin
+ofd @ fclose
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2011 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
Added: cpu/x86/pc/newton/spiui.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/x86/pc/newton/spiui.fth Tue Nov 29 01:26:22 2011 (r2707)
@@ -0,0 +1,179 @@
+\ See license at end of file
+purpose: User interface for reflashing SPI FLASH parts
+
+\ This code is concerned with the user interface for getting
+\ a new firmware image into memory and using it to program
+\ a FLASH device from that image. The details of how to actually
+\ access the FLASH device are defined elsewhere.
+
+h# 4000 constant /chunk \ Convenient sized piece for progress reports
+
+: write-flash-range ( adr end-offset start-offset -- )
+ ." Writing" cr
+ ?do ( adr )
+ \ Save time - don't write if the data is the same
+ i .x (cr ( adr )
+ spi-us d# 20 >= if ( adr )
+ \ Just write if reading is slow
+ true ( adr must-write? )
+ else ( adr )
+ dup /flash-block i flash-verify ( adr must-write? )
+ then ( adr must-write? )
+
+ if
+ i flash-erase-block
+ dup /flash-block i flash-write ( adr )
+ then
+ /flash-block + ( adr' )
+ /flash-block +loop ( adr )
+ cr drop ( )
+;
+
+: verify-flash-range ( adr end-offset start-offset -- )
+ ." Verifying" cr
+ ?do ( adr )
+ i .x (cr
+ dup /flash-block i flash-verify abort" Verify failed"
+ /flash-block + ( adr' )
+ /flash-block +loop ( adr )
+ cr drop ( )
+;
+
+
+\ Perform a series of sanity checks on the new firmware image.
+
+[ifdef] load-base
+: flash-buf load-base ;
+[else]
+/flash buffer: flash-buf
+[then]
+
+0 value file-loaded?
+
+: -cbid ( offset -- ) flash-buf /flash + swap - ;
+
+: check-id-string ( offset expect$ -- )
+ rot -cbid @ -cbid cscount ( expect$ got$ )
+ 2over 2over $= 0= if ( expect$ got$ )
+ ." Expecting " 2swap type ." , got " type cr
+ abort
+ then ( expect$ got$ )
+ 4drop ( )
+;
+: ?coreboot-id ( -- )
+ h# 14 -cbid @ /flash <> abort" Coreboot flash size mismatch"
+ h# 1c " SAMSUNG" check-id-string
+ h# 18 " Stumpy" check-id-string
+;
+: ?cbfs ( -- )
+ flash-buf " LARCHIVE" comp abort" Image file is not in CBFS format"
+ \ We could also check the integrity of the CBFS headers
+;
+
+: ?image-valid ( len -- )
+ /flash <> abort" Image file is the wrong length"
+
+ ?cbfs
+ ?coreboot-id
+;
+
+: $get-file ( "filename" -- )
+ $read-open
+ flash-buf /flash ifd @ fgets ( len )
+ ifd @ fclose
+
+ ?image-valid
+
+ true to file-loaded?
+;
+
+: ?file ( -- )
+ file-loaded? 0= if
+ ." You must first load a valid FLASH image file with" cr
+ ." get-file filename" cr
+ abort
+ then
+;
+
+: read-flash ( "filename" -- )
+ writing
+ /flash 0 do
+ i .x (cr
+ flash-buf i + /chunk i flash-read
+ /chunk +loop
+ flash-buf /flash ofd @ fputs
+ ofd @ fclose
+;
+
+: verify ( -- ) ?file flash-buf /flash 0 verify-flash-range ;
+
+: verify-firmware ( -- )
+ flash-buf /flash 0 verify-flash-range \ Verify first part
+;
+
+: write-firmware ( -- )
+ flash-buf /flash 0 write-flash-range \ Write first part
+;
+
+: reflash ( -- ) \ Flash from data already in memory
+ ?file
+ flash-write-enable
+
+ write-firmware
+
+ ['] verify-firmware catch if
+ ." Verify failed. Retrying once" cr
+ spi-identify
+ write-firmware
+ verify-firmware
+ then
+ flash-write-disable
+;
+
+defer fw-filename$ ' null$ to fw-filename$
+
+: get-file ( ["filename"] -- )
+ parse-word ( adr len )
+ dup 0= if 2drop fw-filename$ then ( adr len )
+ ." Reading " 2dup type cr ( adr len )
+ $get-file
+;
+
+: flash ( ["filename"] -- ) get-file ?enough-power reflash ;
+: flash! ( ["filename"] -- ) get-file reflash ;
+
+: safe-flash-read ( -- )
+ flash-buf /flash 0 flash-read
+;
+
+dev /flash
+: selftest ( -- error? )
+ .cbfs
+ d# 2000 ms \ More time to inspect
+ false
+;
+device-end
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2011 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
Added: cpu/x86/pc/newton/start.bth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/x86/pc/newton/start.bth Tue Nov 29 01:26:22 2011 (r2707)
@@ -0,0 +1,67 @@
+\ See license at end of file
+purpose: Low-level startup code
+
+command: &builder &this
+build-now
+
+\needs start-assembling fload ${BP}/cpu/x86/asmtools.fth
+\needs write-dropin fload ${BP}/forth/lib/mkdropin.fth
+
+hex
+
+fload ${BP}/cpu/x86/pc/newton/config.fth
+
+fload ${BP}/cpu/x86/pc/report.fth \ Startup reports
+
+start-assembling
+
+label my-entry
+[ifdef] debug-startup
+ e9 c, 0 , \ To be patched later
+end-code
+
+fload ${BP}/cpu/x86/pc/dot.fth \ Numeric display
+[then]
+
+label startup
+[ifdef] debug-startup
+\ ascii x report
+[then]
+ ret
+end-code
+
+[ifdef] debug-startup
+also 386-assembler
+startup my-entry put-branch
+previous
+[then]
+
+end-assembling
+
+writing start.di
+asm-base here over - 0 " start" write-dropin
+ofd @ fclose
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2011 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
Added: cpu/x86/pc/newton/testicons.bth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/x86/pc/newton/testicons.bth Tue Nov 29 01:26:22 2011 (r2707)
@@ -0,0 +1,11 @@
+purpose: Expand the test icons
+
+command: &builder &this
+build-now
+
+" tar xfz ../testicons.tgz" expand$ $sh
+
+\ This forces the creation of a .log file, so we don't re-fetch
+writing testicons.version
+" 1" ofd @ fputs
+ofd @ fclose
Added: cpu/x86/pc/newton/testicons.tgz
==============================================================================
Files /dev/null 00:00:00 1970 (empty, because file is newly added) and cpu/x86/pc/newton/testicons.tgz Tue Nov 29 01:26:22 2011 (r2707) differ
Added: cpu/x86/pc/newton/testitems.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/x86/pc/newton/testitems.fth Tue Nov 29 01:26:22 2011 (r2707)
@@ -0,0 +1,105 @@
+purpose: Platform-specific layout of diagnostic GUI menu items
+
+d# 6 to #mfgcols
+d# 4 to #mfgrows
+
+: dummy-test-dev ( $ -- )
+ clear-n-restore-scroller
+ ??cr ." Testing " type ." - to be implemented" cr
+ mfg-color-green sq-border!
+ d# 2000 hold-message drop
+ cursor-off gui-alerts refresh
+ flush-keyboard
+;
+
+: mfg-test-disk ( name$ -- )
+ clear-n-restore-scroller
+ ??cr ." Testing " 2dup type cr
+
+ ['] $.partitions catch if
+ 2drop false
+ else
+ 0 true
+ then
+
+ d# 2000 ms \ More time to inspect
+
+ mfg-test-result
+;
+
+icon: play.icon rom:play.565
+icon: quit.icon rom:quit.565
+icon: cpu.icon rom:cpu.565
+icon: spi.icon rom:spi.565
+icon: ram.icon rom:ram.565
+icon: sdcard.icon rom:sdcard.565
+icon: usb.icon rom:usb.565
+icon: wifi.icon rom:wifi.565
+icon: audio.icon rom:audio.565
+icon: display.icon rom:display.565
+icon: timer.icon rom:timer.565
+icon: clock.icon rom:clock.565
+icon: leds.icon rom:leds.565
+
+: cpu-item ( -- ) " /cpu" mfg-test-dev ;
+: spiflash-item ( -- ) " /flash" mfg-test-dev ;
+: memory-item ( -- ) " /memory" mfg-test-dev ;
+: usb-item ( -- ) " /usb" mfg-test-dev ;
+: int-sd-item ( -- ) " disk" mfg-test-disk ;
+\ : ext-sd-item ( -- ) " ext:0" mfg-test-dev ;
+: rtc-item ( -- ) " /rtc" mfg-test-dev ;
+: display-item ( -- ) " screen" mfg-test-dev ;
+: audio-item ( -- ) " /audio" dummy-test-dev ;
+: camera-item ( -- ) " /camera" mfg-test-dev ;
+: wlan-item ( -- ) " /wlan" dummy-test-dev ;
+: timer-item ( -- ) " /timer" mfg-test-dev ;
+: touchpad-item ( -- ) " /mouse" mfg-test-dev ;
+: keyboard-item ( -- ) " /keyboard" mfg-test-dev ;
+: switch-item ( -- ) " /switches" mfg-test-dev ;
+: leds-item ( -- ) " /leds" mfg-test-dev ;
+
+: newton-test-menu-items ( -- )
+ silent-probe-usb
+
+ 0 to #mfgtests
+ 0 1 set-col-row
+
+ " CPU"
+ ['] cpu-item cpu.icon add-icon
+
+ " SPI Flash: Contains EC code, firmware, manufacturing data."
+ ['] spiflash-item spi.icon add-icon
+
+ " RAM chips"
+ ['] memory-item ram.icon add-icon
+
+ " Internal mass storage"
+ ['] int-sd-item sdcard.icon add-icon
+
+ " Timer"
+ ['] timer-item timer.icon add-icon
+
+ " RTC (Real-Time Clock)"
+ ['] rtc-item clock.icon add-icon
+
+ " Display"
+ ['] display-item display.icon add-icon
+
+ " Audio: Speaker and microphone"
+ ['] audio-item audio.icon add-icon
+
+ " Wireless LAN"
+ ['] wlan-item wifi.icon add-icon
+
+ " USB ports"
+ ['] usb-item usb.icon add-icon
+
+ \ These are last because they require user participation.
+ \ The earlier tests are all included in automatic batch-mode.
+
+\ " LEDs"
+\ ['] leds-item leds.icon add-icon
+
+;
+
+' newton-test-menu-items to test-menu-items
Added: cpu/x86/pc/newton/usb.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/x86/pc/newton/usb.fth Tue Nov 29 01:26:22 2011 (r2707)
@@ -0,0 +1,143 @@
+purpose: Platform-specific USB elaborations
+\ See license at end of file
+
+0 config-int usb-delay \ Milliseconds to wait before set-address
+
+devalias u /usb/disk
+
+\ Like $show-devs, but ignores pagination keystrokes
+: $nopage-show-devs ( nodename$ -- )
+ ['] exit? behavior >r ['] false to exit?
+ $show-devs
+ r> to exit?
+;
+
+: (probe-usb2) ( -- )
+ " device_type" get-property if exit then
+[ifdef] use-usb-debug-port
+ \ I haven't figured out how to turn on the EHCI cleanly
+ \ when the Debug Port is running
+ dbgp-off
+[then]
+ get-encoded-string " ehci" $= if
+ pwd$ open-dev ?dup if close-dev then
+ then
+;
+: (show-usb2) ( -- )
+ " device_type" get-property if exit then
+ get-encoded-string " ehci" $= if
+ pwd$ $nopage-show-devs
+ then
+;
+: (probe-usb1) ( -- )
+ " device_type" get-property if exit then
+ get-encoded-string 2dup " uhci" $= >r " ohci" $= r> or if
+ pwd$ open-dev ?dup if close-dev then
+ then
+;
+: (show-usb1) ( -- )
+ " device_type" get-property if exit then
+ get-encoded-string 2dup " uhci" $= >r " ohci" $= r> or if
+ pwd$ $nopage-show-devs
+ then
+;
+: show-usb ( -- )
+ ." USB2 devices:" cr
+ " /" ['] (show-usb2) scan-subtree
+
+ ." USB1 devices:" cr
+ " /" ['] (show-usb1) scan-subtree
+;
+: silent-probe-usb ( -- )
+ " /" ['] (probe-usb2) scan-subtree
+ " /" ['] (probe-usb1) scan-subtree
+ report-disk report-net
+;
+: probe-usb ( -- )
+ silent-probe-usb
+ show-usb
+;
+alias p2 probe-usb
+
+0 value usb-keyboard-ih
+
+devalias usb-keyboard /usb/keyboard
+
+: attach-usb-keyboard ( -- )
+ " usb-keyboard" expand-alias if ( devspec$ )
+ drop " /usb" comp 0= if ( )
+ " usb-keyboard" open-dev to usb-keyboard-ih
+." USB keyboard attached" cr
+ usb-keyboard-ih add-input
+ exit
+ then
+ else ( devspec$ )
+ 2drop
+ then
+;
+
+: detach-usb-keyboard ( -- )
+ usb-keyboard-ih if
+ usb-keyboard-ih remove-input
+ usb-keyboard-ih close-dev
+ 0 to usb-keyboard-ih
+ then
+;
+
+: ?usb-keyboard ( -- )
+ attach-usb-keyboard
+ " /usb/serial" open-dev ?dup if
+ add-input
+ then
+;
+
+\ Unlink every node whose phys.hi component matches port
+: port-match? ( port -- flag )
+ get-unit if drop false exit then
+ get-encoded-int =
+;
+: rm-usb-children ( port -- )
+ device-context? 0= if drop exit then
+ also ( port )
+ 'child ( port prev )
+ first-child begin while ( port prev )
+ over port-match? if ( port prev )
+ 'peer link@ over link! ( port prev ) \ Disconnect
+ else ( port prev )
+ drop 'peer ( port prev' )
+ then ( port prev )
+ next-child repeat ( port prev )
+ 2drop ( )
+ previous definitions
+;
+
+: usb-quiet ( -- )
+ [ ' linux-hook behavior compile, ] \ Chain to old behavior
+ " usb1" " reset-usb" execute-device-method drop
+ " usb2" " reset-usb" execute-device-method drop
+;
+' usb-quiet to linux-hook
+
+\ 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
Added: cpu/x86/pc/newton/vstest.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/x86/pc/newton/vstest.fth Tue Nov 29 01:26:22 2011 (r2707)
@@ -0,0 +1,57 @@
+purpose: Video streaming test helper words
+\ See license at end of file
+
+hex
+headers
+
+load-base value vs-adr
+0 value vs-/frame
+0 value vs-height
+0 value vs-width
+0 value vs-x
+0 value vs-y
+d# 16 buffer: vs-guid
+\ XXX Need support for other format than YUV2 frames.
+: vs>screen ( -- )
+ vs-adr dup vs-/frame yuv2>rgb
+ vs-adr vs-x vs-y vs-width vs-height " draw-rectangle" $call-screen
+;
+
+: cfg-vs-test ( guid w h /frame -- xt adr )
+ to vs-/frame to vs-height to vs-width
+ vs-guid d# 16 move
+
+ ." Press a key to exit"
+ cursor-off
+ " dimensions" $call-screen ( w h )
+ vs-height - 2/ to vs-y
+ vs-width - 2/ to vs-x
+
+ ['] vs>screen vs-adr
+;
+
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2011 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
+
Added: cpu/x86/pc/newton/yuv2rgb.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/x86/pc/newton/yuv2rgb.fth Tue Nov 29 01:26:22 2011 (r2707)
@@ -0,0 +1,174 @@
+purpose: YUY2 to RGB-565 conversion
+\ See license at end of file
+
+\ B = 1.164(Y - 16) + 2.018(U - 128)
+\ G = 1.164(Y - 16) - 0.813(V - 128) - 0.391(U - 128)
+\ R = 1.164(Y - 16) + 1.596(V - 128)
+
+[ifdef] 386-assembler
+
+\ This code operates on pixel values in memory using scaler of 128
+\ Src bytes are Y0 U Y1 V
+\ Dst bytes are 565RGB 565RGB (2 16-bit pixels)
+
+code yuv2>rgb ( src dst count -- )
+ 4 [sp] di xchg \ di: dst
+ 8 [sp] si xchg \ si: src
+
+ ax push ax push ax push \ Save space on stack for V U Y0
+
+ begin
+ \ Get Y0, make signed, multiply by 1.164 * 128, save on stack
+ ax ax xor al lods d# 16 # ax sub d# 149 # ax ax imul-imm ax 0 [sp] mov
+ ax ax xor al lods d# 128 # ax sub ax 4 [sp] mov \ Get U, make signed, save on stack
+ \ Get Y1, make signed, multiply by 1.164 * 128, save in BX
+ ax ax xor al lods d# 16 # ax sub d# 149 # ax bx imul-imm
+ ax ax xor al lods d# 128 # ax sub ax 8 [sp] mov \ Get V, make signed, save on stack
+
+ \ Generate R
+ d# 204 # 8 [sp] ax imul-imm \ Multiply V by 1.596 * 128
+ bx ax add \ Add Y1
+ d# 7 # ax sar \ Scale down by 128
+
+ 0< if ax ax xor then \ Clip to 0
+ d# 255 # ax cmp > if d# 255 # ax mov then \ Clip to 255
+
+ h# f8 # ax and \ Use upper 5 bits only
+ d# 8 # ax shl \ Shift R into position
+ ax cx mov \ Save it
+
+ \ Generate B
+ d# 258 # 4 [sp] ax imul-imm \ Multiply U by 2.018 * 128
+ bx ax add \ Add Y1
+ d# 7 # ax sar \ Scale down by 128
+
+ 0< if ax ax xor then \ Clip to 0
+ d# 255 # ax cmp > if d# 255 # ax mov then \ Clip to 255
+
+ h# f8 # ax and \ Use upper 5 bits only
+ d# 3 # ax shr \ Shift B into position
+ ax cx or \ Save it
+
+ \ Generate G
+ d# -104 # 8 [sp] dx imul-imm \ Multiply V by -0.813 * 128
+ d# -50 # 4 [sp] ax imul-imm \ Multiply U by -0.391 * 128
+ dx ax add \ Add
+ ax dx mov \ Save to be used for the 2nd RGB
+ bx ax add \ Add Y1
+ d# 7 # ax sar \ Scale down by 128
+
+ 0< if ax ax xor then \ Clip to 0
+ d# 255 # ax cmp > if d# 255 # ax mov then \ Clip to 255
+
+ h# fc # ax and \ Use upper 6 bits only
+ d# 3 # ax shl \ Shift G into position
+ ax cx or \ Save it
+ d# 16 # cx shl \ Save second RGB
+
+ \ Generate 2nd R
+ 0 [sp] bx mov \ Work on Y0
+ d# 204 # 8 [sp] ax imul-imm \ Multiply V by 1.596 * 128
+ bx ax add \ Add Y0
+ d# 7 # ax sar \ Scale down by 128
+
+ 0< if ax ax xor then \ Clip to 0
+ d# 255 # ax cmp > if d# 255 # ax mov then \ Clip to 255
+
+ h# f8 # ax and \ Use upper 5 bits only
+ d# 8 # ax shl \ Shift R into position
+ ax cx or \ Save it
+
+ \ Generate 2nd B
+ d# 258 # 4 [sp] ax imul-imm \ Multiply U by 2.018 * 128
+ bx ax add \ Add Y0
+ d# 7 # ax sar \ Scale down by 128
+
+ 0< if ax ax xor then \ Clip to 0
+ d# 255 # ax cmp > if d# 255 # ax mov then \ Clip to 255
+
+ h# f8 # ax and \ Use upper 5 bits only
+ d# 3 # ax shr \ Shift B into position
+ ax cx or \ Save it
+
+ \ Generate 2nd G
+ dx ax mov \ v*0.813+u*0.391
+ bx ax add \ Add Y-
+ d# 7 # ax sar \ Scale down by 128
+
+ 0< if ax ax xor then \ Clip to 0
+ d# 255 # ax cmp > if d# 255 # ax mov then \ Clip to 255
+
+ h# fc # ax and \ Use upper 6 bits only
+ d# 3 # ax shl \ Shift G into position
+ cx ax or \ Save it
+
+ ax stos \ Output both RGB
+
+ d# 4 # h# c [sp] sub
+ 0= until
+
+ d# 16 [sp] sp lea \ Clean stack
+ di pop
+ si pop
+c;
+[then]
+
+[ifndef] yuv2>rgb
+
+\ Forth code: no division; use scaler of 128
+0 value y1
+0 value v 0 value v*0.813+u*0.391 0 value v*1.596
+0 value u 0 value u*2.018
+
+: do-uv-comp ( -- )
+ u d# 258 * to u*2.018
+ v d# -104 * u d# -50 * + to v*0.813+u*0.391
+ v d# 204 * to v*1.596
+;
+: y>rgb ( y -- rgb )
+ d# 16 - d# 149 * ( 1.164 ) ( y' )
+ dup u*2.018 + 7 >>a 0 max d# 255 min h# f8 and 3 >> ( y b )
+ over v*0.813+u*0.391 + 7 >>a 0 max d# 255 min h# fc and 3 << or ( y gb )
+ swap v*1.596 + 7 >>a 0 max d# 255 min h# f8 and 8 << or ( rgb )
+;
+: yuyv>rgb ( y0uy1v -- rgb0 rgb1 )
+ lbsplit ( v y1 u y0 )
+ swap d# 128 - to u rot d# 128 - to v ( y1 y0 )
+ do-uv-comp ( y1 y0 )
+ y>rgb ( y1 rgb0 )
+ swap y>rgb ( rgb0 rgb1 )
+;
+
+: yuv2>rgb ( src dst len -- )
+ 4 / 0 do ( src dst )
+ over i la+ be-l@ yuyv>rgb ( src dst rgb0 rgb1 )
+ wljoin over i la+ le-l! ( src dst )
+ loop 2drop
+;
+
+[then]
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2011 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
+
Author: quozl
Date: Wed Nov 23 02:03:08 2011
New Revision: 2700
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2700
Log:
OLPC XO-1.75 - change architecture device-tree tag
Modified:
cpu/arm/olpc/1.75/prefw.bth
Modified: cpu/arm/olpc/1.75/prefw.bth
==============================================================================
--- cpu/arm/olpc/1.75/prefw.bth Tue Nov 22 04:11:39 2011 (r2699)
+++ cpu/arm/olpc/1.75/prefw.bth Wed Nov 23 02:03:08 2011 (r2700)
@@ -53,7 +53,7 @@
dev /
" olpc,XO-1.75" model
- " Marvell,Armada 610" encode-string " architecture" property
+ " 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
Author: quozl
Date: Tue Nov 22 04:11:39 2011
New Revision: 2699
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2699
Log:
fix hang on " u:f" r/w create-file caused by stack imbalance after handling UFS partition letter
Modified:
ofw/disklabel/methods.fth
Modified: ofw/disklabel/methods.fth
==============================================================================
--- ofw/disklabel/methods.fth Mon Nov 21 23:40:32 2011 (r2698)
+++ ofw/disklabel/methods.fth Tue Nov 22 04:11:39 2011 (r2699)
@@ -197,14 +197,14 @@
over c@ ascii 0 ascii 9 between if ( adr len )
over c@ ascii 0 - to #part ( adr len )
1 /string ( adr' len' )
- dup 0= if 2drop exit then ( adr len )
+ dup 0= if exit then ( adr len )
then
\ If the first character is "a".."h", it's a UFS partition letter
over c@ lcc ascii a ascii h between if ( adr len )
over c@ to ufs-partition ( adr len )
1 /string ( adr' len' )
- dup 0= if 2drop exit then ( adr len )
+ dup 0= if exit then ( adr len )
then ( adr len )
;
: parse-partition ( -- )