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 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 #include <sys/modctl.h>
  28 #include <sys/sunddi.h>
  29 #include <sys/sunndi.h>
  30 
  31 /*
  32  * The hvm_bootstrap misc module is installed in the i86hvm platform
  33  * directly so it will only be loaded in HVM emulated environment.
  34  */
  35 
  36 
  37 /*
  38  * hvmboot_rootconf() exists to force attach all xdf disk driver nodes
  39  * before the pv cmdk disk driver comes along and tries to access any of
  40  * these nodes (which usually happens when mounting the root disk device
  41  * in an hvm environment).  See the block comments at the top of pv_cmdk.c
  42  * for more information about why this is necessary.
  43  *
  44  * hvmboot_rootconf() also force attaches xnf network driver nodes so
  45  * that boot interface can be plumbed when booted via the network.
  46  */
  47 int
  48 hvmboot_rootconf()
  49 {
  50         dev_info_t      *xpvd_dip;
  51         major_t         dev_major;
  52 
  53         dev_major = ddi_name_to_major("xdf");
  54         if (dev_major == (major_t)-1)
  55                 cmn_err(CE_PANIC, "unable to load xdf disk driver");
  56 
  57         if (resolve_pathname("/xpvd", &xpvd_dip, NULL, NULL) != 0)
  58                 cmn_err(CE_PANIC, "unable to configure /xpvd nexus");
  59 
  60         (void) ndi_devi_config_driver(xpvd_dip, 0, dev_major);
  61 
  62         dev_major = ddi_name_to_major("xnf");
  63         if (dev_major == (major_t)-1)
  64                 cmn_err(CE_PANIC, "unable to load xnf network driver");
  65         (void) ndi_devi_config_driver(xpvd_dip, 0, dev_major);
  66 
  67         ndi_rele_devi(xpvd_dip);
  68         return (0);
  69 }
  70 
  71 static struct modlmisc modlmisc = {
  72         &mod_miscops, "hvm_bootstrap misc module"
  73 };
  74 
  75 static struct modlinkage modlinkage = {
  76         MODREV_1, { (void *)&modlmisc, NULL }
  77 };
  78 
  79 int
  80 _info(struct modinfo *modinfop)
  81 {
  82         return (mod_info(&modlinkage, modinfop));
  83 }
  84 
  85 int
  86 _init()
  87 {
  88         return (mod_install(&modlinkage));
  89 }
  90 
  91 int
  92 _fini()
  93 {
  94         return (EBUSY);
  95 }