xref: /titanic_50/usr/src/uts/i86pc/i86hvm/io/hvm_bootstrap.c (revision 45179f4335d029f1129eb7283f8087740f0395f1)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
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 
22 /*
23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 #include <sys/modctl.h>
30 #include <sys/sunddi.h>
31 #include <sys/sunndi.h>
32 
33 /*
34  * The hvm_bootstrap misc module is installed in the i86hvm platform
35  * directly so it will only be loaded in HVM emulated environment.
36  */
37 
38 
39 /*
40  * hvmboot_rootconf() exists to force attach all xdf disk driver nodes
41  * before the pv cmdk disk driver comes along and tries to access any of
42  * these nodes (which usually happens when mounting the root disk device
43  * in an hvm environment).  See the block comments at the top of pv_cmdk.c
44  * for more information about why this is necessary.
45  */
46 int
47 hvmboot_rootconf()
48 {
49 	dev_info_t	*xpvd_dip;
50 	major_t		xdf_major;
51 
52 	xdf_major = ddi_name_to_major("xdf");
53 	if (xdf_major == (major_t)-1)
54 		cmn_err(CE_PANIC, "unable to load xdf disk driver");
55 
56 	if (resolve_pathname("/xpvd", &xpvd_dip, NULL, NULL) != 0)
57 		cmn_err(CE_PANIC, "unable to configure /xpvd nexus");
58 
59 	(void) ndi_devi_config_driver(xpvd_dip, 0, xdf_major);
60 
61 	ndi_rele_devi(xpvd_dip);
62 	return (0);
63 }
64 
65 static struct modlmisc modlmisc = {
66 	&mod_miscops, "hvm_bootstrap misc module"
67 };
68 
69 static struct modlinkage modlinkage = {
70 	MODREV_1, (void *)&modlmisc, NULL
71 };
72 
73 int
74 _info(struct modinfo *modinfop)
75 {
76 	return (mod_info(&modlinkage, modinfop));
77 }
78 
79 int
80 _init()
81 {
82 	return (mod_install(&modlinkage));
83 }
84 
85 int
86 _fini()
87 {
88 	return (EBUSY);
89 }
90