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*fea9cb91Slq150181 * Common Development and Distribution License (the "License"). 6*fea9cb91Slq150181 * 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*fea9cb91Slq150181 227c478bd9Sstevel@tonic-gate /* 23*fea9cb91Slq150181 * 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_VISUAL_IO_H 287c478bd9Sstevel@tonic-gate #define _SYS_VISUAL_IO_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #ifdef __cplusplus 337c478bd9Sstevel@tonic-gate extern "C" { 347c478bd9Sstevel@tonic-gate #endif 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #define VIOC ('V' << 8) 377c478bd9Sstevel@tonic-gate #define VIOCF ('F' << 8) 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate /* 417c478bd9Sstevel@tonic-gate * Device Identification 427c478bd9Sstevel@tonic-gate * 437c478bd9Sstevel@tonic-gate * VIS_GETIDENTIFIER returns an identifier string to uniquely identify 447c478bd9Sstevel@tonic-gate * a device type used in the Solaris VISUAL environment. The identifier 457c478bd9Sstevel@tonic-gate * must be unique. We suggest the convention: 467c478bd9Sstevel@tonic-gate * 477c478bd9Sstevel@tonic-gate * <companysymbol><devicetype> 487c478bd9Sstevel@tonic-gate * 497c478bd9Sstevel@tonic-gate * for example: SUNWcg6 507c478bd9Sstevel@tonic-gate */ 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate #define VIS_MAXNAMELEN 128 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate struct vis_identifier { 557c478bd9Sstevel@tonic-gate char name[VIS_MAXNAMELEN]; /* <companysymbol><devicename> */ 567c478bd9Sstevel@tonic-gate }; 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate #define VIS_GETIDENTIFIER (VIOC | 0) 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate /* 637c478bd9Sstevel@tonic-gate * Hardware Cursor Control 647c478bd9Sstevel@tonic-gate * 657c478bd9Sstevel@tonic-gate * Devices with hardware cursors may implement these ioctls in their 667c478bd9Sstevel@tonic-gate * kernel device drivers. 677c478bd9Sstevel@tonic-gate */ 687c478bd9Sstevel@tonic-gate 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate struct vis_cursorpos { 717c478bd9Sstevel@tonic-gate short x; /* cursor x coordinate */ 727c478bd9Sstevel@tonic-gate short y; /* cursor y coordinate */ 737c478bd9Sstevel@tonic-gate }; 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate struct vis_cursorcmap { 767c478bd9Sstevel@tonic-gate int version; /* version */ 777c478bd9Sstevel@tonic-gate int reserved; 787c478bd9Sstevel@tonic-gate unsigned char *red; /* red color map elements */ 797c478bd9Sstevel@tonic-gate unsigned char *green; /* green color map elements */ 807c478bd9Sstevel@tonic-gate unsigned char *blue; /* blue color map elements */ 817c478bd9Sstevel@tonic-gate }; 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate /* 857c478bd9Sstevel@tonic-gate * These ioctls fetch and set various cursor attributes, using the 867c478bd9Sstevel@tonic-gate * vis_cursor struct. 877c478bd9Sstevel@tonic-gate */ 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate #define VIS_SETCURSOR (VIOCF|24) 907c478bd9Sstevel@tonic-gate #define VIS_GETCURSOR (VIOCF|25) 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate struct vis_cursor { 937c478bd9Sstevel@tonic-gate short set; /* what to set */ 947c478bd9Sstevel@tonic-gate short enable; /* cursor on/off */ 957c478bd9Sstevel@tonic-gate struct vis_cursorpos pos; /* cursor position */ 967c478bd9Sstevel@tonic-gate struct vis_cursorpos hot; /* cursor hot spot */ 977c478bd9Sstevel@tonic-gate struct vis_cursorcmap cmap; /* color map info */ 987c478bd9Sstevel@tonic-gate struct vis_cursorpos size; /* cursor bit map size */ 997c478bd9Sstevel@tonic-gate char *image; /* cursor image bits */ 1007c478bd9Sstevel@tonic-gate char *mask; /* cursor mask bits */ 1017c478bd9Sstevel@tonic-gate }; 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate #define VIS_CURSOR_SETCURSOR 0x01 /* set cursor */ 1047c478bd9Sstevel@tonic-gate #define VIS_CURSOR_SETPOSITION 0x02 /* set cursor position */ 1057c478bd9Sstevel@tonic-gate #define VIS_CURSOR_SETHOTSPOT 0x04 /* set cursor hot spot */ 1067c478bd9Sstevel@tonic-gate #define VIS_CURSOR_SETCOLORMAP 0x08 /* set cursor colormap */ 1077c478bd9Sstevel@tonic-gate #define VIS_CURSOR_SETSHAPE 0x10 /* set cursor shape */ 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate #define VIS_CURSOR_SETALL (VIS_CURSOR_SETCURSOR | \ 1107c478bd9Sstevel@tonic-gate VIS_CURSOR_SETPOSITION | \ 1117c478bd9Sstevel@tonic-gate VIS_CURSOR_SETHOTSPOT | \ 1127c478bd9Sstevel@tonic-gate VIS_CURSOR_SETCOLORMAP | \ 1137c478bd9Sstevel@tonic-gate VIS_CURSOR_SETSHAPE) 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate /* 1177c478bd9Sstevel@tonic-gate * These ioctls fetch and move the current cursor position, using the 1187c478bd9Sstevel@tonic-gate * vis_cursorposition struct. 1197c478bd9Sstevel@tonic-gate */ 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate #define VIS_MOVECURSOR (VIOCF|26) 1227c478bd9Sstevel@tonic-gate #define VIS_GETCURSORPOS (VIOCF|27) 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate /* 1257c478bd9Sstevel@tonic-gate * VIS_SETCMAP: 1267c478bd9Sstevel@tonic-gate * VIS_GETCMAP: 1277c478bd9Sstevel@tonic-gate * Set/Get the indicated color map entries. The index states the first 1287c478bd9Sstevel@tonic-gate * color to be update and count specifies the number of entries to be 1297c478bd9Sstevel@tonic-gate * updated from index. red, green, and blue are arrays of color 1307c478bd9Sstevel@tonic-gate * values. The length of the arrays is count. 1317c478bd9Sstevel@tonic-gate */ 1327c478bd9Sstevel@tonic-gate #define VIS_GETCMAP (VIOC|9) 1337c478bd9Sstevel@tonic-gate #define VIS_PUTCMAP (VIOC|10) 134*fea9cb91Slq150181 struct vis_cmap { 1357c478bd9Sstevel@tonic-gate int index; /* Index into colormap to start updating */ 1367c478bd9Sstevel@tonic-gate int count; /* Number of entries to update */ 1377c478bd9Sstevel@tonic-gate unsigned char *red; /* List of red values */ 1387c478bd9Sstevel@tonic-gate unsigned char *green; /* List of green values */ 1397c478bd9Sstevel@tonic-gate unsigned char *blue; /* List of blue values */ 1407c478bd9Sstevel@tonic-gate }; 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate 1437c478bd9Sstevel@tonic-gate #ifdef _KERNEL 1447c478bd9Sstevel@tonic-gate /* 1457c478bd9Sstevel@tonic-gate * The following ioctls are used for communication between the layered 1467c478bd9Sstevel@tonic-gate * device and the framebuffer. The layered driver calls the framebuffer 1477c478bd9Sstevel@tonic-gate * with these ioctls. 1487c478bd9Sstevel@tonic-gate * 1497c478bd9Sstevel@tonic-gate * On machines that don't have a prom, kmdb uses the kernel to display 1507c478bd9Sstevel@tonic-gate * characters. The kernel in turn will use the routines returned by 1517c478bd9Sstevel@tonic-gate * VIS_DEVINIT to ask the framebuffer driver to display the data. The 1527c478bd9Sstevel@tonic-gate * framebuffer driver CANNOT use any DDI services to display this data. It 1537c478bd9Sstevel@tonic-gate * must just dump the data to the framebuffer. In particular, the mutex and 1547c478bd9Sstevel@tonic-gate * copy routines do not work. 1557c478bd9Sstevel@tonic-gate * 1567c478bd9Sstevel@tonic-gate * On machines without a prom, the framebuffer driver must implement all 1577c478bd9Sstevel@tonic-gate * of these ioctls to be a console. On machines with a prom, the 1587c478bd9Sstevel@tonic-gate * framebuffer driver can set vis_devinit.polledio to NULL. 1597c478bd9Sstevel@tonic-gate */ 1607c478bd9Sstevel@tonic-gate typedef short screen_pos_t; 1617c478bd9Sstevel@tonic-gate typedef short screen_size_t; 1627c478bd9Sstevel@tonic-gate 1637c478bd9Sstevel@tonic-gate /* 1647c478bd9Sstevel@tonic-gate * Union of pixel depths 1657c478bd9Sstevel@tonic-gate */ 1667c478bd9Sstevel@tonic-gate typedef union { 1677c478bd9Sstevel@tonic-gate unsigned char mono; /* one-bit */ 1687c478bd9Sstevel@tonic-gate unsigned char four; /* four bit */ 1697c478bd9Sstevel@tonic-gate unsigned char eight; /* eight bit */ 1707c478bd9Sstevel@tonic-gate unsigned char twentyfour[3]; /* 24 bit */ 1717c478bd9Sstevel@tonic-gate } color_t; 1727c478bd9Sstevel@tonic-gate 1737c478bd9Sstevel@tonic-gate /* 1747c478bd9Sstevel@tonic-gate * VIS_DEVINIT: 1757c478bd9Sstevel@tonic-gate * Initialize the framebuffer as a console device. The terminal emulator 1767c478bd9Sstevel@tonic-gate * will provide the following structure to the device driver to be filled in. 1777c478bd9Sstevel@tonic-gate * The driver is expected to fill it in. 1787c478bd9Sstevel@tonic-gate * 1797c478bd9Sstevel@tonic-gate * ioctl(fd, VIS_DEVINIT, struct vis_devinit *) 1807c478bd9Sstevel@tonic-gate */ 1817c478bd9Sstevel@tonic-gate #define VIS_DEVINIT (VIOC|1) 182*fea9cb91Slq150181 #define VIS_CONS_REV 3 /* Console IO interface version */ 1837c478bd9Sstevel@tonic-gate /* Modes */ 1847c478bd9Sstevel@tonic-gate #define VIS_TEXT 0 /* Use text mode when displaying data */ 1857c478bd9Sstevel@tonic-gate #define VIS_PIXEL 1 /* Use pixel mode when displaying data */ 1867c478bd9Sstevel@tonic-gate 1877c478bd9Sstevel@tonic-gate /* 1887c478bd9Sstevel@tonic-gate * VIS_DEVFINI: 1897c478bd9Sstevel@tonic-gate * Tells the framebuffer that it is no longer being used as a console. 1907c478bd9Sstevel@tonic-gate * 1917c478bd9Sstevel@tonic-gate * ioctl(fd, VIS_DEVFINI, unused) 1927c478bd9Sstevel@tonic-gate */ 1937c478bd9Sstevel@tonic-gate #define VIS_DEVFINI (VIOC|2) 1947c478bd9Sstevel@tonic-gate 1957c478bd9Sstevel@tonic-gate /* 1967c478bd9Sstevel@tonic-gate * VIS_CONSCURSOR: 1977c478bd9Sstevel@tonic-gate * Display/Hide cursor on the screen. The layered driver uses this ioctl to 1987c478bd9Sstevel@tonic-gate * display, hide, and move the cursor on the console. The framebuffer driver 1997c478bd9Sstevel@tonic-gate * is expected to draw a cursor at position (col,row) of size width x height. 2007c478bd9Sstevel@tonic-gate * 2017c478bd9Sstevel@tonic-gate * ioctl(fd, VIS_CONSCURSOR, struct vis_conscursor *) 2027c478bd9Sstevel@tonic-gate */ 2037c478bd9Sstevel@tonic-gate #define VIS_CONSCURSOR (VIOC|3) 2047c478bd9Sstevel@tonic-gate /* Cursor action - Either display or hide cursor */ 2057c478bd9Sstevel@tonic-gate #define VIS_HIDE_CURSOR 0 2067c478bd9Sstevel@tonic-gate #define VIS_DISPLAY_CURSOR 1 2077c478bd9Sstevel@tonic-gate #define VIS_GET_CURSOR 2 2087c478bd9Sstevel@tonic-gate 2097c478bd9Sstevel@tonic-gate /* 2107c478bd9Sstevel@tonic-gate * VIS_CONSDISPLAY: 2117c478bd9Sstevel@tonic-gate * Display data on the framebuffer. The data will be in the form specified 2127c478bd9Sstevel@tonic-gate * by the driver during console initialization (see VIS_CONSDEVINIT above). 2137c478bd9Sstevel@tonic-gate * The driver is expected to display the data at location (row,col). Width 2147c478bd9Sstevel@tonic-gate * and height specify the size of the data. 2157c478bd9Sstevel@tonic-gate * 2167c478bd9Sstevel@tonic-gate * ioctl(fd, VIS_CONSDISPLAY, struct vis_consdisplay *) 2177c478bd9Sstevel@tonic-gate */ 2187c478bd9Sstevel@tonic-gate 2197c478bd9Sstevel@tonic-gate #define VIS_CONSDISPLAY (VIOC|5) 2207c478bd9Sstevel@tonic-gate 2217c478bd9Sstevel@tonic-gate /* 2227c478bd9Sstevel@tonic-gate * VIS_CONSCOPY: 2237c478bd9Sstevel@tonic-gate * Move data on the framebuffer. Used to scroll the screen by the terminal 2247c478bd9Sstevel@tonic-gate * emulator or to move data by applications. The driver must copy the data 2257c478bd9Sstevel@tonic-gate * specified by the rectangle (s_col,s_row),(e_col,e_row) to the location 2267c478bd9Sstevel@tonic-gate * which starts at (t_col,t_row), handling overlapping copies correctly. 2277c478bd9Sstevel@tonic-gate * 2287c478bd9Sstevel@tonic-gate * ioctl(fd, VIS_CONSCOPY, struct vis_conscopy *) 2297c478bd9Sstevel@tonic-gate */ 2307c478bd9Sstevel@tonic-gate #define VIS_CONSCOPY (VIOC|7) 2317c478bd9Sstevel@tonic-gate 2327c478bd9Sstevel@tonic-gate struct vis_consdisplay { 2337c478bd9Sstevel@tonic-gate screen_pos_t row; /* Row to display data at */ 2347c478bd9Sstevel@tonic-gate screen_pos_t col; /* Col to display data at */ 2357c478bd9Sstevel@tonic-gate screen_size_t width; /* Width of data */ 2367c478bd9Sstevel@tonic-gate screen_size_t height; /* Height of data */ 2377c478bd9Sstevel@tonic-gate unsigned char *data; /* Data to display */ 2387c478bd9Sstevel@tonic-gate unsigned char fg_color; /* Foreground color */ 2397c478bd9Sstevel@tonic-gate unsigned char bg_color; /* Background color */ 2407c478bd9Sstevel@tonic-gate }; 2417c478bd9Sstevel@tonic-gate 2427c478bd9Sstevel@tonic-gate struct vis_conscopy { 2437c478bd9Sstevel@tonic-gate screen_pos_t s_row; /* Starting row */ 2447c478bd9Sstevel@tonic-gate screen_pos_t s_col; /* Starting col */ 2457c478bd9Sstevel@tonic-gate screen_pos_t e_row; /* Ending row */ 2467c478bd9Sstevel@tonic-gate screen_pos_t e_col; /* Ending col */ 2477c478bd9Sstevel@tonic-gate screen_pos_t t_row; /* Row to move to */ 2487c478bd9Sstevel@tonic-gate screen_pos_t t_col; /* Col to move to */ 2497c478bd9Sstevel@tonic-gate }; 2507c478bd9Sstevel@tonic-gate 2517c478bd9Sstevel@tonic-gate struct vis_conscursor { 2527c478bd9Sstevel@tonic-gate screen_pos_t row; /* Row to display cursor at */ 2537c478bd9Sstevel@tonic-gate screen_pos_t col; /* Col to display cursor at */ 2547c478bd9Sstevel@tonic-gate screen_size_t width; /* Width of cursor */ 2557c478bd9Sstevel@tonic-gate screen_size_t height; /* Height of cursor */ 2567c478bd9Sstevel@tonic-gate color_t fg_color; /* Foreground color */ 2577c478bd9Sstevel@tonic-gate color_t bg_color; /* Background color */ 2587c478bd9Sstevel@tonic-gate short action; /* Hide or show cursor */ 2597c478bd9Sstevel@tonic-gate }; 2607c478bd9Sstevel@tonic-gate 2617c478bd9Sstevel@tonic-gate /* 2627c478bd9Sstevel@tonic-gate * Each software-console-capable frame buffer driver defines its own 2637c478bd9Sstevel@tonic-gate * instance of this (with its own name!) and casts to/from this at the 264*fea9cb91Slq150181 * interface with the terminal emulator. These yield somewhat better 2657c478bd9Sstevel@tonic-gate * type checking than "void *". 2667c478bd9Sstevel@tonic-gate */ 2677c478bd9Sstevel@tonic-gate struct vis_polledio_arg; 268*fea9cb91Slq150181 struct vis_modechg_arg; 2697c478bd9Sstevel@tonic-gate 2707c478bd9Sstevel@tonic-gate /* 2717c478bd9Sstevel@tonic-gate * Each software-console-capable frame buffer driver supplies these routines 2727c478bd9Sstevel@tonic-gate * for I/O from "polled" contexts - kmdb, OBP, etc. No system services are 2737c478bd9Sstevel@tonic-gate * available. 2747c478bd9Sstevel@tonic-gate */ 2757c478bd9Sstevel@tonic-gate struct vis_polledio { 2767c478bd9Sstevel@tonic-gate struct vis_polledio_arg *arg; 277*fea9cb91Slq150181 void (*display)(struct vis_polledio_arg *, struct vis_consdisplay *); 2787c478bd9Sstevel@tonic-gate void (*copy)(struct vis_polledio_arg *, struct vis_conscopy *); 2797c478bd9Sstevel@tonic-gate void (*cursor)(struct vis_polledio_arg *, struct vis_conscursor *); 2807c478bd9Sstevel@tonic-gate }; 2817c478bd9Sstevel@tonic-gate 282*fea9cb91Slq150181 struct vis_devinit; /* forward decl. for typedef */ 283*fea9cb91Slq150181 284*fea9cb91Slq150181 typedef void (*vis_modechg_cb_t)(struct vis_modechg_arg *, 285*fea9cb91Slq150181 struct vis_devinit *); 286*fea9cb91Slq150181 2877c478bd9Sstevel@tonic-gate struct vis_devinit { 288*fea9cb91Slq150181 /* 289*fea9cb91Slq150181 * This set of fields are used as parameters passed from the 290*fea9cb91Slq150181 * layered framebuffer driver to the terminal emulator. 291*fea9cb91Slq150181 */ 2927c478bd9Sstevel@tonic-gate int version; /* Console IO interface version */ 2937c478bd9Sstevel@tonic-gate screen_size_t width; /* Width of the device */ 2947c478bd9Sstevel@tonic-gate screen_size_t height; /* Height of the device */ 2957c478bd9Sstevel@tonic-gate screen_size_t linebytes; /* Bytes per scan line */ 2967c478bd9Sstevel@tonic-gate int depth; /* Device depth */ 2977c478bd9Sstevel@tonic-gate short mode; /* Mode to use when displaying data */ 2987c478bd9Sstevel@tonic-gate struct vis_polledio *polledio; /* Polled output routines */ 299*fea9cb91Slq150181 300*fea9cb91Slq150181 /* 301*fea9cb91Slq150181 * The following fields are used as parameters passed from the 302*fea9cb91Slq150181 * terminal emulator to the underlying framebuffer driver. 303*fea9cb91Slq150181 */ 304*fea9cb91Slq150181 vis_modechg_cb_t modechg_cb; /* Video mode change callback */ 305*fea9cb91Slq150181 struct vis_modechg_arg *modechg_arg; /* Mode change cb arg */ 3067c478bd9Sstevel@tonic-gate }; 3077c478bd9Sstevel@tonic-gate 3087c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 3097c478bd9Sstevel@tonic-gate 3107c478bd9Sstevel@tonic-gate #ifdef __cplusplus 3117c478bd9Sstevel@tonic-gate } 3127c478bd9Sstevel@tonic-gate #endif 3137c478bd9Sstevel@tonic-gate 3147c478bd9Sstevel@tonic-gate #endif /* !_SYS_VISUAL_IO_H */ 315