xref: /titanic_51/usr/src/uts/common/io/consconfig.c (revision 747cfc73193da6c99aeb06f23e70552319393cc4)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 /*
29  * Console and mouse configuration
30  */
31 
32 #include <sys/types.h>
33 #include <sys/param.h>
34 #include <sys/cmn_err.h>
35 #include <sys/user.h>
36 #include <sys/vfs.h>
37 #include <sys/vnode.h>
38 #include <sys/systm.h>
39 #include <sys/file.h>
40 #include <sys/klwp.h>
41 #include <sys/stropts.h>
42 #include <sys/stream.h>
43 #include <sys/strsubr.h>
44 
45 #include <sys/consdev.h>
46 #include <sys/kbio.h>
47 #include <sys/debug.h>
48 #include <sys/reboot.h>
49 #include <sys/termios.h>
50 
51 #include <sys/ddi.h>
52 #include <sys/sunddi.h>
53 #include <sys/modctl.h>
54 #include <sys/ddi_impldefs.h>
55 
56 #include <sys/strsubr.h>
57 #include <sys/errno.h>
58 #include <sys/devops.h>
59 #include <sys/note.h>
60 #include <sys/log.h>
61 #include <sys/consdev.h>
62 
63 /*
64  * On supported configurations, the firmware defines the keyboard and mouse
65  * paths.  However, during USB development, it is useful to be able to use
66  * the USB keyboard and mouse on machines without full USB firmware support.
67  * These variables may be set in /etc/system according to a machine's
68  * USB configuration.  This module will override the firmware's values
69  * with these.
70  */
71 static char *usb_kb_path = NULL;
72 static char *usb_ms_path = NULL;
73 
74 /*
75  * This is the loadable module wrapper.
76  */
77 extern struct mod_ops mod_miscops;
78 
79 /*
80  * Module linkage information for the kernel.
81  */
82 static struct modlmisc modlmisc = {
83 	&mod_miscops, "console configuration %I%"
84 };
85 
86 static struct modlinkage modlinkage = {
87 	MODREV_1, (void *)&modlmisc, NULL
88 };
89 
90 int
91 _init(void)
92 {
93 	return (mod_install(&modlinkage));
94 }
95 
96 int
97 _fini(void)
98 {
99 	return (mod_remove(&modlinkage));
100 }
101 
102 int
103 _info(struct modinfo *modinfop)
104 {
105 	return (mod_info(&modlinkage, modinfop));
106 }
107 
108 extern void dynamic_console_config(void);
109 
110 /*
111  * Configure keyboard and mouse. Main entry here.
112  */
113 void
114 consconfig(void)
115 {
116 	dynamic_console_config();
117 }
118 
119 extern char *
120 consconfig_get_usb_kb_path(void) {
121 	if (usb_kb_path)
122 		return (i_ddi_strdup(usb_kb_path, KM_SLEEP));
123 	return (NULL);
124 }
125 
126 extern char *
127 consconfig_get_usb_ms_path(void) {
128 	if (usb_ms_path)
129 		return (i_ddi_strdup(usb_ms_path, KM_SLEEP));
130 	return (NULL);
131 }
132 
133 void
134 consconfig_teardown(void)
135 {
136 	/*
137 	 * rconsvp is set to NULL to ensure that output messages
138 	 * are sent to the underlying "hardware" device using the
139 	 * monitor's printf routine since we are in the process of
140 	 * either rebooting or halting the machine.
141 	 */
142 	rconsvp = NULL;
143 
144 	log_flushall();
145 }
146