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