Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2216 lines
60 KiB

  1. page,132
  2. ;---------------------------Module-Header-------------------------------;
  3. ; Module Name: IBMCOM.ASM
  4. ;
  5. ; !!!
  6. ;
  7. ; Created: Fri 06-Feb-1987 10:45:12
  8. ; Author: Walt Moore [waltm]
  9. ;
  10. ; Copyright (c) Microsoft Corporation 1985-1990. All Rights Reserved.
  11. ;
  12. ; General Description:
  13. ;
  14. ; History:
  15. ;
  16. ; ***************************************************************
  17. ; Tue Dec 19 1989 09:32:15 -by- Amit Chatterjee [amitc]
  18. ; ---------------------------------------------------------------
  19. ; Modified the 'InitAPort' routine called from 'ReactivateOpenCommPort'.
  20. ; If the out queue for a port has characters to send out then we must
  21. ; restart the trasmission process by faking a comm interrupt on that
  22. ; port.
  23. ; ***************************************************************
  24. ; Tue Nov 21 1989 09:46:50 -by- Amit Chatterjee [amitc]
  25. ; ---------------------------------------------------------------
  26. ; The base port addresses in the COMM1,COMM2,COMM3,COMM4 structures
  27. ; are being zeroed out when the corresponding comm port is closed.
  28. ; This is because the 'ReactivateOpenCommPort' function looks at it
  29. ; and if the port address is not zero decides that comm ports are
  30. ; open.
  31. ; ***************************************************************
  32. ; Tue Nov 14 1989 18:42:00 ADDED TWO EXPORTED FUNCTIONS
  33. ; ---------------------------------------------------------------
  34. ; Added two exported functions 'SuspendOpenCommPorts' and
  35. ; 'ReactivateOpenCommPorts' for 286 winoldap support. The first one simply
  36. ; releases the comm int vects and installs the originall one, the second one
  37. ; hooks back the comm driver comm vectors and then reads the receive buffer,
  38. ; the status and the IIR registers of all the available comm ports to
  39. ; remove pending interrupts. It also reprograms the PIC to enable interrupts
  40. ; on all open comm channels.
  41. ; ---------------------------------------------------------------
  42. ; -by- Amit Chatterjee [amitc]
  43. ; ***************************************************************
  44. ; Tue Aug 30 198? 12:52:00 MAJOR FIX TO HANDLE 8250B
  45. ; ---------------------------------------------------------------
  46. ;
  47. ; 8250B has the following peculiar charactersistic
  48. ; . The very first time (after reset) the Tx Holding Empty
  49. ; interrupt is enabled, an immediate interrupt is generated
  50. ;
  51. ; . After the first time, switching the Tx Holding Empty
  52. ; interrupt enable bit from disabled to enabled will NOT
  53. ; generate an immediate interrupt (unlike in 8250)
  54. ; Because of this the KICKTX routine fails to set the transmit cycle
  55. ; on if the machine has a 8250B
  56. ;
  57. ; This has been taken care as follows:
  58. ; . For the very first byte that is being transmitted, KICKTX
  59. ; is used to generate the first Tx Holding Empty interrupt
  60. ; . Subsequently, whenever we find that the transmit buffer
  61. ; is empty, we use a SOFTWARE INT (either INT 0Bh, or INT 0Ch)
  62. ; to force the first character out, once this is done the
  63. ; Tx Holding Empty interrupt will be generated once the buffer
  64. ; really is empty
  65. ; . Now we no longer disable the Tx Holding Empty interrupt
  66. ; in the Xmit ISR to ensure that even m/cs with 8250, use
  67. ; the software int to kick the tx interrupt on after the
  68. ; first time.
  69. ; . The software interrupt is also forced whenever an X-ON
  70. ; character is received.
  71. ;
  72. ; The code that implements the above logic is marked out with a line
  73. ; asterixes.
  74. ; ------------------------------------------------------------------
  75. ; -by- Amit Chatterjee [amitc]
  76. ; ******************************************************************
  77. ;
  78. ; 062587 HSFlag and Evtmask in DoLPT. These fields do not exist
  79. ; for LPT type devices. The code which manipulated them
  80. ; was removed
  81. ;
  82. ; KickTx from $SndCom - interrupts were not disabled when
  83. ; calling KickTx.
  84. ;
  85. ; $SetCom - added CLD at the start
  86. ;
  87. ; $SetQue - movsw ==> stosw
  88. ;
  89. ; 111285 Changed the Timeout from 7 to 30 seconds.
  90. ;
  91. ; 110885 Forgot to set EV_RxChar event when a character
  92. ; was received.
  93. ;
  94. ; 102985 INS8250, INS8250B bug with enabling interrupts.
  95. ; Setting ACE_ETBEI in the Interrupt Enable Register
  96. ; will cause an immediate interrupt regardless of
  97. ; whether the transmitter register is empty or not.
  98. ; The first interrupt MAY also be missed.
  99. ;
  100. ; The first case is not a problem since we only enable
  101. ; interrupts if the transmitter register is empty. The
  102. ; second problem was showing up on Microsoft System Cards
  103. ; in PC-XTs. The first interrupt was missed after a cold
  104. ; boot. National claims the fix is to write the register
  105. ; twice, which SEEMS to work...
  106. ;
  107. ; Added timeout code to $TRMCOM. If the number of
  108. ; characters in the output queue doesn't decrease
  109. ; in "Timeout" seconds, then the port will be closed
  110. ; anyway. Also flushed the input queue and added a
  111. ; discard-input flag for the data available interrupt
  112. ; code to discard any input received while terminating
  113. ; a port. $TRMCOM will return an error code if it
  114. ; discarded any output data.
  115. ;
  116. ; Removed infinite timeout test in MSRWait routine.
  117. ; Still bad, but it will timeout around 65 seconds
  118. ; instead of never.
  119. ;
  120. ; 102785 LPT initialization code was jumping to InitCom90,
  121. ; which was setting EFlags[si] to null. Well, LPTs
  122. ; don't have an EFlags field, so the null was getting
  123. ; stuffed over the LSB of BIOSPortLoc of the next LPT
  124. ; device.
  125. ;
  126. ; 101185 Save interrupt vector when opening a comm port
  127. ; and restore it when closing. Would you believe
  128. ; there are actually programs that assume the
  129. ; vector points to a non-specific 8259 ACK and
  130. ; an IRET!
  131. ;
  132. ; 100985 Added MS-NET support to gain exclusive control
  133. ; of an LPT port if DOS 3.x and not running in as
  134. ; a server, receiver, or messenger. Required to
  135. ; keep another application, such as command.com
  136. ; from closing the stream or mixing their output
  137. ; with ours.
  138. ; sudeepb 10-Jan-1993 changed the costly cli/sti with non-trapping
  139. ; FCLI/FSTI macros
  140. ;-----------------------------------------------------------------------;
  141. title IBMCom - IBM PC, PC-XT, PC-AT, PS/2 Communications Interface
  142. .xlist
  143. include cmacros.inc
  144. include comdev.inc
  145. include ins8250.inc
  146. include ibmcom.inc
  147. include vint.inc
  148. .list
  149. externNP GetDEB
  150. externNP DoLPT
  151. externNP StringToLPT
  152. externNP FindCOMPort
  153. externNP StealPort
  154. ifdef NEC_98
  155. externFP MSR_READ_Call ;[QN] ;(ins 92.09.27)
  156. externFP AOBA_MSR_READ_Call ;AOBA-bug ins 94.11.19 KBNES
  157. externFP Set8251modeFar ;(ins 94.04.18)
  158. externFP SetFIFOmodeFar ;(ins 94.04.18)
  159. endif ; NEC_98
  160. sBegin Data
  161. externB $MachineID
  162. ifdef NEC_98
  163. ;-------------------------------------------------------;[QN] (ins 92.08.xx)
  164. ; MSR's_DELAY local buffer ;[QN] (ins 92.08.xx)
  165. ;-------------------------------------------------------;[QN] (ins 92.08.xx)
  166. _BIOS_FLAG1_ DB 0 ;[0:458H] ;[QN] (ins 92.08.xx)
  167. _BIOS_FLAG2_ DB 0 ;[0:480H] ;[QN] (ins 92.08.xx)
  168. _BIOS_FLAG3_ DB 0 ;[0:45BH] ;[QN] (ins 93.03.09)
  169. _CPU_ DW 0 ;loop count ;[QN] (ins 92.08.xx)
  170. _TIME_ DW 0 ;target time ;[QN] (ins 92.08.xx)
  171. _MUKASI_ DW 0 ;previous time ;[QN] (ins 92.08.xx)
  172. endif ; NEC_98
  173. sEnd Data
  174. sBegin Code
  175. assumes cs,Code
  176. assumes ds,Data
  177. page
  178. ;----------------------------Public Routine-----------------------------;
  179. ;
  180. ; $RECCOM - Receive Characters From Device
  181. ;
  182. ; Read Byte From RS232 Input Queue If Data Is Ready
  183. ;
  184. ; LPT ports will return with an indication that no characters are
  185. ; available.
  186. ;
  187. ; Entry:
  188. ; AH = Device ID
  189. ; Returns:
  190. ; 'Z' clear if data available
  191. ; AL = byte
  192. ; Error Returns:
  193. ; 'Z' Set if error or no data
  194. ; AX = error code
  195. ; AX = 0 if no data
  196. ; Registers Preserved:
  197. ; SI,DI,DS
  198. ; Registers Destroyed:
  199. ; AX,BX,CX,DX,ES,FLAGS
  200. ; History:
  201. ;-----------------------------------------------------------------------;
  202. ;------------------------------Pseudo-Code------------------------------;
  203. ; {
  204. ; }
  205. ;-----------------------------------------------------------------------;
  206. assumes ds,Data
  207. assumes es,nothing
  208. public $RECCOM
  209. $RECCOM proc near
  210. push si ;Once again, save some registers
  211. push di
  212. call GetDEB ;Get DEB pointer in SI
  213. jc RecCom10 ;Invalid Port [rkh] ...
  214. jns RecCom20 ;COM port
  215. jmp RecCom95 ;LPT port, return no characters
  216. RecCom10:
  217. jmp RecCom100 ; Invalid Port
  218. ; Before removing any charcters from the input queue, check to see
  219. ; if XON needs to be issued. If it needs to be issued, set the
  220. ; flag that will force it and arm transmit interrupts.
  221. RecCom20:
  222. test [si.DCB_Flags],fEnqAck+fEtxAck ;Enq or Etx Ack?
  223. jz RecCom32 ; No
  224. test HSFlag[si],EnqReceived+HHSDropped ;Enq recvd or lines dropped?
  225. jnz RecCom21 ; No Enq recvd & no lines dropped
  226. jmp RecCom60 ; No Enq recvd & no lines dropped
  227. RecCom21:
  228. jmp short RecCom34
  229. RecCom32:
  230. test HSFlag[si],HSSent ;Handshake sent?
  231. ifdef NEC_98
  232. jnz RecCom34 ; No XOFF sent & no lines dropped
  233. jmp RecCom60 ; No XOFF sent & no lines dropped
  234. else ; NEC_98
  235. jnz RecCom33 ; No XOFF sent & no lines dropped
  236. jmp RecCom60 ; No XOFF sent & no lines dropped
  237. RecCom33:
  238. endif ; NEC_98
  239. RecCom34:
  240. mov ax,QInCount[si] ;Get current count of input chars
  241. cmp ax,[si.DCB_XonLim] ;See if at XOn limit
  242. ifdef NEC_98
  243. jbe Dummy00 ;(95.1.25)
  244. jmp RecCom60 ;Not at XOn limit yet
  245. Dummy00:
  246. else ; NEC_98
  247. ja RecCom60 ;Not at XOn limit yet
  248. endif ; NEC_98
  249. ; If any hardware lines are down, then raise them. Then see
  250. ; about sending XON.
  251. ifdef NEC_98
  252. mov dx,CommandPort[si] ;Get the port ;[QN] (ins 92.08.xx)
  253. else ; NEC_98
  254. mov dx,Port[si] ;Get the port
  255. endif ; NEC_98
  256. mov ah,HHSLines[si] ;Get hardware lines mask
  257. ifndef NEC_98
  258. call DOCLI ;Handle this as a critical section
  259. endif ; NEC_98
  260. mov cl,HSFlag[si] ;Get handshaking flags
  261. or ah,ah ;Any hardware lines to play with?
  262. jz RecCom40 ; No
  263. ifdef NEC_98
  264. mov al,CommandShadow[si] ;8251 Command get (ins 92.08.xx)|
  265. test ah,ACE_DTR ;DTR handshake Enable ? (ins 92.08.xx)|
  266. jz RecCom31 ; No (ins 92.08.xx)|
  267. or al,DTR ;Set 8251's DTR Active ! (ins 92.08.xx)|
  268. RecCom31: ; (ins 92.08.xx)|
  269. test ah,ACE_RTS ;RTS handshake Enable ? (ins 92.08.xx)|
  270. jz RecCom33 ; No (ins 92.08.xx)|
  271. or al,RTS ;Set 8251's RTS Active ! (ins 92.08.xx)|
  272. RecCom33: ; (ins 92.08.xx)|
  273. push dx ; (ins 94.05.18)|
  274. mov dh,CommandShadow[si] ; (ins 94.05.18)|
  275. mov dl,al ; (ins 94.05.18)|
  276. and dx,2222h ; (ins 94.05.18)|
  277. cmp dh,dl ; (ins 94.05.18)|
  278. pop dx ; (ins 94.05.18)|
  279. je @f ; (ins 94.05.18)|
  280. FCLI ; (ins 94.05.18)|
  281. test [si.AOBA_flag],fFIFO_Mode ; (ins 94.05.18)|
  282. jz RecCom35 ;Now, 8251 mode (ins 94.05.18)|
  283. call Set8251modeFar ;Change to 8251 mode (ins 94.05.18)|
  284. RecCom35: ; (ins 94.05.18)|
  285. out dx,al ; (ins 92.08.xx)|
  286. test [si.AOBA_flag],fFIFO_Mode ; (ins 94.05.18)|
  287. jz @F ;Now, 8251 mode (ins 94.05.18)|
  288. call SetFIFOmodeFar ;Change to FIFO mode (ins 94.05.18)|
  289. @@: ; (ins 94.05.18)|
  290. mov CommandShadow[si],al ;Get Back 8251 Command (ins 92.08.xx)|
  291. else ; NEC_98
  292. add dl,ACE_MCR ;--> Modem control register
  293. in al,dx
  294. or al,ah ;Turn on the hardware bits
  295. iodelay
  296. out dx,al
  297. endif ; NEC_98
  298. and cl,NOT HHSDropped ;Show hardware lines back up
  299. RecCom40:
  300. test [si.DCB_Flags],fEnqAck+fEtxAck ;Enq or Etx Ack?
  301. jz RecCom47 ; No
  302. test cl,EnqReceived ;Did we receive Enq?
  303. jz RecCom55 ; No
  304. and cl,NOT EnqReceived
  305. jmp short RecCom50
  306. RecCom47:
  307. test cl,XOffSent ;Did we send XOFF?
  308. jz RecCom55 ; No
  309. and cl,NOT XOffSent ;Remove XOFF sent flag
  310. RecCom50:
  311. or cl,XOnPending ;Show XON or ACK must be sent
  312. ifdef NEC_98
  313. mov HSFlag[si],cl ;Store handshake flag ;[QN](ins 92.08.xx /92.10.21)
  314. endif ; NEC_98
  315. call KickTx ;Kick xmit if needed
  316. RecCom55:
  317. mov HSFlag[si],cl ;Store handshake flag
  318. call DOSTI ;Can allow interrupts now
  319. ; Now we can get down to the business at hand, and remove a character
  320. ; from the receive queue. If a communications error exists, we return
  321. ; that, and nothing else.
  322. RecCom60:
  323. xor ax,ax
  324. or ax,ComErr[si] ;Any Errors?
  325. jnz RecCom100 ; Yes, return the error code
  326. or ax,QInCount[si] ;Get current input char count
  327. jz RecCom90 ;No characters in the queue
  328. les di,QInAddr[si] ;Get queue pointer
  329. assumes es,nothing
  330. mov bx,QInGet[si] ;Also get the index to head
  331. mov al,es:[bx][di] ;Finally, get byte from queue
  332. inc bx ;Update queue index
  333. cmp bx,QInSize[si] ;See if time for wrap-around
  334. jc RecCom70 ;Jump if no wrap
  335. xor bx,bx ;wrap by zeroing the index
  336. RecCom70:
  337. mov QInGet[si],bx ;Save new head pointer
  338. dec QInCount[si] ;Dec # of bytes in queue
  339. mov cx, [si.QinCount]
  340. cmp cx, [si.RecvTrigger] ;Q: have we read below trigger?
  341. jae RecCom80 ; N:
  342. and [si.NotifyFlagsHI], NOT CN_RECEIVE ; allow timeout notify again
  343. RecCom80:
  344. or sp,sp ;Reset PSW.Z
  345. pop di
  346. pop si
  347. ret
  348. ; No characters in the input queue. Check to see if EOF
  349. ; was received, and return it if it was. Otherwise show
  350. ; no characters.
  351. RecCom90:
  352. test [si.DCB_Flags],fBinary ;Are we doing binary stuff?
  353. jnz RecCom95 ; Yes, show no characters
  354. mov al,[si.DCB_EofChar] ;Assume EOF
  355. test EFlags[si],fEOF ;Has end of file char been received?
  356. jnz RecCom80 ; Yes, show end of file
  357. RecCom95:
  358. xor ax,ax ;Show no more characters
  359. ; Return with 'Z' to show error or no characters
  360. RecCom100:
  361. xor cx,cx ;Set PSW.Z
  362. pop di
  363. pop si
  364. ret
  365. $RECCOM endp
  366. page
  367. ;----------------------------Public Routine-----------------------------;
  368. ;
  369. ; $RECSTR - Receive Characters From Device
  370. ;
  371. ; Read Byte From RS232 Input Queue If Data Is Ready
  372. ;
  373. ; LPT ports will return with an indication that no characters are
  374. ; available.
  375. ;
  376. ; Entry:
  377. ; AH = Device ID
  378. ; ES:DI -> receive buffer
  379. ; CX max bytes to read
  380. ; Returns:
  381. ; 'Z' clear if data available
  382. ; AX = # of bytes read
  383. ; Error Returns:
  384. ; 'Z' Set if error or no data
  385. ; AX = error code
  386. ; AX = 0 if no data
  387. ; Registers Preserved:
  388. ; SI,DI,DS
  389. ; Registers Destroyed:
  390. ; AX,BX,CX,DX,ES,FLAGS
  391. ; History:
  392. ;-----------------------------------------------------------------------;
  393. ;------------------------------Pseudo-Code------------------------------;
  394. ; {
  395. ; }
  396. ;-----------------------------------------------------------------------;
  397. assumes ds,Data
  398. assumes es,nothing
  399. public $RECSTR
  400. $RECSTR proc near
  401. push si ;Once again, save some registers
  402. push di
  403. call GetDEB ;Get DEB pointer in SI
  404. jc RecStr10 ;Invalid Port [rkh] ...
  405. jns RecStr20 ;COM port
  406. jmp RecStr95 ;LPT port, return no characters
  407. RecStr10:
  408. jmp RecStr100 ; Invalid Port
  409. RecStr15:
  410. jmp RecStr90
  411. RecStr20:
  412. xor ax,ax
  413. or ax,ComErr[si] ;Any Errors?
  414. jnz RecStr10 ; Yes, return the error code
  415. or ax,QInCount[si] ;Get current input char count
  416. jz RecStr15 ;No characters in the queue
  417. cmp cx, ax ;Q: more chars available than can read?
  418. jbe short RecStr30 ; N:
  419. mov cx, ax ; Y: adjust # of chars to read
  420. RecStr30:
  421. push cx
  422. mov dx, QInSize[si]
  423. mov ax, QInGet[si]
  424. sub dx, ax ; dx = # of bytes before end of buf
  425. cmp dx, cx ;Q: more avail than can read?
  426. jbe short RecStr40 ; N:
  427. mov dx, cx ; Y: adjust avail count
  428. RecStr40:
  429. xchg cx, dx ; cx = # of bytes for 1st copy
  430. sub dx, cx ; dx = # of bytes for 2nd copy
  431. push ds
  432. push si
  433. lds bx, QInAddr[si]
  434. mov si, bx
  435. add si, ax ; ds:si -> first char in buffer
  436. cld
  437. rep movsb ; do first copy
  438. mov cx, dx
  439. jcxz short RecStr50 ; jump if no 2nd copy needed
  440. mov si, bx ; ds:si -> start of buffer
  441. rep movsb ; do 2nd copy
  442. RecStr50:
  443. sub si, bx ; si = new QInGet
  444. mov bx, si
  445. pop si
  446. pop ds
  447. pop cx
  448. call DOCLI
  449. mov QInGet[si], bx ; update QInGet
  450. sub QInCount[si], cx ; update count
  451. mov ax, QInCount[si]
  452. call DOSTI
  453. cmp ax, [si.RecvTrigger] ;Q: have we read below trigger?
  454. jae @F ; N:
  455. and [si.NotifyFlagsHI], NOT CN_RECEIVE ; allow timeout notify again
  456. @@:
  457. ; Check to see if XON needs to be issued. If it needs to be issued, set the
  458. ; flag that will force it and arm transmit interrupts.
  459. test [si.DCB_Flags],fEnqAck+fEtxAck ;Enq or Etx Ack?
  460. jz @F ; No
  461. test HSFlag[si],EnqReceived+HHSDropped ;Enq recvd or lines dropped?
  462. jnz RecStr58 ; No Enq recvd & no lines dropped
  463. jmp RecStr80 ; No Enq recvd & no lines dropped
  464. RecStr58:
  465. jmp short RecStr60
  466. @@:
  467. test HSFlag[si],HSSent ;Handshake sent?
  468. jnz RecStr59 ; No XOFF sent & no lines dropped
  469. jmp RecStr80 ; No XOFF sent & no lines dropped
  470. RecStr59:
  471. RecStr60:
  472. ;ax = current count of input chars
  473. cmp ax,[si.DCB_XonLim] ;See if at XOn limit
  474. ifdef NEC_98
  475. jbe Dummy10 ;(95.1.25)
  476. jmp RecStr80 ;Not at XOn limit yet
  477. Dummy10:
  478. else ; NEC_98
  479. ja RecStr80 ;Not at XOn limit yet
  480. endif ; NEC_98
  481. ;; int 1
  482. ; If any hardware lines are down, then raise them. Then see
  483. ; about sending XON.
  484. ifdef NEC_98
  485. push cx ; (ins 92.09.xx)|
  486. mov dx,CommandPort[si] ;Get the port (92.08.xx)|
  487. mov ah,HHSLines[si] ;Get hardware lines mask (92.08.xx)|
  488. mov cl,HSFlag[si] ;Get handshaking flags (92.08.xx)|
  489. or ah,ah ;Any H/W lines to play with?(92.08.xx)|
  490. jz RecStr64 ; No (Goto Xmit Xon Char) (92.08.xx)|
  491. mov al,CommandShadow[si] ;8151 Command get (92.08.xx)|
  492. test ah,ACE_DTR ;DTR handshake Enable ? (92.08.xx)|
  493. jz RecStr61 ; No (92.08.xx)|
  494. or al,DTR ;Set 8251's DTR Active ! (92.08.xx)|
  495. RecStr61: ; (92.08.xx)|
  496. test ah,ACE_RTS ;RTS handshake Enable ? (92.08.xx)|
  497. jz RecStr63 ; No (92.08.xx)|
  498. or al,RTS ;Set 8251's RTS Active ! (92.08.xx)|
  499. RecStr63: ; (92.08.xx)|
  500. push dx ; (ins 94.05.18)|
  501. mov dh,CommandShadow[si] ; (ins 94.05.18)|
  502. mov dl,al ; (ins 94.05.18)|
  503. and dx,2222h ; (ins 94.05.18)|
  504. cmp dh,dl ; (ins 94.05.18)|
  505. pop dx ; (ins 94.05.18)|
  506. je @f ; (ins 94.05.18)|
  507. FCLI ; (ins 94.05.18)|
  508. test [si.AOBA_flag],fFIFO_Mode ; (ins 94.05.18)|
  509. jz RecStr63_1 ;Now, 8251 mode (ins 94.05.18)|
  510. call Set8251modeFar ;Change to 8251 mode (ins 94.05.18)|
  511. RecStr63_1: ; (ins 94.05.18)|
  512. out dx,al ; (92.08.xx)|
  513. test [si.AOBA_flag],fFIFO_Mode ; (ins 94.05.18)|
  514. jz @F ;Now, 8251 mode (ins 94.05.18)|
  515. call SetFIFOmodeFar ;Change to FIFO mode (ins 94.05.18)|
  516. @@: ; (ins 94.05.18)|
  517. mov CommandShadow[si],al ;Get Back 8251 Command Byte (92.08.xx)|
  518. and cl,NOT HHSDropped ;Show hardware lines back up(92.08.xx)|
  519. RecStr64: ; (92.08.xx)|
  520. else ; NEC_98
  521. mov dx,Port[si] ;Get the port
  522. mov ah,HHSLines[si] ;Get hardware lines mask
  523. push cx
  524. call DOCLI ;Handle this as a critical section
  525. mov cl,HSFlag[si] ;Get handshaking flags
  526. or ah,ah ;Any hardware lines to play with?
  527. jz @F ; No
  528. add dl,ACE_MCR ;--> Modem control register
  529. in al,dx
  530. or al,ah ;Turn on the hardware bits
  531. iodelay
  532. out dx,al
  533. and cl,NOT HHSDropped ;Show hardware lines back up
  534. @@:
  535. endif ; NEC_98
  536. test [si.DCB_Flags],fEnqAck+fEtxAck ;Enq or Etx Ack?
  537. jz @F ; No
  538. test cl,EnqReceived ;Did we receive Enq?
  539. jz RecStr70 ; No
  540. and cl,NOT EnqReceived
  541. jmp short RecStr65
  542. @@:
  543. test cl,XOffSent ;Did we send XOFF?
  544. jz RecStr70 ; No
  545. and cl,NOT XOffSent ;Remove XOFF sent flag
  546. RecStr65:
  547. or cl,XOnPending ;Show XON or ACK must be sent
  548. ifdef NEC_98
  549. mov HSFlag[si],cl ;Store handshake flg ;[QN](ins92.10.19)
  550. endif ; NEC_98
  551. call KickTx ;Kick xmit if needed
  552. RecStr70:
  553. mov HSFlag[si],cl ;Store handshake flag
  554. call DOSTI ;Can allow interrupts now
  555. pop cx
  556. RecStr80:
  557. mov ax, cx
  558. or sp,sp ;Reset PSW.Z
  559. pop di
  560. pop si
  561. ret
  562. ; No characters in the input queue. Check to see if EOF
  563. ; was received, and return it if it was. Otherwise show
  564. ; no characters.
  565. RecStr90:
  566. test [si.DCB_Flags],fBinary ;Are we doing binary stuff?
  567. jnz RecStr95 ; Yes, show no characters
  568. mov al,[si.DCB_EofChar] ;Assume EOF
  569. test EFlags[si],fEOF ;Has end of file char been received?
  570. jnz RecStr80 ; Yes, show end of file
  571. RecStr95:
  572. xor ax,ax ;Show no more characters
  573. ; Return with 'Z' to show error or no characters
  574. RecStr100:
  575. xor cx,cx ;Set PSW.Z
  576. pop di
  577. pop si
  578. ret
  579. $RECSTR endp
  580. page
  581. ;----------------------------Public Routine-----------------------------;
  582. ;
  583. ; $SNDIMM - Send A Character Immediately
  584. ;
  585. ; This routine either sends a character to the port immediately,
  586. ; or places the character in a special location which is used by
  587. ; the next transmit interrupt to transmit the character prior to
  588. ; those in the normal transmit queue.
  589. ;
  590. ; For LPT ports, the character is always sent immediately.
  591. ;
  592. ; Entry:
  593. ; AH = Device ID
  594. ; AL = Character
  595. ; Returns:
  596. ; AX = 0
  597. ; Error Returns:
  598. ; AX = 8000H if Bad ID
  599. ; AX = 4000H if couldn't send because another character
  600. ; transmitted "immediately" is waiting to be sent
  601. ; Registers Destroyed:
  602. ; AX,BX,CX,DX,ES,FLAGS
  603. ; History:
  604. ;-----------------------------------------------------------------------;
  605. assumes ds,Data
  606. assumes es,nothing
  607. public $SNDIMM
  608. $SNDIMM proc near
  609. push si
  610. call GetDEB ;Get pointer to the DEB
  611. jc SendImm20 ;Bad ID, return an error
  612. jns SendImm10 ;Its a COM port
  613. ; For LPT ports, call DoLPT to do the dirty work. If DoLPT
  614. ; returns an error code, map it to 4000h.
  615. xor ch,ch ;Show xmit character
  616. call DoLPT ;Do the work here
  617. or ax,ax ;Error occur?
  618. jz SendImm20 ; No, show all is OK
  619. mov ax,4000h ; Yes, return 4000h
  620. jmp short SendImm20
  621. SendImm10:
  622. mov dl, al
  623. mov ax,4000h ;In case we cannot send
  624. test EFlags[si],fTxImmed ;Another char waiting "immediately"?
  625. jnz SendImm20 ; Yes, return error
  626. mov ah,dl ;Set char for TXI
  627. call DOCLI ;TXI is critical section code
  628. call TXI ;Set character to tx immediately
  629. call DOSTI
  630. xor ax,ax ;Show all is OK
  631. SendImm20:
  632. pop si
  633. ret
  634. $SNDIMM endp
  635. page
  636. ;----------------------------Public Routine-----------------------------;
  637. ;
  638. ; $SNDCOM - Send Byte To Port
  639. ;
  640. ; The given byte is sent to the passed port if possible.
  641. ; If the output queue is full, an error will be returned.
  642. ;
  643. ; Entry:
  644. ; AH = Device ID
  645. ; AL = Character
  646. ; Returns:
  647. ; AX = 0
  648. ; Error Returns:
  649. ; AX = error code
  650. ; Registers Destroyed:
  651. ; AX,BX,CX,DX,ES,FLAGS
  652. ; History:
  653. ;-----------------------------------------------------------------------;
  654. assumes ds,Data
  655. assumes es,nothing
  656. public $SNDCOM
  657. $SNDCOM proc near
  658. push si
  659. push di
  660. call GetDEB ;--> DEB
  661. jc SendCom40 ;Invalid ID
  662. jns SendCom20 ;Its a COM port
  663. ; Handle the transmission of a LPT character. The ROM BIOS int 17
  664. ; call will be made to do the transmission. The port address will
  665. ; be restored during the call, then zeroed out upon return.
  666. SendCom10:
  667. xor ch,ch ;Show xmit character
  668. call DoLPT ;Do the work here
  669. jmp short SendCom40 ;Return the status to caller
  670. ; Send a character to a COM port. Return an error if control
  671. ; line timeout occurs or there is no room in the output queue.
  672. SendCom20:
  673. push ax ;Save character
  674. call MSRWait ;See if lines are correct for output
  675. pop ax ;Restore char
  676. jnz SendCom60 ;Timeout occured, return error
  677. mov cx,QOutSize[si] ;See if queue is full
  678. cmp cx,QOutCount[si]
  679. jle SendCom50 ;There is no room in the queue
  680. les di,QOutAddr[si] ;--> output queue
  681. assumes es,nothing
  682. mov bx,QOutPut[si] ;Get index into queue
  683. mov es:[bx][di],al ;Store the byte
  684. inc bx ;Update index
  685. cmp bx,cx ;Wrap time?
  686. jc SendCom30 ; No
  687. xor bx,bx ;Wrap-around is a new zero pointer
  688. SendCom30:
  689. call DOCLI
  690. mov QOutPut[si],bx ;Store updated pointer
  691. mov ax,QOutCount[si] ; get the count
  692. inc ax ; have the updated value in AX for test later
  693. mov QOutCount[si],ax ;Update queue population
  694. call KickTx ;Make sure xmit interrupt is armed
  695. call DOSTI
  696. xor ax,ax ;Show no error (that we know of)
  697. ;****************************************************************************
  698. SendCom40:
  699. pop di
  700. pop si
  701. ret
  702. SendCom50:
  703. or by ComErr+1[si],HIGH CE_TXFULL
  704. .errnz LOW CE_TXFULL
  705. SendCom60:
  706. mov ax,ComErr[si] ;Return error code to caller
  707. jmp short SendCom40
  708. $SNDCOM endp
  709. page
  710. ;----------------------------Public Routine-----------------------------;
  711. ;
  712. ; $SNDCOMSTR - Send buffer To Port
  713. ;
  714. ; The given buffer is sent to the passed port if possible.
  715. ; Once the output queue is detected as being full, a CE_TXFULL error
  716. ; will be indicated and AX will be returned as the # of chars actually
  717. ; queued.
  718. ;
  719. ; Entry:
  720. ; DS:SI --> DEB
  721. ; ES:DI --> buffer
  722. ; Returns:
  723. ; AX = # of bytes queued
  724. ; Registers Destroyed:
  725. ; AX,BX,CX,DX,DI,ES,FLAGS
  726. ; History:
  727. ;-----------------------------------------------------------------------;
  728. assumes ds,Data
  729. assumes es,nothing
  730. public $SNDCOMSTR
  731. $SNDCOMSTR proc near
  732. push cx ; save count
  733. call GetDEB
  734. jc cws_error ; jump if id invalid
  735. jns cws_comm ; jump if COM port
  736. call StringToLPT
  737. pop cx ; discard saved count, ax = # transfered
  738. jmp short cws_exit
  739. cws_error:
  740. pop ax
  741. sub ax, cx ; ax = # transfered
  742. cws_exit:
  743. ret
  744. cws_comm:
  745. call MSRWait ;See if lines are correct for output
  746. pop cx
  747. push cx
  748. jnz cws_error ;Timeout occured, return error
  749. mov dx, QOutSize[si] ;See if queue is full
  750. sub dx, QOutCount[si] ; dx = # of chars free in queue
  751. jg scs_loop
  752. jmp scs_full ;There is no room in the queue
  753. scs_loop:
  754. push cx ; save count left to send
  755. cmp cx, dx ;Q: room for buffer in queue?
  756. jbe @f ; Y:
  757. mov cx, dx ; N: adjust size to send
  758. @@:
  759. push cx ; save # of chars which will be copied
  760. push si
  761. push ds
  762. push di
  763. push es
  764. les bx,QOutAddr[si] ;--> output queue
  765. assumes es,nothing
  766. mov dx, QOutSize[si]
  767. mov di, QOutPut[si] ;Get index into queue
  768. sub dx, di ; dx = # of free chars before end of queue
  769. cmp dx, cx
  770. jbe @f
  771. mov dx, cx
  772. @@:
  773. xchg cx, dx ; cx = # of chars for 1st copy
  774. sub dx, cx ; dx = # of chars for 2nd copy
  775. pop ds
  776. pop si ; ds:si -> src buffer
  777. assumes ds,nothing
  778. add di, bx ; es:di -> current pos in queue
  779. cld
  780. rep movsb ; copy first section
  781. mov cx, dx
  782. jcxz @F
  783. mov di, bx ; circle back to start of queue
  784. rep movsb ; copy 2nd section
  785. @@:
  786. sub di, bx ; di last index into queue
  787. mov dx, di
  788. mov di, si ; last location in src buffer
  789. mov si, ds
  790. mov es, si ; es:di -> last loc in src buf
  791. pop ds
  792. pop si ; ds:si -> ComDEB
  793. assumes ds,data
  794. pop bx ; # of chars copied
  795. call DOCLI
  796. mov QOutPut[si], dx ;new index into queue
  797. add QOutCount[si], bx
  798. call KickTx
  799. call DOSTI
  800. pop cx
  801. sub cx, bx ; # of chars left to send
  802. jnz scs_full_2 ; jump if none
  803. scs_exit:
  804. pop ax
  805. sub ax, cx ; ax = # transfered
  806. ret
  807. scs_full:
  808. call DOCLI
  809. call KickTx
  810. call DOSTI
  811. scs_full_2:
  812. or by ComErr+1[si],HIGH CE_TXFULL
  813. .errnz LOW CE_TXFULL
  814. jmp scs_exit
  815. $SNDCOMSTR endp
  816. page
  817. ;----------------------------Public Routine-----------------------------;
  818. ;
  819. ; $FLUSH - Flush The Input and Output Queues
  820. ;
  821. ; This is a hard initialization of the transmit and receive queue's,
  822. ; which immediately empties the given queue.
  823. ;
  824. ; LPT ports will just return the device error word
  825. ;
  826. ; Entry:
  827. ; AH = Device ID
  828. ; BH = Queue # to clear (0=Tx, 1=Rx)
  829. ; Returns:
  830. ; AX = Device Error Word. (Not reset)
  831. ; Error Returns:
  832. ; AX = error code
  833. ; Registers Preserved:
  834. ; SI,DI,DS
  835. ; Registers Destroyed:
  836. ; AX,BX,CX,DX,ES,FLAGS
  837. ; History:
  838. ;-----------------------------------------------------------------------;
  839. ;------------------------------Pseudo-Code------------------------------;
  840. ; {
  841. ; }
  842. ;-----------------------------------------------------------------------;
  843. assumes ds,Data
  844. assumes es,nothing
  845. public $FLUSH
  846. $FLUSH proc near
  847. push si
  848. push di
  849. call GetDEB ;si --> DEB
  850. jc Flush40 ;Invalid ID
  851. js Flush30 ;LPT port, return any error
  852. mov cx,QOutCount-QInCount ;# of bytes to zero
  853. lea di,QInCount[si] ;--> receive queue data
  854. or bh,bh ;Transmit queue?
  855. jnz Flush10 ; No, input queue
  856. add di,cx ; Yes, --> xmit queue data
  857. Flush10:
  858. cld
  859. push ds
  860. pop es
  861. assumes es,nothing
  862. xor al,al
  863. call DOCLI ;Time to worry about critical sections
  864. rep stosb
  865. call DOSTI
  866. .errnz QInGet-QInCount-2
  867. .errnz QInPut-QInGet-2
  868. .errnz QOutCount-QInPut-2
  869. .errnz QOutGet-QOutCount-2
  870. .errnz QOutPut-QOutGet-2
  871. or bh,bh ;Rx queue?
  872. jz Flush30 ; No, xmit queue
  873. ; If the queue to be cleared is the receive queue, any
  874. ; hardware handshake must be cleared to prevent a possible
  875. ; deadlock situation. Since we just zeroed the queue count,
  876. ; a quick call to $RecCom should do wonders to clear any
  877. ; receive handshake (i.e. send XON if needed).
  878. Flush20:
  879. call $RECCOM ;Take care of handshakes here
  880. Flush30:
  881. mov ax,ComErr[si] ;And return the error word.
  882. Flush40:
  883. pop di
  884. pop si
  885. ret
  886. $FLUSH endp
  887. page
  888. ;----------------------------Private-Routine----------------------------;
  889. ;
  890. ; TXI - Transmit A Character Immediately
  891. ;
  892. ; Set up a character to be transmitted "immediately".
  893. ; by placing the character in a location that guarantees
  894. ; it to be the next character transmitted.
  895. ;
  896. ; The check to see if the immediate character can be placed has
  897. ; already been made prior to entry.
  898. ;
  899. ; Interrupts must be disabled before entering this code
  900. ;
  901. ; Entry:
  902. ; AH = Character
  903. ; DS:SI --> DEB
  904. ; Returns:
  905. ; None
  906. ; Error Returns:
  907. ; None
  908. ; Registers Preserved:
  909. ; BX,CX,SI,DI,DS,ES
  910. ; Registers Destroyed:
  911. ; L,DX,FLAGS
  912. ; History:
  913. ;-----------------------------------------------------------------------;
  914. ;------------------------------Pseudo-Code------------------------------;
  915. ; {
  916. ; }
  917. ;-----------------------------------------------------------------------;
  918. assumes ds,Data
  919. assumes es,nothing
  920. public TXI ;Public for debugging
  921. TXI proc near
  922. ; call DOCLI ;Must be done by caller!
  923. or EFlags[si],fTxImmed ;Show char to xmit
  924. mov ImmedChar[si],ah ;Set character to transmit next
  925. ; jmp short KickTx ;Kick Xmit just in case
  926. errn$ KickTx
  927. TXI endp
  928. page
  929. ;----------------------------Private-Routine----------------------------;
  930. ;
  931. ; KickTx - Kick Transmitter
  932. ;
  933. ; "Kick" the transmitter interrupt routine into operation.
  934. ; If the Transmitter Holding Register isn't empty, then
  935. ; nothing needs to be done. If it is empty, then the xmit
  936. ; interrupt needs to enabled in the IER.
  937. ;
  938. ; Entry:
  939. ; DS:SI --> DEB
  940. ; INTERRUPTS DISABLED!
  941. ; Returns:
  942. ; None
  943. ; Error Returns:
  944. ; None
  945. ; Registers Preserved:
  946. ; BX,CX,SI,DI,DS,ES
  947. ; Registers Destroyed:
  948. ; AX,DX,FLAGS
  949. ; History:
  950. ;-----------------------------------------------------------------------;
  951. ;------------------------------Pseudo-Code------------------------------;
  952. ; {
  953. ; }
  954. ;-----------------------------------------------------------------------;
  955. assumes ds,Data
  956. assumes es,nothing
  957. public KickTx ;Public for debugging
  958. KickTx proc near
  959. ; call DOCLI ;Done by caller
  960. ifdef NEC_98
  961. push cx ; ;[QN] (ins 92.09.24)
  962. endif ; NEC_98
  963. test [si.VCDflags], 1 ;Q: we still own port?
  964. jnz can_we_steal ; N:
  965. enable_int:
  966. ifdef NEC_98
  967. cmp [si.DCB_id],ID_Com1 ;Is This Com1 ID ? (ins 92.08.xx)|
  968. jne KickTx5 ;No, go to KickTx5 (ins 92.08.xx)|
  969. mov dx,MaskFFPort[si] ;F/F Port Mask Bit (ins 92.08.xx)|
  970. in al,dx ; (ins 92.08.xx)|
  971. mov MaskFFShadow[si],al ;Save the Old Mask bit (ins 92.08.xx)|
  972. ; (ins 92.08.xx)|
  973. KickTx5: ; (ins 92.08.xx)|
  974. mov al,MaskFFShadow[si] ;mask data(port C) save (ins 92.08.xx)|
  975. test al,MSK_TXR ; (ins 93.06.18)|
  976. jnz KickTx10 ; Enable (ins 92.08.xx)|
  977. KickTx9:
  978. or al,MSK_TXR+MSK_RXR ; (ins 93.06.18)|
  979. mov dx,MaskFFPort[si] ;Port address (Port C) (ins 92.08.xx)|
  980. mov MaskFFShadow[si],al ;Masking data save (ins 92.08.xx)|
  981. out dx,al ;Masking set (ins 92.08.xx)|
  982. pop cx ; (ins 92.09.24)|
  983. ret ; (ins 92.08.xx)|
  984. KickTx10: ; (ins 92.08.xx)|
  985. and al,NOT(MSK_TXR+MSK_RXR) ; (ins 93.06.18)
  986. mov dx,MaskFFPort[si] ;Port address (Port C) (ins 93.03.22)
  987. out dx,al ;Masking set (ins 93.03.22)
  988. NEWIODELAY 1 ;<OUT 5F,AL> (ins 93.03.22)
  989. jmp short KickTx9 ; (ins 93.03.22)
  990. else ; NEC_98
  991. mov dx,Port[si] ;Get device I/O address
  992. add dl,ACE_IER ;--> Interrupt enable register
  993. in al,dx ;Get current IER state
  994. test al,ACE_ETBEI ;Interrupt already enabled?
  995. jnz KickTx10 ; Yes, don't reenable it
  996. or al,ACE_ETBEI ; No, enable it
  997. out dx,al
  998. iodelay ;8250, 8250-B bug requires
  999. out dx,al ; writting register twice
  1000. KickTx10:
  1001. ; call DOSTI ;Done by caller
  1002. ret
  1003. endif ; NEC_98
  1004. can_we_steal:
  1005. call StealPort ; call VCD to see if we can steal
  1006. ; the port back
  1007. jnc short enable_int ; jump, if we got it
  1008. ;
  1009. ; flush out queue
  1010. ;
  1011. xor ax, ax
  1012. mov [si.QOutCount], ax
  1013. mov [si.QOutMod], ax
  1014. mov ax, [si.QOutGet]
  1015. mov [si.QOutPut], ax
  1016. jmp short KickTx10 ; N:
  1017. KickTx endp
  1018. page
  1019. ;----------------------------Private-Routine----------------------------;
  1020. ;
  1021. ; MSRWait - Modem Status Register Wait
  1022. ;
  1023. ; This routine checks the modem status register for CTS, DSR,
  1024. ; and/or RLSD signals. If a timeout occurs while checking,
  1025. ; the appropriate error code will be returned.
  1026. ;
  1027. ; This routine will not check for any signal with a corresponding
  1028. ; time out value of 0 (ignore line).
  1029. ;
  1030. ; Entry:
  1031. ; SI --> DEB
  1032. ; Returns:
  1033. ; AL = error code
  1034. ; ComErr[si] updated
  1035. ; 'Z' set if no timeout
  1036. ; Error Returns:
  1037. ; None
  1038. ; Registers Destroyed:
  1039. ; AX,CX,DX,FLAGS
  1040. ; History:
  1041. ;-----------------------------------------------------------------------;
  1042. assumes ds,Data
  1043. assumes es,nothing
  1044. public MSRWait ;Public for debugging
  1045. MSRWait proc near
  1046. push di
  1047. MSRRestart:
  1048. xor di,di ;Init Timer
  1049. MSRWait10:
  1050. mov cx,11 ;Init Delay counter (used on non-ATs)
  1051. MSRWait20:
  1052. ifdef NEC_98
  1053. test [si.AOBA_flag],fFIFO_Mode ; (ins 94.04.18)|
  1054. jnz @F ;Now, fifo mode (ins 94.04.18)|
  1055. call MSR_READ_Call ; (ins 92.08.xx)|
  1056. @@: ; (ins 94.04.18)|
  1057. endif ; NEC_98
  1058. xor dh,dh ;Init error accumulator
  1059. mov al,MSRShadow[si] ;Get Modem Status
  1060. and al,MSRMask[si] ;Only leave bits of interest
  1061. xor al,MSRMask[si] ;0 = line high
  1062. jz MSRWait90 ;All lines of interest are high
  1063. mov ah,al ;ah has 1 bits for down lines
  1064. shl ah,1 ;Line Signal Detect low?
  1065. jnc MSRWait30 ; No, it's high
  1066. .errnz ACE_RLSD-10000000b
  1067. cmp di,[si.DCB_RlsTimeout] ;RLSD timeout yet?
  1068. jb MSRWait30 ; No
  1069. or dh,CE_RLSDTO ;Show modem status timeout
  1070. MSRWait30:
  1071. shl ah,1 ;Data Set Ready low?
  1072. shl ah,1
  1073. .errnz ACE_DSR-00100000b
  1074. jnc MSRWait40 ; No, it's high
  1075. cmp di,[si.DCB_DsrTimeout] ;DSR timeout yet?
  1076. jb MSRWait40 ; No
  1077. or dh,CE_DSRTO ;Show data set ready timeout
  1078. MSRWait40:
  1079. shl ah,1 ;CTS low?
  1080. jnc MSRWait50 ; No, it's high
  1081. .errnz ACE_CTS-00010000b
  1082. cmp di,[si.DCB_CtsTimeout] ;CTS timeout yet?
  1083. jb MSRWait50 ; No
  1084. or dh,CE_CTSTO ;Show clear to send timeout
  1085. MSRWait50:
  1086. or dh,dh ;Any timeout occur?
  1087. jnz MSRWait80 ; Yes
  1088. ifndef NEC_98
  1089. cmp [$MachineID],0FCh ;Is this a PC-AT? [rkh debug for PS/2]
  1090. je MSRWait60 ; Yes, use ROM function
  1091. loop MSRWait20 ; No, continue until timeout
  1092. jmp short MSRWait70 ;Should have taken about a millisecond
  1093. endif ; NEC_98
  1094. MSRWait60:
  1095. ifdef NEC_98
  1096. mov cx,1 ;(ins 92.08.xx)|
  1097. call MSR_DELAY ;(ins 92.08.xx)|
  1098. else ; NEC_98
  1099. push bx ;Special SALMON ROM routine to delay
  1100. push di
  1101. xor cx,cx ;Number of Microseconds to delay
  1102. mov dx,1000 ; in CX:DX
  1103. mov ah,86h
  1104. int 15h ;Wait 1 millisecond
  1105. pop di
  1106. pop bx
  1107. endif ; NEC_98
  1108. MSRWait70:
  1109. inc di ;Timer +1
  1110. jmp short MSRWait10 ;Until Timeout or Good status
  1111. MSRWait80:
  1112. xor ah,ah
  1113. mov al,dh
  1114. or by ComErr[si],al ;Return updated status
  1115. .errnz HIGH CE_CTSTO
  1116. .errnz HIGH CE_DSRTO
  1117. .errnz HIGH CE_RLSDTO
  1118. MSRWait90:
  1119. or al,al ;Set 'Z' if no timeout
  1120. pop di
  1121. ret
  1122. MSRWait endp
  1123. page
  1124. ;----------------------------Public Routine-----------------------------;
  1125. ;
  1126. ; $EVT - Set Event Mask
  1127. ;
  1128. ; Set up event word and mask. Returns a pointer to a word in which
  1129. ; certain bits, as enabled by the mask, will be set when certain
  1130. ; events occur.
  1131. ;
  1132. ; Entry:
  1133. ; AH = Device ID
  1134. ; BX = Event enable mask
  1135. ; Returns:
  1136. ; DX:AX --> event word.
  1137. ; Error Returns:
  1138. ; AX = 0 if error
  1139. ; Registers Preserved:
  1140. ; BX,CX,SI,DI,DS,ES
  1141. ; Registers Destroyed:
  1142. ; AX,DX,FLAGS
  1143. ; History:
  1144. ;-----------------------------------------------------------------------;
  1145. ;------------------------------Pseudo-Code------------------------------;
  1146. ; {
  1147. ; }
  1148. ;-----------------------------------------------------------------------;
  1149. assumes ds,Data
  1150. assumes es,nothing
  1151. public $EVT
  1152. $EVT proc near
  1153. push si
  1154. xor dx,dx ;In case of error
  1155. call GetDEB ;Get pointer to DEB
  1156. mov ax,dx ;Finish setting error return value
  1157. jc Evt10 ;Illegal id, return error
  1158. js Evt10 ;LPTx, return error
  1159. mov EvtMask[si],bx ;Save the new event mask
  1160. lea ax,EvtWord[si] ;Get address of event word
  1161. mov dx,ds ; into dx:ax
  1162. Evt10:
  1163. pop si
  1164. ret
  1165. $EVT endp
  1166. page
  1167. ;----------------------------Public Routine-----------------------------;
  1168. ;
  1169. ; $EVTGET - Get Event Word
  1170. ;
  1171. ; Return and clear fields in the event word. This routine MUST be used
  1172. ; by applications to read the event word, as it is the ONLY way they
  1173. ; can be assured that an event is not lost between reading the flags
  1174. ; and resetting some.
  1175. ;
  1176. ; Entry:
  1177. ; AH = Device ID
  1178. ; BX = Event clear mask
  1179. ; Returns:
  1180. ; AX = event word
  1181. ; Error Returns:
  1182. ; None
  1183. ; Registers Preserved:
  1184. ; AX,CX,SI,DI,DS,ES
  1185. ; Registers Destroyed:
  1186. ; BX,FLAGS
  1187. ; History:
  1188. ;-----------------------------------------------------------------------;
  1189. ;------------------------------Pseudo-Code------------------------------;
  1190. ; {
  1191. ; }
  1192. ;-----------------------------------------------------------------------;
  1193. assumes ds,Data
  1194. assumes es,nothing
  1195. public $EVTGET
  1196. $EVTGET proc near
  1197. push si
  1198. call GetDEB
  1199. mov ah,0 ;In case of error (AL already 0)
  1200. jc EvtGet10 ;Illegal ID
  1201. js EvtGet10 ;Illegal ID
  1202. call DOCLI ;No interrupts allowed
  1203. mov ax,EvtWord[si] ;Get the current event word
  1204. not bx ;Convert mask for our purposes
  1205. and bx,ax ;Clear events that user wants us to
  1206. mov EvtWord[si],bx ;And save those results
  1207. call DOSTI ;Magic over
  1208. EvtGet10:
  1209. pop si
  1210. ret
  1211. $EVTGET endp
  1212. page
  1213. ;----------------------------Public Routine-----------------------------;
  1214. ;
  1215. ; $STACOM - Return Status Information
  1216. ;
  1217. ; Returns the number of bytes in both queues.
  1218. ;
  1219. ; LPT ports will show both queues empty.
  1220. ; and resetting some.
  1221. ;
  1222. ; Entry:
  1223. ; AH = Device ID
  1224. ; ES:BX = Pointer to status structure to be updated.
  1225. ; = Null if not to update
  1226. ; Returns:
  1227. ; AX = comm error word
  1228. ; Status Structure Updated.
  1229. ; Error Returns:
  1230. ; AX = error code
  1231. ; Registers Preserved:
  1232. ; SI,DI,DS,ES
  1233. ; Registers Destroyed:
  1234. ; AX,BX,CX,DX,FLAGS
  1235. ; History:
  1236. ;-----------------------------------------------------------------------;
  1237. ;------------------------------Pseudo-Code------------------------------;
  1238. ; {
  1239. ; }
  1240. ;-----------------------------------------------------------------------;
  1241. assumes ds,Data
  1242. assumes es,nothing
  1243. public $STACOM
  1244. $STACOM proc near
  1245. push si
  1246. call GetDEB ;Get DEB pointer in SI
  1247. jc StaCom30 ;Invalid ID
  1248. mov cx,es ;Is the pointer NULL?
  1249. or cx,bx
  1250. jz StaCom25 ; Yes, just return error code
  1251. xor cx,cx
  1252. xor dx,dx
  1253. or ah,ah ;Set 'S' if LPT port
  1254. mov ax,cx ;For LPTs, everything is zero
  1255. js StaCom20 ;LPT port
  1256. ifdef NEC_98
  1257. test [si.AOBA_flag],fFIFO_Mode ; (ins 94.04.16)|
  1258. jnz @F ;Now, fifo mode (ins 94.04.16)|
  1259. call MSR_READ_Call ; (ins 92.08.xx)|
  1260. jmp short MSR_READ_END ;AOBA-bug ins 94.11.19 KBNES
  1261. @@: ; (ins 94.04.16)|
  1262. call AOBA_MSR_READ_Call ;AOBA-bug ins 94.11.19 KBNES
  1263. MSR_READ_END: ;AOBA-bug ins 94.11.19 KBNES
  1264. endif ; NEC_98
  1265. ; Need to get the status for a com port. Since not all the
  1266. ; status is contained within EFlags, it has to be assembled.
  1267. ; Also note that currently there is no way to specify RLSD
  1268. ; as a handshaking line, so fRLSDHold is always returned false.
  1269. mov al,MSRShadow[si] ;Get state of hardware lines
  1270. and al,OutHHSLines[si] ;Mask off required bits
  1271. xor al,OutHHSLines[si] ;1 = line low
  1272. mov cl,4 ;Align bits
  1273. shr al,cl ;al = fCTSHold + fDSRHold
  1274. .errnz ACE_CTS-00010000b
  1275. .errnz ACE_DSR-00100000b
  1276. .errnz fCTSHold-00000001b
  1277. .errnz fDSRHold-00000010b
  1278. mov ah,HSFlag[si] ;Get fXOffHold+fXOffSent
  1279. and ah,XOffReceived+XOffSent
  1280. or al,ah
  1281. .errnz XOffReceived-fXOFFHold
  1282. .errnz XOffSent-fXOFFSent
  1283. mov ah,EFlags[si] ;Get fEOF+fTxImmed
  1284. and ah,fEOF+fTxImmed
  1285. or al,ah
  1286. mov cx,QInCount[si] ;Get input queue count
  1287. mov dx,QOutCount[si] ;Get tx queue count
  1288. StaCom20:
  1289. mov es:[bx.COMS_BitMask1],al
  1290. mov es:[bx.COMS_cbInQue],cx
  1291. mov es:[bx.COMS_cbOutQue],dx
  1292. StaCom25:
  1293. xor ax,ax ;Return old com error
  1294. xchg ax,ComErr[si] ; and clear it out
  1295. StaCom30:
  1296. pop si
  1297. ret
  1298. $STACOM endp
  1299. page
  1300. ;----------------------------Public Routine-----------------------------;
  1301. ;
  1302. ; $SetBrk - Set Break
  1303. ;
  1304. ; Clamp the Tx data line low. Does not wait for the
  1305. ; transmitter holding register and shift registers to empty.
  1306. ;
  1307. ; LPT ports will just return the comm error word
  1308. ;
  1309. ; Entry:
  1310. ; AH = Device ID
  1311. ; Returns:
  1312. ; AX = comm error word
  1313. ; Error Returns:
  1314. ; AX = error code
  1315. ; Registers Preserved:
  1316. ; SI,DI,DS,ES
  1317. ; Registers Destroyed:
  1318. ; AX,BX,CX,DX,FLAGS
  1319. ; History:
  1320. ;-----------------------------------------------------------------------;
  1321. ;------------------------------Pseudo-Code------------------------------;
  1322. ; {
  1323. ; }
  1324. ;-----------------------------------------------------------------------;
  1325. assumes ds,Data
  1326. assumes es,nothing
  1327. public $SETBRK
  1328. $SETBRK proc near
  1329. ifdef NEC_98
  1330. push bx ;(ins 92.08.xx)
  1331. mov bh,SEND_BREAK ;Save the Break commands bit(ins 92.08.xx)
  1332. endif ; NEC_98
  1333. mov cx,0FF00h+ACE_SB ;Will be setting break
  1334. jmp short ClrBrk10
  1335. .errnz BreakSet-ACE_SB ;Must be same bits
  1336. $SETBRK endp
  1337. page
  1338. ;----------------------------Public Routine-----------------------------;
  1339. ;
  1340. ; $CLRBRK - Clear Break
  1341. ;
  1342. ; Release any BREAK clamp on the Tx data line.
  1343. ;
  1344. ; LPT ports will just return the comm error word
  1345. ;
  1346. ; Entry:
  1347. ; AH = Device ID
  1348. ; Returns:
  1349. ; AX = comm error word
  1350. ; Error Returns:
  1351. ; AX = error code
  1352. ; Registers Preserved:
  1353. ; SI,DI,DS,ES
  1354. ; Registers Destroyed:
  1355. ; AX,BX,CX,DX,FLAGS
  1356. ; History:
  1357. ;-----------------------------------------------------------------------;
  1358. ;------------------------------Pseudo-Code------------------------------;
  1359. ; {
  1360. ; }
  1361. ;-----------------------------------------------------------------------;
  1362. assumes ds,Data
  1363. assumes es,nothing
  1364. public $CLRBRK
  1365. $CLRBRK proc near
  1366. ifdef NEC_98
  1367. push bx ;(ins 92.08.xx)
  1368. mov bh,not SEND_BREAK ;Save the Break Reset command(ins 92.08.xx)
  1369. endif ; NEC_98
  1370. mov cx,(NOT ACE_SB) SHL 8
  1371. .errnz BreakSet-ACE_SB ;Must be same bits
  1372. ClrBrk10:
  1373. push si
  1374. call GetDEB ;Get DEB address
  1375. jc ClrBrk30 ;Invalid ID
  1376. js ClrBrk20 ;Ignored for LPT ports
  1377. call DOCLI
  1378. and HSFlag[si],ch ;Set or clear the BreakSet bit
  1379. or HSFlag[si],cl
  1380. ; ch = mask to remove bits in the Line Control Register
  1381. ; cl = mask to turn bits on in the Line Control Register
  1382. ifdef NEC_98
  1383. test [si.AOBA_flag],fFIFO_Mode ; (ins 94.04.16)|
  1384. jz @F ;Now, 8251 mode (ins 94.04.16)|
  1385. call Set8251modeFar ;Change to 8251 mode (ins 94.04.16)|
  1386. @@: ; (ins 94.04.16)|
  1387. mov dx,CommandPort[si] ;8251 Command Address (ins 92.08.xx)|
  1388. mov al,CommandShadow[si] ;8251 Active CMD Byte (ins 92.08.xx)|
  1389. cmp bh,SEND_BREAK ;Send Break ? (ins 92.08.xx)|
  1390. jne ClrBrk15 ; No, Clear bit (ins 92.08.xx)|
  1391. or al,bh ;Send break bit "set" (ins 92.08.xx)|
  1392. jmp short ClrBrk17 ; (ins 92.08.xx)|
  1393. ClrBrk15: ; (ins 92.08.xx)|
  1394. and al,bh ;Send break bit "reset" (ins 92.08.xx)|
  1395. ClrBrk17: ; (ins 92.08.xx)|
  1396. out dx,al ;New command out (ins 92.08.xx)|
  1397. test [si.AOBA_flag],fFIFO_Mode ; (ins 94.04.16)|
  1398. jz @F ;Now, 8251 mode (ins 94.04.16)|
  1399. call SetFIFOmodeFar ;Change to FIFO mode (ins 94.04.16)|
  1400. @@: ; (ins 94.04.16)|
  1401. FSTI ; (ins 92.08.xx)|
  1402. ; (ins 92.08.xx)|
  1403. ClrBrk20: ; (ins 92.08.xx)|
  1404. mov ax,ComErr[si] ;Return Status Word (ins 92.08.xx)|
  1405. ; (ins 92.08.xx)|
  1406. ClrBrk30: ; (ins 92.08.xx)|
  1407. pop si ; (ins 92.08.xx)|
  1408. pop bx ; (ins 92.08.xx)|
  1409. ret ; (ins 92.08.xx)|
  1410. else ; NEC_98
  1411. mov dx,Port[si] ;Get comm device base I/O port
  1412. add dl,ACE_LCR ;Point at the Line Control Regieter
  1413. in al,dx ;Get old line control value
  1414. and al,ch ;Turn off desired bits
  1415. or al,cl ;Turn on desired bits
  1416. iodelay
  1417. out dx,al ;Output New LCR.
  1418. call DOSTI
  1419. ClrBrk20:
  1420. mov ax,ComErr[si] ;Return Status Word
  1421. ClrBrk30:
  1422. pop si
  1423. ret
  1424. endif ; NEC_98
  1425. $CLRBRK endp
  1426. page
  1427. ;----------------------------Public Routine-----------------------------;
  1428. ;
  1429. ; $EXTCOM - Extended Comm Functions
  1430. ;
  1431. ; A number of extended functions are routed through this entry point.
  1432. ;
  1433. ; Functions currently implemented:
  1434. ;
  1435. ; 0: Ignored
  1436. ; 1: SETXOFF - Exactly as if X-OFF character has been received.
  1437. ; 2: SETXON - Exactly as if X-ON character has been received.
  1438. ; 3: SETRTS - Set the RTS signal
  1439. ; 4: CLRRTS - Clear the RTS signal
  1440. ; 5: SETDTR - Set the DTR signal
  1441. ; 6: CLRDTR - Clear the DTR signal
  1442. ; 7: RESET - Yank on reset line if available (LPT devices)
  1443. ;
  1444. ; Entry:
  1445. ; AH = Device ID
  1446. ; BL = Function Code
  1447. ; (0-127 are MS-defined, 128-255 are OEM defined)
  1448. ; Returns:
  1449. ; AX = comm error word
  1450. ; Error Returns:
  1451. ; AX = error code
  1452. ; Registers Preserved:
  1453. ; SI,DI,DS
  1454. ; Registers Destroyed:
  1455. ; AX,BX,CX,DX,ES,FLAGS
  1456. ; History:
  1457. ;-----------------------------------------------------------------------;
  1458. ;------------------------------Pseudo-Code------------------------------;
  1459. ; {
  1460. ; }
  1461. ;-----------------------------------------------------------------------;
  1462. ; Dispatch table for the extended functions
  1463. ExtTab dw ExtComDummy ;Function 0: Never Mind
  1464. dw ExtCom_FN1 ;1: Set X-Off
  1465. dw ExtCom_FN2 ;2: Clear X-Off
  1466. dw ExtCom_FN3 ;3: Set RTS
  1467. dw ExtCom_FN4 ;4: Clear RTS
  1468. dw ExtCom_FN5 ;5: Set DSR
  1469. dw ExtCom_FN6 ;6: Clear DSR
  1470. dw ExtCom_FN7 ;7: Reset printer
  1471. dw ExtCom_FN8 ;8: Get Max LPT Port
  1472. dw ExtCom_FN9 ;9: Get Max COM Port
  1473. dw ExtCom_FN10 ;10: Get COM Port Base & IRQ
  1474. dw ExtCom_FN10 ;11: Get COM Port Base & IRQ
  1475. %OUT fix this for bld 32 -- GetBaseIRQ is now 10
  1476. assumes ds,Data
  1477. assumes es,nothing
  1478. public $EXTCOM
  1479. $EXTCOM proc near
  1480. push si
  1481. push di
  1482. call GetDEB ;Get DEB pointer
  1483. jc ExtCom40 ;Invalid ID, return error
  1484. ifdef NEC_98
  1485. mov dx,CommandPort[si] ;Command registor (ins 92.08.xx)
  1486. else ; NEC_98
  1487. mov dx,Port[si] ; get port address
  1488. endif ; NEC_98
  1489. jns ExtCom10 ;Its a COM port
  1490. cmp bl,7 ;RESET extended function?
  1491. jne ExtCom30 ; No, return error word
  1492. jmp short ExtCom20 ; Yes, invoke the function
  1493. ExtCom10:
  1494. cmp bl,11 ;Last fcn supported
  1495. ja ExtCom30 ;Not an implemented function.
  1496. ExtCom20:
  1497. xor bh,bh
  1498. add bx,bx ;Shift for the call
  1499. call DOCLI ;Consider as critical sections
  1500. call ExtTab[bx] ; and perform the function
  1501. call DOSTI
  1502. jc ExtCom40 ; jump if sub returns data in DX:AX
  1503. ExtCom30:
  1504. mov ax,ComErr[si] ;Return standard error word
  1505. xor dx, dx
  1506. ExtCom40:
  1507. pop di
  1508. pop si
  1509. ret
  1510. $EXTCOM endp
  1511. page
  1512. ;----------------------------Private-Routine----------------------------;
  1513. ;
  1514. ; ExtCom_FN1 - Extended Function Set X-Off
  1515. ;
  1516. ; Analagous to receiving an X-OFF character. Bufferred transmision of
  1517. ; characters is halted until an X-ON character is received, or until
  1518. ; we fake that with a Clear X-Off call.
  1519. ;
  1520. ; Entry:
  1521. ; interrupts disabled
  1522. ; dx = port base address
  1523. ; Returns:
  1524. ; None
  1525. ; Error Returns:
  1526. ; None
  1527. ; Registers Preserved:
  1528. ; SI,DI,DS
  1529. ; Registers Destroyed:
  1530. ; AX,BX,CX,DX,ES,FLAGS
  1531. ; History:
  1532. ;-----------------------------------------------------------------------;
  1533. ;------------------------------Pseudo-Code------------------------------;
  1534. ; {
  1535. ; }
  1536. ;-----------------------------------------------------------------------;
  1537. assumes ds,Data
  1538. assumes es,nothing
  1539. public ExtCom_FN1
  1540. ExtCom_FN1 proc near
  1541. or HSFlag[si],XOffReceived
  1542. ExtComDummy:
  1543. clc
  1544. ret
  1545. ExtCom_FN1 endp
  1546. page
  1547. ;----------------------------Private-Routine----------------------------;
  1548. ;
  1549. ; ExtCom_FN2 - Extended Function Clear X-Off
  1550. ;
  1551. ; Analagous to receiving an X-ON character. Buffered
  1552. ; transmission of characters is restarted.
  1553. ;
  1554. ; Entry:
  1555. ; interrupts disabled
  1556. ; dx = port base address
  1557. ; Returns:
  1558. ; None
  1559. ; Error Returns:
  1560. ; None
  1561. ; Registers Preserved:
  1562. ; SI,DI,DS
  1563. ; Registers Destroyed:
  1564. ; AX,BX,CX,DX,ES,FLAGS
  1565. ; History:
  1566. ;-----------------------------------------------------------------------;
  1567. ;------------------------------Pseudo-Code------------------------------;
  1568. ; {
  1569. ; }
  1570. ;-----------------------------------------------------------------------;
  1571. assumes ds,Data
  1572. assumes es,nothing
  1573. public ExtCom_FN2
  1574. ExtCom_FN2 proc near
  1575. and HSFlag[si],NOT XOffReceived
  1576. call KickTx ;Kick transmitter interrupts on
  1577. clc
  1578. ret
  1579. ExtCom_FN2 endp
  1580. page
  1581. ;----------------------------Private-Routine----------------------------;
  1582. ;
  1583. ; ExtCom_FN3 - Extended Function Set RTS
  1584. ;
  1585. ; Set the RTS signal active.
  1586. ;
  1587. ; Entry:
  1588. ; interrupts disabled
  1589. ; dx = port base address
  1590. ; Returns:
  1591. ; None
  1592. ; Error Returns:
  1593. ; None
  1594. ; Registers Preserved:
  1595. ; SI,DI,DS
  1596. ; Registers Destroyed:
  1597. ; AX,BX,CX,DX,ES,FLAGS
  1598. ; History:
  1599. ;-----------------------------------------------------------------------;
  1600. ;------------------------------Pseudo-Code------------------------------;
  1601. ; {
  1602. ; }
  1603. ;-----------------------------------------------------------------------;
  1604. assumes ds,Data
  1605. assumes es,nothing
  1606. public ExtCom_FN3
  1607. ExtCom_FN3 proc near
  1608. ifdef NEC_98
  1609. mov al,CommandShadow[si] ;Old command byte load (ins 92.08.22)|
  1610. or al,RTS ;=00100000B RTS bit "On"(ins 92.08.22)|
  1611. mov dx,CommandPort[si] ;Command registor (ins 92.08.22)|
  1612. call GoNakasu ;RTS set (ins 92.08.22)|
  1613. mov CommandShadow[si],al ;New command byte save (ins 92.08.22)|
  1614. else ; NEC_98
  1615. add dl,ACE_MCR ;Point at Modem Control Register
  1616. in al,dx ;Get current settings
  1617. or al,ACE_RTS ;Set RTS
  1618. iodelay
  1619. out dx,al ;And update
  1620. endif ;NEC_98
  1621. clc
  1622. ret
  1623. ExtCom_FN3 endp
  1624. page
  1625. ;----------------------------Private-Routine----------------------------;
  1626. ;
  1627. ; ExtCom_FN4 - Extended Function Clear RTS
  1628. ;
  1629. ; Set the RTS signal inactive.
  1630. ;
  1631. ; Entry:
  1632. ; interrupts disabled
  1633. ; dx = port base address
  1634. ; Returns:
  1635. ; None
  1636. ; Error Returns:
  1637. ; None
  1638. ; Registers Preserved:
  1639. ; SI,DI,DS
  1640. ; Registers Destroyed:
  1641. ; AX,BX,CX,DX,ES,FLAGS
  1642. ; History:
  1643. ;-----------------------------------------------------------------------;
  1644. ;------------------------------Pseudo-Code------------------------------;
  1645. ; {
  1646. ; }
  1647. ;-----------------------------------------------------------------------;
  1648. assumes ds,Data
  1649. assumes es,nothing
  1650. public ExtCom_FN4
  1651. ExtCom_FN4 proc near
  1652. ifdef NEC_98
  1653. mov al,CommandShadow[si] ;Old command byte load (ins 92.08.22)|
  1654. and al,not RTS ;=11011111B RTS bit"Off"(ins 92.08.22)|
  1655. mov dx,CommandPort[si] ;Command registor (ins 92.08.22)|
  1656. call GoNakasu ;Clear rts (ins 92.08.22)|
  1657. mov CommandShadow[si],AL ;New command byte save (ins 92.08.22)|
  1658. else ; NEC_98
  1659. add dl,ACE_MCR ;Point at Modem Control Register
  1660. in al,dx ;Get current settings
  1661. and al,NOT ACE_RTS ;Clear RTS
  1662. iodelay
  1663. out dx,al ;And update
  1664. endif ; NEC_98
  1665. clc
  1666. ret
  1667. ExtCom_FN4 endp
  1668. page
  1669. ;----------------------------Private-Routine----------------------------;
  1670. ;
  1671. ; ExtCom_FN5 - Extended Function Set DTR
  1672. ;
  1673. ; Set the DTR signal active.
  1674. ;
  1675. ; Entry:
  1676. ; interrupts disabled
  1677. ; dx = port base address
  1678. ; Returns:
  1679. ; None
  1680. ; Error Returns:
  1681. ; None
  1682. ; Registers Preserved:
  1683. ; SI,DI,DS
  1684. ; Registers Destroyed:
  1685. ; AX,BX,CX,DX,ES,FLAGS
  1686. ; History:
  1687. ;-----------------------------------------------------------------------;
  1688. ;------------------------------Pseudo-Code------------------------------;
  1689. ; {
  1690. ; }
  1691. ;-----------------------------------------------------------------------;
  1692. assumes ds,Data
  1693. assumes es,nothing
  1694. public ExtCom_FN5
  1695. ExtCom_FN5 proc near
  1696. ifdef NEC_98
  1697. mov al,CommandShadow[si] ;Old command byte load (ins 92.08.xx)|
  1698. or al,DTR ;=00000010B DTR bit "On"(ins 92.08.xx)|
  1699. mov dx,CommandPort[si] ;Command registor (ins 92.08.xx)|
  1700. call GoNakasu ;set dtr (ins 92.08.xx)|
  1701. mov CommandShadow[si],al ;New command byte save (ins 92.08.xx)|
  1702. else ; NEC_98
  1703. add dl,ACE_MCR ;Point at Modem Control Register
  1704. in al,dx ;Get current settings
  1705. or al,ACE_DTR ;Set DTR
  1706. iodelay
  1707. out dx,al ;And update
  1708. endif ; NEC_98
  1709. clc
  1710. ret
  1711. ExtCom_FN5 endp
  1712. page
  1713. ;----------------------------Private-Routine----------------------------;
  1714. ;
  1715. ; ExtCom_FN6 - Extended Function Clear DTR
  1716. ;
  1717. ; Set the DTR signal inactive.
  1718. ;
  1719. ; Entry:
  1720. ; interrupts disabled
  1721. ; dx = port base address
  1722. ; Returns:
  1723. ; None
  1724. ; Error Returns:
  1725. ; None
  1726. ; Registers Preserved:
  1727. ; SI,DI,DS
  1728. ; Registers Destroyed:
  1729. ; AX,BX,CX,DX,ES,FLAGS
  1730. ; History:
  1731. ;-----------------------------------------------------------------------;
  1732. ;------------------------------Pseudo-Code------------------------------;
  1733. ; {
  1734. ; }
  1735. ;-----------------------------------------------------------------------;
  1736. assumes ds,Data
  1737. assumes es,nothing
  1738. public ExtCom_FN6
  1739. ExtCom_FN6 proc near
  1740. ifdef NEC_98
  1741. mov al,CommandShadow[si] ;Old command byte load (ins 92.08.xx)|
  1742. and al,not DTR ;=11111101B DTR bit"Off"(ins 92.08.xx)|
  1743. mov dx,CommandPort[si] ;Command registor (ins 92.08.xx)|
  1744. call GoNakasu ;set DTR (ins 92.08.xx)|
  1745. mov CommandShadow[si],al ;New command byte save (ins 92.08.xx)|
  1746. else ; NEC_98
  1747. add dl,ACE_MCR ;Point at Modem Control Register
  1748. in al,dx ;Get current settings
  1749. and al,NOT ACE_DTR ;Clear DTR
  1750. iodelay
  1751. out dx,al ;And update
  1752. endif ; NEC_98
  1753. clc
  1754. ret
  1755. ExtCom_FN6 endp
  1756. ifdef NEC_98
  1757. GoNakasu proc near ; (ins 94.05.19)|
  1758. push dx ; (ins 94.05.19)|
  1759. mov dh,CommandShadow[si] ; (ins 94.05.19)|
  1760. mov dl,al ; (ins 94.05.19)|
  1761. and dx,2222h ; (ins 94.05.19)|
  1762. cmp dh,dl ; (ins 94.05.19)|
  1763. pop dx ; (ins 94.05.19)|
  1764. je @f ; (ins 94.05.19)|
  1765. test [si.AOBA_flag],fFIFO_Mode ; (ins 94.05.19)|
  1766. jz HakataNoYatai ;Now, 8251 mode (ins 94.05.19)|
  1767. call Set8251modeFar ;Change to 8251 mode (ins 94.05.19)|
  1768. HakataNoYatai: ; (ins 94.05.19)|
  1769. out dx,al ; (ins 94.05.19)|
  1770. test [si.AOBA_flag],fFIFO_Mode ; (ins 94.05.19)|
  1771. jz @F ;Now, 8251 mode (ins 94.05.19)|
  1772. call SetFIFOmodeFar ;Change to FIFO mode (ins 94.05.19)|
  1773. @@: ; (ins 94.05.19)|
  1774. ret ; (ins 94.05.19)|
  1775. GoNakasu endp ; (ins 94.05.19)|
  1776. endif ; NEC_98
  1777. page
  1778. ;----------------------------Private-Routine----------------------------;
  1779. ;
  1780. ; ExtCom_FN7 - Extended Function Reset Printer
  1781. ;
  1782. ; Assert the RESET line on an LPT port
  1783. ;
  1784. ; Entry:
  1785. ; interrupts disabled
  1786. ; dx = port base address
  1787. ; Returns:
  1788. ; None
  1789. ; Error Returns:
  1790. ; None
  1791. ; Registers Preserved:
  1792. ; SI,DI,DS
  1793. ; Registers Destroyed:
  1794. ; AX,BX,CX,DX,ES,FLAGS
  1795. ; History:
  1796. ;-----------------------------------------------------------------------;
  1797. ;------------------------------Pseudo-Code------------------------------;
  1798. ; {
  1799. ; }
  1800. ;-----------------------------------------------------------------------;
  1801. assumes ds,Data
  1802. assumes es,nothing
  1803. public ExtCom_FN7
  1804. ExtCom_FN7 proc near
  1805. call DOSTI ;Not called at interrupt time
  1806. mov ch,1 ;ROM BIOS Reset Port
  1807. call DoLPT ;Perform the function
  1808. clc
  1809. ret
  1810. ExtCom_FN7 endp
  1811. page
  1812. ;----------------------------Private-Routine----------------------------;
  1813. ;
  1814. ; ExtCom_FN8 - Get Num Ports
  1815. ;
  1816. ; Entry:
  1817. ; Returns:
  1818. ; AX = Max LPT port id
  1819. ; DX = 0
  1820. ; Error Returns:
  1821. ; None
  1822. ; Registers Preserved:
  1823. ; SI,DI,DS
  1824. ; Registers Destroyed:
  1825. ; AX,BX,CX,DX,ES,FLAGS
  1826. ; History:
  1827. ;-----------------------------------------------------------------------;
  1828. ;------------------------------Pseudo-Code------------------------------;
  1829. ; {
  1830. ; }
  1831. ;-----------------------------------------------------------------------;
  1832. assumes ds,Data
  1833. assumes es,nothing
  1834. public ExtCom_FN8
  1835. ExtCom_FN8 proc near
  1836. mov ax, MAXLPT + LPTx
  1837. xor dx, dx
  1838. stc
  1839. ret
  1840. ExtCom_FN8 endp
  1841. page
  1842. ;----------------------------Private-Routine----------------------------;
  1843. ;
  1844. ; ExtCom_FN9 - Get Max COM Port
  1845. ;
  1846. ; Entry:
  1847. ; Returns:
  1848. ; AX = Max COM port id
  1849. ; DX = 0
  1850. ; Error Returns:
  1851. ; None
  1852. ; Registers Preserved:
  1853. ; SI,DI,DS
  1854. ; Registers Destroyed:
  1855. ; AX,BX,CX,DX,ES,FLAGS
  1856. ; History:
  1857. ;-----------------------------------------------------------------------;
  1858. ;------------------------------Pseudo-Code------------------------------;
  1859. ; {
  1860. ; }
  1861. ;-----------------------------------------------------------------------;
  1862. assumes ds,Data
  1863. assumes es,nothing
  1864. public ExtCom_FN9
  1865. ExtCom_FN9 proc near
  1866. mov ax, MAXCOM
  1867. xor dx, dx
  1868. stc
  1869. ret
  1870. ExtCom_FN9 endp
  1871. page
  1872. ;----------------------------Private-Routine----------------------------;
  1873. ;
  1874. ; ExtCom_FN10 - Get COM Port Bas & IRQ
  1875. ;
  1876. ; Entry:
  1877. ; AH = com id
  1878. ; DS:SI -> DEB
  1879. ; Returns:
  1880. ; AX = base
  1881. ; DX = irq
  1882. ; Error Returns:
  1883. ; None
  1884. ; Registers Preserved:
  1885. ; DS
  1886. ; Registers Destroyed:
  1887. ; AX,BX,CX,DX,DI,ES,FLAGS
  1888. ; History:
  1889. ;-----------------------------------------------------------------------;
  1890. ;------------------------------Pseudo-Code------------------------------;
  1891. ; {
  1892. ; }
  1893. ;-----------------------------------------------------------------------;
  1894. assumes ds,Data
  1895. assumes es,nothing
  1896. public ExtCom_FN10
  1897. ExtCom_FN10 proc near
  1898. call FindCOMPort
  1899. stc
  1900. ret
  1901. ExtCom_FN10 endp
  1902. page
  1903. ifdef NEC_98
  1904. include delay.asm ; (ins 92.08.xx)
  1905. TOMOE_PAT DB 16 DUP('PATCH !!') ;PATCH AREA (ins 92.11.11)
  1906. endif ; NEC_98
  1907. ifdef DEBUG
  1908. public RecCom40, RecCom50, RecCom60, RecCom70, RecCom80
  1909. public RecCom90, RecCom95, RecCom100
  1910. public SendImm10, SendImm20,
  1911. public SendCom10, SendCom20, SendCom30, SendCom40, SendCom50, SendCom60
  1912. public Flush10, Flush20, Flush30, Flush40
  1913. public KickTx10
  1914. public Evt10
  1915. public EvtGet10
  1916. public StaCom20, StaCom25, StaCom30
  1917. public ClrBrk10, ClrBrk20, ClrBrk30
  1918. public ExtCom10, ExtCom20, ExtCom30, ExtCom40, ExtComDummy
  1919. public MSRRestart, MSRWait10, MSRWait20, MSRWait30, MSRWait40
  1920. public MSRWait50, MSRWait60, MSRWait70, MSRWait80, MSRWait90
  1921. endif
  1922. DOSTI proc near
  1923. FSTI
  1924. ret
  1925. DOSTI endp
  1926. DOCLI proc near
  1927. FCLI
  1928. ret
  1929. DOCLI endp
  1930. sEnd code
  1931. End