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  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*
  27  * This file contains ddi functions needed during boot and DR.
  28  * Many functions in swapgeneric.c can be moved here.
  29  *
  30  * The object file is currently linked into unix.
  31  */
  32 
  33 #include <sys/bootconf.h>
  34 #include <sys/conf.h>
  35 #include <sys/ddi_impldefs.h>
  36 #include <sys/ddi_implfuncs.h>
  37 #include <sys/hwconf.h>
  38 #include <sys/instance.h>
  39 #include <sys/kmem.h>
  40 #include <sys/modctl.h>
  41 #include <sys/promif.h>
  42 #include <sys/sunndi.h>
  43 #include <sys/ndi_impldefs.h>
 
 
  58 /*
  59  * This lock must be held while updating devi_sibling pointers of
  60  * rootnex immediate children
  61  */
  62 kmutex_t global_vhci_lock;
  63 
  64 major_t mm_major;
  65 major_t nulldriver_major;
  66 
  67 /*
  68  * Forward declarations
  69  */
  70 static void impl_create_root_class(void);
  71 static void create_devinfo_tree(void);
  72 
  73 #if defined(__x86)
  74 char *bootpath_prop = NULL;
  75 char *fstype_prop = NULL;
  76 #endif
  77 
  78 /*
  79  * Setup the DDI but don't necessarily init the DDI.  This will happen
  80  * later once /boot is released.
  81  */
  82 void
  83 setup_ddi(void)
  84 {
  85         impl_ddi_init_nodeid();
  86         impl_create_root_class();
  87         create_devinfo_tree();
  88         e_ddi_instance_init();
  89         impl_ddi_callback_init();
  90         log_event_init();
  91         fm_init();
  92         ndi_fm_init();
  93         irm_init();
  94 
  95         (void) i_ddi_load_drvconf(DDI_MAJOR_T_NONE);
  96 
  97         ldi_init();
 
 173 
 174                 /*
 175                  * Resort to the emergency measure of blowing away the
 176                  * existing hash entry and replacing it with rootname's.
 177                  */
 178                 delete_mbind(rootname, mb_hashtab);
 179                 if (make_mbind(rootname, major, NULL, mb_hashtab) != 0)
 180                         panic("mb_hashtab: inconsistent state.");
 181         }
 182 
 183         /*
 184          * The `platform' or `implementation architecture' name has been
 185          * translated by boot to be proper for file system use.  It is
 186          * the `name' of the platform actually booted.  Note the assumption
 187          * is that the name will `fit' in the buffer platform (which is
 188          * of size SYS_NMLN, which is far bigger than will actually ever
 189          * be needed).
 190          */
 191         (void) BOP_GETPROP(bootops, "impl-arch-name", platform);
 192 
 193 #if defined(__x86)
 194         /*
 195          * Retrieve and honor the bootpath and optional fstype properties
 196          */
 197         size = (size_t)BOP_GETPROPLEN(bootops, "bootpath");
 198         if (size != -1) {
 199                 bootpath_prop = kmem_zalloc(size, KM_SLEEP);
 200                 (void) BOP_GETPROP(bootops, "bootpath", bootpath_prop);
 201                 setbootpath(bootpath_prop);
 202         }
 203 
 204         size = (size_t)BOP_GETPROPLEN(bootops, "fstype");
 205         if (size != -1) {
 206                 fstype_prop = kmem_zalloc(size, KM_SLEEP);
 207                 (void) BOP_GETPROP(bootops, "fstype", fstype_prop);
 208                 setbootfstype(fstype_prop);
 209         }
 210 #endif
 211 }
 212 
 
 | 
 
 
   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  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  * Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
  25  */
  26 
  27 /*
  28  * This file contains ddi functions needed during boot and DR.
  29  * Many functions in swapgeneric.c can be moved here.
  30  *
  31  * The object file is currently linked into unix.
  32  */
  33 
  34 #include <sys/bootconf.h>
  35 #include <sys/conf.h>
  36 #include <sys/ddi_impldefs.h>
  37 #include <sys/ddi_implfuncs.h>
  38 #include <sys/hwconf.h>
  39 #include <sys/instance.h>
  40 #include <sys/kmem.h>
  41 #include <sys/modctl.h>
  42 #include <sys/promif.h>
  43 #include <sys/sunndi.h>
  44 #include <sys/ndi_impldefs.h>
 
 
  59 /*
  60  * This lock must be held while updating devi_sibling pointers of
  61  * rootnex immediate children
  62  */
  63 kmutex_t global_vhci_lock;
  64 
  65 major_t mm_major;
  66 major_t nulldriver_major;
  67 
  68 /*
  69  * Forward declarations
  70  */
  71 static void impl_create_root_class(void);
  72 static void create_devinfo_tree(void);
  73 
  74 #if defined(__x86)
  75 char *bootpath_prop = NULL;
  76 char *fstype_prop = NULL;
  77 #endif
  78 
  79 char *aoepath_prop = NULL;
  80 
  81 /*
  82  * Setup the DDI but don't necessarily init the DDI.  This will happen
  83  * later once /boot is released.
  84  */
  85 void
  86 setup_ddi(void)
  87 {
  88         impl_ddi_init_nodeid();
  89         impl_create_root_class();
  90         create_devinfo_tree();
  91         e_ddi_instance_init();
  92         impl_ddi_callback_init();
  93         log_event_init();
  94         fm_init();
  95         ndi_fm_init();
  96         irm_init();
  97 
  98         (void) i_ddi_load_drvconf(DDI_MAJOR_T_NONE);
  99 
 100         ldi_init();
 
 176 
 177                 /*
 178                  * Resort to the emergency measure of blowing away the
 179                  * existing hash entry and replacing it with rootname's.
 180                  */
 181                 delete_mbind(rootname, mb_hashtab);
 182                 if (make_mbind(rootname, major, NULL, mb_hashtab) != 0)
 183                         panic("mb_hashtab: inconsistent state.");
 184         }
 185 
 186         /*
 187          * The `platform' or `implementation architecture' name has been
 188          * translated by boot to be proper for file system use.  It is
 189          * the `name' of the platform actually booted.  Note the assumption
 190          * is that the name will `fit' in the buffer platform (which is
 191          * of size SYS_NMLN, which is far bigger than will actually ever
 192          * be needed).
 193          */
 194         (void) BOP_GETPROP(bootops, "impl-arch-name", platform);
 195 
 196         /*
 197          * If boot-aoepath is defined, assume it's AoE boot and set bootpath to
 198          * aoeblk/blkdev device corresponding to specified shelf.slot numbers.
 199          */
 200         size = (size_t)BOP_GETPROPLEN(bootops, "boot-aoepath");
 201         if (size != -1) {
 202                 char    aoedev[MAXPATHLEN];
 203                 char    *delim;
 204                 int     shelf, slot;
 205 
 206                 aoepath_prop = kmem_zalloc(size, KM_SLEEP);
 207                 (void) BOP_GETPROP(bootops, "boot-aoepath", aoepath_prop);
 208                 /*
 209                  * If boot-aoepath is set to "auto", device will be
 210                  * configured later during AoE autoconfiguration.
 211                  */
 212                 if (strcmp(aoepath_prop, "auto") != 0) {
 213                         if ((delim = strchr(aoepath_prop, '.')) != NULL)
 214                                 *delim++ = '\0';
 215                         if (ddi_strtol(aoepath_prop, (char **)NULL, 10,
 216                             (long *)&shelf) != 0)
 217                                 shelf = 0;
 218                         if (delim == NULL ||
 219                             ddi_strtol(delim, (char **)NULL, 10,
 220                             (long *)&slot) != 0)
 221                                 slot = 0;
 222                         /* FIXME aoeblk@0,0 ?! */
 223                         (void) snprintf(aoedev, MAXPATHLEN,
 224                             "/aoe/aoeblk@0,0/blkdev@%d,%d",
 225                             shelf, slot);
 226                         setbootpath(aoedev);
 227                 }
 228         }
 229 
 230 #if defined(__x86)
 231         /*
 232          * Retrieve and honor the bootpath and optional fstype properties
 233          */
 234         size = (size_t)BOP_GETPROPLEN(bootops, "bootpath");
 235         if (size != -1) {
 236                 bootpath_prop = kmem_zalloc(size, KM_SLEEP);
 237                 (void) BOP_GETPROP(bootops, "bootpath", bootpath_prop);
 238                 setbootpath(bootpath_prop);
 239         }
 240 
 241         size = (size_t)BOP_GETPROPLEN(bootops, "fstype");
 242         if (size != -1) {
 243                 fstype_prop = kmem_zalloc(size, KM_SLEEP);
 244                 (void) BOP_GETPROP(bootops, "fstype", fstype_prop);
 245                 setbootfstype(fstype_prop);
 246         }
 247 #endif
 248 }
 249 
 
 |