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/dev/atkbdc/atkbdcreg.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  * SPDX-License-Identifier: BSD-3-Clause
    3  *
    4  * Copyright (c) 1996-1999
    5  * Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
    6  * All rights reserved.
    7  *
    8  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
   10  * are met:
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  * 3. The name of the author may not be used to endorse or promote 
   17  *    products derived from this software without specific prior written 
   18  *    permission.
   19  *
   20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   30  * SUCH DAMAGE.
   31  *
   32  * $FreeBSD$
   33  * from kbdio.h,v 1.8 1998/09/25 11:55:46 yokota Exp
   34  */
   35 
   36 #ifndef _DEV_ATKBDC_ATKBDCREG_H_
   37 #define _DEV_ATKBDC_ATKBDCREG_H_
   38 
   39 #include "opt_kbd.h"    /* Structures depend on the value if KBDIO_DEBUG */
   40 
   41 /* constants */
   42 
   43 /* I/O ports */
   44 #define KBD_STATUS_PORT         4       /* status port, read */
   45 #define KBD_COMMAND_PORT        4       /* controller command port, write */
   46 #define KBD_DATA_PORT           0       /* data port, read/write 
   47                                          * also used as keyboard command
   48                                          * and mouse command port 
   49                                          */
   50 
   51 /* controller commands (sent to KBD_COMMAND_PORT) */
   52 #define KBDC_SET_COMMAND_BYTE   0x0060
   53 #define KBDC_GET_COMMAND_BYTE   0x0020
   54 #define KBDC_WRITE_TO_AUX_MUX   0x0090
   55 #define KBDC_FORCE_AUX_OUTPUT   0x00d3
   56 #define KBDC_WRITE_TO_AUX       0x00d4
   57 #define KBDC_DISABLE_AUX_PORT   0x00a7
   58 #define KBDC_ENABLE_AUX_PORT    0x00a8
   59 #define KBDC_TEST_AUX_PORT      0x00a9
   60 #define KBDC_DIAGNOSE           0x00aa
   61 #define KBDC_TEST_KBD_PORT      0x00ab
   62 #define KBDC_DISABLE_KBD_PORT   0x00ad
   63 #define KBDC_ENABLE_KBD_PORT    0x00ae
   64 
   65 /* controller command byte (set by KBDC_SET_COMMAND_BYTE) */
   66 #define KBD_TRANSLATION         0x0040
   67 #define KBD_RESERVED_BITS       0x0004
   68 #define KBD_OVERRIDE_KBD_LOCK   0x0008
   69 #define KBD_ENABLE_KBD_PORT     0x0000
   70 #define KBD_DISABLE_KBD_PORT    0x0010
   71 #define KBD_ENABLE_AUX_PORT     0x0000
   72 #define KBD_DISABLE_AUX_PORT    0x0020
   73 #define KBD_ENABLE_AUX_INT      0x0002
   74 #define KBD_DISABLE_AUX_INT     0x0000
   75 #define KBD_ENABLE_KBD_INT      0x0001
   76 #define KBD_DISABLE_KBD_INT     0x0000
   77 #define KBD_KBD_CONTROL_BITS    (KBD_DISABLE_KBD_PORT | KBD_ENABLE_KBD_INT)
   78 #define KBD_AUX_CONTROL_BITS    (KBD_DISABLE_AUX_PORT | KBD_ENABLE_AUX_INT)
   79 
   80 /* keyboard device commands (sent to KBD_DATA_PORT) */
   81 #define KBDC_RESET_KBD          0x00ff
   82 #define KBDC_ENABLE_KBD         0x00f4
   83 #define KBDC_DISABLE_KBD        0x00f5
   84 #define KBDC_SET_DEFAULTS       0x00f6
   85 #define KBDC_SEND_DEV_ID        0x00f2
   86 #define KBDC_SET_LEDS           0x00ed
   87 #define KBDC_ECHO               0x00ee
   88 #define KBDC_SET_SCANCODE_SET   0x00f0
   89 #define KBDC_SET_TYPEMATIC      0x00f3
   90 
   91 /* aux device commands (sent to KBD_DATA_PORT) */
   92 #define PSMC_RESET_DEV          0x00ff
   93 #define PSMC_ENABLE_DEV         0x00f4
   94 #define PSMC_DISABLE_DEV        0x00f5
   95 #define PSMC_SET_DEFAULTS       0x00f6
   96 #define PSMC_SEND_DEV_ID        0x00f2
   97 #define PSMC_SEND_DEV_STATUS    0x00e9
   98 #define PSMC_SEND_DEV_DATA      0x00eb
   99 #define PSMC_SET_SCALING11      0x00e6
  100 #define PSMC_SET_SCALING21      0x00e7
  101 #define PSMC_SET_RESOLUTION     0x00e8
  102 #define PSMC_SET_STREAM_MODE    0x00ea
  103 #define PSMC_SET_REMOTE_MODE    0x00f0
  104 #define PSMC_SET_SAMPLING_RATE  0x00f3
  105 
  106 /* PSMC_SET_RESOLUTION argument */
  107 #define PSMD_RES_LOW            0       /* typically 25ppi */
  108 #define PSMD_RES_MEDIUM_LOW     1       /* typically 50ppi */
  109 #define PSMD_RES_MEDIUM_HIGH    2       /* typically 100ppi (default) */
  110 #define PSMD_RES_HIGH           3       /* typically 200ppi */
  111 #define PSMD_MAX_RESOLUTION     PSMD_RES_HIGH
  112 
  113 /* PSMC_SET_SAMPLING_RATE */
  114 #define PSMD_MAX_RATE           255     /* FIXME: not sure if it's possible */
  115 
  116 /* status bits (KBD_STATUS_PORT) */
  117 #define KBDS_BUFFER_FULL        0x0021
  118 #define KBDS_ANY_BUFFER_FULL    0x0001
  119 #define KBDS_KBD_BUFFER_FULL    0x0001
  120 #define KBDS_AUX_BUFFER_FULL    0x0021
  121 #define KBDS_INPUT_BUFFER_FULL  0x0002
  122 
  123 /* return code */
  124 #define KBD_ACK                 0x00fa
  125 #define KBD_RESEND              0x00fe
  126 #define KBD_RESET_DONE          0x00aa
  127 #define KBD_RESET_FAIL          0x00fc
  128 #define KBD_DIAG_DONE           0x0055
  129 #define KBD_DIAG_FAIL           0x00fd
  130 #define KBD_ECHO                0x00ee
  131 
  132 #define PSM_ACK                 0x00fa
  133 #define PSM_RESEND              0x00fe
  134 #define PSM_RESET_DONE          0x00aa
  135 #define PSM_RESET_FAIL          0x00fc
  136 
  137 /* aux device ID */
  138 #define PSM_MOUSE_ID            0
  139 #define PSM_BALLPOINT_ID        2
  140 #define PSM_INTELLI_ID          3
  141 #define PSM_EXPLORER_ID         4
  142 #define PSM_4DMOUSE_ID          6
  143 #define PSM_4DPLUS_ID           8
  144 #define PSM_4DPLUS_RFSW35_ID    24
  145 
  146 #ifdef _KERNEL
  147 
  148 #define ATKBDC_DRIVER_NAME      "atkbdc"
  149 
  150 /* 
  151  * driver specific options: the following options may be set by
  152  * `options' statements in the kernel configuration file. 
  153  */
  154 
  155 /* retry count */
  156 #ifndef KBD_MAXRETRY
  157 #define KBD_MAXRETRY    3
  158 #endif
  159 
  160 /* timing parameters */
  161 #ifndef KBD_RESETDELAY
  162 #define KBD_RESETDELAY  200     /* wait 200msec after kbd/mouse reset */
  163 #endif
  164 #ifndef KBD_MAXWAIT
  165 #define KBD_MAXWAIT     5       /* wait 5 times at most after reset */
  166 #endif
  167 
  168 /* I/O recovery time */
  169 #define KBDC_DELAYTIME  20
  170 #define KBDD_DELAYTIME  7
  171 
  172 /* debug option */
  173 #ifndef KBDIO_DEBUG
  174 #define KBDIO_DEBUG     0
  175 #endif
  176 
  177 /* end of driver specific options */
  178 
  179 /* types/structures */
  180 
  181 #define KBDQ_BUFSIZE    32
  182 
  183 typedef struct _kqueue {
  184     int head;
  185     int tail;
  186     unsigned char q[KBDQ_BUFSIZE];
  187 #if KBDIO_DEBUG >= 2
  188     int call_count;
  189     int qcount;
  190     int max_qcount;
  191 #endif
  192 } kqueue;
  193 
  194 struct resource;
  195 
  196 typedef struct atkbdc_softc {
  197     struct resource *port0;     /* data port */
  198     struct resource *port1;     /* status port */
  199     struct resource *irq;
  200     bus_space_tag_t iot;
  201     bus_space_handle_t ioh0;
  202     bus_space_handle_t ioh1;
  203     int command_byte;           /* current command byte value */
  204     int command_mask;           /* command byte mask bits for kbd/aux devices */
  205     int lock;                   /* FIXME: XXX not quite a semaphore... */
  206     kqueue kbd;                 /* keyboard data queue */
  207     kqueue aux;                 /* auxiliary data queue */
  208     int retry;
  209     int quirks;                 /* controller doesn't like deactivate */
  210 #define KBDC_QUIRK_KEEP_ACTIVATED       (1 << 0)
  211 #define KBDC_QUIRK_IGNORE_PROBE_RESULT  (1 << 1)
  212 #define KBDC_QUIRK_RESET_AFTER_PROBE    (1 << 2)
  213 #define KBDC_QUIRK_SETLEDS_ON_INIT      (1 << 3)
  214 #define KBDC_QUIRK_DISABLE_MUX_PROBE    (1 << 4)
  215     int aux_mux_enabled;        /* active PS/2 multiplexing is enabled */
  216     int aux_mux_port;           /* current aux mux port */
  217 } atkbdc_softc_t; 
  218 
  219 enum kbdc_device_ivar {
  220         KBDC_IVAR_VENDORID,
  221         KBDC_IVAR_SERIAL,
  222         KBDC_IVAR_LOGICALID,
  223         KBDC_IVAR_COMPATID, 
  224 };
  225 
  226 typedef atkbdc_softc_t *KBDC;
  227 
  228 #define KBDC_RID_KBD    0
  229 #define KBDC_RID_AUX    1
  230 
  231 #define KBDC_AUX_MUX_NUM_PORTS  4
  232 
  233 /* function prototypes */
  234 
  235 atkbdc_softc_t *atkbdc_get_softc(int unit);
  236 int atkbdc_probe_unit(int unit, struct resource *port0, struct resource *port1);
  237 int atkbdc_attach_unit(int unit, atkbdc_softc_t *sc, struct resource *port0,
  238                        struct resource *port1);
  239 int atkbdc_configure(void);
  240 
  241 KBDC atkbdc_open(int unit);
  242 int kbdc_lock(KBDC kbdc, int lock);
  243 int kbdc_data_ready(KBDC kbdc);
  244 
  245 int write_controller_command(KBDC kbdc,int c);
  246 int write_controller_data(KBDC kbdc,int c);
  247 
  248 int write_kbd_command(KBDC kbdc,int c);
  249 int write_aux_command(KBDC kbdc,int c);
  250 int send_kbd_command(KBDC kbdc,int c);
  251 int send_aux_command(KBDC kbdc,int c);
  252 int send_kbd_command_and_data(KBDC kbdc,int c,int d);
  253 int send_aux_command_and_data(KBDC kbdc,int c,int d);
  254 
  255 int read_controller_data(KBDC kbdc);
  256 int read_kbd_data(KBDC kbdc);
  257 int read_kbd_data_no_wait(KBDC kbdc);
  258 int read_aux_data(KBDC kbdc);
  259 int read_aux_data_no_wait(KBDC kbdc);
  260 
  261 void empty_kbd_buffer(KBDC kbdc, int t);
  262 void empty_aux_buffer(KBDC kbdc, int t);
  263 void empty_both_buffers(KBDC kbdc, int t);
  264 
  265 int reset_kbd(KBDC kbdc);
  266 int reset_aux_dev(KBDC kbdc);
  267 
  268 int test_controller(KBDC kbdc);
  269 int test_kbd_port(KBDC kbdc);
  270 int test_aux_port(KBDC kbdc);
  271 
  272 int kbdc_get_device_mask(KBDC kbdc);
  273 void kbdc_set_device_mask(KBDC kbdc, int mask);
  274 
  275 int get_controller_command_byte(KBDC kbdc);
  276 int set_controller_command_byte(KBDC kbdc, int command, int flag);
  277 
  278 int set_active_aux_mux_port(KBDC p, int port);
  279 int enable_aux_mux(KBDC p);
  280 int disable_aux_mux(KBDC p);
  281 int aux_mux_is_enabled(KBDC p);
  282 
  283 #endif /* _KERNEL */
  284 
  285 #endif /* !_DEV_ATKBDC_ATKBDCREG_H_ */

Cache object: 29d6e446aaed0e6d9e74c0d3126e9ace


[ 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.