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.

402 lines
15 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. ifdef NEC_98
  10. MAXCOM equ 8 ;9 COMs supported (COM1,2,3) (ins 931218)
  11. else ; NEC_98
  12. MAXCOM equ 3 ;4 COMs supported (COM1,2,3,4)
  13. endif ; NEC_98
  14. RS232B equ 0h ;RS232 Card(s) I/O addr 40:Save area.
  15. LPTB equ 8h ;LPT Card(s) I/O addr 40:Save area.
  16. IRQ3 equ 0bh ; Int vector for Com card @ 2xxh
  17. IRQ4 equ 0ch ; Int vector for Com card @ 3xxh
  18. INTA0 equ 20h ;X'20' 8259 Interrupt Control Port
  19. INTA1 equ 21h ;X'21' 8259 Interrupt Mask Port
  20. EOI equ 20h ;X'20' 8259 End-of-Interrupt ack
  21. Open equ 0201h ;Int 2F open request
  22. Close equ 0202h ;Int 2F close request
  23. Lock2F equ 0203h ;Int 2F lock request
  24. Unlock2F equ 0204h ;Int 2F unlock request
  25. ; COMDEB - Communications Device Equipment Block.
  26. ;
  27. ; This is essentially a superset of the DCB used outside of this
  28. ; module. The DCB is contained within the DEB as the first fields.
  29. ; The fields which follow are data and status fields which
  30. ; are unique to this implementation.
  31. ;
  32. ; AltQInAddr and AltQOutAddr are alternate queue pointers which are used when
  33. ; in "supervisor" mode. Supervisor mode is a processor mode other than the
  34. ; one which Windows normally runs in. In standard mode Windows, supervisor
  35. ; mode is REAL mode. In enhanced mode Windows, supervisor mode is RING 0
  36. ; protected mode. For more details see comments in IBMINT.ASM.
  37. ComDEB struc ;RS232 Data Equip Block
  38. ComDCB db ((DCBSize+1) and 0FFFEh) DUP (0)
  39. ComErr dw 0 ;Non-zero if I/O error
  40. Port dw 0 ;Base I/O Address
  41. NotifyHandle dw 0
  42. NotifyFlags dw 0
  43. RecvTrigger dw -1 ; char count threshold for calling
  44. SendTrigger dw 0 ; char count threshold for calling
  45. ; The following fields are specific to com ports only
  46. IRQhook dw 0 ; ptr to IRQ_Hook_Struc
  47. NextDEB dw 0 ; ptr to next DEB that is sharing IRQ
  48. XOffPoint dw 0 ;Q count where XOff is sent
  49. EvtMask dw 0 ;Mask of events to check for
  50. EvtWord dw 0 ;Event flags
  51. QInAddr dd 0 ;Address of the queue
  52. AltQInAddr dd 0 ; Addr of queue in "supervisor" mode
  53. QInSize dw 0 ;Length of queue in bytes
  54. QOutAddr dd 0 ;Address of the queue
  55. AltQOutAddr dd 0 ; Addr of queue in "supervisor" mode
  56. QOutSize dw 0 ;Length of queue in bytes
  57. QInCount dw 0 ;Number of bytes currently in queue
  58. QInGet dw 0 ;Offset into queue to get bytes from
  59. QInPut dw 0 ;Offset into queue to put bytes in
  60. QOutCount dw 0 ;Number of bytes currently in queue
  61. QOutGet dw 0 ;Offset into queue to get bytes from
  62. QOutPut dw 0 ;Offset into queue to put bytes in
  63. EFlags db 0 ;Extended flags
  64. MSRShadow db 0 ;Modem Status Register Shadow
  65. ErrorMask db 0 ;Default error-checking mask
  66. RxMask db 0 ;Character mask
  67. ImmedChar db 0 ;Char to be transmitted immediately
  68. HSFlag db 0 ;Handshake flag
  69. HHSLines db 0 ;8250 DTR/RTS bits for handshaking
  70. OutHHSLines db 0 ;Lines that must be high to output
  71. MSRMask db 0 ;Mask of Modem Lines to check
  72. MSRInfinite db 0 ;Mask of MSR lines that must be high
  73. IntVecNum db 0 ;Interrupt vector number
  74. LSRShadow db 0 ;Line Status Register shadow
  75. QOutMod dw 0 ;characters sent mod xOnLim ENQ/ETX [rkh]
  76. VCD_data dd 0
  77. VCDflags db 0
  78. MiscFlags db 0 ;still more flags
  79. ifdef NEC_98
  80. TimerProcAdr dw 0 ; System Timer Procesor (ins 92.08.05)
  81. TimerHandle dw 0 ; System Timer Handle (ins 92.08.05)
  82. MaskFFPort dw 0 ; Mask F/F Set/Reset Port (ins 92.08.05)
  83. ReadSigPort dw 0 ; Read Signal Port (ins 92.08.05)
  84. DataPort dw 0 ; Data Port (ins 92.08.05)
  85. CommandPort dw 0 ; Command Port (ins 92.08.05)
  86. StatusPort dw 0 ; Status Port (ins 92.08.05)
  87. IMRPort dw 0 ; Interrupt Mask Register Port (ins 92.08.05)
  88. EOIPort dw 0 ; End Of Interrupt Port (ins 92.08.05)
  89. CommandShadow db 0 ; Copy of 8251 Command byte (ins 92.08.05)
  90. MaskFFShadow db 0 ; Copy of TxR.RxR.TxE MASK byte (ins 92.08.05)
  91. Mask8259 db 0 ;save old IRQ mask (INS 92.08.05)
  92. IntVecIntCount db 0 ; (INS 92.08.05)
  93. AOBA_flag db 0 ; AOBA (ins 94.04.14)
  94. preFCRShadow db 0 ; WIN N FCR ޴ر (ins 94.06.06)
  95. hTimer dw 0 ;Timer Handle Flag <ins 94.06.03>
  96. endif ; NEC_98
  97. ComDEB ends
  98. .errnz (SIZE ComDEB) and 1
  99. .errnz MSRShadow - EvtWord - 35
  100. ; In 3.0 MSRShadow had this relationship to EvtWord and major COM apps all
  101. ; use this offset of 35 to get to MSRShadow so that they can determine the
  102. ; current status of the Modem Status bits. We need to maintain this offset
  103. ; so that these apps will continue to run.
  104. ; The LptDEB is identical to the ComDEB structure, except
  105. ; all the COM port specific stuff has been removed (which
  106. ; convientiently was stored at the end so offsets would
  107. ; be correct). This allows the code to act indifferently
  108. ; when accessing the strucutres for things like the port.
  109. LptDEB struc
  110. xComDCB db ((DCBSize+1) AND 0FFFEh) dup (0)
  111. xComErr dw 0 ;Non-zero if I/O error
  112. xPort dw 0 ;Base I/O Address
  113. xNotifyHandle dw 0
  114. xNotifyFlags dw 0
  115. xRecvTrigger dw -1 ; char count threshold for calling
  116. xSendTrigger dw 0 ; char count threshold for calling
  117. BIOSPortLoc dw 0 ;Offset to port location (i.e. 40:0)
  118. LptDEB ends
  119. .errnz xComDCB-ComDCB
  120. .errnz xComErr-ComErr
  121. .errnz xPort-Port
  122. .errnz xNotifyHandle-NotifyHandle
  123. .errnz xNotifyFlags-NotifyFlags
  124. .errnz xRecvTrigger-RecvTrigger
  125. .errnz xSendTrigger-SendTrigger
  126. ; flag equates in EFlags
  127. fUseDSR equ 00000001b ; set, if DSR is significant
  128. fNoFIFO equ 00000010b ; set, if no FIFO on port
  129. fFIFOchkd equ 00000100b ; set, if FIFO has been checked
  130. fFIFOpre equ 00001000b ; FIFO enabled when port opened
  131. ;fEOF equ 00100000b ; defined in comdev.inc
  132. ;fTxImmed equ 01000000b ; defined in comdev.inc
  133. fEFlagsMask equ fUseDSR OR fFIFOpre OR fFIFOchkd OR fNoFIFO ; flags which shouldn't be cleared
  134. .errnz fEFlagsMask AND (fEOF OR fTxImmed) ;can't overlap with either of the bits
  135. ; that are folded into COMS_BitMask1
  136. ifdef NEC_98
  137. ; flag equates in AOBA_flag ; (ins 94.04.14)
  138. fFIFO_Mode equ 00000001b ; set, if the baudrate is more 1200BPS (ins 94.04.14)
  139. endif ; NEC_98
  140. ; Values for NotifyFlags
  141. ;
  142. CN_RecvSent equ CN_RECEIVE SHL 8
  143. CN_TransSent equ CN_TRANSMIT SHL 8
  144. CN_Idle equ 10000000b
  145. CN_Notify equ 01000000b
  146. NotifyFlagsLO equ byte ptr NotifyFlags
  147. NotifyFlagsHI equ byte ptr NotifyFlags+1
  148. ; Values for the handshake flag
  149. ;
  150. ; BreakSet - True if break was set - stops transmission
  151. ; XOffSent - True if we have sent the XOff character
  152. ; XOffPending - True if XOff character needs to be sent
  153. ; XOnPending - True if XOn character needs to be sent
  154. ; HHSDown - True if host dropped required hardware lines
  155. ; HHSDropped - True if we dropped our hardware handshake lines
  156. ; XOffReceived - True if XOff received from host
  157. ; HSPending - Mask to return non-zero if XOn or Xoff must be sent
  158. ; HSReceived - Mask to return non-zero if handshake has been
  159. ; received from host stopping transmission
  160. ; CannotXmit - Mask to return non-zero if any condition
  161. ; exists which prevents us from tranmitting.
  162. ; HSSent - Mask to return non-zero if we sent a handshake
  163. XOffPending equ 00000001b ;XOff needs to be sent
  164. EnqPending equ 00000001b ;Enq needs to be sent [rkh]
  165. EtxPending equ 00000001b ;Etx needs to be sent
  166. HHSDropped equ 00000010b ;Our hardware handshake lines are down
  167. XOnPending equ 00000100b ;XOn needs to be sent
  168. AckPending equ 00000100b ;Ack needs to be sent (ENQ/ACK & ETX/ACK)
  169. XOffReceived equ 00001000b ;XOff character received
  170. EnqSent equ 00001000b ;Enq has been sent
  171. EtxSent equ 00001000b ;Etx has been sent
  172. XOffSent equ 00010000b ;XOff has been sent
  173. EnqReceived equ 00010000b ;Enq character received (ENQ/ACK)
  174. EtxReceived equ 00010000b ;Etx character received (ETX/ACK)
  175. HHSDown equ 00100000b ;Host hardware handshake lines are down
  176. BreakSet equ 01000000b ;Break has been set
  177. HHSAlwaysDown equ 10000000b ;set if host handshake lines were never
  178. ; detected high
  179. HSPending equ XOffPending+XOnPending
  180. HSReceived equ XOffReceived+HHSDown
  181. HSSent equ XOffSent+HHSDropped
  182. CannotXmit equ HSPending+HSReceived+BreakSet
  183. ; values for MiscFlags
  184. Discard equ 00000001b ;Discard recevied data
  185. ifdef NEC_98
  186. ;** NewI/ODelay - delay long enough for the bus to catch up to the cpu;(ins 92.11.11)
  187. NEWIODELAY MACRO times ;(ins 92.11.11)
  188. LOCAL a ;(ins 92.11.11)
  189. push CX ;(ins 92.11.11)
  190. mov CX,times ;(ins 92.11.11)
  191. a: OUT 5Fh,AL ;(ins 92.11.11)
  192. loop a ;(ins 92.11.11)
  193. pop CX ;(ins 92.11.11)
  194. ENDM ;(ins 92.11.11)
  195. else ; NEC_98
  196. iodelay macro ;;macro to insure that an instruction
  197. jmp $+2 ;; fetch occurs between IN and/or OUT
  198. jmp $+2 ;; instructions on the PC-AT machine
  199. endm
  200. endif ; NEC_98
  201. TimeoutError equ -2 ;Timeout error code for $TRMCOM
  202. Timeout equ 30 ;30 second timeout
  203. DELAY_TIME equ 200 ;Delay at least 200 milliseconds
  204. ; Status bits returned from the BIOS for LPT ports
  205. PS_NotBusy equ 10000000b ;Printer not busy
  206. PS_Ack equ 01000000b ;Data acknowledged
  207. PS_PaperOut equ 00100000b ;Out of paper
  208. PS_Select equ 00010000b ;Device is selected
  209. PS_IOError equ 00001000b ;IO error
  210. PS_Timeout equ 00000001b ;Timeout occured
  211. ; status bit defines for LPT
  212. L_BITS equ 0F8h ; the status bits we want
  213. L_BITS_INVERT equ 048h ; must invert to match BIOS
  214. L_DEVBUSY equ 080h ; device busy bit
  215. L_TIMEOUT equ 001h ; timeout bit
  216. ; control bit defines for LPT
  217. L_NORMAL equ 00Ch ; normal state: selected, no reset
  218. L_RESET equ 008h ; reset state
  219. L_STROBE equ 00Dh ; tell printer we have char
  220. ifdef NEC_98
  221. ; control port for TOKI(Printer) ; <Toki:930923>
  222. Toki_BasePort equ 0140h ; Base I/O Address <Toki:930923>
  223. Toki_DataLatch equ 0140h ; Data Port <Toki:930923>
  224. Toki_PrinterStatus equ 0141h ; Status Port <Toki:930923>
  225. Toki_PrinterControls equ 0142h ; Control Port <Toki:930923>
  226. Toki_ControlStatus equ 0149h ; Control Status Port <Toki:930923>
  227. Toki_EX_Control equ 014eh ; Ex Control Port <Toki:930923>
  228. ;--------------- 8251 Serial Interface Command Status ----------------------
  229. ;--------------------------------------------------------
  230. ; Modem Status ( IBM Emulation ) USE MSR_READ
  231. ;--------------------------------------------------------
  232. DSR = 10000000B ; Data Set Ready
  233. RI = 01000000B ; Ring Indicater (CI)
  234. CTS = 00100000B ; Clear To Send
  235. RLSD = 00010000B ; Recive Line Signal Detect (CD)
  236. ;--------------------------------------------------------
  237. ; Port C ( USART Trap Mask )
  238. ;--------------------------------------------------------
  239. RAM_CHECK = 00010000b ; Prity Check of RAM Enable
  240. SPEAKER_OFF = 00001000b ; Stop Speaker
  241. MSK_TXR = 00000100B ; TX Ready Enable
  242. MSK_TXE = 00000010B ; TX Empty Enable
  243. MSK_RXR = 00000001B ; RX Ready Enable
  244. ;--------------------------------------------------------
  245. ; 8251 Int Enable F/F
  246. ;--------------------------------------------------------
  247. Enable_TxR equ 00000100b ;Tx Ready F/F Enable
  248. Enable_TxE equ 00000010b ;Tx Empty F/F Enable
  249. Enable_RxR equ 00000001b ;Rx Ready F/F Enable
  250. ;--------------------------------------------------------
  251. ; 8251 Status
  252. ;--------------------------------------------------------
  253. BRK_DETECT = 01000000B ; Break Detect
  254. F_ERR = 00100000B ; Framing Err
  255. O_ERR = 00010000B ; OverRun Err
  256. P_ERR = 00001000B ; Parity Err
  257. TX_EMP = 00000100B ; TX Empty
  258. RX_RDY = 00000010B ; RX Ready
  259. TX_RDY = 00000001B ; TX Ready
  260. ;--------------------------------------------------------
  261. ; 8251 Command Byte
  262. ;--------------------------------------------------------
  263. INTER_RESET = 01000000B ; Mode Instruction Set
  264. RTS = 00100000B ; RTS
  265. ERR_RESET = 00010000B ; Reset PE & OE & FE Bit
  266. SEND_BREAK = 00001000B ; The Break commands bit
  267. RX_E = 00000100B ; RX Enable
  268. DTR = 00000010B ; DTR
  269. TX_E = 00000001B ; TX Enable
  270. ;--------------------------------------------------------
  271. ; etc.....
  272. ;--------------------------------------------------------
  273. SLAVE_PIC = 08H ; Slave PIC Port
  274. ISR_READ = 0BH ; ISR Read Command
  275. MASTER_OCW2 = 00H ; Master PIC OCW2 Port
  276. SLAVE_ISR = 08H ; Slave PIC ISR Port
  277. EOI = 20H ; EOI Command
  278. ALL_DONE = 00000000B ; 8251 Interrupt Disable
  279. RS_TIME_MOD = 0B6H ; Ch.0 baudrate Generator
  280. TIMER2 = 075H ;
  281. TIME_CTL = 077H ;
  282. SI_CHR = 0FH ; SHIFT IN
  283. SO_CHR = 0EH ; SHIFT OUT
  284. ;---------------------------------------------------------
  285. ; Parallel Interface Command & Status Set
  286. ;---------------------------------------------------------
  287. PRN_WRITE_DATA equ 040h ;
  288. PRN_READ_SIGNAL1 equ 042h ;
  289. PRN_WRITE_SIGNAL1 equ 046h ;
  290. PRN_PSTB_Active_X2 equ 004h ;
  291. PRN_PSTB_NonActive_X2 equ 005h ;
  292. CMOS_RAM_SEG_X2 equ 0e300h ; Memory Switch Segment ( PC-98XA )
  293. PRN_PSTB_Active_X1 equ 00eh ;
  294. PRN_PSTB_NonActive_X1 equ 00fh ;
  295. CMOS_RAM_SEG_X1 equ 0a300h ; Memory Switch Segment ( PC-9800 )
  296. PRN_TimeOutValue equ 005h
  297. ;-------------------------------------------
  298. ; Offset Address of Software Switch
  299. ;-------------------------------------------
  300. ssw1 equ 0fe2h ;
  301. ssw2 equ 0fe6h ;
  302. ssw3 equ 0feah ;
  303. ssw4 equ 0feeh ;
  304. ssw5 equ 0ff2h ;
  305. ssw6 equ 0ff6h ;
  306. endif ; NEC_98
  307. IRQ_Hook_Struc struc
  308. IRQn db 0
  309. HookCnt db 0
  310. OldMask db 0
  311. VecN db 0FFh
  312. HandlerOff dw 0
  313. First_DEB dw 0
  314. OldIntVec dd 0
  315. IFDEF No_DOSX_Bimodal_Services
  316. RM_OldIntVec dd 0
  317. RM_HandlerOff dw 0
  318. ENDIF
  319. IRQ_Hook_Struc ends
  320. IFDEF No_DOSX_Bimodal_Services
  321. include int31.inc
  322. Get_RM_IntVector equ (Int31_Int_Serv SHL 8) + Int_Get_Real_Vec
  323. Set_RM_IntVector equ (Int31_Int_Serv SHL 8) + Int_Set_Real_Vec
  324. ENDIF
  325. ;
  326. ; flag bits for VCDflags
  327. ;
  328. fCOM_ignore_ints equ 00000001b