]>
wirehaze git hosting - MS-DOS.git/blob - v4.0/src/BIOS/MSAUX.ASM
2 ;----------------------------------------------------------------
4 ; A U X - AUXILARY DEVICE DRIVER :
7 ; This file contains the Auxilary Device Driver. The :
8 ; auxilary driver handles calls to and from the RS-232 port. :
9 ; Three devices uses this code: AUX, COM1, and COM2. AUX and :
10 ; COM1 talk to the zero RS-232 card and COM2 talks to the :
11 ; 'one' RS-232 card. The beginning of the interrupt entry :
12 ; point for these devices sets the variable AUXNUM in the :
13 ; msbio.asm module. If the value is 0 the routines in this :
14 ; file will talk to the the 'zero' card. If the value in :
15 ; AUXNUM is 1 the routines will talk to the 'one' card. :
16 ; The procedure GETDX is called to put the value 0 or 1 in :
17 ; the DX register depending on the value in AUXBUF. :
19 ; The routines in this files are: :
23 ; AUX$READ Read characters from the :
25 ; AUX$RDND Non-desrucrtive read with :
27 ; AUX$FLSH Flush specified device input :
29 ; AUX$WRIT Write characters to the :
31 ; AUX$WRST Get status of specified :
34 ; These routines are not called directly. Call are made via :
35 ; the strategy and interrupt entry point (see Device Header). :
38 ; The Aux Device has a two byte buffer called AUXBUF. The :
39 ; first byte is for the zero card, the second byte is for the :
40 ; one card. A zero value in the byte indicates the buffer is :
41 ; empty. The routines use GETBX to get the address of the :
44 ;----------------------------------------------------------------
46 ;;Ver 3.30 modification ---------------------------
48 INCLUDE MSGROUP
.INC ;DEFINE CODE SEGMENT
52 EXTRN ERR$CNT
:NEAR ;MSBIO1
53 EXTRN GETDX
:NEAR ;MSBIO1
54 EXTRN RDEXIT
:NEAR ;MSCON
55 EXTRN EXIT
:NEAR ;MSBIO1
56 EXTRN BUS$EXIT
:NEAR ;MSBIO1
58 EXTRN AUXBUF
:BYTE ;MSDATA
60 ; VALUES IN AH, REQUESTING FUNCTION OF INT 14H IN ROM BIOS
61 AUXFUNC_SEND EQU
1 ;TRANSMIT
62 AUXFUNC_RECEIVE EQU
2 ;READ
63 AUXFUNC_STATUS EQU
3 ;REQUEST STATUS
65 ; ERROR FLAGS, REPORTED BY INT 14H
67 ; THESE FLAGS REPORTED IN AH:
68 FLAG_DATA_READY EQU
01H ;DATA READY
69 FLAG_OVERRUN EQU
02H ;OVERRUN ERROR
70 FLAG_PARITY EQU
04H ;PARITY ERROR
71 FLAG_FRAME EQU
08H ;FRAMING ERROR
72 FLAG_BREAK EQU 10H
;BREAK DETECT
73 FLAG_TRANHOL_EMP EQU 20H
;TRANSMIT HOLDING REGISTER EMPTY
74 FLAG_TRANSHF_EMP EQU 40H
;TRANSMIT SHIFT REGISTER EMPTY
75 FLAG_TIMEOUT EQU 80H
;TIMEOUT
77 ; THESE FLAGS REPORTED IN AL:
78 FLAG_DELTA_CTS EQU
01H ;DELTA CLEAR TO SEND
79 FLAG_DELTA_DSR EQU
02H ;DELTA DATA SET READY
80 FLAG_TRAIL_RING EQU
04H ;TRAILING EDGE RING INDICATOR
81 FLAG_DELTA_SIG EQU
08H ;DELTA RECEIVE LINE SIGNAL DETECT
82 FLAG_CTS EQU 10H
;CLEAR TO SEND
83 FLAG_DSR EQU 20H
;DATA SET READY
84 FLAG_RING EQU 40H
;RING INDICATOR
85 FLAG_REC_SIG EQU 80H
;RECEIVE LINE SIGNAL DETECT
86 ;;End of modification ------------------
89 ;----------------------------------------------------------------
91 ; Read zero or more characters from Auxilary Device :
93 ; input:es:[di] points to area to receive aux data :
94 ; cx has number of bytes to be read :
95 ; "auxnum" first byte has number of aux device (rel 0):
97 ;----------------------------------------------------------------
100 ASSUME
DS:CODE ; SET BY AUX DEVICE DRIVER ENTRY ROUTINE
101 jcxz EXVEC2
; if no characters, get out
102 call GETBX
; put address of AUXBUF in BX
103 xor AX,AX ; clear AX register
104 xchg AL,[BX] ; Get character , if any, from
105 ; buffer and clear buffer
106 or AL,AL ; if AL is nonzero there was a
107 ; character in the buffer
108 jnz AUX2
; if so skip AUXIN call
110 call AUXIN
; get character from port
112 stosb ; store character
113 loop AUX1
; if more character, go around again
115 Jump EXIT
; all done, successful exit
119 ; AUXIN: make a call on ROM BIOS to read character from
120 ; the auxilary device, then do some error checking.
121 ; If an error occurs then AUXIN jumps to ERR$CNT and
122 ; does NOT return to where it was called from.
127 mov ah,AUXFUNC_RECEIVE
129 ;check for Frame, Parity, or Overrun errors
130 ;WARNING: these error bits are unpredictable
131 ; if timeout (bit 7) is set
132 test ah,FLAG_FRAME
or FLAG_PARITY
or FLAG_OVERRUN
133 jz AROK
;No error if all bits are clear
135 ;Error getting character
136 add sp,+2 ;Remove rtn address (near call)
138 or al,FLAG_REC_SIG
or FLAG_DSR
or FLAG_CTS
142 RET ;CHAR JUST READ IS IN AL, STATUS IS IN AH
145 ;----------------------------------------------------------------
147 ; Aux non-destructive read with no waiting :
149 ; input: es:[di] points to area to receive aux data :
151 ;----------------------------------------------------------------
155 ASSUME
DS:CODE ; SET BY AUX DEVICE DRIVER ENTRY ROUTINE
156 call GETBX
; have BX point to AUXBUF
157 mov AL,[BX] ; copy contents of buffer to AL
158 or AL,AL ; if AL is non-zero (char in buffer)
159 jnz AUXRDX
; then return character
160 call AUXSTAT
; if not, get status of AUX device
161 TEST AH,FLAG_DATA_READY
;TEST DATA READY
162 jz AUXBUS
; then device is busy (not ready)
164 TEST AL,FLAG_DSR
;TEST DATA SET READY
165 jz AUXBUS
; then device is busy (not ready)
166 call AUXIN
; else aux is ready, get character
167 call GETBX
; have bx point to AUXBUF
168 mov [BX],AL ; save character in buffer
170 Jump RDEXIT
; return character
173 Jump BUS$EXIT
; jump to device busy exit
176 ;----------------------------------------------------------------
178 ; Aux Output Status :
180 ;----------------------------------------------------------------
183 ASSUME
DS:CODE ; SET BY AUX DEVICE DRIVER ENTRY ROUTINE
184 call AUXSTAT
; get status of AUX in AX
185 ; now test to see if device is busy
186 ; if this bit is not set,
187 ;;Ver 3.30 modification -----------------------
188 TEST AL,FLAG_DSR
;TEST DATA SET READY
189 jz AUXBUS
; then device is busy (not ready)
190 TEST AH,FLAG_TRANHOL_EMP
;TEST TRANSMIT HOLD REG EMPTY
191 ;;End of modification -------------------------
192 jz AUXBUS
; then device is busy (not ready)
198 ; AUXSTAT makes a call on the ROM-BIOS to determine the status
199 ; of the auxilary device
201 ; AX is filled with status of port.
202 ; DX is changes to specify which card - either 0, 1 (, 2, 3) ;ba
203 ; NO other registers are modified
207 mov ah,AUXFUNC_STATUS
214 ;0=INIT, 1=SEND, 2=RECEIVE, 3=STATUS
215 call GETDX
; have DX point to proper card
216 int 14h
; call rom-bios for status
220 ;----------------------------------------------------------------
222 ; Flush AUX Input buffer - set contents of AUXBUF to zero :
224 ;----------------------------------------------------------------
227 ASSUME
DS:CODE ; SET BY AUX DEVICE DRIVER ENTRY ROUTINE
228 call GETBX
; get BX to point to AUXBUF
229 mov BYTE PTR [BX],0 ; zero out buffer
230 Jump Exit
; all done, successful return
235 ;----------------------------------------------------------------
237 ; Write to Auxilary Device :
239 ;----------------------------------------------------------------
242 ASSUME
DS:CODE ; SET BY AUX DEVICE DRIVER ENTRY ROUTINE
243 jcxz EXVEC2
; if CX is zero, no characters
244 ; to be written, jump to exit
246 mov AL,ES:[DI] ; get character to be written
247 inc DI ; move DI pointer to next character
248 ;;Ver 3.30 modification ---------------------------
249 MOV AH,AUXFUNC_SEND
;VALUE=1, INDICATES A WRITE
250 CALL AUXOP
;SEND CHARACTER OVER AUX PORT
252 TEST AH,FLAG_TIMEOUT
;CHECK FOR ERROR
253 ;;End of modification ---------------------------
254 jz AWOK
; then no error
255 mov AL,10 ; else indicate write fault
256 Jump
ERR$CNT
; call error routines
258 ; if CX is non-zero, still more
260 loop AUX$
LOOP ; more characrter to print
261 Jump Exit
; all done, successful return
266 ; GETBX puts the address of AUXBUF (the Auxilary Device buffer)
267 ; in BX. After calling GETBX, a routine can get to AUXBUF
270 ; NOTE: The getdx routine is in msbio1 and looks like:
271 ; mov dx,word ptr cs:[auxnum]