1ae115bc7Smrj /* 2ae115bc7Smrj * CDDL HEADER START 3ae115bc7Smrj * 4ae115bc7Smrj * The contents of this file are subject to the terms of the 5ae115bc7Smrj * Common Development and Distribution License (the "License"). 6ae115bc7Smrj * You may not use this file except in compliance with the License. 7ae115bc7Smrj * 8ae115bc7Smrj * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9ae115bc7Smrj * or http://www.opensolaris.org/os/licensing. 10ae115bc7Smrj * See the License for the specific language governing permissions 11ae115bc7Smrj * and limitations under the License. 12ae115bc7Smrj * 13ae115bc7Smrj * When distributing Covered Code, include this CDDL HEADER in each 14ae115bc7Smrj * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15ae115bc7Smrj * If applicable, add the following below this CDDL HEADER, with the 16ae115bc7Smrj * fields enclosed by brackets "[]" replaced with your own identifying 17ae115bc7Smrj * information: Portions Copyright [yyyy] [name of copyright owner] 18ae115bc7Smrj * 19ae115bc7Smrj * CDDL HEADER END 20ae115bc7Smrj */ 21ae115bc7Smrj 22ae115bc7Smrj /* 23*c9503a49Slq150181 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24ae115bc7Smrj * Use is subject to license terms. 25ae115bc7Smrj */ 26ae115bc7Smrj 27ae115bc7Smrj #pragma ident "%Z%%M% %I% %E% SMI" 28ae115bc7Smrj 29ae115bc7Smrj /* 30ae115bc7Smrj * isa-specific console configuration routines 31ae115bc7Smrj */ 32ae115bc7Smrj 33ae115bc7Smrj #include <sys/types.h> 34ae115bc7Smrj #include <sys/param.h> 35ae115bc7Smrj #include <sys/cmn_err.h> 36ae115bc7Smrj #include <sys/systm.h> 37ae115bc7Smrj #include <sys/conf.h> 38ae115bc7Smrj #include <sys/debug.h> 39ae115bc7Smrj #include <sys/ddi.h> 40ae115bc7Smrj #include <sys/sunddi.h> 41ae115bc7Smrj #include <sys/sunndi.h> 42ae115bc7Smrj #include <sys/esunddi.h> 43ae115bc7Smrj #include <sys/ddi_impldefs.h> 44ae115bc7Smrj #include <sys/promif.h> 45ae115bc7Smrj #include <sys/modctl.h> 46ae115bc7Smrj #include <sys/termios.h> 47ae115bc7Smrj 48ae115bc7Smrj /* The names of currently supported graphics drivers on x86 */ 49ae115bc7Smrj static char * 50ae115bc7Smrj gfxdrv_name[] = { 51ae115bc7Smrj "vgatext", 52ae115bc7Smrj "i915", 53ae115bc7Smrj "nvidia" 54ae115bc7Smrj }; 55ae115bc7Smrj 56ae115bc7Smrj int 57ae115bc7Smrj plat_use_polled_debug() { 58ae115bc7Smrj return (0); 59ae115bc7Smrj } 60ae115bc7Smrj 61ae115bc7Smrj int 62ae115bc7Smrj plat_support_serial_kbd_and_ms() { 63ae115bc7Smrj return (0); 64ae115bc7Smrj } 65ae115bc7Smrj 66ae115bc7Smrj #define CONS_INVALID -1 67ae115bc7Smrj #define CONS_SCREEN 0 68ae115bc7Smrj #define CONS_TTYA 1 69ae115bc7Smrj #define CONS_TTYB 2 70ae115bc7Smrj #define CONS_USBSER 3 71ae115bc7Smrj 72ae115bc7Smrj static int 73ae115bc7Smrj console_type() 74ae115bc7Smrj { 75ae115bc7Smrj static int boot_console = CONS_INVALID; 76ae115bc7Smrj 77ae115bc7Smrj char *cons; 78ae115bc7Smrj dev_info_t *root; 79ae115bc7Smrj 80ae115bc7Smrj if (boot_console != CONS_INVALID) 81ae115bc7Smrj return (boot_console); 82ae115bc7Smrj 83ae115bc7Smrj /* 84ae115bc7Smrj * console is defined by "console" property, with 85ae115bc7Smrj * fallback on the old "input-device" property. 86ae115bc7Smrj */ 87ae115bc7Smrj boot_console = CONS_SCREEN; /* default is screen/kb */ 88ae115bc7Smrj root = ddi_root_node(); 89ae115bc7Smrj if ((ddi_prop_lookup_string(DDI_DEV_T_ANY, root, 90ae115bc7Smrj DDI_PROP_DONTPASS, "console", &cons) == DDI_SUCCESS) || 91ae115bc7Smrj (ddi_prop_lookup_string(DDI_DEV_T_ANY, root, 92ae115bc7Smrj DDI_PROP_DONTPASS, "input-device", &cons) == DDI_SUCCESS)) { 93ae115bc7Smrj if (strcmp(cons, "ttya") == 0) 94ae115bc7Smrj boot_console = CONS_TTYA; 95ae115bc7Smrj else if (strcmp(cons, "ttyb") == 0) 96ae115bc7Smrj boot_console = CONS_TTYB; 97ae115bc7Smrj else if (strcmp(cons, "usb-serial") == 0) { 98ae115bc7Smrj (void) i_ddi_attach_hw_nodes("ehci"); 99ae115bc7Smrj (void) i_ddi_attach_hw_nodes("uhci"); 100ae115bc7Smrj (void) i_ddi_attach_hw_nodes("ohci"); 101ae115bc7Smrj /* 102ae115bc7Smrj * USB device enumerate asynchronously. 103ae115bc7Smrj * Wait 2 seconds for USB serial devices to attach. 104ae115bc7Smrj */ 105ae115bc7Smrj delay(drv_usectohz(2000000)); 106ae115bc7Smrj boot_console = CONS_USBSER; 107ae115bc7Smrj } 108ae115bc7Smrj ddi_prop_free(cons); 109ae115bc7Smrj } 110ae115bc7Smrj return (boot_console); 111ae115bc7Smrj } 112ae115bc7Smrj 113ae115bc7Smrj int 114ae115bc7Smrj plat_stdin_is_keyboard(void) 115ae115bc7Smrj { 116ae115bc7Smrj return (console_type() == CONS_SCREEN); 117ae115bc7Smrj } 118ae115bc7Smrj 119ae115bc7Smrj int 120ae115bc7Smrj plat_stdout_is_framebuffer(void) 121ae115bc7Smrj { 122ae115bc7Smrj return (console_type() == CONS_SCREEN); 123ae115bc7Smrj } 124ae115bc7Smrj 125ae115bc7Smrj /* 126ae115bc7Smrj * Return generic path to keyboard device from the alias. 127ae115bc7Smrj */ 128ae115bc7Smrj char * 129ae115bc7Smrj plat_kbdpath(void) 130ae115bc7Smrj { 131ae115bc7Smrj /* 132ae115bc7Smrj * Hardcode to isa keyboard path 133ae115bc7Smrj * XXX make it settable via bootprop? 134ae115bc7Smrj */ 135ae115bc7Smrj return ("/isa/i8042@1,60/keyboard@0"); 136ae115bc7Smrj } 137ae115bc7Smrj 138ae115bc7Smrj /* 139ae115bc7Smrj * Return generic path to display device from the alias. 140ae115bc7Smrj */ 141ae115bc7Smrj char * 142ae115bc7Smrj plat_fbpath(void) 143ae115bc7Smrj { 144ae115bc7Smrj static char *fbpath = NULL; 145ae115bc7Smrj static char fbpath_buf[MAXPATHLEN]; 146ae115bc7Smrj major_t major; 147ae115bc7Smrj dev_info_t *dip; 148ae115bc7Smrj int i; 149ae115bc7Smrj 150ae115bc7Smrj for (i = 0; i < (sizeof (gfxdrv_name) / sizeof (char *)); i++) { 151ae115bc7Smrj /* 152ae115bc7Smrj * look for first instance of each driver 153ae115bc7Smrj */ 154ae115bc7Smrj major = ddi_name_to_major(gfxdrv_name[i]); 155ae115bc7Smrj if (major != (major_t)-1) { 156ae115bc7Smrj dip = devnamesp[major].dn_head; 157ae115bc7Smrj if (dip && 158ae115bc7Smrj i_ddi_attach_node_hierarchy(dip) == DDI_SUCCESS) { 159ae115bc7Smrj (void) ddi_pathname(dip, fbpath_buf); 160ae115bc7Smrj fbpath = fbpath_buf; 161ae115bc7Smrj } 162ae115bc7Smrj } 163ae115bc7Smrj 164ae115bc7Smrj if (fbpath) 165ae115bc7Smrj return (fbpath); 166ae115bc7Smrj } 167ae115bc7Smrj 168ae115bc7Smrj /* No screen found */ 169ae115bc7Smrj return (NULL); 170ae115bc7Smrj } 171ae115bc7Smrj 172ae115bc7Smrj char * 173ae115bc7Smrj plat_mousepath(void) 174ae115bc7Smrj { 175ae115bc7Smrj /* 176ae115bc7Smrj * Hardcode to isa mouse path 177ae115bc7Smrj * XXX make it settable via bootprop? 178ae115bc7Smrj */ 179ae115bc7Smrj return ("/isa/i8042@1,60/mouse@1"); 180ae115bc7Smrj } 181ae115bc7Smrj 182ae115bc7Smrj /* return path of first usb serial device */ 183ae115bc7Smrj static char * 184ae115bc7Smrj plat_usbser_path(void) 185ae115bc7Smrj { 186ae115bc7Smrj extern dev_info_t *usbser_first_device(void); 187ae115bc7Smrj 188ae115bc7Smrj dev_info_t *us_dip; 189ae115bc7Smrj static char *us_path = NULL; 190ae115bc7Smrj 191ae115bc7Smrj if (us_path) 192ae115bc7Smrj return (us_path); 193ae115bc7Smrj 194ae115bc7Smrj us_dip = usbser_first_device(); 195ae115bc7Smrj if (us_dip == NULL) 196ae115bc7Smrj return (NULL); 197ae115bc7Smrj 198ae115bc7Smrj us_path = kmem_alloc(MAXPATHLEN, KM_SLEEP); 199ae115bc7Smrj (void) ddi_pathname(us_dip, us_path); 200ae115bc7Smrj ndi_rele_devi(us_dip); /* held from usbser_first_device */ 201ae115bc7Smrj return (us_path); 202ae115bc7Smrj } 203ae115bc7Smrj 204ae115bc7Smrj /* 205ae115bc7Smrj * Lacking support for com2 and com3, if that matters. 206ae115bc7Smrj * Another possible enhancement could be to use properties 207ae115bc7Smrj * for the port mapping rather than simply hard-code them. 208ae115bc7Smrj */ 209ae115bc7Smrj char * 210ae115bc7Smrj plat_stdinpath(void) 211ae115bc7Smrj { 212ae115bc7Smrj switch (console_type()) { 213ae115bc7Smrj case CONS_TTYA: 214ae115bc7Smrj return ("/isa/asy@1,3f8:a"); 215ae115bc7Smrj case CONS_TTYB: 216ae115bc7Smrj return ("/isa/asy@1,2f8:b"); 217ae115bc7Smrj case CONS_USBSER: 218ae115bc7Smrj return (plat_usbser_path()); 219ae115bc7Smrj case CONS_SCREEN: 220ae115bc7Smrj default: 221ae115bc7Smrj break; 222ae115bc7Smrj }; 223ae115bc7Smrj return (plat_kbdpath()); 224ae115bc7Smrj } 225ae115bc7Smrj 226ae115bc7Smrj char * 227ae115bc7Smrj plat_stdoutpath(void) 228ae115bc7Smrj { 229ae115bc7Smrj switch (console_type()) { 230ae115bc7Smrj case CONS_TTYA: 231ae115bc7Smrj return ("/isa/asy@1,3f8:a"); 232ae115bc7Smrj case CONS_TTYB: 233ae115bc7Smrj return ("/isa/asy@1,2f8:b"); 234ae115bc7Smrj case CONS_USBSER: 235ae115bc7Smrj return (plat_usbser_path()); 236ae115bc7Smrj case CONS_SCREEN: 237ae115bc7Smrj default: 238ae115bc7Smrj break; 239ae115bc7Smrj }; 240ae115bc7Smrj return (plat_fbpath()); 241ae115bc7Smrj } 242ae115bc7Smrj 243ae115bc7Smrj /* 244ae115bc7Smrj * If VIS_PIXEL mode will be implemented on x86, these following 245ae115bc7Smrj * functions should be re-considered. Now these functions are 246ae115bc7Smrj * unused on x86. 247ae115bc7Smrj */ 248ae115bc7Smrj void 249*c9503a49Slq150181 plat_tem_get_inverses(int *inverse, int *inverse_screen) 250*c9503a49Slq150181 { 251*c9503a49Slq150181 *inverse = 0; 252*c9503a49Slq150181 *inverse_screen = 0; 253*c9503a49Slq150181 } 254*c9503a49Slq150181 255*c9503a49Slq150181 void 256ae115bc7Smrj plat_tem_get_prom_font_size(int *charheight, int *windowtop) 257ae115bc7Smrj { 258ae115bc7Smrj *charheight = 0; 259ae115bc7Smrj *windowtop = 0; 260ae115bc7Smrj } 261ae115bc7Smrj 262ae115bc7Smrj void 263ae115bc7Smrj plat_tem_get_prom_size(size_t *height, size_t *width) 264ae115bc7Smrj { 265ae115bc7Smrj *height = 25; 266ae115bc7Smrj *width = 80; 267ae115bc7Smrj } 268ae115bc7Smrj 269ae115bc7Smrj void 270ae115bc7Smrj plat_tem_hide_prom_cursor(void) 271ae115bc7Smrj { 272ae115bc7Smrj } 273ae115bc7Smrj 274ae115bc7Smrj void 275ae115bc7Smrj plat_tem_get_prom_pos(uint32_t *row, uint32_t *col) 276ae115bc7Smrj { 277ae115bc7Smrj *row = 0; 278ae115bc7Smrj *col = 0; 279ae115bc7Smrj } 280