Author: wmb
Date: 2009-08-20 08:31:15 +0200 (Thu, 20 Aug 2009)
New Revision: 1309
Added:
ofw/core/muxdev.fth
Modified:
cpu/x86/pc/olpc/via/fw.bth
cpu/x86/pc/olpc/via/memtest.fth
cpu/x86/pc/olpc/via/usb.fth
ofw/gui/graphics.fth
ofw/gui/iconmenu.fth
ofw/gui/nullio.fth
Log:
Changed console multiplexing to use a general purpose multiplexor
package instead of the "dual-console" diplexor.
Modified: cpu/x86/pc/olpc/via/fw.bth
===================================================================
--- cpu/x86/pc/olpc/via/fw.bth 2009-08-20 06:26:26 UTC (rev 1308)
+++ cpu/x86/pc/olpc/via/fw.bth 2009-08-20 06:31:15 UTC (rev 1309)
@@ -233,15 +233,18 @@
fload ${BP}/cpu/x86/pc/boot.fth
fload ${BP}/cpu/x86/pc/linux.fth
+0 value screen-ih
+fload ${BP}/ofw/core/muxdev.fth \ I/O collection/distribution device
+
fload ${BP}/cpu/x86/pc/olpc/via/usb.fth
false to stand-init-debug?
\ true to stand-init-debug?
-hex
: serial-enabled? ( -- flag ) h# 8846 config-b@ h# 40 and 0<> ;
+hex
: i-key-wait ( ms -- pressed? )
serial-enabled? 0= if drop false exit then ( ms )
@@ -317,6 +320,20 @@
;
' setup-for-linux to linux-hook
+true value text-on?
+: text-off ( -- )
+ text-on? if
+ screen-ih remove-mux
+ false to text-on?
+ then
+;
+: text-on ( -- )
+ text-on? 0= if
+ screen-ih add-mux
+ true to text-on?
+ then
+;
+
fload ${BP}/cpu/x86/pc/olpc/help.fth
fload ${BP}/cpu/x86/pc/olpc/gui.fth
fload ${BP}/cpu/x86/pc/olpc/via/suspend.fth \ Suspend/resume setup
@@ -363,42 +380,12 @@
fload ${BP}/cpu/x86/pc/olpc/rtcwake.fth
-[ifdef] use-ega
-: ega-output ( -- )
- \ This only works if stdout is currently /display
- stdout @ if
- " text-mode3" screen-ih $call-method
- then
- " /ega-text" output
-;
-[then]
-
" /xp u:\boot\olpc.fth sd:\boot\olpc.fth c:\boot\olpc.fth nand:\boot\olpc.fth /prober /usb/ethernet /usb/wlan"
' boot-device set-config-string-default
\needs ramdisk " " d# 128 config-string ramdisk
" " ' boot-file set-config-string-default \ Let the boot script set the cmdline
-: upup
- " u:\irdpup.gz" to ramdisk
- " console=ttyS0,115200 ide=nodma pmedia=ataflash nosmp noacpi" to boot-file
- " u:\vmlpup" to boot-device
-;
-: cpup
- " c:\initrd.gz" to ramdisk
- " console=ttyS0,115200 ide=nodma pmedia=ataflash nosmp noacpi" to boot-file
- " c:\vmlinuz" to boot-device
-;
-: okern
-\ " c:\initrd.gz" to ramdisk
-[ifdef] use-apic
- " root=/dev/sda1 console=ttyS0,115200 acpi=off rootwait" to boot-file
-[else]
- " root=/dev/sda1 console=ttyS0,115200 acpi=off rootwait noapic nolapic" to boot-file
-[then]
- " u:\vmlinuz" to boot-device
-;
-
: dimmer ( -- ) screen-ih if " dimmer" screen-ih $call-method then ;
: brighter ( -- ) screen-ih if " brighter" screen-ih $call-method then ;
@@ -447,6 +434,8 @@
\ Prevent "resume from S3" on restart
4 acpi-w@ h# 1c00 invert and 4 acpi-w!
+ h# 3000 ms \ Give the EC time to do its thing
+
6 h# cf9 pc! \ In case the EC doesn't do it
begin halt again
;
@@ -519,8 +508,8 @@
" dhcp" ' ip-address set-config-string-default
-\ fload ${BP}/cpu/x86/pc/report.fth
-fload ${BP}/ofw/core/dualconsole.fth
+: c1-idle ( -- ) interrupts-enabled? if halt then ;
+' c1-idle to stdin-idle
: fast-boot? ( -- flag )
[ifdef] rom-loaded
@@ -536,6 +525,21 @@
1 h# 61 cmos! 1 h# 60 cmos!
;
+: console-start ( -- )
+ serial-enabled? 0= if
+ ['] null$ to fallback-device
+ then
+
+ install-mux-io
+ true to text-on?
+
+ " //null" open-dev to null-ih \ For text-off state
+
+ ?gui-banner
+\ ." nvramrc" cr
+\ use-nvramrc? if nvramrc safe-evaluate then
+;
+
: interpreter-init ( -- )
hex
warning on
@@ -568,22 +572,6 @@
then ( )
;
-: console-start ( -- )
- " screen" open-dev ?dup if
- dup to screen-ih
- set-stdout
-\ logo-banner drop
-\ close-dev
-\ 0 stdout !
- then
-
- install-dual-console
-
- ?gui-banner
-\ ." nvramrc" cr
-\ use-nvramrc? if nvramrc safe-evaluate then
-;
-
: debug-interact ( -- )
early-interact? if
" Interrupting startup sequence prior to probing" .because
@@ -624,10 +612,6 @@
;
[then]
-: open-keyboard ( -- )
- " keyboard" open-dev ?dup if set-stdin then
-;
-
: startup ( -- )
standalone? 0= if exit then
@@ -647,13 +631,12 @@
read-game-keys
- stdout off \
+ text-off
" probe-" do-drop-in
probe-pci
sound
- open-keyboard
?games
['] false to interrupt-auto-boot?
probe-usb
@@ -672,13 +655,12 @@
unblock-exceptions
['] (interrupt-auto-boot?) to interrupt-auto-boot?
?usb-keyboard
-\ install-console
-\ install-dual-console
- banner
+ auto-banner? if banner then
+
auto-boot
- frozen? ( frozen? )
- unfreeze visible ( frozen? )
+ frozen? text-on? 0= and ( no-banner? )
+ unfreeze visible ( no-banner? )
if banner then \ Reissue banner if it was suppressed
blue-letters ." Type 'help' for more information." black-letters
Modified: cpu/x86/pc/olpc/via/memtest.fth
===================================================================
--- cpu/x86/pc/olpc/via/memtest.fth 2009-08-20 06:26:26 UTC (rev 1308)
+++ cpu/x86/pc/olpc/via/memtest.fth 2009-08-20 06:31:15 UTC (rev 1309)
@@ -47,8 +47,10 @@
h# 810 config-l@ dup 100.0000 -1 mmu-map
[then]
[else]
- " text-mode3" stdout @ $call-method \ XXX should be screen-ih
- stdout off
+ screen-ih if
+ " text-mode3" screen-ih $call-method
+ then
+ text-off
make-lb-table
[then]
[ifdef] unfreeze unfreeze [then]
Modified: cpu/x86/pc/olpc/via/usb.fth
===================================================================
--- cpu/x86/pc/olpc/via/usb.fth 2009-08-20 06:26:26 UTC (rev 1308)
+++ cpu/x86/pc/olpc/via/usb.fth 2009-08-20 06:31:15 UTC (rev 1309)
@@ -56,13 +56,13 @@
" keyboard" expand-alias if ( devspec$ )
drop " /usb" comp 0= if ( )
red-letters ." Using USB keyboard." cr black-letters
- " keyboard" input
+ " keyboard" open-dev add-mux
exit
then
then
" /usb/serial" open-dev ?dup if
red-letters ." Using USB serial console." cr black-letters
- dup set-stdin set-stdout
+ add-mux
then
;
Added: ofw/core/muxdev.fth
===================================================================
--- ofw/core/muxdev.fth (rev 0)
+++ ofw/core/muxdev.fth 2009-08-20 06:31:15 UTC (rev 1309)
@@ -0,0 +1,186 @@
+\ See license at end of file
+purpose: Multiplexor device collects input and distributes I/O
+
+dev /packages
+new-device
+" mux" device-name
+
+0 instance variable first-device
+
+struct
+ /n field >link
+ /n field >ihandle
+ /n field >read
+ /n field >write
+constant /list-node
+
+: read ( adr len -- actual )
+ first-device @
+ begin dup while ( adr len listnode )
+ >r ( adr len )
+ r@ >read @ ?dup if ( adr len xt )
+ >r 2dup r> ( adr len adr len xt )
+ r@ >ihandle @ call-package ( adr len actual )
+ dup 0> if nip nip r> drop exit then ( adr len actual )
+ drop ( adr len )
+ then ( adr len )
+ r> >link @ ( adr len listnode' )
+ repeat ( adr len listnode )
+ 3drop -2
+;
+: write ( adr len -- len )
+ first-device @
+ begin dup while ( adr len listnode )
+ >r ( adr len )
+ r@ >write @ ?dup if ( adr len xt )
+ >r 2dup r> ( adr len adr len xt )
+ r@ >ihandle @ call-package drop ( adr len )
+ then ( adr len )
+ r> >link @ ( adr len listnode' )
+ repeat ( adr len listnode )
+ drop nip
+;
+
+: show-devices ( -- )
+ first-device @
+ begin dup while ( listnode )
+ >r ( )
+ r@ >read @ if ." R" else ." " then
+ r@ >write @ if ." W" else ." " then
+ space
+ r@ >ihandle @ dup . iselect pwd iunselect
+ r> >link @ ( listnode' )
+ repeat ( listnode )
+ drop ( )
+;
+
+: add-device ( ihandle -- )
+ /list-node alloc-mem >r ( ihandle r: listnode )
+
+ dup r@ >ihandle ! ( ihandle r: listnode )
+
+ ihandle>phandle ( phandle r: listnode )
+
+ " read" 2 pick find-method 0= if 0 then ( phandle xt r: listnode )
+ r@ >read !
+
+ " write" 2 pick find-method 0= if 0 then ( phandle xt r: listnode )
+ r@ >write ! ( phandle r: listnode )
+
+ " install-abort" 2 pick find-method if ( phandle xt r: listnode )
+ r@ >ihandle @ call-package ( phandle r: listnode )
+ then ( phandle r: listnode )
+
+ drop
+
+ first-device @ r@ >link ! ( r: listnode )
+ r> first-device ! ( )
+;
+
+: open ( -- true ) true ;
+
+: close ( -- )
+ first-device @
+ begin dup while ( listnode )
+ >r ( r: listnode )
+ " remove-abort" r@ >ihandle @ ( $ ihandle r: listnode )
+ ihandle>phandle find-method if ( xt r: listnode )
+ r> >ihandle @ call-package ( r: listnode )
+ then ( r: listnode )
+
+ r@ >ihandle @ close-dev ( r: listnode )
+ r@ >link @ ( next r: listnode )
+ r> /list-node free-mem ( next )
+ repeat ( 0 )
+ drop
+;
+
+: remove-device ( ihandle -- )
+ >r first-device ( prev r: ihandle )
+
+ begin dup >link @ dup while ( prev this r: ihandle )
+ dup >ihandle @ r@ = if ( prev this r: ihandle )
+
+ " remove-abort" r@ ihandle>phandle find-method if ( prev this xt r: ihandle )
+ r@ call-package ( prev this r: ihandle )
+ then ( prev this r: ihandle )
+ r> drop ( prev this )
+
+ dup >link @ ( prev this next )
+ rot >link ! ( this )
+ /list-node free-mem ( )
+ exit ( )
+ then ( prev this r: ihandle )
+ nip ( prev' r: ihandle )
+ repeat ( prev next r: ihandle )
+ r> 3drop
+;
+
+: install-abort ( -- ) ;
+: remove-abort ( -- ) ;
+
+finish-device
+device-end
+
+0 value mux-ih
+
+: open-mux ( -- )
+ mux-ih 0= if
+ " " " mux" $open-package
+ dup 0= abort" Can't open mux package"
+ to mux-ih
+ then
+;
+
+: add-mux ( ih -- )
+ ?dup if " add-device" mux-ih $call-method then
+;
+
+: remove-mux ( ih -- ) " remove-device" mux-ih $call-method ;
+
+: .mux ( -- )
+ mux-ih if
+ " show-devices" mux-ih $call-method
+ else
+ ." Mux isn't open" cr
+ then
+;
+
+: install-mux-io ( -- )
+ open-mux
+
+ fallback-device open-dev add-mux
+
+ screen open-dev to screen-ih
+ screen-ih add-mux
+
+ keyboard open-dev add-mux
+
+ mux-ih stdin ! mux-ih stdout !
+
+ console-io
+;
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2009 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: ofw/gui/graphics.fth
===================================================================
--- ofw/gui/graphics.fth 2009-08-20 06:26:26 UTC (rev 1308)
+++ ofw/gui/graphics.fth 2009-08-20 06:31:15 UTC (rev 1309)
@@ -166,9 +166,6 @@
" "(9b)1;1H"(9b)2JK"(9b)2;1H" screen-write
;
-: not-screen? ( -- flag )
- screen-ih stdout @ <> null-ih stdout @ <> and
-;
headers
\ LICENSE_BEGIN
\ Copyright (c) 2006 FirmWorks
Modified: ofw/gui/iconmenu.fth
===================================================================
--- ofw/gui/iconmenu.fth 2009-08-20 06:26:26 UTC (rev 1308)
+++ ofw/gui/iconmenu.fth 2009-08-20 06:31:15 UTC (rev 1309)
@@ -420,13 +420,7 @@
\ headerless
: menu-or-quit ( -- )
- menu? if
- " device_type" stdout @ ihandle>phandle get-package-property 0= if
- get-encoded-string " display" $= if
- menu exit
- then
- then
- then
+ menu? if screen-ih if menu exit then then
quit
;
\ Install menu-or-quit in the "user-interface" defer word later,
Modified: ofw/gui/nullio.fth
===================================================================
--- ofw/gui/nullio.fth 2009-08-20 06:26:26 UTC (rev 1308)
+++ ofw/gui/nullio.fth 2009-08-20 06:31:15 UTC (rev 1309)
@@ -8,7 +8,7 @@
headers
: null-output ( -- )
- " " " null-io" $open-package to null-ih
+ " //null" open-dev to null-ih
null-ih if
stdout @ to old-stdout-ih
null-ih stdout !