blob: d63c3277555f4986a622781e439acfe148bab01c [file] [log] [blame]
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -07001/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
randyf2df1fe92007-10-20 16:00:42 -07005 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -07007 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
randyf2df1fe92007-10-20 16:00:42 -070021
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070022/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
23/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
24/* All Rights Reserved */
25
26/*
Seth Goldberg15bfc6b2009-07-14 19:07:47 -070027 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070028 * Use is subject to license terms.
29 */
30
31#ifndef _KB8042_H
32#define _KB8042_H
33
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070034#ifdef __cplusplus
35extern "C" {
36#endif
37
38/*
39 * Messages from keyboard.
40 */
41#define KB_ERROR 0x00 /* Keyboard overrun or detection error */
42#define KB_POST_OK 0xAA /* Sent at completion of poweron */
43#define KB_ECHO 0xEE /* Response to Echo command (EE) */
44#define KB_ACK 0xFA /* Acknowledgement byte from keyboard */
45#define KB_POST_FAIL 0xFC /* Power On Self Test failed */
46#define KB_RESEND 0xFE /* response from keyboard to resend data */
sethgfd9cb952005-11-01 22:55:18 -080047#define KB_REPLY_MAXLEN 8 /* Maximum # of bytes the keyboard can reply */
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070048/*
49 * Commands to keyboard.
50 */
51#define KB_SET_LED 0xED /* Tell kbd that following byte is led status */
52#define KB_READID 0xF2 /* command to read keyboard id */
53#define KB_ENABLE 0xF4 /* command to to enable keyboard */
54#define KB_RESET 0xFF /* command to reset keyboard */
55#define KB_SET_TYPE 0xF3 /* command--next byte is typematic values */
56#define KB_SET_SCAN 0xF0 /* kbd command to set scan code set */
57
58/*
59 * LED bits
60 */
61#define LED_SCR 0x01 /* Flag bit for scroll lock */
62#define LED_CAP 0x04 /* Flag bit for cap lock */
63#define LED_NUM 0x02 /* Flag bit for num lock */
64
65/*
66 * Keyboard scan code prefixes
67 */
68#define KAT_BREAK 0xf0 /* first byte in two byte break sequence */
69#define KXT_EXTEND 0xe0 /* first byte in two byte extended sequence */
70#define KXT_EXTEND2 0xe1 /* Used in "Pause" sequence */
71
72/*
73 * Korean keyboard keys. We handle these specially to avoid having to
74 * dramatically extend the table.
75 */
76#define KXT_HANGUL_HANJA 0xf1
77#define KXT_HANGUL 0xf2
78
79#ifdef _KERNEL
80
81struct kb8042 {
82 kmutex_t w_hw_mutex; /* hardware mutex */
83 int w_init; /* workstation has been initialized */
84 queue_t *w_qp; /* pointer to queue for this minor device */
85 int w_kblayout; /* keyboard layout code */
86 dev_t w_dev; /* major/minor for this device */
87 ddi_iblock_cookie_t w_iblock;
88 ddi_acc_handle_t handle;
89 uint8_t *addr;
90 int kb_old_key_pos; /* scancode for autorepeat filtering */
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070091 struct {
92 int desired;
93 int commanded;
94 } leds;
95 int parse_scan_state;
96 struct kbtrans *hw_kbtrans;
97 struct cons_polledio polledio;
98 struct {
99 unsigned char mod1;
100 unsigned char mod2;
101 unsigned char trigger;
102 boolean_t mod1_down;
103 boolean_t mod2_down;
104 boolean_t enabled;
105 } debugger;
106 boolean_t polled_synthetic_release_pending;
107 int polled_synthetic_release_key;
108 int simulated_kbd_type;
sethgfd9cb952005-11-01 22:55:18 -0800109 uint32_t init_state;
110 int break_received;
randyf2df1fe92007-10-20 16:00:42 -0700111 boolean_t suspended;
112 int ops;
113 kcondvar_t suspend_cv;
114 kcondvar_t ops_cv;
Seth Goldberg15bfc6b2009-07-14 19:07:47 -0700115 int acked;
116 int need_retry;
117 kcondvar_t cmd_cv;
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700118};
119
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700120extern boolean_t KeyboardConvertScan(struct kb8042 *, unsigned char scan,
121 int *keynum, enum keystate *, boolean_t *);
sethgfd9cb952005-11-01 22:55:18 -0800122extern int KeyboardConvertScan_init(struct kb8042 *, int scanset);
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700123
Seth Goldbergbb2d7d52008-09-22 18:07:42 -0700124#if defined(__i386) || defined(__amd64)
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700125/*
126 * We pick up the initial state of the keyboard from the BIOS state.
127 */
128#define BIOS_KB_FLAG 0x417 /* address of BIOS keyboard state */
129#define BIOS_SCROLL_STATE 0x10
130#define BIOS_NUM_STATE 0x20
131#define BIOS_CAPS_STATE 0x40
132#endif
133
sethgfd9cb952005-11-01 22:55:18 -0800134/*
135 * Initialization states
136 */
137#define KB8042_UNINITIALIZED 0x00000000
138#define KB8042_MINOR_NODE_CREATED 0x00000001
139#define KB8042_REGS_MAPPED 0x00000002
140#define KB8042_HW_MUTEX_INITTED 0x00000004
141#define KB8042_INTR_ADDED 0x00000008
142
143/*
144 * Key values that map into the USB translation table in kb8042.c
145 */
146#define K8042_STOP 160
147
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700148#endif
149
150#ifdef __cplusplus
151}
152#endif
153
154#endif /* _KB8042_H */