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 5*99d47a04Slq150181 * Common Development and Distribution License (the "License"). 6*99d47a04Slq150181 * 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 */ 21*99d47a04Slq150181 227c478bd9Sstevel@tonic-gate /* 23*99d47a04Slq150181 * Copyright 2006 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 _SYS_CONSKBD_H 287c478bd9Sstevel@tonic-gate #define _SYS_CONSKBD_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #include <sys/types.h> 337c478bd9Sstevel@tonic-gate #include <sys/stream.h> 347c478bd9Sstevel@tonic-gate #include <sys/consdev.h> 357c478bd9Sstevel@tonic-gate #include <sys/kbd.h> 367c478bd9Sstevel@tonic-gate #include <sys/kbtrans.h> 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #ifdef __cplusplus 397c478bd9Sstevel@tonic-gate extern "C" { 407c478bd9Sstevel@tonic-gate #endif 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate /* 437c478bd9Sstevel@tonic-gate * Lower Queue State: 447c478bd9Sstevel@tonic-gate * 457c478bd9Sstevel@tonic-gate * Every physical keyboard has a corresponding STREAMS queue. We call this 467c478bd9Sstevel@tonic-gate * queue lower queue. To describe this kind of queue, we define a structure 477c478bd9Sstevel@tonic-gate * (refer conskbd_lower_queue_t). Every lower queue has a state, transform 487c478bd9Sstevel@tonic-gate * of the state describes the process from a keyborad attached to system to 497c478bd9Sstevel@tonic-gate * the keyboard is plumbed into conskbd or rejected. 507c478bd9Sstevel@tonic-gate * Rule: 517c478bd9Sstevel@tonic-gate * 527c478bd9Sstevel@tonic-gate * 1) LQS_UNINITIALIZED ---> LQS_KIOCTYPE_ACK_PENDING; 537c478bd9Sstevel@tonic-gate * send a KIOCTYPE to lower queue, and then wait response; 547c478bd9Sstevel@tonic-gate * 557c478bd9Sstevel@tonic-gate * 2) LQS_KIOCTYPE_ACK_PENDING ---> LQS_INITIALIZED_LEGACY; 567c478bd9Sstevel@tonic-gate * receive nak to KIOCTYPE, the corresponding keyboard can not 577c478bd9Sstevel@tonic-gate * multiplexed with other keyboards. so the conskbd is bypassed, 587c478bd9Sstevel@tonic-gate * only one keyboard is supported. 597c478bd9Sstevel@tonic-gate * 607c478bd9Sstevel@tonic-gate * 3) LQS_KIOCTYPE_ACK_PENDING ---> LQS_KIOCTRANS_ACK_PENDING; 617c478bd9Sstevel@tonic-gate * receive ack to KIOCTYPE, and send KIOCTRANS to lower queue, 627c478bd9Sstevel@tonic-gate * 637c478bd9Sstevel@tonic-gate * 4) LQS_KIOCTRANS_ACK_PENDING ---> LQS_KIOCLAYOUT_ACK_PENDING; 647c478bd9Sstevel@tonic-gate * receive ack to KIOCTRANS, and send KIOCLAYOUT to lower queue 657c478bd9Sstevel@tonic-gate * 66*99d47a04Slq150181 * 5) LQS_KIOCTRANS_ACK_PENDING ---> Destroy 677c478bd9Sstevel@tonic-gate * receive nak to KIOCTRANS, it is a fatal error so that this 687c478bd9Sstevel@tonic-gate * keyboard is not avilable. destroy the lower queue struct. 697c478bd9Sstevel@tonic-gate * 70*99d47a04Slq150181 * 6) LQS_KIOCLAYOUT_ACK_PENDING ---> LQS_KIOCSLED_ACK_PENDING; 71*99d47a04Slq150181 * receive ack/nak to KIOCLAYOUT, and send KIOCSLED/KIOCGLED to 72*99d47a04Slq150181 * lower queue. 73*99d47a04Slq150181 * 747c478bd9Sstevel@tonic-gate * 7) LQS_KIOCSLED_ACK_PENDING ---> LQS_INITIALIZED 75*99d47a04Slq150181 * receive ack/nak, the keyboard is linked under conskbd, multiplexed 767c478bd9Sstevel@tonic-gate * with other keyboards. 777c478bd9Sstevel@tonic-gate * 787c478bd9Sstevel@tonic-gate * 8) when lower queue is in the state of LQS_INITIALIZED_LEGACY or 797c478bd9Sstevel@tonic-gate * LQS_INITIALIZED, no state transform occures unless the lower 807c478bd9Sstevel@tonic-gate * queue is destroyed. 817c478bd9Sstevel@tonic-gate */ 827c478bd9Sstevel@tonic-gate enum conskbd_lqs_state { 837c478bd9Sstevel@tonic-gate LQS_UNINITIALIZED = 0, 847c478bd9Sstevel@tonic-gate LQS_KIOCTYPE_ACK_PENDING = 1, /* waiting ACK for KIOCTYPE */ 857c478bd9Sstevel@tonic-gate LQS_KIOCTRANS_ACK_PENDING = 2, /* waiting ACK for KIOCTRANS */ 867c478bd9Sstevel@tonic-gate LQS_KIOCLAYOUT_ACK_PENDING = 3, /* waiting ACK for KIOCLAYOUT */ 87*99d47a04Slq150181 LQS_KIOCSLED_ACK_PENDING = 4, /* waiting ACK for KIOCSLED/KIOCGLED */ 887c478bd9Sstevel@tonic-gate LQS_INITIALIZED_LEGACY = 5, /* only one lower legacy keyboard */ 897c478bd9Sstevel@tonic-gate LQS_INITIALIZED = 6 /* virtual keyboard initialized */ 907c478bd9Sstevel@tonic-gate }; 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate struct conskbd_state; 937c478bd9Sstevel@tonic-gate struct conskbd_lower_queue; 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate /* 967c478bd9Sstevel@tonic-gate * state of lower queue. 977c478bd9Sstevel@tonic-gate */ 987c478bd9Sstevel@tonic-gate typedef struct conskbd_lower_queue conskbd_lower_queue_t; 997c478bd9Sstevel@tonic-gate struct conskbd_lower_queue { 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate conskbd_lower_queue_t *lqs_next; 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate queue_t *lqs_queue; /* streams queue of lower driver */ 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate queue_t *lqs_pending_queue; /* queue of pending message from */ 1067c478bd9Sstevel@tonic-gate mblk_t *lqs_pending_plink; /* pending I_PLINK message */ 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate /* state of lower queue */ 1097c478bd9Sstevel@tonic-gate enum conskbd_lqs_state lqs_state; 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate /* polled I/O interface structure of lower keyboard driver */ 1127c478bd9Sstevel@tonic-gate struct cons_polledio *lqs_polledio; 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate /* key status (key-down/key-up) of each key */ 1157c478bd9Sstevel@tonic-gate enum keystate lqs_key_state[KBTRANS_KEYNUMS_MAX]; 1167c478bd9Sstevel@tonic-gate }; 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate /* 1197c478bd9Sstevel@tonic-gate * Pending message structure. 1207c478bd9Sstevel@tonic-gate * 1217c478bd9Sstevel@tonic-gate * Note: 1227c478bd9Sstevel@tonic-gate * When conskbd receives message from its upper module, it has to 1237c478bd9Sstevel@tonic-gate * clone the message and send a copy to each of its lower queues. The 1247c478bd9Sstevel@tonic-gate * conskbd_pending_msg structure is used to track the process of handling 1257c478bd9Sstevel@tonic-gate * this kind of messages. 1267c478bd9Sstevel@tonic-gate */ 1277c478bd9Sstevel@tonic-gate typedef struct conskbd_pending_msg conskbd_pending_msg_t; 1287c478bd9Sstevel@tonic-gate struct conskbd_pending_msg { 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate conskbd_pending_msg_t *kpm_next; 1317c478bd9Sstevel@tonic-gate 1327c478bd9Sstevel@tonic-gate /* the upper queue from which request message is sent out */ 1337c478bd9Sstevel@tonic-gate queue_t *kpm_upper_queue; 1347c478bd9Sstevel@tonic-gate 1357c478bd9Sstevel@tonic-gate mblk_t *kpm_req_msg; /* the message block from upper */ 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate /* message ID and Command Code of the message pointed by kpm_req_msg */ 1387c478bd9Sstevel@tonic-gate uint_t kpm_req_id; 1397c478bd9Sstevel@tonic-gate int kpm_req_cmd; 1407c478bd9Sstevel@tonic-gate 1417c478bd9Sstevel@tonic-gate /* number of request message's copies sent down to lower queues */ 1427c478bd9Sstevel@tonic-gate int kpm_req_nums; 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate /* number of responses to request message received from lower queues */ 1457c478bd9Sstevel@tonic-gate int kpm_resp_nums; 1467c478bd9Sstevel@tonic-gate 1477c478bd9Sstevel@tonic-gate mblk_t *kpm_resp_list; /* chain of responses from lower */ 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate kmutex_t kpm_lock; /* lock for this structure */ 1507c478bd9Sstevel@tonic-gate }; 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate /* 1537c478bd9Sstevel@tonic-gate * software state structure for virtual keyboard 1547c478bd9Sstevel@tonic-gate */ 1557c478bd9Sstevel@tonic-gate struct conskbd_state { 1567c478bd9Sstevel@tonic-gate 1577c478bd9Sstevel@tonic-gate /* kbtrans of virtual keyboard */ 1587c478bd9Sstevel@tonic-gate struct kbtrans *conskbd_kbtrans; 1597c478bd9Sstevel@tonic-gate 1607c478bd9Sstevel@tonic-gate /* polled I/O interface structure of virutal keyboard */ 1617c478bd9Sstevel@tonic-gate struct cons_polledio conskbd_polledio; 1627c478bd9Sstevel@tonic-gate 1637c478bd9Sstevel@tonic-gate /* chain of lower physical keyboard queues */ 1647c478bd9Sstevel@tonic-gate conskbd_lower_queue_t *conskbd_lqueue_list; 1657c478bd9Sstevel@tonic-gate 1667c478bd9Sstevel@tonic-gate /* the number of lower physical keyboard queues */ 1677c478bd9Sstevel@tonic-gate int conskbd_lqueue_nums; 1687c478bd9Sstevel@tonic-gate 1697c478bd9Sstevel@tonic-gate int conskbd_layout; /* layout of virtual keyboard */ 1707c478bd9Sstevel@tonic-gate int conskbd_led_state; /* LED state of virtual keyboard */ 1717c478bd9Sstevel@tonic-gate 1727c478bd9Sstevel@tonic-gate boolean_t conskbd_directio; /* upstream directory */ 1737c478bd9Sstevel@tonic-gate boolean_t conskbd_bypassed; /* is virtual keyboard disabled ? */ 1747c478bd9Sstevel@tonic-gate }; 1757c478bd9Sstevel@tonic-gate typedef struct conskbd_state conskbd_state_t; 1767c478bd9Sstevel@tonic-gate 1777c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1787c478bd9Sstevel@tonic-gate } 1797c478bd9Sstevel@tonic-gate #endif 1807c478bd9Sstevel@tonic-gate 1817c478bd9Sstevel@tonic-gate #endif /* _SYS_CONSKBD_H */ 182