[openfirmware] r1325 - cpu/x86/pc/olpc/via dev/video/common ofw/gui
svn at openfirmware.info
svn at openfirmware.info
Tue Aug 25 05:04:49 CEST 2009
Author: wmb
Date: 2009-08-25 05:04:49 +0200 (Tue, 25 Aug 2009)
New Revision: 1325
Added:
cpu/x86/pc/olpc/via/mfgtest.fth
cpu/x86/pc/olpc/via/testicons.bth
cpu/x86/pc/olpc/via/testicons.tgz
Modified:
cpu/x86/pc/olpc/via/fw.bth
cpu/x86/pc/olpc/via/olpc.bth
dev/video/common/rectangle16.fth
ofw/gui/bmp24rgb565.fth
ofw/gui/graphics.fth
ofw/gui/iconmenu.fth
ofw/gui/menumisc.fth
ofw/gui/rgb565bmp24.fth
Log:
Via - added graphical selftest menu from Luke Gorrie.
Modified: cpu/x86/pc/olpc/via/fw.bth
===================================================================
--- cpu/x86/pc/olpc/via/fw.bth 2009-08-24 23:02:25 UTC (rev 1324)
+++ cpu/x86/pc/olpc/via/fw.bth 2009-08-25 03:04:49 UTC (rev 1325)
@@ -307,7 +307,7 @@
fload ${BP}/ofw/gui/loadmenu.fth
fload ${BP}/ofw/gui/insticon.fth
-\ fload ${BP}/cpu/x86/pc/olpc/via/mfgtest.fth
+fload ${BP}/cpu/x86/pc/olpc/via/mfgtest.fth
: screen-#lines ( -- n )
screen-ih 0= if default-#lines exit then
Added: cpu/x86/pc/olpc/via/mfgtest.fth
===================================================================
--- cpu/x86/pc/olpc/via/mfgtest.fth (rev 0)
+++ cpu/x86/pc/olpc/via/mfgtest.fth 2009-08-25 03:04:49 UTC (rev 1325)
@@ -0,0 +1,191 @@
+\ See license at end of file
+purpose: Menu for manufacturing tests
+
+h# f800 constant color-red
+h# 07e0 constant color-green
+
+: flush-keyboard ( -- ) begin key? while key drop repeat ;
+
+: sq-border! ( bg -- ) current-sq sq >border ! ;
+
+: red-screen ( -- ) h# ffff color-red " replace-color16" $call-screen ;
+: green-screen ( -- ) h# ffff color-green " replace-color16" $call-screen ;
+
+0 value pass?
+
+: mfg-test-dev ( $ -- )
+ restore-scroller
+ find-device
+ ??cr ." Testing " pwd
+ " selftest" current-device execute-phandle-method ( return abort? )
+ if
+ ?dup if
+ ??cr ." Selftest failed. Return code = " .d cr
+ color-red sq-border!
+ false to pass?
+ red-screen
+ flush-keyboard
+ wait-return
+ else
+ green-letters
+ ." Okay" cr
+ black-letters
+ color-green sq-border!
+ true to pass?
+ d# 2000 hold-message
+ then
+ else
+ ." Selftest failed due to abort" cr
+ color-red sq-border!
+ false to pass?
+ red-screen
+ flush-keyboard
+ wait-return
+ then
+ cursor-off gui-alerts refresh
+ flush-keyboard
+;
+
+: draw-error-border ( -- )
+ color-red d# 20 d# 20 d# 1160 d# 820 d# 20 box
+;
+
+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: battery.icon rom:battery.565
+icon: camera.icon rom:camera.565
+icon: wifi.icon rom:wifi.565
+icon: audio.icon rom:audio.565
+icon: touchpad.icon rom:touchpad.565
+icon: display.icon rom:display.565
+icon: keyboard.icon rom:keyboard.565
+icon: timer.icon rom:timer.565
+icon: clock.icon rom:clock.565
+
+: all-tests-passed ( -- )
+ restore-scroller
+ clear-screen
+ ." All automatic tests passed successfully." cr cr cr
+ green-screen
+ wait-return
+ cursor-off gui-alerts refresh
+ flush-keyboard
+;
+
+d# 14 value #mfgtests
+
+: play-item ( -- )
+ 5 #mfgtests + 5 do
+ i set-current-sq
+ refresh
+ d# 200 0 do
+ d# 10 ms key? if unloop unloop exit then
+ loop
+ doit
+ pass? 0= if unloop exit then
+ loop
+ all-tests-passed
+;
+: quit-item ( -- ) menu-done ;
+: cpu-item ( -- ) " /cpu" mfg-test-dev ;
+: battery-item ( -- ) " /battery" mfg-test-dev ;
+: flash-item ( -- ) " /flash" mfg-test-dev ;
+: memory-item ( -- ) " /memory" mfg-test-dev ;
+: usb-item ( -- ) " /usb" mfg-test-dev ;
+: sd-item ( -- ) " /sd/disk:0" mfg-test-dev ;
+: rtc-item ( -- ) " /rtc" mfg-test-dev ;
+: display-item ( -- ) " /display" mfg-test-dev ;
+: audio-item ( -- ) " /audio" mfg-test-dev ;
+: camera-item ( -- ) " /camera" mfg-test-dev ;
+: wlan-item ( -- ) " /wlan" mfg-test-dev ;
+: timer-item ( -- ) " /timer" mfg-test-dev ;
+: touchpad-item ( -- ) " /mouse" mfg-test-dev ;
+: keyboard-item ( -- ) " /keyboard" mfg-test-dev ;
+
+: mfgtest-menu ( -- )
+ clear-menu
+
+ " Run all non-interactive tests. (Press a key between tests to stop.)"
+ ['] play-item play.icon 0 1 selected install-icon
+
+ " Exit selftest mode."
+ ['] quit-item quit.icon 0 3 install-icon
+
+ " CPU"
+ ['] cpu-item cpu.icon 1 0 install-icon
+
+ " SPI Flash: Contains EC code, firmware, manufacturing data."
+ ['] flash-item spi.icon 1 1 install-icon
+
+ " RAM chips"
+ ['] memory-item ram.icon 1 2 install-icon
+
+ " SD card controllers - internal and external mass storage"
+ ['] sd-item sdcard.icon 1 3 install-icon
+
+ " USB ports"
+ ['] usb-item usb.icon 1 4 install-icon
+
+ " Battery"
+ ['] battery-item battery.icon 2 0 install-icon
+
+ " Camera"
+ ['] camera-item camera.icon 2 1 install-icon
+
+ " Wireless LAN"
+ ['] wlan-item wifi.icon 2 2 install-icon
+
+ " Audio: Speaker and microphone"
+ ['] audio-item audio.icon 2 3 install-icon
+
+ " Display"
+ ['] display-item display.icon 2 4 install-icon
+
+ " RTC (Real-Time Clock)"
+ ['] rtc-item clock.icon 3 0 install-icon
+
+ " ISA Timer"
+ ['] timer-item timer.icon 3 1 install-icon
+
+ \ These are last because they require user participation.
+ \ The earlier tests are all included in automatic batch-mode.
+
+ " Keyboard"
+ ['] keyboard-item keyboard.icon 3 2 install-icon
+
+ " Touchpad"
+ ['] touchpad-item touchpad.icon 3 3 install-icon
+
+;
+
+' mfgtest-menu to root-menu
+' noop to do-title
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2009 Luke Gorrie
+\
+\ 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/via/olpc.bth
===================================================================
--- cpu/x86/pc/olpc/via/olpc.bth 2009-08-24 23:02:25 UTC (rev 1324)
+++ cpu/x86/pc/olpc/via/olpc.bth 2009-08-25 03:04:49 UTC (rev 1325)
@@ -31,8 +31,8 @@
\ in: ${BP}/cpu/x86/pc/olpc/via/build/mcastnand.bin
in: ${BP}/dev/hdaudio/build/hdaudio.fc
in: sd8686.bin
+in: testicons.bin
-
build-now
fload ${BP}/cpu/x86/pc/olpc/via/versions.fth
@@ -160,6 +160,24 @@
" ${BP}/cpu/x86/pc/olpc/via/build/dsdt.aml" " dsdt" $add-deflated-dropin
\ " ${BP}/cpu/x86/pc/olpc/via/build/ssdt.aml" " ssdt" $add-deflated-dropin
+ \ icons for mfg test gui
+ " testicons/play.565" " play.565" $add-deflated-dropin
+ " testicons/quit.565" " quit.565" $add-deflated-dropin
+ " testicons/cpu.565" " cpu.565" $add-deflated-dropin
+ " testicons/spi.565" " spi.565" $add-deflated-dropin
+ " testicons/ram.565" " ram.565" $add-deflated-dropin
+ " testicons/sdcard.565" " sdcard.565" $add-deflated-dropin
+ " testicons/keyboard.565" " keyboard.565" $add-deflated-dropin
+ " testicons/display.565" " display.565" $add-deflated-dropin
+ " testicons/touchpad.565" " touchpad.565" $add-deflated-dropin
+ " testicons/audio.565" " audio.565" $add-deflated-dropin
+ " testicons/usb.565" " usb.565" $add-deflated-dropin
+ " testicons/battery.565" " battery.565" $add-deflated-dropin
+ " testicons/camera.565" " camera.565" $add-deflated-dropin
+ " testicons/wifi.565" " wifi.565" $add-deflated-dropin
+ " testicons/clock.565" " clock.565" $add-deflated-dropin
+ " testicons/timer.565" " timer.565" $add-deflated-dropin
+
[ifdef] Later
" ${BP}/cpu/x86/pc/olpc/via/build/nandblaster_rx.bin" " nb_rx" $add-deflated-dropin
" ${BP}/cpu/x86/pc/olpc/via/build/nandblaster_tx.bin" " nb_tx" $add-deflated-dropin
Added: cpu/x86/pc/olpc/via/testicons.bth
===================================================================
--- cpu/x86/pc/olpc/via/testicons.bth (rev 0)
+++ cpu/x86/pc/olpc/via/testicons.bth 2009-08-25 03:04:49 UTC (rev 1325)
@@ -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/olpc/via/testicons.tgz
===================================================================
(Binary files differ)
Property changes on: cpu/x86/pc/olpc/via/testicons.tgz
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: dev/video/common/rectangle16.fth
===================================================================
--- dev/video/common/rectangle16.fth 2009-08-24 23:02:25 UTC (rev 1324)
+++ dev/video/common/rectangle16.fth 2009-08-25 03:04:49 UTC (rev 1325)
@@ -59,6 +59,15 @@
;
: dimensions ( -- width height ) width height ;
+: replace-color16 ( old new -- )
+ frame-buffer-adr width height * 2* bounds do
+ over i w@ = if
+ dup i w!
+ then
+ 2 +loop
+ 2drop
+;
+
\ LICENSE_BEGIN
\ Copyright (c) 2006 FirmWorks
\
Modified: ofw/gui/bmp24rgb565.fth
===================================================================
--- ofw/gui/bmp24rgb565.fth 2009-08-24 23:02:25 UTC (rev 1324)
+++ ofw/gui/bmp24rgb565.fth 2009-08-25 03:04:49 UTC (rev 1325)
@@ -1,6 +1,7 @@
\ See license at end of file
purpose: Conversion from RGB888 BMP to RGB565 raw formats
+0 value pixels-offset
0 value image-width
0 value image-height
0 value #planes
@@ -22,7 +23,7 @@
: get-planes ( -- )
#planes 0 ?do
image-height 0 do
- image-height i 1+ - line-bytes * /bmp-hdr + ifd @ fseek
+ image-height i 1+ - line-bytes * pixels-offset + ifd @ fseek
image-width copy-scan-line
loop
loop
@@ -31,6 +32,7 @@
: putw ( w -- ) wbsplit swap ofd @ fputc ofd @ fputc ;
: bmp>rects ( -- )
+ bmp-hdr h# 0a + le-l@ to pixels-offset
bmp-hdr h# 12 + le-l@ to image-width
bmp-hdr h# 16 + le-l@ to image-height
bmp-hdr h# 1a + le-w@ to #planes
Modified: ofw/gui/graphics.fth
===================================================================
--- ofw/gui/graphics.fth 2009-08-24 23:02:25 UTC (rev 1324)
+++ ofw/gui/graphics.fth 2009-08-25 03:04:49 UTC (rev 1325)
@@ -12,9 +12,10 @@
7 constant gray
h# f constant white
-h# 13 constant background
-gray constant selected-color
-blue constant ready-color
+h# ff h# ff h# ff rgb>565 value background
+\ h# 0010 value selected-color
+ 0 0 h# 80 rgb>565 value selected-color
+h# ff h# ff h# ff rgb>565 value ready-color
\ \\\\\\\\\\\\\\\\
\ Device Support \
@@ -23,7 +24,7 @@
\needs screen-ih 0 value screen-ih
0 value mouse-ih
-d# 640 d# 480 2value max-xy
+d# 1200 d# 900 2value max-xy
: max-x ( -- n ) max-xy drop ;
: max-y ( -- n ) max-xy nip ;
Modified: ofw/gui/iconmenu.fth
===================================================================
--- ofw/gui/iconmenu.fth 2009-08-24 23:02:25 UTC (rev 1324)
+++ ofw/gui/iconmenu.fth 2009-08-25 03:04:49 UTC (rev 1325)
@@ -12,9 +12,9 @@
\ user can select an icon, and execute its function
\ notes
-\ screen is max-x >= 640 by max-y >= 480 (can assume 640x480 for now)
+\ screen is max-x >= 1200 by max-y >= 900 (can assume 1200x900 for now)
\ 0,0 is left,top; 12 boxes 128x128 begin at 48,48
-\ each may contain a 64x64 icon, centered, and a string below
+\ each may contain a 128x128 icon, centered, and a string below
\ mouse or keyboard can select, and run associated function
\ moving mouse cursor into occupied square changes selection
\ keyboard input removes mouse cursor and moves mouse to selected square
@@ -25,7 +25,7 @@
\ have:
\ fill-rectangle ( color x y w h - ) color is 0..255
-\ draw-rectangle ( address x y w h - ) address of 64x64 pixmap
+\ draw-rectangle ( address x y w h - ) address of 128x128 pixmap
\ read-rectangle ( address x y w h - )
\ move-mouse-cursor ( x y - )
\ remove-mouse-cursor ( - )
@@ -38,13 +38,14 @@
headers
d# 32 value version-height
-3 constant rows
+4 constant rows
5 constant cols
headerless
rows cols * constant squares
-d# 100 constant sq-size
-d# 64 constant icon-size
-d# 100 constant title-area
+d# 180 value sq-size
+d# 128 value image-size \ on file
+d# 128 value icon-size \ on screen
+d# 100 value title-area
: sq-max-y ( -- pixels ) sq-size rows * ;
@@ -88,16 +89,20 @@
struct
/n field >icon
+ /n field >pixels
/n field >function
+ /n field >border
2 /n * field >help \ Brief description
\ 32 field >label \ later...
dup constant /entry
squares * buffer: squarebuf
-
+icon-size dup * 2 * constant /icon
+image-size dup * 2 * 8 + constant /image
+
: sq ( sq - a ) sq? /entry * squarebuf + ;
: set-sq ( help$ 'function 'icon sq - )
- sq tuck >icon ! tuck >function ! ( help$ 'entry )
+ sq background over >border ! tuck >icon ! tuck >function ! ( help$ 'entry )
>r
?save-string r> >help 2!
;
@@ -129,16 +134,18 @@
d# 10 constant thickness
-: hilite ( color - )
- current-sq sq>xy ( color left top )
- sq-size icon-size - 2/ thickness - tuck + -rot + swap
- icon-size thickness 2* + dup thickness box
+: draw-border ( color sq - )
+ sq>xy ( color left top )
+ sq-size icon-size - thickness 3 * - 2/ tuck + -rot + swap
+ icon-size thickness 3 * + dup thickness 2/ box
;
+: hilite ( color - ) current-sq draw-border ;
+
headers
: emphasize ( - ) ready-color hilite ;
: highlight ( - ) selected-color hilite ;
-: lowlight ( - ) background hilite ;
+: lowlight ( - ) current-sq sq >border @ hilite ;
headerless
: ?lowlight ( -- ) current-sq valid? if lowlight then ;
@@ -147,14 +154,102 @@
: describe ( -- )
current-sq sq >help 2@ show-description
;
-: draw-sq ( sq - )
+
+code expand-rect ( src dst w h --- )
+ dx pop \ Height of source image in pixels
+ 4 [sp] edi xchg
+ 8 [sp] esi xchg
+ begin
+ 0 [sp] cx mov \ Width of source image in pixels
+ begin
+ op: ax lods \ Get a pixel
+ op: ax d# 256 [edi] mov \ Write to next line
+ op: ax stos \ Write to this line + increment
+ op: ax d# 256 [edi] mov \ Write to next line
+ op: ax stos \ Write to this line + increment
+ loopa
+ d# 256 # edi add \ Skip the next output line - already written
+ edx dec
+ 0= until
+ eax pop \ Discard source width
+ edi pop \ Restore EDI
+ esi pop \ Restore ESI
+c;
+
+: expand-icon ( adr - eadr )
+ /icon alloc-mem tuck ( eadr adr eadr )
+ dup /icon 0 fill \ temp - clear old data
+ icon-size 2/ icon-size 2/ expand-rect ( eadr )
+;
+
+alias /pix* /w*
+
+0 value src-w
+0 value src-h
+
+: center-icon ( hdr-adr -- eadr )
+ /icon alloc-mem >r ( hdr-adr r: eadr )
+ r@ /icon 2 pick 8 + le-w@ wfill ( hdr-adr )
+ dup 4 + le-w@ to src-w ( hdr-adr )
+ dup 6 + le-w@ to src-h ( hdr-adr )
+ 8 + ( src-adr )
+
+ \ Calculate offset in dest array for centering
+ icon-size src-h - 2/ icon-size * ( src-adr line-offset )
+ icon-size src-w - 2/ + /pix* ( src-adr byte-offset )
+ r@ + ( src-adr dst-adr )
+
+ \ Copy rectangle from source to destination
+ swap src-h src-w * /pix* bounds ?do ( dst-adr )
+ i over src-w /pix* move ( dst-adr )
+ icon-size /pix* + ( dst-adr' )
+ src-w /pix* +loop ( dst-adr )
+ drop ( )
+ r> ( eadr )
+;
+
+: load-pixels ( device$ -- pix-adr )
+ r/o open-file abort" error opening icon file"
+ >r ( r: fileid )
+ r@ fsize dup alloc-mem swap ( adr len r: fileid )
+ 2dup r@ fgets ( adr len actual r: fileid )
+ over <> abort" error reading icon data" ( adr len )
+ r> fclose ( adr len )
+
+ over 4 + le-l@ h# 0040.0040 = if ( hdr-adr len )
+ over 8 + expand-icon ( hdr-adr len pix-adr )
+ -rot free-mem ( pix-adr )
+ else ( hdr-adr len )
+ over 4 + le-l@ h# 0080.0080 = if ( hdr-adr len )
+ drop 8 + ( pix-adr )
+ else ( hdr-adr len )
+ over center-icon ( hdr-adr len pix-adr )
+ -rot free-mem ( pix-adr )
+ then
+ then
+;
+
+: load-icon ( sq -- )
+ sq dup >pixels @ 0= if ( sq-adr )
+ dup >icon @ count load-pixels ( sq-adr pix-adr )
+ swap >pixels ! ( )
+ else
+ drop ( )
+ then
+;
+
+: draw-sq ( sq -- )
dup -1 = if exit then
background over sq>xy sq-size dup fill-rectangle
- dup sq >icon @ dup if
+ dup sq >border @ over draw-border
+ dup sq >icon @ if
+ dup load-icon
+ dup sq >pixels @
swap sq>xy sq-size icon-size - 2/ tuck + -rot + swap
icon-size dup draw-rectangle
+ lowlight \ draw border
else
- 2drop
+ drop
then
;
Modified: ofw/gui/menumisc.fth
===================================================================
--- ofw/gui/menumisc.fth 2009-08-24 23:02:25 UTC (rev 1324)
+++ ofw/gui/menumisc.fth 2009-08-25 03:04:49 UTC (rev 1325)
@@ -51,8 +51,8 @@
;
\ Defining word for icon images
-: icon: ( "name" "filename" -- ) ( child: -- adr )
- create parse-word $file,
+: icon: ( "name" "devicename" -- ) ( child: -- adr )
+ create parse-word ",
;
icon: exit.icon ${BP}/ofw/gui/exeunt.icx
Modified: ofw/gui/rgb565bmp24.fth
===================================================================
--- ofw/gui/rgb565bmp24.fth 2009-08-24 23:02:25 UTC (rev 1324)
+++ ofw/gui/rgb565bmp24.fth 2009-08-25 03:04:49 UTC (rev 1325)
@@ -78,8 +78,8 @@
;
: raw565bmp24 ( -- )
reading writing
- d# 640 to image-width
- d# 480 to image-height
+ d# 1200 to image-width
+ d# 900 to image-height
565>rects
ifd @ fclose ofd @ fclose
More information about the openfirmware
mailing list