17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 52df1fe9cSrandyf * Common Development and Distribution License (the "License"). 62df1fe9cSrandyf * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 212df1fe9cSrandyf 227c478bd9Sstevel@tonic-gate /* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ 237c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */ 247c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate /* 27*15bfc6b7SSeth Goldberg * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 287c478bd9Sstevel@tonic-gate * Use is subject to license terms. 297c478bd9Sstevel@tonic-gate */ 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #ifndef _KB8042_H 327c478bd9Sstevel@tonic-gate #define _KB8042_H 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #ifdef __cplusplus 357c478bd9Sstevel@tonic-gate extern "C" { 367c478bd9Sstevel@tonic-gate #endif 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate /* 397c478bd9Sstevel@tonic-gate * Messages from keyboard. 407c478bd9Sstevel@tonic-gate */ 417c478bd9Sstevel@tonic-gate #define KB_ERROR 0x00 /* Keyboard overrun or detection error */ 427c478bd9Sstevel@tonic-gate #define KB_POST_OK 0xAA /* Sent at completion of poweron */ 437c478bd9Sstevel@tonic-gate #define KB_ECHO 0xEE /* Response to Echo command (EE) */ 447c478bd9Sstevel@tonic-gate #define KB_ACK 0xFA /* Acknowledgement byte from keyboard */ 457c478bd9Sstevel@tonic-gate #define KB_POST_FAIL 0xFC /* Power On Self Test failed */ 467c478bd9Sstevel@tonic-gate #define KB_RESEND 0xFE /* response from keyboard to resend data */ 47fd9cb95cSsethg #define KB_REPLY_MAXLEN 8 /* Maximum # of bytes the keyboard can reply */ 487c478bd9Sstevel@tonic-gate /* 497c478bd9Sstevel@tonic-gate * Commands to keyboard. 507c478bd9Sstevel@tonic-gate */ 517c478bd9Sstevel@tonic-gate #define KB_SET_LED 0xED /* Tell kbd that following byte is led status */ 527c478bd9Sstevel@tonic-gate #define KB_READID 0xF2 /* command to read keyboard id */ 537c478bd9Sstevel@tonic-gate #define KB_ENABLE 0xF4 /* command to to enable keyboard */ 547c478bd9Sstevel@tonic-gate #define KB_RESET 0xFF /* command to reset keyboard */ 557c478bd9Sstevel@tonic-gate #define KB_SET_TYPE 0xF3 /* command--next byte is typematic values */ 567c478bd9Sstevel@tonic-gate #define KB_SET_SCAN 0xF0 /* kbd command to set scan code set */ 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate /* 597c478bd9Sstevel@tonic-gate * LED bits 607c478bd9Sstevel@tonic-gate */ 617c478bd9Sstevel@tonic-gate #define LED_SCR 0x01 /* Flag bit for scroll lock */ 627c478bd9Sstevel@tonic-gate #define LED_CAP 0x04 /* Flag bit for cap lock */ 637c478bd9Sstevel@tonic-gate #define LED_NUM 0x02 /* Flag bit for num lock */ 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate /* 667c478bd9Sstevel@tonic-gate * Keyboard scan code prefixes 677c478bd9Sstevel@tonic-gate */ 687c478bd9Sstevel@tonic-gate #define KAT_BREAK 0xf0 /* first byte in two byte break sequence */ 697c478bd9Sstevel@tonic-gate #define KXT_EXTEND 0xe0 /* first byte in two byte extended sequence */ 707c478bd9Sstevel@tonic-gate #define KXT_EXTEND2 0xe1 /* Used in "Pause" sequence */ 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate /* 737c478bd9Sstevel@tonic-gate * Korean keyboard keys. We handle these specially to avoid having to 747c478bd9Sstevel@tonic-gate * dramatically extend the table. 757c478bd9Sstevel@tonic-gate */ 767c478bd9Sstevel@tonic-gate #define KXT_HANGUL_HANJA 0xf1 777c478bd9Sstevel@tonic-gate #define KXT_HANGUL 0xf2 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate #ifdef _KERNEL 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate struct kb8042 { 827c478bd9Sstevel@tonic-gate kmutex_t w_hw_mutex; /* hardware mutex */ 837c478bd9Sstevel@tonic-gate int w_init; /* workstation has been initialized */ 847c478bd9Sstevel@tonic-gate queue_t *w_qp; /* pointer to queue for this minor device */ 857c478bd9Sstevel@tonic-gate int w_kblayout; /* keyboard layout code */ 867c478bd9Sstevel@tonic-gate dev_t w_dev; /* major/minor for this device */ 877c478bd9Sstevel@tonic-gate ddi_iblock_cookie_t w_iblock; 887c478bd9Sstevel@tonic-gate ddi_acc_handle_t handle; 897c478bd9Sstevel@tonic-gate uint8_t *addr; 907c478bd9Sstevel@tonic-gate int kb_old_key_pos; /* scancode for autorepeat filtering */ 917c478bd9Sstevel@tonic-gate struct { 927c478bd9Sstevel@tonic-gate int desired; 937c478bd9Sstevel@tonic-gate int commanded; 947c478bd9Sstevel@tonic-gate } leds; 957c478bd9Sstevel@tonic-gate int parse_scan_state; 967c478bd9Sstevel@tonic-gate struct kbtrans *hw_kbtrans; 977c478bd9Sstevel@tonic-gate struct cons_polledio polledio; 987c478bd9Sstevel@tonic-gate struct { 997c478bd9Sstevel@tonic-gate unsigned char mod1; 1007c478bd9Sstevel@tonic-gate unsigned char mod2; 1017c478bd9Sstevel@tonic-gate unsigned char trigger; 1027c478bd9Sstevel@tonic-gate boolean_t mod1_down; 1037c478bd9Sstevel@tonic-gate boolean_t mod2_down; 1047c478bd9Sstevel@tonic-gate boolean_t enabled; 1057c478bd9Sstevel@tonic-gate } debugger; 1067c478bd9Sstevel@tonic-gate boolean_t polled_synthetic_release_pending; 1077c478bd9Sstevel@tonic-gate int polled_synthetic_release_key; 1087c478bd9Sstevel@tonic-gate int simulated_kbd_type; 109fd9cb95cSsethg uint32_t init_state; 110fd9cb95cSsethg int break_received; 1112df1fe9cSrandyf boolean_t suspended; 1122df1fe9cSrandyf int ops; 1132df1fe9cSrandyf kcondvar_t suspend_cv; 1142df1fe9cSrandyf kcondvar_t ops_cv; 115*15bfc6b7SSeth Goldberg int acked; 116*15bfc6b7SSeth Goldberg int need_retry; 117*15bfc6b7SSeth Goldberg kcondvar_t cmd_cv; 1187c478bd9Sstevel@tonic-gate }; 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate extern boolean_t KeyboardConvertScan(struct kb8042 *, unsigned char scan, 1217c478bd9Sstevel@tonic-gate int *keynum, enum keystate *, boolean_t *); 122fd9cb95cSsethg extern int KeyboardConvertScan_init(struct kb8042 *, int scanset); 1237c478bd9Sstevel@tonic-gate 124bb2d7d5eSSeth Goldberg #if defined(__i386) || defined(__amd64) 1257c478bd9Sstevel@tonic-gate /* 1267c478bd9Sstevel@tonic-gate * We pick up the initial state of the keyboard from the BIOS state. 1277c478bd9Sstevel@tonic-gate */ 1287c478bd9Sstevel@tonic-gate #define BIOS_KB_FLAG 0x417 /* address of BIOS keyboard state */ 1297c478bd9Sstevel@tonic-gate #define BIOS_SCROLL_STATE 0x10 1307c478bd9Sstevel@tonic-gate #define BIOS_NUM_STATE 0x20 1317c478bd9Sstevel@tonic-gate #define BIOS_CAPS_STATE 0x40 1327c478bd9Sstevel@tonic-gate #endif 1337c478bd9Sstevel@tonic-gate 134fd9cb95cSsethg /* 135fd9cb95cSsethg * Initialization states 136fd9cb95cSsethg */ 137fd9cb95cSsethg #define KB8042_UNINITIALIZED 0x00000000 138fd9cb95cSsethg #define KB8042_MINOR_NODE_CREATED 0x00000001 139fd9cb95cSsethg #define KB8042_REGS_MAPPED 0x00000002 140fd9cb95cSsethg #define KB8042_HW_MUTEX_INITTED 0x00000004 141fd9cb95cSsethg #define KB8042_INTR_ADDED 0x00000008 142fd9cb95cSsethg 143fd9cb95cSsethg /* 144fd9cb95cSsethg * Key values that map into the USB translation table in kb8042.c 145fd9cb95cSsethg */ 146fd9cb95cSsethg #define K8042_STOP 160 147fd9cb95cSsethg 1487c478bd9Sstevel@tonic-gate #endif 1497c478bd9Sstevel@tonic-gate 1507c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1517c478bd9Sstevel@tonic-gate } 1527c478bd9Sstevel@tonic-gate #endif 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate #endif /* _KB8042_H */ 155