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