xref: /illumos-gate/usr/src/uts/sun4u/os/fillsysinfo.c (revision 12551037)
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
525cf1a30Sjl  * Common Development and Distribution License (the "License").
625cf1a30Sjl  * 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  */
217c478bd9Sstevel@tonic-gate /*
2206fb6a36Sdv  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #include <sys/errno.h>
277c478bd9Sstevel@tonic-gate #include <sys/types.h>
287c478bd9Sstevel@tonic-gate #include <sys/param.h>
297c478bd9Sstevel@tonic-gate #include <sys/cpu.h>
307c478bd9Sstevel@tonic-gate #include <sys/cpuvar.h>
317c478bd9Sstevel@tonic-gate #include <sys/clock.h>
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #include <sys/promif.h>
347c478bd9Sstevel@tonic-gate #include <sys/promimpl.h>
357c478bd9Sstevel@tonic-gate #include <sys/systm.h>
367c478bd9Sstevel@tonic-gate #include <sys/machsystm.h>
377c478bd9Sstevel@tonic-gate #include <sys/debug.h>
387c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
397c478bd9Sstevel@tonic-gate #include <sys/modctl.h>
407c478bd9Sstevel@tonic-gate #include <sys/spitregs.h>
417c478bd9Sstevel@tonic-gate #include <sys/cheetahregs.h>
427c478bd9Sstevel@tonic-gate #include <sys/cpu_module.h>
437c478bd9Sstevel@tonic-gate #include <sys/kobj.h>
447c478bd9Sstevel@tonic-gate #include <sys/cmp.h>
457c478bd9Sstevel@tonic-gate #include <sys/async.h>
467c478bd9Sstevel@tonic-gate #include <vm/page.h>
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate /*
497c478bd9Sstevel@tonic-gate  * The OpenBoot Standalone Interface supplies the kernel with
507c478bd9Sstevel@tonic-gate  * implementation dependent parameters through the devinfo/property mechanism
517c478bd9Sstevel@tonic-gate  */
527c478bd9Sstevel@tonic-gate typedef enum { XDRBOOL, XDRINT, XDRSTRING } xdrs;
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate /*
557c478bd9Sstevel@tonic-gate  * structure describing properties that we are interested in querying the
567c478bd9Sstevel@tonic-gate  * OBP for.
577c478bd9Sstevel@tonic-gate  */
587c478bd9Sstevel@tonic-gate struct getprop_info {
597c478bd9Sstevel@tonic-gate 	char	*name;
607c478bd9Sstevel@tonic-gate 	xdrs	type;
617c478bd9Sstevel@tonic-gate 	uint_t	*var;
627c478bd9Sstevel@tonic-gate };
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate /*
657c478bd9Sstevel@tonic-gate  * structure used to convert between a string returned by the OBP & a type
667c478bd9Sstevel@tonic-gate  * used within the kernel. We prefer to paramaterize rather than type.
677c478bd9Sstevel@tonic-gate  */
687c478bd9Sstevel@tonic-gate struct convert_info {
697c478bd9Sstevel@tonic-gate 	char	*name;
707c478bd9Sstevel@tonic-gate 	uint_t	var;
717c478bd9Sstevel@tonic-gate 	char	*realname;
727c478bd9Sstevel@tonic-gate };
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate /*
757c478bd9Sstevel@tonic-gate  * structure describing nodes that we are interested in querying the OBP for
767c478bd9Sstevel@tonic-gate  * properties.
777c478bd9Sstevel@tonic-gate  */
787c478bd9Sstevel@tonic-gate struct node_info {
797c478bd9Sstevel@tonic-gate 	char			*name;
807c478bd9Sstevel@tonic-gate 	int			size;
817c478bd9Sstevel@tonic-gate 	struct getprop_info	*prop;
827c478bd9Sstevel@tonic-gate 	struct getprop_info	*prop_end;
837c478bd9Sstevel@tonic-gate 	unsigned int		*value;
847c478bd9Sstevel@tonic-gate };
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate /*
877c478bd9Sstevel@tonic-gate  * macro definitions for routines that form the OBP interface
887c478bd9Sstevel@tonic-gate  */
897c478bd9Sstevel@tonic-gate #define	NEXT			prom_nextnode
907c478bd9Sstevel@tonic-gate #define	CHILD			prom_childnode
917c478bd9Sstevel@tonic-gate #define	GETPROP			prom_getprop
927c478bd9Sstevel@tonic-gate #define	GETPROPLEN		prom_getproplen
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate /* 0=quiet; 1=verbose; 2=debug */
967c478bd9Sstevel@tonic-gate int	debug_fillsysinfo = 0;
977c478bd9Sstevel@tonic-gate #define	VPRINTF if (debug_fillsysinfo) prom_printf
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate int ncpunode;
1007c478bd9Sstevel@tonic-gate struct cpu_node cpunodes[NCPU];
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate static void	check_cpus_ver(void);
1037c478bd9Sstevel@tonic-gate static void	check_cpus_set(void);
1048682d1efSRichard Lowe static void fill_address(pnode_t, char *);
105fa9e4066Sahrens void	fill_cpu(pnode_t);
1067c478bd9Sstevel@tonic-gate void	fill_cpu_ddi(dev_info_t *);
1077c478bd9Sstevel@tonic-gate void	empty_cpu(int);
108fa9e4066Sahrens void	plat_fill_mc(pnode_t);
1097c478bd9Sstevel@tonic-gate #pragma weak plat_fill_mc
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate uint64_t	system_clock_freq;
1127c478bd9Sstevel@tonic-gate 
1137c478bd9Sstevel@tonic-gate /*
1147c478bd9Sstevel@tonic-gate  * list of well known devices that must be mapped, and the variables that
1157c478bd9Sstevel@tonic-gate  * contain their addresses.
1167c478bd9Sstevel@tonic-gate  */
1177c478bd9Sstevel@tonic-gate caddr_t		v_auxio_addr = NULL;
1187c478bd9Sstevel@tonic-gate caddr_t		v_eeprom_addr = NULL;
1197c478bd9Sstevel@tonic-gate caddr_t		v_timecheck_addr = NULL;
1204fe8b416SPeter Tribble caddr_t		v_rtc_addr_reg = NULL;
1217c478bd9Sstevel@tonic-gate volatile unsigned char	*v_rtc_data_reg = NULL;
1227c478bd9Sstevel@tonic-gate volatile uint8_t	*v_pmc_addr_reg = NULL;
1237c478bd9Sstevel@tonic-gate volatile uint8_t	*v_pmc_data_reg = NULL;
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate int		niobus = 0;
1267c478bd9Sstevel@tonic-gate uint_t		niommu_tsbs = 0;
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate /*
1297c478bd9Sstevel@tonic-gate  * Hardware watchdog support.
1307c478bd9Sstevel@tonic-gate  */
1317c478bd9Sstevel@tonic-gate #define	CHOSEN_EEPROM	"eeprom"
1327c478bd9Sstevel@tonic-gate #define	WATCHDOG_ENABLE "watchdog-enable"
1334fe8b416SPeter Tribble static pnode_t		chosen_eeprom;
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate /*
1367c478bd9Sstevel@tonic-gate  * Appropriate tod module will be dynamically selected while booting
1377c478bd9Sstevel@tonic-gate  * based on finding a device tree node with a "device_type" property value
1387c478bd9Sstevel@tonic-gate  * of "tod". If such a node describing tod is not found, for backward
1397c478bd9Sstevel@tonic-gate  * compatibility, a node with a "name" property value of "eeprom" and
1407c478bd9Sstevel@tonic-gate  * "model" property value of "mk48t59" will be used. Failing to find a
1417c478bd9Sstevel@tonic-gate  * node matching either of the above criteria will result in no tod module
1427c478bd9Sstevel@tonic-gate  * being selected; this will cause the boot process to halt.
1437c478bd9Sstevel@tonic-gate  */
1447c478bd9Sstevel@tonic-gate char	*tod_module_name;
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate /*
1477c478bd9Sstevel@tonic-gate  * If this variable is non-zero, cpr should return "not supported" when
1487c478bd9Sstevel@tonic-gate  * it is queried even though it would normally be supported on this platform.
1497c478bd9Sstevel@tonic-gate  */
1507c478bd9Sstevel@tonic-gate int cpr_supported_override;
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate /*
1537c478bd9Sstevel@tonic-gate  * Some platforms may need to support CPR even in the absence of the
1547c478bd9Sstevel@tonic-gate  * energystar-v* property (Enchilada server, for example).  If this
1557c478bd9Sstevel@tonic-gate  * variable is non-zero, cpr should proceed even in the absence
1567c478bd9Sstevel@tonic-gate  * of the energystar-v* property.
1577c478bd9Sstevel@tonic-gate  */
1587c478bd9Sstevel@tonic-gate int cpr_platform_enable = 0;
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate /*
1617c478bd9Sstevel@tonic-gate  * Some nodes have functions that need to be called when they're seen.
1627c478bd9Sstevel@tonic-gate  */
163fa9e4066Sahrens static void	have_sbus(pnode_t);
164fa9e4066Sahrens static void	have_pci(pnode_t);
165fa9e4066Sahrens static void	have_eeprom(pnode_t);
166fa9e4066Sahrens static void	have_auxio(pnode_t);
167fa9e4066Sahrens static void	have_rtc(pnode_t);
168fa9e4066Sahrens static void	have_tod(pnode_t);
169fa9e4066Sahrens static void	have_pmc(pnode_t);
1707c478bd9Sstevel@tonic-gate 
1717c478bd9Sstevel@tonic-gate static struct wkdevice {
1727c478bd9Sstevel@tonic-gate 	char *wk_namep;
173fa9e4066Sahrens 	void (*wk_func)(pnode_t);
1747c478bd9Sstevel@tonic-gate 	caddr_t *wk_vaddrp;
1757c478bd9Sstevel@tonic-gate 	ushort_t wk_flags;
1767c478bd9Sstevel@tonic-gate #define	V_OPTIONAL	0x0000
1777c478bd9Sstevel@tonic-gate #define	V_MUSTHAVE	0x0001
1787c478bd9Sstevel@tonic-gate #define	V_MAPPED	0x0002
1797c478bd9Sstevel@tonic-gate #define	V_MULTI		0x0003	/* optional, may be more than one */
1807c478bd9Sstevel@tonic-gate } wkdevice[] = {
1817c478bd9Sstevel@tonic-gate 	{ "sbus", have_sbus, NULL, V_MULTI },
1827c478bd9Sstevel@tonic-gate 	{ "pci", have_pci, NULL, V_MULTI },
1837c478bd9Sstevel@tonic-gate 	{ "eeprom", have_eeprom, NULL, V_MULTI },
1847c478bd9Sstevel@tonic-gate 	{ "auxio", have_auxio, NULL, V_OPTIONAL },
1857c478bd9Sstevel@tonic-gate 	{ "rtc", have_rtc, NULL, V_OPTIONAL },
1867c478bd9Sstevel@tonic-gate 	{ "pmc", have_pmc, NULL, V_OPTIONAL },
1877c478bd9Sstevel@tonic-gate 	{ 0, },
1887c478bd9Sstevel@tonic-gate };
1897c478bd9Sstevel@tonic-gate 
190fa9e4066Sahrens static void map_wellknown(pnode_t);
1917c478bd9Sstevel@tonic-gate 
1927c478bd9Sstevel@tonic-gate void
map_wellknown_devices()1937c478bd9Sstevel@tonic-gate map_wellknown_devices()
1947c478bd9Sstevel@tonic-gate {
1957c478bd9Sstevel@tonic-gate 	struct wkdevice *wkp;
1967c478bd9Sstevel@tonic-gate 	phandle_t	ieeprom;
197fa9e4066Sahrens 	pnode_t	root;
1987c478bd9Sstevel@tonic-gate 	uint_t	stick_freq;
1997c478bd9Sstevel@tonic-gate 
2007c478bd9Sstevel@tonic-gate 	/*
2017c478bd9Sstevel@tonic-gate 	 * if there is a chosen eeprom, note it (for have_eeprom())
2027c478bd9Sstevel@tonic-gate 	 */
2037c478bd9Sstevel@tonic-gate 	if (GETPROPLEN(prom_chosennode(), CHOSEN_EEPROM) ==
2047c478bd9Sstevel@tonic-gate 	    sizeof (phandle_t) &&
2057c478bd9Sstevel@tonic-gate 	    GETPROP(prom_chosennode(), CHOSEN_EEPROM, (caddr_t)&ieeprom) != -1)
206fa9e4066Sahrens 		chosen_eeprom = (pnode_t)prom_decode_int(ieeprom);
2077c478bd9Sstevel@tonic-gate 
208fa9e4066Sahrens 	root = prom_nextnode((pnode_t)0);
2097c478bd9Sstevel@tonic-gate 	/*
2107c478bd9Sstevel@tonic-gate 	 * Get System clock frequency from root node if it exists.
2117c478bd9Sstevel@tonic-gate 	 */
2127c478bd9Sstevel@tonic-gate 	if (GETPROP(root, "stick-frequency", (caddr_t)&stick_freq) != -1)
2137c478bd9Sstevel@tonic-gate 		system_clock_freq = stick_freq;
2147c478bd9Sstevel@tonic-gate 
215fa9e4066Sahrens 	map_wellknown(NEXT((pnode_t)0));
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate 	/*
2187c478bd9Sstevel@tonic-gate 	 * See if it worked
2197c478bd9Sstevel@tonic-gate 	 */
2207c478bd9Sstevel@tonic-gate 	for (wkp = wkdevice; wkp->wk_namep; ++wkp) {
2217c478bd9Sstevel@tonic-gate 		if (wkp->wk_flags == V_MUSTHAVE) {
2227c478bd9Sstevel@tonic-gate 			cmn_err(CE_PANIC, "map_wellknown_devices: required "
2237c478bd9Sstevel@tonic-gate 			    "device %s not mapped", wkp->wk_namep);
2247c478bd9Sstevel@tonic-gate 		}
2257c478bd9Sstevel@tonic-gate 	}
2267c478bd9Sstevel@tonic-gate 
2277c478bd9Sstevel@tonic-gate 	/*
2287c478bd9Sstevel@tonic-gate 	 * all sun4u systems must have an IO bus, i.e. sbus or pcibus
2297c478bd9Sstevel@tonic-gate 	 */
2307c478bd9Sstevel@tonic-gate 	if (niobus == 0)
2317c478bd9Sstevel@tonic-gate 		cmn_err(CE_PANIC, "map_wellknown_devices: no i/o bus node");
2327c478bd9Sstevel@tonic-gate 
2337c478bd9Sstevel@tonic-gate 	check_cpus_ver();
2347c478bd9Sstevel@tonic-gate 	check_cpus_set();
2357c478bd9Sstevel@tonic-gate }
2367c478bd9Sstevel@tonic-gate 
2377c478bd9Sstevel@tonic-gate /*
2387c478bd9Sstevel@tonic-gate  * map_wellknown - map known devices & registers
2397c478bd9Sstevel@tonic-gate  */
2407c478bd9Sstevel@tonic-gate static void
map_wellknown(pnode_t curnode)241fa9e4066Sahrens map_wellknown(pnode_t curnode)
2427c478bd9Sstevel@tonic-gate {
2437c478bd9Sstevel@tonic-gate 	extern int status_okay(int, char *, int);
2447c478bd9Sstevel@tonic-gate 	char tmp_name[MAXSYSNAME];
2457c478bd9Sstevel@tonic-gate 	int sok;
2467c478bd9Sstevel@tonic-gate 
2477c478bd9Sstevel@tonic-gate #ifdef VPRINTF
2487c478bd9Sstevel@tonic-gate 	VPRINTF("map_wellknown(%x)\n", curnode);
2497c478bd9Sstevel@tonic-gate #endif /* VPRINTF */
2507c478bd9Sstevel@tonic-gate 
2517c478bd9Sstevel@tonic-gate 	for (curnode = CHILD(curnode); curnode; curnode = NEXT(curnode)) {
2527c478bd9Sstevel@tonic-gate 		/*
2537c478bd9Sstevel@tonic-gate 		 * prune subtree if status property indicating not okay
2547c478bd9Sstevel@tonic-gate 		 */
2557c478bd9Sstevel@tonic-gate 		sok = status_okay((int)curnode, (char *)NULL, 0);
2567c478bd9Sstevel@tonic-gate 		if (!sok) {
2577c478bd9Sstevel@tonic-gate 			char devtype_buf[OBP_MAXPROPNAME];
2587c478bd9Sstevel@tonic-gate 			int size;
2597c478bd9Sstevel@tonic-gate 
2607c478bd9Sstevel@tonic-gate #ifdef VPRINTF
2617c478bd9Sstevel@tonic-gate 			VPRINTF("map_wellknown: !okay status property\n");
2627c478bd9Sstevel@tonic-gate #endif /* VPRINTF */
2637c478bd9Sstevel@tonic-gate 			/*
2647c478bd9Sstevel@tonic-gate 			 * a status property indicating bad memory will be
2657c478bd9Sstevel@tonic-gate 			 * associated with a node which has a "device_type"
2667c478bd9Sstevel@tonic-gate 			 * property with a value of "memory-controller"
2677c478bd9Sstevel@tonic-gate 			 */
2687c478bd9Sstevel@tonic-gate 			if ((size = GETPROPLEN(curnode,
2697c478bd9Sstevel@tonic-gate 			    OBP_DEVICETYPE)) == -1)
2707c478bd9Sstevel@tonic-gate 				continue;
2717c478bd9Sstevel@tonic-gate 			if (size > OBP_MAXPROPNAME) {
2727c478bd9Sstevel@tonic-gate 				cmn_err(CE_CONT, "node %x '%s' prop too "
2737c478bd9Sstevel@tonic-gate 				    "big\n", curnode, OBP_DEVICETYPE);
2747c478bd9Sstevel@tonic-gate 				continue;
2757c478bd9Sstevel@tonic-gate 			}
2767c478bd9Sstevel@tonic-gate 			if (GETPROP(curnode, OBP_DEVICETYPE,
2777c478bd9Sstevel@tonic-gate 			    devtype_buf) == -1) {
2787c478bd9Sstevel@tonic-gate 				cmn_err(CE_CONT, "node %x '%s' get failed\n",
2797c478bd9Sstevel@tonic-gate 				    curnode, OBP_DEVICETYPE);
2807c478bd9Sstevel@tonic-gate 				continue;
2817c478bd9Sstevel@tonic-gate 			}
2827c478bd9Sstevel@tonic-gate 			if (strcmp(devtype_buf, "memory-controller") != 0)
2837c478bd9Sstevel@tonic-gate 				continue;
2847c478bd9Sstevel@tonic-gate 			/*
2857c478bd9Sstevel@tonic-gate 			 * ...else fall thru and process the node...
2867c478bd9Sstevel@tonic-gate 			 */
2877c478bd9Sstevel@tonic-gate 		}
2887c478bd9Sstevel@tonic-gate 		bzero(tmp_name, MAXSYSNAME);
2897c478bd9Sstevel@tonic-gate 		if (GETPROP(curnode, OBP_NAME, (caddr_t)tmp_name) != -1)
2907c478bd9Sstevel@tonic-gate 			fill_address(curnode, tmp_name);
2917c478bd9Sstevel@tonic-gate 		if (GETPROP(curnode, OBP_DEVICETYPE, tmp_name) != -1 &&
2927c478bd9Sstevel@tonic-gate 		    strcmp(tmp_name, "cpu") == 0) {
2937c478bd9Sstevel@tonic-gate 			fill_cpu(curnode);
2947c478bd9Sstevel@tonic-gate 		}
2957c478bd9Sstevel@tonic-gate 		if (strcmp(tmp_name, "tod") == 0)
2967c478bd9Sstevel@tonic-gate 			have_tod(curnode);
2977c478bd9Sstevel@tonic-gate 		if (sok && (strcmp(tmp_name, "memory-controller") == 0) &&
2987c478bd9Sstevel@tonic-gate 		    (&plat_fill_mc != NULL))
2997c478bd9Sstevel@tonic-gate 			plat_fill_mc(curnode);
3007c478bd9Sstevel@tonic-gate 		map_wellknown(curnode);
3017c478bd9Sstevel@tonic-gate 	}
3027c478bd9Sstevel@tonic-gate }
3037c478bd9Sstevel@tonic-gate 
3047c478bd9Sstevel@tonic-gate static void
fill_address(pnode_t curnode,char * namep)305fa9e4066Sahrens fill_address(pnode_t curnode, char *namep)
3067c478bd9Sstevel@tonic-gate {
3077c478bd9Sstevel@tonic-gate 	struct wkdevice *wkp;
3087c478bd9Sstevel@tonic-gate 	int size;
3097c478bd9Sstevel@tonic-gate 	uint32_t vaddr;
3107c478bd9Sstevel@tonic-gate 
3117c478bd9Sstevel@tonic-gate 	for (wkp = wkdevice; wkp->wk_namep; ++wkp) {
3127c478bd9Sstevel@tonic-gate 		if (strcmp(wkp->wk_namep, namep) != 0)
3137c478bd9Sstevel@tonic-gate 			continue;
3147c478bd9Sstevel@tonic-gate 		if (wkp->wk_flags == V_MAPPED)
3157c478bd9Sstevel@tonic-gate 			return;
3167c478bd9Sstevel@tonic-gate 		if (wkp->wk_vaddrp != NULL) {
3177c478bd9Sstevel@tonic-gate 			if ((size = GETPROPLEN(curnode, OBP_ADDRESS)) == -1) {
3187c478bd9Sstevel@tonic-gate 				cmn_err(CE_CONT, "device %s size %d\n",
3197c478bd9Sstevel@tonic-gate 				    namep, size);
3207c478bd9Sstevel@tonic-gate 				continue;
3217c478bd9Sstevel@tonic-gate 			}
3227c478bd9Sstevel@tonic-gate 			if (size != sizeof (vaddr)) {
3237c478bd9Sstevel@tonic-gate 				cmn_err(CE_CONT, "device %s address prop too "
3247c478bd9Sstevel@tonic-gate 				    "big\n", namep);
3257c478bd9Sstevel@tonic-gate 				continue;
3267c478bd9Sstevel@tonic-gate 			}
3277c478bd9Sstevel@tonic-gate 			if (GETPROP(curnode, OBP_ADDRESS,
3287c478bd9Sstevel@tonic-gate 			    (caddr_t)&vaddr) == -1) {
3297c478bd9Sstevel@tonic-gate 				cmn_err(CE_CONT, "device %s not mapped\n",
3307c478bd9Sstevel@tonic-gate 				    namep);
3317c478bd9Sstevel@tonic-gate 				continue;
3327c478bd9Sstevel@tonic-gate 			}
3337c478bd9Sstevel@tonic-gate 
3347c478bd9Sstevel@tonic-gate 			/* make into a native pointer */
335f166393fSesolom 			*wkp->wk_vaddrp = (caddr_t)(uintptr_t)vaddr;
3367c478bd9Sstevel@tonic-gate #ifdef VPRINTF
337f166393fSesolom 			VPRINTF("fill_address: %s mapped to %p\n", namep,
338903a11ebSrh 			    (void *)*wkp->wk_vaddrp);
3397c478bd9Sstevel@tonic-gate #endif /* VPRINTF */
3407c478bd9Sstevel@tonic-gate 		}
3417c478bd9Sstevel@tonic-gate 		if (wkp->wk_func != NULL)
3427c478bd9Sstevel@tonic-gate 			(*wkp->wk_func)(curnode);
3437c478bd9Sstevel@tonic-gate 		/*
3447c478bd9Sstevel@tonic-gate 		 * If this one is optional and there may be more than
3457c478bd9Sstevel@tonic-gate 		 * one, don't set V_MAPPED, which would cause us to skip it
3467c478bd9Sstevel@tonic-gate 		 * next time around
3477c478bd9Sstevel@tonic-gate 		 */
3487c478bd9Sstevel@tonic-gate 		if (wkp->wk_flags != V_MULTI)
3497c478bd9Sstevel@tonic-gate 			wkp->wk_flags = V_MAPPED;
3507c478bd9Sstevel@tonic-gate 	}
3517c478bd9Sstevel@tonic-gate }
3527c478bd9Sstevel@tonic-gate 
3537c478bd9Sstevel@tonic-gate int
get_portid(pnode_t node,pnode_t * cmpp)354fa9e4066Sahrens get_portid(pnode_t node, pnode_t *cmpp)
3557c478bd9Sstevel@tonic-gate {
3567c478bd9Sstevel@tonic-gate 	int portid;
35725cf1a30Sjl 	int i;
3587c478bd9Sstevel@tonic-gate 	char dev_type[OBP_MAXPROPNAME];
35925cf1a30Sjl 	pnode_t cpu_parent;
3607c478bd9Sstevel@tonic-gate 
3617c478bd9Sstevel@tonic-gate 	if (cmpp != NULL)
3627c478bd9Sstevel@tonic-gate 		*cmpp = OBP_NONODE;
3637c478bd9Sstevel@tonic-gate 
3647c478bd9Sstevel@tonic-gate 	if (GETPROP(node, "portid", (caddr_t)&portid) != -1)
3657c478bd9Sstevel@tonic-gate 		return (portid);
3667c478bd9Sstevel@tonic-gate 	if (GETPROP(node, "upa-portid", (caddr_t)&portid) != -1)
3677c478bd9Sstevel@tonic-gate 		return (portid);
3687c478bd9Sstevel@tonic-gate 	if (GETPROP(node, "device_type", (caddr_t)&dev_type) == -1)
3697c478bd9Sstevel@tonic-gate 		return (-1);
3707c478bd9Sstevel@tonic-gate 
37125cf1a30Sjl 	/*
37225cf1a30Sjl 	 * For a virtual cpu node that is a CMP core, the "portid"
37325cf1a30Sjl 	 * is in the parent node.
37425cf1a30Sjl 	 * For a virtual cpu node that is a CMT strand, the "portid" is
37525cf1a30Sjl 	 * in its grandparent node.
37625cf1a30Sjl 	 * So we iterate up as far as 2 levels to get the "portid".
37725cf1a30Sjl 	 */
3787c478bd9Sstevel@tonic-gate 	if (strcmp(dev_type, "cpu") == 0) {
37925cf1a30Sjl 		cpu_parent = node = prom_parentnode(node);
38025cf1a30Sjl 		for (i = 0; i < 2; i++) {
38125cf1a30Sjl 			if (node == OBP_NONODE || node == OBP_BADNODE)
38225cf1a30Sjl 				break;
38325cf1a30Sjl 			if (GETPROP(node, "portid", (caddr_t)&portid) != -1) {
38425cf1a30Sjl 				if (cmpp != NULL)
38525cf1a30Sjl 					*cmpp = cpu_parent;
38625cf1a30Sjl 				return (portid);
38725cf1a30Sjl 			}
38825cf1a30Sjl 			node = prom_parentnode(node);
3897c478bd9Sstevel@tonic-gate 		}
3907c478bd9Sstevel@tonic-gate 	}
3917c478bd9Sstevel@tonic-gate 
3927c478bd9Sstevel@tonic-gate 	return (-1);
3937c478bd9Sstevel@tonic-gate }
3947c478bd9Sstevel@tonic-gate 
3957c478bd9Sstevel@tonic-gate /*
3967c478bd9Sstevel@tonic-gate  * Adjust page coloring variables based on the physical ecache setsize of
3977c478bd9Sstevel@tonic-gate  * the configured cpus:
3987c478bd9Sstevel@tonic-gate  *
3997c478bd9Sstevel@tonic-gate  * Set ecache_setsize to max ecache set size to be used by
4007c478bd9Sstevel@tonic-gate  * page_coloring_init() to determine the page colors to configure.
4017c478bd9Sstevel@tonic-gate  * The adjustment is unlikely to be necessary... For cheetah+ systems,
4027c478bd9Sstevel@tonic-gate  * ecache_setsize should already be set in cpu_fiximp() to the maximum
4037c478bd9Sstevel@tonic-gate  * possible ecache setsize of any supported cheetah+ cpus. The adjustment
4047c478bd9Sstevel@tonic-gate  * is for the off chance that a non-cheetah+ system may have heterogenous
4057c478bd9Sstevel@tonic-gate  * cpus.
4067c478bd9Sstevel@tonic-gate  *
4077c478bd9Sstevel@tonic-gate  * Set cpu_setsize to the actual cpu setsize if the setsize is homogenous
4087c478bd9Sstevel@tonic-gate  * across all cpus otherwise set it to -1 if heterogenous.
4097c478bd9Sstevel@tonic-gate  *
4107c478bd9Sstevel@tonic-gate  * Set cpu_page_colors to -1 to signify heterogeneity of ecache setsizes
4117c478bd9Sstevel@tonic-gate  * to the page_get routines.
4127c478bd9Sstevel@tonic-gate  */
4137c478bd9Sstevel@tonic-gate static void
adj_ecache_setsize(int ecsetsize)4147c478bd9Sstevel@tonic-gate adj_ecache_setsize(int ecsetsize)
4157c478bd9Sstevel@tonic-gate {
4167c478bd9Sstevel@tonic-gate 	if (ecsetsize > ecache_setsize)
4177c478bd9Sstevel@tonic-gate 		ecache_setsize = ecsetsize;
4187c478bd9Sstevel@tonic-gate 
4197c478bd9Sstevel@tonic-gate 	switch (cpu_setsize) {
4207c478bd9Sstevel@tonic-gate 	case -1:
4217c478bd9Sstevel@tonic-gate 		break;
4227c478bd9Sstevel@tonic-gate 	case 0:
4237c478bd9Sstevel@tonic-gate 		cpu_setsize = ecsetsize;
4247c478bd9Sstevel@tonic-gate 		break;
4257c478bd9Sstevel@tonic-gate 	default:
4267c478bd9Sstevel@tonic-gate 		/* set to -1 if hetergenous cpus */
4277c478bd9Sstevel@tonic-gate 		if (cpu_setsize != ecsetsize) {
4287c478bd9Sstevel@tonic-gate 			if (do_pg_coloring)
4297c478bd9Sstevel@tonic-gate 				cpu_page_colors = -1;
4307c478bd9Sstevel@tonic-gate 			/*
4317c478bd9Sstevel@tonic-gate 			 * if page coloring disabled, cpu_page_colors should
4327c478bd9Sstevel@tonic-gate 			 * remain 0 to prevent page coloring processing.
4337c478bd9Sstevel@tonic-gate 			 */
4347c478bd9Sstevel@tonic-gate 			cpu_setsize = -1;
4357c478bd9Sstevel@tonic-gate 		}
4367c478bd9Sstevel@tonic-gate 		break;
4377c478bd9Sstevel@tonic-gate 	}
4387c478bd9Sstevel@tonic-gate }
4397c478bd9Sstevel@tonic-gate 
4407c478bd9Sstevel@tonic-gate void
fill_cpu(pnode_t node)441fa9e4066Sahrens fill_cpu(pnode_t node)
4427c478bd9Sstevel@tonic-gate {
4437c478bd9Sstevel@tonic-gate 	extern int cpu_get_cpu_unum(int, char *, int, int *);
4447c478bd9Sstevel@tonic-gate 	struct cpu_node *cpunode;
4457c478bd9Sstevel@tonic-gate 	processorid_t cpuid;
4467c478bd9Sstevel@tonic-gate 	int portid;
4477c478bd9Sstevel@tonic-gate 	int tlbsize;
4487c478bd9Sstevel@tonic-gate 	int size;
4497c478bd9Sstevel@tonic-gate 	uint_t clk_freq;
450fa9e4066Sahrens 	pnode_t cmpnode;
4517c478bd9Sstevel@tonic-gate 	char namebuf[OBP_MAXPROPNAME], unum[UNUM_NAMLEN];
4527c478bd9Sstevel@tonic-gate 	char *namebufp;
4539703af20Swh 	int proplen;
4547c478bd9Sstevel@tonic-gate 
4557c478bd9Sstevel@tonic-gate 	if ((portid = get_portid(node, &cmpnode)) == -1) {
4567c478bd9Sstevel@tonic-gate 		cmn_err(CE_PANIC, "portid not found");
4577c478bd9Sstevel@tonic-gate 	}
4587c478bd9Sstevel@tonic-gate 
4597c478bd9Sstevel@tonic-gate 	if (GETPROP(node, "cpuid", (caddr_t)&cpuid) == -1) {
4607c478bd9Sstevel@tonic-gate 		cpuid = portid;
4617c478bd9Sstevel@tonic-gate 	}
4627c478bd9Sstevel@tonic-gate 
4637c478bd9Sstevel@tonic-gate 	if (cpuid < 0 || cpuid >= NCPU) {
464e98fafb9Sjl 		cmn_err(CE_PANIC, "cpu node %x: cpuid %d out of range", node,
465e98fafb9Sjl 		    cpuid);
4667c478bd9Sstevel@tonic-gate 		return;
4677c478bd9Sstevel@tonic-gate 	}
4687c478bd9Sstevel@tonic-gate 
4697c478bd9Sstevel@tonic-gate 	cpunode = &cpunodes[cpuid];
4707c478bd9Sstevel@tonic-gate 	cpunode->portid = portid;
47125cf1a30Sjl 	cpunode->nodeid = node;
4727c478bd9Sstevel@tonic-gate 
4737c478bd9Sstevel@tonic-gate 	if (cpu_get_cpu_unum(cpuid, unum, UNUM_NAMLEN, &size) != 0) {
4747c478bd9Sstevel@tonic-gate 		cpunode->fru_fmri[0] = '\0';
4757c478bd9Sstevel@tonic-gate 	} else {
4767c478bd9Sstevel@tonic-gate 		(void) snprintf(cpunode->fru_fmri, sizeof (cpunode->fru_fmri),
4777c478bd9Sstevel@tonic-gate 		    "%s%s", CPU_FRU_FMRI, unum);
4787c478bd9Sstevel@tonic-gate 	}
4797c478bd9Sstevel@tonic-gate 
48025cf1a30Sjl 	if (cmpnode) {
48125cf1a30Sjl 		/*
48225cf1a30Sjl 		 * For the CMT case, the parent "core" node contains
48325cf1a30Sjl 		 * properties needed below, use it instead of the
48425cf1a30Sjl 		 * cpu node.
48525cf1a30Sjl 		 */
48625cf1a30Sjl 		if ((GETPROP(cmpnode, "device_type", namebuf) > 0) &&
48725cf1a30Sjl 		    (strcmp(namebuf, "core") == 0)) {
48825cf1a30Sjl 			node = cmpnode;
48925cf1a30Sjl 		}
49025cf1a30Sjl 	}
49125cf1a30Sjl 
4927c478bd9Sstevel@tonic-gate 	(void) GETPROP(node, (cmpnode ? "compatible" : "name"), namebuf);
4939703af20Swh 
4949703af20Swh 	/* Make sure CPU name is within boundary and NULL terminated */
4959703af20Swh 	proplen = GETPROPLEN(node, (cmpnode ? "compatible" : "name"));
4969703af20Swh 	ASSERT(proplen > 0 && proplen <= OBP_MAXPROPNAME);
4979703af20Swh 
4989703af20Swh 	if (proplen >= OBP_MAXPROPNAME)
4999703af20Swh 		proplen = OBP_MAXPROPNAME - 1;
5009703af20Swh 
5019703af20Swh 	namebuf[proplen] = '\0';
5029703af20Swh 
5037c478bd9Sstevel@tonic-gate 	namebufp = namebuf;
5047c478bd9Sstevel@tonic-gate 	if (strncmp(namebufp, "SUNW,", 5) == 0)
5057c478bd9Sstevel@tonic-gate 		namebufp += 5;
50625cf1a30Sjl 	else if (strncmp(namebufp, "FJSV,", 5) == 0)
50725cf1a30Sjl 		namebufp += 5;
5087c478bd9Sstevel@tonic-gate 	(void) strcpy(cpunode->name, namebufp);
5097c478bd9Sstevel@tonic-gate 
5107c478bd9Sstevel@tonic-gate 	(void) GETPROP(node, "implementation#",
5117c478bd9Sstevel@tonic-gate 	    (caddr_t)&cpunode->implementation);
5127c478bd9Sstevel@tonic-gate 	(void) GETPROP(node, "mask#", (caddr_t)&cpunode->version);
5137c478bd9Sstevel@tonic-gate 
5147c478bd9Sstevel@tonic-gate 	if (IS_CHEETAH(cpunode->implementation)) {
5157c478bd9Sstevel@tonic-gate 		/* remap mask reg */
5167c478bd9Sstevel@tonic-gate 		cpunode->version = REMAP_CHEETAH_MASK(cpunode->version);
5177c478bd9Sstevel@tonic-gate 	}
5187c478bd9Sstevel@tonic-gate 	if (GETPROP(node, "clock-frequency", (caddr_t)&clk_freq) == -1) {
5197c478bd9Sstevel@tonic-gate 		/*
5207c478bd9Sstevel@tonic-gate 		 * If we didn't find it in the CPU node, look in the root node.
5217c478bd9Sstevel@tonic-gate 		 */
522fa9e4066Sahrens 		pnode_t root = prom_nextnode((pnode_t)0);
5237c478bd9Sstevel@tonic-gate 		if (GETPROP(root, "clock-frequency", (caddr_t)&clk_freq) == -1)
5247c478bd9Sstevel@tonic-gate 			clk_freq = 0;
5257c478bd9Sstevel@tonic-gate 	}
5267c478bd9Sstevel@tonic-gate 	cpunode->clock_freq = clk_freq;
5277c478bd9Sstevel@tonic-gate 
5287c478bd9Sstevel@tonic-gate 	ASSERT(cpunode->clock_freq != 0);
5297c478bd9Sstevel@tonic-gate 	/*
5307c478bd9Sstevel@tonic-gate 	 * Compute scaling factor based on rate of %tick. This is used
5317c478bd9Sstevel@tonic-gate 	 * to convert from ticks derived from %tick to nanoseconds. See
5327c478bd9Sstevel@tonic-gate 	 * comment in sun4u/sys/clock.h for details.
5337c478bd9Sstevel@tonic-gate 	 */
5347c478bd9Sstevel@tonic-gate 	cpunode->tick_nsec_scale = (uint_t)(((uint64_t)NANOSEC <<
5357c478bd9Sstevel@tonic-gate 	    (32 - TICK_NSEC_SHIFT)) / cpunode->clock_freq);
5367c478bd9Sstevel@tonic-gate 
5377c478bd9Sstevel@tonic-gate 	(void) GETPROP(node, "#itlb-entries", (caddr_t)&tlbsize);
5387c478bd9Sstevel@tonic-gate 	ASSERT(tlbsize < USHRT_MAX); /* since we cast it */
5397c478bd9Sstevel@tonic-gate 	cpunode->itlb_size = (ushort_t)tlbsize;
5407c478bd9Sstevel@tonic-gate 
5417c478bd9Sstevel@tonic-gate 	(void) GETPROP(node, "#dtlb-entries", (caddr_t)&tlbsize);
5427c478bd9Sstevel@tonic-gate 	ASSERT(tlbsize < USHRT_MAX); /* since we cast it */
5437c478bd9Sstevel@tonic-gate 	cpunode->dtlb_size = (ushort_t)tlbsize;
5447c478bd9Sstevel@tonic-gate 
5457c478bd9Sstevel@tonic-gate 	if (cmpnode != OBP_NONODE) {
5467c478bd9Sstevel@tonic-gate 		/*
5477c478bd9Sstevel@tonic-gate 		 * If the CPU has a level 3 cache, then it will be the
5487c478bd9Sstevel@tonic-gate 		 * external cache. Otherwise the level 2 cache is the
5497c478bd9Sstevel@tonic-gate 		 * external cache.
5507c478bd9Sstevel@tonic-gate 		 */
5517c478bd9Sstevel@tonic-gate 		size = 0;
5527c478bd9Sstevel@tonic-gate 		(void) GETPROP(node, "l3-cache-size", (caddr_t)&size);
5537c478bd9Sstevel@tonic-gate 		if (size <= 0)
5547c478bd9Sstevel@tonic-gate 			(void) GETPROP(node, "l2-cache-size", (caddr_t)&size);
5557c478bd9Sstevel@tonic-gate 		ASSERT(size != 0);
5567c478bd9Sstevel@tonic-gate 		cpunode->ecache_size = size;
5577c478bd9Sstevel@tonic-gate 
5587c478bd9Sstevel@tonic-gate 		size = 0;
5597c478bd9Sstevel@tonic-gate 		(void) GETPROP(node, "l3-cache-line-size", (caddr_t)&size);
5607c478bd9Sstevel@tonic-gate 		if (size <= 0)
5617c478bd9Sstevel@tonic-gate 			(void) GETPROP(node, "l2-cache-line-size",
5627c478bd9Sstevel@tonic-gate 			    (caddr_t)&size);
5637c478bd9Sstevel@tonic-gate 		ASSERT(size != 0);
5647c478bd9Sstevel@tonic-gate 		cpunode->ecache_linesize = size;
5657c478bd9Sstevel@tonic-gate 
5667c478bd9Sstevel@tonic-gate 		size = 0;
5677c478bd9Sstevel@tonic-gate 		(void) GETPROP(node, "l2-cache-associativity", (caddr_t)&size);
5687c478bd9Sstevel@tonic-gate 		ASSERT(size != 0);
5697c478bd9Sstevel@tonic-gate 		cpunode->ecache_associativity = size;
5707c478bd9Sstevel@tonic-gate 
5717c478bd9Sstevel@tonic-gate 		cmp_add_cpu(portid, cpuid);
5727c478bd9Sstevel@tonic-gate 	} else {
5737c478bd9Sstevel@tonic-gate 		size = 0;
5747c478bd9Sstevel@tonic-gate 		(void) GETPROP(node, "ecache-size", (caddr_t)&size);
5757c478bd9Sstevel@tonic-gate 		ASSERT(size != 0);
5767c478bd9Sstevel@tonic-gate 		cpunode->ecache_size = size;
5777c478bd9Sstevel@tonic-gate 
5787c478bd9Sstevel@tonic-gate 		size = 0;
5797c478bd9Sstevel@tonic-gate 		(void) GETPROP(node, "ecache-line-size", (caddr_t)&size);
5807c478bd9Sstevel@tonic-gate 		ASSERT(size != 0);
5817c478bd9Sstevel@tonic-gate 		cpunode->ecache_linesize = size;
5827c478bd9Sstevel@tonic-gate 
5837c478bd9Sstevel@tonic-gate 		size = 0;
5847c478bd9Sstevel@tonic-gate 		(void) GETPROP(node, "ecache-associativity", (caddr_t)&size);
5857c478bd9Sstevel@tonic-gate 		ASSERT(size != 0);
5867c478bd9Sstevel@tonic-gate 		cpunode->ecache_associativity = size;
5877c478bd9Sstevel@tonic-gate 	}
5887c478bd9Sstevel@tonic-gate 
5897c478bd9Sstevel@tonic-gate 	/* by default set msram to non-mirrored one */
5907c478bd9Sstevel@tonic-gate 	cpunode->msram = ECACHE_CPU_NON_MIRROR;
5917c478bd9Sstevel@tonic-gate 
5927c478bd9Sstevel@tonic-gate 	if (GETPROPLEN(node, "msram") != -1) {
5937c478bd9Sstevel@tonic-gate 		cpunode->msram = ECACHE_CPU_MIRROR;
5947c478bd9Sstevel@tonic-gate 	}
5957c478bd9Sstevel@tonic-gate 
5967c478bd9Sstevel@tonic-gate 	if (GETPROPLEN(node, "msram-observed") != -1) {
5977c478bd9Sstevel@tonic-gate 		cpunode->msram = ECACHE_CPU_MIRROR;
5987c478bd9Sstevel@tonic-gate 	}
5997c478bd9Sstevel@tonic-gate 
6007c478bd9Sstevel@tonic-gate 	if (ncpunode == 0) {
6017c478bd9Sstevel@tonic-gate 		cpu_fiximp(node);
6027c478bd9Sstevel@tonic-gate 	}
6037c478bd9Sstevel@tonic-gate 
6047c478bd9Sstevel@tonic-gate 	cpunode->ecache_setsize =
6057c478bd9Sstevel@tonic-gate 	    cpunode->ecache_size / cpunode->ecache_associativity;
6067c478bd9Sstevel@tonic-gate 
6077c478bd9Sstevel@tonic-gate 	adj_ecache_setsize(cpunode->ecache_setsize);
6087c478bd9Sstevel@tonic-gate 
6097c478bd9Sstevel@tonic-gate 	ncpunode++;
6107c478bd9Sstevel@tonic-gate }
6117c478bd9Sstevel@tonic-gate 
6127c478bd9Sstevel@tonic-gate int
get_portid_ddi(dev_info_t * dip,dev_info_t ** cmpp)6137c478bd9Sstevel@tonic-gate get_portid_ddi(dev_info_t *dip, dev_info_t **cmpp)
6147c478bd9Sstevel@tonic-gate {
6157c478bd9Sstevel@tonic-gate 	int portid;
61625cf1a30Sjl 	int i;
6177c478bd9Sstevel@tonic-gate 	char dev_type[OBP_MAXPROPNAME];
6187c478bd9Sstevel@tonic-gate 	int len = OBP_MAXPROPNAME;
61925cf1a30Sjl 	dev_info_t *cpu_parent;
6207c478bd9Sstevel@tonic-gate 
6217c478bd9Sstevel@tonic-gate 	if (cmpp != NULL)
6227c478bd9Sstevel@tonic-gate 		*cmpp = NULL;
6237c478bd9Sstevel@tonic-gate 
6247c478bd9Sstevel@tonic-gate 	if ((portid = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
62525cf1a30Sjl 	    DDI_PROP_DONTPASS, "portid", -1)) != -1)
6267c478bd9Sstevel@tonic-gate 		return (portid);
6277c478bd9Sstevel@tonic-gate 	if ((portid = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
62825cf1a30Sjl 	    DDI_PROP_DONTPASS, "upa-portid", -1)) != -1)
6297c478bd9Sstevel@tonic-gate 		return (portid);
6307c478bd9Sstevel@tonic-gate 	if (ddi_prop_op(DDI_DEV_T_ANY, dip, PROP_LEN_AND_VAL_BUF,
63125cf1a30Sjl 	    DDI_PROP_DONTPASS, "device_type", (caddr_t)dev_type,
63225cf1a30Sjl 	    &len) != 0)
6337c478bd9Sstevel@tonic-gate 		return (-1);
6347c478bd9Sstevel@tonic-gate 
63525cf1a30Sjl 	/*
63625cf1a30Sjl 	 * For a virtual cpu node that is a CMP core, the "portid"
63725cf1a30Sjl 	 * is in the parent node.
63825cf1a30Sjl 	 * For a virtual cpu node that is a CMT strand, the "portid" is
63925cf1a30Sjl 	 * in its grandparent node.
64025cf1a30Sjl 	 * So we iterate up as far as 2 levels to get the "portid".
64125cf1a30Sjl 	 */
6427c478bd9Sstevel@tonic-gate 	if (strcmp(dev_type, "cpu") == 0) {
64325cf1a30Sjl 		cpu_parent = dip = ddi_get_parent(dip);
64425cf1a30Sjl 		for (i = 0; dip != NULL && i < 2; i++) {
64525cf1a30Sjl 			if ((portid = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
64625cf1a30Sjl 			    DDI_PROP_DONTPASS, "portid", -1)) != -1) {
64725cf1a30Sjl 				if (cmpp != NULL)
64825cf1a30Sjl 					*cmpp = cpu_parent;
64925cf1a30Sjl 				return (portid);
65025cf1a30Sjl 			}
65125cf1a30Sjl 			dip = ddi_get_parent(dip);
6527c478bd9Sstevel@tonic-gate 		}
6537c478bd9Sstevel@tonic-gate 	}
6547c478bd9Sstevel@tonic-gate 
6557c478bd9Sstevel@tonic-gate 	return (-1);
6567c478bd9Sstevel@tonic-gate }
6577c478bd9Sstevel@tonic-gate 
6587c478bd9Sstevel@tonic-gate /*
6597c478bd9Sstevel@tonic-gate  * A hotplug version of fill_cpu().  (Doesn't assume that there's a node
6607c478bd9Sstevel@tonic-gate  * in the PROM device tree for this CPU.)  We still need the PROM version
6617c478bd9Sstevel@tonic-gate  * since it is called very early in the boot cycle before (before
6627c478bd9Sstevel@tonic-gate  * setup_ddi()).  Sigh...someday this will all be cleaned up.
6637c478bd9Sstevel@tonic-gate  */
6647c478bd9Sstevel@tonic-gate void
fill_cpu_ddi(dev_info_t * dip)6657c478bd9Sstevel@tonic-gate fill_cpu_ddi(dev_info_t *dip)
6667c478bd9Sstevel@tonic-gate {
6677c478bd9Sstevel@tonic-gate 	extern int cpu_get_cpu_unum(int, char *, int, int *);
6687c478bd9Sstevel@tonic-gate 	struct cpu_node *cpunode;
6697c478bd9Sstevel@tonic-gate 	processorid_t cpuid;
6707c478bd9Sstevel@tonic-gate 	int portid;
67125cf1a30Sjl 	int len = OBP_MAXPROPNAME;
6727c478bd9Sstevel@tonic-gate 	int tlbsize;
6737c478bd9Sstevel@tonic-gate 	dev_info_t *cmpnode;
6747c478bd9Sstevel@tonic-gate 	char namebuf[OBP_MAXPROPNAME], unum[UNUM_NAMLEN];
6757c478bd9Sstevel@tonic-gate 	char *namebufp;
67625cf1a30Sjl 	char dev_type[OBP_MAXPROPNAME];
6777c478bd9Sstevel@tonic-gate 
6787c478bd9Sstevel@tonic-gate 	if ((portid = get_portid_ddi(dip, &cmpnode)) == -1) {
6797c478bd9Sstevel@tonic-gate 		cmn_err(CE_PANIC, "portid not found");
6807c478bd9Sstevel@tonic-gate 	}
6817c478bd9Sstevel@tonic-gate 
6827c478bd9Sstevel@tonic-gate 	if ((cpuid = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
6837c478bd9Sstevel@tonic-gate 	    DDI_PROP_DONTPASS, "cpuid", -1)) == -1) {
6847c478bd9Sstevel@tonic-gate 		cpuid = portid;
6857c478bd9Sstevel@tonic-gate 	}
6867c478bd9Sstevel@tonic-gate 
6877c478bd9Sstevel@tonic-gate 	if (cpuid < 0 || cpuid >= NCPU) {
6887c478bd9Sstevel@tonic-gate 		cmn_err(CE_PANIC, "cpu dip %p: cpuid %d out of range",
689e98fafb9Sjl 		    (void *)dip, cpuid);
6907c478bd9Sstevel@tonic-gate 		return;
6917c478bd9Sstevel@tonic-gate 	}
6927c478bd9Sstevel@tonic-gate 
6937c478bd9Sstevel@tonic-gate 	cpunode = &cpunodes[cpuid];
6947c478bd9Sstevel@tonic-gate 	cpunode->portid = portid;
69525cf1a30Sjl 	cpunode->nodeid = ddi_get_nodeid(dip);
69625cf1a30Sjl 
69725cf1a30Sjl 	if (cmpnode != NULL) {
69825cf1a30Sjl 		/*
69925cf1a30Sjl 		 * For the CMT case, the parent "core" node contains
70025cf1a30Sjl 		 * properties needed below, use it instead of the
70125cf1a30Sjl 		 * cpu node.
70225cf1a30Sjl 		 */
70325cf1a30Sjl 		if ((ddi_prop_op(DDI_DEV_T_ANY, cmpnode, PROP_LEN_AND_VAL_BUF,
70425cf1a30Sjl 		    DDI_PROP_DONTPASS, "device_type",
70525cf1a30Sjl 		    (caddr_t)dev_type, &len) == DDI_PROP_SUCCESS) &&
70625cf1a30Sjl 		    (strcmp(dev_type, "core") == 0))
70725cf1a30Sjl 			dip = cmpnode;
70825cf1a30Sjl 	}
7097c478bd9Sstevel@tonic-gate 
7107c478bd9Sstevel@tonic-gate 	if (cpu_get_cpu_unum(cpuid, unum, UNUM_NAMLEN, &len) != 0) {
7117c478bd9Sstevel@tonic-gate 		cpunode->fru_fmri[0] = '\0';
7127c478bd9Sstevel@tonic-gate 	} else {
7137c478bd9Sstevel@tonic-gate 		(void) snprintf(cpunode->fru_fmri, sizeof (cpunode->fru_fmri),
7147c478bd9Sstevel@tonic-gate 		    "%s%s", CPU_FRU_FMRI, unum);
7157c478bd9Sstevel@tonic-gate 	}
7167c478bd9Sstevel@tonic-gate 
7177c478bd9Sstevel@tonic-gate 	len = sizeof (namebuf);
7187c478bd9Sstevel@tonic-gate 	(void) ddi_prop_op(DDI_DEV_T_ANY, dip, PROP_LEN_AND_VAL_BUF,
7197c478bd9Sstevel@tonic-gate 	    DDI_PROP_DONTPASS, (cmpnode ? "compatible" : "name"),
7207c478bd9Sstevel@tonic-gate 	    (caddr_t)namebuf, &len);
7217c478bd9Sstevel@tonic-gate 
7227c478bd9Sstevel@tonic-gate 	namebufp = namebuf;
7237c478bd9Sstevel@tonic-gate 	if (strncmp(namebufp, "SUNW,", 5) == 0)
7247c478bd9Sstevel@tonic-gate 		namebufp += 5;
72525cf1a30Sjl 	else if (strncmp(namebufp, "FJSV,", 5) == 0)
72625cf1a30Sjl 		namebufp += 5;
7277c478bd9Sstevel@tonic-gate 	(void) strcpy(cpunode->name, namebufp);
7287c478bd9Sstevel@tonic-gate 
7297c478bd9Sstevel@tonic-gate 	cpunode->implementation = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
7307c478bd9Sstevel@tonic-gate 	    DDI_PROP_DONTPASS, "implementation#", 0);
7317c478bd9Sstevel@tonic-gate 
7327c478bd9Sstevel@tonic-gate 	cpunode->version = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
7337c478bd9Sstevel@tonic-gate 	    DDI_PROP_DONTPASS, "mask#", 0);
7347c478bd9Sstevel@tonic-gate 
7357c478bd9Sstevel@tonic-gate 	if (IS_CHEETAH(cpunode->implementation)) {
7367c478bd9Sstevel@tonic-gate 		/* remap mask reg */
7377c478bd9Sstevel@tonic-gate 		cpunode->version = REMAP_CHEETAH_MASK(cpunode->version);
7387c478bd9Sstevel@tonic-gate 	}
7397c478bd9Sstevel@tonic-gate 
74025cf1a30Sjl 	cpunode->clock_freq = (uint32_t)ddi_prop_get_int(DDI_DEV_T_ANY, dip,
7417c478bd9Sstevel@tonic-gate 	    DDI_PROP_DONTPASS, "clock-frequency", 0);
7427c478bd9Sstevel@tonic-gate 
7437c478bd9Sstevel@tonic-gate 	ASSERT(cpunode->clock_freq != 0);
7447c478bd9Sstevel@tonic-gate 	/*
7457c478bd9Sstevel@tonic-gate 	 * Compute scaling factor based on rate of %tick. This is used
7467c478bd9Sstevel@tonic-gate 	 * to convert from ticks derived from %tick to nanoseconds. See
7477c478bd9Sstevel@tonic-gate 	 * comment in sun4u/sys/clock.h for details.
7487c478bd9Sstevel@tonic-gate 	 */
7497c478bd9Sstevel@tonic-gate 	cpunode->tick_nsec_scale = (uint_t)(((uint64_t)NANOSEC <<
7507c478bd9Sstevel@tonic-gate 	    (32 - TICK_NSEC_SHIFT)) / cpunode->clock_freq);
7517c478bd9Sstevel@tonic-gate 
7527c478bd9Sstevel@tonic-gate 	tlbsize = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
7537c478bd9Sstevel@tonic-gate 	    DDI_PROP_DONTPASS, "#itlb-entries", 0);
7547c478bd9Sstevel@tonic-gate 	ASSERT(tlbsize < USHRT_MAX); /* since we cast it */
7557c478bd9Sstevel@tonic-gate 	cpunode->itlb_size = (ushort_t)tlbsize;
7567c478bd9Sstevel@tonic-gate 
7577c478bd9Sstevel@tonic-gate 	tlbsize = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
7587c478bd9Sstevel@tonic-gate 	    DDI_PROP_DONTPASS, "#dtlb-entries", 0);
7597c478bd9Sstevel@tonic-gate 	ASSERT(tlbsize < USHRT_MAX); /* since we cast it */
7607c478bd9Sstevel@tonic-gate 	cpunode->dtlb_size = (ushort_t)tlbsize;
7617c478bd9Sstevel@tonic-gate 
7627c478bd9Sstevel@tonic-gate 	if (cmpnode != NULL) {
7637c478bd9Sstevel@tonic-gate 		/*
7647c478bd9Sstevel@tonic-gate 		 * If the CPU has a level 3 cache, then that is it's
7657c478bd9Sstevel@tonic-gate 		 * external cache. Otherwise the external cache must
7667c478bd9Sstevel@tonic-gate 		 * be the level 2 cache.
7677c478bd9Sstevel@tonic-gate 		 */
7687c478bd9Sstevel@tonic-gate 		cpunode->ecache_size = ddi_prop_get_int(DDI_DEV_T_ANY,
7697c478bd9Sstevel@tonic-gate 		    dip, DDI_PROP_DONTPASS, "l3-cache-size", 0);
7707c478bd9Sstevel@tonic-gate 		if (cpunode->ecache_size == 0)
7717c478bd9Sstevel@tonic-gate 			cpunode->ecache_size = ddi_prop_get_int(DDI_DEV_T_ANY,
7727c478bd9Sstevel@tonic-gate 			    dip, DDI_PROP_DONTPASS, "l2-cache-size", 0);
7737c478bd9Sstevel@tonic-gate 		ASSERT(cpunode->ecache_size != 0);
7747c478bd9Sstevel@tonic-gate 
7757c478bd9Sstevel@tonic-gate 		cpunode->ecache_linesize = ddi_prop_get_int(DDI_DEV_T_ANY,
7767c478bd9Sstevel@tonic-gate 		    dip, DDI_PROP_DONTPASS, "l3-cache-line-size", 0);
7777c478bd9Sstevel@tonic-gate 		if (cpunode->ecache_linesize == 0)
7787c478bd9Sstevel@tonic-gate 			cpunode->ecache_linesize =
7797c478bd9Sstevel@tonic-gate 			    ddi_prop_get_int(DDI_DEV_T_ANY, dip,
7807c478bd9Sstevel@tonic-gate 			    DDI_PROP_DONTPASS, "l2-cache-line-size", 0);
7817c478bd9Sstevel@tonic-gate 		ASSERT(cpunode->ecache_linesize != 0);
7827c478bd9Sstevel@tonic-gate 
7837c478bd9Sstevel@tonic-gate 		cpunode->ecache_associativity = ddi_prop_get_int(DDI_DEV_T_ANY,
7847c478bd9Sstevel@tonic-gate 		    dip, DDI_PROP_DONTPASS, "l2-cache-associativity", 0);
7857c478bd9Sstevel@tonic-gate 		ASSERT(cpunode->ecache_associativity != 0);
7867c478bd9Sstevel@tonic-gate 
7877c478bd9Sstevel@tonic-gate 		cmp_add_cpu(portid, cpuid);
7887c478bd9Sstevel@tonic-gate 	} else {
7897c478bd9Sstevel@tonic-gate 		cpunode->ecache_size = ddi_prop_get_int(DDI_DEV_T_ANY,
7907c478bd9Sstevel@tonic-gate 		    dip, DDI_PROP_DONTPASS, "ecache-size", 0);
7917c478bd9Sstevel@tonic-gate 		ASSERT(cpunode->ecache_size != 0);
7927c478bd9Sstevel@tonic-gate 
7937c478bd9Sstevel@tonic-gate 		cpunode->ecache_linesize = ddi_prop_get_int(DDI_DEV_T_ANY,
7947c478bd9Sstevel@tonic-gate 		    dip, DDI_PROP_DONTPASS, "ecache-line-size", 0);
7957c478bd9Sstevel@tonic-gate 		ASSERT(cpunode->ecache_linesize != 0);
7967c478bd9Sstevel@tonic-gate 
7977c478bd9Sstevel@tonic-gate 		cpunode->ecache_associativity = ddi_prop_get_int(DDI_DEV_T_ANY,
7987c478bd9Sstevel@tonic-gate 		    dip, DDI_PROP_DONTPASS, "ecache-associativity", 0);
7997c478bd9Sstevel@tonic-gate 		ASSERT(cpunode->ecache_associativity != 0);
8007c478bd9Sstevel@tonic-gate 	}
8017c478bd9Sstevel@tonic-gate 
8027c478bd9Sstevel@tonic-gate 	/* by default set msram to non-mirrored one */
8037c478bd9Sstevel@tonic-gate 	cpunode->msram = ECACHE_CPU_NON_MIRROR;
8047c478bd9Sstevel@tonic-gate 
8057c478bd9Sstevel@tonic-gate 	if (ddi_prop_exists(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS, "msram")) {
806e98fafb9Sjl 		cpunode->msram = ECACHE_CPU_MIRROR;
8077c478bd9Sstevel@tonic-gate 	} else if (ddi_prop_exists(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS,
808e98fafb9Sjl 	    "msram-observed")) {
809e98fafb9Sjl 		cpunode->msram = ECACHE_CPU_MIRROR;
8107c478bd9Sstevel@tonic-gate 	}
8117c478bd9Sstevel@tonic-gate 
8127c478bd9Sstevel@tonic-gate 	ASSERT(ncpunode > 0);	/* fiximp not req'd */
8137c478bd9Sstevel@tonic-gate 
8147c478bd9Sstevel@tonic-gate 	cpunode->ecache_setsize =
8157c478bd9Sstevel@tonic-gate 	    cpunode->ecache_size / cpunode->ecache_associativity;
8167c478bd9Sstevel@tonic-gate 
8177c478bd9Sstevel@tonic-gate 	adj_ecache_setsize(cpunode->ecache_setsize);
8187c478bd9Sstevel@tonic-gate 
8197c478bd9Sstevel@tonic-gate 	ncpunode++;
8207c478bd9Sstevel@tonic-gate }
8217c478bd9Sstevel@tonic-gate 
8227c478bd9Sstevel@tonic-gate void
empty_cpu(int cpuid)8237c478bd9Sstevel@tonic-gate empty_cpu(int cpuid)
8247c478bd9Sstevel@tonic-gate {
8257c478bd9Sstevel@tonic-gate 	bzero(&cpunodes[cpuid], sizeof (struct cpu_node));
8267c478bd9Sstevel@tonic-gate 	ncpunode--;
8277c478bd9Sstevel@tonic-gate }
8287c478bd9Sstevel@tonic-gate 
8297c478bd9Sstevel@tonic-gate #ifdef SF_ERRATA_30 /* call causes fp-disabled */
8307c478bd9Sstevel@tonic-gate int spitfire_call_bug = 0;
8317c478bd9Sstevel@tonic-gate #endif
8327c478bd9Sstevel@tonic-gate #ifdef SF_V9_TABLE_28	/* fp over/underflow traps may cause wrong fsr.cexc */
8337c478bd9Sstevel@tonic-gate int spitfire_bb_fsr_bug = 0;
8347c478bd9Sstevel@tonic-gate #endif
8357c478bd9Sstevel@tonic-gate 
8367c478bd9Sstevel@tonic-gate #ifdef JALAPENO_ERRATA_85
8377c478bd9Sstevel@tonic-gate /*
8387c478bd9Sstevel@tonic-gate  * Set the values here assuming we're running 2.4 or later Jalapenos.  If
8397c478bd9Sstevel@tonic-gate  * not, they'll be reset below.  Either way, the default can be overridden
8407c478bd9Sstevel@tonic-gate  * when we read /etc/system later in boot.
8417c478bd9Sstevel@tonic-gate  */
8427c478bd9Sstevel@tonic-gate int jp_errata_85_allow_slow_scrub = 1;
8437c478bd9Sstevel@tonic-gate int jp_errata_85_enable = 0;
8447c478bd9Sstevel@tonic-gate #endif	/* JALAPENO_ERRATA_85 */
8457c478bd9Sstevel@tonic-gate 
8467c478bd9Sstevel@tonic-gate static void
check_cpus_ver(void)8477c478bd9Sstevel@tonic-gate check_cpus_ver(void)
8487c478bd9Sstevel@tonic-gate {
8497c478bd9Sstevel@tonic-gate 	int i;
8507c478bd9Sstevel@tonic-gate 	int impl, cpuid = getprocessorid();
8517c478bd9Sstevel@tonic-gate 	int min_supported_rev;
8527c478bd9Sstevel@tonic-gate 
8537c478bd9Sstevel@tonic-gate 	ASSERT(cpunodes[cpuid].nodeid != 0);
8547c478bd9Sstevel@tonic-gate 
8557c478bd9Sstevel@tonic-gate 	impl = cpunodes[cpuid].implementation;
8567c478bd9Sstevel@tonic-gate 	switch (impl) {
8577c478bd9Sstevel@tonic-gate 	default:
8587c478bd9Sstevel@tonic-gate 		min_supported_rev = 0;
8597c478bd9Sstevel@tonic-gate 		break;
8607c478bd9Sstevel@tonic-gate 	case SPITFIRE_IMPL:
8617c478bd9Sstevel@tonic-gate 		min_supported_rev = SPITFIRE_MINREV_SUPPORTED;
8627c478bd9Sstevel@tonic-gate 		break;
8637c478bd9Sstevel@tonic-gate 	case CHEETAH_IMPL:
8647c478bd9Sstevel@tonic-gate 		min_supported_rev = CHEETAH_MINREV_SUPPORTED;
8657c478bd9Sstevel@tonic-gate 		break;
8667c478bd9Sstevel@tonic-gate 	}
8677c478bd9Sstevel@tonic-gate 
8687c478bd9Sstevel@tonic-gate 	for (i = 0; i < NCPU; i++) {
8697c478bd9Sstevel@tonic-gate 		if (cpunodes[i].nodeid == 0)
8707c478bd9Sstevel@tonic-gate 			continue;
8717c478bd9Sstevel@tonic-gate 
8727c478bd9Sstevel@tonic-gate 		if (IS_SPITFIRE(impl)) {
8737c478bd9Sstevel@tonic-gate 			if (cpunodes[i].version < min_supported_rev) {
874e98fafb9Sjl 				cmn_err(CE_PANIC, "UltraSPARC versions older "
875e98fafb9Sjl 				    "than %d.%d are no longer supported "
876e98fafb9Sjl 				    "(cpu #%d)",
877e98fafb9Sjl 				    SPITFIRE_MAJOR_VERSION(min_supported_rev),
878e98fafb9Sjl 				    SPITFIRE_MINOR_VERSION(min_supported_rev),
879e98fafb9Sjl 				    i);
8807c478bd9Sstevel@tonic-gate 			}
8817c478bd9Sstevel@tonic-gate 
8827c478bd9Sstevel@tonic-gate 			/*
8837c478bd9Sstevel@tonic-gate 			 * Min supported rev is 2.1 but we've seen problems
8847c478bd9Sstevel@tonic-gate 			 * with that so we still want to warn if we see one.
8857c478bd9Sstevel@tonic-gate 			 */
8867c478bd9Sstevel@tonic-gate 			if (cpunodes[i].version < 0x22) {
8877c478bd9Sstevel@tonic-gate 				cmn_err(CE_WARN,
8887c478bd9Sstevel@tonic-gate 				"UltraSPARC versions older than "
8897c478bd9Sstevel@tonic-gate 				"2.2 are not supported (cpu #%d)", i);
8907c478bd9Sstevel@tonic-gate #ifdef SF_ERRATA_30 /* call causes fp-disabled */
8917c478bd9Sstevel@tonic-gate 				spitfire_call_bug = 1;
8927c478bd9Sstevel@tonic-gate #endif /* SF_ERRATA_30 */
8937c478bd9Sstevel@tonic-gate 			}
8947c478bd9Sstevel@tonic-gate 		}
8957c478bd9Sstevel@tonic-gate 
8967c478bd9Sstevel@tonic-gate 
8977c478bd9Sstevel@tonic-gate #ifdef SF_V9_TABLE_28	/* fp over/underflow traps may cause wrong fsr.cexc */
8987c478bd9Sstevel@tonic-gate 		if (IS_SPITFIRE(impl) || IS_BLACKBIRD(impl))
8997c478bd9Sstevel@tonic-gate 			spitfire_bb_fsr_bug = 1;
9007c478bd9Sstevel@tonic-gate #endif /* SF_V9_TABLE_28 */
9017c478bd9Sstevel@tonic-gate 
9027c478bd9Sstevel@tonic-gate 		if (IS_CHEETAH(impl)) {
9037c478bd9Sstevel@tonic-gate 			if (cpunodes[i].version < min_supported_rev) {
904e98fafb9Sjl 				cmn_err(CE_PANIC, "UltraSPARC-III versions "
905e98fafb9Sjl 				    "older than %d.%d are no longer supported "
906e98fafb9Sjl 				    "(cpu #%d)",
907e98fafb9Sjl 				    CHEETAH_MAJOR_VERSION(min_supported_rev),
908e98fafb9Sjl 				    CHEETAH_MINOR_VERSION(min_supported_rev),
909e98fafb9Sjl 				    i);
9107c478bd9Sstevel@tonic-gate 			}
9117c478bd9Sstevel@tonic-gate 
9127c478bd9Sstevel@tonic-gate 		}
9137c478bd9Sstevel@tonic-gate 
9147c478bd9Sstevel@tonic-gate #ifdef JALAPENO_ERRATA_85
9157c478bd9Sstevel@tonic-gate 		if (IS_JALAPENO(impl) && (cpunodes[i].version < 0x24)) {
9167c478bd9Sstevel@tonic-gate 			jp_errata_85_allow_slow_scrub = 0;
9177c478bd9Sstevel@tonic-gate 			jp_errata_85_enable = 1;
9187c478bd9Sstevel@tonic-gate 		}
9197c478bd9Sstevel@tonic-gate #endif /* JALAPENO_ERRATA_85 */
9207c478bd9Sstevel@tonic-gate 	}
9217c478bd9Sstevel@tonic-gate }
9227c478bd9Sstevel@tonic-gate 
9237c478bd9Sstevel@tonic-gate /*
9247c478bd9Sstevel@tonic-gate  * Check for a legal set of CPUs.
9257c478bd9Sstevel@tonic-gate  */
9267c478bd9Sstevel@tonic-gate static void
check_cpus_set(void)9277c478bd9Sstevel@tonic-gate check_cpus_set(void)
9287c478bd9Sstevel@tonic-gate {
9297c478bd9Sstevel@tonic-gate 	int i;
9307c478bd9Sstevel@tonic-gate 	int impl;
9317c478bd9Sstevel@tonic-gate 	int npanther = 0;
932e98fafb9Sjl 	int njupiter = 0;
9337c478bd9Sstevel@tonic-gate 
9347c478bd9Sstevel@tonic-gate 	impl = cpunodes[getprocessorid()].implementation;
9357c478bd9Sstevel@tonic-gate 
9367c478bd9Sstevel@tonic-gate 	switch (impl) {
9377c478bd9Sstevel@tonic-gate 	case CHEETAH_PLUS_IMPL:
9387c478bd9Sstevel@tonic-gate 	case JAGUAR_IMPL:
9397c478bd9Sstevel@tonic-gate 	case PANTHER_IMPL:
9407c478bd9Sstevel@tonic-gate 		/*
9417c478bd9Sstevel@tonic-gate 		 * Check for a legal heterogeneous set of CPUs.
9427c478bd9Sstevel@tonic-gate 		 */
9437c478bd9Sstevel@tonic-gate 		for (i = 0; i < NCPU; i++) {
9447c478bd9Sstevel@tonic-gate 			if (cpunodes[i].nodeid == 0)
9457c478bd9Sstevel@tonic-gate 				continue;
9467c478bd9Sstevel@tonic-gate 
9477c478bd9Sstevel@tonic-gate 			if (IS_PANTHER(cpunodes[i].implementation)) {
9487c478bd9Sstevel@tonic-gate 				npanther += 1;
9497c478bd9Sstevel@tonic-gate 			}
9507c478bd9Sstevel@tonic-gate 
9517c478bd9Sstevel@tonic-gate 			if (!(IS_CHEETAH_PLUS(cpunodes[i].implementation) ||
9527c478bd9Sstevel@tonic-gate 			    IS_JAGUAR(cpunodes[i].implementation) ||
9537c478bd9Sstevel@tonic-gate 			    IS_PANTHER(cpunodes[i].implementation))) {
9547c478bd9Sstevel@tonic-gate 				use_mp = 0;
9557c478bd9Sstevel@tonic-gate 				break;
9567c478bd9Sstevel@tonic-gate 			}
9577c478bd9Sstevel@tonic-gate 		}
9587c478bd9Sstevel@tonic-gate 		break;
959e98fafb9Sjl 	case OLYMPUS_C_IMPL:
960e98fafb9Sjl 	case JUPITER_IMPL:
961e98fafb9Sjl 		/*
962e98fafb9Sjl 		 * Check for a legal heterogeneous set of CPUs on the
963e98fafb9Sjl 		 * OPL platform.
964e98fafb9Sjl 		 */
965e98fafb9Sjl 		for (i = 0; i < NCPU; i++) {
966e98fafb9Sjl 			if (cpunodes[i].nodeid == 0)
967e98fafb9Sjl 				continue;
968e98fafb9Sjl 
969e98fafb9Sjl 			if (IS_JUPITER(cpunodes[i].implementation)) {
970e98fafb9Sjl 				njupiter += 1;
971e98fafb9Sjl 			}
972e98fafb9Sjl 			if (!(IS_OLYMPUS_C(cpunodes[i].implementation) ||
973e98fafb9Sjl 			    IS_JUPITER(cpunodes[i].implementation))) {
974e98fafb9Sjl 				use_mp = 0;
975e98fafb9Sjl 				break;
976e98fafb9Sjl 			}
977e98fafb9Sjl 		}
978e98fafb9Sjl 		break;
9797c478bd9Sstevel@tonic-gate 	default:
9807c478bd9Sstevel@tonic-gate 		/*
9817c478bd9Sstevel@tonic-gate 		 * Check for a homogeneous set of CPUs.
9827c478bd9Sstevel@tonic-gate 		 */
9837c478bd9Sstevel@tonic-gate 		for (i = 0; i < NCPU; i++) {
9847c478bd9Sstevel@tonic-gate 			if (cpunodes[i].nodeid == 0)
9857c478bd9Sstevel@tonic-gate 				continue;
9867c478bd9Sstevel@tonic-gate 
9877c478bd9Sstevel@tonic-gate 			if (cpunodes[i].implementation != impl) {
9887c478bd9Sstevel@tonic-gate 				use_mp = 0;
9897c478bd9Sstevel@tonic-gate 				break;
9907c478bd9Sstevel@tonic-gate 			}
9917c478bd9Sstevel@tonic-gate 		}
9927c478bd9Sstevel@tonic-gate 		break;
9937c478bd9Sstevel@tonic-gate 	}
9947c478bd9Sstevel@tonic-gate 
9957c478bd9Sstevel@tonic-gate 	/*
9967c478bd9Sstevel@tonic-gate 	 * Change from mmu_page_sizes from 4 to 6 for totally-Panther domains,
99735b14535Ssusans 	 * where npanther == ncpunode. Also, set ecache_alignsize (and a few
99835b14535Ssusans 	 * other globals) to the correct value for totally-Panther domains.
9997c478bd9Sstevel@tonic-gate 	 */
10007c478bd9Sstevel@tonic-gate 	if (&mmu_init_mmu_page_sizes) {
10017c478bd9Sstevel@tonic-gate 		(void) mmu_init_mmu_page_sizes(npanther);
10027c478bd9Sstevel@tonic-gate 	}
100335b14535Ssusans 	if ((npanther == ncpunode) && (&cpu_fix_allpanther)) {
100435b14535Ssusans 		cpu_fix_allpanther();
100535b14535Ssusans 	}
10067c478bd9Sstevel@tonic-gate 
1007e98fafb9Sjl 	/*
1008e98fafb9Sjl 	 * For all-Jupiter domains the cpu module will update the hwcap features
1009e98fafb9Sjl 	 * for integer multiply-add instruction support.
1010e98fafb9Sjl 	 */
1011e98fafb9Sjl 	if ((njupiter == ncpunode) && (&cpu_fix_alljupiter)) {
1012e98fafb9Sjl 		cpu_fix_alljupiter();
1013e98fafb9Sjl 	}
1014e98fafb9Sjl 
10157c478bd9Sstevel@tonic-gate 	/*
10167c478bd9Sstevel@tonic-gate 	 * Set max cpus we can have based on ncpunode and use_mp
10177c478bd9Sstevel@tonic-gate 	 */
10187c478bd9Sstevel@tonic-gate 	if (use_mp) {
10197c478bd9Sstevel@tonic-gate 		int (*set_max_ncpus)(void);
10207c478bd9Sstevel@tonic-gate 
10217c478bd9Sstevel@tonic-gate 		set_max_ncpus = (int (*)(void))
1022e98fafb9Sjl 		    kobj_getsymvalue("set_platform_max_ncpus", 0);
10237c478bd9Sstevel@tonic-gate 
10247c478bd9Sstevel@tonic-gate 		if (set_max_ncpus) {
10257c478bd9Sstevel@tonic-gate 			max_ncpus = set_max_ncpus();
10267c478bd9Sstevel@tonic-gate 			if (max_ncpus < ncpunode)
10277c478bd9Sstevel@tonic-gate 				max_ncpus = ncpunode;
102806fb6a36Sdv 			boot_ncpus = boot_max_ncpus = ncpunode;
10297c478bd9Sstevel@tonic-gate 		} else {
10307c478bd9Sstevel@tonic-gate 			max_ncpus = ncpunode;
10314fe8b416SPeter Tribble 			boot_ncpus = ncpunode;
10327c478bd9Sstevel@tonic-gate 		}
10337c478bd9Sstevel@tonic-gate 	} else {
10347c478bd9Sstevel@tonic-gate 		cmn_err(CE_NOTE, "MP not supported on mismatched modules,"
10357c478bd9Sstevel@tonic-gate 		    " booting UP only");
10367c478bd9Sstevel@tonic-gate 
10377c478bd9Sstevel@tonic-gate 		for (i = 0; i < NCPU; i++) {
10387c478bd9Sstevel@tonic-gate 			if (cpunodes[i].nodeid == 0)
10397c478bd9Sstevel@tonic-gate 				continue;
10407c478bd9Sstevel@tonic-gate 
10417c478bd9Sstevel@tonic-gate 			cmn_err(CE_NOTE, "cpu%d: %s version 0x%x", i,
10427c478bd9Sstevel@tonic-gate 			    cpunodes[i].name, cpunodes[i].version);
10437c478bd9Sstevel@tonic-gate 		}
10447c478bd9Sstevel@tonic-gate 
10457c478bd9Sstevel@tonic-gate 		max_ncpus = 1;
10464fe8b416SPeter Tribble 		boot_ncpus = 1;
10477c478bd9Sstevel@tonic-gate 	}
10487c478bd9Sstevel@tonic-gate }
10497c478bd9Sstevel@tonic-gate 
10507c478bd9Sstevel@tonic-gate /*
10517c478bd9Sstevel@tonic-gate  * The first sysio must always programmed up for the system clock and error
10527c478bd9Sstevel@tonic-gate  * handling purposes, referenced by v_sysio_addr in machdep.c.
10537c478bd9Sstevel@tonic-gate  */
10547c478bd9Sstevel@tonic-gate static void
have_sbus(pnode_t node)1055fa9e4066Sahrens have_sbus(pnode_t node)
10567c478bd9Sstevel@tonic-gate {
10577c478bd9Sstevel@tonic-gate 	int size;
10587c478bd9Sstevel@tonic-gate 	uint_t portid;
10597c478bd9Sstevel@tonic-gate 
10607c478bd9Sstevel@tonic-gate 	size = GETPROPLEN(node, "upa-portid");
10617c478bd9Sstevel@tonic-gate 	if (size == -1 || size > sizeof (portid))
10627c478bd9Sstevel@tonic-gate 		cmn_err(CE_PANIC, "upa-portid size");
10637c478bd9Sstevel@tonic-gate 	if (GETPROP(node, "upa-portid", (caddr_t)&portid) == -1)
10647c478bd9Sstevel@tonic-gate 		cmn_err(CE_PANIC, "upa-portid");
10657c478bd9Sstevel@tonic-gate 
10667c478bd9Sstevel@tonic-gate 	niobus++;
10677c478bd9Sstevel@tonic-gate 
10687c478bd9Sstevel@tonic-gate 	/*
10697c478bd9Sstevel@tonic-gate 	 * need one physical TSB
10707c478bd9Sstevel@tonic-gate 	 */
10717c478bd9Sstevel@tonic-gate 	niommu_tsbs++;
10727c478bd9Sstevel@tonic-gate }
10737c478bd9Sstevel@tonic-gate 
10747c478bd9Sstevel@tonic-gate 
10757c478bd9Sstevel@tonic-gate #define	IOMMU_PER_SCHIZO	2
10767c478bd9Sstevel@tonic-gate 
10777c478bd9Sstevel@tonic-gate /*
10787c478bd9Sstevel@tonic-gate  * The first psycho must always programmed up for the system clock and error
10797c478bd9Sstevel@tonic-gate  * handling purposes.
10807c478bd9Sstevel@tonic-gate  */
10817c478bd9Sstevel@tonic-gate static void
have_pci(pnode_t node)1082fa9e4066Sahrens have_pci(pnode_t node)
10837c478bd9Sstevel@tonic-gate {
10847c478bd9Sstevel@tonic-gate 	int size;
10857c478bd9Sstevel@tonic-gate 	uint_t portid;
10867c478bd9Sstevel@tonic-gate 	char compatible[OBP_MAXDRVNAME];
10877c478bd9Sstevel@tonic-gate 
10887c478bd9Sstevel@tonic-gate 	size = GETPROPLEN(node, "portid");
10897c478bd9Sstevel@tonic-gate 	if (size == -1) size = GETPROPLEN(node, "upa-portid");
10907c478bd9Sstevel@tonic-gate 	if (size == -1)
10917c478bd9Sstevel@tonic-gate 		return;
10927c478bd9Sstevel@tonic-gate 	if (size > sizeof (portid))
10937c478bd9Sstevel@tonic-gate 		cmn_err(CE_PANIC, "portid size wrong");
10947c478bd9Sstevel@tonic-gate 
10957c478bd9Sstevel@tonic-gate 	if (GETPROP(node, "portid", (caddr_t)&portid) == -1)
10967c478bd9Sstevel@tonic-gate 		if (GETPROP(node, "upa-portid", (caddr_t)&portid) == -1)
10977c478bd9Sstevel@tonic-gate 			cmn_err(CE_PANIC, "portid not found");
10987c478bd9Sstevel@tonic-gate 
10997c478bd9Sstevel@tonic-gate 	niobus++;
11007c478bd9Sstevel@tonic-gate 
11017c478bd9Sstevel@tonic-gate 
11027c478bd9Sstevel@tonic-gate 	/*
11037c478bd9Sstevel@tonic-gate 	 * Need two physical TSBs for Schizo compatible nodes,
11047c478bd9Sstevel@tonic-gate 	 * one otherwise.
11057c478bd9Sstevel@tonic-gate 	 */
11067c478bd9Sstevel@tonic-gate 	compatible[0] = '\0';
11077c478bd9Sstevel@tonic-gate 	(void) prom_getprop(node, OBP_COMPATIBLE, compatible);
11087c478bd9Sstevel@tonic-gate 	if (strcmp(compatible, "pci108e,8001") == 0)
11097c478bd9Sstevel@tonic-gate 		niommu_tsbs += IOMMU_PER_SCHIZO;
11107c478bd9Sstevel@tonic-gate 	else
11117c478bd9Sstevel@tonic-gate 		niommu_tsbs++;
11127c478bd9Sstevel@tonic-gate }
11137c478bd9Sstevel@tonic-gate 
11147c478bd9Sstevel@tonic-gate /*
11157c478bd9Sstevel@tonic-gate  * The first eeprom is used as the TOD clock, referenced
11167c478bd9Sstevel@tonic-gate  * by v_eeprom_addr in locore.s.
11177c478bd9Sstevel@tonic-gate  */
11187c478bd9Sstevel@tonic-gate static void
have_eeprom(pnode_t node)1119fa9e4066Sahrens have_eeprom(pnode_t node)
11207c478bd9Sstevel@tonic-gate {
11217c478bd9Sstevel@tonic-gate 	int size;
11227c478bd9Sstevel@tonic-gate 	uint32_t eaddr;
11237c478bd9Sstevel@tonic-gate 
11247c478bd9Sstevel@tonic-gate 	/*
11257c478bd9Sstevel@tonic-gate 	 * "todmostek" module will be selected based on finding a "model"
11267c478bd9Sstevel@tonic-gate 	 * property value of "mk48t59" in the "eeprom" node.
11277c478bd9Sstevel@tonic-gate 	 */
11287c478bd9Sstevel@tonic-gate 	if (tod_module_name == NULL) {
11297c478bd9Sstevel@tonic-gate 		char buf[MAXSYSNAME];
11307c478bd9Sstevel@tonic-gate 
11317c478bd9Sstevel@tonic-gate 		if ((GETPROP(node, "model", buf) != -1) &&
11327c478bd9Sstevel@tonic-gate 		    (strcmp(buf, "mk48t59") == 0))
11337c478bd9Sstevel@tonic-gate 			tod_module_name = "todmostek";
11347c478bd9Sstevel@tonic-gate 	}
11357c478bd9Sstevel@tonic-gate 
11367c478bd9Sstevel@tonic-gate 	/*
11377c478bd9Sstevel@tonic-gate 	 * If we have found two distinct eeprom's, then we're done.
11387c478bd9Sstevel@tonic-gate 	 */
11397c478bd9Sstevel@tonic-gate 	if (v_eeprom_addr && v_timecheck_addr != v_eeprom_addr)
11407c478bd9Sstevel@tonic-gate 		return;
11417c478bd9Sstevel@tonic-gate 
11427c478bd9Sstevel@tonic-gate 	/*
11437c478bd9Sstevel@tonic-gate 	 * multiple eeproms may exist but at least
11447c478bd9Sstevel@tonic-gate 	 * one must have an "address" property
11457c478bd9Sstevel@tonic-gate 	 */
11467c478bd9Sstevel@tonic-gate 	if ((size = GETPROPLEN(node, OBP_ADDRESS)) == -1)
11477c478bd9Sstevel@tonic-gate 		return;
11487c478bd9Sstevel@tonic-gate 	if (size != sizeof (eaddr))
11497c478bd9Sstevel@tonic-gate 		cmn_err(CE_PANIC, "eeprom addr size");
11507c478bd9Sstevel@tonic-gate 	if (GETPROP(node, OBP_ADDRESS, (caddr_t)&eaddr) == -1)
11517c478bd9Sstevel@tonic-gate 		cmn_err(CE_PANIC, "eeprom addr");
11527c478bd9Sstevel@tonic-gate 
11537c478bd9Sstevel@tonic-gate 	/*
11547c478bd9Sstevel@tonic-gate 	 * If we have a chosen eeprom and it is not this node, keep looking.
11557c478bd9Sstevel@tonic-gate 	 */
1156*12551037SToomas Soome 	if (chosen_eeprom != 0 && chosen_eeprom != node) {
1157f166393fSesolom 		v_timecheck_addr = (caddr_t)(uintptr_t)eaddr;
11587c478bd9Sstevel@tonic-gate 		return;
11597c478bd9Sstevel@tonic-gate 	}
11607c478bd9Sstevel@tonic-gate 
1161f166393fSesolom 	v_eeprom_addr = (caddr_t)(uintptr_t)eaddr;
11627c478bd9Sstevel@tonic-gate 
11637c478bd9Sstevel@tonic-gate 	/*
11647c478bd9Sstevel@tonic-gate 	 * If we don't find an I/O board to use to check the clock,
11657c478bd9Sstevel@tonic-gate 	 * we'll fall back on whichever TOD is available.
11667c478bd9Sstevel@tonic-gate 	 */
11677c478bd9Sstevel@tonic-gate 	if (v_timecheck_addr == NULL)
11687c478bd9Sstevel@tonic-gate 		v_timecheck_addr = v_eeprom_addr;
11697c478bd9Sstevel@tonic-gate 
11707c478bd9Sstevel@tonic-gate 	/*
11717c478bd9Sstevel@tonic-gate 	 * Does this eeprom have watchdog support?
11727c478bd9Sstevel@tonic-gate 	 */
11737c478bd9Sstevel@tonic-gate 	if (GETPROPLEN(node, WATCHDOG_ENABLE) != -1)
11747c478bd9Sstevel@tonic-gate 		watchdog_available = 1;
11757c478bd9Sstevel@tonic-gate }
11767c478bd9Sstevel@tonic-gate 
11777c478bd9Sstevel@tonic-gate static void
have_rtc(pnode_t node)1178fa9e4066Sahrens have_rtc(pnode_t node)
11797c478bd9Sstevel@tonic-gate {
11807c478bd9Sstevel@tonic-gate 	int size;
11817c478bd9Sstevel@tonic-gate 	uint32_t eaddr;
11827c478bd9Sstevel@tonic-gate 
11837c478bd9Sstevel@tonic-gate 	/*
11847c478bd9Sstevel@tonic-gate 	 * "ds1287" module will be selected based on finding a "model"
11857c478bd9Sstevel@tonic-gate 	 * property value of "ds1287" in the "rtc" node.
11867c478bd9Sstevel@tonic-gate 	 */
11877c478bd9Sstevel@tonic-gate 	if (tod_module_name == NULL) {
11887c478bd9Sstevel@tonic-gate 		char buf[MAXSYSNAME];
11897c478bd9Sstevel@tonic-gate 
11907c478bd9Sstevel@tonic-gate 		if (GETPROP(node, "model", buf) != -1) {
11917c478bd9Sstevel@tonic-gate 			if ((strcmp(buf, "m5819p") == 0) ||
11927c478bd9Sstevel@tonic-gate 			    (strcmp(buf, "m5823") == 0))
1193e98fafb9Sjl 				tod_module_name = "todm5823";
11947c478bd9Sstevel@tonic-gate 			else if (strcmp(buf, "ds1287") == 0)
1195e98fafb9Sjl 				tod_module_name = "todds1287";
11967c478bd9Sstevel@tonic-gate 		}
11977c478bd9Sstevel@tonic-gate 	}
11987c478bd9Sstevel@tonic-gate 
11997c478bd9Sstevel@tonic-gate 	/*
12007c478bd9Sstevel@tonic-gate 	 * XXX - drives on if address prop doesn't exist, later falls
12017c478bd9Sstevel@tonic-gate 	 * over in tod module
12027c478bd9Sstevel@tonic-gate 	 */
12037c478bd9Sstevel@tonic-gate 	if ((size = GETPROPLEN(node, OBP_ADDRESS)) == -1)
12047c478bd9Sstevel@tonic-gate 		return;
12057c478bd9Sstevel@tonic-gate 	if (size != sizeof (eaddr))
12067c478bd9Sstevel@tonic-gate 		cmn_err(CE_PANIC, "rtc addr size");
12077c478bd9Sstevel@tonic-gate 	if (GETPROP(node, OBP_ADDRESS, (caddr_t)&eaddr) == -1)
12087c478bd9Sstevel@tonic-gate 		cmn_err(CE_PANIC, "rtc addr");
12097c478bd9Sstevel@tonic-gate 
1210f166393fSesolom 	v_rtc_addr_reg = (caddr_t)(uintptr_t)eaddr;
1211f166393fSesolom 	v_rtc_data_reg = (volatile unsigned char *)(uintptr_t)eaddr + 1;
12127c478bd9Sstevel@tonic-gate 
12137c478bd9Sstevel@tonic-gate 	/*
12147c478bd9Sstevel@tonic-gate 	 * Does this rtc have watchdog support?
12157c478bd9Sstevel@tonic-gate 	 */
12167c478bd9Sstevel@tonic-gate 	if (GETPROPLEN(node, WATCHDOG_ENABLE) != -1)
12177c478bd9Sstevel@tonic-gate 		watchdog_available = 1;
12187c478bd9Sstevel@tonic-gate }
12197c478bd9Sstevel@tonic-gate 
12207c478bd9Sstevel@tonic-gate static void
have_pmc(pnode_t node)1221fa9e4066Sahrens have_pmc(pnode_t node)
12227c478bd9Sstevel@tonic-gate {
12237c478bd9Sstevel@tonic-gate 	uint32_t vaddr;
1224fa9e4066Sahrens 	pnode_t root;
12257c478bd9Sstevel@tonic-gate 
12267c478bd9Sstevel@tonic-gate 	/*
12277c478bd9Sstevel@tonic-gate 	 * Watchdog property is in the root node.
12287c478bd9Sstevel@tonic-gate 	 */
1229fa9e4066Sahrens 	root = prom_nextnode((pnode_t)0);
12307c478bd9Sstevel@tonic-gate 	if (GETPROPLEN(root, WATCHDOG_ENABLE) != -1) {
12317c478bd9Sstevel@tonic-gate 		/*
12327c478bd9Sstevel@tonic-gate 		 * The hardware watchdog timer resides within logical
12337c478bd9Sstevel@tonic-gate 		 * unit 8 of SuperI/O. The address property of the node
12347c478bd9Sstevel@tonic-gate 		 * contains the virtual address that we use to program
12357c478bd9Sstevel@tonic-gate 		 * the timer.
12367c478bd9Sstevel@tonic-gate 		 */
12377c478bd9Sstevel@tonic-gate 		if (GETPROP(node, OBP_ADDRESS, (caddr_t)&vaddr) == -1) {
12387c478bd9Sstevel@tonic-gate 			watchdog_available = 0;
12397c478bd9Sstevel@tonic-gate 			return;
12407c478bd9Sstevel@tonic-gate 		}
1241f166393fSesolom 		v_pmc_addr_reg = (volatile uint8_t *)(uintptr_t)vaddr;
1242f166393fSesolom 		v_pmc_data_reg = (volatile uint8_t *)(uintptr_t)vaddr + 1;
12437c478bd9Sstevel@tonic-gate 		watchdog_available = 1;
12447c478bd9Sstevel@tonic-gate 	}
12457c478bd9Sstevel@tonic-gate }
12467c478bd9Sstevel@tonic-gate 
12477c478bd9Sstevel@tonic-gate static void
have_auxio(pnode_t node)1248fa9e4066Sahrens have_auxio(pnode_t node)
12497c478bd9Sstevel@tonic-gate {
12507c478bd9Sstevel@tonic-gate 	size_t size, n;
12517c478bd9Sstevel@tonic-gate 	uint32_t addr[5];
12527c478bd9Sstevel@tonic-gate 
12537c478bd9Sstevel@tonic-gate 	/*
12547c478bd9Sstevel@tonic-gate 	 * Get the size of the auzio's address property.
12557c478bd9Sstevel@tonic-gate 	 * On some platforms, the address property contains one
12567c478bd9Sstevel@tonic-gate 	 * entry and on others it contains five entries.
12577c478bd9Sstevel@tonic-gate 	 * In all cases, the first entries are compatible.
12587c478bd9Sstevel@tonic-gate 	 *
12597c478bd9Sstevel@tonic-gate 	 * This routine gets the address property for the auxio
12607c478bd9Sstevel@tonic-gate 	 * node and stores the first entry in v_auxio_addr which
12617c478bd9Sstevel@tonic-gate 	 * is used by the routine set_auxioreg in sun4u/ml/locore.s.
12627c478bd9Sstevel@tonic-gate 	 */
12637c478bd9Sstevel@tonic-gate 	if ((size = GETPROPLEN(node, OBP_ADDRESS)) == -1)
12647c478bd9Sstevel@tonic-gate 		cmn_err(CE_PANIC, "no auxio address property");
12657c478bd9Sstevel@tonic-gate 
12667c478bd9Sstevel@tonic-gate 	switch (n = (size / sizeof (addr[0]))) {
12677c478bd9Sstevel@tonic-gate 	case 1:
12687c478bd9Sstevel@tonic-gate 		break;
12697c478bd9Sstevel@tonic-gate 	case 5:
12707c478bd9Sstevel@tonic-gate 		break;
12717c478bd9Sstevel@tonic-gate 	default:
12727c478bd9Sstevel@tonic-gate 		cmn_err(CE_PANIC, "auxio addr has %lu entries?", n);
12737c478bd9Sstevel@tonic-gate 	}
12747c478bd9Sstevel@tonic-gate 
12757c478bd9Sstevel@tonic-gate 	if (GETPROP(node, OBP_ADDRESS, (caddr_t)addr) == -1)
12767c478bd9Sstevel@tonic-gate 		cmn_err(CE_PANIC, "auxio addr");
12777c478bd9Sstevel@tonic-gate 
1278f166393fSesolom 	v_auxio_addr = (caddr_t)(uintptr_t)(addr[0]); /* make into pointer */
12797c478bd9Sstevel@tonic-gate }
12807c478bd9Sstevel@tonic-gate 
12817c478bd9Sstevel@tonic-gate static void
have_tod(pnode_t node)1282fa9e4066Sahrens have_tod(pnode_t node)
12837c478bd9Sstevel@tonic-gate {
12847c478bd9Sstevel@tonic-gate 	static char tod_name[MAXSYSNAME];
12857c478bd9Sstevel@tonic-gate 
12867c478bd9Sstevel@tonic-gate 	if (GETPROP(node, OBP_NAME, (caddr_t)tod_name) == -1)
12877c478bd9Sstevel@tonic-gate 		cmn_err(CE_PANIC, "tod name");
12887c478bd9Sstevel@tonic-gate 	/*
12897c478bd9Sstevel@tonic-gate 	 * This is a node with "device_type" property value of "tod".
12907c478bd9Sstevel@tonic-gate 	 * Name of the tod module is the name from the node.
12917c478bd9Sstevel@tonic-gate 	 */
12927c478bd9Sstevel@tonic-gate 	tod_module_name = tod_name;
12937c478bd9Sstevel@tonic-gate }
1294