home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / DEV / MOUSE / HW.INC < prev    next >
Text File  |  1995-04-14  |  17KB  |  385 lines

  1. ;*DDK*************************************************************************/
  2. ;
  3. ; COPYRIGHT (C) Microsoft Corporation, 1989
  4. ; COPYRIGHT    Copyright (C) 1995 IBM Corporation
  5. ;
  6. ;    The following IBM OS/2 WARP source code is provided to you solely for
  7. ;    the purpose of assisting you in your development of OS/2 WARP device
  8. ;    drivers. You may use this code in accordance with the IBM License
  9. ;    Agreement provided in the IBM Device Driver Source Kit for OS/2. This
  10. ;    Copyright statement may not be removed.;
  11. ;*****************************************************************************/
  12.  
  13. ;/*************************************************************************
  14. ;*
  15. ;* SOURCE FILE NAME = HW.INC
  16. ;*
  17. ;* DESCRIPTIVE NAME = Device dependent DD include file.
  18. ;*
  19. ;*
  20. ;* VERSION      V2.0
  21. ;*
  22. ;* DATE         07/08/91
  23. ;*
  24. ;* DESCRIPTION  Device dependent DD include file.
  25. ;*
  26. ;* FUNCTIONS    NONE.
  27. ;*
  28. ;* NOTES        Hardware specific equates
  29. ;*
  30. ;*
  31. ;*
  32. ;*
  33. ;* STRUCTURES   NONE
  34. ;*
  35. ;* EXTERNAL REFERENCES
  36. ;*
  37. ;*              NONE
  38. ;*
  39. ;* EXTERNAL FUNCTIONS
  40. ;*
  41. ;*              NONE
  42. ;*
  43. ;* CHANGE ACTIVITY =
  44. ;*   DATE      FLAG        APAR   CHANGE DESCRIPTION
  45. ;*   --------  ----------  -----  --------------------------------------
  46. ;*   mm/dd/yy  @Vr.mpppxx  xxxxx  xxxxxxx
  47. ;*   07/08/91              53248
  48. ;*   04/04/93              53232  Add support for Logitech middle button
  49. ;*
  50. ;**************************************************************************
  51.  
  52.  
  53. ;***************************************************************************
  54. ;*               B U S   D E F I N I T I O N S                             *
  55. ;***************************************************************************
  56. ;* Since the Adaptor for the bus mouse is based on an 8255A, we have to
  57. ;*     program the 8255A properly in order to function. We need to select:
  58. ;*
  59. ;*     Mode 0 (for all ports).
  60. ;*     Port A (input - this allows us to read information from the ALPS
  61. ;*             chip and from the buttons)
  62. ;*     Port B (output - this allows us to write a value there and then
  63. ;*             read it back in. It is not connected to anything)
  64. ;*     Port C, upper half (output - this allows us to send control
  65. ;*             information to the ALPS chip)
  66. ;*     Port C, lower half (input - this allows us to poll the current states
  67. ;*             of IRQs 2, 3, 4, and 5)
  68. ;*
  69. ;* The value that does this is
  70. ;*
  71. ;*     10010001
  72. ;*     ||||||||-----   Port C Lower is input
  73. ;*     |||||||------   Port B is output
  74. ;*     ||||||-------   Mode 0 for Group B (Port B and lower half of Port C)
  75. ;*     |||||--------   Port C Upper is output
  76. ;*     ||||---------   Port A is input
  77. ;*     |------------   Mode 0 for Group A (Port A and upper half of Port C)
  78. ;*     -------------   Mode set control word
  79. ;***************************************************************************
  80.  
  81. BUS_MOUSE_BASE  EQU     023Ch           ; Base I/O addr of bus mouse.
  82.  
  83. BUS_DATA        EQU     BUS_MOUSE_BASE  ; Port where mouse data is read from.
  84. BUS_SIG         EQU     BUS_MOUSE_BASE + 1 ; Port unused for mouse, used for de-
  85.                                         ; termining existence of bus adaptor.
  86. BUS_CONTROL     EQU     BUS_MOUSE_BASE + 2 ; Port used to control adaptor.
  87. BUS_INIT        EQU     BUS_MOUSE_BASE + 3 ; Port used to init bus adaptor.
  88.  
  89. BUS_INIT_VALUE  EQU     10010001b       ; Value used to init bus adaptor.
  90.  
  91. LOW_X           EQU     090h            ; Cmd to read low 4 bits of delta X
  92. HI_X            EQU     0B0h            ; Cmd to read high 2 bits of delta X
  93. LOW_Y           EQU     0D0h            ; Cmd to read low 4 bits of delta Y
  94. HI_Y            EQU     0F0h            ; Cmd to read high 2 bits of delta Y
  95.  
  96. Num_Of_Ports    equ 4                   ; Number of ports
  97.  
  98. BUS_First_Possible  EQU 023cH           ; I/O address of first possible InPort
  99. BUS_Last_Possible   EQU 023fH           ; I/O address of last possible InPort
  100.  
  101.  
  102. ;************************************************************************
  103. ;*               I N P O R T     D E F I N I T I O N S                  *
  104. ;************************************************************************
  105.  
  106. INP_FIRST_PORT EQU      23Ch            ; Address of primary InPort.
  107. INP_LAST_PORT  EQU      238h            ; Address of secondary InPort.
  108.  
  109. INP_ADDR        EQU     0               ; Inport addr register offset.
  110. INP_DATA        EQU     1               ; Inport data register offset.
  111. INP_ID          EQU     2               ; Inport ID register offset.
  112. INP_TEST        EQU     3               ; Inport test register offset.
  113.  
  114. INPORT_ID       EQU     0DEh            ; InPort type code in ID register
  115.  
  116. INP_STATUS_REG  EQU     0               ; Status register number.
  117. INP_DATA1_REG   EQU     1               ; Internal data register 1.
  118. INP_DATA2_REG   EQU     2               ; Internal data register 2.
  119. INP_MODE_REG    EQU     7               ; Mode register number.
  120.  
  121. INP_RESET       EQU     10000000b       ; Value to reset InPort.
  122.  
  123. HZ0INTR0        EQU     00000000b       ; Value to select 0 Hz, INTR=0
  124. HZ0INTR1        EQU     00000110b       ; Value to select 0 Hz, INTR=1
  125. HZ30            EQU     00000001b       ; Value to select 30 Hz.
  126. HZ50            EQU     00000010b       ; Value to select 50 Hz.
  127. HZ100           EQU     00000011b       ; Value to select 100 Hz.
  128. HZ200           EQU     00000100b       ; Value to select 200 Hz.
  129. DATA_INT_ENAB   EQU     00001000b       ; Data int enable bit.
  130. TIMER_INT_ENAB  EQU     00010000b       ; Timer int enable bit.
  131. HOLD_BIT        EQU     00100000b       ; Hold bit.
  132. NOT_HOLD_BIT    EQU     11011111B       ; All on except bit 5
  133.  
  134. BUTTON_1_BIT    EQU     00000100b       ; Bit indicating button 1.
  135. BUTTON_3_BIT    EQU     00000001b       ; Bit indicating button 3.
  136. MOVEMENT_BIT    EQU     01000000b       ; Bit indicating movement.
  137.  
  138. INP_MASTER_LEVELS       EQU 10111000b   ; IRQs 7, 5, 4, and 3.
  139. INP_SLAVE_LEVELS        EQU 10011110b   ; IRQs 15, 12, 11, 10, and 9.
  140.  
  141. ;****************************************************************
  142. ;*                 P D I   D E F I N I T I O N S                *
  143. ;****************************************************************
  144.  
  145. PDI_IRQ         EQU     0Ch             ; Always IRQ 12 for PS/2 mouse.
  146. PDI_IRQ_MASK    EQU     00010000b       ; Bit mask for IRQ 12.
  147. PDI_PACKETSIZE  EQU     3               ; Bytes in a packet of data.
  148. ALIGN_TIMEOUT   equ     15000           ; 30,000 msecs = 30 seconds
  149. THREE_BUTT_MASK equ     00001000b       ; Bit 4 reserved bit when 3 button
  150.                                         ; mouse detected                  
  151. TWO_BUTT_MASK   equ     00001100b       ; Bits 3 and 4 reserved bits used by
  152.                                         ; hardware are always the same in
  153.                                         ; first byte of packet.           
  154. DX_SIGN         EQU     00010000b       ; Bit 4 is dx sign bit in status byte
  155. DY_SIGN         EQU     00100000b       ; Bit 5 is dy sign bit in status byte
  156.  
  157. PDI_25PPI       EQU     0               ; Value to set resolution to 25 ppi.
  158. PDI_50PPI       EQU     1               ; Value to set resolution to 50 ppi.
  159. PDI_100PPI      EQU     2               ; Value to set resolution to 100 ppi.
  160. PDI_200PPI      EQU     3               ; Value to set resolution to 200 ppi.
  161.  
  162.  
  163. MCMD_RESET      EQU     0FFh            ; Reset mouse command
  164. MCMD_RESEND     EQU     0FEh            ; Resend data to mouse
  165. MCMD_DIAG_ERR   EQU     0FCh            ; Error on mouse diagnostics
  166. MCMD_ACK        EQU     0FAh            ; Acknowledge
  167. MCMD_DEFAULT    EQU     0F6h
  168. MCMD_DISABLE    EQU     0F5h            ; Disable Mouse command
  169. MCMD_ENABLE     EQU     0F4h            ; Enable Mouse command
  170. MCMD_RATE       EQU     0F3h            ; Set sampling rate
  171. MCMD_READ_TYPE  EQU     0F2h            ; Read device type
  172. MCMD_REMOTE     EQU     0F0h            ; Set remote mode
  173. MCMD_ECHO       EQU     0EEh            ; Set wrap mode
  174. MCMD_KILL_ECHO  EQU     0ECh            ; reset wrap mode
  175. MCMD_READDATA   EQU     0EBh            ; Read mouse data
  176. MCMD_STREAM     EQU     0EAh            ; Set stream mode
  177. MCMD_STATUS     EQU     0E9h            ; Status Request
  178. MCMD_RESOLUTION EQU     0E8h            ; Set Resolution
  179. MCMD_SCALE_2_1  EQU     0E7h            ; Set scaling 2 to 1
  180. MCMD_SCALE_1_1  EQU     0E6h            ; Set scaling 1 to 1
  181. MCMD_DIAG_OK    EQU     0AAh            ; Diagnostics ok
  182. MCMD_DIAG_ID    EQU     000h            ; Diagnostic ID number
  183.  
  184. ;*
  185. ;* The following codes are specific to the Microsoft PS/2 mouse
  186. ;*
  187.  
  188. MCMD_MS_VERS    EQU     052h            ; Read current firmware version number
  189. MCMD_MS_INPORT  EQU     056h            ; Read raw InPort data
  190. MCDM_MS_DIAG    EQU     059h            ; enter MS diagnostices mode
  191. MCMD_MS_READRAM EQU     05Bh            ; read ram byte
  192.  
  193. PDI_MOUSE_ID    EQU     0               ; ID returned from mouse
  194. PDI_BALLPOINT_ID EQU    2               ; ID returned from Ballpoint
  195.  
  196.  
  197. ;****************************************************************
  198. ;*               8 0 4 2  D E F I N I T I O N S                 *
  199. ;****************************************************************
  200.  
  201. ;*
  202. ;* 8042 port definitions.
  203. ;*
  204.  
  205. DATA_8042       EQU     60h             ; Port where data is sent to/from 8042.
  206. CONTROL_8042    EQU     64h             ; Port where commands are sent to 8042.
  207. STATUS_8042     EQU     64h             ; Port where status is read from 8042.
  208.  
  209. ;*
  210. ;* Status register bit definitions.
  211. ;*
  212.  
  213. O_FULL          EQU     01h             ; 8042's output buffer is full.
  214. I_FULL          EQU     02h             ; 8042's input buffer is full.
  215. A_FULL          EQU     20h             ; 8042's aux output buffer is full.
  216.  
  217. ;*
  218. ;* Command byte bit definitions.
  219. ;*
  220.  
  221. AUX_DISABLED    EQU     20h             ; Auxiliary interface is disabled.
  222. AUX_INT_ENABLE  EQU     02h             ; Auxiliary interrupts are enabled.
  223.  
  224. ;*
  225. ;* 8042 commands.
  226. ;*
  227.  
  228. CMD8042_READ_CMD EQU    020h            ; Read command byte.
  229. CMD8042_WRITE_CMD EQU   060h            ; Write command byte.
  230. CMD8042_DISABLE_AUX EQU 0A7h            ; Disable auxiliary interface.
  231. CMD8042_ENABLE_AUX EQU  0A8h            ; Enable auxiliary interface.
  232. CMD8042_TEST_AUX EQU    0A9h            ; Test auxiliary interface.
  233. CMD8042_DISABLE_KBD EQU 0ADh            ; Disable keyboard.
  234. CMD8042_ENABLE_KBD EQU  0AEh            ; Enable keyboard.
  235. CMD8042_WRITE_AUX EQU   0D4h            ; Send data to auxiliary device.
  236.  
  237. ;************************************************************************
  238. ;*               8 2 5 9 A  D E F I N I T I O N S                       *
  239. ;************************************************************************
  240.  
  241. MASTER_MASK_ADDR EQU    021h            ; Master's mask register addr.
  242. SLAVE_MASK_ADDR EQU     0A1h            ; Slave's mask register addr.
  243. IRQS_PER_8259   EQU     8               ; # IRQs on each 8259A.
  244. SELECT_IRR      EQU     0Ah             ; Selects int request register.
  245. SELECT_ISR      EQU     0Bh             ; Selects in service register.
  246.  
  247. ;************************************************************************
  248. ;               S E R I A L     D E F I N I T I O N S                   *
  249. ;************************************************************************
  250.  
  251. MSS_PACKETSIZE          EQU     3       ; Bytes in a packet of data.
  252. BALLPOINT_PACKETSIZE    EQU     4       ; Bytes in a packet of data.
  253. SYNCBIT                 EQU     40H     ; Bit 6 is the sync bit
  254.  
  255. ;*
  256. ;*  Below are the offsets from the Port Base Address to the various
  257. ;*            Serial Port register addresses
  258. ;*
  259.  
  260. TXB              EQU          0     ; Transmit buffer
  261. RXB              EQU          0     ; Receive buffer
  262. LATLSB           EQU          0     ; Divisor latch least sig bits
  263. LATMSB           EQU          1     ; Divisor latch most sig bits
  264. IER              EQU          1     ; Interrupt enable register
  265. IIR              EQU          2     ; Interrupt indentification register
  266. FCR              EQU          2     ; FIFO Control Register
  267. LCR              EQU          3     ; Line control register
  268. MCR              EQU          4     ; Modem control register
  269. LSR              EQU          5     ; Line status register
  270. MSR              EQU          6     ; Modem status register
  271. SCR              EQU          7     ; Scratch register
  272.  
  273.  
  274. ;*
  275. ;* These give the number of milliseconds to wait while waiting for the serial
  276. ;*   mouse to reset itself. We will first use the value given by SHORTDELAY
  277. ;*   and if that fails, we will then use the value given by LONGDELAY.
  278. ;*
  279.  
  280. SHORTDELAY      EQU     350             ; 350  msecs
  281. LONGDELAY       EQU    1000             ; 1000 msecs
  282.  
  283. ;*
  284. ;* These are the values that are written into the divisor latch for the
  285. ;*       various baud rates. They are obtained by dividing the clock rate
  286. ;*       (1.8432 MHz) by 16x the desired baud rate.
  287. ;*
  288.  
  289. DIV_50          EQU     900h
  290. DIV_75          EQU     600h
  291. DIV_110         EQU     417h
  292. DIV_150         EQU     300h
  293. DIV_300         EQU     180h
  294. DIV_600         EQU     0C0h
  295. DIV_1200        EQU     060h
  296. DIV_1800        EQU     040h
  297. DIV_2000        EQU     03Ah
  298. DIV_2400        EQU     030h
  299. DIV_3600        EQU     020h
  300. DIV_4800        EQU     018h
  301. DIV_7200        EQU     010h
  302. DIV_9600        EQU     00Ch
  303.  
  304. ;*
  305. ;* Interrupt enable masks
  306. ;*
  307.  
  308. IE_RX           EQU     00000001b       ; read data available
  309. IE_TX           EQU     00000010b       ; transmit buffer empty
  310. IE_LX           EQU     00000100b       ; line status change
  311. IE_MX           EQU     00001000b       ; modem status change
  312.  
  313. IERMASK         EQU     00000001B       ; Interrupt Enable Register Mask
  314.  
  315. ;*
  316. ;* Interrupt identification masks
  317. ;*
  318.  
  319. II_PENDING      EQU     00000001b   ; Clear if interrupt pending.
  320. IIRMASK         EQU      0F8H       ; Interrupt ID Register permanent Mask bits
  321.  
  322. ;*
  323. ;* Line control masks
  324. ;*
  325.  
  326. LC_BMASK        EQU     00000011b       ; data bits mask
  327. LC_BITS5        EQU     00000000b       ; 5 data bits
  328. LC_BITS6        EQU     00000001b       ; 6 data bits
  329. LC_BITS7        EQU     00000010b       ; 7 data bits
  330. LC_BITS8        EQU     00000011b       ; 8 data bits
  331.  
  332. LC_SMASK        EQU     00000100b       ; stop bits mask
  333. LC_STOP1        EQU     00000000b       ; 1 stop bit
  334. LC_STOP2        EQU     00000100b       ; 2 stop bits (1.5 if 5 data bits)
  335.  
  336. LC_PMASK        EQU     00111000b       ; parity mask
  337. LC_PNONE        EQU     00000000b       ; none parity
  338. LC_PODD         EQU     00001000b       ; odd parity
  339. LC_PEVEN        EQU     00011000b       ; even parity
  340. LC_PMARK        EQU     00101000b       ; mark parity
  341. LC_PSPACE       EQU     00111000b       ; space parity
  342.  
  343. LC_BREAK        EQU     01000000b       ; transmit break
  344. LC_DLAB         EQU     10000000b       ; divisor latch access bit
  345. LC_MASK         EQU     01111111b       ; documented line control register bits
  346.  
  347. LCRMASK         EQU 00000010B  ; Line Control Reg Mask, 7 data bits 1 stop bit
  348.  
  349. ;*
  350. ;* Modem control register masks
  351. ;*
  352.  
  353. MC_DTR          EQU     00000001b       ; data terminal ready
  354. MC_RTS          EQU     00000010b       ; request to send
  355. MC_OUT1         EQU     00000100b       ; output 1
  356. MC_OUT2         EQU     00001000b       ; output 2
  357. MC_LOOP         EQU     00010000b       ; loopback mode
  358.  
  359. MCRMASK         EQU     00001011B       ; Modem Control Register Mask
  360.  
  361. ;*
  362. ;* Line status register masks
  363. ;*
  364.  
  365. LS_DR           EQU     00000001b       ; data ready
  366. LS_OERR         EQU     00000010b       ; overrun error
  367. LS_PERR         EQU     00000100b       ; parity error
  368. LS_FERR         EQU     00001000b       ; framing error
  369. LS_BI           EQU     00010000b       ; break interrupt
  370. LS_THRE         EQU     00100000b       ; TX holding register empty
  371. LS_TSRE         EQU     01000000b       ; TX shift register empty
  372.  
  373. ;*
  374. ;* Modem status register definitions:
  375. ;*
  376.  
  377. MS_DCTS         EQU     00000001b       ; delta clear to send
  378. MS_DDSR         EQU     00000010b       ; delta data set ready
  379. MS_TERI         EQU     00000100b       ; trailing edge of ring indicator
  380. MS_DDCD         EQU     00001000b       ; delta receiver line signal detect
  381. MS_CTS          EQU     00010000b       ; clear to send
  382. MS_DSR          EQU     00100000b       ; data set ready
  383. MS_RI           EQU     01000000b       ; ring indicator
  384. MS_DCD          EQU     10000000b       ; receiver line signal detect
  385.