1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _KBTRANS_STREAMS_H 28 #define _KBTRANS_STREAMS_H 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 #include <sys/stream.h> 35 36 #define KBTRANS_POLLED_BUF_SIZE 30 37 38 /* definitions for various state machines */ 39 #define KBTRANS_STREAMS_OPEN 0x00000001 /* keyboard is open for business */ 40 41 #define NO_HARD_RESET 0 /* resets only state struct */ 42 #define HARD_RESET 1 /* resets keyboard and state structure */ 43 44 /* 45 * structure to keep track of currently pressed keys when in 46 * TR_UNTRANS_EVENT mode 47 */ 48 typedef struct key_event { 49 uchar_t key_station; /* Physical key station associated with event */ 50 Firm_event event; /* Event that sent out on down */ 51 } Key_event; 52 53 54 /* state structure for kbtrans_streams */ 55 struct kbtrans { 56 struct kbtrans_lower kbtrans_lower; /* actual translation state */ 57 58 /* Read and write queues */ 59 queue_t *kbtrans_streams_readq; 60 queue_t *kbtrans_streams_writeq; 61 62 /* Pending "ioctl" awaiting buffer */ 63 mblk_t *kbtrans_streams_iocpending; 64 65 /* Number of times the keyboard overflowed input */ 66 int kbtrans_overflow_cnt; 67 68 /* random flags */ 69 int kbtrans_streams_flags; 70 71 /* id from qbufcall on allocb failure */ 72 bufcall_id_t kbtrans_streams_bufcallid; 73 74 unsigned kbtrans_streams_count; 75 timeout_id_t kbtrans_streams_rptid; /* timeout id for repeat */ 76 77 int kbtrans_streams_iocerror; /* error return from "ioctl" */ 78 int kbtrans_streams_translate_mode; /* Translate keycodes? */ 79 int kbtrans_streams_translatable; /* Keyboard is translatable? */ 80 81 /* Vuid_id_addrs for various events */ 82 struct { 83 short ascii; 84 short top; 85 short vkey; 86 } kbtrans_streams_vuid_addr; 87 88 /* 89 * Table of key stations currently down that have 90 * have firm events that need to be matched with up transitions 91 * when translation mode is TR_*EVENT 92 */ 93 struct key_event *kbtrans_streams_downs; 94 95 /* Number of down entries */ 96 int kbtrans_streams_num_downs_entries; /* entries in downs */ 97 98 /* Bytes allocated for downs */ 99 uint_t kbtrans_streams_downs_bytes; 100 101 /* Abort state */ 102 enum { 103 ABORT_NORMAL, 104 ABORT_ABORT1_RECEIVED, 105 NEW_ABORT_ABORT1_RECEIVED /* for new abort key */ 106 } kbtrans_streams_abort_state; 107 108 /* Indicated whether or not abort may be honored */ 109 boolean_t kbtrans_streams_abortable; 110 111 /* 112 * During an abort sequence, says which key started the sequence. 113 * This is used to support both L1+A and F1+A. 114 */ 115 kbtrans_key_t kbtrans_streams_abort1_key; 116 117 /* It is used to support new abort sequence Shift+Pause */ 118 kbtrans_key_t kbtrans_streams_new_abort1_key; 119 120 /* Functions to be called based on the translation type */ 121 struct keyboard_callback *kbtrans_streams_callback; 122 123 /* Private structure for the keyboard specific module/driver */ 124 struct kbtrans_hardware *kbtrans_streams_hw; 125 126 /* Callbacks into the keyboard specific module/driver */ 127 struct kbtrans_callbacks *kbtrans_streams_hw_callbacks; 128 129 /* Keyboard type */ 130 int kbtrans_streams_id; 131 132 /* Buffers to hold characters during the polled mode */ 133 char *kbtrans_polled_pending_chars; 134 char kbtrans_polled_buf[KBTRANS_POLLED_BUF_SIZE+1]; 135 136 /* vt switch key sequence state */ 137 enum { 138 VT_SWITCH_KEY_NONE = 0, 139 VT_SWITCH_KEY_ALT, /* left Alt key is pressed */ 140 VT_SWITCH_KEY_ALTGR /* right Alt key is pressed */ 141 } vt_switch_keystate; 142 143 kcondvar_t progressbar_key_abort_cv; 144 kmutex_t progressbar_key_abort_lock; 145 int progressbar_key_abort_flag; 146 kt_did_t progressbar_key_abort_t_did; 147 }; 148 149 #ifdef __cplusplus 150 } 151 #endif 152 153 #endif /* _KBTRANS_STREAMS_H */ 154