106bbe1e0Sedp /*
206bbe1e0Sedp  * CDDL HEADER START
306bbe1e0Sedp  *
406bbe1e0Sedp  * The contents of this file are subject to the terms of the
506bbe1e0Sedp  * Common Development and Distribution License (the "License").
606bbe1e0Sedp  * You may not use this file except in compliance with the License.
706bbe1e0Sedp  *
806bbe1e0Sedp  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
906bbe1e0Sedp  * or http://www.opensolaris.org/os/licensing.
1006bbe1e0Sedp  * See the License for the specific language governing permissions
1106bbe1e0Sedp  * and limitations under the License.
1206bbe1e0Sedp  *
1306bbe1e0Sedp  * When distributing Covered Code, include this CDDL HEADER in each
1406bbe1e0Sedp  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1506bbe1e0Sedp  * If applicable, add the following below this CDDL HEADER, with the
1606bbe1e0Sedp  * fields enclosed by brackets "[]" replaced with your own identifying
1706bbe1e0Sedp  * information: Portions Copyright [yyyy] [name of copyright owner]
1806bbe1e0Sedp  *
1906bbe1e0Sedp  * CDDL HEADER END
2006bbe1e0Sedp  */
2106bbe1e0Sedp 
2206bbe1e0Sedp /*
23*62b88567SRao Shoaib  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
2406bbe1e0Sedp  * Use is subject to license terms.
2506bbe1e0Sedp  */
2606bbe1e0Sedp 
2706bbe1e0Sedp #include <sys/modctl.h>
2806bbe1e0Sedp #include <sys/sunddi.h>
2906bbe1e0Sedp #include <sys/sunndi.h>
3006bbe1e0Sedp 
3106bbe1e0Sedp /*
3206bbe1e0Sedp  * The hvm_bootstrap misc module is installed in the i86hvm platform
3306bbe1e0Sedp  * directly so it will only be loaded in HVM emulated environment.
3406bbe1e0Sedp  */
3506bbe1e0Sedp 
3606bbe1e0Sedp 
3706bbe1e0Sedp /*
3806bbe1e0Sedp  * hvmboot_rootconf() exists to force attach all xdf disk driver nodes
3906bbe1e0Sedp  * before the pv cmdk disk driver comes along and tries to access any of
4006bbe1e0Sedp  * these nodes (which usually happens when mounting the root disk device
4106bbe1e0Sedp  * in an hvm environment).  See the block comments at the top of pv_cmdk.c
4206bbe1e0Sedp  * for more information about why this is necessary.
43*62b88567SRao Shoaib  *
44*62b88567SRao Shoaib  * hvmboot_rootconf() also force attaches xnf network driver nodes so
45*62b88567SRao Shoaib  * that boot interface can be plumbed when booted via the network.
4606bbe1e0Sedp  */
4706bbe1e0Sedp int
hvmboot_rootconf()4806bbe1e0Sedp hvmboot_rootconf()
4906bbe1e0Sedp {
5006bbe1e0Sedp 	dev_info_t	*xpvd_dip;
51*62b88567SRao Shoaib 	major_t		dev_major;
5206bbe1e0Sedp 
53*62b88567SRao Shoaib 	dev_major = ddi_name_to_major("xdf");
54*62b88567SRao Shoaib 	if (dev_major == (major_t)-1)
5506bbe1e0Sedp 		cmn_err(CE_PANIC, "unable to load xdf disk driver");
5606bbe1e0Sedp 
5706bbe1e0Sedp 	if (resolve_pathname("/xpvd", &xpvd_dip, NULL, NULL) != 0)
5806bbe1e0Sedp 		cmn_err(CE_PANIC, "unable to configure /xpvd nexus");
5906bbe1e0Sedp 
60*62b88567SRao Shoaib 	(void) ndi_devi_config_driver(xpvd_dip, 0, dev_major);
61*62b88567SRao Shoaib 
62*62b88567SRao Shoaib 	dev_major = ddi_name_to_major("xnf");
63*62b88567SRao Shoaib 	if (dev_major == (major_t)-1)
64*62b88567SRao Shoaib 		cmn_err(CE_PANIC, "unable to load xnf network driver");
65*62b88567SRao Shoaib 	(void) ndi_devi_config_driver(xpvd_dip, 0, dev_major);
6606bbe1e0Sedp 
6706bbe1e0Sedp 	ndi_rele_devi(xpvd_dip);
6806bbe1e0Sedp 	return (0);
6906bbe1e0Sedp }
7006bbe1e0Sedp 
7106bbe1e0Sedp static struct modlmisc modlmisc = {
7206bbe1e0Sedp 	&mod_miscops, "hvm_bootstrap misc module"
7306bbe1e0Sedp };
7406bbe1e0Sedp 
7506bbe1e0Sedp static struct modlinkage modlinkage = {
7606bbe1e0Sedp 	MODREV_1, (void *)&modlmisc, NULL
7706bbe1e0Sedp };
7806bbe1e0Sedp 
7906bbe1e0Sedp int
_info(struct modinfo * modinfop)8006bbe1e0Sedp _info(struct modinfo *modinfop)
8106bbe1e0Sedp {
8206bbe1e0Sedp 	return (mod_info(&modlinkage, modinfop));
8306bbe1e0Sedp }
8406bbe1e0Sedp 
8506bbe1e0Sedp int
_init()8606bbe1e0Sedp _init()
8706bbe1e0Sedp {
8806bbe1e0Sedp 	return (mod_install(&modlinkage));
8906bbe1e0Sedp }
9006bbe1e0Sedp 
9106bbe1e0Sedp int
_fini()9206bbe1e0Sedp _fini()
9306bbe1e0Sedp {
9406bbe1e0Sedp 	return (EBUSY);
9506bbe1e0Sedp }
96