xref: /onnv-gate/usr/src/uts/common/io/kb8042/kb8042.h (revision 10087:45644b99daec)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
55295Srandyf  * Common Development and Distribution License (the "License").
65295Srandyf  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
215295Srandyf 
220Sstevel@tonic-gate /*	Copyright (c) 1990, 1991 UNIX System Laboratories, Inc.	*/
230Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T	*/
240Sstevel@tonic-gate /*	  All Rights Reserved  	*/
250Sstevel@tonic-gate 
260Sstevel@tonic-gate /*
27*10087SSeth.Goldberg@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
280Sstevel@tonic-gate  * Use is subject to license terms.
290Sstevel@tonic-gate  */
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #ifndef	_KB8042_H
320Sstevel@tonic-gate #define	_KB8042_H
330Sstevel@tonic-gate 
340Sstevel@tonic-gate #ifdef	__cplusplus
350Sstevel@tonic-gate extern "C" {
360Sstevel@tonic-gate #endif
370Sstevel@tonic-gate 
380Sstevel@tonic-gate /*
390Sstevel@tonic-gate  * Messages from keyboard.
400Sstevel@tonic-gate  */
410Sstevel@tonic-gate #define	KB_ERROR	0x00	/* Keyboard overrun or detection error */
420Sstevel@tonic-gate #define	KB_POST_OK	0xAA	/* Sent at completion of poweron */
430Sstevel@tonic-gate #define	KB_ECHO		0xEE	/* Response to Echo command (EE)  */
440Sstevel@tonic-gate #define	KB_ACK		0xFA	/* Acknowledgement byte from keyboard */
450Sstevel@tonic-gate #define	KB_POST_FAIL	0xFC	/* Power On Self Test failed */
460Sstevel@tonic-gate #define	KB_RESEND	0xFE	/* response from keyboard to resend data */
47822Ssethg #define	KB_REPLY_MAXLEN	8	/* Maximum # of bytes the keyboard can reply */
480Sstevel@tonic-gate /*
490Sstevel@tonic-gate  * Commands to keyboard.
500Sstevel@tonic-gate  */
510Sstevel@tonic-gate #define	KB_SET_LED	0xED	/* Tell kbd that following byte is led status */
520Sstevel@tonic-gate #define	KB_READID	0xF2	/* command to read keyboard id */
530Sstevel@tonic-gate #define	KB_ENABLE	0xF4	/* command to to enable keyboard */
540Sstevel@tonic-gate #define	KB_RESET	0xFF	/* command to reset keyboard */
550Sstevel@tonic-gate #define	KB_SET_TYPE	0xF3	/* command--next byte is typematic values */
560Sstevel@tonic-gate #define	KB_SET_SCAN	0xF0	/* kbd command to set scan code set */
570Sstevel@tonic-gate 
580Sstevel@tonic-gate /*
590Sstevel@tonic-gate  * LED bits
600Sstevel@tonic-gate  */
610Sstevel@tonic-gate #define	LED_SCR		0x01	/* Flag bit for scroll lock */
620Sstevel@tonic-gate #define	LED_CAP		0x04	/* Flag bit for cap lock */
630Sstevel@tonic-gate #define	LED_NUM		0x02	/* Flag bit for num lock */
640Sstevel@tonic-gate 
650Sstevel@tonic-gate /*
660Sstevel@tonic-gate  * Keyboard scan code prefixes
670Sstevel@tonic-gate  */
680Sstevel@tonic-gate #define	KAT_BREAK	0xf0	/* first byte in two byte break sequence */
690Sstevel@tonic-gate #define	KXT_EXTEND	0xe0	/* first byte in two byte extended sequence */
700Sstevel@tonic-gate #define	KXT_EXTEND2	0xe1	/* Used in "Pause" sequence */
710Sstevel@tonic-gate 
720Sstevel@tonic-gate /*
730Sstevel@tonic-gate  * Korean keyboard keys.  We handle these specially to avoid having to
740Sstevel@tonic-gate  * dramatically extend the table.
750Sstevel@tonic-gate  */
760Sstevel@tonic-gate #define	KXT_HANGUL_HANJA	0xf1
770Sstevel@tonic-gate #define	KXT_HANGUL		0xf2
780Sstevel@tonic-gate 
790Sstevel@tonic-gate #ifdef _KERNEL
800Sstevel@tonic-gate 
810Sstevel@tonic-gate struct kb8042 {
820Sstevel@tonic-gate 	kmutex_t	w_hw_mutex;	/* hardware mutex */
830Sstevel@tonic-gate 	int	w_init;		/* workstation has been initialized */
840Sstevel@tonic-gate 	queue_t	*w_qp;		/* pointer to queue for this minor device */
850Sstevel@tonic-gate 	int	w_kblayout;	/* keyboard layout code */
860Sstevel@tonic-gate 	dev_t	w_dev;		/* major/minor for this device */
870Sstevel@tonic-gate 	ddi_iblock_cookie_t	w_iblock;
880Sstevel@tonic-gate 	ddi_acc_handle_t	handle;
890Sstevel@tonic-gate 	uint8_t			*addr;
900Sstevel@tonic-gate 	int	kb_old_key_pos;	/* scancode for autorepeat filtering */
910Sstevel@tonic-gate 	struct {
920Sstevel@tonic-gate 		int desired;
930Sstevel@tonic-gate 		int commanded;
940Sstevel@tonic-gate 	}	leds;
950Sstevel@tonic-gate 	int	parse_scan_state;
960Sstevel@tonic-gate 	struct kbtrans	*hw_kbtrans;
970Sstevel@tonic-gate 	struct cons_polledio	polledio;
980Sstevel@tonic-gate 	struct {
990Sstevel@tonic-gate 		unsigned char mod1;
1000Sstevel@tonic-gate 		unsigned char mod2;
1010Sstevel@tonic-gate 		unsigned char trigger;
1020Sstevel@tonic-gate 		boolean_t mod1_down;
1030Sstevel@tonic-gate 		boolean_t mod2_down;
1040Sstevel@tonic-gate 		boolean_t enabled;
1050Sstevel@tonic-gate 	}		debugger;
1060Sstevel@tonic-gate 	boolean_t	polled_synthetic_release_pending;
1070Sstevel@tonic-gate 	int		polled_synthetic_release_key;
1080Sstevel@tonic-gate 	int		simulated_kbd_type;
109822Ssethg 	uint32_t	init_state;
110822Ssethg 	int		break_received;
1115295Srandyf 	boolean_t	suspended;
1125295Srandyf 	int		ops;
1135295Srandyf 	kcondvar_t	suspend_cv;
1145295Srandyf 	kcondvar_t	ops_cv;
115*10087SSeth.Goldberg@Sun.COM 	int		acked;
116*10087SSeth.Goldberg@Sun.COM 	int		need_retry;
117*10087SSeth.Goldberg@Sun.COM 	kcondvar_t	cmd_cv;
1180Sstevel@tonic-gate };
1190Sstevel@tonic-gate 
1200Sstevel@tonic-gate extern boolean_t KeyboardConvertScan(struct kb8042 *, unsigned char scan,
1210Sstevel@tonic-gate 			int *keynum, enum keystate *, boolean_t *);
122822Ssethg extern int KeyboardConvertScan_init(struct kb8042 *, int scanset);
1230Sstevel@tonic-gate 
1247658SSeth.Goldberg@Sun.COM #if defined(__i386) || defined(__amd64)
1250Sstevel@tonic-gate /*
1260Sstevel@tonic-gate  * We pick up the initial state of the keyboard from the BIOS state.
1270Sstevel@tonic-gate  */
1280Sstevel@tonic-gate #define	BIOS_KB_FLAG		0x417	/* address of BIOS keyboard state */
1290Sstevel@tonic-gate #define	BIOS_SCROLL_STATE	0x10
1300Sstevel@tonic-gate #define	BIOS_NUM_STATE		0x20
1310Sstevel@tonic-gate #define	BIOS_CAPS_STATE		0x40
1320Sstevel@tonic-gate #endif
1330Sstevel@tonic-gate 
134822Ssethg /*
135822Ssethg  * Initialization states
136822Ssethg  */
137822Ssethg #define	KB8042_UNINITIALIZED		0x00000000
138822Ssethg #define	KB8042_MINOR_NODE_CREATED	0x00000001
139822Ssethg #define	KB8042_REGS_MAPPED		0x00000002
140822Ssethg #define	KB8042_HW_MUTEX_INITTED		0x00000004
141822Ssethg #define	KB8042_INTR_ADDED		0x00000008
142822Ssethg 
143822Ssethg /*
144822Ssethg  * Key values that map into the USB translation table in kb8042.c
145822Ssethg  */
146822Ssethg #define	K8042_STOP	160
147822Ssethg 
1480Sstevel@tonic-gate #endif
1490Sstevel@tonic-gate 
1500Sstevel@tonic-gate #ifdef	__cplusplus
1510Sstevel@tonic-gate }
1520Sstevel@tonic-gate #endif
1530Sstevel@tonic-gate 
1540Sstevel@tonic-gate #endif /* _KB8042_H */
155