xref: /onnv-gate/usr/src/uts/common/io/kb8042/kb8042.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*	Copyright (c) 1990, 1991 UNIX System Laboratories, Inc.	*/
23*0Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T	*/
24*0Sstevel@tonic-gate /*	  All Rights Reserved  	*/
25*0Sstevel@tonic-gate 
26*0Sstevel@tonic-gate /*
27*0Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
28*0Sstevel@tonic-gate  * Use is subject to license terms.
29*0Sstevel@tonic-gate  */
30*0Sstevel@tonic-gate 
31*0Sstevel@tonic-gate #ifndef	_KB8042_H
32*0Sstevel@tonic-gate #define	_KB8042_H
33*0Sstevel@tonic-gate 
34*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
35*0Sstevel@tonic-gate 
36*0Sstevel@tonic-gate #ifdef	__cplusplus
37*0Sstevel@tonic-gate extern "C" {
38*0Sstevel@tonic-gate #endif
39*0Sstevel@tonic-gate 
40*0Sstevel@tonic-gate /*
41*0Sstevel@tonic-gate  * Messages from keyboard.
42*0Sstevel@tonic-gate  */
43*0Sstevel@tonic-gate #define	KB_ERROR	0x00	/* Keyboard overrun or detection error */
44*0Sstevel@tonic-gate #define	KB_POST_OK	0xAA	/* Sent at completion of poweron */
45*0Sstevel@tonic-gate #define	KB_ECHO		0xEE	/* Response to Echo command (EE)  */
46*0Sstevel@tonic-gate #define	KB_ACK		0xFA	/* Acknowledgement byte from keyboard */
47*0Sstevel@tonic-gate #define	KB_POST_FAIL	0xFC	/* Power On Self Test failed */
48*0Sstevel@tonic-gate #define	KB_RESEND	0xFE	/* response from keyboard to resend data */
49*0Sstevel@tonic-gate 
50*0Sstevel@tonic-gate /*
51*0Sstevel@tonic-gate  * Commands to keyboard.
52*0Sstevel@tonic-gate  */
53*0Sstevel@tonic-gate #define	KB_SET_LED	0xED	/* Tell kbd that following byte is led status */
54*0Sstevel@tonic-gate #define	KB_READID	0xF2	/* command to read keyboard id */
55*0Sstevel@tonic-gate #define	KB_ENABLE	0xF4	/* command to to enable keyboard */
56*0Sstevel@tonic-gate #define	KB_RESET	0xFF	/* command to reset keyboard */
57*0Sstevel@tonic-gate #define	KB_SET_TYPE	0xF3	/* command--next byte is typematic values */
58*0Sstevel@tonic-gate #define	KB_SET_SCAN	0xF0	/* kbd command to set scan code set */
59*0Sstevel@tonic-gate 
60*0Sstevel@tonic-gate /*
61*0Sstevel@tonic-gate  * LED bits
62*0Sstevel@tonic-gate  */
63*0Sstevel@tonic-gate #define	LED_SCR		0x01	/* Flag bit for scroll lock */
64*0Sstevel@tonic-gate #define	LED_CAP		0x04	/* Flag bit for cap lock */
65*0Sstevel@tonic-gate #define	LED_NUM		0x02	/* Flag bit for num lock */
66*0Sstevel@tonic-gate 
67*0Sstevel@tonic-gate /*
68*0Sstevel@tonic-gate  * Keyboard scan code prefixes
69*0Sstevel@tonic-gate  */
70*0Sstevel@tonic-gate #define	KAT_BREAK	0xf0	/* first byte in two byte break sequence */
71*0Sstevel@tonic-gate #define	KXT_EXTEND	0xe0	/* first byte in two byte extended sequence */
72*0Sstevel@tonic-gate #define	KXT_EXTEND2	0xe1	/* Used in "Pause" sequence */
73*0Sstevel@tonic-gate 
74*0Sstevel@tonic-gate /*
75*0Sstevel@tonic-gate  * Korean keyboard keys.  We handle these specially to avoid having to
76*0Sstevel@tonic-gate  * dramatically extend the table.
77*0Sstevel@tonic-gate  */
78*0Sstevel@tonic-gate #define	KXT_HANGUL_HANJA	0xf1
79*0Sstevel@tonic-gate #define	KXT_HANGUL		0xf2
80*0Sstevel@tonic-gate 
81*0Sstevel@tonic-gate #ifdef _KERNEL
82*0Sstevel@tonic-gate 
83*0Sstevel@tonic-gate struct kb8042 {
84*0Sstevel@tonic-gate 	kmutex_t	w_hw_mutex;	/* hardware mutex */
85*0Sstevel@tonic-gate 	int	w_init;		/* workstation has been initialized */
86*0Sstevel@tonic-gate 	queue_t	*w_qp;		/* pointer to queue for this minor device */
87*0Sstevel@tonic-gate 	int	w_kblayout;	/* keyboard layout code */
88*0Sstevel@tonic-gate 	dev_t	w_dev;		/* major/minor for this device */
89*0Sstevel@tonic-gate 	ddi_iblock_cookie_t	w_iblock;
90*0Sstevel@tonic-gate 	ddi_acc_handle_t	handle;
91*0Sstevel@tonic-gate 	uint8_t			*addr;
92*0Sstevel@tonic-gate 	int	kb_old_key_pos;	/* scancode for autorepeat filtering */
93*0Sstevel@tonic-gate 	int	command_state;
94*0Sstevel@tonic-gate 	struct {
95*0Sstevel@tonic-gate 		int desired;
96*0Sstevel@tonic-gate 		int commanded;
97*0Sstevel@tonic-gate 	}	leds;
98*0Sstevel@tonic-gate 	int	parse_scan_state;
99*0Sstevel@tonic-gate 	struct kbtrans	*hw_kbtrans;
100*0Sstevel@tonic-gate 	struct cons_polledio	polledio;
101*0Sstevel@tonic-gate 	struct {
102*0Sstevel@tonic-gate 		unsigned char mod1;
103*0Sstevel@tonic-gate 		unsigned char mod2;
104*0Sstevel@tonic-gate 		unsigned char trigger;
105*0Sstevel@tonic-gate 		boolean_t mod1_down;
106*0Sstevel@tonic-gate 		boolean_t mod2_down;
107*0Sstevel@tonic-gate 		boolean_t enabled;
108*0Sstevel@tonic-gate 	}		debugger;
109*0Sstevel@tonic-gate 	boolean_t	polled_synthetic_release_pending;
110*0Sstevel@tonic-gate 	int		polled_synthetic_release_key;
111*0Sstevel@tonic-gate 	int		simulated_kbd_type;
112*0Sstevel@tonic-gate };
113*0Sstevel@tonic-gate 
114*0Sstevel@tonic-gate #define	KB_COMMAND_STATE_IDLE	0
115*0Sstevel@tonic-gate #define	KB_COMMAND_STATE_LED	1
116*0Sstevel@tonic-gate #define	KB_COMMAND_STATE_WAIT	2
117*0Sstevel@tonic-gate 
118*0Sstevel@tonic-gate extern boolean_t KeyboardConvertScan(struct kb8042 *, unsigned char scan,
119*0Sstevel@tonic-gate 			int *keynum, enum keystate *, boolean_t *);
120*0Sstevel@tonic-gate extern void KeyboardConvertScan_init(struct kb8042 *);
121*0Sstevel@tonic-gate 
122*0Sstevel@tonic-gate #if	defined(i86pc)
123*0Sstevel@tonic-gate /*
124*0Sstevel@tonic-gate  * We pick up the initial state of the keyboard from the BIOS state.
125*0Sstevel@tonic-gate  */
126*0Sstevel@tonic-gate #define	BIOS_KB_FLAG		0x417	/* address of BIOS keyboard state */
127*0Sstevel@tonic-gate #define	BIOS_SCROLL_STATE	0x10
128*0Sstevel@tonic-gate #define	BIOS_NUM_STATE		0x20
129*0Sstevel@tonic-gate #define	BIOS_CAPS_STATE		0x40
130*0Sstevel@tonic-gate #endif
131*0Sstevel@tonic-gate 
132*0Sstevel@tonic-gate #endif
133*0Sstevel@tonic-gate 
134*0Sstevel@tonic-gate #ifdef	__cplusplus
135*0Sstevel@tonic-gate }
136*0Sstevel@tonic-gate #endif
137*0Sstevel@tonic-gate 
138*0Sstevel@tonic-gate #endif /* _KB8042_H */
139