xref: /titanic_41/usr/src/uts/sparc/io/consplat.c (revision 70025d765b044c6d8594bb965a2247a61e991a99)
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 /*
64  * Return generic path to keyboard device from the alias.
65  */
66 char *
67 plat_kbdpath(void)
68 {
69 	static char *kbdpath = NULL;
70 	static char buf[MAXPATHLEN];
71 	char *path;
72 
73 	if (kbdpath != NULL)
74 		return (kbdpath);
75 
76 	/*
77 	 * look for the keyboard property in /aliases
78 	 * The keyboard alias is required on 1275 systems
79 	 */
80 	path = get_alias("keyboard", buf);
81 	if (path != NULL) {
82 		kbdpath = path;
83 		return (path);
84 	}
85 
86 	return (NULL);
87 }
88 
89 /*
90  * Return generic path to display device from the alias.
91  */
92 char *
93 plat_fbpath(void)
94 {
95 	static char *fbpath = NULL;
96 	static char buf[MAXPATHLEN];
97 	char *path;
98 
99 	if (fbpath != NULL)
100 		return (fbpath);
101 
102 	/* look for the screen property in /aliases */
103 	path = get_alias("screen", buf);
104 	if (path != NULL) {
105 		fbpath = path;
106 		return (path);
107 	}
108 
109 	return (NULL);
110 }
111 
112 char *
113 plat_mousepath(void)
114 {
115 	static char 	*mousepath = NULL;
116 	static char 	buf[MAXPATHLEN];
117 	char 		*path, *p, *q;
118 	major_t		zs_major, kb_major;
119 
120 	if (mousepath != NULL)
121 		return (mousepath);
122 
123 	/* look for the mouse property in /aliases */
124 	path = get_alias("mouse", buf);
125 	if (path != NULL) {
126 		mousepath = path;
127 		return (path);
128 	}
129 
130 	if (!plat_support_serial_kbd_and_ms())
131 		return (NULL);
132 
133 	if ((zs_major = mod_name_to_major("zs")) == -1)
134 		return (NULL);
135 
136 	if ((path = plat_kbdpath()) == NULL)
137 		return (NULL);
138 
139 	if ((kb_major = path_to_major(path)) == (major_t)-1)
140 		return (NULL);
141 
142 	if (zs_major != kb_major)
143 		return (NULL);
144 
145 	/*
146 	 * If we didn't find the mouse property and we're on an OBP
147 	 * system with a 'zs' port keyboard/mouse duart then the mouse
148 	 * is the 'b' channel of the keyboard duart. Change :a to :b
149 	 * or append :b to the last component of the path.
150 	 * (It's still canonical without :a)
151 	 */
152 	(void) strcpy(buf, path);
153 	p = (strrchr(buf, '/'));	/* p points to last comp. */
154 	if (p != NULL) {
155 		q = strchr(p, ':');
156 		if (q != 0)
157 			*q = (char)0;	/* Replace or append options */
158 		(void) strcat(p, ":b");
159 		mousepath = buf;
160 		return (mousepath);
161 	}
162 	return (NULL);
163 }
164 
165 char *
166 plat_stdinpath(void)
167 {
168 	return (prom_stdinpath());
169 }
170 
171 char *
172 plat_stdoutpath(void)
173 {
174 	static char *outpath;
175 	static char buf[MAXPATHLEN];
176 	char *p;
177 
178 	if (outpath != NULL)
179 		return (outpath);
180 
181 	p = prom_stdoutpath();
182 	if (p == NULL)
183 		return (NULL);
184 
185 	/*
186 	 * If the output device is a framebuffer, we don't
187 	 * care about monitor resolution options strings.
188 	 * In fact, we can't handle them at all, so strip them.
189 	 */
190 	if (prom_stdout_is_framebuffer()) {
191 		prom_strip_options(p, buf);
192 		p = buf;
193 	}
194 
195 	outpath = p;
196 	return (outpath);
197 }
198 
199 int
200 plat_stdin_is_keyboard(void)
201 {
202 	return (prom_stdin_is_keyboard());
203 }
204 
205 int
206 plat_stdout_is_framebuffer(void)
207 {
208 	return (prom_stdout_is_framebuffer());
209 }
210 
211 void
212 kadb_uses_kernel()
213 {
214 	/* only used on intel */
215 }
216