xref: /onnv-gate/usr/src/uts/i86pc/i86hvm/io/hvm_bootstrap.c (revision 10119:4e23e3ec42f6)
16451Sedp /*
26451Sedp  * CDDL HEADER START
36451Sedp  *
46451Sedp  * The contents of this file are subject to the terms of the
56451Sedp  * Common Development and Distribution License (the "License").
66451Sedp  * You may not use this file except in compliance with the License.
76451Sedp  *
86451Sedp  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
96451Sedp  * or http://www.opensolaris.org/os/licensing.
106451Sedp  * See the License for the specific language governing permissions
116451Sedp  * and limitations under the License.
126451Sedp  *
136451Sedp  * When distributing Covered Code, include this CDDL HEADER in each
146451Sedp  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
156451Sedp  * If applicable, add the following below this CDDL HEADER, with the
166451Sedp  * fields enclosed by brackets "[]" replaced with your own identifying
176451Sedp  * information: Portions Copyright [yyyy] [name of copyright owner]
186451Sedp  *
196451Sedp  * CDDL HEADER END
206451Sedp  */
216451Sedp 
226451Sedp /*
23*10119SRao.Shoaib@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
246451Sedp  * Use is subject to license terms.
256451Sedp  */
266451Sedp 
276451Sedp #include <sys/modctl.h>
286451Sedp #include <sys/sunddi.h>
296451Sedp #include <sys/sunndi.h>
306451Sedp 
316451Sedp /*
326451Sedp  * The hvm_bootstrap misc module is installed in the i86hvm platform
336451Sedp  * directly so it will only be loaded in HVM emulated environment.
346451Sedp  */
356451Sedp 
366451Sedp 
376451Sedp /*
386451Sedp  * hvmboot_rootconf() exists to force attach all xdf disk driver nodes
396451Sedp  * before the pv cmdk disk driver comes along and tries to access any of
406451Sedp  * these nodes (which usually happens when mounting the root disk device
416451Sedp  * in an hvm environment).  See the block comments at the top of pv_cmdk.c
426451Sedp  * for more information about why this is necessary.
43*10119SRao.Shoaib@Sun.COM  *
44*10119SRao.Shoaib@Sun.COM  * hvmboot_rootconf() also force attaches xnf network driver nodes so
45*10119SRao.Shoaib@Sun.COM  * that boot interface can be plumbed when booted via the network.
466451Sedp  */
476451Sedp int
hvmboot_rootconf()486451Sedp hvmboot_rootconf()
496451Sedp {
506451Sedp 	dev_info_t	*xpvd_dip;
51*10119SRao.Shoaib@Sun.COM 	major_t		dev_major;
526451Sedp 
53*10119SRao.Shoaib@Sun.COM 	dev_major = ddi_name_to_major("xdf");
54*10119SRao.Shoaib@Sun.COM 	if (dev_major == (major_t)-1)
556451Sedp 		cmn_err(CE_PANIC, "unable to load xdf disk driver");
566451Sedp 
576451Sedp 	if (resolve_pathname("/xpvd", &xpvd_dip, NULL, NULL) != 0)
586451Sedp 		cmn_err(CE_PANIC, "unable to configure /xpvd nexus");
596451Sedp 
60*10119SRao.Shoaib@Sun.COM 	(void) ndi_devi_config_driver(xpvd_dip, 0, dev_major);
61*10119SRao.Shoaib@Sun.COM 
62*10119SRao.Shoaib@Sun.COM 	dev_major = ddi_name_to_major("xnf");
63*10119SRao.Shoaib@Sun.COM 	if (dev_major == (major_t)-1)
64*10119SRao.Shoaib@Sun.COM 		cmn_err(CE_PANIC, "unable to load xnf network driver");
65*10119SRao.Shoaib@Sun.COM 	(void) ndi_devi_config_driver(xpvd_dip, 0, dev_major);
666451Sedp 
676451Sedp 	ndi_rele_devi(xpvd_dip);
686451Sedp 	return (0);
696451Sedp }
706451Sedp 
716451Sedp static struct modlmisc modlmisc = {
726451Sedp 	&mod_miscops, "hvm_bootstrap misc module"
736451Sedp };
746451Sedp 
756451Sedp static struct modlinkage modlinkage = {
766451Sedp 	MODREV_1, (void *)&modlmisc, NULL
776451Sedp };
786451Sedp 
796451Sedp int
_info(struct modinfo * modinfop)806451Sedp _info(struct modinfo *modinfop)
816451Sedp {
826451Sedp 	return (mod_info(&modlinkage, modinfop));
836451Sedp }
846451Sedp 
856451Sedp int
_init()866451Sedp _init()
876451Sedp {
886451Sedp 	return (mod_install(&modlinkage));
896451Sedp }
906451Sedp 
916451Sedp int
_fini()926451Sedp _fini()
936451Sedp {
946451Sedp 	return (EBUSY);
956451Sedp }
96