1 0 stevel /* 2 0 stevel * CDDL HEADER START 3 0 stevel * 4 0 stevel * The contents of this file are subject to the terms of the 5 1253 lq150181 * Common Development and Distribution License (the "License"). 6 1253 lq150181 * You may not use this file except in compliance with the License. 7 0 stevel * 8 0 stevel * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 0 stevel * or http://www.opensolaris.org/os/licensing. 10 0 stevel * See the License for the specific language governing permissions 11 0 stevel * and limitations under the License. 12 0 stevel * 13 0 stevel * When distributing Covered Code, include this CDDL HEADER in each 14 0 stevel * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 0 stevel * If applicable, add the following below this CDDL HEADER, with the 16 0 stevel * fields enclosed by brackets "[]" replaced with your own identifying 17 0 stevel * information: Portions Copyright [yyyy] [name of copyright owner] 18 0 stevel * 19 0 stevel * CDDL HEADER END 20 0 stevel */ 21 1253 lq150181 22 0 stevel /* 23 5974 jm22469 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 24 0 stevel * Use is subject to license terms. 25 0 stevel */ 26 0 stevel 27 0 stevel #pragma ident "%Z%%M% %I% %E% SMI" 28 0 stevel 29 0 stevel /* 30 0 stevel * isa-specific console configuration routines 31 0 stevel */ 32 0 stevel 33 0 stevel #include <sys/types.h> 34 0 stevel #include <sys/param.h> 35 0 stevel #include <sys/cmn_err.h> 36 0 stevel #include <sys/systm.h> 37 0 stevel #include <sys/conf.h> 38 0 stevel #include <sys/debug.h> 39 0 stevel #include <sys/ddi.h> 40 0 stevel #include <sys/sunddi.h> 41 0 stevel #include <sys/esunddi.h> 42 0 stevel #include <sys/ddi_impldefs.h> 43 0 stevel #include <sys/promif.h> 44 0 stevel #include <sys/modctl.h> 45 0 stevel #include <sys/termios.h> 46 0 stevel 47 0 stevel extern char *get_alias(char *alias, char *buf); 48 0 stevel 49 0 stevel extern int polled_debug; 50 0 stevel 51 0 stevel int 52 0 stevel plat_use_polled_debug() 53 0 stevel { 54 0 stevel return (polled_debug); 55 0 stevel } 56 0 stevel 57 0 stevel int 58 0 stevel plat_support_serial_kbd_and_ms() 59 0 stevel { 60 0 stevel return (1); 61 0 stevel } 62 0 stevel 63 0 stevel /* 64 0 stevel * Return generic path to keyboard device from the alias. 65 0 stevel */ 66 0 stevel char * 67 0 stevel plat_kbdpath(void) 68 0 stevel { 69 0 stevel static char *kbdpath = NULL; 70 0 stevel static char buf[MAXPATHLEN]; 71 0 stevel char *path; 72 0 stevel 73 0 stevel if (kbdpath != NULL) 74 0 stevel return (kbdpath); 75 0 stevel 76 0 stevel /* 77 0 stevel * look for the keyboard property in /aliases 78 0 stevel * The keyboard alias is required on 1275 systems 79 0 stevel */ 80 0 stevel path = get_alias("keyboard", buf); 81 0 stevel if (path != NULL) { 82 0 stevel kbdpath = path; 83 0 stevel return (path); 84 0 stevel } 85 0 stevel 86 0 stevel return (NULL); 87 0 stevel } 88 0 stevel 89 0 stevel /* 90 0 stevel * Return generic path to display device from the alias. 91 0 stevel */ 92 0 stevel char * 93 0 stevel plat_fbpath(void) 94 0 stevel { 95 0 stevel static char *fbpath = NULL; 96 0 stevel static char buf[MAXPATHLEN]; 97 0 stevel char *path; 98 0 stevel 99 0 stevel if (fbpath != NULL) 100 0 stevel return (fbpath); 101 0 stevel 102 0 stevel /* look for the screen property in /aliases */ 103 0 stevel path = get_alias("screen", buf); 104 0 stevel if (path != NULL) { 105 0 stevel fbpath = path; 106 0 stevel return (path); 107 0 stevel } 108 0 stevel 109 0 stevel return (NULL); 110 0 stevel } 111 0 stevel 112 0 stevel char * 113 0 stevel plat_mousepath(void) 114 0 stevel { 115 0 stevel static char *mousepath = NULL; 116 0 stevel static char buf[MAXPATHLEN]; 117 0 stevel char *path, *p, *q; 118 0 stevel major_t zs_major, kb_major; 119 0 stevel 120 0 stevel if (mousepath != NULL) 121 0 stevel return (mousepath); 122 0 stevel 123 0 stevel /* look for the mouse property in /aliases */ 124 0 stevel path = get_alias("mouse", buf); 125 0 stevel if (path != NULL) { 126 0 stevel mousepath = path; 127 0 stevel return (path); 128 0 stevel } 129 0 stevel 130 0 stevel if (!plat_support_serial_kbd_and_ms()) 131 0 stevel return (NULL); 132 0 stevel 133 0 stevel if ((zs_major = mod_name_to_major("zs")) == -1) 134 0 stevel return (NULL); 135 0 stevel 136 0 stevel if ((path = plat_kbdpath()) == NULL) 137 0 stevel return (NULL); 138 0 stevel 139 0 stevel if ((kb_major = path_to_major(path)) == (major_t)-1) 140 0 stevel return (NULL); 141 0 stevel 142 0 stevel if (zs_major != kb_major) 143 0 stevel return (NULL); 144 0 stevel 145 0 stevel /* 146 0 stevel * If we didn't find the mouse property and we're on an OBP 147 0 stevel * system with a 'zs' port keyboard/mouse duart then the mouse 148 0 stevel * is the 'b' channel of the keyboard duart. Change :a to :b 149 0 stevel * or append :b to the last component of the path. 150 0 stevel * (It's still canonical without :a) 151 0 stevel */ 152 0 stevel (void) strcpy(buf, path); 153 0 stevel p = (strrchr(buf, '/')); /* p points to last comp. */ 154 0 stevel if (p != NULL) { 155 0 stevel q = strchr(p, ':'); 156 0 stevel if (q != 0) 157 0 stevel *q = (char)0; /* Replace or append options */ 158 0 stevel (void) strcat(p, ":b"); 159 0 stevel mousepath = buf; 160 0 stevel return (mousepath); 161 0 stevel } 162 0 stevel return (NULL); 163 0 stevel } 164 0 stevel 165 0 stevel char * 166 0 stevel plat_stdinpath(void) 167 0 stevel { 168 0 stevel return (prom_stdinpath()); 169 0 stevel } 170 0 stevel 171 0 stevel char * 172 0 stevel plat_stdoutpath(void) 173 0 stevel { 174 0 stevel static char *outpath; 175 0 stevel static char buf[MAXPATHLEN]; 176 0 stevel char *p; 177 0 stevel 178 0 stevel if (outpath != NULL) 179 0 stevel return (outpath); 180 0 stevel 181 0 stevel p = prom_stdoutpath(); 182 0 stevel if (p == NULL) 183 0 stevel return (NULL); 184 0 stevel 185 0 stevel /* 186 0 stevel * If the output device is a framebuffer, we don't 187 0 stevel * care about monitor resolution options strings. 188 0 stevel * In fact, we can't handle them at all, so strip them. 189 0 stevel */ 190 0 stevel if (prom_stdout_is_framebuffer()) { 191 0 stevel prom_strip_options(p, buf); 192 0 stevel p = buf; 193 0 stevel } 194 0 stevel 195 0 stevel outpath = p; 196 0 stevel return (outpath); 197 0 stevel } 198 0 stevel 199 0 stevel int 200 0 stevel plat_stdin_is_keyboard(void) 201 0 stevel { 202 0 stevel return (prom_stdin_is_keyboard()); 203 0 stevel } 204 0 stevel 205 0 stevel int 206 0 stevel plat_stdout_is_framebuffer(void) 207 0 stevel { 208 0 stevel return (prom_stdout_is_framebuffer()); 209 0 stevel } 210 0 stevel 211 0 stevel void 212 0 stevel kadb_uses_kernel() 213 0 stevel { 214 0 stevel /* only used on intel */ 215 0 stevel } 216 1253 lq150181 217 1253 lq150181 void 218 3994 lq150181 plat_tem_get_inverses(int *inverse, int *inverse_screen) 219 3994 lq150181 { 220 3994 lq150181 prom_get_tem_inverses(inverse, inverse_screen); 221 3994 lq150181 } 222 3994 lq150181 223 3994 lq150181 void 224 1253 lq150181 plat_tem_get_prom_font_size(int *charheight, int *windowtop) 225 1253 lq150181 { 226 1253 lq150181 prom_get_term_font_size(charheight, windowtop); 227 1253 lq150181 } 228 1253 lq150181 229 1253 lq150181 void 230 1253 lq150181 plat_tem_get_prom_size(size_t *height, size_t *width) 231 1253 lq150181 { 232 1253 lq150181 prom_get_tem_size(height, width); 233 1253 lq150181 } 234 1253 lq150181 235 1253 lq150181 void 236 1253 lq150181 plat_tem_hide_prom_cursor(void) 237 1253 lq150181 { 238 1253 lq150181 prom_hide_cursor(); 239 1253 lq150181 } 240 1253 lq150181 241 1253 lq150181 void 242 1253 lq150181 plat_tem_get_prom_pos(uint32_t *row, uint32_t *col) 243 1253 lq150181 { 244 1253 lq150181 prom_get_tem_pos(row, col); 245 1253 lq150181 } 246 5974 jm22469 247 5974 jm22469 /* 248 5974 jm22469 * Find the path of the virtual console (if available on the 249 5974 jm22469 * current architecture). 250 5974 jm22469 * 251 5974 jm22469 * Returns: -1 if not found, else actual path length. 252 5974 jm22469 */ 253 5974 jm22469 int 254 5974 jm22469 plat_virtual_console_path(char **bufp) 255 5974 jm22469 { 256 5974 jm22469 pnode_t pnode; 257 5974 jm22469 int buflen; 258 5974 jm22469 static char buf[OBP_MAXPATHLEN]; 259 5974 jm22469 260 5974 jm22469 pnode = prom_finddevice("/virtual-devices/console"); 261 5974 jm22469 262 5974 jm22469 if (pnode == OBP_BADNODE) 263 5974 jm22469 return (-1); 264 5974 jm22469 265 5974 jm22469 if ((buflen = prom_phandle_to_path(pnode, buf, sizeof (buf))) < 0) 266 5974 jm22469 return (-1); 267 5974 jm22469 268 5974 jm22469 *bufp = buf; 269 5974 jm22469 270 5974 jm22469 return (buflen); 271 5974 jm22469 } 272