10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51253Slq150181 * Common Development and Distribution License (the "License"). 61253Slq150181 * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 211253Slq150181 220Sstevel@tonic-gate /* 23*10064SJames.Anderson@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #ifndef _SYS_CONSDEV_H 280Sstevel@tonic-gate #define _SYS_CONSDEV_H 290Sstevel@tonic-gate 300Sstevel@tonic-gate #include <sys/isa_defs.h> 310Sstevel@tonic-gate #include <sys/dditypes.h> 320Sstevel@tonic-gate 330Sstevel@tonic-gate #ifdef __cplusplus 340Sstevel@tonic-gate extern "C" { 350Sstevel@tonic-gate #endif 360Sstevel@tonic-gate 371253Slq150181 380Sstevel@tonic-gate #if defined(_KERNEL) || defined(_KMDB) 390Sstevel@tonic-gate 400Sstevel@tonic-gate /* 410Sstevel@tonic-gate * Paths to console devices 420Sstevel@tonic-gate */ 430Sstevel@tonic-gate #define CONSKBD_PATH "/pseudo/conskbd@0:conskbd" 440Sstevel@tonic-gate #define CONSMS_PATH "/pseudo/consms@0:mouse" 450Sstevel@tonic-gate #define WC_PATH "/pseudo/wc@0:wscons" 460Sstevel@tonic-gate #define IWSCN_PATH "/pseudo/iwscn@0:iwscn" 470Sstevel@tonic-gate #define CVC_PATH "/pseudo/cvc@0:cvc" 480Sstevel@tonic-gate 490Sstevel@tonic-gate /* 500Sstevel@tonic-gate * Console redirection. 510Sstevel@tonic-gate */ 520Sstevel@tonic-gate extern dev_t rconsdev; /* real (underlying) console */ 530Sstevel@tonic-gate extern struct vnode *rconsvp; /* pointer to vnode for that device */ 540Sstevel@tonic-gate 550Sstevel@tonic-gate /* 56*10064SJames.Anderson@Sun.COM * Virtual Serial Console redirection. 57*10064SJames.Anderson@Sun.COM */ 58*10064SJames.Anderson@Sun.COM extern struct vnode *vsconsvp; /* pointer to vnode for virtual console */ 59*10064SJames.Anderson@Sun.COM 60*10064SJames.Anderson@Sun.COM /* 610Sstevel@tonic-gate * Mouse, keyboard, and frame buffer configuration information. 620Sstevel@tonic-gate * 630Sstevel@tonic-gate * XXX: Assumes a single mouse/keyboard/frame buffer triple. 640Sstevel@tonic-gate */ 650Sstevel@tonic-gate extern dev_t mousedev; /* default mouse device */ 660Sstevel@tonic-gate extern dev_t kbddev; /* default (actual) keyboard device */ 670Sstevel@tonic-gate extern dev_t stdindev; /* default standard input device */ 680Sstevel@tonic-gate extern dev_t fbdev; /* default framebuffer device */ 690Sstevel@tonic-gate extern struct vnode *fbvp; /* pointer to vnode for that device */ 700Sstevel@tonic-gate extern dev_info_t *fbdip; /* pointer to dev_info for fbdev (optional) */ 710Sstevel@tonic-gate 721253Slq150181 extern int consmode; /* CONS_FW or CONS_KFB */ 731253Slq150181 extern int cons_tem_disable; 741253Slq150181 #define CONS_FW 0 751253Slq150181 #define CONS_KFB 1 761253Slq150181 770Sstevel@tonic-gate /* 780Sstevel@tonic-gate * Workstation console redirection. 790Sstevel@tonic-gate * 800Sstevel@tonic-gate * The workstation console device is the multiplexor that hooks keyboard and 810Sstevel@tonic-gate * frame buffer together into a single tty-like device. Access to it is 820Sstevel@tonic-gate * through the redirecting driver, so that frame buffer output can be 830Sstevel@tonic-gate * redirected to other devices. wsconsvp names the redirecting access point, 840Sstevel@tonic-gate * and rwsconsvp names the workstation console itself. 850Sstevel@tonic-gate * 860Sstevel@tonic-gate * XXX: Assumes a single workstation console. 870Sstevel@tonic-gate */ 880Sstevel@tonic-gate extern struct vnode *wsconsvp; /* vnode for redirecting ws cons access */ 890Sstevel@tonic-gate extern struct vnode *rwsconsvp; /* vnode for underlying workstation console */ 900Sstevel@tonic-gate 910Sstevel@tonic-gate /* 920Sstevel@tonic-gate * Generic console ioctls. 930Sstevel@tonic-gate * 940Sstevel@tonic-gate * On systems without OBP, all potential console devices should implement these. 950Sstevel@tonic-gate * 960Sstevel@tonic-gate * On systems with OBP, all potential console devices should implement 970Sstevel@tonic-gate * the ABORTENABLE ioctls. All potential console devices that cannot share 980Sstevel@tonic-gate * their hardware with OBP should implement the POLLEDIO ioctls. 990Sstevel@tonic-gate */ 1000Sstevel@tonic-gate #define _CONSIOC (('C'<<24)|('O'<<16)|('N'<<8)) 1010Sstevel@tonic-gate 1020Sstevel@tonic-gate /* 1030Sstevel@tonic-gate * Get the structure of function pointers to be used for polled I/O 1040Sstevel@tonic-gate * 1050Sstevel@tonic-gate * struct cons_polledio *polledio; 1060Sstevel@tonic-gate * struct strioctl str; 1070Sstevel@tonic-gate * 1080Sstevel@tonic-gate * str.ic_cmd = CONS_OPENPOLLEDIO; 1090Sstevel@tonic-gate * str.ic_timout = INFTIM; 1100Sstevel@tonic-gate * str.ic_len = sizeof (polledio); 1110Sstevel@tonic-gate * str.ic_dp = (char *)&polledio; 1120Sstevel@tonic-gate * ioctl(fd, I_STR, &str); 1130Sstevel@tonic-gate */ 1140Sstevel@tonic-gate #define CONSOPENPOLLEDIO (_CONSIOC|0) 1150Sstevel@tonic-gate 1160Sstevel@tonic-gate /* 1170Sstevel@tonic-gate * Get the current state of abort enable 1180Sstevel@tonic-gate * enable = ioctl(fd, CONSGETABORTENABLE, 0) 1190Sstevel@tonic-gate */ 1200Sstevel@tonic-gate #define CONSGETABORTENABLE (_CONSIOC|1) 1210Sstevel@tonic-gate 1220Sstevel@tonic-gate /* 1230Sstevel@tonic-gate * Set the current state of abort enable 1240Sstevel@tonic-gate * ioctl(fd, CONSSETABORTENABLE, boolean_t) 1250Sstevel@tonic-gate */ 1260Sstevel@tonic-gate #define CONSSETABORTENABLE (_CONSIOC|2) 1270Sstevel@tonic-gate 1280Sstevel@tonic-gate /* 1290Sstevel@tonic-gate * Undo anything that was done with CONSOPENPOLLEDIO 1300Sstevel@tonic-gate * ioctl(fd, CONSCLOSEPOLLEDIO, 0) 1310Sstevel@tonic-gate */ 1320Sstevel@tonic-gate #define CONSCLOSEPOLLEDIO (_CONSIOC|3) 1330Sstevel@tonic-gate 1340Sstevel@tonic-gate /* 1350Sstevel@tonic-gate * Set the type simulated by hardwares 1360Sstevel@tonic-gate * ioctl(fd, CONSSETKBDTYPE, kbdtype) 1370Sstevel@tonic-gate * kbdtype: 1380Sstevel@tonic-gate * KB_PC or KB_USB 1390Sstevel@tonic-gate */ 1400Sstevel@tonic-gate #define CONSSETKBDTYPE (_CONSIOC|4) 1410Sstevel@tonic-gate 1420Sstevel@tonic-gate #define CONSPOLLEDIO_V0 0 1430Sstevel@tonic-gate #define CONSPOLLEDIO_V1 1 1440Sstevel@tonic-gate 1450Sstevel@tonic-gate typedef int kbtrans_key_t; 1460Sstevel@tonic-gate 1470Sstevel@tonic-gate enum keystate { KEY_PRESSED = 0, KEY_RELEASED = 1 }; 1480Sstevel@tonic-gate 1490Sstevel@tonic-gate 1500Sstevel@tonic-gate /* 1510Sstevel@tonic-gate * Opaque state structure for driver state. Each driver has its own 1520Sstevel@tonic-gate * implementation (with different names!), and casts to/from this. 1530Sstevel@tonic-gate * This allows better type-checking than "void *", helping to ensure 1540Sstevel@tonic-gate * that the structure passed in is the structure used in the callback. 1550Sstevel@tonic-gate */ 1561762Slt200341 typedef struct __cons_polledio_arg *cons_polledio_arg_t; 1570Sstevel@tonic-gate 1580Sstevel@tonic-gate /* 1590Sstevel@tonic-gate * This is the structure that is used to handle polled I/O. It is filled 1600Sstevel@tonic-gate * in by a lower driver, passed up, and eventually registered with the 1610Sstevel@tonic-gate * debugger that needs to do polled I/O. 1620Sstevel@tonic-gate */ 1630Sstevel@tonic-gate typedef struct cons_polledio { 1640Sstevel@tonic-gate 1650Sstevel@tonic-gate /* 1660Sstevel@tonic-gate * version of this structure 1670Sstevel@tonic-gate */ 1680Sstevel@tonic-gate unsigned cons_polledio_version; 1690Sstevel@tonic-gate 1700Sstevel@tonic-gate /* 1710Sstevel@tonic-gate * Argument that is passed to the following routines. 1720Sstevel@tonic-gate */ 1731762Slt200341 cons_polledio_arg_t cons_polledio_argument; 1740Sstevel@tonic-gate 1750Sstevel@tonic-gate /* 1760Sstevel@tonic-gate * Pointer to the routine and its argument that handles putting 1770Sstevel@tonic-gate * characters out to the polled device. 1780Sstevel@tonic-gate */ 1791762Slt200341 void (*cons_polledio_putchar)(cons_polledio_arg_t, 1800Sstevel@tonic-gate uchar_t); 1810Sstevel@tonic-gate 1820Sstevel@tonic-gate /* 1830Sstevel@tonic-gate * Pointer to the routine and its argument that handles getting 1840Sstevel@tonic-gate * characters from the polled device. This routine is blocking. 1850Sstevel@tonic-gate */ 1861762Slt200341 int (*cons_polledio_getchar)(cons_polledio_arg_t); 1870Sstevel@tonic-gate 1880Sstevel@tonic-gate /* 1890Sstevel@tonic-gate * Pointer to the routine and its argument that checks to see 1900Sstevel@tonic-gate * if a character is pending input. This routine is non-blocking. 1910Sstevel@tonic-gate */ 1921762Slt200341 boolean_t (*cons_polledio_ischar)(cons_polledio_arg_t); 1930Sstevel@tonic-gate 1940Sstevel@tonic-gate /* 1950Sstevel@tonic-gate * Initialize the polled subsystem. This routine is called once 1960Sstevel@tonic-gate * per mode change from non-polled to polled mode. 1970Sstevel@tonic-gate */ 1981762Slt200341 void (*cons_polledio_enter)(cons_polledio_arg_t); 1990Sstevel@tonic-gate 2000Sstevel@tonic-gate /* 2010Sstevel@tonic-gate * Restore the non-polled subsystem. This routine is called once 2020Sstevel@tonic-gate * per mode change from non-polled to polled mode. 2030Sstevel@tonic-gate */ 2041762Slt200341 void (*cons_polledio_exit)(cons_polledio_arg_t); 2050Sstevel@tonic-gate 2060Sstevel@tonic-gate 2070Sstevel@tonic-gate /* Routine to set the LED's in polled mode */ 2081762Slt200341 void (*cons_polledio_setled)(cons_polledio_arg_t, int); 2090Sstevel@tonic-gate 2100Sstevel@tonic-gate /* Routine to indicate that a scande is available in polled mode */ 2110Sstevel@tonic-gate boolean_t (*cons_polledio_keycheck)( 2121762Slt200341 cons_polledio_arg_t, 2130Sstevel@tonic-gate kbtrans_key_t *, enum keystate *); 2140Sstevel@tonic-gate } cons_polledio_t; 2150Sstevel@tonic-gate 2160Sstevel@tonic-gate extern cons_polledio_t *cons_polledio; 2170Sstevel@tonic-gate 2180Sstevel@tonic-gate /* 2190Sstevel@tonic-gate * Workstation Console 2200Sstevel@tonic-gate */ 2210Sstevel@tonic-gate #define _WCIOC (('W'<<24)|('C'<<16)) 2220Sstevel@tonic-gate #define WC_OPEN_FB (_WCIOC | 0) 2230Sstevel@tonic-gate #define WC_CLOSE_FB (_WCIOC | 1) 2240Sstevel@tonic-gate 2250Sstevel@tonic-gate #endif /* _KERNEL || _KMDB */ 2260Sstevel@tonic-gate 2270Sstevel@tonic-gate #ifdef __cplusplus 2280Sstevel@tonic-gate } 2290Sstevel@tonic-gate #endif 2300Sstevel@tonic-gate 2310Sstevel@tonic-gate #endif /* _SYS_CONSDEV_H */ 232