17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51ae08745Sheppo  * Common Development and Distribution License (the "License").
61ae08745Sheppo  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
211ae08745Sheppo 
227c478bd9Sstevel@tonic-gate /*
23*fc256490SJason Beloro  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate /*
287c478bd9Sstevel@tonic-gate  * sun4u specific DDI implementation
297c478bd9Sstevel@tonic-gate  */
307c478bd9Sstevel@tonic-gate #include <sys/bootconf.h>
317c478bd9Sstevel@tonic-gate #include <sys/conf.h>
327c478bd9Sstevel@tonic-gate #include <sys/ddi_subrdefs.h>
337c478bd9Sstevel@tonic-gate #include <sys/ethernet.h>
347c478bd9Sstevel@tonic-gate #include <sys/idprom.h>
357c478bd9Sstevel@tonic-gate #include <sys/machsystm.h>
367c478bd9Sstevel@tonic-gate #include <sys/promif.h>
377c478bd9Sstevel@tonic-gate #include <sys/prom_plat.h>
387c478bd9Sstevel@tonic-gate #include <sys/sunndi.h>
397c478bd9Sstevel@tonic-gate #include <sys/systeminfo.h>
407c478bd9Sstevel@tonic-gate #include <sys/fpu/fpusystm.h>
417c478bd9Sstevel@tonic-gate #include <sys/vm.h>
427c478bd9Sstevel@tonic-gate #include <sys/fs/dv_node.h>
437c478bd9Sstevel@tonic-gate #include <sys/fs/snode.h>
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate /*
467c478bd9Sstevel@tonic-gate  * Favored drivers of this implementation
477c478bd9Sstevel@tonic-gate  * architecture.  These drivers MUST be present for
487c478bd9Sstevel@tonic-gate  * the system to boot at all.
497c478bd9Sstevel@tonic-gate  */
507c478bd9Sstevel@tonic-gate char *impl_module_list[] = {
517c478bd9Sstevel@tonic-gate 	"rootnex",
527c478bd9Sstevel@tonic-gate 	"options",
537c478bd9Sstevel@tonic-gate 	"sad",		/* Referenced via init_tbl[] */
547c478bd9Sstevel@tonic-gate 	"pseudo",
557c478bd9Sstevel@tonic-gate 	"clone",
567c478bd9Sstevel@tonic-gate 	"scsi_vhci",
577c478bd9Sstevel@tonic-gate 	(char *)0
587c478bd9Sstevel@tonic-gate };
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate /*
617c478bd9Sstevel@tonic-gate  * These strings passed to not_serviced in locore.s
627c478bd9Sstevel@tonic-gate  */
637c478bd9Sstevel@tonic-gate const char busname_ovec[] = "onboard ";
647c478bd9Sstevel@tonic-gate const char busname_svec[] = "SBus ";
657c478bd9Sstevel@tonic-gate const char busname_vec[] = "";
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate static uint64_t *intr_map_reg[32];
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate /*
717c478bd9Sstevel@tonic-gate  * Forward declarations
727c478bd9Sstevel@tonic-gate  */
737c478bd9Sstevel@tonic-gate static int getlongprop_buf();
747c478bd9Sstevel@tonic-gate static int get_boardnum(int nid, dev_info_t *par);
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate /*
777c478bd9Sstevel@tonic-gate  * Check the status of the device node passed as an argument.
787c478bd9Sstevel@tonic-gate  *
797c478bd9Sstevel@tonic-gate  *	if ((status is OKAY) || (status is DISABLED))
807c478bd9Sstevel@tonic-gate  *		return DDI_SUCCESS
817c478bd9Sstevel@tonic-gate  *	else
827c478bd9Sstevel@tonic-gate  *		print a warning and return DDI_FAILURE
837c478bd9Sstevel@tonic-gate  */
847c478bd9Sstevel@tonic-gate /*ARGSUSED*/
857c478bd9Sstevel@tonic-gate int
check_status(int id,char * buf,dev_info_t * parent)867c478bd9Sstevel@tonic-gate check_status(int id, char *buf, dev_info_t *parent)
877c478bd9Sstevel@tonic-gate {
887c478bd9Sstevel@tonic-gate 	char status_buf[64];
897c478bd9Sstevel@tonic-gate 	char devtype_buf[OBP_MAXPROPNAME];
907c478bd9Sstevel@tonic-gate 	char board_buf[32];
917c478bd9Sstevel@tonic-gate 	char path[OBP_MAXPATHLEN];
927c478bd9Sstevel@tonic-gate 	int boardnum;
937c478bd9Sstevel@tonic-gate 	int retval = DDI_FAILURE;
947c478bd9Sstevel@tonic-gate 	extern int status_okay(int, char *, int);
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate 	/*
977c478bd9Sstevel@tonic-gate 	 * is the status okay?
987c478bd9Sstevel@tonic-gate 	 */
997c478bd9Sstevel@tonic-gate 	if (status_okay(id, status_buf, sizeof (status_buf)))
1007c478bd9Sstevel@tonic-gate 		return (DDI_SUCCESS);
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate 	/*
1037c478bd9Sstevel@tonic-gate 	 * a status property indicating bad memory will be associated
1047c478bd9Sstevel@tonic-gate 	 * with a node which has a "device_type" property with a value of
1057c478bd9Sstevel@tonic-gate 	 * "memory-controller". in this situation, return DDI_SUCCESS
1067c478bd9Sstevel@tonic-gate 	 */
1077c478bd9Sstevel@tonic-gate 	if (getlongprop_buf(id, OBP_DEVICETYPE, devtype_buf,
1087c478bd9Sstevel@tonic-gate 	    sizeof (devtype_buf)) > 0) {
1097c478bd9Sstevel@tonic-gate 		if (strcmp(devtype_buf, "memory-controller") == 0)
1107c478bd9Sstevel@tonic-gate 			retval = DDI_SUCCESS;
1117c478bd9Sstevel@tonic-gate 	}
1127c478bd9Sstevel@tonic-gate 
1137c478bd9Sstevel@tonic-gate 	/*
1147c478bd9Sstevel@tonic-gate 	 * get the full OBP pathname of this node
1157c478bd9Sstevel@tonic-gate 	 */
1167c478bd9Sstevel@tonic-gate 	if (prom_phandle_to_path((phandle_t)id, path, sizeof (path)) < 0)
1177c478bd9Sstevel@tonic-gate 		cmn_err(CE_WARN, "prom_phandle_to_path(%d) failed", id);
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate 	/*
1207c478bd9Sstevel@tonic-gate 	 * get the board number, if one exists
1217c478bd9Sstevel@tonic-gate 	 */
1227c478bd9Sstevel@tonic-gate 	if ((boardnum = get_boardnum(id, parent)) >= 0)
1237c478bd9Sstevel@tonic-gate 		(void) sprintf(board_buf, " on board %d", boardnum);
1247c478bd9Sstevel@tonic-gate 	else
1257c478bd9Sstevel@tonic-gate 		board_buf[0] = '\0';
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate 	/*
1287c478bd9Sstevel@tonic-gate 	 * print the status property information
1297c478bd9Sstevel@tonic-gate 	 */
1307c478bd9Sstevel@tonic-gate 	cmn_err(CE_WARN, "status '%s' for '%s'%s",
131*fc256490SJason Beloro 	    status_buf, path, board_buf);
1327c478bd9Sstevel@tonic-gate 	return (retval);
1337c478bd9Sstevel@tonic-gate }
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate /*
1367c478bd9Sstevel@tonic-gate  * determine the board number associated with this nodeid
1377c478bd9Sstevel@tonic-gate  */
1387c478bd9Sstevel@tonic-gate static int
get_boardnum(int nid,dev_info_t * par)1397c478bd9Sstevel@tonic-gate get_boardnum(int nid, dev_info_t *par)
1407c478bd9Sstevel@tonic-gate {
1417c478bd9Sstevel@tonic-gate 	int board_num;
1427c478bd9Sstevel@tonic-gate 
143fa9e4066Sahrens 	if (prom_getprop((pnode_t)nid, OBP_BOARDNUM,
1447c478bd9Sstevel@tonic-gate 	    (caddr_t)&board_num) != -1)
1457c478bd9Sstevel@tonic-gate 		return (board_num);
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate 	/*
1487c478bd9Sstevel@tonic-gate 	 * Look at current node and up the parent chain
1497c478bd9Sstevel@tonic-gate 	 * till we find a node with an OBP_BOARDNUM.
1507c478bd9Sstevel@tonic-gate 	 */
1517c478bd9Sstevel@tonic-gate 	while (par) {
1527c478bd9Sstevel@tonic-gate 		nid = ddi_get_nodeid(par);
1537c478bd9Sstevel@tonic-gate 
154fa9e4066Sahrens 		if (prom_getprop((pnode_t)nid, OBP_BOARDNUM,
1557c478bd9Sstevel@tonic-gate 		    (caddr_t)&board_num) != -1)
1567c478bd9Sstevel@tonic-gate 			return (board_num);
1577c478bd9Sstevel@tonic-gate 
1587c478bd9Sstevel@tonic-gate 		par = ddi_get_parent(par);
1597c478bd9Sstevel@tonic-gate 	}
1607c478bd9Sstevel@tonic-gate 	return (-1);
1617c478bd9Sstevel@tonic-gate }
1627c478bd9Sstevel@tonic-gate 
1637c478bd9Sstevel@tonic-gate /*
1647c478bd9Sstevel@tonic-gate  * Note that this routine does not take into account the endianness
1657c478bd9Sstevel@tonic-gate  * of the host or the device (or PROM) when retrieving properties.
1667c478bd9Sstevel@tonic-gate  */
1677c478bd9Sstevel@tonic-gate static int
getlongprop_buf(int id,char * name,char * buf,int maxlen)1687c478bd9Sstevel@tonic-gate getlongprop_buf(int id, char *name, char *buf, int maxlen)
1697c478bd9Sstevel@tonic-gate {
1707c478bd9Sstevel@tonic-gate 	int size;
1717c478bd9Sstevel@tonic-gate 
172fa9e4066Sahrens 	size = prom_getproplen((pnode_t)id, name);
1737c478bd9Sstevel@tonic-gate 	if (size <= 0 || (size > maxlen - 1))
1747c478bd9Sstevel@tonic-gate 		return (-1);
1757c478bd9Sstevel@tonic-gate 
176fa9e4066Sahrens 	if (-1 == prom_getprop((pnode_t)id, name, buf))
1777c478bd9Sstevel@tonic-gate 		return (-1);
1787c478bd9Sstevel@tonic-gate 
1797c478bd9Sstevel@tonic-gate 	/*
1807c478bd9Sstevel@tonic-gate 	 * Workaround for bugid 1085575 - OBP may return a "name" property
1817c478bd9Sstevel@tonic-gate 	 * without null terminating the string with '\0'.  When this occurs,
1827c478bd9Sstevel@tonic-gate 	 * append a '\0' and return (size + 1).
1837c478bd9Sstevel@tonic-gate 	 */
1847c478bd9Sstevel@tonic-gate 	if (strcmp("name", name) == 0) {
1857c478bd9Sstevel@tonic-gate 		if (buf[size - 1] != '\0') {
1867c478bd9Sstevel@tonic-gate 			buf[size] = '\0';
1877c478bd9Sstevel@tonic-gate 			size += 1;
1887c478bd9Sstevel@tonic-gate 		}
1897c478bd9Sstevel@tonic-gate 	}
1907c478bd9Sstevel@tonic-gate 
1917c478bd9Sstevel@tonic-gate 	return (size);
1927c478bd9Sstevel@tonic-gate }
1937c478bd9Sstevel@tonic-gate 
1947c478bd9Sstevel@tonic-gate /*
1957c478bd9Sstevel@tonic-gate  * Routines to set/get UPA slave only device interrupt mapping registers.
1967c478bd9Sstevel@tonic-gate  * set_intr_mapping_reg() is called by the UPA master to register the address
1977c478bd9Sstevel@tonic-gate  * of an interrupt mapping register. The upa id is that of the master. If
1987c478bd9Sstevel@tonic-gate  * this routine is called on behalf of a slave device, the framework
1997c478bd9Sstevel@tonic-gate  * determines the upa id of the slave based on that supplied by the master.
2007c478bd9Sstevel@tonic-gate  *
2017c478bd9Sstevel@tonic-gate  * get_intr_mapping_reg() is called by the UPA nexus driver on behalf
2027c478bd9Sstevel@tonic-gate  * of a child device to get and program the interrupt mapping register of
2037c478bd9Sstevel@tonic-gate  * one of it's child nodes.  It uses the upa id of the child device to
2047c478bd9Sstevel@tonic-gate  * index into a table of mapping registers.  If the routine is called on
2057c478bd9Sstevel@tonic-gate  * behalf of a slave device and the mapping register has not been set,
2067c478bd9Sstevel@tonic-gate  * the framework determines the devinfo node of the corresponding master
2077c478bd9Sstevel@tonic-gate  * nexus which owns the mapping register of the slave and installs that
2087c478bd9Sstevel@tonic-gate  * driver.  The device driver which owns the mapping register must call
2097c478bd9Sstevel@tonic-gate  * set_intr_mapping_reg() in its attach routine to register the slaves
2107c478bd9Sstevel@tonic-gate  * mapping register with the system.
2117c478bd9Sstevel@tonic-gate  */
2127c478bd9Sstevel@tonic-gate void
set_intr_mapping_reg(int upaid,uint64_t * addr,int slave)2137c478bd9Sstevel@tonic-gate set_intr_mapping_reg(int upaid, uint64_t *addr, int slave)
2147c478bd9Sstevel@tonic-gate {
2157c478bd9Sstevel@tonic-gate 	int affin_upaid;
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate 	/* For UPA master devices, set the mapping reg addr and we're done */
2187c478bd9Sstevel@tonic-gate 	if (slave == 0) {
2197c478bd9Sstevel@tonic-gate 		intr_map_reg[upaid] = addr;
2207c478bd9Sstevel@tonic-gate 		return;
2217c478bd9Sstevel@tonic-gate 	}
2227c478bd9Sstevel@tonic-gate 
2237c478bd9Sstevel@tonic-gate 	/*
2247c478bd9Sstevel@tonic-gate 	 * If we get here, we're adding an entry for a UPA slave only device.
2257c478bd9Sstevel@tonic-gate 	 * The UPA id of the device which has affinity with that requesting,
2267c478bd9Sstevel@tonic-gate 	 * will be the device with the same UPA id minus the slave number.
2277c478bd9Sstevel@tonic-gate 	 * If the affin_upaid is negative, silently return to the caller.
2287c478bd9Sstevel@tonic-gate 	 */
2297c478bd9Sstevel@tonic-gate 	if ((affin_upaid = upaid - slave) < 0)
2307c478bd9Sstevel@tonic-gate 		return;
2317c478bd9Sstevel@tonic-gate 
2327c478bd9Sstevel@tonic-gate 	/*
2337c478bd9Sstevel@tonic-gate 	 * Load the address of the mapping register in the correct slot
2347c478bd9Sstevel@tonic-gate 	 * for the slave device.
2357c478bd9Sstevel@tonic-gate 	 */
2367c478bd9Sstevel@tonic-gate 	intr_map_reg[affin_upaid] = addr;
2377c478bd9Sstevel@tonic-gate }
2387c478bd9Sstevel@tonic-gate 
2397c478bd9Sstevel@tonic-gate uint64_t *
get_intr_mapping_reg(int upaid,int slave)2407c478bd9Sstevel@tonic-gate get_intr_mapping_reg(int upaid, int slave)
2417c478bd9Sstevel@tonic-gate {
2427c478bd9Sstevel@tonic-gate 	int affin_upaid;
2437c478bd9Sstevel@tonic-gate 	dev_info_t *affin_dip;
2447c478bd9Sstevel@tonic-gate 	uint64_t *addr = intr_map_reg[upaid];
2457c478bd9Sstevel@tonic-gate 
2467c478bd9Sstevel@tonic-gate 	/* If we're a UPA master, or we have a valid mapping register. */
2477c478bd9Sstevel@tonic-gate 	if (!slave || addr != NULL)
2487c478bd9Sstevel@tonic-gate 		return (addr);
2497c478bd9Sstevel@tonic-gate 
2507c478bd9Sstevel@tonic-gate 	/*
2517c478bd9Sstevel@tonic-gate 	 * We only get here if we're a UPA slave only device whose interrupt
2527c478bd9Sstevel@tonic-gate 	 * mapping register has not been set.
2537c478bd9Sstevel@tonic-gate 	 * We need to try and install the nexus whose physical address
2547c478bd9Sstevel@tonic-gate 	 * space is where the slaves mapping register resides.  They
2557c478bd9Sstevel@tonic-gate 	 * should call set_intr_mapping_reg() in their xxattach() to register
2567c478bd9Sstevel@tonic-gate 	 * the mapping register with the system.
2577c478bd9Sstevel@tonic-gate 	 */
2587c478bd9Sstevel@tonic-gate 
2597c478bd9Sstevel@tonic-gate 	/*
2607c478bd9Sstevel@tonic-gate 	 * We don't know if a single- or multi-interrupt proxy is fielding
2617c478bd9Sstevel@tonic-gate 	 * our UPA slave interrupt, we must check both cases.
2627c478bd9Sstevel@tonic-gate 	 * Start out by assuming the multi-interrupt case.
2637c478bd9Sstevel@tonic-gate 	 * We assume that single- and multi- interrupters are not
2647c478bd9Sstevel@tonic-gate 	 * overlapping in UPA portid space.
2657c478bd9Sstevel@tonic-gate 	 */
2667c478bd9Sstevel@tonic-gate 
2677c478bd9Sstevel@tonic-gate 	affin_upaid = upaid | 3;
2687c478bd9Sstevel@tonic-gate 
2697c478bd9Sstevel@tonic-gate 	/*
2707c478bd9Sstevel@tonic-gate 	 * We start looking for the multi-interrupter affinity node.
2717c478bd9Sstevel@tonic-gate 	 * We know it's ONLY a child of the root node since the root
2727c478bd9Sstevel@tonic-gate 	 * node defines UPA space.
2737c478bd9Sstevel@tonic-gate 	 */
2747c478bd9Sstevel@tonic-gate 	for (affin_dip = ddi_get_child(ddi_root_node()); affin_dip;
2757c478bd9Sstevel@tonic-gate 	    affin_dip = ddi_get_next_sibling(affin_dip))
2767c478bd9Sstevel@tonic-gate 		if (ddi_prop_get_int(DDI_DEV_T_ANY, affin_dip,
2777c478bd9Sstevel@tonic-gate 		    DDI_PROP_DONTPASS, "upa-portid", -1) == affin_upaid)
2787c478bd9Sstevel@tonic-gate 			break;
2797c478bd9Sstevel@tonic-gate 
2807c478bd9Sstevel@tonic-gate 	if (affin_dip) {
2817c478bd9Sstevel@tonic-gate 		if (i_ddi_attach_node_hierarchy(affin_dip) == DDI_SUCCESS) {
2827c478bd9Sstevel@tonic-gate 			/* try again to get the mapping register. */
2837c478bd9Sstevel@tonic-gate 			addr = intr_map_reg[upaid];
2847c478bd9Sstevel@tonic-gate 		}
2857c478bd9Sstevel@tonic-gate 	}
2867c478bd9Sstevel@tonic-gate 
2877c478bd9Sstevel@tonic-gate 	/*
2887c478bd9Sstevel@tonic-gate 	 * If we still don't have a mapping register try single -interrupter
2897c478bd9Sstevel@tonic-gate 	 * case.
2907c478bd9Sstevel@tonic-gate 	 */
2917c478bd9Sstevel@tonic-gate 	if (addr == NULL) {
2927c478bd9Sstevel@tonic-gate 
2937c478bd9Sstevel@tonic-gate 		affin_upaid = upaid | 1;
2947c478bd9Sstevel@tonic-gate 
2957c478bd9Sstevel@tonic-gate 		for (affin_dip = ddi_get_child(ddi_root_node()); affin_dip;
2967c478bd9Sstevel@tonic-gate 		    affin_dip = ddi_get_next_sibling(affin_dip))
2977c478bd9Sstevel@tonic-gate 			if (ddi_prop_get_int(DDI_DEV_T_ANY, affin_dip,
2987c478bd9Sstevel@tonic-gate 			    DDI_PROP_DONTPASS, "upa-portid", -1) == affin_upaid)
2997c478bd9Sstevel@tonic-gate 				break;
3007c478bd9Sstevel@tonic-gate 
3017c478bd9Sstevel@tonic-gate 		if (affin_dip) {
3027c478bd9Sstevel@tonic-gate 			if (i_ddi_attach_node_hierarchy(affin_dip)
3037c478bd9Sstevel@tonic-gate 			    == DDI_SUCCESS) {
3047c478bd9Sstevel@tonic-gate 				/* try again to get the mapping register. */
3057c478bd9Sstevel@tonic-gate 				addr = intr_map_reg[upaid];
3067c478bd9Sstevel@tonic-gate 			}
3077c478bd9Sstevel@tonic-gate 		}
3087c478bd9Sstevel@tonic-gate 	}
3097c478bd9Sstevel@tonic-gate 	return (addr);
3107c478bd9Sstevel@tonic-gate }
3117c478bd9Sstevel@tonic-gate 
3127c478bd9Sstevel@tonic-gate 
3137c478bd9Sstevel@tonic-gate static struct upa_dma_pfns {
3147c478bd9Sstevel@tonic-gate 	pfn_t hipfn;
3157c478bd9Sstevel@tonic-gate 	pfn_t lopfn;
3167c478bd9Sstevel@tonic-gate } upa_dma_pfn_array[MAX_UPA];
3177c478bd9Sstevel@tonic-gate 
3187c478bd9Sstevel@tonic-gate static int upa_dma_pfn_ndx = 0;
3197c478bd9Sstevel@tonic-gate 
3207c478bd9Sstevel@tonic-gate /*
3217c478bd9Sstevel@tonic-gate  * Certain UPA busses cannot accept dma transactions from any other source
3227c478bd9Sstevel@tonic-gate  * except for memory due to livelock conditions in their hardware. (e.g. sbus
3237c478bd9Sstevel@tonic-gate  * and PCI). These routines allow devices or busses on the UPA to register
3247c478bd9Sstevel@tonic-gate  * a physical address block within it's own register space where DMA can be
3257c478bd9Sstevel@tonic-gate  * performed.  Currently, the FFB is the only such device which supports
3267c478bd9Sstevel@tonic-gate  * device DMA on the UPA.
3277c478bd9Sstevel@tonic-gate  */
3287c478bd9Sstevel@tonic-gate void
pf_set_dmacapable(pfn_t hipfn,pfn_t lopfn)3297c478bd9Sstevel@tonic-gate pf_set_dmacapable(pfn_t hipfn, pfn_t lopfn)
3307c478bd9Sstevel@tonic-gate {
3317c478bd9Sstevel@tonic-gate 	int i = upa_dma_pfn_ndx;
3327c478bd9Sstevel@tonic-gate 
3337c478bd9Sstevel@tonic-gate 	upa_dma_pfn_ndx++;
3347c478bd9Sstevel@tonic-gate 
3357c478bd9Sstevel@tonic-gate 	upa_dma_pfn_array[i].hipfn = hipfn;
3367c478bd9Sstevel@tonic-gate 	upa_dma_pfn_array[i].lopfn = lopfn;
3377c478bd9Sstevel@tonic-gate }
3387c478bd9Sstevel@tonic-gate 
3397c478bd9Sstevel@tonic-gate void
pf_unset_dmacapable(pfn_t pfn)3407c478bd9Sstevel@tonic-gate pf_unset_dmacapable(pfn_t pfn)
3417c478bd9Sstevel@tonic-gate {
3427c478bd9Sstevel@tonic-gate 	int i;
3437c478bd9Sstevel@tonic-gate 
3447c478bd9Sstevel@tonic-gate 	for (i = 0; i < upa_dma_pfn_ndx; i++) {
3457c478bd9Sstevel@tonic-gate 		if (pfn <= upa_dma_pfn_array[i].hipfn &&
3467c478bd9Sstevel@tonic-gate 		    pfn >= upa_dma_pfn_array[i].lopfn) {
3477c478bd9Sstevel@tonic-gate 			upa_dma_pfn_array[i].hipfn =
3487c478bd9Sstevel@tonic-gate 			    upa_dma_pfn_array[upa_dma_pfn_ndx - 1].hipfn;
3497c478bd9Sstevel@tonic-gate 			upa_dma_pfn_array[i].lopfn =
3507c478bd9Sstevel@tonic-gate 			    upa_dma_pfn_array[upa_dma_pfn_ndx - 1].lopfn;
3517c478bd9Sstevel@tonic-gate 			upa_dma_pfn_ndx--;
3527c478bd9Sstevel@tonic-gate 			break;
3537c478bd9Sstevel@tonic-gate 		}
3547c478bd9Sstevel@tonic-gate 	}
3557c478bd9Sstevel@tonic-gate }
3567c478bd9Sstevel@tonic-gate 
3577c478bd9Sstevel@tonic-gate /*
3587c478bd9Sstevel@tonic-gate  * This routine should only be called using a pfn that is known to reside
3597c478bd9Sstevel@tonic-gate  * in IO space.  The function pf_is_memory() can be used to determine this.
3607c478bd9Sstevel@tonic-gate  */
3617c478bd9Sstevel@tonic-gate int
pf_is_dmacapable(pfn_t pfn)3627c478bd9Sstevel@tonic-gate pf_is_dmacapable(pfn_t pfn)
3637c478bd9Sstevel@tonic-gate {
3647c478bd9Sstevel@tonic-gate 	int i, j;
3657c478bd9Sstevel@tonic-gate 
3667c478bd9Sstevel@tonic-gate 	/* If the caller passed in a memory pfn, return true. */
3677c478bd9Sstevel@tonic-gate 	if (pf_is_memory(pfn))
3687c478bd9Sstevel@tonic-gate 		return (1);
3697c478bd9Sstevel@tonic-gate 
3707c478bd9Sstevel@tonic-gate 	for (i = upa_dma_pfn_ndx, j = 0; j < i; j++)
3717c478bd9Sstevel@tonic-gate 		if (pfn <= upa_dma_pfn_array[j].hipfn &&
3727c478bd9Sstevel@tonic-gate 		    pfn >= upa_dma_pfn_array[j].lopfn)
3737c478bd9Sstevel@tonic-gate 			return (1);
3747c478bd9Sstevel@tonic-gate 
3757c478bd9Sstevel@tonic-gate 	return (0);
3767c478bd9Sstevel@tonic-gate }
3777c478bd9Sstevel@tonic-gate 
3787c478bd9Sstevel@tonic-gate 
3797c478bd9Sstevel@tonic-gate /*
3807c478bd9Sstevel@tonic-gate  * Find cpu_id corresponding to the dip of a CPU device node
3817c478bd9Sstevel@tonic-gate  */
3827c478bd9Sstevel@tonic-gate int
dip_to_cpu_id(dev_info_t * dip,processorid_t * cpu_id)3837c478bd9Sstevel@tonic-gate dip_to_cpu_id(dev_info_t *dip, processorid_t *cpu_id)
3847c478bd9Sstevel@tonic-gate {
385fa9e4066Sahrens 	pnode_t		nodeid;
3867c478bd9Sstevel@tonic-gate 	int		i;
3877c478bd9Sstevel@tonic-gate 
388fa9e4066Sahrens 	nodeid = (pnode_t)ddi_get_nodeid(dip);
3897c478bd9Sstevel@tonic-gate 	for (i = 0; i < NCPU; i++) {
3907c478bd9Sstevel@tonic-gate 		if (cpunodes[i].nodeid == nodeid) {
3917c478bd9Sstevel@tonic-gate 			*cpu_id = i;
3927c478bd9Sstevel@tonic-gate 			return (DDI_SUCCESS);
3937c478bd9Sstevel@tonic-gate 		}
3947c478bd9Sstevel@tonic-gate 	}
3957c478bd9Sstevel@tonic-gate 	return (DDI_FAILURE);
3967c478bd9Sstevel@tonic-gate }
397*fc256490SJason Beloro 
398*fc256490SJason Beloro /* ARGSUSED */
399*fc256490SJason Beloro void
translate_devid(dev_info_t * dip)400*fc256490SJason Beloro translate_devid(dev_info_t *dip)
401*fc256490SJason Beloro {
402*fc256490SJason Beloro }
403