Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:41

0001 /**
0002  * @file
0003  *
0004  * @ingroup RTEMSBSPsI386
0005  *
0006  * @brief Keyboard and mouse definitions.
0007  */
0008 
0009 /*
0010  *  include/linux/pc_keyb.h
0011  *  PC Keyboard And Keyboard Controller
0012  *  (c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
0013  *
0014  * RTEMS port: by Rosimildo da Silva.
0015  *
0016  * This module was ported from Linux.
0017  *
0018  */
0019 
0020 /*
0021  *  Configuration Switches
0022  */
0023 
0024 #undef KBD_REPORT_ERR           /* Report keyboard errors */
0025 #define KBD_REPORT_UNKN         /* Report unknown scan codes */
0026 #define KBD_REPORT_TIMEOUTS     /* Report keyboard timeouts */
0027 #undef KBD_IS_FOCUS_9000        /* We have the brain-damaged FOCUS-9000 keyboard */
0028 #undef INITIALIZE_MOUSE         /* Define if your PS/2 mouse needs initialization. */
0029 
0030 #define KBD_INIT_TIMEOUT 1000       /* Timeout in ms for initializing the keyboard */
0031 #define KBC_TIMEOUT 250         /* Timeout in ms for sending to keyboard controller */
0032 #define KBD_TIMEOUT 1000        /* Timeout in ms for keyboard command acknowledge */
0033 
0034 /*
0035  *  Internal variables of the driver
0036  */
0037 
0038 extern unsigned char pckbd_read_mask;
0039 extern unsigned char aux_device_present;
0040 
0041 /*
0042  *  Keyboard Controller Registers on normal PCs.
0043  */
0044 
0045 #define KBD_STATUS_REG      0x64    /* Status register (R) */
0046 #define KBD_CNTL_REG        0x64    /* Controller command register (W) */
0047 #define KBD_DATA_REG        0x60    /* Keyboard data register (R/W) */
0048 
0049 /*
0050  *  Keyboard Controller Commands
0051  */
0052 
0053 #define KBD_CCMD_READ_MODE  0x20    /* Read mode bits */
0054 #define KBD_CCMD_WRITE_MODE 0x60    /* Write mode bits */
0055 #define KBD_CCMD_GET_VERSION    0xA1    /* Get controller version */
0056 #define KBD_CCMD_MOUSE_DISABLE  0xA7    /* Disable mouse interface */
0057 #define KBD_CCMD_MOUSE_ENABLE   0xA8    /* Enable mouse interface */
0058 #define KBD_CCMD_TEST_MOUSE 0xA9    /* Mouse interface test */
0059 #define KBD_CCMD_SELF_TEST  0xAA    /* Controller self test */
0060 #define KBD_CCMD_KBD_TEST   0xAB    /* Keyboard interface test */
0061 #define KBD_CCMD_KBD_DISABLE    0xAD    /* Keyboard interface disable */
0062 #define KBD_CCMD_KBD_ENABLE 0xAE    /* Keyboard interface enable */
0063 #define KBD_CCMD_WRITE_AUX_OBUF 0xD3    /* Write to output buffer as if
0064                        initiated by the auxiliary device */
0065 #define KBD_CCMD_WRITE_MOUSE    0xD4    /* Write the following byte to the mouse */
0066 
0067 /*
0068  *  Keyboard Commands
0069  */
0070 
0071 #define KBD_CMD_SET_LEDS    0xED    /* Set keyboard leds */
0072 #define KBD_CMD_SET_RATE    0xF3    /* Set typematic rate */
0073 #define KBD_CMD_ENABLE      0xF4    /* Enable scanning */
0074 #define KBD_CMD_DISABLE     0xF5    /* Disable scanning */
0075 #define KBD_CMD_RESET       0xFF    /* Reset */
0076 
0077 /*
0078  *  Keyboard Replies
0079  */
0080 
0081 #define KBD_REPLY_POR       0xAA    /* Power on reset */
0082 #define KBD_REPLY_ACK       0xFA    /* Command ACK */
0083 #define KBD_REPLY_RESEND    0xFE    /* Command NACK, send the cmd again */
0084 
0085 /*
0086  *  Status Register Bits
0087  */
0088 
0089 #define KBD_STAT_OBF        0x01    /* Keyboard output buffer full */
0090 #define KBD_STAT_IBF        0x02    /* Keyboard input buffer full */
0091 #define KBD_STAT_SELFTEST   0x04    /* Self test successful */
0092 #define KBD_STAT_CMD        0x08    /* Last write was a command write (0=data) */
0093 #define KBD_STAT_UNLOCKED   0x10    /* Zero if keyboard locked */
0094 #define KBD_STAT_MOUSE_OBF  0x20    /* Mouse output buffer full */
0095 #define KBD_STAT_GTO        0x40    /* General receive/xmit timeout */
0096 #define KBD_STAT_PERR       0x80    /* Parity error */
0097 
0098 #define AUX_STAT_OBF (KBD_STAT_OBF | KBD_STAT_MOUSE_OBF)
0099 
0100 /*
0101  *  Controller Mode Register Bits
0102  */
0103 
0104 #define KBD_MODE_KBD_INT    0x01    /* Keyboard data generate IRQ1 */
0105 #define KBD_MODE_MOUSE_INT  0x02    /* Mouse data generate IRQ12 */
0106 #define KBD_MODE_SYS        0x04    /* The system flag (?) */
0107 #define KBD_MODE_NO_KEYLOCK 0x08    /* The keylock doesn't affect the keyboard if set */
0108 #define KBD_MODE_DISABLE_KBD    0x10    /* Disable keyboard interface */
0109 #define KBD_MODE_DISABLE_MOUSE  0x20    /* Disable mouse interface */
0110 #define KBD_MODE_KCC        0x40    /* Scan code conversion to PC format */
0111 #define KBD_MODE_RFU        0x80
0112 
0113 /*
0114  *  Mouse Commands
0115  */
0116 
0117 #define AUX_SET_RES     0xE8    /* Set resolution */
0118 #define AUX_SET_SCALE11     0xE6    /* Set 1:1 scaling */
0119 #define AUX_SET_SCALE21     0xE7    /* Set 2:1 scaling */
0120 #define AUX_GET_SCALE       0xE9    /* Get scaling factor */
0121 #define AUX_SET_STREAM      0xEA    /* Set stream mode */
0122 #define AUX_SET_SAMPLE      0xF3    /* Set sample rate */
0123 #define AUX_ENABLE_DEV      0xF4    /* Enable aux device */
0124 #define AUX_DISABLE_DEV     0xF5    /* Disable aux device */
0125 #define AUX_RESET       0xFF    /* Reset aux device */
0126 #define AUX_ACK         0xFA    /* Command byte ACK. */
0127 
0128 #define AUX_BUF_SIZE        512 /* This might be better divisible by
0129                        three to make overruns stay in sync
0130                        but then the read function would need
0131                        a lock etc - ick */
0132 
0133 struct aux_queue {
0134     unsigned long head;
0135     unsigned long tail;
0136     struct wait_queue *proc_list;
0137     struct fasync_struct *fasync;
0138     unsigned char buf[AUX_BUF_SIZE];
0139 };
0140 
0141 /* How to access the keyboard macros on this platform.  */
0142 #define kbd_read_input() inb(KBD_DATA_REG)
0143 #define kbd_read_status() inb(KBD_STATUS_REG)
0144 #define kbd_write_output(val) outb(val, KBD_DATA_REG)
0145 #define kbd_write_command(val) outb(val, KBD_CNTL_REG)
0146 
0147 /*
0148  * Machine specific bits for the PS/2 driver
0149  */
0150 
0151 #define AUX_IRQ 12