xref: /onnv-gate/usr/src/uts/sun4u/os/mach_ddi_impl.c (revision 1991:f29baf5bf770)
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
5*1991Sheppo  * Common Development and Distribution License (the "License").
6*1991Sheppo  * 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  */
21*1991Sheppo 
220Sstevel@tonic-gate /*
231333Scth  * Copyright 2006 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  * sun4u specific DDI implementation
310Sstevel@tonic-gate  */
320Sstevel@tonic-gate #include <sys/bootconf.h>
330Sstevel@tonic-gate #include <sys/conf.h>
340Sstevel@tonic-gate #include <sys/ddi_subrdefs.h>
350Sstevel@tonic-gate #include <sys/ethernet.h>
360Sstevel@tonic-gate #include <sys/idprom.h>
370Sstevel@tonic-gate #include <sys/machsystm.h>
380Sstevel@tonic-gate #include <sys/promif.h>
390Sstevel@tonic-gate #include <sys/prom_plat.h>
400Sstevel@tonic-gate #include <sys/sunndi.h>
410Sstevel@tonic-gate #include <sys/systeminfo.h>
420Sstevel@tonic-gate #include <sys/fpu/fpusystm.h>
430Sstevel@tonic-gate #include <sys/vm.h>
440Sstevel@tonic-gate #include <sys/fs/dv_node.h>
450Sstevel@tonic-gate #include <sys/fs/snode.h>
460Sstevel@tonic-gate 
470Sstevel@tonic-gate /*
480Sstevel@tonic-gate  * Favored drivers of this implementation
490Sstevel@tonic-gate  * architecture.  These drivers MUST be present for
500Sstevel@tonic-gate  * the system to boot at all.
510Sstevel@tonic-gate  */
520Sstevel@tonic-gate char *impl_module_list[] = {
530Sstevel@tonic-gate 	"rootnex",
540Sstevel@tonic-gate 	"options",
550Sstevel@tonic-gate 	"sad",		/* Referenced via init_tbl[] */
560Sstevel@tonic-gate 	"pseudo",
570Sstevel@tonic-gate 	"clone",
580Sstevel@tonic-gate 	"scsi_vhci",
590Sstevel@tonic-gate 	(char *)0
600Sstevel@tonic-gate };
610Sstevel@tonic-gate 
620Sstevel@tonic-gate /*
630Sstevel@tonic-gate  * These strings passed to not_serviced in locore.s
640Sstevel@tonic-gate  */
650Sstevel@tonic-gate const char busname_ovec[] = "onboard ";
660Sstevel@tonic-gate const char busname_svec[] = "SBus ";
670Sstevel@tonic-gate const char busname_vec[] = "";
680Sstevel@tonic-gate 
690Sstevel@tonic-gate 
700Sstevel@tonic-gate static uint64_t *intr_map_reg[32];
710Sstevel@tonic-gate 
720Sstevel@tonic-gate /*
730Sstevel@tonic-gate  * Forward declarations
740Sstevel@tonic-gate  */
750Sstevel@tonic-gate static int getlongprop_buf();
760Sstevel@tonic-gate static int get_boardnum(int nid, dev_info_t *par);
770Sstevel@tonic-gate 
780Sstevel@tonic-gate /*
790Sstevel@tonic-gate  * Check the status of the device node passed as an argument.
800Sstevel@tonic-gate  *
810Sstevel@tonic-gate  *	if ((status is OKAY) || (status is DISABLED))
820Sstevel@tonic-gate  *		return DDI_SUCCESS
830Sstevel@tonic-gate  *	else
840Sstevel@tonic-gate  *		print a warning and return DDI_FAILURE
850Sstevel@tonic-gate  */
860Sstevel@tonic-gate /*ARGSUSED*/
870Sstevel@tonic-gate int
880Sstevel@tonic-gate check_status(int id, char *buf, dev_info_t *parent)
890Sstevel@tonic-gate {
900Sstevel@tonic-gate 	char status_buf[64];
910Sstevel@tonic-gate 	char devtype_buf[OBP_MAXPROPNAME];
920Sstevel@tonic-gate 	char board_buf[32];
930Sstevel@tonic-gate 	char path[OBP_MAXPATHLEN];
940Sstevel@tonic-gate 	int boardnum;
950Sstevel@tonic-gate 	int retval = DDI_FAILURE;
960Sstevel@tonic-gate 	extern int status_okay(int, char *, int);
970Sstevel@tonic-gate 
980Sstevel@tonic-gate 	/*
990Sstevel@tonic-gate 	 * is the status okay?
1000Sstevel@tonic-gate 	 */
1010Sstevel@tonic-gate 	if (status_okay(id, status_buf, sizeof (status_buf)))
1020Sstevel@tonic-gate 		return (DDI_SUCCESS);
1030Sstevel@tonic-gate 
1040Sstevel@tonic-gate 	/*
1050Sstevel@tonic-gate 	 * a status property indicating bad memory will be associated
1060Sstevel@tonic-gate 	 * with a node which has a "device_type" property with a value of
1070Sstevel@tonic-gate 	 * "memory-controller". in this situation, return DDI_SUCCESS
1080Sstevel@tonic-gate 	 */
1090Sstevel@tonic-gate 	if (getlongprop_buf(id, OBP_DEVICETYPE, devtype_buf,
1100Sstevel@tonic-gate 	    sizeof (devtype_buf)) > 0) {
1110Sstevel@tonic-gate 		if (strcmp(devtype_buf, "memory-controller") == 0)
1120Sstevel@tonic-gate 			retval = DDI_SUCCESS;
1130Sstevel@tonic-gate 	}
1140Sstevel@tonic-gate 
1150Sstevel@tonic-gate 	/*
1160Sstevel@tonic-gate 	 * get the full OBP pathname of this node
1170Sstevel@tonic-gate 	 */
1180Sstevel@tonic-gate 	if (prom_phandle_to_path((phandle_t)id, path, sizeof (path)) < 0)
1190Sstevel@tonic-gate 		cmn_err(CE_WARN, "prom_phandle_to_path(%d) failed", id);
1200Sstevel@tonic-gate 
1210Sstevel@tonic-gate 	/*
1220Sstevel@tonic-gate 	 * get the board number, if one exists
1230Sstevel@tonic-gate 	 */
1240Sstevel@tonic-gate 	if ((boardnum = get_boardnum(id, parent)) >= 0)
1250Sstevel@tonic-gate 		(void) sprintf(board_buf, " on board %d", boardnum);
1260Sstevel@tonic-gate 	else
1270Sstevel@tonic-gate 		board_buf[0] = '\0';
1280Sstevel@tonic-gate 
1290Sstevel@tonic-gate 	/*
1300Sstevel@tonic-gate 	 * print the status property information
1310Sstevel@tonic-gate 	 */
1320Sstevel@tonic-gate 	cmn_err(CE_WARN, "status '%s' for '%s'%s",
1330Sstevel@tonic-gate 		status_buf, path, board_buf);
1340Sstevel@tonic-gate 	return (retval);
1350Sstevel@tonic-gate }
1360Sstevel@tonic-gate 
1370Sstevel@tonic-gate /*
1380Sstevel@tonic-gate  * determine the board number associated with this nodeid
1390Sstevel@tonic-gate  */
1400Sstevel@tonic-gate static int
1410Sstevel@tonic-gate get_boardnum(int nid, dev_info_t *par)
1420Sstevel@tonic-gate {
1430Sstevel@tonic-gate 	int board_num;
1440Sstevel@tonic-gate 
145789Sahrens 	if (prom_getprop((pnode_t)nid, OBP_BOARDNUM,
1460Sstevel@tonic-gate 	    (caddr_t)&board_num) != -1)
1470Sstevel@tonic-gate 		return (board_num);
1480Sstevel@tonic-gate 
1490Sstevel@tonic-gate 	/*
1500Sstevel@tonic-gate 	 * Look at current node and up the parent chain
1510Sstevel@tonic-gate 	 * till we find a node with an OBP_BOARDNUM.
1520Sstevel@tonic-gate 	 */
1530Sstevel@tonic-gate 	while (par) {
1540Sstevel@tonic-gate 		nid = ddi_get_nodeid(par);
1550Sstevel@tonic-gate 
156789Sahrens 		if (prom_getprop((pnode_t)nid, OBP_BOARDNUM,
1570Sstevel@tonic-gate 		    (caddr_t)&board_num) != -1)
1580Sstevel@tonic-gate 			return (board_num);
1590Sstevel@tonic-gate 
1600Sstevel@tonic-gate 		par = ddi_get_parent(par);
1610Sstevel@tonic-gate 	}
1620Sstevel@tonic-gate 	return (-1);
1630Sstevel@tonic-gate }
1640Sstevel@tonic-gate 
1650Sstevel@tonic-gate /*
1660Sstevel@tonic-gate  * Note that this routine does not take into account the endianness
1670Sstevel@tonic-gate  * of the host or the device (or PROM) when retrieving properties.
1680Sstevel@tonic-gate  */
1690Sstevel@tonic-gate static int
1700Sstevel@tonic-gate getlongprop_buf(int id, char *name, char *buf, int maxlen)
1710Sstevel@tonic-gate {
1720Sstevel@tonic-gate 	int size;
1730Sstevel@tonic-gate 
174789Sahrens 	size = prom_getproplen((pnode_t)id, name);
1750Sstevel@tonic-gate 	if (size <= 0 || (size > maxlen - 1))
1760Sstevel@tonic-gate 		return (-1);
1770Sstevel@tonic-gate 
178789Sahrens 	if (-1 == prom_getprop((pnode_t)id, name, buf))
1790Sstevel@tonic-gate 		return (-1);
1800Sstevel@tonic-gate 
1810Sstevel@tonic-gate 	/*
1820Sstevel@tonic-gate 	 * Workaround for bugid 1085575 - OBP may return a "name" property
1830Sstevel@tonic-gate 	 * without null terminating the string with '\0'.  When this occurs,
1840Sstevel@tonic-gate 	 * append a '\0' and return (size + 1).
1850Sstevel@tonic-gate 	 */
1860Sstevel@tonic-gate 	if (strcmp("name", name) == 0) {
1870Sstevel@tonic-gate 		if (buf[size - 1] != '\0') {
1880Sstevel@tonic-gate 			buf[size] = '\0';
1890Sstevel@tonic-gate 			size += 1;
1900Sstevel@tonic-gate 		}
1910Sstevel@tonic-gate 	}
1920Sstevel@tonic-gate 
1930Sstevel@tonic-gate 	return (size);
1940Sstevel@tonic-gate }
1950Sstevel@tonic-gate 
1960Sstevel@tonic-gate /*
1970Sstevel@tonic-gate  * Routines to set/get UPA slave only device interrupt mapping registers.
1980Sstevel@tonic-gate  * set_intr_mapping_reg() is called by the UPA master to register the address
1990Sstevel@tonic-gate  * of an interrupt mapping register. The upa id is that of the master. If
2000Sstevel@tonic-gate  * this routine is called on behalf of a slave device, the framework
2010Sstevel@tonic-gate  * determines the upa id of the slave based on that supplied by the master.
2020Sstevel@tonic-gate  *
2030Sstevel@tonic-gate  * get_intr_mapping_reg() is called by the UPA nexus driver on behalf
2040Sstevel@tonic-gate  * of a child device to get and program the interrupt mapping register of
2050Sstevel@tonic-gate  * one of it's child nodes.  It uses the upa id of the child device to
2060Sstevel@tonic-gate  * index into a table of mapping registers.  If the routine is called on
2070Sstevel@tonic-gate  * behalf of a slave device and the mapping register has not been set,
2080Sstevel@tonic-gate  * the framework determines the devinfo node of the corresponding master
2090Sstevel@tonic-gate  * nexus which owns the mapping register of the slave and installs that
2100Sstevel@tonic-gate  * driver.  The device driver which owns the mapping register must call
2110Sstevel@tonic-gate  * set_intr_mapping_reg() in its attach routine to register the slaves
2120Sstevel@tonic-gate  * mapping register with the system.
2130Sstevel@tonic-gate  */
2140Sstevel@tonic-gate void
2150Sstevel@tonic-gate set_intr_mapping_reg(int upaid, uint64_t *addr, int slave)
2160Sstevel@tonic-gate {
2170Sstevel@tonic-gate 	int affin_upaid;
2180Sstevel@tonic-gate 
2190Sstevel@tonic-gate 	/* For UPA master devices, set the mapping reg addr and we're done */
2200Sstevel@tonic-gate 	if (slave == 0) {
2210Sstevel@tonic-gate 		intr_map_reg[upaid] = addr;
2220Sstevel@tonic-gate 		return;
2230Sstevel@tonic-gate 	}
2240Sstevel@tonic-gate 
2250Sstevel@tonic-gate 	/*
2260Sstevel@tonic-gate 	 * If we get here, we're adding an entry for a UPA slave only device.
2270Sstevel@tonic-gate 	 * The UPA id of the device which has affinity with that requesting,
2280Sstevel@tonic-gate 	 * will be the device with the same UPA id minus the slave number.
2290Sstevel@tonic-gate 	 * If the affin_upaid is negative, silently return to the caller.
2300Sstevel@tonic-gate 	 */
2310Sstevel@tonic-gate 	if ((affin_upaid = upaid - slave) < 0)
2320Sstevel@tonic-gate 		return;
2330Sstevel@tonic-gate 
2340Sstevel@tonic-gate 	/*
2350Sstevel@tonic-gate 	 * Load the address of the mapping register in the correct slot
2360Sstevel@tonic-gate 	 * for the slave device.
2370Sstevel@tonic-gate 	 */
2380Sstevel@tonic-gate 	intr_map_reg[affin_upaid] = addr;
2390Sstevel@tonic-gate }
2400Sstevel@tonic-gate 
2410Sstevel@tonic-gate uint64_t *
2420Sstevel@tonic-gate get_intr_mapping_reg(int upaid, int slave)
2430Sstevel@tonic-gate {
2440Sstevel@tonic-gate 	int affin_upaid;
2450Sstevel@tonic-gate 	dev_info_t *affin_dip;
2460Sstevel@tonic-gate 	uint64_t *addr = intr_map_reg[upaid];
2470Sstevel@tonic-gate 
2480Sstevel@tonic-gate 	/* If we're a UPA master, or we have a valid mapping register. */
2490Sstevel@tonic-gate 	if (!slave || addr != NULL)
2500Sstevel@tonic-gate 		return (addr);
2510Sstevel@tonic-gate 
2520Sstevel@tonic-gate 	/*
2530Sstevel@tonic-gate 	 * We only get here if we're a UPA slave only device whose interrupt
2540Sstevel@tonic-gate 	 * mapping register has not been set.
2550Sstevel@tonic-gate 	 * We need to try and install the nexus whose physical address
2560Sstevel@tonic-gate 	 * space is where the slaves mapping register resides.  They
2570Sstevel@tonic-gate 	 * should call set_intr_mapping_reg() in their xxattach() to register
2580Sstevel@tonic-gate 	 * the mapping register with the system.
2590Sstevel@tonic-gate 	 */
2600Sstevel@tonic-gate 
2610Sstevel@tonic-gate 	/*
2620Sstevel@tonic-gate 	 * We don't know if a single- or multi-interrupt proxy is fielding
2630Sstevel@tonic-gate 	 * our UPA slave interrupt, we must check both cases.
2640Sstevel@tonic-gate 	 * Start out by assuming the multi-interrupt case.
2650Sstevel@tonic-gate 	 * We assume that single- and multi- interrupters are not
2660Sstevel@tonic-gate 	 * overlapping in UPA portid space.
2670Sstevel@tonic-gate 	 */
2680Sstevel@tonic-gate 
2690Sstevel@tonic-gate 	affin_upaid = upaid | 3;
2700Sstevel@tonic-gate 
2710Sstevel@tonic-gate 	/*
2720Sstevel@tonic-gate 	 * We start looking for the multi-interrupter affinity node.
2730Sstevel@tonic-gate 	 * We know it's ONLY a child of the root node since the root
2740Sstevel@tonic-gate 	 * node defines UPA space.
2750Sstevel@tonic-gate 	 */
2760Sstevel@tonic-gate 	for (affin_dip = ddi_get_child(ddi_root_node()); affin_dip;
2770Sstevel@tonic-gate 	    affin_dip = ddi_get_next_sibling(affin_dip))
2780Sstevel@tonic-gate 		if (ddi_prop_get_int(DDI_DEV_T_ANY, affin_dip,
2790Sstevel@tonic-gate 		    DDI_PROP_DONTPASS, "upa-portid", -1) == affin_upaid)
2800Sstevel@tonic-gate 			break;
2810Sstevel@tonic-gate 
2820Sstevel@tonic-gate 	if (affin_dip) {
2830Sstevel@tonic-gate 		if (i_ddi_attach_node_hierarchy(affin_dip) == DDI_SUCCESS) {
2840Sstevel@tonic-gate 			/* try again to get the mapping register. */
2850Sstevel@tonic-gate 			addr = intr_map_reg[upaid];
2860Sstevel@tonic-gate 		}
2870Sstevel@tonic-gate 	}
2880Sstevel@tonic-gate 
2890Sstevel@tonic-gate 	/*
2900Sstevel@tonic-gate 	 * If we still don't have a mapping register try single -interrupter
2910Sstevel@tonic-gate 	 * case.
2920Sstevel@tonic-gate 	 */
2930Sstevel@tonic-gate 	if (addr == NULL) {
2940Sstevel@tonic-gate 
2950Sstevel@tonic-gate 		affin_upaid = upaid | 1;
2960Sstevel@tonic-gate 
2970Sstevel@tonic-gate 		for (affin_dip = ddi_get_child(ddi_root_node()); affin_dip;
2980Sstevel@tonic-gate 		    affin_dip = ddi_get_next_sibling(affin_dip))
2990Sstevel@tonic-gate 			if (ddi_prop_get_int(DDI_DEV_T_ANY, affin_dip,
3000Sstevel@tonic-gate 			    DDI_PROP_DONTPASS, "upa-portid", -1) == affin_upaid)
3010Sstevel@tonic-gate 				break;
3020Sstevel@tonic-gate 
3030Sstevel@tonic-gate 		if (affin_dip) {
3040Sstevel@tonic-gate 			if (i_ddi_attach_node_hierarchy(affin_dip)
3050Sstevel@tonic-gate 			    == DDI_SUCCESS) {
3060Sstevel@tonic-gate 				/* try again to get the mapping register. */
3070Sstevel@tonic-gate 				addr = intr_map_reg[upaid];
3080Sstevel@tonic-gate 			}
3090Sstevel@tonic-gate 		}
3100Sstevel@tonic-gate 	}
3110Sstevel@tonic-gate 	return (addr);
3120Sstevel@tonic-gate }
3130Sstevel@tonic-gate 
3140Sstevel@tonic-gate 
3150Sstevel@tonic-gate static struct upa_dma_pfns {
3160Sstevel@tonic-gate 	pfn_t hipfn;
3170Sstevel@tonic-gate 	pfn_t lopfn;
3180Sstevel@tonic-gate } upa_dma_pfn_array[MAX_UPA];
3190Sstevel@tonic-gate 
3200Sstevel@tonic-gate static int upa_dma_pfn_ndx = 0;
3210Sstevel@tonic-gate 
3220Sstevel@tonic-gate /*
3230Sstevel@tonic-gate  * Certain UPA busses cannot accept dma transactions from any other source
3240Sstevel@tonic-gate  * except for memory due to livelock conditions in their hardware. (e.g. sbus
3250Sstevel@tonic-gate  * and PCI). These routines allow devices or busses on the UPA to register
3260Sstevel@tonic-gate  * a physical address block within it's own register space where DMA can be
3270Sstevel@tonic-gate  * performed.  Currently, the FFB is the only such device which supports
3280Sstevel@tonic-gate  * device DMA on the UPA.
3290Sstevel@tonic-gate  */
3300Sstevel@tonic-gate void
3310Sstevel@tonic-gate pf_set_dmacapable(pfn_t hipfn, pfn_t lopfn)
3320Sstevel@tonic-gate {
3330Sstevel@tonic-gate 	int i = upa_dma_pfn_ndx;
3340Sstevel@tonic-gate 
3350Sstevel@tonic-gate 	upa_dma_pfn_ndx++;
3360Sstevel@tonic-gate 
3370Sstevel@tonic-gate 	upa_dma_pfn_array[i].hipfn = hipfn;
3380Sstevel@tonic-gate 	upa_dma_pfn_array[i].lopfn = lopfn;
3390Sstevel@tonic-gate }
3400Sstevel@tonic-gate 
3410Sstevel@tonic-gate void
3420Sstevel@tonic-gate pf_unset_dmacapable(pfn_t pfn)
3430Sstevel@tonic-gate {
3440Sstevel@tonic-gate 	int i;
3450Sstevel@tonic-gate 
3460Sstevel@tonic-gate 	for (i = 0; i < upa_dma_pfn_ndx; i++) {
3470Sstevel@tonic-gate 		if (pfn <= upa_dma_pfn_array[i].hipfn &&
3480Sstevel@tonic-gate 		    pfn >= upa_dma_pfn_array[i].lopfn) {
3490Sstevel@tonic-gate 			upa_dma_pfn_array[i].hipfn =
3500Sstevel@tonic-gate 			    upa_dma_pfn_array[upa_dma_pfn_ndx - 1].hipfn;
3510Sstevel@tonic-gate 			upa_dma_pfn_array[i].lopfn =
3520Sstevel@tonic-gate 			    upa_dma_pfn_array[upa_dma_pfn_ndx - 1].lopfn;
3530Sstevel@tonic-gate 			upa_dma_pfn_ndx--;
3540Sstevel@tonic-gate 			break;
3550Sstevel@tonic-gate 		}
3560Sstevel@tonic-gate 	}
3570Sstevel@tonic-gate }
3580Sstevel@tonic-gate 
3590Sstevel@tonic-gate /*
3600Sstevel@tonic-gate  * This routine should only be called using a pfn that is known to reside
3610Sstevel@tonic-gate  * in IO space.  The function pf_is_memory() can be used to determine this.
3620Sstevel@tonic-gate  */
3630Sstevel@tonic-gate int
3640Sstevel@tonic-gate pf_is_dmacapable(pfn_t pfn)
3650Sstevel@tonic-gate {
3660Sstevel@tonic-gate 	int i, j;
3670Sstevel@tonic-gate 
3680Sstevel@tonic-gate 	/* If the caller passed in a memory pfn, return true. */
3690Sstevel@tonic-gate 	if (pf_is_memory(pfn))
3700Sstevel@tonic-gate 		return (1);
3710Sstevel@tonic-gate 
3720Sstevel@tonic-gate 	for (i = upa_dma_pfn_ndx, j = 0; j < i; j++)
3730Sstevel@tonic-gate 		if (pfn <= upa_dma_pfn_array[j].hipfn &&
3740Sstevel@tonic-gate 		    pfn >= upa_dma_pfn_array[j].lopfn)
3750Sstevel@tonic-gate 			return (1);
3760Sstevel@tonic-gate 
3770Sstevel@tonic-gate 	return (0);
3780Sstevel@tonic-gate }
3790Sstevel@tonic-gate 
3800Sstevel@tonic-gate 
3810Sstevel@tonic-gate /*
3820Sstevel@tonic-gate  * Find cpu_id corresponding to the dip of a CPU device node
3830Sstevel@tonic-gate  */
3840Sstevel@tonic-gate int
3850Sstevel@tonic-gate dip_to_cpu_id(dev_info_t *dip, processorid_t *cpu_id)
3860Sstevel@tonic-gate {
387789Sahrens 	pnode_t		nodeid;
3880Sstevel@tonic-gate 	int		i;
3890Sstevel@tonic-gate 
390789Sahrens 	nodeid = (pnode_t)ddi_get_nodeid(dip);
3910Sstevel@tonic-gate 	for (i = 0; i < NCPU; i++) {
3920Sstevel@tonic-gate 		if (cpunodes[i].nodeid == nodeid) {
3930Sstevel@tonic-gate 			*cpu_id = i;
3940Sstevel@tonic-gate 			return (DDI_SUCCESS);
3950Sstevel@tonic-gate 		}
3960Sstevel@tonic-gate 	}
3970Sstevel@tonic-gate 	return (DDI_FAILURE);
3980Sstevel@tonic-gate }
399