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 5e4603304Sqz150045 * Common Development and Distribution License (the "License"). 6e4603304Sqz150045 * 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 */ 21aecfc01dSrui zang - Sun Microsystems - Beijing China 227c478bd9Sstevel@tonic-gate /* 233bce8c8cSJan Setje-Eilers * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _KBTRANS_STREAMS_H 287c478bd9Sstevel@tonic-gate #define _KBTRANS_STREAMS_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #ifdef __cplusplus 317c478bd9Sstevel@tonic-gate extern "C" { 327c478bd9Sstevel@tonic-gate #endif 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #include <sys/stream.h> 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #define KBTRANS_POLLED_BUF_SIZE 30 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate /* definitions for various state machines */ 397c478bd9Sstevel@tonic-gate #define KBTRANS_STREAMS_OPEN 0x00000001 /* keyboard is open for business */ 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate #define NO_HARD_RESET 0 /* resets only state struct */ 427c478bd9Sstevel@tonic-gate #define HARD_RESET 1 /* resets keyboard and state structure */ 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate /* 457c478bd9Sstevel@tonic-gate * structure to keep track of currently pressed keys when in 467c478bd9Sstevel@tonic-gate * TR_UNTRANS_EVENT mode 477c478bd9Sstevel@tonic-gate */ 487c478bd9Sstevel@tonic-gate typedef struct key_event { 497c478bd9Sstevel@tonic-gate uchar_t key_station; /* Physical key station associated with event */ 507c478bd9Sstevel@tonic-gate Firm_event event; /* Event that sent out on down */ 517c478bd9Sstevel@tonic-gate } Key_event; 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate /* state structure for kbtrans_streams */ 557c478bd9Sstevel@tonic-gate struct kbtrans { 567c478bd9Sstevel@tonic-gate struct kbtrans_lower kbtrans_lower; /* actual translation state */ 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate /* Read and write queues */ 597c478bd9Sstevel@tonic-gate queue_t *kbtrans_streams_readq; 607c478bd9Sstevel@tonic-gate queue_t *kbtrans_streams_writeq; 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate /* Pending "ioctl" awaiting buffer */ 637c478bd9Sstevel@tonic-gate mblk_t *kbtrans_streams_iocpending; 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate /* Number of times the keyboard overflowed input */ 667c478bd9Sstevel@tonic-gate int kbtrans_overflow_cnt; 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate /* random flags */ 697c478bd9Sstevel@tonic-gate int kbtrans_streams_flags; 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate /* id from qbufcall on allocb failure */ 727c478bd9Sstevel@tonic-gate bufcall_id_t kbtrans_streams_bufcallid; 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate timeout_id_t kbtrans_streams_rptid; /* timeout id for repeat */ 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate int kbtrans_streams_iocerror; /* error return from "ioctl" */ 777c478bd9Sstevel@tonic-gate int kbtrans_streams_translate_mode; /* Translate keycodes? */ 787c478bd9Sstevel@tonic-gate int kbtrans_streams_translatable; /* Keyboard is translatable? */ 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate /* Vuid_id_addrs for various events */ 817c478bd9Sstevel@tonic-gate struct { 827c478bd9Sstevel@tonic-gate short ascii; 837c478bd9Sstevel@tonic-gate short top; 847c478bd9Sstevel@tonic-gate short vkey; 857c478bd9Sstevel@tonic-gate } kbtrans_streams_vuid_addr; 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate /* 887c478bd9Sstevel@tonic-gate * Table of key stations currently down that have 897c478bd9Sstevel@tonic-gate * have firm events that need to be matched with up transitions 907c478bd9Sstevel@tonic-gate * when translation mode is TR_*EVENT 917c478bd9Sstevel@tonic-gate */ 927c478bd9Sstevel@tonic-gate struct key_event *kbtrans_streams_downs; 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate /* Number of down entries */ 957c478bd9Sstevel@tonic-gate int kbtrans_streams_num_downs_entries; /* entries in downs */ 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate /* Bytes allocated for downs */ 987c478bd9Sstevel@tonic-gate uint_t kbtrans_streams_downs_bytes; 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate /* Abort state */ 1017c478bd9Sstevel@tonic-gate enum { 1027c478bd9Sstevel@tonic-gate ABORT_NORMAL, 103e4603304Sqz150045 ABORT_ABORT1_RECEIVED, 104e4603304Sqz150045 NEW_ABORT_ABORT1_RECEIVED /* for new abort key */ 1057c478bd9Sstevel@tonic-gate } kbtrans_streams_abort_state; 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate /* Indicated whether or not abort may be honored */ 1087c478bd9Sstevel@tonic-gate boolean_t kbtrans_streams_abortable; 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate /* 1117c478bd9Sstevel@tonic-gate * During an abort sequence, says which key started the sequence. 1127c478bd9Sstevel@tonic-gate * This is used to support both L1+A and F1+A. 1137c478bd9Sstevel@tonic-gate */ 1147c478bd9Sstevel@tonic-gate kbtrans_key_t kbtrans_streams_abort1_key; 1157c478bd9Sstevel@tonic-gate 116e4603304Sqz150045 /* It is used to support new abort sequence Shift+Pause */ 117e4603304Sqz150045 kbtrans_key_t kbtrans_streams_new_abort1_key; 118e4603304Sqz150045 1197c478bd9Sstevel@tonic-gate /* Functions to be called based on the translation type */ 1207c478bd9Sstevel@tonic-gate struct keyboard_callback *kbtrans_streams_callback; 1217c478bd9Sstevel@tonic-gate 1227c478bd9Sstevel@tonic-gate /* Private structure for the keyboard specific module/driver */ 1237c478bd9Sstevel@tonic-gate struct kbtrans_hardware *kbtrans_streams_hw; 1247c478bd9Sstevel@tonic-gate 1257c478bd9Sstevel@tonic-gate /* Callbacks into the keyboard specific module/driver */ 1267c478bd9Sstevel@tonic-gate struct kbtrans_callbacks *kbtrans_streams_hw_callbacks; 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate /* Keyboard type */ 1297c478bd9Sstevel@tonic-gate int kbtrans_streams_id; 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate /* Buffers to hold characters during the polled mode */ 1327c478bd9Sstevel@tonic-gate char *kbtrans_polled_pending_chars; 1337c478bd9Sstevel@tonic-gate char kbtrans_polled_buf[KBTRANS_POLLED_BUF_SIZE+1]; 134aecfc01dSrui zang - Sun Microsystems - Beijing China 135aecfc01dSrui zang - Sun Microsystems - Beijing China /* vt switch key sequence state */ 136aecfc01dSrui zang - Sun Microsystems - Beijing China enum { 137aecfc01dSrui zang - Sun Microsystems - Beijing China VT_SWITCH_KEY_NONE = 0, 138aecfc01dSrui zang - Sun Microsystems - Beijing China VT_SWITCH_KEY_ALT, /* left Alt key is pressed */ 139aecfc01dSrui zang - Sun Microsystems - Beijing China VT_SWITCH_KEY_ALTGR /* right Alt key is pressed */ 140aecfc01dSrui zang - Sun Microsystems - Beijing China } vt_switch_keystate; 1413bce8c8cSJan Setje-Eilers 1423bce8c8cSJan Setje-Eilers kcondvar_t progressbar_key_abort_cv; 1433bce8c8cSJan Setje-Eilers kmutex_t progressbar_key_abort_lock; 1443bce8c8cSJan Setje-Eilers int progressbar_key_abort_flag; 145*6087c6ddSJan Setje-Eilers kt_did_t progressbar_key_abort_t_did; 1467c478bd9Sstevel@tonic-gate }; 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1497c478bd9Sstevel@tonic-gate } 1507c478bd9Sstevel@tonic-gate #endif 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate #endif /* _KBTRANS_STREAMS_H */ 153