blob: d83057d2a50ad6a1b7abc2bed4ac1e33a05f43b7 [file] [log] [blame]
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -07001/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
Richard Bean39b361b2008-10-16 16:24:06 -05005 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -07007 *
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/*
Jan Setje-Eilers48633f12009-03-02 18:20:31 -080022 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070023 * Use is subject to license terms.
24 */
25
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070026/*
27 * Console and mouse configuration
28 */
29
30#include <sys/types.h>
31#include <sys/param.h>
32#include <sys/cmn_err.h>
33#include <sys/user.h>
34#include <sys/vfs.h>
35#include <sys/vnode.h>
36#include <sys/systm.h>
37#include <sys/file.h>
38#include <sys/klwp.h>
39#include <sys/stropts.h>
40#include <sys/stream.h>
41#include <sys/strsubr.h>
42
43#include <sys/consdev.h>
44#include <sys/kbio.h>
45#include <sys/debug.h>
46#include <sys/reboot.h>
47#include <sys/termios.h>
48
49#include <sys/ddi.h>
50#include <sys/sunddi.h>
51#include <sys/modctl.h>
52#include <sys/ddi_impldefs.h>
53
54#include <sys/strsubr.h>
55#include <sys/errno.h>
56#include <sys/devops.h>
57#include <sys/note.h>
Jan Setje-Eilers48633f12009-03-02 18:20:31 -080058#include <sys/consplat.h>
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070059
60/*
61 * On supported configurations, the firmware defines the keyboard and mouse
62 * paths. However, during USB development, it is useful to be able to use
63 * the USB keyboard and mouse on machines without full USB firmware support.
64 * These variables may be set in /etc/system according to a machine's
65 * USB configuration. This module will override the firmware's values
66 * with these.
67 */
68static char *usb_kb_path = NULL;
69static char *usb_ms_path = NULL;
70
71/*
72 * This is the loadable module wrapper.
73 */
74extern struct mod_ops mod_miscops;
75
76/*
77 * Module linkage information for the kernel.
78 */
79static struct modlmisc modlmisc = {
Richard Bean39b361b2008-10-16 16:24:06 -050080 &mod_miscops, "console configuration"
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -070081};
82
83static struct modlinkage modlinkage = {
84 MODREV_1, (void *)&modlmisc, NULL
85};
86
87int
88_init(void)
89{
90 return (mod_install(&modlinkage));
91}
92
93int
94_fini(void)
95{
96 return (mod_remove(&modlinkage));
97}
98
99int
100_info(struct modinfo *modinfop)
101{
102 return (mod_info(&modlinkage, modinfop));
103}
104
105extern void dynamic_console_config(void);
Vincent Wang40482322009-10-14 01:13:43 +0800106extern boolean_t consconfig_dacf_initialized(void);
stevel@tonic-gate7c478bd2005-06-14 00:00:00 -0700107
108/*
109 * Configure keyboard and mouse. Main entry here.
110 */
111void
112consconfig(void)
113{
114 dynamic_console_config();
115}
116
117extern char *
118consconfig_get_usb_kb_path(void) {
119 if (usb_kb_path)
120 return (i_ddi_strdup(usb_kb_path, KM_SLEEP));
121 return (NULL);
122}
123
124extern char *
125consconfig_get_usb_ms_path(void) {
126 if (usb_ms_path)
127 return (i_ddi_strdup(usb_ms_path, KM_SLEEP));
128 return (NULL);
129}
Jan Setje-Eilers48633f12009-03-02 18:20:31 -0800130
131extern char *
132consconfig_get_plat_fbpath(void) {
133 return (plat_fbpath());
134}
Vincent Wang40482322009-10-14 01:13:43 +0800135
136extern boolean_t
137consconfig_console_is_ready(void) {
138 return (consconfig_dacf_initialized());
139}