xref: /illumos-gate/usr/src/uts/common/io/consconfig.c (revision 40482326)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
539b361b2SRichard Bean  * Common Development and Distribution License (the "License").
639b361b2SRichard Bean  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
2248633f18SJan Setje-Eilers  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /*
277c478bd9Sstevel@tonic-gate  * Console and mouse configuration
287c478bd9Sstevel@tonic-gate  */
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #include <sys/types.h>
317c478bd9Sstevel@tonic-gate #include <sys/param.h>
327c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
337c478bd9Sstevel@tonic-gate #include <sys/user.h>
347c478bd9Sstevel@tonic-gate #include <sys/vfs.h>
357c478bd9Sstevel@tonic-gate #include <sys/vnode.h>
367c478bd9Sstevel@tonic-gate #include <sys/systm.h>
377c478bd9Sstevel@tonic-gate #include <sys/file.h>
387c478bd9Sstevel@tonic-gate #include <sys/klwp.h>
397c478bd9Sstevel@tonic-gate #include <sys/stropts.h>
407c478bd9Sstevel@tonic-gate #include <sys/stream.h>
417c478bd9Sstevel@tonic-gate #include <sys/strsubr.h>
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate #include <sys/consdev.h>
447c478bd9Sstevel@tonic-gate #include <sys/kbio.h>
457c478bd9Sstevel@tonic-gate #include <sys/debug.h>
467c478bd9Sstevel@tonic-gate #include <sys/reboot.h>
477c478bd9Sstevel@tonic-gate #include <sys/termios.h>
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate #include <sys/ddi.h>
507c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
517c478bd9Sstevel@tonic-gate #include <sys/modctl.h>
527c478bd9Sstevel@tonic-gate #include <sys/ddi_impldefs.h>
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate #include <sys/strsubr.h>
557c478bd9Sstevel@tonic-gate #include <sys/errno.h>
567c478bd9Sstevel@tonic-gate #include <sys/devops.h>
577c478bd9Sstevel@tonic-gate #include <sys/note.h>
5848633f18SJan Setje-Eilers #include <sys/consplat.h>
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate /*
617c478bd9Sstevel@tonic-gate  * On supported configurations, the firmware defines the keyboard and mouse
627c478bd9Sstevel@tonic-gate  * paths.  However, during USB development, it is useful to be able to use
637c478bd9Sstevel@tonic-gate  * the USB keyboard and mouse on machines without full USB firmware support.
647c478bd9Sstevel@tonic-gate  * These variables may be set in /etc/system according to a machine's
657c478bd9Sstevel@tonic-gate  * USB configuration.  This module will override the firmware's values
667c478bd9Sstevel@tonic-gate  * with these.
677c478bd9Sstevel@tonic-gate  */
687c478bd9Sstevel@tonic-gate static char *usb_kb_path = NULL;
697c478bd9Sstevel@tonic-gate static char *usb_ms_path = NULL;
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate /*
727c478bd9Sstevel@tonic-gate  * This is the loadable module wrapper.
737c478bd9Sstevel@tonic-gate  */
747c478bd9Sstevel@tonic-gate extern struct mod_ops mod_miscops;
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate /*
777c478bd9Sstevel@tonic-gate  * Module linkage information for the kernel.
787c478bd9Sstevel@tonic-gate  */
797c478bd9Sstevel@tonic-gate static struct modlmisc modlmisc = {
8039b361b2SRichard Bean 	&mod_miscops, "console configuration"
817c478bd9Sstevel@tonic-gate };
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate static struct modlinkage modlinkage = {
847c478bd9Sstevel@tonic-gate 	MODREV_1, (void *)&modlmisc, NULL
857c478bd9Sstevel@tonic-gate };
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate int
_init(void)887c478bd9Sstevel@tonic-gate _init(void)
897c478bd9Sstevel@tonic-gate {
907c478bd9Sstevel@tonic-gate 	return (mod_install(&modlinkage));
917c478bd9Sstevel@tonic-gate }
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate int
_fini(void)947c478bd9Sstevel@tonic-gate _fini(void)
957c478bd9Sstevel@tonic-gate {
967c478bd9Sstevel@tonic-gate 	return (mod_remove(&modlinkage));
977c478bd9Sstevel@tonic-gate }
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate int
_info(struct modinfo * modinfop)1007c478bd9Sstevel@tonic-gate _info(struct modinfo *modinfop)
1017c478bd9Sstevel@tonic-gate {
1027c478bd9Sstevel@tonic-gate 	return (mod_info(&modlinkage, modinfop));
1037c478bd9Sstevel@tonic-gate }
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate extern void dynamic_console_config(void);
106*40482326SVincent Wang extern boolean_t consconfig_dacf_initialized(void);
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate /*
1097c478bd9Sstevel@tonic-gate  * Configure keyboard and mouse. Main entry here.
1107c478bd9Sstevel@tonic-gate  */
1117c478bd9Sstevel@tonic-gate void
consconfig(void)1127c478bd9Sstevel@tonic-gate consconfig(void)
1137c478bd9Sstevel@tonic-gate {
1147c478bd9Sstevel@tonic-gate 	dynamic_console_config();
1157c478bd9Sstevel@tonic-gate }
1167c478bd9Sstevel@tonic-gate 
1177c478bd9Sstevel@tonic-gate extern char *
consconfig_get_usb_kb_path(void)1187c478bd9Sstevel@tonic-gate consconfig_get_usb_kb_path(void) {
1197c478bd9Sstevel@tonic-gate 	if (usb_kb_path)
1207c478bd9Sstevel@tonic-gate 		return (i_ddi_strdup(usb_kb_path, KM_SLEEP));
1217c478bd9Sstevel@tonic-gate 	return (NULL);
1227c478bd9Sstevel@tonic-gate }
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate extern char *
consconfig_get_usb_ms_path(void)1257c478bd9Sstevel@tonic-gate consconfig_get_usb_ms_path(void) {
1267c478bd9Sstevel@tonic-gate 	if (usb_ms_path)
1277c478bd9Sstevel@tonic-gate 		return (i_ddi_strdup(usb_ms_path, KM_SLEEP));
1287c478bd9Sstevel@tonic-gate 	return (NULL);
1297c478bd9Sstevel@tonic-gate }
13048633f18SJan Setje-Eilers 
13148633f18SJan Setje-Eilers extern char *
consconfig_get_plat_fbpath(void)13248633f18SJan Setje-Eilers consconfig_get_plat_fbpath(void) {
13348633f18SJan Setje-Eilers 	return (plat_fbpath());
13448633f18SJan Setje-Eilers }
135*40482326SVincent Wang 
136*40482326SVincent Wang extern boolean_t
consconfig_console_is_ready(void)137*40482326SVincent Wang consconfig_console_is_ready(void) {
138*40482326SVincent Wang 	return (consconfig_dacf_initialized());
139*40482326SVincent Wang }
140