1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _SYS_CONSDEV_H 28*0Sstevel@tonic-gate #define _SYS_CONSDEV_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #include <sys/isa_defs.h> 33*0Sstevel@tonic-gate #include <sys/dditypes.h> 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gate #ifdef __cplusplus 36*0Sstevel@tonic-gate extern "C" { 37*0Sstevel@tonic-gate #endif 38*0Sstevel@tonic-gate 39*0Sstevel@tonic-gate #if defined(_KERNEL) || defined(_KMDB) 40*0Sstevel@tonic-gate 41*0Sstevel@tonic-gate /* 42*0Sstevel@tonic-gate * Paths to console devices 43*0Sstevel@tonic-gate */ 44*0Sstevel@tonic-gate #define CONSKBD_PATH "/pseudo/conskbd@0:conskbd" 45*0Sstevel@tonic-gate #define CONSMS_PATH "/pseudo/consms@0:mouse" 46*0Sstevel@tonic-gate #define WC_PATH "/pseudo/wc@0:wscons" 47*0Sstevel@tonic-gate #define IWSCN_PATH "/pseudo/iwscn@0:iwscn" 48*0Sstevel@tonic-gate #define CVC_PATH "/pseudo/cvc@0:cvc" 49*0Sstevel@tonic-gate 50*0Sstevel@tonic-gate /* 51*0Sstevel@tonic-gate * Console redirection. 52*0Sstevel@tonic-gate */ 53*0Sstevel@tonic-gate extern dev_t rconsdev; /* real (underlying) console */ 54*0Sstevel@tonic-gate extern struct vnode *rconsvp; /* pointer to vnode for that device */ 55*0Sstevel@tonic-gate 56*0Sstevel@tonic-gate /* 57*0Sstevel@tonic-gate * Mouse, keyboard, and frame buffer configuration information. 58*0Sstevel@tonic-gate * 59*0Sstevel@tonic-gate * XXX: Assumes a single mouse/keyboard/frame buffer triple. 60*0Sstevel@tonic-gate */ 61*0Sstevel@tonic-gate extern dev_t mousedev; /* default mouse device */ 62*0Sstevel@tonic-gate extern dev_t kbddev; /* default (actual) keyboard device */ 63*0Sstevel@tonic-gate extern dev_t stdindev; /* default standard input device */ 64*0Sstevel@tonic-gate extern dev_t fbdev; /* default framebuffer device */ 65*0Sstevel@tonic-gate extern struct vnode *fbvp; /* pointer to vnode for that device */ 66*0Sstevel@tonic-gate extern dev_info_t *fbdip; /* pointer to dev_info for fbdev (optional) */ 67*0Sstevel@tonic-gate 68*0Sstevel@tonic-gate /* 69*0Sstevel@tonic-gate * Workstation console redirection. 70*0Sstevel@tonic-gate * 71*0Sstevel@tonic-gate * The workstation console device is the multiplexor that hooks keyboard and 72*0Sstevel@tonic-gate * frame buffer together into a single tty-like device. Access to it is 73*0Sstevel@tonic-gate * through the redirecting driver, so that frame buffer output can be 74*0Sstevel@tonic-gate * redirected to other devices. wsconsvp names the redirecting access point, 75*0Sstevel@tonic-gate * and rwsconsvp names the workstation console itself. 76*0Sstevel@tonic-gate * 77*0Sstevel@tonic-gate * XXX: Assumes a single workstation console. 78*0Sstevel@tonic-gate */ 79*0Sstevel@tonic-gate extern struct vnode *wsconsvp; /* vnode for redirecting ws cons access */ 80*0Sstevel@tonic-gate extern struct vnode *rwsconsvp; /* vnode for underlying workstation console */ 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gate extern int cn_conf; 83*0Sstevel@tonic-gate 84*0Sstevel@tonic-gate /* 85*0Sstevel@tonic-gate * Generic console ioctls. 86*0Sstevel@tonic-gate * 87*0Sstevel@tonic-gate * On systems without OBP, all potential console devices should implement these. 88*0Sstevel@tonic-gate * 89*0Sstevel@tonic-gate * On systems with OBP, all potential console devices should implement 90*0Sstevel@tonic-gate * the ABORTENABLE ioctls. All potential console devices that cannot share 91*0Sstevel@tonic-gate * their hardware with OBP should implement the POLLEDIO ioctls. 92*0Sstevel@tonic-gate */ 93*0Sstevel@tonic-gate #define _CONSIOC (('C'<<24)|('O'<<16)|('N'<<8)) 94*0Sstevel@tonic-gate 95*0Sstevel@tonic-gate /* 96*0Sstevel@tonic-gate * Get the structure of function pointers to be used for polled I/O 97*0Sstevel@tonic-gate * 98*0Sstevel@tonic-gate * struct cons_polledio *polledio; 99*0Sstevel@tonic-gate * struct strioctl str; 100*0Sstevel@tonic-gate * 101*0Sstevel@tonic-gate * str.ic_cmd = CONS_OPENPOLLEDIO; 102*0Sstevel@tonic-gate * str.ic_timout = INFTIM; 103*0Sstevel@tonic-gate * str.ic_len = sizeof (polledio); 104*0Sstevel@tonic-gate * str.ic_dp = (char *)&polledio; 105*0Sstevel@tonic-gate * ioctl(fd, I_STR, &str); 106*0Sstevel@tonic-gate */ 107*0Sstevel@tonic-gate #define CONSOPENPOLLEDIO (_CONSIOC|0) 108*0Sstevel@tonic-gate 109*0Sstevel@tonic-gate /* 110*0Sstevel@tonic-gate * Get the current state of abort enable 111*0Sstevel@tonic-gate * enable = ioctl(fd, CONSGETABORTENABLE, 0) 112*0Sstevel@tonic-gate */ 113*0Sstevel@tonic-gate #define CONSGETABORTENABLE (_CONSIOC|1) 114*0Sstevel@tonic-gate 115*0Sstevel@tonic-gate /* 116*0Sstevel@tonic-gate * Set the current state of abort enable 117*0Sstevel@tonic-gate * ioctl(fd, CONSSETABORTENABLE, boolean_t) 118*0Sstevel@tonic-gate */ 119*0Sstevel@tonic-gate #define CONSSETABORTENABLE (_CONSIOC|2) 120*0Sstevel@tonic-gate 121*0Sstevel@tonic-gate /* 122*0Sstevel@tonic-gate * Undo anything that was done with CONSOPENPOLLEDIO 123*0Sstevel@tonic-gate * ioctl(fd, CONSCLOSEPOLLEDIO, 0) 124*0Sstevel@tonic-gate */ 125*0Sstevel@tonic-gate #define CONSCLOSEPOLLEDIO (_CONSIOC|3) 126*0Sstevel@tonic-gate 127*0Sstevel@tonic-gate /* 128*0Sstevel@tonic-gate * Set the type simulated by hardwares 129*0Sstevel@tonic-gate * ioctl(fd, CONSSETKBDTYPE, kbdtype) 130*0Sstevel@tonic-gate * kbdtype: 131*0Sstevel@tonic-gate * KB_PC or KB_USB 132*0Sstevel@tonic-gate */ 133*0Sstevel@tonic-gate #define CONSSETKBDTYPE (_CONSIOC|4) 134*0Sstevel@tonic-gate 135*0Sstevel@tonic-gate #define CONSPOLLEDIO_V0 0 136*0Sstevel@tonic-gate #define CONSPOLLEDIO_V1 1 137*0Sstevel@tonic-gate 138*0Sstevel@tonic-gate typedef int kbtrans_key_t; 139*0Sstevel@tonic-gate 140*0Sstevel@tonic-gate enum keystate { KEY_PRESSED = 0, KEY_RELEASED = 1 }; 141*0Sstevel@tonic-gate 142*0Sstevel@tonic-gate 143*0Sstevel@tonic-gate /* 144*0Sstevel@tonic-gate * Opaque state structure for driver state. Each driver has its own 145*0Sstevel@tonic-gate * implementation (with different names!), and casts to/from this. 146*0Sstevel@tonic-gate * This allows better type-checking than "void *", helping to ensure 147*0Sstevel@tonic-gate * that the structure passed in is the structure used in the callback. 148*0Sstevel@tonic-gate */ 149*0Sstevel@tonic-gate struct cons_polledio_arg; 150*0Sstevel@tonic-gate typedef struct cons_polledio_arg *cons_polledio_arg_t; 151*0Sstevel@tonic-gate 152*0Sstevel@tonic-gate /* 153*0Sstevel@tonic-gate * This is the structure that is used to handle polled I/O. It is filled 154*0Sstevel@tonic-gate * in by a lower driver, passed up, and eventually registered with the 155*0Sstevel@tonic-gate * debugger that needs to do polled I/O. 156*0Sstevel@tonic-gate */ 157*0Sstevel@tonic-gate typedef struct cons_polledio { 158*0Sstevel@tonic-gate 159*0Sstevel@tonic-gate /* 160*0Sstevel@tonic-gate * version of this structure 161*0Sstevel@tonic-gate */ 162*0Sstevel@tonic-gate unsigned cons_polledio_version; 163*0Sstevel@tonic-gate 164*0Sstevel@tonic-gate /* 165*0Sstevel@tonic-gate * Argument that is passed to the following routines. 166*0Sstevel@tonic-gate */ 167*0Sstevel@tonic-gate struct cons_polledio_arg *cons_polledio_argument; 168*0Sstevel@tonic-gate 169*0Sstevel@tonic-gate /* 170*0Sstevel@tonic-gate * Pointer to the routine and its argument that handles putting 171*0Sstevel@tonic-gate * characters out to the polled device. 172*0Sstevel@tonic-gate */ 173*0Sstevel@tonic-gate void (*cons_polledio_putchar)(struct cons_polledio_arg *, 174*0Sstevel@tonic-gate uchar_t); 175*0Sstevel@tonic-gate 176*0Sstevel@tonic-gate /* 177*0Sstevel@tonic-gate * Pointer to the routine and its argument that handles getting 178*0Sstevel@tonic-gate * characters from the polled device. This routine is blocking. 179*0Sstevel@tonic-gate */ 180*0Sstevel@tonic-gate int (*cons_polledio_getchar)(struct cons_polledio_arg *); 181*0Sstevel@tonic-gate 182*0Sstevel@tonic-gate /* 183*0Sstevel@tonic-gate * Pointer to the routine and its argument that checks to see 184*0Sstevel@tonic-gate * if a character is pending input. This routine is non-blocking. 185*0Sstevel@tonic-gate */ 186*0Sstevel@tonic-gate boolean_t (*cons_polledio_ischar)(struct cons_polledio_arg *); 187*0Sstevel@tonic-gate 188*0Sstevel@tonic-gate /* 189*0Sstevel@tonic-gate * Initialize the polled subsystem. This routine is called once 190*0Sstevel@tonic-gate * per mode change from non-polled to polled mode. 191*0Sstevel@tonic-gate */ 192*0Sstevel@tonic-gate void (*cons_polledio_enter)(struct cons_polledio_arg *); 193*0Sstevel@tonic-gate 194*0Sstevel@tonic-gate /* 195*0Sstevel@tonic-gate * Restore the non-polled subsystem. This routine is called once 196*0Sstevel@tonic-gate * per mode change from non-polled to polled mode. 197*0Sstevel@tonic-gate */ 198*0Sstevel@tonic-gate void (*cons_polledio_exit)(struct cons_polledio_arg *); 199*0Sstevel@tonic-gate 200*0Sstevel@tonic-gate 201*0Sstevel@tonic-gate /* Routine to set the LED's in polled mode */ 202*0Sstevel@tonic-gate void (*cons_polledio_setled)(struct cons_polledio_arg *, int); 203*0Sstevel@tonic-gate 204*0Sstevel@tonic-gate /* Routine to indicate that a scande is available in polled mode */ 205*0Sstevel@tonic-gate boolean_t (*cons_polledio_keycheck)( 206*0Sstevel@tonic-gate struct cons_polledio_arg *, 207*0Sstevel@tonic-gate kbtrans_key_t *, enum keystate *); 208*0Sstevel@tonic-gate } cons_polledio_t; 209*0Sstevel@tonic-gate 210*0Sstevel@tonic-gate extern cons_polledio_t *cons_polledio; 211*0Sstevel@tonic-gate 212*0Sstevel@tonic-gate /* 213*0Sstevel@tonic-gate * Workstation Console 214*0Sstevel@tonic-gate */ 215*0Sstevel@tonic-gate #define _WCIOC (('W'<<24)|('C'<<16)) 216*0Sstevel@tonic-gate #if defined(_CONSOLE_OUTPUT_VIA_SOFTWARE) 217*0Sstevel@tonic-gate #define WC_OPEN_FB (_WCIOC | 0) 218*0Sstevel@tonic-gate #define WC_CLOSE_FB (_WCIOC | 1) 219*0Sstevel@tonic-gate #endif 220*0Sstevel@tonic-gate 221*0Sstevel@tonic-gate #endif /* _KERNEL || _KMDB */ 222*0Sstevel@tonic-gate 223*0Sstevel@tonic-gate #ifdef __cplusplus 224*0Sstevel@tonic-gate } 225*0Sstevel@tonic-gate #endif 226*0Sstevel@tonic-gate 227*0Sstevel@tonic-gate #endif /* _SYS_CONSDEV_H */ 228