diff options
Diffstat (limited to 'board-js2x/slof/sio.fs')
-rw-r--r-- | board-js2x/slof/sio.fs | 74 |
1 files changed, 48 insertions, 26 deletions
diff --git a/board-js2x/slof/sio.fs b/board-js2x/slof/sio.fs index c7fa2fe..4c967e0 100644 --- a/board-js2x/slof/sio.fs +++ b/board-js2x/slof/sio.fs @@ -1,63 +1,85 @@ -\ ============================================================================= -\ * Copyright (c) 2004, 2005 IBM Corporation -\ * All rights reserved. -\ * This program and the accompanying materials -\ * are made available under the terms of the BSD License -\ * which accompanies this distribution, and is available at -\ * http://www.opensource.org/licenses/bsd-license.php -\ * -\ * Contributors: -\ * IBM Corporation - initial implementation -\ ============================================================================= +\ ***************************************************************************** +\ * Copyright (c) 2004, 2007 IBM Corporation +\ * All rights reserved. +\ * This program and the accompanying materials +\ * are made available under the terms of the BSD License +\ * which accompanies this distribution, and is available at +\ * http://www.opensource.org/licenses/bsd-license.php +\ * +\ * Contributors: +\ * IBM Corporation - initial implementation +\ ****************************************************************************/ \ National Semiconductor SIO. \ See http://www.national.com/pf/PC/PC87417.html for the datasheet. -\ We only use the first serial port, and the RTC. +\ We use both serial ports, and the RTC. \ See 3.7.5. -new-device s" /ht/isa@4/serial" full-name +new-device 3f8 1 set-unit s" serial" 2dup device-name device-type +\ Enable this UART. +3 7 siocfg! 1 30 siocfg! + \ 8 bytes of ISA I/O space -1 encode-int 0 >serial encode-int+ 8 encode-int+ s" reg" property +my-unit encode-int rot encode-int+ 8 encode-int+ s" reg" property d# 19200 encode-int s" current-speed" property +44 encode-int 0 encode-int+ s" interrupts" property : open true ; : close ; : write ( adr len -- actual ) tuck type ; -: read ( adr len -- actual ) IF key swap c! 1 ELSE 0 THEN ; +: read ( adr len -- actual ) 0= IF drop 0 EXIT THEN + serial-key? 0= IF 0 swap c! -2 EXIT THEN + serial-key swap c! 1 ; + +finish-device + + +new-device 2f8 1 set-unit + +s" serial" 2dup device-name device-type + +\ Enable this UART. +2 7 siocfg! 1 30 siocfg! + +\ 8 bytes of ISA I/O space +my-unit encode-int rot encode-int+ 8 encode-int+ s" reg" property +d# 19200 encode-int s" current-speed" property +43 encode-int 0 encode-int+ s" interrupts" property + +: open true ; +: close ; +: write ( adr len -- actual ) tuck type ; +: read ( adr len -- actual ) 0= IF drop 0 EXIT THEN + serial-key? 0= IF 0 swap c! -2 EXIT THEN + serial-key swap c! 1 ; finish-device \ See the "Device Support Extensions" OF Recommended Practice document. -new-device s" /ht/isa@4/rtc" full-name +new-device 1070 1 set-unit s" rtc" 2dup device-name device-type \ Following is for Linux, to recognize this RTC: s" pnpPNP,b00" compatible -\ Enable the RTC, set its address at 1070. -10 7 siocfg! 1 30 siocfg! 10 60 siocfg! 10 62 siocfg! - -: rtc! 1070 io-c! 1071 io-c! ; -: rtc@ 1070 io-c! 1071 io-c@ ; +: rtc! my-space io-c! my-space 1+ io-c! ; +: rtc@ my-space io-c! my-space 1+ io-c@ ; \ 10 bytes of ISA I/O space, at 1070. -1 encode-int 1070 encode-int+ 10 encode-int+ s" reg" property - -\ Set sane configuration; BCD mode is required by Linux. -20 0a rtc! 02 0b rtc! 00 0c rtc! +my-unit encode-int rot encode-int+ 10 encode-int+ s" reg" property : open true ; : close ; \ XXX: dummy methods. -: get-time ( -- sec min hr day mth yr ) 0 0 0 1 1 d# 1973 ; +: get-time ( -- sec min hr day mth yr ) 38 22 c 1 1 d# 1973 ; : set-time ( sec min hr day mth yr -- ) 3drop 3drop ; finish-device |