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 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 220Sstevel@tonic-gate /* 230Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 280Sstevel@tonic-gate 290Sstevel@tonic-gate /* 300Sstevel@tonic-gate * This file contains ddi functions needed during boot and DR. 310Sstevel@tonic-gate * Many functions in swapgeneric.c can be moved here. 320Sstevel@tonic-gate * 330Sstevel@tonic-gate * The object file is currently linked into unix. 340Sstevel@tonic-gate */ 350Sstevel@tonic-gate 360Sstevel@tonic-gate #include <sys/bootconf.h> 370Sstevel@tonic-gate #include <sys/conf.h> 380Sstevel@tonic-gate #include <sys/ddi_impldefs.h> 390Sstevel@tonic-gate #include <sys/ddi_implfuncs.h> 400Sstevel@tonic-gate #include <sys/hwconf.h> 410Sstevel@tonic-gate #include <sys/instance.h> 420Sstevel@tonic-gate #include <sys/kmem.h> 430Sstevel@tonic-gate #include <sys/modctl.h> 440Sstevel@tonic-gate #include <sys/promif.h> 450Sstevel@tonic-gate #include <sys/sunndi.h> 460Sstevel@tonic-gate #include <sys/ndi_impldefs.h> 470Sstevel@tonic-gate #include <sys/systeminfo.h> 480Sstevel@tonic-gate #include <sys/hwconf.h> 490Sstevel@tonic-gate #include <sys/sysevent_impl.h> 500Sstevel@tonic-gate #include <sys/sunldi_impl.h> 510Sstevel@tonic-gate #include <sys/disp.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 extern struct bootops *bootops; 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 */ 1360Sstevel@tonic-gate if ((major = ddi_name_to_major("rootnex")) == (major_t)-1) 1370Sstevel@tonic-gate panic("Couldn't find major number for 'rootnex'"); 1380Sstevel@tonic-gate 1390Sstevel@tonic-gate size = (size_t)BOP_GETPROPLEN(bootops, "mfg-name"); 1400Sstevel@tonic-gate rootname = kmem_zalloc(size, KM_SLEEP); 1410Sstevel@tonic-gate (void) BOP_GETPROP(bootops, "mfg-name", rootname); 1420Sstevel@tonic-gate 1430Sstevel@tonic-gate /* 1440Sstevel@tonic-gate * Fix conflict between OBP names and filesystem names. 1450Sstevel@tonic-gate * Substitute '_' for '/' in the name. Ick. This is only 1460Sstevel@tonic-gate * needed for the root node since '/' is not a legal name 1470Sstevel@tonic-gate * character in an OBP device name. 1480Sstevel@tonic-gate */ 1490Sstevel@tonic-gate for (cp = rootname; *cp; cp++) 1500Sstevel@tonic-gate if (*cp == '/') 1510Sstevel@tonic-gate *cp = '_'; 1520Sstevel@tonic-gate 1530Sstevel@tonic-gate /* 1540Sstevel@tonic-gate * Bind rootname to rootnex driver 1550Sstevel@tonic-gate */ 1560Sstevel@tonic-gate if (make_mbind(rootname, major, NULL, mb_hashtab) != 0) { 1570Sstevel@tonic-gate cmn_err(CE_WARN, "A driver or driver alias has already " 1580Sstevel@tonic-gate "registered the name \"%s\". The root nexus needs to " 1590Sstevel@tonic-gate "use this name, and will override the existing entry. " 1600Sstevel@tonic-gate "Please correct /etc/name_to_major and/or " 1610Sstevel@tonic-gate "/etc/driver_aliases and reboot.", rootname); 1620Sstevel@tonic-gate 1630Sstevel@tonic-gate /* 1640Sstevel@tonic-gate * Resort to the emergency measure of blowing away the 1650Sstevel@tonic-gate * existing hash entry and replacing it with rootname's. 1660Sstevel@tonic-gate */ 1670Sstevel@tonic-gate delete_mbind(rootname, mb_hashtab); 1680Sstevel@tonic-gate if (make_mbind(rootname, major, NULL, mb_hashtab) != 0) 1690Sstevel@tonic-gate panic("mb_hashtab: inconsistent state."); 1700Sstevel@tonic-gate } 1710Sstevel@tonic-gate 1720Sstevel@tonic-gate /* 1730Sstevel@tonic-gate * The `platform' or `implementation architecture' name has been 1740Sstevel@tonic-gate * translated by boot to be proper for file system use. It is 1750Sstevel@tonic-gate * the `name' of the platform actually booted. Note the assumption 1760Sstevel@tonic-gate * is that the name will `fit' in the buffer platform (which is 1770Sstevel@tonic-gate * of size SYS_NMLN, which is far bigger than will actually ever 1780Sstevel@tonic-gate * be needed). 1790Sstevel@tonic-gate */ 1800Sstevel@tonic-gate (void) BOP_GETPROP(bootops, "impl-arch-name", platform); 1810Sstevel@tonic-gate 1820Sstevel@tonic-gate #if defined(__x86) 1830Sstevel@tonic-gate /* 1840Sstevel@tonic-gate * Retrieve and honor the bootpath and optional fstype properties 1850Sstevel@tonic-gate */ 1860Sstevel@tonic-gate size = (size_t)BOP_GETPROPLEN(bootops, "bootpath"); 1870Sstevel@tonic-gate if (size != -1) { 1880Sstevel@tonic-gate bootpath_prop = kmem_zalloc(size, KM_SLEEP); 1890Sstevel@tonic-gate (void) BOP_GETPROP(bootops, "bootpath", bootpath_prop); 1900Sstevel@tonic-gate setbootpath(bootpath_prop); 1910Sstevel@tonic-gate } 1920Sstevel@tonic-gate 1930Sstevel@tonic-gate size = (size_t)BOP_GETPROPLEN(bootops, "fstype"); 1940Sstevel@tonic-gate if (size != -1) { 1950Sstevel@tonic-gate fstype_prop = kmem_zalloc(size, KM_SLEEP); 1960Sstevel@tonic-gate (void) BOP_GETPROP(bootops, "fstype", fstype_prop); 1970Sstevel@tonic-gate setbootfstype(fstype_prop); 1980Sstevel@tonic-gate } 1990Sstevel@tonic-gate #endif 2000Sstevel@tonic-gate } 2010Sstevel@tonic-gate 2020Sstevel@tonic-gate /* 2030Sstevel@tonic-gate * Note that this routine does not take into account the endianness 2040Sstevel@tonic-gate * of the host or the device (or PROM) when retrieving properties. 2050Sstevel@tonic-gate */ 2060Sstevel@tonic-gate static int 2070Sstevel@tonic-gate getlongprop_buf(int id, char *name, char *buf, int maxlen) 2080Sstevel@tonic-gate { 2090Sstevel@tonic-gate int size; 2100Sstevel@tonic-gate 211789Sahrens size = prom_getproplen((pnode_t)id, name); 2120Sstevel@tonic-gate if (size <= 0 || (size > maxlen - 1)) 2130Sstevel@tonic-gate return (-1); 2140Sstevel@tonic-gate 215789Sahrens if (-1 == prom_getprop((pnode_t)id, name, buf)) 2160Sstevel@tonic-gate return (-1); 2170Sstevel@tonic-gate 2180Sstevel@tonic-gate /* 2190Sstevel@tonic-gate * Workaround for bugid 1085575 - OBP may return a "name" property 2200Sstevel@tonic-gate * without null terminating the string with '\0'. When this occurs, 2210Sstevel@tonic-gate * append a '\0' and return (size + 1). 2220Sstevel@tonic-gate */ 2230Sstevel@tonic-gate if (strcmp("name", name) == 0) { 2240Sstevel@tonic-gate if (buf[size - 1] != '\0') { 2250Sstevel@tonic-gate buf[size] = '\0'; 2260Sstevel@tonic-gate size += 1; 2270Sstevel@tonic-gate } 2280Sstevel@tonic-gate } 2290Sstevel@tonic-gate 2300Sstevel@tonic-gate return (size); 2310Sstevel@tonic-gate } 2320Sstevel@tonic-gate 2330Sstevel@tonic-gate /*ARGSUSED1*/ 2340Sstevel@tonic-gate static int 2350Sstevel@tonic-gate get_neighbors(dev_info_t *di, int flag) 2360Sstevel@tonic-gate { 2370Sstevel@tonic-gate register int nid, snid, cnid; 2380Sstevel@tonic-gate dev_info_t *parent; 2390Sstevel@tonic-gate char buf[OBP_MAXPROPNAME]; 2400Sstevel@tonic-gate 2410Sstevel@tonic-gate if (di == NULL) 2420Sstevel@tonic-gate return (DDI_WALK_CONTINUE); 2430Sstevel@tonic-gate 2440Sstevel@tonic-gate nid = ddi_get_nodeid(di); 2450Sstevel@tonic-gate 2460Sstevel@tonic-gate snid = cnid = 0; 2470Sstevel@tonic-gate switch (flag) { 2480Sstevel@tonic-gate case DDI_WALK_PRUNESIB: 249789Sahrens cnid = (int)prom_childnode((pnode_t)nid); 2500Sstevel@tonic-gate break; 2510Sstevel@tonic-gate case DDI_WALK_PRUNECHILD: 252789Sahrens snid = (int)prom_nextnode((pnode_t)nid); 2530Sstevel@tonic-gate break; 2540Sstevel@tonic-gate case 0: 255789Sahrens snid = (int)prom_nextnode((pnode_t)nid); 256789Sahrens cnid = (int)prom_childnode((pnode_t)nid); 2570Sstevel@tonic-gate break; 2580Sstevel@tonic-gate default: 2590Sstevel@tonic-gate return (DDI_WALK_TERMINATE); 2600Sstevel@tonic-gate } 2610Sstevel@tonic-gate 2620Sstevel@tonic-gate 2630Sstevel@tonic-gate if (snid && (snid != -1) && ((parent = ddi_get_parent(di)) != NULL)) { 2640Sstevel@tonic-gate /* 2650Sstevel@tonic-gate * add the first sibling that passes check_status() 2660Sstevel@tonic-gate */ 2670Sstevel@tonic-gate for (; snid && (snid != -1); 268789Sahrens snid = (int)prom_nextnode((pnode_t)snid)) { 2690Sstevel@tonic-gate if (getlongprop_buf(snid, OBP_NAME, buf, 2700Sstevel@tonic-gate sizeof (buf)) > 0) { 2710Sstevel@tonic-gate if (check_status(snid, buf, parent) == 2720Sstevel@tonic-gate DDI_SUCCESS) { 2730Sstevel@tonic-gate (void) ddi_add_child(parent, buf, 2740Sstevel@tonic-gate snid, -1); 2750Sstevel@tonic-gate break; 2760Sstevel@tonic-gate } 2770Sstevel@tonic-gate } 2780Sstevel@tonic-gate } 2790Sstevel@tonic-gate } 2800Sstevel@tonic-gate 2810Sstevel@tonic-gate if (cnid && (cnid != -1)) { 2820Sstevel@tonic-gate /* 2830Sstevel@tonic-gate * add the first child that passes check_status() 2840Sstevel@tonic-gate */ 2850Sstevel@tonic-gate if (getlongprop_buf(cnid, OBP_NAME, buf, sizeof (buf)) > 0) { 2860Sstevel@tonic-gate if (check_status(cnid, buf, di) == DDI_SUCCESS) { 2870Sstevel@tonic-gate (void) ddi_add_child(di, buf, cnid, -1); 2880Sstevel@tonic-gate } else { 289789Sahrens for (cnid = (int)prom_nextnode((pnode_t)cnid); 2900Sstevel@tonic-gate cnid && (cnid != -1); 291789Sahrens cnid = (int)prom_nextnode((pnode_t)cnid)) { 2920Sstevel@tonic-gate if (getlongprop_buf(cnid, OBP_NAME, 2930Sstevel@tonic-gate buf, sizeof (buf)) > 0) { 2940Sstevel@tonic-gate if (check_status(cnid, buf, di) 2950Sstevel@tonic-gate == DDI_SUCCESS) { 2960Sstevel@tonic-gate (void) ddi_add_child( 2970Sstevel@tonic-gate di, buf, cnid, -1); 2980Sstevel@tonic-gate break; 2990Sstevel@tonic-gate } 3000Sstevel@tonic-gate } 3010Sstevel@tonic-gate } 3020Sstevel@tonic-gate } 3030Sstevel@tonic-gate } 3040Sstevel@tonic-gate } 3050Sstevel@tonic-gate 3060Sstevel@tonic-gate return (DDI_WALK_CONTINUE); 3070Sstevel@tonic-gate } 3080Sstevel@tonic-gate 3090Sstevel@tonic-gate static void 3100Sstevel@tonic-gate di_dfs(dev_info_t *devi, int (*f)(dev_info_t *, int), caddr_t arg) 3110Sstevel@tonic-gate { 3120Sstevel@tonic-gate (void) (*f)(devi, 0); 3130Sstevel@tonic-gate if (devi) { 3140Sstevel@tonic-gate di_dfs((dev_info_t *)DEVI(devi)->devi_child, f, arg); 3150Sstevel@tonic-gate di_dfs((dev_info_t *)DEVI(devi)->devi_sibling, f, arg); 3160Sstevel@tonic-gate } 3170Sstevel@tonic-gate } 3180Sstevel@tonic-gate 3190Sstevel@tonic-gate dev_info_t * 3200Sstevel@tonic-gate i_ddi_create_branch(dev_info_t *pdip, int nid) 3210Sstevel@tonic-gate { 3220Sstevel@tonic-gate char *buf; 3230Sstevel@tonic-gate dev_info_t *dip = NULL; 3240Sstevel@tonic-gate 3250Sstevel@tonic-gate if (pdip == NULL || nid == OBP_NONODE || nid == OBP_BADNODE) 3260Sstevel@tonic-gate return (NULL); 3270Sstevel@tonic-gate 3280Sstevel@tonic-gate buf = kmem_alloc(OBP_MAXPROPNAME, KM_SLEEP); 3290Sstevel@tonic-gate 3300Sstevel@tonic-gate if (getlongprop_buf(nid, OBP_NAME, buf, OBP_MAXPROPNAME) > 0) { 3310Sstevel@tonic-gate if (check_status(nid, buf, pdip) == DDI_SUCCESS) 3320Sstevel@tonic-gate dip = ddi_add_child(pdip, buf, nid, -1); 3330Sstevel@tonic-gate } 3340Sstevel@tonic-gate 3350Sstevel@tonic-gate kmem_free(buf, OBP_MAXPROPNAME); 3360Sstevel@tonic-gate 3370Sstevel@tonic-gate if (dip == NULL) 3380Sstevel@tonic-gate return (NULL); 3390Sstevel@tonic-gate 3400Sstevel@tonic-gate /* 3410Sstevel@tonic-gate * Don't create any siblings of the branch root, just 3420Sstevel@tonic-gate * children. 3430Sstevel@tonic-gate */ 3440Sstevel@tonic-gate (void) get_neighbors(dip, DDI_WALK_PRUNESIB); 3450Sstevel@tonic-gate 3460Sstevel@tonic-gate di_dfs(ddi_get_child(dip), get_neighbors, 0); 3470Sstevel@tonic-gate 3480Sstevel@tonic-gate return (dip); 3490Sstevel@tonic-gate } 3500Sstevel@tonic-gate 3510Sstevel@tonic-gate static void 3520Sstevel@tonic-gate create_devinfo_tree(void) 3530Sstevel@tonic-gate { 3540Sstevel@tonic-gate major_t major; 355789Sahrens pnode_t nodeid; 3560Sstevel@tonic-gate 3570Sstevel@tonic-gate i_ddi_node_cache_init(); 3580Sstevel@tonic-gate #if defined(__sparc) 3590Sstevel@tonic-gate nodeid = prom_nextnode(0); 3600Sstevel@tonic-gate #else /* x86 */ 3610Sstevel@tonic-gate nodeid = DEVI_SID_NODEID; 3620Sstevel@tonic-gate #endif 3630Sstevel@tonic-gate top_devinfo = i_ddi_alloc_node(NULL, rootname, 3640Sstevel@tonic-gate nodeid, -1, NULL, KM_SLEEP); 3650Sstevel@tonic-gate ndi_hold_devi(top_devinfo); /* never release the root */ 3660Sstevel@tonic-gate 3670Sstevel@tonic-gate i_ddi_add_devimap(top_devinfo); 3680Sstevel@tonic-gate 3690Sstevel@tonic-gate /* 3700Sstevel@tonic-gate * Bind root node. 3710Sstevel@tonic-gate * This code is special because root node has no parent 3720Sstevel@tonic-gate */ 3730Sstevel@tonic-gate major = ddi_name_to_major("rootnex"); 3740Sstevel@tonic-gate ASSERT(major != (major_t)-1); 3750Sstevel@tonic-gate DEVI(top_devinfo)->devi_major = major; 3760Sstevel@tonic-gate devnamesp[major].dn_head = top_devinfo; 3770Sstevel@tonic-gate i_ddi_set_binding_name(top_devinfo, rootname); 3780Sstevel@tonic-gate i_ddi_set_node_state(top_devinfo, DS_BOUND); 3790Sstevel@tonic-gate 3800Sstevel@tonic-gate /* 3810Sstevel@tonic-gate * Record that devinfos have been made for "rootnex." 3820Sstevel@tonic-gate * di_dfs() is used to read the prom because it doesn't get the 3830Sstevel@tonic-gate * next sibling until the function returns, unlike ddi_walk_devs(). 3840Sstevel@tonic-gate */ 3850Sstevel@tonic-gate di_dfs(ddi_root_node(), get_neighbors, 0); 386*851Sszhou 387*851Sszhou #if !defined(__sparc) 388*851Sszhou /* 389*851Sszhou * On x86, there is no prom. Create device tree by 390*851Sszhou * probing pci config space 391*851Sszhou */ 392*851Sszhou { 393*851Sszhou extern void impl_setup_ddi(void); 394*851Sszhou impl_setup_ddi(); 395*851Sszhou } 396*851Sszhou #endif /* x86 */ 3970Sstevel@tonic-gate } 3980Sstevel@tonic-gate 3990Sstevel@tonic-gate /* 4000Sstevel@tonic-gate * Init and attach the root node. root node is the first one to be 4010Sstevel@tonic-gate * attached, so the process is somewhat "handcrafted". 4020Sstevel@tonic-gate */ 4030Sstevel@tonic-gate void 4040Sstevel@tonic-gate i_ddi_init_root() 4050Sstevel@tonic-gate { 4060Sstevel@tonic-gate extern int i_ndi_make_spec_children(dev_info_t *, uint_t); 4070Sstevel@tonic-gate 4080Sstevel@tonic-gate #ifdef DDI_PROP_DEBUG 4090Sstevel@tonic-gate (void) ddi_prop_debug(1); /* Enable property debugging */ 4100Sstevel@tonic-gate #endif /* DDI_PROP_DEBUG */ 4110Sstevel@tonic-gate 4120Sstevel@tonic-gate /* 4130Sstevel@tonic-gate * Initialize root node 4140Sstevel@tonic-gate */ 4150Sstevel@tonic-gate if (impl_ddi_sunbus_initchild(top_devinfo) != DDI_SUCCESS) 4160Sstevel@tonic-gate panic("Could not initialize root nexus"); 4170Sstevel@tonic-gate 4180Sstevel@tonic-gate /* 4190Sstevel@tonic-gate * Attach root node (no need to probe) 4200Sstevel@tonic-gate * Hold both devinfo and rootnex driver so they can't go away. 4210Sstevel@tonic-gate */ 4220Sstevel@tonic-gate DEVI(top_devinfo)->devi_ops = ndi_hold_driver(top_devinfo); 4230Sstevel@tonic-gate ASSERT(DEV_OPS_HELD(DEVI(top_devinfo)->devi_ops)); 4240Sstevel@tonic-gate DEVI(top_devinfo)->devi_instance = e_ddi_assign_instance(top_devinfo); 4250Sstevel@tonic-gate 426495Scth mutex_enter(&(DEVI(top_devinfo)->devi_lock)); 4270Sstevel@tonic-gate DEVI_SET_ATTACHING(top_devinfo); 428495Scth mutex_exit(&(DEVI(top_devinfo)->devi_lock)); 429495Scth 4300Sstevel@tonic-gate if (devi_attach(top_devinfo, DDI_ATTACH) != DDI_SUCCESS) 4310Sstevel@tonic-gate panic("Could not attach root nexus"); 432495Scth 433495Scth mutex_enter(&(DEVI(top_devinfo)->devi_lock)); 4340Sstevel@tonic-gate DEVI_CLR_ATTACHING(top_devinfo); 435495Scth mutex_exit(&(DEVI(top_devinfo)->devi_lock)); 4360Sstevel@tonic-gate 4370Sstevel@tonic-gate mutex_init(&global_vhci_lock, NULL, MUTEX_DEFAULT, NULL); 4380Sstevel@tonic-gate 4390Sstevel@tonic-gate ndi_hold_devi(top_devinfo); /* hold it forever */ 4400Sstevel@tonic-gate i_ddi_set_node_state(top_devinfo, DS_READY); 4410Sstevel@tonic-gate 4420Sstevel@tonic-gate /* 4430Sstevel@tonic-gate * Now, expand .conf children of root 4440Sstevel@tonic-gate */ 4450Sstevel@tonic-gate (void) i_ndi_make_spec_children(top_devinfo, 0); 4460Sstevel@tonic-gate 4470Sstevel@tonic-gate /* 4480Sstevel@tonic-gate * Must be set up before attaching root or pseudo drivers 4490Sstevel@tonic-gate */ 4500Sstevel@tonic-gate pm_init_locks(); 4510Sstevel@tonic-gate 4520Sstevel@tonic-gate /* 4530Sstevel@tonic-gate * Attach options dip 4540Sstevel@tonic-gate */ 4550Sstevel@tonic-gate options_dip = i_ddi_attach_pseudo_node("options"); 4560Sstevel@tonic-gate 4570Sstevel@tonic-gate /* 4580Sstevel@tonic-gate * Attach pseudo nexus and enumerate its children 4590Sstevel@tonic-gate */ 4600Sstevel@tonic-gate pseudo_dip = i_ddi_attach_pseudo_node(DEVI_PSEUDO_NEXNAME); 4610Sstevel@tonic-gate (void) i_ndi_make_spec_children(pseudo_dip, 0); 4620Sstevel@tonic-gate 4630Sstevel@tonic-gate /* 4640Sstevel@tonic-gate * Attach and hold clone dip 4650Sstevel@tonic-gate */ 4660Sstevel@tonic-gate clone_dip = i_ddi_attach_pseudo_node("clone"); 4670Sstevel@tonic-gate clone_major = ddi_driver_major(clone_dip); 4680Sstevel@tonic-gate mm_major = ddi_name_to_major("mm"); 4690Sstevel@tonic-gate 4700Sstevel@tonic-gate /* 4710Sstevel@tonic-gate * Attach scsi_vhci for MPXIO, this registers scsi vhci class 4720Sstevel@tonic-gate * with the MPXIO framework. 4730Sstevel@tonic-gate */ 4740Sstevel@tonic-gate scsi_vhci_dip = i_ddi_attach_pseudo_node("scsi_vhci"); 4750Sstevel@tonic-gate } 476