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 /* 22*6582Ssetje * 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 #pragma ident "%Z%%M% %I% %E% SMI" 270Sstevel@tonic-gate 280Sstevel@tonic-gate /* 290Sstevel@tonic-gate * This file contains ddi functions needed during boot and DR. 300Sstevel@tonic-gate * Many functions in swapgeneric.c can be moved here. 310Sstevel@tonic-gate * 320Sstevel@tonic-gate * The object file is currently linked into unix. 330Sstevel@tonic-gate */ 340Sstevel@tonic-gate 350Sstevel@tonic-gate #include <sys/bootconf.h> 360Sstevel@tonic-gate #include <sys/conf.h> 370Sstevel@tonic-gate #include <sys/ddi_impldefs.h> 380Sstevel@tonic-gate #include <sys/ddi_implfuncs.h> 390Sstevel@tonic-gate #include <sys/hwconf.h> 400Sstevel@tonic-gate #include <sys/instance.h> 410Sstevel@tonic-gate #include <sys/kmem.h> 420Sstevel@tonic-gate #include <sys/modctl.h> 430Sstevel@tonic-gate #include <sys/promif.h> 440Sstevel@tonic-gate #include <sys/sunndi.h> 450Sstevel@tonic-gate #include <sys/ndi_impldefs.h> 460Sstevel@tonic-gate #include <sys/systeminfo.h> 470Sstevel@tonic-gate #include <sys/hwconf.h> 480Sstevel@tonic-gate #include <sys/sysevent_impl.h> 490Sstevel@tonic-gate #include <sys/sunldi_impl.h> 500Sstevel@tonic-gate #include <sys/disp.h> 515648Ssetje #include <sys/bootconf.h> 520Sstevel@tonic-gate #include <sys/fm/util.h> 530Sstevel@tonic-gate 540Sstevel@tonic-gate extern dev_info_t *top_devinfo; 550Sstevel@tonic-gate extern dev_info_t *scsi_vhci_dip; 560Sstevel@tonic-gate extern struct hwc_class *hcl_head; 570Sstevel@tonic-gate static char *rootname; /* node name of top_devinfo */ 580Sstevel@tonic-gate 590Sstevel@tonic-gate /* 600Sstevel@tonic-gate * This lock must be held while updating devi_sibling pointers of 610Sstevel@tonic-gate * rootnex immediate children 620Sstevel@tonic-gate */ 630Sstevel@tonic-gate kmutex_t global_vhci_lock; 640Sstevel@tonic-gate 650Sstevel@tonic-gate major_t mm_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(); 920Sstevel@tonic-gate 930Sstevel@tonic-gate (void) i_ddi_load_drvconf((major_t)-1); 940Sstevel@tonic-gate 950Sstevel@tonic-gate ldi_init(); 960Sstevel@tonic-gate 970Sstevel@tonic-gate i_ddi_devices_init(); 980Sstevel@tonic-gate i_ddi_read_devices_files(); 990Sstevel@tonic-gate } 1000Sstevel@tonic-gate 1010Sstevel@tonic-gate /* 1020Sstevel@tonic-gate * Perform setup actions post startup (i_ddi_io_initialized) 1030Sstevel@tonic-gate */ 1040Sstevel@tonic-gate void 1050Sstevel@tonic-gate setup_ddi_poststartup(void) 1060Sstevel@tonic-gate { 1070Sstevel@tonic-gate extern void i_ddi_start_flush_daemon(void); 1080Sstevel@tonic-gate extern void i_ddi_intr_redist_all_cpus(void); 1090Sstevel@tonic-gate 1100Sstevel@tonic-gate i_ddi_start_flush_daemon(); 1110Sstevel@tonic-gate 1120Sstevel@tonic-gate /* 1130Sstevel@tonic-gate * For platforms that support INTR_WEIGHTED_DIST, we perform a 1140Sstevel@tonic-gate * redistribution at this point (after NICs configured) so that 1150Sstevel@tonic-gate * "isolation" relative to "ddi-intr-weight" occurs. 1160Sstevel@tonic-gate */ 1170Sstevel@tonic-gate i_ddi_intr_redist_all_cpus(); 1180Sstevel@tonic-gate } 1190Sstevel@tonic-gate 1200Sstevel@tonic-gate /* 1210Sstevel@tonic-gate * Create classes and major number bindings for the name of my root. 1220Sstevel@tonic-gate * Called immediately before 'loadrootmodules' 1230Sstevel@tonic-gate */ 1240Sstevel@tonic-gate static void 1250Sstevel@tonic-gate impl_create_root_class(void) 1260Sstevel@tonic-gate { 1270Sstevel@tonic-gate major_t major; 1280Sstevel@tonic-gate size_t size; 1290Sstevel@tonic-gate char *cp; 1300Sstevel@tonic-gate 1310Sstevel@tonic-gate /* 1320Sstevel@tonic-gate * The name for the root nexus is exactly as the manufacturer 1330Sstevel@tonic-gate * placed it in the prom name property. No translation. 1340Sstevel@tonic-gate */ 1350Sstevel@tonic-gate if ((major = ddi_name_to_major("rootnex")) == (major_t)-1) 1360Sstevel@tonic-gate panic("Couldn't find major number for 'rootnex'"); 1370Sstevel@tonic-gate 138*6582Ssetje /* 139*6582Ssetje * C OBP (Serengeti) does not include the NULL when returning 140*6582Ssetje * the length of the name property, while this violates 1275, 141*6582Ssetje * Solaris needs to work around this by allocating space for 142*6582Ssetje * an extra character. 143*6582Ssetje */ 144*6582Ssetje size = (size_t)BOP_GETPROPLEN(bootops, "mfg-name") + 1; 1450Sstevel@tonic-gate rootname = kmem_zalloc(size, KM_SLEEP); 1460Sstevel@tonic-gate (void) BOP_GETPROP(bootops, "mfg-name", rootname); 1470Sstevel@tonic-gate 1480Sstevel@tonic-gate /* 1490Sstevel@tonic-gate * Fix conflict between OBP names and filesystem names. 1500Sstevel@tonic-gate * Substitute '_' for '/' in the name. Ick. This is only 1510Sstevel@tonic-gate * needed for the root node since '/' is not a legal name 1520Sstevel@tonic-gate * character in an OBP device name. 1530Sstevel@tonic-gate */ 1540Sstevel@tonic-gate for (cp = rootname; *cp; cp++) 1550Sstevel@tonic-gate if (*cp == '/') 1560Sstevel@tonic-gate *cp = '_'; 1570Sstevel@tonic-gate 1580Sstevel@tonic-gate /* 1590Sstevel@tonic-gate * Bind rootname to rootnex driver 1600Sstevel@tonic-gate */ 1610Sstevel@tonic-gate if (make_mbind(rootname, major, NULL, mb_hashtab) != 0) { 1620Sstevel@tonic-gate cmn_err(CE_WARN, "A driver or driver alias has already " 1630Sstevel@tonic-gate "registered the name \"%s\". The root nexus needs to " 1640Sstevel@tonic-gate "use this name, and will override the existing entry. " 1650Sstevel@tonic-gate "Please correct /etc/name_to_major and/or " 1660Sstevel@tonic-gate "/etc/driver_aliases and reboot.", rootname); 1670Sstevel@tonic-gate 1680Sstevel@tonic-gate /* 1690Sstevel@tonic-gate * Resort to the emergency measure of blowing away the 1700Sstevel@tonic-gate * existing hash entry and replacing it with rootname's. 1710Sstevel@tonic-gate */ 1720Sstevel@tonic-gate delete_mbind(rootname, mb_hashtab); 1730Sstevel@tonic-gate if (make_mbind(rootname, major, NULL, mb_hashtab) != 0) 1740Sstevel@tonic-gate panic("mb_hashtab: inconsistent state."); 1750Sstevel@tonic-gate } 1760Sstevel@tonic-gate 1770Sstevel@tonic-gate /* 1780Sstevel@tonic-gate * The `platform' or `implementation architecture' name has been 1790Sstevel@tonic-gate * translated by boot to be proper for file system use. It is 1800Sstevel@tonic-gate * the `name' of the platform actually booted. Note the assumption 1810Sstevel@tonic-gate * is that the name will `fit' in the buffer platform (which is 1820Sstevel@tonic-gate * of size SYS_NMLN, which is far bigger than will actually ever 1830Sstevel@tonic-gate * be needed). 1840Sstevel@tonic-gate */ 1850Sstevel@tonic-gate (void) BOP_GETPROP(bootops, "impl-arch-name", platform); 1860Sstevel@tonic-gate 1870Sstevel@tonic-gate #if defined(__x86) 1880Sstevel@tonic-gate /* 1890Sstevel@tonic-gate * Retrieve and honor the bootpath and optional fstype properties 1900Sstevel@tonic-gate */ 1910Sstevel@tonic-gate size = (size_t)BOP_GETPROPLEN(bootops, "bootpath"); 1920Sstevel@tonic-gate if (size != -1) { 1930Sstevel@tonic-gate bootpath_prop = kmem_zalloc(size, KM_SLEEP); 1940Sstevel@tonic-gate (void) BOP_GETPROP(bootops, "bootpath", bootpath_prop); 1950Sstevel@tonic-gate setbootpath(bootpath_prop); 1960Sstevel@tonic-gate } 1970Sstevel@tonic-gate 1980Sstevel@tonic-gate size = (size_t)BOP_GETPROPLEN(bootops, "fstype"); 1990Sstevel@tonic-gate if (size != -1) { 2000Sstevel@tonic-gate fstype_prop = kmem_zalloc(size, KM_SLEEP); 2010Sstevel@tonic-gate (void) BOP_GETPROP(bootops, "fstype", fstype_prop); 2020Sstevel@tonic-gate setbootfstype(fstype_prop); 2030Sstevel@tonic-gate } 2040Sstevel@tonic-gate #endif 2050Sstevel@tonic-gate } 2060Sstevel@tonic-gate 2070Sstevel@tonic-gate /* 2080Sstevel@tonic-gate * Note that this routine does not take into account the endianness 2090Sstevel@tonic-gate * of the host or the device (or PROM) when retrieving properties. 2100Sstevel@tonic-gate */ 2110Sstevel@tonic-gate static int 2120Sstevel@tonic-gate getlongprop_buf(int id, char *name, char *buf, int maxlen) 2130Sstevel@tonic-gate { 2140Sstevel@tonic-gate int size; 2150Sstevel@tonic-gate 216789Sahrens size = prom_getproplen((pnode_t)id, name); 2170Sstevel@tonic-gate if (size <= 0 || (size > maxlen - 1)) 2180Sstevel@tonic-gate return (-1); 2190Sstevel@tonic-gate 220789Sahrens if (-1 == prom_getprop((pnode_t)id, name, buf)) 2210Sstevel@tonic-gate return (-1); 2220Sstevel@tonic-gate 2230Sstevel@tonic-gate /* 2240Sstevel@tonic-gate * Workaround for bugid 1085575 - OBP may return a "name" property 2250Sstevel@tonic-gate * without null terminating the string with '\0'. When this occurs, 2260Sstevel@tonic-gate * append a '\0' and return (size + 1). 2270Sstevel@tonic-gate */ 2280Sstevel@tonic-gate if (strcmp("name", name) == 0) { 2290Sstevel@tonic-gate if (buf[size - 1] != '\0') { 2300Sstevel@tonic-gate buf[size] = '\0'; 2310Sstevel@tonic-gate size += 1; 2320Sstevel@tonic-gate } 2330Sstevel@tonic-gate } 2340Sstevel@tonic-gate 2350Sstevel@tonic-gate return (size); 2360Sstevel@tonic-gate } 2370Sstevel@tonic-gate 2380Sstevel@tonic-gate /*ARGSUSED1*/ 2390Sstevel@tonic-gate static int 2400Sstevel@tonic-gate get_neighbors(dev_info_t *di, int flag) 2410Sstevel@tonic-gate { 2420Sstevel@tonic-gate register int nid, snid, cnid; 2430Sstevel@tonic-gate dev_info_t *parent; 2440Sstevel@tonic-gate char buf[OBP_MAXPROPNAME]; 2450Sstevel@tonic-gate 2460Sstevel@tonic-gate if (di == NULL) 2470Sstevel@tonic-gate return (DDI_WALK_CONTINUE); 2480Sstevel@tonic-gate 2490Sstevel@tonic-gate nid = ddi_get_nodeid(di); 2500Sstevel@tonic-gate 2510Sstevel@tonic-gate snid = cnid = 0; 2520Sstevel@tonic-gate switch (flag) { 2530Sstevel@tonic-gate case DDI_WALK_PRUNESIB: 254789Sahrens cnid = (int)prom_childnode((pnode_t)nid); 2550Sstevel@tonic-gate break; 2560Sstevel@tonic-gate case DDI_WALK_PRUNECHILD: 257789Sahrens snid = (int)prom_nextnode((pnode_t)nid); 2580Sstevel@tonic-gate break; 2590Sstevel@tonic-gate case 0: 260789Sahrens snid = (int)prom_nextnode((pnode_t)nid); 261789Sahrens cnid = (int)prom_childnode((pnode_t)nid); 2620Sstevel@tonic-gate break; 2630Sstevel@tonic-gate default: 2640Sstevel@tonic-gate return (DDI_WALK_TERMINATE); 2650Sstevel@tonic-gate } 2660Sstevel@tonic-gate 2670Sstevel@tonic-gate 2680Sstevel@tonic-gate if (snid && (snid != -1) && ((parent = ddi_get_parent(di)) != NULL)) { 2690Sstevel@tonic-gate /* 2700Sstevel@tonic-gate * add the first sibling that passes check_status() 2710Sstevel@tonic-gate */ 2720Sstevel@tonic-gate for (; snid && (snid != -1); 273789Sahrens snid = (int)prom_nextnode((pnode_t)snid)) { 2740Sstevel@tonic-gate if (getlongprop_buf(snid, OBP_NAME, buf, 2750Sstevel@tonic-gate sizeof (buf)) > 0) { 2760Sstevel@tonic-gate if (check_status(snid, buf, parent) == 2770Sstevel@tonic-gate DDI_SUCCESS) { 2780Sstevel@tonic-gate (void) ddi_add_child(parent, buf, 2790Sstevel@tonic-gate snid, -1); 2800Sstevel@tonic-gate break; 2810Sstevel@tonic-gate } 2820Sstevel@tonic-gate } 2830Sstevel@tonic-gate } 2840Sstevel@tonic-gate } 2850Sstevel@tonic-gate 2860Sstevel@tonic-gate if (cnid && (cnid != -1)) { 2870Sstevel@tonic-gate /* 2880Sstevel@tonic-gate * add the first child that passes check_status() 2890Sstevel@tonic-gate */ 2900Sstevel@tonic-gate if (getlongprop_buf(cnid, OBP_NAME, buf, sizeof (buf)) > 0) { 2910Sstevel@tonic-gate if (check_status(cnid, buf, di) == DDI_SUCCESS) { 2920Sstevel@tonic-gate (void) ddi_add_child(di, buf, cnid, -1); 2930Sstevel@tonic-gate } else { 294789Sahrens for (cnid = (int)prom_nextnode((pnode_t)cnid); 2950Sstevel@tonic-gate cnid && (cnid != -1); 296789Sahrens cnid = (int)prom_nextnode((pnode_t)cnid)) { 2970Sstevel@tonic-gate if (getlongprop_buf(cnid, OBP_NAME, 2980Sstevel@tonic-gate buf, sizeof (buf)) > 0) { 2990Sstevel@tonic-gate if (check_status(cnid, buf, di) 3000Sstevel@tonic-gate == DDI_SUCCESS) { 3010Sstevel@tonic-gate (void) ddi_add_child( 3020Sstevel@tonic-gate di, buf, cnid, -1); 3030Sstevel@tonic-gate break; 3040Sstevel@tonic-gate } 3050Sstevel@tonic-gate } 3060Sstevel@tonic-gate } 3070Sstevel@tonic-gate } 3080Sstevel@tonic-gate } 3090Sstevel@tonic-gate } 3100Sstevel@tonic-gate 3110Sstevel@tonic-gate return (DDI_WALK_CONTINUE); 3120Sstevel@tonic-gate } 3130Sstevel@tonic-gate 3140Sstevel@tonic-gate static void 3150Sstevel@tonic-gate di_dfs(dev_info_t *devi, int (*f)(dev_info_t *, int), caddr_t arg) 3160Sstevel@tonic-gate { 3170Sstevel@tonic-gate (void) (*f)(devi, 0); 3180Sstevel@tonic-gate if (devi) { 3190Sstevel@tonic-gate di_dfs((dev_info_t *)DEVI(devi)->devi_child, f, arg); 3200Sstevel@tonic-gate di_dfs((dev_info_t *)DEVI(devi)->devi_sibling, f, arg); 3210Sstevel@tonic-gate } 3220Sstevel@tonic-gate } 3230Sstevel@tonic-gate 3240Sstevel@tonic-gate dev_info_t * 3250Sstevel@tonic-gate i_ddi_create_branch(dev_info_t *pdip, int nid) 3260Sstevel@tonic-gate { 3270Sstevel@tonic-gate char *buf; 3280Sstevel@tonic-gate dev_info_t *dip = NULL; 3290Sstevel@tonic-gate 3300Sstevel@tonic-gate if (pdip == NULL || nid == OBP_NONODE || nid == OBP_BADNODE) 3310Sstevel@tonic-gate return (NULL); 3320Sstevel@tonic-gate 3330Sstevel@tonic-gate buf = kmem_alloc(OBP_MAXPROPNAME, KM_SLEEP); 3340Sstevel@tonic-gate 3350Sstevel@tonic-gate if (getlongprop_buf(nid, OBP_NAME, buf, OBP_MAXPROPNAME) > 0) { 3360Sstevel@tonic-gate if (check_status(nid, buf, pdip) == DDI_SUCCESS) 3370Sstevel@tonic-gate dip = ddi_add_child(pdip, buf, nid, -1); 3380Sstevel@tonic-gate } 3390Sstevel@tonic-gate 3400Sstevel@tonic-gate kmem_free(buf, OBP_MAXPROPNAME); 3410Sstevel@tonic-gate 3420Sstevel@tonic-gate if (dip == NULL) 3430Sstevel@tonic-gate return (NULL); 3440Sstevel@tonic-gate 3450Sstevel@tonic-gate /* 3460Sstevel@tonic-gate * Don't create any siblings of the branch root, just 3470Sstevel@tonic-gate * children. 3480Sstevel@tonic-gate */ 3490Sstevel@tonic-gate (void) get_neighbors(dip, DDI_WALK_PRUNESIB); 3500Sstevel@tonic-gate 3510Sstevel@tonic-gate di_dfs(ddi_get_child(dip), get_neighbors, 0); 3520Sstevel@tonic-gate 3530Sstevel@tonic-gate return (dip); 3540Sstevel@tonic-gate } 3550Sstevel@tonic-gate 3560Sstevel@tonic-gate static void 3570Sstevel@tonic-gate create_devinfo_tree(void) 3580Sstevel@tonic-gate { 3590Sstevel@tonic-gate major_t major; 360789Sahrens pnode_t nodeid; 3610Sstevel@tonic-gate 3620Sstevel@tonic-gate i_ddi_node_cache_init(); 3630Sstevel@tonic-gate #if defined(__sparc) 3640Sstevel@tonic-gate nodeid = prom_nextnode(0); 3650Sstevel@tonic-gate #else /* x86 */ 3660Sstevel@tonic-gate nodeid = DEVI_SID_NODEID; 3670Sstevel@tonic-gate #endif 3680Sstevel@tonic-gate top_devinfo = i_ddi_alloc_node(NULL, rootname, 3690Sstevel@tonic-gate nodeid, -1, NULL, KM_SLEEP); 3700Sstevel@tonic-gate ndi_hold_devi(top_devinfo); /* never release the root */ 3710Sstevel@tonic-gate 3720Sstevel@tonic-gate i_ddi_add_devimap(top_devinfo); 3730Sstevel@tonic-gate 3740Sstevel@tonic-gate /* 3750Sstevel@tonic-gate * Bind root node. 3760Sstevel@tonic-gate * This code is special because root node has no parent 3770Sstevel@tonic-gate */ 3780Sstevel@tonic-gate major = ddi_name_to_major("rootnex"); 3790Sstevel@tonic-gate ASSERT(major != (major_t)-1); 3800Sstevel@tonic-gate DEVI(top_devinfo)->devi_major = major; 3810Sstevel@tonic-gate devnamesp[major].dn_head = top_devinfo; 3820Sstevel@tonic-gate i_ddi_set_binding_name(top_devinfo, rootname); 3830Sstevel@tonic-gate i_ddi_set_node_state(top_devinfo, DS_BOUND); 3840Sstevel@tonic-gate 3850Sstevel@tonic-gate /* 3860Sstevel@tonic-gate * Record that devinfos have been made for "rootnex." 3870Sstevel@tonic-gate * di_dfs() is used to read the prom because it doesn't get the 3880Sstevel@tonic-gate * next sibling until the function returns, unlike ddi_walk_devs(). 3890Sstevel@tonic-gate */ 3900Sstevel@tonic-gate di_dfs(ddi_root_node(), get_neighbors, 0); 391851Sszhou 392851Sszhou #if !defined(__sparc) 393851Sszhou /* 394851Sszhou * On x86, there is no prom. Create device tree by 395851Sszhou * probing pci config space 396851Sszhou */ 397851Sszhou { 398851Sszhou extern void impl_setup_ddi(void); 399851Sszhou impl_setup_ddi(); 400851Sszhou } 401851Sszhou #endif /* x86 */ 4020Sstevel@tonic-gate } 4030Sstevel@tonic-gate 4040Sstevel@tonic-gate /* 4050Sstevel@tonic-gate * Init and attach the root node. root node is the first one to be 4060Sstevel@tonic-gate * attached, so the process is somewhat "handcrafted". 4070Sstevel@tonic-gate */ 4080Sstevel@tonic-gate void 4090Sstevel@tonic-gate i_ddi_init_root() 4100Sstevel@tonic-gate { 4110Sstevel@tonic-gate #ifdef DDI_PROP_DEBUG 4120Sstevel@tonic-gate (void) ddi_prop_debug(1); /* Enable property debugging */ 4130Sstevel@tonic-gate #endif /* DDI_PROP_DEBUG */ 4140Sstevel@tonic-gate 4150Sstevel@tonic-gate /* 4160Sstevel@tonic-gate * Initialize root node 4170Sstevel@tonic-gate */ 4180Sstevel@tonic-gate if (impl_ddi_sunbus_initchild(top_devinfo) != DDI_SUCCESS) 4190Sstevel@tonic-gate panic("Could not initialize root nexus"); 4200Sstevel@tonic-gate 4210Sstevel@tonic-gate /* 4220Sstevel@tonic-gate * Attach root node (no need to probe) 4230Sstevel@tonic-gate * Hold both devinfo and rootnex driver so they can't go away. 4240Sstevel@tonic-gate */ 4250Sstevel@tonic-gate DEVI(top_devinfo)->devi_ops = ndi_hold_driver(top_devinfo); 4260Sstevel@tonic-gate ASSERT(DEV_OPS_HELD(DEVI(top_devinfo)->devi_ops)); 4270Sstevel@tonic-gate DEVI(top_devinfo)->devi_instance = e_ddi_assign_instance(top_devinfo); 4280Sstevel@tonic-gate 429495Scth mutex_enter(&(DEVI(top_devinfo)->devi_lock)); 4300Sstevel@tonic-gate DEVI_SET_ATTACHING(top_devinfo); 431495Scth mutex_exit(&(DEVI(top_devinfo)->devi_lock)); 432495Scth 4330Sstevel@tonic-gate if (devi_attach(top_devinfo, DDI_ATTACH) != DDI_SUCCESS) 4340Sstevel@tonic-gate panic("Could not attach root nexus"); 435495Scth 436495Scth mutex_enter(&(DEVI(top_devinfo)->devi_lock)); 4370Sstevel@tonic-gate DEVI_CLR_ATTACHING(top_devinfo); 438495Scth mutex_exit(&(DEVI(top_devinfo)->devi_lock)); 4390Sstevel@tonic-gate 4400Sstevel@tonic-gate mutex_init(&global_vhci_lock, NULL, MUTEX_DEFAULT, NULL); 4410Sstevel@tonic-gate 4420Sstevel@tonic-gate ndi_hold_devi(top_devinfo); /* hold it forever */ 4430Sstevel@tonic-gate i_ddi_set_node_state(top_devinfo, DS_READY); 4440Sstevel@tonic-gate 4450Sstevel@tonic-gate /* 4460Sstevel@tonic-gate * Now, expand .conf children of root 4470Sstevel@tonic-gate */ 4480Sstevel@tonic-gate (void) i_ndi_make_spec_children(top_devinfo, 0); 4490Sstevel@tonic-gate 4500Sstevel@tonic-gate /* 4510Sstevel@tonic-gate * Must be set up before attaching root or pseudo drivers 4520Sstevel@tonic-gate */ 4530Sstevel@tonic-gate pm_init_locks(); 4540Sstevel@tonic-gate 4550Sstevel@tonic-gate /* 4560Sstevel@tonic-gate * Attach options dip 4570Sstevel@tonic-gate */ 4580Sstevel@tonic-gate options_dip = i_ddi_attach_pseudo_node("options"); 4590Sstevel@tonic-gate 4600Sstevel@tonic-gate /* 4610Sstevel@tonic-gate * Attach pseudo nexus and enumerate its children 4620Sstevel@tonic-gate */ 4630Sstevel@tonic-gate pseudo_dip = i_ddi_attach_pseudo_node(DEVI_PSEUDO_NEXNAME); 4640Sstevel@tonic-gate (void) i_ndi_make_spec_children(pseudo_dip, 0); 4650Sstevel@tonic-gate 4660Sstevel@tonic-gate /* 4670Sstevel@tonic-gate * Attach and hold clone dip 4680Sstevel@tonic-gate */ 4690Sstevel@tonic-gate clone_dip = i_ddi_attach_pseudo_node("clone"); 4700Sstevel@tonic-gate clone_major = ddi_driver_major(clone_dip); 4710Sstevel@tonic-gate mm_major = ddi_name_to_major("mm"); 4720Sstevel@tonic-gate 4730Sstevel@tonic-gate /* 4740Sstevel@tonic-gate * Attach scsi_vhci for MPXIO, this registers scsi vhci class 4750Sstevel@tonic-gate * with the MPXIO framework. 4760Sstevel@tonic-gate */ 4770Sstevel@tonic-gate scsi_vhci_dip = i_ddi_attach_pseudo_node("scsi_vhci"); 4780Sstevel@tonic-gate } 479