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.

265 lines
9.6 KiB

  1. DEBUG equ 1
  2. No_DOSX_Bimodal_Services = 1
  3. IFDEF No_DOSX_Bimodal_Services
  4. %OUT generating code to handle ints without Bimodal Interrupt Services for DOSX
  5. ENDIF
  6. wo equ word ptr
  7. by equ byte ptr
  8. MAXLPT equ 2 ;3 LPTs supported (LPT1,2,3)
  9. MAXCOM equ 3 ;4 COMs supported (COM1,2,3,4)
  10. RS232B equ 0h ;RS232 Card(s) I/O addr 40:Save area.
  11. LPTB equ 8h ;LPT Card(s) I/O addr 40:Save area.
  12. IRQ3 equ 0bh ; Int vector for Com card @ 2xxh
  13. IRQ4 equ 0ch ; Int vector for Com card @ 3xxh
  14. INTA0 equ 20h ;X'20' 8259 Interrupt Control Port
  15. INTA1 equ 21h ;X'21' 8259 Interrupt Mask Port
  16. EOI equ 20h ;X'20' 8259 End-of-Interrupt ack
  17. Open equ 0201h ;Int 2F open request
  18. Close equ 0202h ;Int 2F close request
  19. Lock2F equ 0203h ;Int 2F lock request
  20. Unlock2F equ 0204h ;Int 2F unlock request
  21. ; COMDEB - Communications Device Equipment Block.
  22. ;
  23. ; This is essentially a superset of the DCB used outside of this
  24. ; module. The DCB is contained within the DEB as the first fields.
  25. ; The fields which follow are data and status fields which
  26. ; are unique to this implementation.
  27. ;
  28. ; AltQInAddr and AltQOutAddr are alternate queue pointers which are used when
  29. ; in "supervisor" mode. Supervisor mode is a processor mode other than the
  30. ; one which Windows normally runs in. In standard mode Windows, supervisor
  31. ; mode is REAL mode. In enhanced mode Windows, supervisor mode is RING 0
  32. ; protected mode. For more details see comments in IBMINT.ASM.
  33. ComDEB struc ;RS232 Data Equip Block
  34. ComDCB db ((DCBSize+1) and 0FFFEh) DUP (0)
  35. ComErr dw 0 ;Non-zero if I/O error
  36. Port dw 0 ;Base I/O Address
  37. NotifyHandle dw 0
  38. NotifyFlags dw 0
  39. RecvTrigger dw -1 ; char count threshold for calling
  40. SendTrigger dw 0 ; char count threshold for calling
  41. ; The following fields are specific to com ports only
  42. IRQhook dw 0 ; ptr to IRQ_Hook_Struc
  43. NextDEB dw 0 ; ptr to next DEB that is sharing IRQ
  44. XOffPoint dw 0 ;Q count where XOff is sent
  45. EvtMask dw 0 ;Mask of events to check for
  46. EvtWord dw 0 ;Event flags
  47. QInAddr dd 0 ;Address of the queue
  48. AltQInAddr dd 0 ; Addr of queue in "supervisor" mode
  49. QInSize dw 0 ;Length of queue in bytes
  50. QOutAddr dd 0 ;Address of the queue
  51. AltQOutAddr dd 0 ; Addr of queue in "supervisor" mode
  52. QOutSize dw 0 ;Length of queue in bytes
  53. QInCount dw 0 ;Number of bytes currently in queue
  54. QInGet dw 0 ;Offset into queue to get bytes from
  55. QInPut dw 0 ;Offset into queue to put bytes in
  56. QOutCount dw 0 ;Number of bytes currently in queue
  57. QOutGet dw 0 ;Offset into queue to get bytes from
  58. QOutPut dw 0 ;Offset into queue to put bytes in
  59. EFlags db 0 ;Extended flags
  60. MSRShadow db 0 ;Modem Status Register Shadow
  61. ErrorMask db 0 ;Default error-checking mask
  62. RxMask db 0 ;Character mask
  63. ImmedChar db 0 ;Char to be transmitted immediately
  64. HSFlag db 0 ;Handshake flag
  65. HHSLines db 0 ;8250 DTR/RTS bits for handshaking
  66. OutHHSLines db 0 ;Lines that must be high to output
  67. MSRMask db 0 ;Mask of Modem Lines to check
  68. MSRInfinite db 0 ;Mask of MSR lines that must be high
  69. IntVecNum db 0 ;Interrupt vector number
  70. LSRShadow db 0 ;Line Status Register shadow
  71. QOutMod dw 0 ;characters sent mod xOnLim ENQ/ETX [rkh]
  72. VCD_data dd 0
  73. VCDflags db 0
  74. MiscFlags db 0 ;still more flags
  75. ComDEB ends
  76. .errnz (SIZE ComDEB) and 1
  77. .errnz MSRShadow - EvtWord - 35
  78. ; In 3.0 MSRShadow had this relationship to EvtWord and major COM apps all
  79. ; use this offset of 35 to get to MSRShadow so that they can determine the
  80. ; current status of the Modem Status bits. We need to maintain this offset
  81. ; so that these apps will continue to run.
  82. ; The LptDEB is identical to the ComDEB structure, except
  83. ; all the COM port specific stuff has been removed (which
  84. ; convientiently was stored at the end so offsets would
  85. ; be correct). This allows the code to act indifferently
  86. ; when accessing the strucutres for things like the port.
  87. LptDEB struc
  88. xComDCB db ((DCBSize+1) AND 0FFFEh) dup (0)
  89. xComErr dw 0 ;Non-zero if I/O error
  90. xPort dw 0 ;Base I/O Address
  91. xNotifyHandle dw 0
  92. xNotifyFlags dw 0
  93. xRecvTrigger dw -1 ; char count threshold for calling
  94. xSendTrigger dw 0 ; char count threshold for calling
  95. BIOSPortLoc dw 0 ;Offset to port location (i.e. 40:0)
  96. LptDEB ends
  97. .errnz xComDCB-ComDCB
  98. .errnz xComErr-ComErr
  99. .errnz xPort-Port
  100. .errnz xNotifyHandle-NotifyHandle
  101. .errnz xNotifyFlags-NotifyFlags
  102. .errnz xRecvTrigger-RecvTrigger
  103. .errnz xSendTrigger-SendTrigger
  104. ; flag equates in EFlags
  105. fUseDSR equ 00000001b ; set, if DSR is significant
  106. fNoFIFO equ 00000010b ; set, if no FIFO on port
  107. fFIFOchkd equ 00000100b ; set, if FIFO has been checked
  108. fFIFOpre equ 00001000b ; FIFO enabled when port opened
  109. ;fEOF equ 00100000b ; defined in comdev.inc
  110. ;fTxImmed equ 01000000b ; defined in comdev.inc
  111. fEFlagsMask equ fUseDSR OR fFIFOpre OR fFIFOchkd OR fNoFIFO ; flags which shouldn't be cleared
  112. .errnz fEFlagsMask AND (fEOF OR fTxImmed) ;can't overlap with either of the bits
  113. ; that are folded into COMS_BitMask1
  114. ; Values for NotifyFlags
  115. ;
  116. CN_RecvSent equ CN_RECEIVE SHL 8
  117. CN_TransSent equ CN_TRANSMIT SHL 8
  118. CN_Idle equ 10000000b
  119. CN_Notify equ 01000000b
  120. NotifyFlagsLO equ byte ptr NotifyFlags
  121. NotifyFlagsHI equ byte ptr NotifyFlags+1
  122. ; Values for the handshake flag
  123. ;
  124. ; BreakSet - True if break was set - stops transmission
  125. ; XOffSent - True if we have sent the XOff character
  126. ; XOffPending - True if XOff character needs to be sent
  127. ; XOnPending - True if XOn character needs to be sent
  128. ; HHSDown - True if host dropped required hardware lines
  129. ; HHSDropped - True if we dropped our hardware handshake lines
  130. ; XOffReceived - True if XOff received from host
  131. ; HSPending - Mask to return non-zero if XOn or Xoff must be sent
  132. ; HSReceived - Mask to return non-zero if handshake has been
  133. ; received from host stopping transmission
  134. ; CannotXmit - Mask to return non-zero if any condition
  135. ; exists which prevents us from tranmitting.
  136. ; HSSent - Mask to return non-zero if we sent a handshake
  137. XOffPending equ 00000001b ;XOff needs to be sent
  138. EnqPending equ 00000001b ;Enq needs to be sent [rkh]
  139. EtxPending equ 00000001b ;Etx needs to be sent
  140. HHSDropped equ 00000010b ;Our hardware handshake lines are down
  141. XOnPending equ 00000100b ;XOn needs to be sent
  142. AckPending equ 00000100b ;Ack needs to be sent (ENQ/ACK & ETX/ACK)
  143. XOffReceived equ 00001000b ;XOff character received
  144. EnqSent equ 00001000b ;Enq has been sent
  145. EtxSent equ 00001000b ;Etx has been sent
  146. XOffSent equ 00010000b ;XOff has been sent
  147. EnqReceived equ 00010000b ;Enq character received (ENQ/ACK)
  148. EtxReceived equ 00010000b ;Etx character received (ETX/ACK)
  149. HHSDown equ 00100000b ;Host hardware handshake lines are down
  150. BreakSet equ 01000000b ;Break has been set
  151. HHSAlwaysDown equ 10000000b ;set if host handshake lines were never
  152. ; detected high
  153. HSPending equ XOffPending+XOnPending
  154. HSReceived equ XOffReceived+HHSDown
  155. HSSent equ XOffSent+HHSDropped
  156. CannotXmit equ HSPending+HSReceived+BreakSet
  157. ; values for MiscFlags
  158. Discard equ 00000001b ;Discard recevied data
  159. iodelay macro ;;macro to insure that an instruction
  160. jmp $+2 ;; fetch occurs between IN and/or OUT
  161. jmp $+2 ;; instructions on the PC-AT machine
  162. endm
  163. TimeoutError equ -2 ;Timeout error code for $TRMCOM
  164. Timeout equ 30 ;30 second timeout
  165. DELAY_TIME equ 200 ;Delay at least 200 milliseconds
  166. ; Status bits returned from the BIOS for LPT ports
  167. PS_NotBusy equ 10000000b ;Printer not busy
  168. PS_Ack equ 01000000b ;Data acknowledged
  169. PS_PaperOut equ 00100000b ;Out of paper
  170. PS_Select equ 00010000b ;Device is selected
  171. PS_IOError equ 00001000b ;IO error
  172. PS_Timeout equ 00000001b ;Timeout occured
  173. ; status bit defines for LPT
  174. L_BITS equ 0F8h ; the status bits we want
  175. L_BITS_INVERT equ 048h ; must invert to match BIOS
  176. L_DEVBUSY equ 080h ; device busy bit
  177. L_TIMEOUT equ 001h ; timeout bit
  178. ; control bit defines for LPT
  179. L_NORMAL equ 00Ch ; normal state: selected, no reset
  180. L_RESET equ 008h ; reset state
  181. L_STROBE equ 00Dh ; tell printer we have char
  182. IRQ_Hook_Struc struc
  183. IRQn db 0
  184. HookCnt db 0
  185. OldMask db 0
  186. VecN db 0FFh
  187. HandlerOff dw 0
  188. First_DEB dw 0
  189. OldIntVec dd 0
  190. IFDEF No_DOSX_Bimodal_Services
  191. RM_OldIntVec dd 0
  192. RM_HandlerOff dw 0
  193. ENDIF
  194. IRQ_Hook_Struc ends
  195. IFDEF No_DOSX_Bimodal_Services
  196. include int31.inc
  197. Get_RM_IntVector equ (Int31_Int_Serv SHL 8) + Int_Get_Real_Vec
  198. Set_RM_IntVector equ (Int31_Int_Serv SHL 8) + Int_Set_Real_Vec
  199. ENDIF
  200. ;
  201. ; flag bits for VCDflags
  202. ;
  203. fCOM_ignore_ints equ 00000001b