The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/i386ps2/kdabios.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* 
    2  * Mach Operating System
    3  * Copyright (c) 1991 Carnegie Mellon University
    4  * Copyright (c) 1991 IBM Corporation 
    5  * All Rights Reserved.
    6  * 
    7  * Permission to use, copy, modify and distribute this software and its
    8  * documentation is hereby granted, provided that both the copyright
    9  * notice and this permission notice appear in all copies of the
   10  * software, derivative works or modified versions, and any portions
   11  * thereof, and that both notices appear in supporting documentation,
   12  * and that the name IBM not be used in advertising or publicity 
   13  * pertaining to distribution of the software without specific, written
   14  * prior permission.
   15  * 
   16  * CARNEGIE MELLON AND IBM ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS IS"
   17  * CONDITION.  CARNEGIE MELLON AND IBM DISCLAIM ANY LIABILITY OF ANY KIND FOR
   18  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   19  * 
   20  * Carnegie Mellon requests users of this software to return to
   21  * 
   22  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   23  *  School of Computer Science
   24  *  Carnegie Mellon University
   25  *  Pittsburgh PA 15213-3890
   26  * 
   27  * any improvements or extensions that they make and grant Carnegie Mellon
   28  * the rights to redistribute these changes.
   29  */
   30 
   31 /*
   32  * HISTORY
   33  * $Log:        kdabios.h,v $
   34  * Revision 2.3  93/03/11  14:09:33  danner
   35  *      u_long -> u_int
   36  *      [93/03/09            danner]
   37  * 
   38  *      [93/03/09            danner]
   39  * 
   40  * Revision 2.2  93/02/04  08:01:15  danner
   41  *      Integrate PS2 code from IBM.
   42  *      [93/01/18            prithvi]
   43  * 
   44  */
   45 
   46 #ifndef _H_KTSABIOS
   47 #define _H_KTSABIOS
   48 /*
   49  * COMPONENT_NAME: SYSX/HFTSS/KTSM Keyboard Device Driver ktsabios.h
   50  *
   51  * FUNCTIONS:
   52  *
   53  * ORIGINS: 27
   54  */                                                                   
   55 
   56 /*
   57  * Few words on coding style: ---------------------------------
   58  *
   59  * set tabstop=8
   60  *
   61  */
   62 
   63 /*
   64  * This structure is good for most of the kbd requests, most info
   65  * between kbd and abios are passed in bytes 0x14 and 0x15.
   66  *
   67  * The time_to_wait before resuming request is in microseconds.
   68  * It is valid only if rc = 0x0002 = ABIOS_STAGE_ON_TIME.
   69  */
   70 struct Keyboard_params {
   71         u_int   time_to_wait;           /* 0x10, OUT */
   72         u_char  byte_1;                 /* 0x14, IN/OUT */
   73         u_char  byte_2;                 /* 0x15, IN/OUT */
   74 };
   75 
   76 /*
   77  * Set up kbd ABIOS request block, assuming request block length
   78  * of KBD_REQUEST_BLOCK_LEN+0x10 bytes.  This should be sufficient.
   79  * The real value can be found by issuing ABIOS_LOGICAL_PARAMETER
   80  * function.
   81  *
   82  * The last time I check, kbd rb len should be 49 bytes.
   83  */
   84 #define KBD_REQUEST_BLOCK_LEN           64
   85 struct Kbd_request {
   86         struct Request_header   request_header; /* 0x00-0x0f abios.h */
   87         union {
   88                 struct Logical_id_params        logical_id_params;
   89                 struct Keyboard_params          keyboard_params;
   90                 u_char                          uc[KBD_REQUEST_BLOCK_LEN];
   91         } un;
   92         int     state;
   93         int     sleep_on_intr;  /* sleep waiting for interrupt */
   94 };
   95 #define KBD_RB_IDLE             0               /* don't use BIT0 */
   96 #define KBD_RB_STARTED          BIT0
   97 #define KBD_RB_STAGING          BIT1
   98 #define KBD_RB_SLEEPING         BIT2
   99 
  100 /*
  101  * We need at least 2 abios request blocks for keyboard:
  102  * kreq[0] for continuous read request (read the keystrokes)
  103  * kreq[1] for single-staged or discrete multi-staged request
  104  *      (reset, set caps lock led, set typematic rate, ... etc)
  105  */
  106 extern struct Kbd_request kreq[2];
  107 
  108 /*
  109  * ABIOS keyboard specific function codes.
  110  */
  111 #define ABIOS_KBD_READ_LEDS             0x0b
  112 #define ABIOS_KBD_SET_LEDS              0x0c
  113 #define ABIOS_KBD_SET_TYPEMATIC         0x0d
  114 #define ABIOS_KBD_READ_SC_MODE          0x0e
  115 #define ABIOS_KBD_SET_SC_MODE           0x0f
  116 #define ABIOS_KBD_CMD_CTRLR             0x10
  117 #define ABIOS_KBD_CMD_KBD               0x11
  118 
  119 /*
  120  * ABIOS keyboard specific return codes.
  121  */
  122 #define ABIOS_KBD_RC_KEY_AVAIL          (ABIOS_ATTENTION | ABIOS_STAGE_ON_INT)
  123 #define ABIOS_KBD_RC_BUSY               0x8000
  124 #define ABIOS_KBD_RC_RESET_FAILED       0x9001
  125 #define ABIOS_KBD_RC_WATCHDOG_TIMEOUT   0xfffe
  126 
  127 /*
  128  * For ABIOS_LOGICAL_PARAMETER (0x01)
  129  * rc = 0 only.  NO interrupt.
  130  */
  131 /* IN */
  132 #define KBD_SET_RESERVED_ABIOS_LOGICAL_PARAMETER(rb) \
  133         { \
  134         *((u_short *)&(rb).un.uc[0x0a]) = 0; \
  135         *((u_short *)&(rb).un.uc[0x0c]) = 0; \
  136         *((u_short *)&(rb).un.uc[0x0e]) = 0; \
  137         }
  138 /* OUT */
  139 /* define in abios.h */
  140 
  141 /*
  142  * For ABIOS_READ_PARAMETER (0x03) function.
  143  * This function returns the keyboard id.
  144  */
  145 /* IN */
  146 #define KBD_SET_RESERVED_ABIOS_READ_PARAMETER(rb) \
  147                                         KBD_SET_RESERVED_ABIOS_RESET(rb)
  148 /* OUT */
  149 #define KBD_TIME_TO_WAIT(rb)            (rb).un.keyboard_params.time_to_wait
  150 #define KBD_ID_BYTE_1(rb)               (rb).un.keyboard_params.byte_1
  151 #define KBD_ID_BYTE_2(rb)               (rb).un.keyboard_params.byte_2
  152 #define KBD_ID_SHORT(rb)                *((u_short *)&(rb).un.uc[0x04])
  153 
  154 /*
  155  * For ABIOS_RESET (0x05)
  156  * For ABIOS_ENABLE_INTR (0x06)
  157  * For ABIOS_DISABLE_INTR (0x07)
  158  */
  159 /* IN */
  160 #define KBD_SET_RESERVED_ABIOS_RESET(rb) \
  161         { \
  162         *((u_short *)&(rb).un.uc[0x06]) = 0; \
  163         }
  164 #define KBD_SET_RESERVED_ABIOS_ENABLE_INTR(rb) \
  165                                         KBD_SET_RESERVED_ABIOS_RESET(rb)
  166 #define KBD_SET_RESERVED_ABIOS_DISABLE_INTR(rb) \
  167                                         KBD_SET_RESERVED_ABIOS_RESET(rb)
  168 /* OUT */
  169 /* none */
  170 
  171 /*
  172  * For ABIOS_READ (0x08)
  173  */
  174 /* IN */
  175 #define KBD_SET_RESERVED_ABIOS_READ(rb) \
  176                                         KBD_SET_RESERVED_ABIOS_RESET(rb)
  177 /* OUT */
  178 #define KBD_SCAN_CODE(rb)               (rb).un.keyboard_params.byte_1
  179 
  180 /*
  181  * For ABIOS_KBD_READ_LEDS (0x0b)
  182  * For ABIOS_KBD_SET_LEDS (0x0c)
  183  */
  184 /* IN */
  185 #define KBD_SET_RESERVED_ABIOS_KBD_READ_LEDS(rb) \
  186                                         KBD_SET_RESERVED_ABIOS_RESET(rb)
  187 #define KBD_SET_RESERVED_ABIOS_KBD_SET_LEDS(rb) \
  188                                         KBD_SET_RESERVED_ABIOS_RESET(rb)
  189 /* IN/OUT */
  190 #define KBD_LEDS(rb)                    (rb).un.keyboard_params.byte_1
  191 #define KBD_LED_SCROLL                  BIT0
  192 #define KBD_LED_NUM                     BIT1
  193 #define KBD_LED_CAPS                    BIT2
  194 
  195 /*
  196  * For ABIOS_KBD_SET_TYPEMATIC (0x0d)
  197  */
  198 /* IN */
  199 #define KBD_SET_RESERVED_ABIOS_KBD_SET_TYPEMATIC(rb) \
  200                                         KBD_SET_RESERVED_ABIOS_RESET(rb)
  201 #define KBD_TYPEMATIC_RATE(rb)          (rb).un.keyboard_params.byte_1
  202 #define KBD_T_RATE_30_CPS               0       /* 30.0 char per second */
  203 #define KBD_T_RATE_27_CPS               1       /* 26.7 CPS */
  204 #define KBD_T_RATE_24_CPS               2       /* 24.0 CPS */
  205 #define KBD_T_RATE_22_CPS               3       /* 21.8 CPS */
  206 #define KBD_T_RATE_20_CPS               4       /* 20.0 CPS */
  207 #define KBD_T_RATE_19_CPS               5       /* 18.5 CPS */
  208 #define KBD_T_RATE_17_CPS               6       /* 17.1 CPS */
  209 #define KBD_T_RATE_16_CPS               7       /* 16.0 CPS */
  210 #define KBD_T_RATE_15_CPS               8       /* 15.0 CPS */
  211 #define KBD_T_RATE_13_CPS               9       /* 13.3 CPS */
  212 #define KBD_T_RATE_12_CPS               10      /* 12.0 CPS */
  213 #define KBD_T_RATE_11_CPS               11      /* 10.9 CPS */
  214 #define KBD_T_RATE_10_CPS               12      /* 10.0 CPS */
  215 #define KBD_T_RATE_9_CPS                13      /* 9.2 CPS, 14 = 8.6 CPS */
  216 #define KBD_T_RATE_8_CPS                15      /* 8.0 CPS, 16 = 7.5 CPS */
  217 #define KBD_T_RATE_7_CPS                17      /* 6.7 CPS */
  218 #define KBD_T_RATE_6_CPS                18      /* 6.0 CPS, 19 = 5.5 CPS */
  219 #define KBD_T_RATE_5_CPS                20      /* 5.0 CPS, 21=4.6, 22=4.3 */
  220 #define KBD_T_RATE_4_CPS                23      /* 4.0 CPS, 24=3.7, 25=3.3 */
  221 #define KBD_T_RATE_3_CPS                26      /* 3.0 CPS, 27=2.7, 28=2.5 */
  222 #define KBD_T_RATE_2_CPS                31      /* 2.0 CPS, 29=2.3, 30=2.1 */
  223 #define KBD_T_RATE_DEFAULT              KBD_T_RATE_11_CPS
  224 #define KBD_T_RATE_FAST                 KBD_T_RATE_20_CPS
  225 #define KBD_T_RATE_MEDIUM               KBD_T_RATE_10_CPS
  226 #define KBD_T_RATE_SLOW                 KBD_T_RATE_5_CPS
  227 #define KBD_TYPEMATIC_DELAY(rb)         (rb).un.keyboard_params.byte_2
  228 #define KBD_T_DELAY_250_MSEC            0
  229 #define KBD_T_DELAY_500_MSEC            1
  230 #define KBD_T_DELAY_750_MSEC            2
  231 #define KBD_T_DELAY_1000_MSEC           3
  232 /* OUT */
  233 /* none */
  234 
  235 /*
  236  * For ABIOS_KBD_READ_SC_MODE (0x0e)
  237  * For ABIOS_KBD_SET_SC_MODE (0x0f)
  238  */
  239 /* IN */
  240 #define KBD_SET_RESERVED_ABIOS_KBD_READ_SC_MODE(rb) \
  241                                         KBD_SET_RESERVED_ABIOS_RESET(rb)
  242 #define KBD_SET_RESERVED_ABIOS_KBD_SET_SC_MODE(rb) \
  243                                         KBD_SET_RESERVED_ABIOS_RESET(rb)
  244 /* IN/OUT */
  245 #define KBD_SC_MODE(rb)                 (rb).un.keyboard_params.byte_1
  246 #define KBD_SC_MODE_1                   1
  247 #define KBD_SC_MODE_2                   2
  248 #define KBD_SC_MODE_3                   3
  249 
  250 /*
  251  * For ABIOS_KBD_CMD_CTRLR (0x10)
  252  * For ABIOS_KBD_CMD_KBD (0x11)
  253  */
  254 /* IN */
  255 #define KBD_SET_RESERVED_ABIOS_KBD_CMD_CTRLR(rb) \
  256         { \
  257         *((u_short *)&(rb).un.uc[0x04]) = 0; \
  258         *((u_short *)&(rb).un.uc[0x18]) = 0; \
  259         }
  260 #define KBD_SET_RESERVED_ABIOS_KBD_CMD_KBD(rb) \
  261                                 KBD_SET_RESERVED_ABIOS_KBD_CMD_CTRLR(rb)
  262 #define KBD_CMD_PTR(rb)                 *((u_int *)&(rb).un.uc[0x06])
  263 #define KBD_CMD_COUNT(rb)               ((rb).un.uc[0x0c])
  264 #define KBD_ALL_KEY_T                   0xf7
  265 #define KBD_ALL_KEY_M_B                 0xf8
  266 #define KBD_ALL_KEY_M                   0xf9
  267 #define KBD_ALL_KEY_T_M_B               0xfa
  268 #define KBD_ONE_KEY_T                   0xfb
  269 #define KBD_ONE_KEY_M_B                 0xfc
  270 #define KBD_ONE_KEY_M                   0xfd
  271 
  272 struct Kbd_abios_data {
  273         int             rb_inited;      /* kreq[0], kreq[1] inited? */
  274         int             kbd_inited;     /* sc3?, t/m/b? ...etc */
  275         int             installed;      /* keyboard is present */
  276         int             num_rb;         /* number of request blocks */
  277         u_int           bad_intr_count; /* count spurious intr fr kbd */
  278         u_short         lid;            /* abios logical id for kbd */
  279         u_short         lid_flags;      /* until abios32 */
  280         u_char          sc;
  281 };
  282 extern struct Kbd_abios_data kbd_abios_data;
  283 
  284 /*
  285  * Work ...
  286  * temporary define's, need to find out what
  287  * the real keyboard ids for 102 & 106 keyboards.
  288  */
  289 #define KBD_TYPE_NONE   0               /* no key board */
  290 #define KBD_TYPE_101    0x83ab          /* U.S. keyboard */
  291 #define KBD_TYPE_102    2               /* World Trade keyboard, 2 for now */
  292 #define KBD_TYPE_106    3               /* Japanese keyboard, 3 for now */
  293 
  294 /* Keys needed for the low level keyboard control.
  295 ** This is scan code set 3.
  296 */
  297 #define SC_KEYUP        0xf0
  298 #define SC_LCTL         0x11
  299 #define SC_LSFT         0x12
  300 #define SC_CAPS         0x14
  301 #define SC_LALT         0x19
  302 #define SC_RALT         0x39
  303 #define SC_RCTL         0x58
  304 #define SC_RSFT         0x59
  305 #define SC_PAD4         0x6b
  306 #define SC_PDEL         0x71
  307 
  308 /*
  309  * For SC3 to SC1 conversion 
  310  */
  311 #define K_UP_SC3        0xf0
  312 #define K_CTLSC3L       0x11
  313 #define K_CTLSC3R       0x58
  314 #define K_CTLSC3        K_CTLSC3L
  315 #define K_ALTSC3L       0x19
  316 #define K_ALTSC3R       0x39
  317 #define K_ALTSC3        K_ALTSC3L
  318 #define K_pad4SC3       0x6b
  319 #define K_DELSC3        0x71
  320 
  321 extern unsigned char tbl_sc3to1[];
  322 #define SC3_TO_SC1(sc3) (tbl_sc3to1[sc3])
  323 
  324 extern int kddebug;
  325 #define KDDEBUG_VERBOSE BIT16   /* I'm here, I'm there, blah, blah, blah ... */
  326 #define KDDEBUG_TERSE   BIT29           /* debug scancode <==> char */
  327 #define KDDEBUG_INFO    BIT30           /* useful msgs */
  328 
  329 #define RC_GOOD         0
  330 #define RC_BAD          -1
  331 
  332 #endif /* _H_KTSABIOS */

Cache object: 9b9c8d3bbddeb879b61153997d6cbbbd


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.