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.

443 lines
16 KiB

  1. ;++
  2. ;
  3. ; Copyright (c) 1989 Microsoft Corporation
  4. ;
  5. ; Module Name:
  6. ;
  7. ; mouse.inc
  8. ;
  9. ; Abstract:
  10. ;
  11. ; This file defines the hardware specific equates to be used in
  12. ; the mouse detection code.
  13. ;
  14. ; Author:
  15. ;
  16. ; Shie-Lin (shielint) 22-Feb-1992
  17. ;
  18. ; Revision History:
  19. ;
  20. ;--
  21. ;
  22. ; External references
  23. ;
  24. IFDEF NEC_98
  25. ELSE ; NEC_98
  26. extrn _InportMouseIrqDetection:proc
  27. ENDIF ; NEC_98
  28. extrn _READ_PORT_UCHAR: proc
  29. extrn _WRITE_PORT_UCHAR: proc
  30. ;
  31. ; Internal Macros
  32. ;
  33. IOdelay macro
  34. jmp $+2
  35. jmp $+2
  36. endm
  37. address macro StartAddr, EndAddr
  38. add dx,StartAddr-EndAddr
  39. endm
  40. DelayIn macro
  41. push dx
  42. call _READ_PORT_UCHAR ; destroy AL
  43. add sp, 2
  44. endm
  45. DelayOut macro
  46. push ax
  47. push dx
  48. call _WRITE_PORT_UCHAR ; destroy AL
  49. add sp, 4
  50. endm
  51. IFDEF NEC_98
  52. MultiDelayOut8 macro
  53. push di
  54. mov di, ax
  55. DelayOut
  56. mov ax, di
  57. DelayOut
  58. mov ax, di
  59. DelayOut
  60. mov ax, di
  61. DelayOut
  62. mov ax, di
  63. DelayOut
  64. mov ax, di
  65. DelayOut
  66. mov ax, di
  67. DelayOut
  68. mov ax, di
  69. DelayOut
  70. pop di
  71. endm
  72. ELSE ; NEC_98
  73. ENDIF ; NEC_98
  74. ;
  75. ; Mouse information structure
  76. ; N.B. This must match the one defined in hwdetect.h
  77. ;
  78. MouseInformation struc
  79. MouseType db 0
  80. MouseSubtype db 0
  81. MousePort dw 0 ; if serial mouse, 1 for com1, 2 for com2 ...
  82. MouseIrq dw 0
  83. DeviceIdLength dw 0
  84. DeviceId db 10 dup(?); Pnp device id if any
  85. MouseInformation ends
  86. ;
  87. ; Mouse ID's returned by GetMouseType().
  88. ;
  89. UNKNOWN_MOUSE equ 0 ; Don't know whether or not a mouse is
  90. ; installed...
  91. NO_MOUSE equ 100H ; No mouse installed.
  92. MS_MOUSE equ 200H ; MS Regular mouse
  93. MS_BALLPOINT equ 300H ; MS Ballpoint mouse
  94. LT_MOUSE equ 400H ; LogTec mouse
  95. IFDEF NEC_98
  96. NEC_MOUSE equ 500H ; NEC PC-9800 Series Mouse
  97. PC98BUS_MOUSE equ 7h
  98. ENDIF ; NEC_98
  99. PS2_MOUSE equ 1h ; Connect to 8042 mouse port
  100. SERIAL_MOUSE equ 2h
  101. INPORT_MOUSE equ 3h
  102. BUS_MOUSE equ 4h
  103. PS2_MOUSE_WITH_WHEEL equ 5
  104. SERIAL_MOUSE_WITH_WHEEL equ 6
  105. TRUE EQU 0ffh
  106. FALSE EQU 0
  107. LW_ClockTickCount EQU 46Ch
  108. HW_ClockTickCount EQU 46Eh
  109. ;************************************************************************
  110. ; I N P O R T D E F I N I T I O N S *
  111. ;************************************************************************
  112. INP_ADDR EQU 0 ; Inport addr register offset.
  113. INP_DATA EQU 1 ; Inport data register offset.
  114. INP_ID EQU 2 ; Inport ID register offset.
  115. INP_TEST EQU 3 ; Inport test register offset.
  116. INPORT_ID EQU 0DEh ; InPort ID byte.
  117. INP_STATUS_REG EQU 0 ; Status register number.
  118. INP_DATA1_REG EQU 1 ; Internal data register 1.
  119. INP_DATA2_REG EQU 2 ; Internal data register 2.
  120. INP_MODE_REG EQU 7 ; Mode register number.
  121. INP_RESET EQU 10000000b ; Value to reset InPort.
  122. HZ0INTR0 EQU 00000000b ; Value to select 0 Hz, INTR=0
  123. HZ0INTR1 EQU 00000110b ; Value to select 0 Hz, INTR=1
  124. HZ30 EQU 00000001b ; Value to select 30 Hz.
  125. DATA_INT_ENAB EQU 00001000b ; Data int enable bit.
  126. TIMER_INT_ENAB EQU 00010000b ; Timer int enable bit.
  127. HOLD_BIT EQU 00100000b ; Hold bit.
  128. BUTTON_1_BIT EQU 00000100b ; Bit indicating button 1.
  129. BUTTON_3_BIT EQU 00000001b ; Bit indicating button 3.
  130. MOVEMENT_BIT EQU 01000000b ; Bit indicating movement.
  131. INPORT_FIRST_PORT EQU 23Ch ; Address of primary InPort.
  132. INPORT_LAST_PORT EQU 230h ; Address of secondary InPort.
  133. MACH20_IRQ EQU 0Ch ; IRQ used for Mach 20 InPort
  134. ; under Mach 20 OS/2.
  135. ;****************************************************************
  136. ; B U S D E F I N I T I O N S *
  137. ;****************************************************************
  138. ; Since the Adaptor for the bus mouse is based on an 8255A, we have to
  139. ; program the 8255A properly in order to function. We need to select:
  140. ;
  141. ; Mode 0 (for all ports).
  142. ; Port A (input - this allows us to read information from the ALPS
  143. ; chip and from the buttons)
  144. ; Port B (output - this allows us to write a value there and then
  145. ; read it back in. It is not connected to anything)
  146. ; Port C, upper half (output - this allows us to send control
  147. ; information to the ALPS chip)
  148. ; Port C, lower half (input - this allows us to poll the current states
  149. ; of IRQs 2, 3, 4, and 5)
  150. ;
  151. ; The value that does this is
  152. ;
  153. ; 10010001
  154. ; ||||||||----- Port C Lower is input
  155. ; |||||||------ Port B is output
  156. ; ||||||------- Mode 0 for Group B (Port B and lower half of Port C)
  157. ; |||||-------- Port C Upper is output
  158. ; ||||--------- Port A is input
  159. ; |------------ Mode 0 for Group A (Port A and upper half of Port C)
  160. ; ------------- Mode set control word
  161. ;
  162. BUS_MOUSE_BASE EQU 023Ch ; Base I/O addr of bus mouse.
  163. BUS_DATA EQU BUS_MOUSE_BASE ; Port where mouse data is read from.
  164. BUS_SIG EQU BUS_MOUSE_BASE + 1 ; Port unused for mouse, used for de-
  165. ; termining existence of bus adaptor.
  166. BUS_CONTROL EQU BUS_MOUSE_BASE + 2 ; Port used to control adaptor.
  167. BUS_INIT EQU BUS_MOUSE_BASE + 3 ; Port used to init bus adaptor.
  168. BUS_INIT_VALUE EQU 10010001b ; Value used to init bus adaptor.
  169. LOW_X EQU 090h ; Cmd to read low 4 bits of delta X
  170. HI_X EQU 0B0h ; Cmd to read high 2 bits of delta X
  171. LOW_Y EQU 0D0h ; Cmd to read low 4 bits of delta Y
  172. HI_Y EQU 0F0h ; Cmd to read high 2 bits of delta Y
  173. ;************************************************************************
  174. ; S E R I A L D E F I N I T I O N S *
  175. ;************************************************************************
  176. SERIAL_PACKETSIZE EQU 3 ; Bytes in a packet of data.
  177. SYNC_BIT EQU 40H ; Bit 6 is the sync bit
  178. ;
  179. ; These are the offsets within the COM chip of the various registers.
  180. ;
  181. TXB EQU 0 ; Transmit buffer
  182. RXB EQU 0 ; Receive buffer
  183. LATLSB EQU 0 ; Divisor latch, LSB
  184. LATMSB EQU 1 ; Divisor latch, MSB
  185. IER EQU 1 ; Interrupt enable register
  186. IIR EQU 2 ; Interrupt identification register
  187. LCR EQU 3 ; Line control register
  188. MCR EQU 4 ; Modem control register
  189. LSR EQU 5 ; Line status register
  190. MSR EQU 6 ; Modem status register
  191. IFDEF NEC_98
  192. BASE_8251_NEC EQU 30h ; Base I/O address of 8251 serial controller
  193. BASE_16550_NEC EQU 238h ; Base I/O address of 16550 serial controller
  194. DATA_8251 EQU BASE_8251_NEC ; Port used to data read/write.
  195. MODE_8251 EQU BASE_8251_NEC + 2 ; Port used to set mode.
  196. COMMAND_8251 EQU BASE_8251_NEC + 2 ; Port used to write command.
  197. STATUS_8251 EQU BASE_8251_NEC + 2 ; Port used to read status.
  198. SIGNAL_READ_8251 EQU BASE_8251_NEC + 3 ; Port used to read signal.
  199. MASK_8251 EQU BASE_8251_NEC + 5 ; Port used to set mask.
  200. BAUD_MODE_NEC EQU 77h ; Port used to set mode for baud rate.
  201. BAUD_COUNT_NEC EQU 75h ; Port used to write baud rate.
  202. SPEAKER_CONTROL_PORT EQU 37h
  203. SPEAKER_OFF EQU 07h
  204. SPEAKER_ON EQU 06h
  205. WAIT1S EQU 90000h
  206. ENDIF ;NEC_98
  207. ;
  208. ; These give the number of milliseconds to wait while waiting for the serial
  209. ; mouse to reset itself. We will first use the value given by SHORTDELAY
  210. ; and if that fails, we will then use the value given by LONGDELAY.
  211. ;
  212. SHORTDELAY EQU 6 ; 350 msecs = 350/55.5 = 6 clock ticks.
  213. LONGDELAY EQU 18 ; 1000 msecs = 1000/55.5 = 18 clock ticks.
  214. ;
  215. ; These are the values that are written into the divisor latch for the
  216. ; various baud rates. They are obtained by dividing the clock rate
  217. ; (1.8432 MHz) by 16x the desired baud rate.
  218. ;
  219. DIV_50 EQU 900h
  220. DIV_75 EQU 600h
  221. DIV_110 EQU 417h
  222. DIV_150 EQU 300h
  223. DIV_300 EQU 180h
  224. DIV_600 EQU 0C0h
  225. DIV_1200 EQU 060h
  226. DIV_1800 EQU 040h
  227. DIV_2000 EQU 03Ah
  228. DIV_2400 EQU 030h
  229. DIV_3600 EQU 020h
  230. DIV_4800 EQU 018h
  231. DIV_7200 EQU 010h
  232. DIV_9600 EQU 00Ch
  233. ;
  234. ;** Interrupt enable masks
  235. ;
  236. IE_RX EQU 00000001b ; read data available
  237. IE_TX EQU 00000010b ; transmit buffer empty
  238. IE_LX EQU 00000100b ; line status change
  239. IE_MX EQU 00001000b ; modem status change
  240. ;
  241. ;** Line control masks
  242. ;
  243. LC_BMASK EQU 00000011b ; data bits mask
  244. LC_BITS5 EQU 00000000b ; 5 data bits
  245. LC_BITS6 EQU 00000001b ; 6 data bits
  246. LC_BITS7 EQU 00000010b ; 7 data bits
  247. LC_BITS8 EQU 00000011b ; 8 data bits
  248. LC_SMASK EQU 00000100b ; stop bits mask
  249. LC_STOP1 EQU 00000000b ; 1 stop bit
  250. LC_STOP2 EQU 00000100b ; 2 stop bits (1.5 if 5 data bits)
  251. LC_PMASK EQU 00111000b ; parity mask
  252. LC_PNONE EQU 00000000b ; none parity
  253. LC_PODD EQU 00001000b ; odd parity
  254. LC_PEVEN EQU 00011000b ; even parity
  255. LC_PMARK EQU 00101000b ; mark parity
  256. LC_PSPACE EQU 00111000b ; space parity
  257. LC_BREAK EQU 01000000b ; transmit break
  258. LC_DLAB EQU 10000000b ; divisor latch access bit
  259. LC_MASK EQU 01111111b ; documented line control register bits
  260. ;
  261. ;** Modem control register masks
  262. ;
  263. MC_DTR EQU 00000001b ; data terminal ready
  264. MC_RTS EQU 00000010b ; request to send
  265. MC_OUT1 EQU 00000100b ; output 1
  266. MC_OUT2 EQU 00001000b ; output 2
  267. MC_LOOP EQU 00010000b ; loopback mode
  268. ;
  269. ;** Line status register masks
  270. ;
  271. LS_DR EQU 00000001b ; data ready
  272. LS_OERR EQU 00000010b ; overrun error
  273. LS_PERR EQU 00000100b ; parity error
  274. LS_FERR EQU 00001000b ; framing error
  275. LS_BI EQU 00010000b ; break interrupt
  276. LS_THRE EQU 00100000b ; TX holding register empty
  277. LS_TSRE EQU 01000000b ; TX shift register empty
  278. ;
  279. ;** Modem status register definitions:
  280. ;
  281. MS_DCTS EQU 00000001b ; delta clear to send
  282. MS_DDSR EQU 00000010b ; delta data set ready
  283. MS_TERI EQU 00000100b ; trailing edge of ring indicator
  284. MS_DDCD EQU 00001000b ; delta receiver line signal detect
  285. MS_CTS EQU 00010000b ; clear to send
  286. MS_DSR EQU 00100000b ; data set ready
  287. MS_RI EQU 01000000b ; ring indicator
  288. MS_DCD EQU 10000000b ; receiver line signal detect
  289. ;************************************************************************
  290. ; 8 2 5 9 A D E F I N I T I O N S *
  291. ;************************************************************************
  292. MASTER_MASK_ADDR EQU 021h ; Master's mask register addr.
  293. SLAVE_MASK_ADDR EQU 0A1h ; Slave's mask register addr.
  294. IRQS_PER_8259 EQU 8 ; # IRQs on each 8259A.
  295. SELECT_IRR EQU 0Ah ; Selects int request register.
  296. SELECT_ISR EQU 0Bh ; Selects in service register.
  297. ;****************************************************************
  298. ; P S / 2 D E F I N I T I O N S *
  299. ;****************************************************************
  300. PS2_IRQ EQU 0Ch ; Always IRQ 12 for PS/2 mouse.
  301. PS2_IRQ_MASK EQU 00010000b ; Bit mask for IRQ 12.
  302. PS2_PACKETSIZE EQU 3 ; Bytes in a packet of data.
  303. DX_SIGN EQU 00010000b ; Bit 4 is dx sign bit in status byte
  304. DY_SIGN EQU 00100000b ; Bit 5 is dy sign bit in status byte
  305. PS2_25PPI EQU 0 ; Value to set resolution to 25 ppi.
  306. PS2_50PPI EQU 1 ; Value to set resolution to 50 ppi.
  307. PS2_100PPI EQU 2 ; Value to set resolution to 100 ppi.
  308. PS2_200PPI EQU 3 ; Value to set resolution to 200 ppi.
  309. MOUSE_RESET EQU 0FFh ; Reset mouse command
  310. MOUSE_RESEND EQU 0FEh ; Resend data to mouse
  311. MOUSE_DIAG_ERR EQU 0FCh ; Error on mouse diagnostics
  312. MOUSE_ACK EQU 0FAh ; Acknowledge
  313. MOUSE_DEFAULT EQU 0F6h
  314. MOUSE_DISABLE EQU 0F5h ; Disable Mouse command
  315. MOUSE_ENABLE EQU 0F4h ; Enable Mouse command
  316. MOUSE_RATE EQU 0F3h ; Set sampling rate
  317. MOUSE_READ_TYPE EQU 0F2h ; Read device type
  318. MOUSE_REMOTE EQU 0F0h ; Set remote mode
  319. MOUSE_ECHO EQU 0EEh ; Set wrap mode
  320. MOUSE_KILL_ECHO EQU 0ECh ; reset wrap mode
  321. MOUSE_READDATA EQU 0EBh ; Read mouse data
  322. MOUSE_STREAM EQU 0EAh ; Set stream mode
  323. MOUSE_STATUS EQU 0E9h ; Status Request
  324. MOUSE_RESOLUTION EQU 0E8h ; Set Resolution
  325. MOUSE_SCALE_2_1 EQU 0E7h ; Set scaling 2 to 1
  326. MOUSE_SCALE_1_1 EQU 0E6h ; Set scaling 1 to 1
  327. MOUSE_DIAG_OK EQU 0AAh ; Diagnostics ok
  328. MOUSE_DIAG_ID EQU 000h ; Diagnostic ID number
  329. ;
  330. ; The following codes are specific to the Microsoft PS/2 mouse
  331. ;
  332. MOUSE_MS_VERS EQU 052h ; Read current firmware version number
  333. MOUSE_MS_INPORT EQU 056h ; Read raw InPort data
  334. MOUSE_MS_DIAG EQU 059h ; enter MS diagnostices mode
  335. MOUSE_MS_READRAM EQU 05Bh ; read ram byte
  336. ;****************************************************************
  337. ; 8 0 4 2 D E F I N I T I O N S *
  338. ;****************************************************************
  339. ;
  340. ; 8042 port definitions.
  341. ;
  342. DATA_8042 EQU 60h ; Port where data is sent to/from 8042.
  343. CONTROL_8042 EQU 64h ; Port where commands are sent to 8042.
  344. STATUS_8042 EQU 64h ; Port where status is read from 8042.
  345. CRT_DATA_SEG EQU 40H ; ROM BIOS CRT Data Segment Address
  346. ;
  347. ; Status register bit definitions.
  348. ;
  349. OUTPUT_BUFFER_FULL EQU 01h ; 8042's output buffer is full.
  350. INPUT_BUFFER_FULL EQU 02h ; 8042's input buffer is full.
  351. AUX_OUTPUT_BUFFER_FULL EQU 20h ; 8042's aux output buffer is full.
  352. ;
  353. ; Command byte bit definitions.
  354. ;
  355. AUX_DISABLED EQU 20h ; Auxiliary interface is disabled.
  356. AUX_INT_ENABLE EQU 02h ; Auxiliary interrupts are enabled.
  357. KBD_INT_ENABLE EQU 01H ; Keyboard interrupt enabled.
  358. ;
  359. ; 8042 commands.
  360. ;
  361. CMD8042_READ_CMD EQU 020h ; Read command byte.
  362. CMD8042_WRITE_CMD EQU 060h ; Write command byte.
  363. CMD8042_DISABLE_AUX EQU 0A7h ; Disable auxiliary interface.
  364. CMD8042_ENABLE_AUX EQU 0A8h ; Enable auxiliary interface.
  365. CMD8042_TEST_AUX EQU 0A9h ; Test auxiliary interface.
  366. CMD8042_DISABLE_KBD EQU 0ADh ; Disable keyboard.
  367. CMD8042_ENABLE_KBD EQU 0AEh ; Enable keyboard.
  368. CMD8042_WRITE_AUX EQU 0D4h ; Send data to auxiliary device.