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, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #pragma ident "%Z%%M% %I% %E% SMI" 28 29 /* 30 * isa-specific console configuration routines 31 */ 32 33 #include <sys/types.h> 34 #include <sys/param.h> 35 #include <sys/cmn_err.h> 36 #include <sys/systm.h> 37 #include <sys/conf.h> 38 #include <sys/debug.h> 39 #include <sys/ddi.h> 40 #include <sys/sunddi.h> 41 #include <sys/esunddi.h> 42 #include <sys/ddi_impldefs.h> 43 #include <sys/promif.h> 44 #include <sys/modctl.h> 45 #include <sys/termios.h> 46 47 extern char *get_alias(char *alias, char *buf); 48 49 extern int polled_debug; 50 51 int 52 plat_use_polled_debug() 53 { 54 return (polled_debug); 55 } 56 57 int 58 plat_support_serial_kbd_and_ms() 59 { 60 return (1); 61 } 62 63 int 64 plat_usb_kb_path_override() { 65 return (0); 66 } 67 68 /* 69 * Return generic path to keyboard device from the alias. 70 */ 71 char * 72 plat_kbdpath(void) 73 { 74 static char *kbdpath = NULL; 75 static char buf[MAXPATHLEN]; 76 char *path; 77 78 if (kbdpath != NULL) 79 return (kbdpath); 80 81 /* 82 * look for the keyboard property in /aliases 83 * The keyboard alias is required on 1275 systems 84 */ 85 path = get_alias("keyboard", buf); 86 if (path != NULL) { 87 kbdpath = path; 88 return (path); 89 } 90 91 return (NULL); 92 } 93 94 /* 95 * Return generic path to display device from the alias. 96 */ 97 char * 98 plat_fbpath(void) 99 { 100 static char *fbpath = NULL; 101 static char buf[MAXPATHLEN]; 102 char *path; 103 104 if (fbpath != NULL) 105 return (fbpath); 106 107 /* look for the screen property in /aliases */ 108 path = get_alias("screen", buf); 109 if (path != NULL) { 110 fbpath = path; 111 return (path); 112 } 113 114 return (NULL); 115 } 116 117 char * 118 plat_mousepath(void) 119 { 120 static char *mousepath = NULL; 121 static char buf[MAXPATHLEN]; 122 char *path, *p, *q; 123 major_t zs_major, kb_major; 124 125 if (mousepath != NULL) 126 return (mousepath); 127 128 /* look for the mouse property in /aliases */ 129 path = get_alias("mouse", buf); 130 if (path != NULL) { 131 mousepath = path; 132 return (path); 133 } 134 135 if (!plat_support_serial_kbd_and_ms()) 136 return (NULL); 137 138 if ((zs_major = mod_name_to_major("zs")) == -1) 139 return (NULL); 140 141 if ((path = plat_kbdpath()) == NULL) 142 return (NULL); 143 144 if ((kb_major = path_to_major(path)) == (major_t)-1) 145 return (NULL); 146 147 if (zs_major != kb_major) 148 return (NULL); 149 150 /* 151 * If we didn't find the mouse property and we're on an OBP 152 * system with a 'zs' port keyboard/mouse duart then the mouse 153 * is the 'b' channel of the keyboard duart. Change :a to :b 154 * or append :b to the last component of the path. 155 * (It's still canonical without :a) 156 */ 157 (void) strcpy(buf, path); 158 p = (strrchr(buf, '/')); /* p points to last comp. */ 159 if (p != NULL) { 160 q = strchr(p, ':'); 161 if (q != 0) 162 *q = (char)0; /* Replace or append options */ 163 (void) strcat(p, ":b"); 164 mousepath = buf; 165 return (mousepath); 166 } 167 return (NULL); 168 } 169 170 char * 171 plat_stdinpath(void) 172 { 173 return (prom_stdinpath()); 174 } 175 176 char * 177 plat_stdoutpath(void) 178 { 179 static char *outpath; 180 static char buf[MAXPATHLEN]; 181 char *p; 182 183 if (outpath != NULL) 184 return (outpath); 185 186 p = prom_stdoutpath(); 187 if (p == NULL) 188 return (NULL); 189 190 /* 191 * If the output device is a framebuffer, we don't 192 * care about monitor resolution options strings. 193 * In fact, we can't handle them at all, so strip them. 194 */ 195 if (prom_stdout_is_framebuffer()) { 196 prom_strip_options(p, buf); 197 p = buf; 198 } 199 200 outpath = p; 201 return (outpath); 202 } 203 204 int 205 plat_stdin_is_keyboard(void) 206 { 207 return (prom_stdin_is_keyboard()); 208 } 209 210 int 211 plat_stdout_is_framebuffer(void) 212 { 213 return (prom_stdout_is_framebuffer()); 214 } 215 216 void 217 kadb_uses_kernel() 218 { 219 /* only used on intel */ 220 } 221