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 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 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 /* 270Sstevel@tonic-gate * Copyright 2005 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 #pragma ident "%Z%%M% %I% %E% SMI" 350Sstevel@tonic-gate 360Sstevel@tonic-gate #ifdef __cplusplus 370Sstevel@tonic-gate extern "C" { 380Sstevel@tonic-gate #endif 390Sstevel@tonic-gate 400Sstevel@tonic-gate /* 410Sstevel@tonic-gate * Messages from keyboard. 420Sstevel@tonic-gate */ 430Sstevel@tonic-gate #define KB_ERROR 0x00 /* Keyboard overrun or detection error */ 440Sstevel@tonic-gate #define KB_POST_OK 0xAA /* Sent at completion of poweron */ 450Sstevel@tonic-gate #define KB_ECHO 0xEE /* Response to Echo command (EE) */ 460Sstevel@tonic-gate #define KB_ACK 0xFA /* Acknowledgement byte from keyboard */ 470Sstevel@tonic-gate #define KB_POST_FAIL 0xFC /* Power On Self Test failed */ 480Sstevel@tonic-gate #define KB_RESEND 0xFE /* response from keyboard to resend data */ 49*822Ssethg #define KB_REPLY_MAXLEN 8 /* Maximum # of bytes the keyboard can reply */ 500Sstevel@tonic-gate /* 510Sstevel@tonic-gate * Commands to keyboard. 520Sstevel@tonic-gate */ 530Sstevel@tonic-gate #define KB_SET_LED 0xED /* Tell kbd that following byte is led status */ 540Sstevel@tonic-gate #define KB_READID 0xF2 /* command to read keyboard id */ 550Sstevel@tonic-gate #define KB_ENABLE 0xF4 /* command to to enable keyboard */ 560Sstevel@tonic-gate #define KB_RESET 0xFF /* command to reset keyboard */ 570Sstevel@tonic-gate #define KB_SET_TYPE 0xF3 /* command--next byte is typematic values */ 580Sstevel@tonic-gate #define KB_SET_SCAN 0xF0 /* kbd command to set scan code set */ 590Sstevel@tonic-gate 600Sstevel@tonic-gate /* 610Sstevel@tonic-gate * LED bits 620Sstevel@tonic-gate */ 630Sstevel@tonic-gate #define LED_SCR 0x01 /* Flag bit for scroll lock */ 640Sstevel@tonic-gate #define LED_CAP 0x04 /* Flag bit for cap lock */ 650Sstevel@tonic-gate #define LED_NUM 0x02 /* Flag bit for num lock */ 660Sstevel@tonic-gate 670Sstevel@tonic-gate /* 680Sstevel@tonic-gate * Keyboard scan code prefixes 690Sstevel@tonic-gate */ 700Sstevel@tonic-gate #define KAT_BREAK 0xf0 /* first byte in two byte break sequence */ 710Sstevel@tonic-gate #define KXT_EXTEND 0xe0 /* first byte in two byte extended sequence */ 720Sstevel@tonic-gate #define KXT_EXTEND2 0xe1 /* Used in "Pause" sequence */ 730Sstevel@tonic-gate 740Sstevel@tonic-gate /* 750Sstevel@tonic-gate * Korean keyboard keys. We handle these specially to avoid having to 760Sstevel@tonic-gate * dramatically extend the table. 770Sstevel@tonic-gate */ 780Sstevel@tonic-gate #define KXT_HANGUL_HANJA 0xf1 790Sstevel@tonic-gate #define KXT_HANGUL 0xf2 800Sstevel@tonic-gate 810Sstevel@tonic-gate #ifdef _KERNEL 820Sstevel@tonic-gate 830Sstevel@tonic-gate struct kb8042 { 840Sstevel@tonic-gate kmutex_t w_hw_mutex; /* hardware mutex */ 850Sstevel@tonic-gate int w_init; /* workstation has been initialized */ 860Sstevel@tonic-gate queue_t *w_qp; /* pointer to queue for this minor device */ 870Sstevel@tonic-gate int w_kblayout; /* keyboard layout code */ 880Sstevel@tonic-gate dev_t w_dev; /* major/minor for this device */ 890Sstevel@tonic-gate ddi_iblock_cookie_t w_iblock; 900Sstevel@tonic-gate ddi_acc_handle_t handle; 910Sstevel@tonic-gate uint8_t *addr; 920Sstevel@tonic-gate int kb_old_key_pos; /* scancode for autorepeat filtering */ 930Sstevel@tonic-gate int command_state; 940Sstevel@tonic-gate struct { 950Sstevel@tonic-gate int desired; 960Sstevel@tonic-gate int commanded; 970Sstevel@tonic-gate } leds; 980Sstevel@tonic-gate int parse_scan_state; 990Sstevel@tonic-gate struct kbtrans *hw_kbtrans; 1000Sstevel@tonic-gate struct cons_polledio polledio; 1010Sstevel@tonic-gate struct { 1020Sstevel@tonic-gate unsigned char mod1; 1030Sstevel@tonic-gate unsigned char mod2; 1040Sstevel@tonic-gate unsigned char trigger; 1050Sstevel@tonic-gate boolean_t mod1_down; 1060Sstevel@tonic-gate boolean_t mod2_down; 1070Sstevel@tonic-gate boolean_t enabled; 1080Sstevel@tonic-gate } debugger; 1090Sstevel@tonic-gate boolean_t polled_synthetic_release_pending; 1100Sstevel@tonic-gate int polled_synthetic_release_key; 1110Sstevel@tonic-gate int simulated_kbd_type; 112*822Ssethg uint32_t init_state; 113*822Ssethg int break_received; 1140Sstevel@tonic-gate }; 1150Sstevel@tonic-gate 1160Sstevel@tonic-gate #define KB_COMMAND_STATE_IDLE 0 1170Sstevel@tonic-gate #define KB_COMMAND_STATE_LED 1 1180Sstevel@tonic-gate #define KB_COMMAND_STATE_WAIT 2 1190Sstevel@tonic-gate 1200Sstevel@tonic-gate extern boolean_t KeyboardConvertScan(struct kb8042 *, unsigned char scan, 1210Sstevel@tonic-gate int *keynum, enum keystate *, boolean_t *); 122*822Ssethg extern int KeyboardConvertScan_init(struct kb8042 *, int scanset); 1230Sstevel@tonic-gate 1240Sstevel@tonic-gate #if defined(i86pc) 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 134*822Ssethg /* 135*822Ssethg * Initialization states 136*822Ssethg */ 137*822Ssethg #define KB8042_UNINITIALIZED 0x00000000 138*822Ssethg #define KB8042_MINOR_NODE_CREATED 0x00000001 139*822Ssethg #define KB8042_REGS_MAPPED 0x00000002 140*822Ssethg #define KB8042_HW_MUTEX_INITTED 0x00000004 141*822Ssethg #define KB8042_INTR_ADDED 0x00000008 142*822Ssethg 143*822Ssethg /* 144*822Ssethg * Key values that map into the USB translation table in kb8042.c 145*822Ssethg */ 146*822Ssethg #define K8042_STOP 160 147*822Ssethg 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