home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v1.zip / DDKX86 / H / KBD.H < prev    next >
Text File  |  1995-04-14  |  9KB  |  183 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. /*static char *SCCSID = "@(#)kbd.h      6.1 90/11/15";*/
  14. /***    Keyboard Device Driver (KBD)
  15.  *
  16.  *      SCCSID = @(#)kbd.h       13.11 90/08/02
  17.  *
  18.  *      KBD public constants.
  19.  *
  20.  *      MODIFICATION HISTORY
  21.  *          01/30/89  MTS    Created.
  22.  */
  23.  
  24.  
  25. // Ports (for both PC/AT and PS/2)
  26.  
  27. #define PORT_BUFFER             0x60
  28. #define PORT_CMD                0x64
  29. #define PORT_STATUS             0x64
  30.  
  31. // Output states for PORT_BUFFER (ie, which virtual byte it's pointing to)
  32.  
  33. #define PORTBUFF_KBD            0       //normal condition
  34. #define PORTBUFF_COMMAND        1       //set by CMD_WRITECOMMAND
  35. #define PORTBUFF_OUTPUT         2       //set by CMD_WRITEOUTPUT
  36. #define PORTBUFF_KYBD_OUTPUT    3       //set by CMD_WRITE_KYBD_OUTPUT
  37.  
  38. // Values that can be written to PORT_CMD
  39.  
  40. #define CMD_READCOMMAND         0x20    //supported
  41. #define CMD_PS2_READMEMLO       0x21    //NOT SUPPORTED
  42. #define CMD_PS2_READMEMHI       0x3f    //NOT SUPPORTED
  43. #define CMD_WRITECOMMAND        0x60    //supported
  44. #define CMD_PS2_WRITEMEMLO      0x61    //NOT SUPPORTED
  45. #define CMD_PS2_WRITEMEMHI      0x7f    //NOT SUPPORTED
  46. #define CMD_PS2_TESTPW          0xa4    //NOT SUPPORTED
  47. #define CMD_PS2_LOADPW          0xa5    //NOT SUPPORTED
  48. #define CMD_PS2_ENABLEPW        0xa6    //NOT SUPPORTED
  49. #define CMD_AUXILIARYLO         0xa7    //NOT SUPPORTED
  50. #define CMD_AUXILIARYHI         0xa9    //NOT SUPPORTED
  51. #define CMD_SELFTEST            0xaa    //supported(always return SCAN_TESTDONE)
  52. #define CMD_INTERFACETEST       0xab    //supported (always return ZERO)
  53. #define CMD_DIAGNOSTICDUMP      0xac    //NOT SUPPORTED
  54. #define CMD_DISABLEKBD          0xad    //supported
  55. #define CMD_ENABLEKBD           0xae    //supported
  56. #define CMD_READINPUT           0xc0    //supported
  57. #define CMD_PS2_READINLO        0xc1    //NOT SUPPORTED
  58. #define CMD_PS2_READINHI        0xc2    //NOT SUPPORTED
  59. #define CMD_READOUTPUT          0xd0    //supported
  60. #define CMD_WRITEOUTPUT         0xd1    //supported
  61. #define CMD_WRITE_KYBD_OUTPUT   0xd2    //supported
  62. #define CMD_PS2_WRITEOUTLO      0xd3    //NOT SUPPORTED
  63. #define CMD_PS2_WRITEOUTHI      0xd4    //NOT SUPPORTED
  64. #define CMD_READTESTINPUT       0xe0    //supported
  65. #define CMD_PULSEOUTPUTLO       0xf0    //supported
  66. #define CMD_PULSEOUTPUTHI       0xff    //supported
  67.  
  68.  
  69. // Values that can be read from PORT_CMD (the Status byte)
  70.  
  71. #define STATUS_BUFFERFULL       0x01    //set when virtBuff is valid
  72. #define STATUS_CMDFULL          0x02    //always clear
  73. #define STATUS_SYSFLAG          0x04    //transferred from Command byte
  74. #define STATUS_DATAEXPECTED     0x08    //set after write to PORT_CMD
  75. #define STATUS_NOTINHIBITED     0x10    //keyboard is not inhibited (locked)
  76. #define STATUS_XMITTIMEOUT      0x20    //always clear
  77. #define STATUS_RECVTIMEOUT      0x40    //always clear
  78. #define STATUS_PARITYERROR      0x80    //always clear
  79.  
  80. // Values that can be written to PORT_BUFFER (when it's the Kbd byte)
  81.  
  82. #define KBD_SETLEDS             0xed    //supported (responds SCAN_ACK)
  83. #define KBD_ECHO                0xee    //supported (responds SCAN_ECHO)
  84. #define KBD_NEW_SETSCAN         0xf0    //NOT SUPPORTED
  85. #define KBD_REPORTID            0xf2    //supported (responds 1 or 2 ID bytes)
  86. #define KBD_SETREPEAT           0xf3    //supported (responds SCAN_ACK)
  87. #define KBD_ENABLE              0xf4    //supported (responds SCAN_ACK)
  88. #define KBD_DEFDISABLE          0xf5    //supported (responds SCAN_ACK)
  89. #define KBD_SETDEFAULT          0xf6    //supported (responds SCAN_ACK)
  90. #define KBD_NEW_REPT            0xf7    //ignored   (responds SCAN_ACK)
  91. #define KBD_NEW_MAKEBRK         0xf8    //ignored   (responds SCAN_ACK)
  92. #define KBD_NEW_MAKEONLY        0xf9    //ignored   (responds SCAN_ACK)
  93. #define KBD_NEW_REPTMAKEBRK     0xfa    //ignored   (responds SCAN_ACK)
  94. #define KBD_NEW_KEYREPT         0xfb    //ignored   (responds SCAN_ACK)
  95. #define KBD_NEW_KEYMAKEBRK      0xfc    //ignored   (responds SCAN_ACK)
  96. #define KBD_NEW_KEYMAKEONLY     0xfd    //ignored   (responds SCAN_ACK)
  97. #define KBD_RESEND              0xfe    //supported (responds w/last scan sent)
  98. #define KBD_RESET               0xff    //supported (responds SCAN_ACK ...)
  99. #define KBD_LOWEST              0xed    //lowest keyboard command code
  100. #define KBD_HIGHEST             0xff    //highest keyboard command code
  101.  
  102. // Bit masks for the parameter of KBD_SETREPEAT
  103.  
  104. #define REPEAT_RATEMASK         0x1f    //typematic rate
  105. #define REPEAT_DELAYMASK        0x60    //typematic delay
  106.  
  107. // Values returned by KBD_REPORTID
  108.  
  109. #define KBDID_ENHANCED1         0xab    //Common 1st ID byte for Enhanced.
  110. #define KBDID_ENHANCED2         0x41    //Various 2nd ID bytes returned for
  111. #define KBDID_ENHANCED2A        0x54    //  Enhanced keyboards.
  112. #define KBDID_ENHANCED2B        0x85
  113.  
  114. // Values that can be written to PORT_BUFFER (when it's the Command byte)
  115.  
  116. #define COMMAND_INTENABLE       0x01    //controls interrupt simulation
  117. #define COMMAND_SYSFLAG         0x04    //transferred to Status byte
  118. #define COMMAND_NOINHIBIT       0x08    //ignored (but retained in Command byte)
  119. #define COMMAND_DISABLEKBD      0x10    //disables further data
  120. #define COMMAND_PCMODE          0x20    //NOT SUPPORTED
  121. #define COMMAND_XLTMODE         0x40    //NOT SUPPORTED
  122.  
  123. // Values that can be read from PORT_BUFFER (when it's the Input byte)
  124.  
  125. #define INPUT_RESERVED          0x0f    //reserved bits
  126. #define INPUT_256K              0x10    //generally always set (>=512k)
  127. #define INPUT_NOJUMPER          0x20    //always set
  128. #define INPUT_MONO              0x40    //always clear
  129. #define INPUT_NOTINHIBITED      0x80    //set based on physical hardware
  130.  
  131. // Values that can be read/written via PORT_BUFFER (when it's the Output byte)
  132.  
  133. #define OUTPUT_CPURESET         0x01    //NOT SUPPORTED
  134. #define OUTPUT_A20              0x02    //state depends on VDMM A20 flag
  135. #define OUTPUT_RESERVED         0x0c    //reserved bits
  136. #define OUTPUT_BUFFERFULL       0x10    //forces STATUS_BUFFERFULL to go high
  137. #define OUTPUT_CMDEMPTY         0x20    //forces STATUS_CMDFULL to inverse
  138. #define OUTPUT_KBDDATA          0x40    //keyboard data (output)
  139. #define OUTPUT_KBDCLOCK         0x80    //keyboard clock (output)
  140.  
  141. // Bit masks of test inputs
  142.  
  143. #define TESTINPUT_T0            0x01
  144. #define TESTINPUT_T1            0x02
  145.  
  146. // LED state codes
  147.  
  148. #define LED_SCROLLLOCK          0x01    //set Scroll lock indicator on
  149. #define LED_NUMLOCK             0x02    //set Num lock indicator on
  150. #define LED_CAPSLOCK            0x04    //set Cap lock indicator on
  151. #define LED_ALL                 (LED_SCROLLLOCK + LED_NUMLOCK + LED_CAPSLOCK)
  152.  
  153. // Common scan codes
  154.  
  155. #define SCAN_TESTDONE           0x55    //???reply scan code after kbd test
  156. #define SCAN_BATCOMPLETE        0xaa    //reply scan code after BAT
  157. #define SCAN_HIGHESTKEY         0xe1    //highest that isn't treated specially
  158. #define SCAN_E0PREFIX           0xe0    //send as a prefix to some extended keys
  159. #define SCAN_E1PREFIX           0xe1    //send as a prefix to some extended keys
  160. #define SCAN_ECHO               0xee    //reply scan code of an ECHO command
  161. #define SCAN_ACK                0xfa    //send to acknowledge kbd commands
  162. #define SCAN_BATFAIL            0xfc    //send if BAT failed (not use in VDD)
  163. #define SCAN_RESEND             0xfe    //send resend req. if input was invalid
  164. #define SCAN_OVERRUN            0xff    //send when exceed buffer capacity
  165. #define SCAN_BREAKMASK          0x80    //key break mask of scan code
  166.  
  167. // Interface Test result codes
  168.  
  169. #define IFTEST_NOERROR          0x00    //no error detected
  170. #define IFTEST_CLOCKLOW         0x01    //keyboard clock line is stuck low
  171. #define IFTEST_CLOCKHIGH        0x02    //keyboard clock line is stuck high
  172. #define IFTEST_DATALOW          0x03    //keyboard data line is stuck low
  173. #define IFTEST_DATAHIGH         0x04    //keyboard data line is stuck high
  174.  
  175. // Miscellaneous constants
  176.  
  177. #define KBD_IRQ                 1       //keyboard IRQ number
  178. #define KBDBEEP_FREQ            1000    //keyboard beep frequency in Hz
  179. #define KBDBEEP_DURATION        13      //keyboard beep duration in ms
  180. #define KBDID_UNKNOWN           0x0000
  181. #define KBDID_PCAT              0x0100
  182. #define KBDID_ENHANCED          0x41ab
  183.