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