10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 54145Scth * Common Development and Distribution License (the "License"). 64145Scth * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 226582Ssetje * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate /* 270Sstevel@tonic-gate * This file contains ddi functions needed during boot and DR. 280Sstevel@tonic-gate * Many functions in swapgeneric.c can be moved here. 290Sstevel@tonic-gate * 300Sstevel@tonic-gate * The object file is currently linked into unix. 310Sstevel@tonic-gate */ 320Sstevel@tonic-gate 330Sstevel@tonic-gate #include <sys/bootconf.h> 340Sstevel@tonic-gate #include <sys/conf.h> 350Sstevel@tonic-gate #include <sys/ddi_impldefs.h> 360Sstevel@tonic-gate #include <sys/ddi_implfuncs.h> 370Sstevel@tonic-gate #include <sys/hwconf.h> 380Sstevel@tonic-gate #include <sys/instance.h> 390Sstevel@tonic-gate #include <sys/kmem.h> 400Sstevel@tonic-gate #include <sys/modctl.h> 410Sstevel@tonic-gate #include <sys/promif.h> 420Sstevel@tonic-gate #include <sys/sunndi.h> 430Sstevel@tonic-gate #include <sys/ndi_impldefs.h> 440Sstevel@tonic-gate #include <sys/systeminfo.h> 450Sstevel@tonic-gate #include <sys/hwconf.h> 460Sstevel@tonic-gate #include <sys/sysevent_impl.h> 470Sstevel@tonic-gate #include <sys/sunldi_impl.h> 480Sstevel@tonic-gate #include <sys/disp.h> 495648Ssetje #include <sys/bootconf.h> 500Sstevel@tonic-gate #include <sys/fm/util.h> 517931SSean.Ye@Sun.COM #include <sys/ddifm_impl.h> 520Sstevel@tonic-gate 530Sstevel@tonic-gate extern dev_info_t *top_devinfo; 540Sstevel@tonic-gate extern dev_info_t *scsi_vhci_dip; 550Sstevel@tonic-gate extern struct hwc_class *hcl_head; 560Sstevel@tonic-gate static char *rootname; /* node name of top_devinfo */ 570Sstevel@tonic-gate 580Sstevel@tonic-gate /* 590Sstevel@tonic-gate * This lock must be held while updating devi_sibling pointers of 600Sstevel@tonic-gate * rootnex immediate children 610Sstevel@tonic-gate */ 620Sstevel@tonic-gate kmutex_t global_vhci_lock; 630Sstevel@tonic-gate 640Sstevel@tonic-gate major_t mm_major; 65*8011SChris.Horne@Sun.COM major_t nulldriver_major; 660Sstevel@tonic-gate 670Sstevel@tonic-gate /* 680Sstevel@tonic-gate * Forward declarations 690Sstevel@tonic-gate */ 700Sstevel@tonic-gate static void impl_create_root_class(void); 710Sstevel@tonic-gate static void create_devinfo_tree(void); 720Sstevel@tonic-gate 730Sstevel@tonic-gate #if defined(__x86) 740Sstevel@tonic-gate char *bootpath_prop = NULL; 750Sstevel@tonic-gate char *fstype_prop = NULL; 760Sstevel@tonic-gate #endif 770Sstevel@tonic-gate 780Sstevel@tonic-gate /* 790Sstevel@tonic-gate * Setup the DDI but don't necessarily init the DDI. This will happen 800Sstevel@tonic-gate * later once /boot is released. 810Sstevel@tonic-gate */ 820Sstevel@tonic-gate void 830Sstevel@tonic-gate setup_ddi(void) 840Sstevel@tonic-gate { 850Sstevel@tonic-gate impl_ddi_init_nodeid(); 860Sstevel@tonic-gate impl_create_root_class(); 870Sstevel@tonic-gate create_devinfo_tree(); 880Sstevel@tonic-gate e_ddi_instance_init(); 890Sstevel@tonic-gate impl_ddi_callback_init(); 900Sstevel@tonic-gate log_event_init(); 910Sstevel@tonic-gate fm_init(); 927931SSean.Ye@Sun.COM ndi_fm_init(); 930Sstevel@tonic-gate 947009Scth (void) i_ddi_load_drvconf(DDI_MAJOR_T_NONE); 950Sstevel@tonic-gate 960Sstevel@tonic-gate ldi_init(); 970Sstevel@tonic-gate 980Sstevel@tonic-gate i_ddi_devices_init(); 990Sstevel@tonic-gate i_ddi_read_devices_files(); 1000Sstevel@tonic-gate } 1010Sstevel@tonic-gate 1020Sstevel@tonic-gate /* 1030Sstevel@tonic-gate * Perform setup actions post startup (i_ddi_io_initialized) 1040Sstevel@tonic-gate */ 1050Sstevel@tonic-gate void 1060Sstevel@tonic-gate setup_ddi_poststartup(void) 1070Sstevel@tonic-gate { 1080Sstevel@tonic-gate extern void i_ddi_start_flush_daemon(void); 1090Sstevel@tonic-gate extern void i_ddi_intr_redist_all_cpus(void); 1100Sstevel@tonic-gate 1110Sstevel@tonic-gate i_ddi_start_flush_daemon(); 1120Sstevel@tonic-gate 1130Sstevel@tonic-gate /* 1140Sstevel@tonic-gate * For platforms that support INTR_WEIGHTED_DIST, we perform a 1150Sstevel@tonic-gate * redistribution at this point (after NICs configured) so that 1160Sstevel@tonic-gate * "isolation" relative to "ddi-intr-weight" occurs. 1170Sstevel@tonic-gate */ 1180Sstevel@tonic-gate i_ddi_intr_redist_all_cpus(); 1190Sstevel@tonic-gate } 1200Sstevel@tonic-gate 1210Sstevel@tonic-gate /* 1220Sstevel@tonic-gate * Create classes and major number bindings for the name of my root. 1230Sstevel@tonic-gate * Called immediately before 'loadrootmodules' 1240Sstevel@tonic-gate */ 1250Sstevel@tonic-gate static void 1260Sstevel@tonic-gate impl_create_root_class(void) 1270Sstevel@tonic-gate { 1280Sstevel@tonic-gate major_t major; 1290Sstevel@tonic-gate size_t size; 1300Sstevel@tonic-gate char *cp; 1310Sstevel@tonic-gate 1320Sstevel@tonic-gate /* 1330Sstevel@tonic-gate * The name for the root nexus is exactly as the manufacturer 1340Sstevel@tonic-gate * placed it in the prom name property. No translation. 1350Sstevel@tonic-gate */ 1367009Scth if ((major = ddi_name_to_major("rootnex")) == DDI_MAJOR_T_NONE) 1370Sstevel@tonic-gate panic("Couldn't find major number for 'rootnex'"); 1380Sstevel@tonic-gate 1396582Ssetje /* 1406582Ssetje * C OBP (Serengeti) does not include the NULL when returning 1416582Ssetje * the length of the name property, while this violates 1275, 1426582Ssetje * Solaris needs to work around this by allocating space for 1436582Ssetje * an extra character. 1446582Ssetje */ 1456582Ssetje size = (size_t)BOP_GETPROPLEN(bootops, "mfg-name") + 1; 1460Sstevel@tonic-gate rootname = kmem_zalloc(size, KM_SLEEP); 1470Sstevel@tonic-gate (void) BOP_GETPROP(bootops, "mfg-name", rootname); 1480Sstevel@tonic-gate 1490Sstevel@tonic-gate /* 1500Sstevel@tonic-gate * Fix conflict between OBP names and filesystem names. 1510Sstevel@tonic-gate * Substitute '_' for '/' in the name. Ick. This is only 1520Sstevel@tonic-gate * needed for the root node since '/' is not a legal name 1530Sstevel@tonic-gate * character in an OBP device name. 1540Sstevel@tonic-gate */ 1550Sstevel@tonic-gate for (cp = rootname; *cp; cp++) 1560Sstevel@tonic-gate if (*cp == '/') 1570Sstevel@tonic-gate *cp = '_'; 1580Sstevel@tonic-gate 1590Sstevel@tonic-gate /* 1600Sstevel@tonic-gate * Bind rootname to rootnex driver 1610Sstevel@tonic-gate */ 1620Sstevel@tonic-gate if (make_mbind(rootname, major, NULL, mb_hashtab) != 0) { 1630Sstevel@tonic-gate cmn_err(CE_WARN, "A driver or driver alias has already " 1640Sstevel@tonic-gate "registered the name \"%s\". The root nexus needs to " 1650Sstevel@tonic-gate "use this name, and will override the existing entry. " 1660Sstevel@tonic-gate "Please correct /etc/name_to_major and/or " 1670Sstevel@tonic-gate "/etc/driver_aliases and reboot.", rootname); 1680Sstevel@tonic-gate 1690Sstevel@tonic-gate /* 1700Sstevel@tonic-gate * Resort to the emergency measure of blowing away the 1710Sstevel@tonic-gate * existing hash entry and replacing it with rootname's. 1720Sstevel@tonic-gate */ 1730Sstevel@tonic-gate delete_mbind(rootname, mb_hashtab); 1740Sstevel@tonic-gate if (make_mbind(rootname, major, NULL, mb_hashtab) != 0) 1750Sstevel@tonic-gate panic("mb_hashtab: inconsistent state."); 1760Sstevel@tonic-gate } 1770Sstevel@tonic-gate 1780Sstevel@tonic-gate /* 1790Sstevel@tonic-gate * The `platform' or `implementation architecture' name has been 1800Sstevel@tonic-gate * translated by boot to be proper for file system use. It is 1810Sstevel@tonic-gate * the `name' of the platform actually booted. Note the assumption 1820Sstevel@tonic-gate * is that the name will `fit' in the buffer platform (which is 1830Sstevel@tonic-gate * of size SYS_NMLN, which is far bigger than will actually ever 1840Sstevel@tonic-gate * be needed). 1850Sstevel@tonic-gate */ 1860Sstevel@tonic-gate (void) BOP_GETPROP(bootops, "impl-arch-name", platform); 1870Sstevel@tonic-gate 1880Sstevel@tonic-gate #if defined(__x86) 1890Sstevel@tonic-gate /* 1900Sstevel@tonic-gate * Retrieve and honor the bootpath and optional fstype properties 1910Sstevel@tonic-gate */ 1920Sstevel@tonic-gate size = (size_t)BOP_GETPROPLEN(bootops, "bootpath"); 1930Sstevel@tonic-gate if (size != -1) { 1940Sstevel@tonic-gate bootpath_prop = kmem_zalloc(size, KM_SLEEP); 1950Sstevel@tonic-gate (void) BOP_GETPROP(bootops, "bootpath", bootpath_prop); 1960Sstevel@tonic-gate setbootpath(bootpath_prop); 1970Sstevel@tonic-gate } 1980Sstevel@tonic-gate 1990Sstevel@tonic-gate size = (size_t)BOP_GETPROPLEN(bootops, "fstype"); 2000Sstevel@tonic-gate if (size != -1) { 2010Sstevel@tonic-gate fstype_prop = kmem_zalloc(size, KM_SLEEP); 2020Sstevel@tonic-gate (void) BOP_GETPROP(bootops, "fstype", fstype_prop); 2030Sstevel@tonic-gate setbootfstype(fstype_prop); 2040Sstevel@tonic-gate } 2050Sstevel@tonic-gate #endif 2060Sstevel@tonic-gate } 2070Sstevel@tonic-gate 2080Sstevel@tonic-gate /* 2090Sstevel@tonic-gate * Note that this routine does not take into account the endianness 2100Sstevel@tonic-gate * of the host or the device (or PROM) when retrieving properties. 2110Sstevel@tonic-gate */ 2120Sstevel@tonic-gate static int 2130Sstevel@tonic-gate getlongprop_buf(int id, char *name, char *buf, int maxlen) 2140Sstevel@tonic-gate { 2150Sstevel@tonic-gate int size; 2160Sstevel@tonic-gate 217789Sahrens size = prom_getproplen((pnode_t)id, name); 2180Sstevel@tonic-gate if (size <= 0 || (size > maxlen - 1)) 2190Sstevel@tonic-gate return (-1); 2200Sstevel@tonic-gate 221789Sahrens if (-1 == prom_getprop((pnode_t)id, name, buf)) 2220Sstevel@tonic-gate return (-1); 2230Sstevel@tonic-gate 2240Sstevel@tonic-gate /* 2250Sstevel@tonic-gate * Workaround for bugid 1085575 - OBP may return a "name" property 2260Sstevel@tonic-gate * without null terminating the string with '\0'. When this occurs, 2270Sstevel@tonic-gate * append a '\0' and return (size + 1). 2280Sstevel@tonic-gate */ 2290Sstevel@tonic-gate if (strcmp("name", name) == 0) { 2300Sstevel@tonic-gate if (buf[size - 1] != '\0') { 2310Sstevel@tonic-gate buf[size] = '\0'; 2320Sstevel@tonic-gate size += 1; 2330Sstevel@tonic-gate } 2340Sstevel@tonic-gate } 2350Sstevel@tonic-gate 2360Sstevel@tonic-gate return (size); 2370Sstevel@tonic-gate } 2380Sstevel@tonic-gate 2390Sstevel@tonic-gate /*ARGSUSED1*/ 2400Sstevel@tonic-gate static int 2410Sstevel@tonic-gate get_neighbors(dev_info_t *di, int flag) 2420Sstevel@tonic-gate { 2430Sstevel@tonic-gate register int nid, snid, cnid; 2440Sstevel@tonic-gate dev_info_t *parent; 2450Sstevel@tonic-gate char buf[OBP_MAXPROPNAME]; 2460Sstevel@tonic-gate 2470Sstevel@tonic-gate if (di == NULL) 2480Sstevel@tonic-gate return (DDI_WALK_CONTINUE); 2490Sstevel@tonic-gate 2500Sstevel@tonic-gate nid = ddi_get_nodeid(di); 2510Sstevel@tonic-gate 2520Sstevel@tonic-gate snid = cnid = 0; 2530Sstevel@tonic-gate switch (flag) { 2540Sstevel@tonic-gate case DDI_WALK_PRUNESIB: 255789Sahrens cnid = (int)prom_childnode((pnode_t)nid); 2560Sstevel@tonic-gate break; 2570Sstevel@tonic-gate case DDI_WALK_PRUNECHILD: 258789Sahrens snid = (int)prom_nextnode((pnode_t)nid); 2590Sstevel@tonic-gate break; 2600Sstevel@tonic-gate case 0: 261789Sahrens snid = (int)prom_nextnode((pnode_t)nid); 262789Sahrens cnid = (int)prom_childnode((pnode_t)nid); 2630Sstevel@tonic-gate break; 2640Sstevel@tonic-gate default: 2650Sstevel@tonic-gate return (DDI_WALK_TERMINATE); 2660Sstevel@tonic-gate } 2670Sstevel@tonic-gate 2680Sstevel@tonic-gate 2690Sstevel@tonic-gate if (snid && (snid != -1) && ((parent = ddi_get_parent(di)) != NULL)) { 2700Sstevel@tonic-gate /* 2710Sstevel@tonic-gate * add the first sibling that passes check_status() 2720Sstevel@tonic-gate */ 2730Sstevel@tonic-gate for (; snid && (snid != -1); 274789Sahrens snid = (int)prom_nextnode((pnode_t)snid)) { 2750Sstevel@tonic-gate if (getlongprop_buf(snid, OBP_NAME, buf, 2760Sstevel@tonic-gate sizeof (buf)) > 0) { 2770Sstevel@tonic-gate if (check_status(snid, buf, parent) == 2780Sstevel@tonic-gate DDI_SUCCESS) { 2790Sstevel@tonic-gate (void) ddi_add_child(parent, buf, 2800Sstevel@tonic-gate snid, -1); 2810Sstevel@tonic-gate break; 2820Sstevel@tonic-gate } 2830Sstevel@tonic-gate } 2840Sstevel@tonic-gate } 2850Sstevel@tonic-gate } 2860Sstevel@tonic-gate 2870Sstevel@tonic-gate if (cnid && (cnid != -1)) { 2880Sstevel@tonic-gate /* 2890Sstevel@tonic-gate * add the first child that passes check_status() 2900Sstevel@tonic-gate */ 2910Sstevel@tonic-gate if (getlongprop_buf(cnid, OBP_NAME, buf, sizeof (buf)) > 0) { 2920Sstevel@tonic-gate if (check_status(cnid, buf, di) == DDI_SUCCESS) { 2930Sstevel@tonic-gate (void) ddi_add_child(di, buf, cnid, -1); 2940Sstevel@tonic-gate } else { 295789Sahrens for (cnid = (int)prom_nextnode((pnode_t)cnid); 2960Sstevel@tonic-gate cnid && (cnid != -1); 297789Sahrens cnid = (int)prom_nextnode((pnode_t)cnid)) { 2980Sstevel@tonic-gate if (getlongprop_buf(cnid, OBP_NAME, 2990Sstevel@tonic-gate buf, sizeof (buf)) > 0) { 3000Sstevel@tonic-gate if (check_status(cnid, buf, di) 3010Sstevel@tonic-gate == DDI_SUCCESS) { 3020Sstevel@tonic-gate (void) ddi_add_child( 3030Sstevel@tonic-gate di, buf, cnid, -1); 3040Sstevel@tonic-gate break; 3050Sstevel@tonic-gate } 3060Sstevel@tonic-gate } 3070Sstevel@tonic-gate } 3080Sstevel@tonic-gate } 3090Sstevel@tonic-gate } 3100Sstevel@tonic-gate } 3110Sstevel@tonic-gate 3120Sstevel@tonic-gate return (DDI_WALK_CONTINUE); 3130Sstevel@tonic-gate } 3140Sstevel@tonic-gate 3150Sstevel@tonic-gate static void 3160Sstevel@tonic-gate di_dfs(dev_info_t *devi, int (*f)(dev_info_t *, int), caddr_t arg) 3170Sstevel@tonic-gate { 3180Sstevel@tonic-gate (void) (*f)(devi, 0); 3190Sstevel@tonic-gate if (devi) { 3200Sstevel@tonic-gate di_dfs((dev_info_t *)DEVI(devi)->devi_child, f, arg); 3210Sstevel@tonic-gate di_dfs((dev_info_t *)DEVI(devi)->devi_sibling, f, arg); 3220Sstevel@tonic-gate } 3230Sstevel@tonic-gate } 3240Sstevel@tonic-gate 3250Sstevel@tonic-gate dev_info_t * 3260Sstevel@tonic-gate i_ddi_create_branch(dev_info_t *pdip, int nid) 3270Sstevel@tonic-gate { 3280Sstevel@tonic-gate char *buf; 3290Sstevel@tonic-gate dev_info_t *dip = NULL; 3300Sstevel@tonic-gate 3310Sstevel@tonic-gate if (pdip == NULL || nid == OBP_NONODE || nid == OBP_BADNODE) 3320Sstevel@tonic-gate return (NULL); 3330Sstevel@tonic-gate 3340Sstevel@tonic-gate buf = kmem_alloc(OBP_MAXPROPNAME, KM_SLEEP); 3350Sstevel@tonic-gate 3360Sstevel@tonic-gate if (getlongprop_buf(nid, OBP_NAME, buf, OBP_MAXPROPNAME) > 0) { 3370Sstevel@tonic-gate if (check_status(nid, buf, pdip) == DDI_SUCCESS) 3380Sstevel@tonic-gate dip = ddi_add_child(pdip, buf, nid, -1); 3390Sstevel@tonic-gate } 3400Sstevel@tonic-gate 3410Sstevel@tonic-gate kmem_free(buf, OBP_MAXPROPNAME); 3420Sstevel@tonic-gate 3430Sstevel@tonic-gate if (dip == NULL) 3440Sstevel@tonic-gate return (NULL); 3450Sstevel@tonic-gate 3460Sstevel@tonic-gate /* 3470Sstevel@tonic-gate * Don't create any siblings of the branch root, just 3480Sstevel@tonic-gate * children. 3490Sstevel@tonic-gate */ 3500Sstevel@tonic-gate (void) get_neighbors(dip, DDI_WALK_PRUNESIB); 3510Sstevel@tonic-gate 3520Sstevel@tonic-gate di_dfs(ddi_get_child(dip), get_neighbors, 0); 3530Sstevel@tonic-gate 3540Sstevel@tonic-gate return (dip); 3550Sstevel@tonic-gate } 3560Sstevel@tonic-gate 3570Sstevel@tonic-gate static void 3580Sstevel@tonic-gate create_devinfo_tree(void) 3590Sstevel@tonic-gate { 3600Sstevel@tonic-gate major_t major; 361789Sahrens pnode_t nodeid; 3620Sstevel@tonic-gate 3630Sstevel@tonic-gate i_ddi_node_cache_init(); 3640Sstevel@tonic-gate #if defined(__sparc) 3650Sstevel@tonic-gate nodeid = prom_nextnode(0); 3660Sstevel@tonic-gate #else /* x86 */ 3670Sstevel@tonic-gate nodeid = DEVI_SID_NODEID; 3680Sstevel@tonic-gate #endif 3690Sstevel@tonic-gate top_devinfo = i_ddi_alloc_node(NULL, rootname, 3700Sstevel@tonic-gate nodeid, -1, NULL, KM_SLEEP); 3710Sstevel@tonic-gate ndi_hold_devi(top_devinfo); /* never release the root */ 3720Sstevel@tonic-gate 3730Sstevel@tonic-gate i_ddi_add_devimap(top_devinfo); 3740Sstevel@tonic-gate 3750Sstevel@tonic-gate /* 3760Sstevel@tonic-gate * Bind root node. 3770Sstevel@tonic-gate * This code is special because root node has no parent 3780Sstevel@tonic-gate */ 3790Sstevel@tonic-gate major = ddi_name_to_major("rootnex"); 3807009Scth ASSERT(major != DDI_MAJOR_T_NONE); 3810Sstevel@tonic-gate DEVI(top_devinfo)->devi_major = major; 3820Sstevel@tonic-gate devnamesp[major].dn_head = top_devinfo; 3830Sstevel@tonic-gate i_ddi_set_binding_name(top_devinfo, rootname); 3840Sstevel@tonic-gate i_ddi_set_node_state(top_devinfo, DS_BOUND); 3850Sstevel@tonic-gate 3860Sstevel@tonic-gate /* 3870Sstevel@tonic-gate * Record that devinfos have been made for "rootnex." 3880Sstevel@tonic-gate * di_dfs() is used to read the prom because it doesn't get the 3890Sstevel@tonic-gate * next sibling until the function returns, unlike ddi_walk_devs(). 3900Sstevel@tonic-gate */ 3910Sstevel@tonic-gate di_dfs(ddi_root_node(), get_neighbors, 0); 392851Sszhou 393851Sszhou #if !defined(__sparc) 394851Sszhou /* 395851Sszhou * On x86, there is no prom. Create device tree by 396851Sszhou * probing pci config space 397851Sszhou */ 398851Sszhou { 399851Sszhou extern void impl_setup_ddi(void); 400851Sszhou impl_setup_ddi(); 401851Sszhou } 402851Sszhou #endif /* x86 */ 4030Sstevel@tonic-gate } 4040Sstevel@tonic-gate 4050Sstevel@tonic-gate /* 4060Sstevel@tonic-gate * Init and attach the root node. root node is the first one to be 4070Sstevel@tonic-gate * attached, so the process is somewhat "handcrafted". 4080Sstevel@tonic-gate */ 4090Sstevel@tonic-gate void 4100Sstevel@tonic-gate i_ddi_init_root() 4110Sstevel@tonic-gate { 4120Sstevel@tonic-gate #ifdef DDI_PROP_DEBUG 4130Sstevel@tonic-gate (void) ddi_prop_debug(1); /* Enable property debugging */ 4140Sstevel@tonic-gate #endif /* DDI_PROP_DEBUG */ 4150Sstevel@tonic-gate 4160Sstevel@tonic-gate /* 4170Sstevel@tonic-gate * Initialize root node 4180Sstevel@tonic-gate */ 4190Sstevel@tonic-gate if (impl_ddi_sunbus_initchild(top_devinfo) != DDI_SUCCESS) 4200Sstevel@tonic-gate panic("Could not initialize root nexus"); 4210Sstevel@tonic-gate 4220Sstevel@tonic-gate /* 4230Sstevel@tonic-gate * Attach root node (no need to probe) 4240Sstevel@tonic-gate * Hold both devinfo and rootnex driver so they can't go away. 4250Sstevel@tonic-gate */ 4260Sstevel@tonic-gate DEVI(top_devinfo)->devi_ops = ndi_hold_driver(top_devinfo); 4270Sstevel@tonic-gate ASSERT(DEV_OPS_HELD(DEVI(top_devinfo)->devi_ops)); 4280Sstevel@tonic-gate DEVI(top_devinfo)->devi_instance = e_ddi_assign_instance(top_devinfo); 4290Sstevel@tonic-gate 430495Scth mutex_enter(&(DEVI(top_devinfo)->devi_lock)); 4310Sstevel@tonic-gate DEVI_SET_ATTACHING(top_devinfo); 432495Scth mutex_exit(&(DEVI(top_devinfo)->devi_lock)); 433495Scth 4340Sstevel@tonic-gate if (devi_attach(top_devinfo, DDI_ATTACH) != DDI_SUCCESS) 4350Sstevel@tonic-gate panic("Could not attach root nexus"); 436495Scth 437495Scth mutex_enter(&(DEVI(top_devinfo)->devi_lock)); 4380Sstevel@tonic-gate DEVI_CLR_ATTACHING(top_devinfo); 439495Scth mutex_exit(&(DEVI(top_devinfo)->devi_lock)); 4400Sstevel@tonic-gate 4410Sstevel@tonic-gate mutex_init(&global_vhci_lock, NULL, MUTEX_DEFAULT, NULL); 4420Sstevel@tonic-gate 4430Sstevel@tonic-gate ndi_hold_devi(top_devinfo); /* hold it forever */ 4440Sstevel@tonic-gate i_ddi_set_node_state(top_devinfo, DS_READY); 4450Sstevel@tonic-gate 4460Sstevel@tonic-gate /* 4470Sstevel@tonic-gate * Now, expand .conf children of root 4480Sstevel@tonic-gate */ 4490Sstevel@tonic-gate (void) i_ndi_make_spec_children(top_devinfo, 0); 4500Sstevel@tonic-gate 4510Sstevel@tonic-gate /* 4520Sstevel@tonic-gate * Must be set up before attaching root or pseudo drivers 4530Sstevel@tonic-gate */ 4540Sstevel@tonic-gate pm_init_locks(); 4550Sstevel@tonic-gate 4560Sstevel@tonic-gate /* 4570Sstevel@tonic-gate * Attach options dip 4580Sstevel@tonic-gate */ 4590Sstevel@tonic-gate options_dip = i_ddi_attach_pseudo_node("options"); 4600Sstevel@tonic-gate 4610Sstevel@tonic-gate /* 4620Sstevel@tonic-gate * Attach pseudo nexus and enumerate its children 4630Sstevel@tonic-gate */ 4640Sstevel@tonic-gate pseudo_dip = i_ddi_attach_pseudo_node(DEVI_PSEUDO_NEXNAME); 4650Sstevel@tonic-gate (void) i_ndi_make_spec_children(pseudo_dip, 0); 4660Sstevel@tonic-gate 4670Sstevel@tonic-gate /* 4680Sstevel@tonic-gate * Attach and hold clone dip 4690Sstevel@tonic-gate */ 4700Sstevel@tonic-gate clone_dip = i_ddi_attach_pseudo_node("clone"); 4710Sstevel@tonic-gate clone_major = ddi_driver_major(clone_dip); 4720Sstevel@tonic-gate mm_major = ddi_name_to_major("mm"); 473*8011SChris.Horne@Sun.COM nulldriver_major = ddi_name_to_major("nulldriver"); 4740Sstevel@tonic-gate 4750Sstevel@tonic-gate /* 4760Sstevel@tonic-gate * Attach scsi_vhci for MPXIO, this registers scsi vhci class 4770Sstevel@tonic-gate * with the MPXIO framework. 4780Sstevel@tonic-gate */ 4790Sstevel@tonic-gate scsi_vhci_dip = i_ddi_attach_pseudo_node("scsi_vhci"); 4800Sstevel@tonic-gate } 481