xref: /titanic_51/usr/src/uts/i86pc/i86hvm/io/hvm_bootstrap.c (revision 62b885670cb2373723bdad8e9fc26c05f8dabfb6)
1eb0cc229Sedp /*
2eb0cc229Sedp  * CDDL HEADER START
3eb0cc229Sedp  *
4eb0cc229Sedp  * The contents of this file are subject to the terms of the
5eb0cc229Sedp  * Common Development and Distribution License (the "License").
6eb0cc229Sedp  * You may not use this file except in compliance with the License.
7eb0cc229Sedp  *
8eb0cc229Sedp  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9eb0cc229Sedp  * or http://www.opensolaris.org/os/licensing.
10eb0cc229Sedp  * See the License for the specific language governing permissions
11eb0cc229Sedp  * and limitations under the License.
12eb0cc229Sedp  *
13eb0cc229Sedp  * When distributing Covered Code, include this CDDL HEADER in each
14eb0cc229Sedp  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15eb0cc229Sedp  * If applicable, add the following below this CDDL HEADER, with the
16eb0cc229Sedp  * fields enclosed by brackets "[]" replaced with your own identifying
17eb0cc229Sedp  * information: Portions Copyright [yyyy] [name of copyright owner]
18eb0cc229Sedp  *
19eb0cc229Sedp  * CDDL HEADER END
20eb0cc229Sedp  */
21eb0cc229Sedp 
22eb0cc229Sedp /*
23*62b88567SRao Shoaib  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24eb0cc229Sedp  * Use is subject to license terms.
25eb0cc229Sedp  */
26eb0cc229Sedp 
27eb0cc229Sedp #include <sys/modctl.h>
28eb0cc229Sedp #include <sys/sunddi.h>
29eb0cc229Sedp #include <sys/sunndi.h>
30eb0cc229Sedp 
31eb0cc229Sedp /*
32eb0cc229Sedp  * The hvm_bootstrap misc module is installed in the i86hvm platform
33eb0cc229Sedp  * directly so it will only be loaded in HVM emulated environment.
34eb0cc229Sedp  */
35eb0cc229Sedp 
36eb0cc229Sedp 
37eb0cc229Sedp /*
38eb0cc229Sedp  * hvmboot_rootconf() exists to force attach all xdf disk driver nodes
39eb0cc229Sedp  * before the pv cmdk disk driver comes along and tries to access any of
40eb0cc229Sedp  * these nodes (which usually happens when mounting the root disk device
41eb0cc229Sedp  * in an hvm environment).  See the block comments at the top of pv_cmdk.c
42eb0cc229Sedp  * 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.
46eb0cc229Sedp  */
47eb0cc229Sedp int
48eb0cc229Sedp hvmboot_rootconf()
49eb0cc229Sedp {
50eb0cc229Sedp 	dev_info_t	*xpvd_dip;
51*62b88567SRao Shoaib 	major_t		dev_major;
52eb0cc229Sedp 
53*62b88567SRao Shoaib 	dev_major = ddi_name_to_major("xdf");
54*62b88567SRao Shoaib 	if (dev_major == (major_t)-1)
55eb0cc229Sedp 		cmn_err(CE_PANIC, "unable to load xdf disk driver");
56eb0cc229Sedp 
57eb0cc229Sedp 	if (resolve_pathname("/xpvd", &xpvd_dip, NULL, NULL) != 0)
58eb0cc229Sedp 		cmn_err(CE_PANIC, "unable to configure /xpvd nexus");
59eb0cc229Sedp 
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);
66eb0cc229Sedp 
67eb0cc229Sedp 	ndi_rele_devi(xpvd_dip);
68eb0cc229Sedp 	return (0);
69eb0cc229Sedp }
70eb0cc229Sedp 
71eb0cc229Sedp static struct modlmisc modlmisc = {
72eb0cc229Sedp 	&mod_miscops, "hvm_bootstrap misc module"
73eb0cc229Sedp };
74eb0cc229Sedp 
75eb0cc229Sedp static struct modlinkage modlinkage = {
76eb0cc229Sedp 	MODREV_1, (void *)&modlmisc, NULL
77eb0cc229Sedp };
78eb0cc229Sedp 
79eb0cc229Sedp int
80eb0cc229Sedp _info(struct modinfo *modinfop)
81eb0cc229Sedp {
82eb0cc229Sedp 	return (mod_info(&modlinkage, modinfop));
83eb0cc229Sedp }
84eb0cc229Sedp 
85eb0cc229Sedp int
86eb0cc229Sedp _init()
87eb0cc229Sedp {
88eb0cc229Sedp 	return (mod_install(&modlinkage));
89eb0cc229Sedp }
90eb0cc229Sedp 
91eb0cc229Sedp int
92eb0cc229Sedp _fini()
93eb0cc229Sedp {
94eb0cc229Sedp 	return (EBUSY);
95eb0cc229Sedp }
96