10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51772Sjl139090 * Common Development and Distribution License (the "License"). 61772Sjl139090 * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*6880Sdv142724 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 270Sstevel@tonic-gate 280Sstevel@tonic-gate #include <sys/errno.h> 290Sstevel@tonic-gate #include <sys/types.h> 300Sstevel@tonic-gate #include <sys/param.h> 310Sstevel@tonic-gate #include <sys/cpu.h> 320Sstevel@tonic-gate #include <sys/cpuvar.h> 330Sstevel@tonic-gate #include <sys/clock.h> 340Sstevel@tonic-gate 350Sstevel@tonic-gate #include <sys/promif.h> 360Sstevel@tonic-gate #include <sys/promimpl.h> 370Sstevel@tonic-gate #include <sys/systm.h> 380Sstevel@tonic-gate #include <sys/machsystm.h> 390Sstevel@tonic-gate #include <sys/debug.h> 400Sstevel@tonic-gate #include <sys/sunddi.h> 410Sstevel@tonic-gate #include <sys/modctl.h> 420Sstevel@tonic-gate #include <sys/spitregs.h> 430Sstevel@tonic-gate #include <sys/cheetahregs.h> 440Sstevel@tonic-gate #include <sys/cpu_module.h> 450Sstevel@tonic-gate #include <sys/kobj.h> 460Sstevel@tonic-gate #include <sys/cmp.h> 470Sstevel@tonic-gate #include <sys/async.h> 480Sstevel@tonic-gate #include <vm/page.h> 490Sstevel@tonic-gate 500Sstevel@tonic-gate /* 510Sstevel@tonic-gate * The OpenBoot Standalone Interface supplies the kernel with 520Sstevel@tonic-gate * implementation dependent parameters through the devinfo/property mechanism 530Sstevel@tonic-gate */ 540Sstevel@tonic-gate typedef enum { XDRBOOL, XDRINT, XDRSTRING } xdrs; 550Sstevel@tonic-gate 560Sstevel@tonic-gate /* 570Sstevel@tonic-gate * structure describing properties that we are interested in querying the 580Sstevel@tonic-gate * OBP for. 590Sstevel@tonic-gate */ 600Sstevel@tonic-gate struct getprop_info { 610Sstevel@tonic-gate char *name; 620Sstevel@tonic-gate xdrs type; 630Sstevel@tonic-gate uint_t *var; 640Sstevel@tonic-gate }; 650Sstevel@tonic-gate 660Sstevel@tonic-gate /* 670Sstevel@tonic-gate * structure used to convert between a string returned by the OBP & a type 680Sstevel@tonic-gate * used within the kernel. We prefer to paramaterize rather than type. 690Sstevel@tonic-gate */ 700Sstevel@tonic-gate struct convert_info { 710Sstevel@tonic-gate char *name; 720Sstevel@tonic-gate uint_t var; 730Sstevel@tonic-gate char *realname; 740Sstevel@tonic-gate }; 750Sstevel@tonic-gate 760Sstevel@tonic-gate /* 770Sstevel@tonic-gate * structure describing nodes that we are interested in querying the OBP for 780Sstevel@tonic-gate * properties. 790Sstevel@tonic-gate */ 800Sstevel@tonic-gate struct node_info { 810Sstevel@tonic-gate char *name; 820Sstevel@tonic-gate int size; 830Sstevel@tonic-gate struct getprop_info *prop; 840Sstevel@tonic-gate struct getprop_info *prop_end; 850Sstevel@tonic-gate unsigned int *value; 860Sstevel@tonic-gate }; 870Sstevel@tonic-gate 880Sstevel@tonic-gate /* 890Sstevel@tonic-gate * macro definitions for routines that form the OBP interface 900Sstevel@tonic-gate */ 910Sstevel@tonic-gate #define NEXT prom_nextnode 920Sstevel@tonic-gate #define CHILD prom_childnode 930Sstevel@tonic-gate #define GETPROP prom_getprop 940Sstevel@tonic-gate #define GETPROPLEN prom_getproplen 950Sstevel@tonic-gate 960Sstevel@tonic-gate 970Sstevel@tonic-gate /* 0=quiet; 1=verbose; 2=debug */ 980Sstevel@tonic-gate int debug_fillsysinfo = 0; 990Sstevel@tonic-gate #define VPRINTF if (debug_fillsysinfo) prom_printf 1000Sstevel@tonic-gate 1010Sstevel@tonic-gate int ncpunode; 1020Sstevel@tonic-gate struct cpu_node cpunodes[NCPU]; 1030Sstevel@tonic-gate 1040Sstevel@tonic-gate static void check_cpus_ver(void); 1050Sstevel@tonic-gate static void check_cpus_set(void); 106789Sahrens void fill_cpu(pnode_t); 1070Sstevel@tonic-gate void fill_cpu_ddi(dev_info_t *); 1080Sstevel@tonic-gate void empty_cpu(int); 109789Sahrens void plat_fill_mc(pnode_t); 1100Sstevel@tonic-gate #pragma weak plat_fill_mc 1110Sstevel@tonic-gate 1120Sstevel@tonic-gate uint64_t system_clock_freq; 1130Sstevel@tonic-gate 1140Sstevel@tonic-gate /* 1150Sstevel@tonic-gate * list of well known devices that must be mapped, and the variables that 1160Sstevel@tonic-gate * contain their addresses. 1170Sstevel@tonic-gate */ 1180Sstevel@tonic-gate caddr_t v_auxio_addr = NULL; 1190Sstevel@tonic-gate caddr_t v_eeprom_addr = NULL; 1200Sstevel@tonic-gate caddr_t v_timecheck_addr = NULL; 1210Sstevel@tonic-gate caddr_t v_rtc_addr_reg = NULL; 1220Sstevel@tonic-gate volatile unsigned char *v_rtc_data_reg = NULL; 1230Sstevel@tonic-gate volatile uint8_t *v_pmc_addr_reg = NULL; 1240Sstevel@tonic-gate volatile uint8_t *v_pmc_data_reg = NULL; 1250Sstevel@tonic-gate 1260Sstevel@tonic-gate int niobus = 0; 1270Sstevel@tonic-gate uint_t niommu_tsbs = 0; 1280Sstevel@tonic-gate 1290Sstevel@tonic-gate /* 1300Sstevel@tonic-gate * Hardware watchdog support. 1310Sstevel@tonic-gate */ 1320Sstevel@tonic-gate #define CHOSEN_EEPROM "eeprom" 1330Sstevel@tonic-gate #define WATCHDOG_ENABLE "watchdog-enable" 134789Sahrens static pnode_t chosen_eeprom; 1350Sstevel@tonic-gate 1360Sstevel@tonic-gate /* 1370Sstevel@tonic-gate * Appropriate tod module will be dynamically selected while booting 1380Sstevel@tonic-gate * based on finding a device tree node with a "device_type" property value 1390Sstevel@tonic-gate * of "tod". If such a node describing tod is not found, for backward 1400Sstevel@tonic-gate * compatibility, a node with a "name" property value of "eeprom" and 1410Sstevel@tonic-gate * "model" property value of "mk48t59" will be used. Failing to find a 1420Sstevel@tonic-gate * node matching either of the above criteria will result in no tod module 1430Sstevel@tonic-gate * being selected; this will cause the boot process to halt. 1440Sstevel@tonic-gate */ 1450Sstevel@tonic-gate char *tod_module_name; 1460Sstevel@tonic-gate 1470Sstevel@tonic-gate /* 1480Sstevel@tonic-gate * If this variable is non-zero, cpr should return "not supported" when 1490Sstevel@tonic-gate * it is queried even though it would normally be supported on this platform. 1500Sstevel@tonic-gate */ 1510Sstevel@tonic-gate int cpr_supported_override; 1520Sstevel@tonic-gate 1530Sstevel@tonic-gate /* 1540Sstevel@tonic-gate * Some platforms may need to support CPR even in the absence of the 1550Sstevel@tonic-gate * energystar-v* property (Enchilada server, for example). If this 1560Sstevel@tonic-gate * variable is non-zero, cpr should proceed even in the absence 1570Sstevel@tonic-gate * of the energystar-v* property. 1580Sstevel@tonic-gate */ 1590Sstevel@tonic-gate int cpr_platform_enable = 0; 1600Sstevel@tonic-gate 1610Sstevel@tonic-gate /* 1620Sstevel@tonic-gate * Some nodes have functions that need to be called when they're seen. 1630Sstevel@tonic-gate */ 164789Sahrens static void have_sbus(pnode_t); 165789Sahrens static void have_pci(pnode_t); 166789Sahrens static void have_eeprom(pnode_t); 167789Sahrens static void have_auxio(pnode_t); 168789Sahrens static void have_rtc(pnode_t); 169789Sahrens static void have_tod(pnode_t); 170789Sahrens static void have_pmc(pnode_t); 1710Sstevel@tonic-gate 1720Sstevel@tonic-gate static struct wkdevice { 1730Sstevel@tonic-gate char *wk_namep; 174789Sahrens void (*wk_func)(pnode_t); 1750Sstevel@tonic-gate caddr_t *wk_vaddrp; 1760Sstevel@tonic-gate ushort_t wk_flags; 1770Sstevel@tonic-gate #define V_OPTIONAL 0x0000 1780Sstevel@tonic-gate #define V_MUSTHAVE 0x0001 1790Sstevel@tonic-gate #define V_MAPPED 0x0002 1800Sstevel@tonic-gate #define V_MULTI 0x0003 /* optional, may be more than one */ 1810Sstevel@tonic-gate } wkdevice[] = { 1820Sstevel@tonic-gate { "sbus", have_sbus, NULL, V_MULTI }, 1830Sstevel@tonic-gate { "pci", have_pci, NULL, V_MULTI }, 1840Sstevel@tonic-gate { "eeprom", have_eeprom, NULL, V_MULTI }, 1850Sstevel@tonic-gate { "auxio", have_auxio, NULL, V_OPTIONAL }, 1860Sstevel@tonic-gate { "rtc", have_rtc, NULL, V_OPTIONAL }, 1870Sstevel@tonic-gate { "pmc", have_pmc, NULL, V_OPTIONAL }, 1880Sstevel@tonic-gate { 0, }, 1890Sstevel@tonic-gate }; 1900Sstevel@tonic-gate 191789Sahrens static void map_wellknown(pnode_t); 1920Sstevel@tonic-gate 1930Sstevel@tonic-gate void 1940Sstevel@tonic-gate map_wellknown_devices() 1950Sstevel@tonic-gate { 1960Sstevel@tonic-gate struct wkdevice *wkp; 1970Sstevel@tonic-gate phandle_t ieeprom; 198789Sahrens pnode_t root; 1990Sstevel@tonic-gate uint_t stick_freq; 2000Sstevel@tonic-gate 2010Sstevel@tonic-gate /* 2020Sstevel@tonic-gate * if there is a chosen eeprom, note it (for have_eeprom()) 2030Sstevel@tonic-gate */ 2040Sstevel@tonic-gate if (GETPROPLEN(prom_chosennode(), CHOSEN_EEPROM) == 2050Sstevel@tonic-gate sizeof (phandle_t) && 2060Sstevel@tonic-gate GETPROP(prom_chosennode(), CHOSEN_EEPROM, (caddr_t)&ieeprom) != -1) 207789Sahrens chosen_eeprom = (pnode_t)prom_decode_int(ieeprom); 2080Sstevel@tonic-gate 209789Sahrens root = prom_nextnode((pnode_t)0); 2100Sstevel@tonic-gate /* 2110Sstevel@tonic-gate * Get System clock frequency from root node if it exists. 2120Sstevel@tonic-gate */ 2130Sstevel@tonic-gate if (GETPROP(root, "stick-frequency", (caddr_t)&stick_freq) != -1) 2140Sstevel@tonic-gate system_clock_freq = stick_freq; 2150Sstevel@tonic-gate 216789Sahrens map_wellknown(NEXT((pnode_t)0)); 2170Sstevel@tonic-gate 2180Sstevel@tonic-gate /* 2190Sstevel@tonic-gate * See if it worked 2200Sstevel@tonic-gate */ 2210Sstevel@tonic-gate for (wkp = wkdevice; wkp->wk_namep; ++wkp) { 2220Sstevel@tonic-gate if (wkp->wk_flags == V_MUSTHAVE) { 2230Sstevel@tonic-gate cmn_err(CE_PANIC, "map_wellknown_devices: required " 2240Sstevel@tonic-gate "device %s not mapped", wkp->wk_namep); 2250Sstevel@tonic-gate } 2260Sstevel@tonic-gate } 2270Sstevel@tonic-gate 2280Sstevel@tonic-gate /* 2290Sstevel@tonic-gate * all sun4u systems must have an IO bus, i.e. sbus or pcibus 2300Sstevel@tonic-gate */ 2310Sstevel@tonic-gate if (niobus == 0) 2320Sstevel@tonic-gate cmn_err(CE_PANIC, "map_wellknown_devices: no i/o bus node"); 2330Sstevel@tonic-gate 2340Sstevel@tonic-gate check_cpus_ver(); 2350Sstevel@tonic-gate check_cpus_set(); 2360Sstevel@tonic-gate } 2370Sstevel@tonic-gate 2380Sstevel@tonic-gate /* 2390Sstevel@tonic-gate * map_wellknown - map known devices & registers 2400Sstevel@tonic-gate */ 2410Sstevel@tonic-gate static void 242789Sahrens map_wellknown(pnode_t curnode) 2430Sstevel@tonic-gate { 2440Sstevel@tonic-gate extern int status_okay(int, char *, int); 2450Sstevel@tonic-gate char tmp_name[MAXSYSNAME]; 246789Sahrens static void fill_address(pnode_t, char *); 2470Sstevel@tonic-gate int sok; 2480Sstevel@tonic-gate 2490Sstevel@tonic-gate #ifdef VPRINTF 2500Sstevel@tonic-gate VPRINTF("map_wellknown(%x)\n", curnode); 2510Sstevel@tonic-gate #endif /* VPRINTF */ 2520Sstevel@tonic-gate 2530Sstevel@tonic-gate for (curnode = CHILD(curnode); curnode; curnode = NEXT(curnode)) { 2540Sstevel@tonic-gate /* 2550Sstevel@tonic-gate * prune subtree if status property indicating not okay 2560Sstevel@tonic-gate */ 2570Sstevel@tonic-gate sok = status_okay((int)curnode, (char *)NULL, 0); 2580Sstevel@tonic-gate if (!sok) { 2590Sstevel@tonic-gate char devtype_buf[OBP_MAXPROPNAME]; 2600Sstevel@tonic-gate int size; 2610Sstevel@tonic-gate 2620Sstevel@tonic-gate #ifdef VPRINTF 2630Sstevel@tonic-gate VPRINTF("map_wellknown: !okay status property\n"); 2640Sstevel@tonic-gate #endif /* VPRINTF */ 2650Sstevel@tonic-gate /* 2660Sstevel@tonic-gate * a status property indicating bad memory will be 2670Sstevel@tonic-gate * associated with a node which has a "device_type" 2680Sstevel@tonic-gate * property with a value of "memory-controller" 2690Sstevel@tonic-gate */ 2700Sstevel@tonic-gate if ((size = GETPROPLEN(curnode, 2710Sstevel@tonic-gate OBP_DEVICETYPE)) == -1) 2720Sstevel@tonic-gate continue; 2730Sstevel@tonic-gate if (size > OBP_MAXPROPNAME) { 2740Sstevel@tonic-gate cmn_err(CE_CONT, "node %x '%s' prop too " 2750Sstevel@tonic-gate "big\n", curnode, OBP_DEVICETYPE); 2760Sstevel@tonic-gate continue; 2770Sstevel@tonic-gate } 2780Sstevel@tonic-gate if (GETPROP(curnode, OBP_DEVICETYPE, 2790Sstevel@tonic-gate devtype_buf) == -1) { 2800Sstevel@tonic-gate cmn_err(CE_CONT, "node %x '%s' get failed\n", 2810Sstevel@tonic-gate curnode, OBP_DEVICETYPE); 2820Sstevel@tonic-gate continue; 2830Sstevel@tonic-gate } 2840Sstevel@tonic-gate if (strcmp(devtype_buf, "memory-controller") != 0) 2850Sstevel@tonic-gate continue; 2860Sstevel@tonic-gate /* 2870Sstevel@tonic-gate * ...else fall thru and process the node... 2880Sstevel@tonic-gate */ 2890Sstevel@tonic-gate } 2900Sstevel@tonic-gate bzero(tmp_name, MAXSYSNAME); 2910Sstevel@tonic-gate if (GETPROP(curnode, OBP_NAME, (caddr_t)tmp_name) != -1) 2920Sstevel@tonic-gate fill_address(curnode, tmp_name); 2930Sstevel@tonic-gate if (GETPROP(curnode, OBP_DEVICETYPE, tmp_name) != -1 && 2940Sstevel@tonic-gate strcmp(tmp_name, "cpu") == 0) { 2950Sstevel@tonic-gate fill_cpu(curnode); 2960Sstevel@tonic-gate } 2970Sstevel@tonic-gate if (strcmp(tmp_name, "tod") == 0) 2980Sstevel@tonic-gate have_tod(curnode); 2990Sstevel@tonic-gate if (sok && (strcmp(tmp_name, "memory-controller") == 0) && 3000Sstevel@tonic-gate (&plat_fill_mc != NULL)) 3010Sstevel@tonic-gate plat_fill_mc(curnode); 3020Sstevel@tonic-gate map_wellknown(curnode); 3030Sstevel@tonic-gate } 3040Sstevel@tonic-gate } 3050Sstevel@tonic-gate 3060Sstevel@tonic-gate static void 307789Sahrens fill_address(pnode_t curnode, char *namep) 3080Sstevel@tonic-gate { 3090Sstevel@tonic-gate struct wkdevice *wkp; 3100Sstevel@tonic-gate int size; 3110Sstevel@tonic-gate uint32_t vaddr; 3120Sstevel@tonic-gate 3130Sstevel@tonic-gate for (wkp = wkdevice; wkp->wk_namep; ++wkp) { 3140Sstevel@tonic-gate if (strcmp(wkp->wk_namep, namep) != 0) 3150Sstevel@tonic-gate continue; 3160Sstevel@tonic-gate if (wkp->wk_flags == V_MAPPED) 3170Sstevel@tonic-gate return; 3180Sstevel@tonic-gate if (wkp->wk_vaddrp != NULL) { 3190Sstevel@tonic-gate if ((size = GETPROPLEN(curnode, OBP_ADDRESS)) == -1) { 3200Sstevel@tonic-gate cmn_err(CE_CONT, "device %s size %d\n", 3210Sstevel@tonic-gate namep, size); 3220Sstevel@tonic-gate continue; 3230Sstevel@tonic-gate } 3240Sstevel@tonic-gate if (size != sizeof (vaddr)) { 3250Sstevel@tonic-gate cmn_err(CE_CONT, "device %s address prop too " 3260Sstevel@tonic-gate "big\n", namep); 3270Sstevel@tonic-gate continue; 3280Sstevel@tonic-gate } 3290Sstevel@tonic-gate if (GETPROP(curnode, OBP_ADDRESS, 3300Sstevel@tonic-gate (caddr_t)&vaddr) == -1) { 3310Sstevel@tonic-gate cmn_err(CE_CONT, "device %s not mapped\n", 3320Sstevel@tonic-gate namep); 3330Sstevel@tonic-gate continue; 3340Sstevel@tonic-gate } 3350Sstevel@tonic-gate 3360Sstevel@tonic-gate /* make into a native pointer */ 337501Sesolom *wkp->wk_vaddrp = (caddr_t)(uintptr_t)vaddr; 3380Sstevel@tonic-gate #ifdef VPRINTF 339501Sesolom VPRINTF("fill_address: %s mapped to %p\n", namep, 3400Sstevel@tonic-gate *wkp->wk_vaddrp); 3410Sstevel@tonic-gate #endif /* VPRINTF */ 3420Sstevel@tonic-gate } 3430Sstevel@tonic-gate if (wkp->wk_func != NULL) 3440Sstevel@tonic-gate (*wkp->wk_func)(curnode); 3450Sstevel@tonic-gate /* 3460Sstevel@tonic-gate * If this one is optional and there may be more than 3470Sstevel@tonic-gate * one, don't set V_MAPPED, which would cause us to skip it 3480Sstevel@tonic-gate * next time around 3490Sstevel@tonic-gate */ 3500Sstevel@tonic-gate if (wkp->wk_flags != V_MULTI) 3510Sstevel@tonic-gate wkp->wk_flags = V_MAPPED; 3520Sstevel@tonic-gate } 3530Sstevel@tonic-gate } 3540Sstevel@tonic-gate 3550Sstevel@tonic-gate int 356789Sahrens get_portid(pnode_t node, pnode_t *cmpp) 3570Sstevel@tonic-gate { 3580Sstevel@tonic-gate int portid; 3591772Sjl139090 int i; 3600Sstevel@tonic-gate char dev_type[OBP_MAXPROPNAME]; 3611772Sjl139090 pnode_t cpu_parent; 3620Sstevel@tonic-gate 3630Sstevel@tonic-gate if (cmpp != NULL) 3640Sstevel@tonic-gate *cmpp = OBP_NONODE; 3650Sstevel@tonic-gate 3660Sstevel@tonic-gate if (GETPROP(node, "portid", (caddr_t)&portid) != -1) 3670Sstevel@tonic-gate return (portid); 3680Sstevel@tonic-gate if (GETPROP(node, "upa-portid", (caddr_t)&portid) != -1) 3690Sstevel@tonic-gate return (portid); 3700Sstevel@tonic-gate if (GETPROP(node, "device_type", (caddr_t)&dev_type) == -1) 3710Sstevel@tonic-gate return (-1); 3720Sstevel@tonic-gate 3731772Sjl139090 /* 3741772Sjl139090 * For a virtual cpu node that is a CMP core, the "portid" 3751772Sjl139090 * is in the parent node. 3761772Sjl139090 * For a virtual cpu node that is a CMT strand, the "portid" is 3771772Sjl139090 * in its grandparent node. 3781772Sjl139090 * So we iterate up as far as 2 levels to get the "portid". 3791772Sjl139090 */ 3800Sstevel@tonic-gate if (strcmp(dev_type, "cpu") == 0) { 3811772Sjl139090 cpu_parent = node = prom_parentnode(node); 3821772Sjl139090 for (i = 0; i < 2; i++) { 3831772Sjl139090 if (node == OBP_NONODE || node == OBP_BADNODE) 3841772Sjl139090 break; 3851772Sjl139090 if (GETPROP(node, "portid", (caddr_t)&portid) != -1) { 3861772Sjl139090 if (cmpp != NULL) 3871772Sjl139090 *cmpp = cpu_parent; 3881772Sjl139090 return (portid); 3891772Sjl139090 } 3901772Sjl139090 node = prom_parentnode(node); 3910Sstevel@tonic-gate } 3920Sstevel@tonic-gate } 3930Sstevel@tonic-gate 3940Sstevel@tonic-gate return (-1); 3950Sstevel@tonic-gate } 3960Sstevel@tonic-gate 3970Sstevel@tonic-gate /* 3980Sstevel@tonic-gate * Adjust page coloring variables based on the physical ecache setsize of 3990Sstevel@tonic-gate * the configured cpus: 4000Sstevel@tonic-gate * 4010Sstevel@tonic-gate * Set ecache_setsize to max ecache set size to be used by 4020Sstevel@tonic-gate * page_coloring_init() to determine the page colors to configure. 4030Sstevel@tonic-gate * The adjustment is unlikely to be necessary... For cheetah+ systems, 4040Sstevel@tonic-gate * ecache_setsize should already be set in cpu_fiximp() to the maximum 4050Sstevel@tonic-gate * possible ecache setsize of any supported cheetah+ cpus. The adjustment 4060Sstevel@tonic-gate * is for the off chance that a non-cheetah+ system may have heterogenous 4070Sstevel@tonic-gate * cpus. 4080Sstevel@tonic-gate * 4090Sstevel@tonic-gate * Set cpu_setsize to the actual cpu setsize if the setsize is homogenous 4100Sstevel@tonic-gate * across all cpus otherwise set it to -1 if heterogenous. 4110Sstevel@tonic-gate * 4120Sstevel@tonic-gate * Set cpu_page_colors to -1 to signify heterogeneity of ecache setsizes 4130Sstevel@tonic-gate * to the page_get routines. 4140Sstevel@tonic-gate */ 4150Sstevel@tonic-gate static void 4160Sstevel@tonic-gate adj_ecache_setsize(int ecsetsize) 4170Sstevel@tonic-gate { 4180Sstevel@tonic-gate if (ecsetsize > ecache_setsize) 4190Sstevel@tonic-gate ecache_setsize = ecsetsize; 4200Sstevel@tonic-gate 4210Sstevel@tonic-gate switch (cpu_setsize) { 4220Sstevel@tonic-gate case -1: 4230Sstevel@tonic-gate break; 4240Sstevel@tonic-gate case 0: 4250Sstevel@tonic-gate cpu_setsize = ecsetsize; 4260Sstevel@tonic-gate break; 4270Sstevel@tonic-gate default: 4280Sstevel@tonic-gate /* set to -1 if hetergenous cpus */ 4290Sstevel@tonic-gate if (cpu_setsize != ecsetsize) { 4300Sstevel@tonic-gate if (do_pg_coloring) 4310Sstevel@tonic-gate cpu_page_colors = -1; 4320Sstevel@tonic-gate /* 4330Sstevel@tonic-gate * if page coloring disabled, cpu_page_colors should 4340Sstevel@tonic-gate * remain 0 to prevent page coloring processing. 4350Sstevel@tonic-gate */ 4360Sstevel@tonic-gate cpu_setsize = -1; 4370Sstevel@tonic-gate } 4380Sstevel@tonic-gate break; 4390Sstevel@tonic-gate } 4400Sstevel@tonic-gate } 4410Sstevel@tonic-gate 4420Sstevel@tonic-gate void 443789Sahrens fill_cpu(pnode_t node) 4440Sstevel@tonic-gate { 4450Sstevel@tonic-gate extern int cpu_get_cpu_unum(int, char *, int, int *); 4460Sstevel@tonic-gate struct cpu_node *cpunode; 4470Sstevel@tonic-gate processorid_t cpuid; 4480Sstevel@tonic-gate int portid; 4490Sstevel@tonic-gate int tlbsize; 4500Sstevel@tonic-gate int size; 4510Sstevel@tonic-gate uint_t clk_freq; 452789Sahrens pnode_t cmpnode; 4530Sstevel@tonic-gate char namebuf[OBP_MAXPROPNAME], unum[UNUM_NAMLEN]; 4540Sstevel@tonic-gate char *namebufp; 4555666Swh31274 int proplen; 4560Sstevel@tonic-gate 4570Sstevel@tonic-gate if ((portid = get_portid(node, &cmpnode)) == -1) { 4580Sstevel@tonic-gate cmn_err(CE_PANIC, "portid not found"); 4590Sstevel@tonic-gate } 4600Sstevel@tonic-gate 4610Sstevel@tonic-gate if (GETPROP(node, "cpuid", (caddr_t)&cpuid) == -1) { 4620Sstevel@tonic-gate cpuid = portid; 4630Sstevel@tonic-gate } 4640Sstevel@tonic-gate 4650Sstevel@tonic-gate if (cpuid < 0 || cpuid >= NCPU) { 4665037Sjl139090 cmn_err(CE_PANIC, "cpu node %x: cpuid %d out of range", node, 4675037Sjl139090 cpuid); 4680Sstevel@tonic-gate return; 4690Sstevel@tonic-gate } 4700Sstevel@tonic-gate 4710Sstevel@tonic-gate cpunode = &cpunodes[cpuid]; 4720Sstevel@tonic-gate cpunode->portid = portid; 4731772Sjl139090 cpunode->nodeid = node; 4740Sstevel@tonic-gate 4750Sstevel@tonic-gate if (cpu_get_cpu_unum(cpuid, unum, UNUM_NAMLEN, &size) != 0) { 4760Sstevel@tonic-gate cpunode->fru_fmri[0] = '\0'; 4770Sstevel@tonic-gate } else { 4780Sstevel@tonic-gate (void) snprintf(cpunode->fru_fmri, sizeof (cpunode->fru_fmri), 4790Sstevel@tonic-gate "%s%s", CPU_FRU_FMRI, unum); 4800Sstevel@tonic-gate } 4810Sstevel@tonic-gate 4821772Sjl139090 if (cmpnode) { 4831772Sjl139090 /* 4841772Sjl139090 * For the CMT case, the parent "core" node contains 4851772Sjl139090 * properties needed below, use it instead of the 4861772Sjl139090 * cpu node. 4871772Sjl139090 */ 4881772Sjl139090 if ((GETPROP(cmpnode, "device_type", namebuf) > 0) && 4891772Sjl139090 (strcmp(namebuf, "core") == 0)) { 4901772Sjl139090 node = cmpnode; 4911772Sjl139090 } 4921772Sjl139090 } 4931772Sjl139090 4940Sstevel@tonic-gate (void) GETPROP(node, (cmpnode ? "compatible" : "name"), namebuf); 4955666Swh31274 4965666Swh31274 /* Make sure CPU name is within boundary and NULL terminated */ 4975666Swh31274 proplen = GETPROPLEN(node, (cmpnode ? "compatible" : "name")); 4985666Swh31274 ASSERT(proplen > 0 && proplen <= OBP_MAXPROPNAME); 4995666Swh31274 5005666Swh31274 if (proplen >= OBP_MAXPROPNAME) 5015666Swh31274 proplen = OBP_MAXPROPNAME - 1; 5025666Swh31274 5035666Swh31274 namebuf[proplen] = '\0'; 5045666Swh31274 5050Sstevel@tonic-gate namebufp = namebuf; 5060Sstevel@tonic-gate if (strncmp(namebufp, "SUNW,", 5) == 0) 5070Sstevel@tonic-gate namebufp += 5; 5081772Sjl139090 else if (strncmp(namebufp, "FJSV,", 5) == 0) 5091772Sjl139090 namebufp += 5; 5100Sstevel@tonic-gate (void) strcpy(cpunode->name, namebufp); 5110Sstevel@tonic-gate 5120Sstevel@tonic-gate (void) GETPROP(node, "implementation#", 5130Sstevel@tonic-gate (caddr_t)&cpunode->implementation); 5140Sstevel@tonic-gate (void) GETPROP(node, "mask#", (caddr_t)&cpunode->version); 5150Sstevel@tonic-gate 5160Sstevel@tonic-gate if (IS_CHEETAH(cpunode->implementation)) { 5170Sstevel@tonic-gate /* remap mask reg */ 5180Sstevel@tonic-gate cpunode->version = REMAP_CHEETAH_MASK(cpunode->version); 5190Sstevel@tonic-gate } 5200Sstevel@tonic-gate if (GETPROP(node, "clock-frequency", (caddr_t)&clk_freq) == -1) { 5210Sstevel@tonic-gate /* 5220Sstevel@tonic-gate * If we didn't find it in the CPU node, look in the root node. 5230Sstevel@tonic-gate */ 524789Sahrens pnode_t root = prom_nextnode((pnode_t)0); 5250Sstevel@tonic-gate if (GETPROP(root, "clock-frequency", (caddr_t)&clk_freq) == -1) 5260Sstevel@tonic-gate clk_freq = 0; 5270Sstevel@tonic-gate } 5280Sstevel@tonic-gate cpunode->clock_freq = clk_freq; 5290Sstevel@tonic-gate 5300Sstevel@tonic-gate ASSERT(cpunode->clock_freq != 0); 5310Sstevel@tonic-gate /* 5320Sstevel@tonic-gate * Compute scaling factor based on rate of %tick. This is used 5330Sstevel@tonic-gate * to convert from ticks derived from %tick to nanoseconds. See 5340Sstevel@tonic-gate * comment in sun4u/sys/clock.h for details. 5350Sstevel@tonic-gate */ 5360Sstevel@tonic-gate cpunode->tick_nsec_scale = (uint_t)(((uint64_t)NANOSEC << 5370Sstevel@tonic-gate (32 - TICK_NSEC_SHIFT)) / cpunode->clock_freq); 5380Sstevel@tonic-gate 5390Sstevel@tonic-gate (void) GETPROP(node, "#itlb-entries", (caddr_t)&tlbsize); 5400Sstevel@tonic-gate ASSERT(tlbsize < USHRT_MAX); /* since we cast it */ 5410Sstevel@tonic-gate cpunode->itlb_size = (ushort_t)tlbsize; 5420Sstevel@tonic-gate 5430Sstevel@tonic-gate (void) GETPROP(node, "#dtlb-entries", (caddr_t)&tlbsize); 5440Sstevel@tonic-gate ASSERT(tlbsize < USHRT_MAX); /* since we cast it */ 5450Sstevel@tonic-gate cpunode->dtlb_size = (ushort_t)tlbsize; 5460Sstevel@tonic-gate 5470Sstevel@tonic-gate if (cmpnode != OBP_NONODE) { 5480Sstevel@tonic-gate /* 5490Sstevel@tonic-gate * If the CPU has a level 3 cache, then it will be the 5500Sstevel@tonic-gate * external cache. Otherwise the level 2 cache is the 5510Sstevel@tonic-gate * external cache. 5520Sstevel@tonic-gate */ 5530Sstevel@tonic-gate size = 0; 5540Sstevel@tonic-gate (void) GETPROP(node, "l3-cache-size", (caddr_t)&size); 5550Sstevel@tonic-gate if (size <= 0) 5560Sstevel@tonic-gate (void) GETPROP(node, "l2-cache-size", (caddr_t)&size); 5570Sstevel@tonic-gate ASSERT(size != 0); 5580Sstevel@tonic-gate cpunode->ecache_size = size; 5590Sstevel@tonic-gate 5600Sstevel@tonic-gate size = 0; 5610Sstevel@tonic-gate (void) GETPROP(node, "l3-cache-line-size", (caddr_t)&size); 5620Sstevel@tonic-gate if (size <= 0) 5630Sstevel@tonic-gate (void) GETPROP(node, "l2-cache-line-size", 5640Sstevel@tonic-gate (caddr_t)&size); 5650Sstevel@tonic-gate ASSERT(size != 0); 5660Sstevel@tonic-gate cpunode->ecache_linesize = size; 5670Sstevel@tonic-gate 5680Sstevel@tonic-gate size = 0; 5690Sstevel@tonic-gate (void) GETPROP(node, "l2-cache-associativity", (caddr_t)&size); 5700Sstevel@tonic-gate ASSERT(size != 0); 5710Sstevel@tonic-gate cpunode->ecache_associativity = size; 5720Sstevel@tonic-gate 5730Sstevel@tonic-gate cmp_add_cpu(portid, cpuid); 5740Sstevel@tonic-gate } else { 5750Sstevel@tonic-gate size = 0; 5760Sstevel@tonic-gate (void) GETPROP(node, "ecache-size", (caddr_t)&size); 5770Sstevel@tonic-gate ASSERT(size != 0); 5780Sstevel@tonic-gate cpunode->ecache_size = size; 5790Sstevel@tonic-gate 5800Sstevel@tonic-gate size = 0; 5810Sstevel@tonic-gate (void) GETPROP(node, "ecache-line-size", (caddr_t)&size); 5820Sstevel@tonic-gate ASSERT(size != 0); 5830Sstevel@tonic-gate cpunode->ecache_linesize = size; 5840Sstevel@tonic-gate 5850Sstevel@tonic-gate size = 0; 5860Sstevel@tonic-gate (void) GETPROP(node, "ecache-associativity", (caddr_t)&size); 5870Sstevel@tonic-gate ASSERT(size != 0); 5880Sstevel@tonic-gate cpunode->ecache_associativity = size; 5890Sstevel@tonic-gate } 5900Sstevel@tonic-gate 5910Sstevel@tonic-gate /* by default set msram to non-mirrored one */ 5920Sstevel@tonic-gate cpunode->msram = ECACHE_CPU_NON_MIRROR; 5930Sstevel@tonic-gate 5940Sstevel@tonic-gate if (GETPROPLEN(node, "msram") != -1) { 5950Sstevel@tonic-gate cpunode->msram = ECACHE_CPU_MIRROR; 5960Sstevel@tonic-gate } 5970Sstevel@tonic-gate 5980Sstevel@tonic-gate if (GETPROPLEN(node, "msram-observed") != -1) { 5990Sstevel@tonic-gate cpunode->msram = ECACHE_CPU_MIRROR; 6000Sstevel@tonic-gate } 6010Sstevel@tonic-gate 6020Sstevel@tonic-gate if (ncpunode == 0) { 6030Sstevel@tonic-gate cpu_fiximp(node); 6040Sstevel@tonic-gate } 6050Sstevel@tonic-gate 6060Sstevel@tonic-gate cpunode->ecache_setsize = 6070Sstevel@tonic-gate cpunode->ecache_size / cpunode->ecache_associativity; 6080Sstevel@tonic-gate 6090Sstevel@tonic-gate adj_ecache_setsize(cpunode->ecache_setsize); 6100Sstevel@tonic-gate 6110Sstevel@tonic-gate ncpunode++; 6120Sstevel@tonic-gate } 6130Sstevel@tonic-gate 6140Sstevel@tonic-gate int 6150Sstevel@tonic-gate get_portid_ddi(dev_info_t *dip, dev_info_t **cmpp) 6160Sstevel@tonic-gate { 6170Sstevel@tonic-gate int portid; 6181772Sjl139090 int i; 6190Sstevel@tonic-gate char dev_type[OBP_MAXPROPNAME]; 6200Sstevel@tonic-gate int len = OBP_MAXPROPNAME; 6211772Sjl139090 dev_info_t *cpu_parent; 6220Sstevel@tonic-gate 6230Sstevel@tonic-gate if (cmpp != NULL) 6240Sstevel@tonic-gate *cmpp = NULL; 6250Sstevel@tonic-gate 6260Sstevel@tonic-gate if ((portid = ddi_prop_get_int(DDI_DEV_T_ANY, dip, 6271772Sjl139090 DDI_PROP_DONTPASS, "portid", -1)) != -1) 6280Sstevel@tonic-gate return (portid); 6290Sstevel@tonic-gate if ((portid = ddi_prop_get_int(DDI_DEV_T_ANY, dip, 6301772Sjl139090 DDI_PROP_DONTPASS, "upa-portid", -1)) != -1) 6310Sstevel@tonic-gate return (portid); 6320Sstevel@tonic-gate if (ddi_prop_op(DDI_DEV_T_ANY, dip, PROP_LEN_AND_VAL_BUF, 6331772Sjl139090 DDI_PROP_DONTPASS, "device_type", (caddr_t)dev_type, 6341772Sjl139090 &len) != 0) 6350Sstevel@tonic-gate return (-1); 6360Sstevel@tonic-gate 6371772Sjl139090 /* 6381772Sjl139090 * For a virtual cpu node that is a CMP core, the "portid" 6391772Sjl139090 * is in the parent node. 6401772Sjl139090 * For a virtual cpu node that is a CMT strand, the "portid" is 6411772Sjl139090 * in its grandparent node. 6421772Sjl139090 * So we iterate up as far as 2 levels to get the "portid". 6431772Sjl139090 */ 6440Sstevel@tonic-gate if (strcmp(dev_type, "cpu") == 0) { 6451772Sjl139090 cpu_parent = dip = ddi_get_parent(dip); 6461772Sjl139090 for (i = 0; dip != NULL && i < 2; i++) { 6471772Sjl139090 if ((portid = ddi_prop_get_int(DDI_DEV_T_ANY, dip, 6481772Sjl139090 DDI_PROP_DONTPASS, "portid", -1)) != -1) { 6491772Sjl139090 if (cmpp != NULL) 6501772Sjl139090 *cmpp = cpu_parent; 6511772Sjl139090 return (portid); 6521772Sjl139090 } 6531772Sjl139090 dip = ddi_get_parent(dip); 6540Sstevel@tonic-gate } 6550Sstevel@tonic-gate } 6560Sstevel@tonic-gate 6570Sstevel@tonic-gate return (-1); 6580Sstevel@tonic-gate } 6590Sstevel@tonic-gate 6600Sstevel@tonic-gate /* 6610Sstevel@tonic-gate * A hotplug version of fill_cpu(). (Doesn't assume that there's a node 6620Sstevel@tonic-gate * in the PROM device tree for this CPU.) We still need the PROM version 6630Sstevel@tonic-gate * since it is called very early in the boot cycle before (before 6640Sstevel@tonic-gate * setup_ddi()). Sigh...someday this will all be cleaned up. 6650Sstevel@tonic-gate */ 6660Sstevel@tonic-gate void 6670Sstevel@tonic-gate fill_cpu_ddi(dev_info_t *dip) 6680Sstevel@tonic-gate { 6690Sstevel@tonic-gate extern int cpu_get_cpu_unum(int, char *, int, int *); 6700Sstevel@tonic-gate struct cpu_node *cpunode; 6710Sstevel@tonic-gate processorid_t cpuid; 6720Sstevel@tonic-gate int portid; 6731772Sjl139090 int len = OBP_MAXPROPNAME; 6740Sstevel@tonic-gate int tlbsize; 6750Sstevel@tonic-gate dev_info_t *cmpnode; 6760Sstevel@tonic-gate char namebuf[OBP_MAXPROPNAME], unum[UNUM_NAMLEN]; 6770Sstevel@tonic-gate char *namebufp; 6781772Sjl139090 char dev_type[OBP_MAXPROPNAME]; 6790Sstevel@tonic-gate 6800Sstevel@tonic-gate if ((portid = get_portid_ddi(dip, &cmpnode)) == -1) { 6810Sstevel@tonic-gate cmn_err(CE_PANIC, "portid not found"); 6820Sstevel@tonic-gate } 6830Sstevel@tonic-gate 6840Sstevel@tonic-gate if ((cpuid = ddi_prop_get_int(DDI_DEV_T_ANY, dip, 6850Sstevel@tonic-gate DDI_PROP_DONTPASS, "cpuid", -1)) == -1) { 6860Sstevel@tonic-gate cpuid = portid; 6870Sstevel@tonic-gate } 6880Sstevel@tonic-gate 6890Sstevel@tonic-gate if (cpuid < 0 || cpuid >= NCPU) { 6900Sstevel@tonic-gate cmn_err(CE_PANIC, "cpu dip %p: cpuid %d out of range", 6915037Sjl139090 (void *)dip, cpuid); 6920Sstevel@tonic-gate return; 6930Sstevel@tonic-gate } 6940Sstevel@tonic-gate 6950Sstevel@tonic-gate cpunode = &cpunodes[cpuid]; 6960Sstevel@tonic-gate cpunode->portid = portid; 6971772Sjl139090 cpunode->nodeid = ddi_get_nodeid(dip); 6981772Sjl139090 6991772Sjl139090 if (cmpnode != NULL) { 7001772Sjl139090 /* 7011772Sjl139090 * For the CMT case, the parent "core" node contains 7021772Sjl139090 * properties needed below, use it instead of the 7031772Sjl139090 * cpu node. 7041772Sjl139090 */ 7051772Sjl139090 if ((ddi_prop_op(DDI_DEV_T_ANY, cmpnode, PROP_LEN_AND_VAL_BUF, 7061772Sjl139090 DDI_PROP_DONTPASS, "device_type", 7071772Sjl139090 (caddr_t)dev_type, &len) == DDI_PROP_SUCCESS) && 7081772Sjl139090 (strcmp(dev_type, "core") == 0)) 7091772Sjl139090 dip = cmpnode; 7101772Sjl139090 } 7110Sstevel@tonic-gate 7120Sstevel@tonic-gate if (cpu_get_cpu_unum(cpuid, unum, UNUM_NAMLEN, &len) != 0) { 7130Sstevel@tonic-gate cpunode->fru_fmri[0] = '\0'; 7140Sstevel@tonic-gate } else { 7150Sstevel@tonic-gate (void) snprintf(cpunode->fru_fmri, sizeof (cpunode->fru_fmri), 7160Sstevel@tonic-gate "%s%s", CPU_FRU_FMRI, unum); 7170Sstevel@tonic-gate } 7180Sstevel@tonic-gate 7190Sstevel@tonic-gate len = sizeof (namebuf); 7200Sstevel@tonic-gate (void) ddi_prop_op(DDI_DEV_T_ANY, dip, PROP_LEN_AND_VAL_BUF, 7210Sstevel@tonic-gate DDI_PROP_DONTPASS, (cmpnode ? "compatible" : "name"), 7220Sstevel@tonic-gate (caddr_t)namebuf, &len); 7230Sstevel@tonic-gate 7240Sstevel@tonic-gate namebufp = namebuf; 7250Sstevel@tonic-gate if (strncmp(namebufp, "SUNW,", 5) == 0) 7260Sstevel@tonic-gate namebufp += 5; 7271772Sjl139090 else if (strncmp(namebufp, "FJSV,", 5) == 0) 7281772Sjl139090 namebufp += 5; 7290Sstevel@tonic-gate (void) strcpy(cpunode->name, namebufp); 7300Sstevel@tonic-gate 7310Sstevel@tonic-gate cpunode->implementation = ddi_prop_get_int(DDI_DEV_T_ANY, dip, 7320Sstevel@tonic-gate DDI_PROP_DONTPASS, "implementation#", 0); 7330Sstevel@tonic-gate 7340Sstevel@tonic-gate cpunode->version = ddi_prop_get_int(DDI_DEV_T_ANY, dip, 7350Sstevel@tonic-gate DDI_PROP_DONTPASS, "mask#", 0); 7360Sstevel@tonic-gate 7370Sstevel@tonic-gate if (IS_CHEETAH(cpunode->implementation)) { 7380Sstevel@tonic-gate /* remap mask reg */ 7390Sstevel@tonic-gate cpunode->version = REMAP_CHEETAH_MASK(cpunode->version); 7400Sstevel@tonic-gate } 7410Sstevel@tonic-gate 7421772Sjl139090 cpunode->clock_freq = (uint32_t)ddi_prop_get_int(DDI_DEV_T_ANY, dip, 7430Sstevel@tonic-gate DDI_PROP_DONTPASS, "clock-frequency", 0); 7440Sstevel@tonic-gate 7450Sstevel@tonic-gate ASSERT(cpunode->clock_freq != 0); 7460Sstevel@tonic-gate /* 7470Sstevel@tonic-gate * Compute scaling factor based on rate of %tick. This is used 7480Sstevel@tonic-gate * to convert from ticks derived from %tick to nanoseconds. See 7490Sstevel@tonic-gate * comment in sun4u/sys/clock.h for details. 7500Sstevel@tonic-gate */ 7510Sstevel@tonic-gate cpunode->tick_nsec_scale = (uint_t)(((uint64_t)NANOSEC << 7520Sstevel@tonic-gate (32 - TICK_NSEC_SHIFT)) / cpunode->clock_freq); 7530Sstevel@tonic-gate 7540Sstevel@tonic-gate tlbsize = ddi_prop_get_int(DDI_DEV_T_ANY, dip, 7550Sstevel@tonic-gate DDI_PROP_DONTPASS, "#itlb-entries", 0); 7560Sstevel@tonic-gate ASSERT(tlbsize < USHRT_MAX); /* since we cast it */ 7570Sstevel@tonic-gate cpunode->itlb_size = (ushort_t)tlbsize; 7580Sstevel@tonic-gate 7590Sstevel@tonic-gate tlbsize = ddi_prop_get_int(DDI_DEV_T_ANY, dip, 7600Sstevel@tonic-gate DDI_PROP_DONTPASS, "#dtlb-entries", 0); 7610Sstevel@tonic-gate ASSERT(tlbsize < USHRT_MAX); /* since we cast it */ 7620Sstevel@tonic-gate cpunode->dtlb_size = (ushort_t)tlbsize; 7630Sstevel@tonic-gate 7640Sstevel@tonic-gate if (cmpnode != NULL) { 7650Sstevel@tonic-gate /* 7660Sstevel@tonic-gate * If the CPU has a level 3 cache, then that is it's 7670Sstevel@tonic-gate * external cache. Otherwise the external cache must 7680Sstevel@tonic-gate * be the level 2 cache. 7690Sstevel@tonic-gate */ 7700Sstevel@tonic-gate cpunode->ecache_size = ddi_prop_get_int(DDI_DEV_T_ANY, 7710Sstevel@tonic-gate dip, DDI_PROP_DONTPASS, "l3-cache-size", 0); 7720Sstevel@tonic-gate if (cpunode->ecache_size == 0) 7730Sstevel@tonic-gate cpunode->ecache_size = ddi_prop_get_int(DDI_DEV_T_ANY, 7740Sstevel@tonic-gate dip, DDI_PROP_DONTPASS, "l2-cache-size", 0); 7750Sstevel@tonic-gate ASSERT(cpunode->ecache_size != 0); 7760Sstevel@tonic-gate 7770Sstevel@tonic-gate cpunode->ecache_linesize = ddi_prop_get_int(DDI_DEV_T_ANY, 7780Sstevel@tonic-gate dip, DDI_PROP_DONTPASS, "l3-cache-line-size", 0); 7790Sstevel@tonic-gate if (cpunode->ecache_linesize == 0) 7800Sstevel@tonic-gate cpunode->ecache_linesize = 7810Sstevel@tonic-gate ddi_prop_get_int(DDI_DEV_T_ANY, dip, 7820Sstevel@tonic-gate DDI_PROP_DONTPASS, "l2-cache-line-size", 0); 7830Sstevel@tonic-gate ASSERT(cpunode->ecache_linesize != 0); 7840Sstevel@tonic-gate 7850Sstevel@tonic-gate cpunode->ecache_associativity = ddi_prop_get_int(DDI_DEV_T_ANY, 7860Sstevel@tonic-gate dip, DDI_PROP_DONTPASS, "l2-cache-associativity", 0); 7870Sstevel@tonic-gate ASSERT(cpunode->ecache_associativity != 0); 7880Sstevel@tonic-gate 7890Sstevel@tonic-gate cmp_add_cpu(portid, cpuid); 7900Sstevel@tonic-gate } else { 7910Sstevel@tonic-gate cpunode->ecache_size = ddi_prop_get_int(DDI_DEV_T_ANY, 7920Sstevel@tonic-gate dip, DDI_PROP_DONTPASS, "ecache-size", 0); 7930Sstevel@tonic-gate ASSERT(cpunode->ecache_size != 0); 7940Sstevel@tonic-gate 7950Sstevel@tonic-gate cpunode->ecache_linesize = ddi_prop_get_int(DDI_DEV_T_ANY, 7960Sstevel@tonic-gate dip, DDI_PROP_DONTPASS, "ecache-line-size", 0); 7970Sstevel@tonic-gate ASSERT(cpunode->ecache_linesize != 0); 7980Sstevel@tonic-gate 7990Sstevel@tonic-gate cpunode->ecache_associativity = ddi_prop_get_int(DDI_DEV_T_ANY, 8000Sstevel@tonic-gate dip, DDI_PROP_DONTPASS, "ecache-associativity", 0); 8010Sstevel@tonic-gate ASSERT(cpunode->ecache_associativity != 0); 8020Sstevel@tonic-gate } 8030Sstevel@tonic-gate 8040Sstevel@tonic-gate /* by default set msram to non-mirrored one */ 8050Sstevel@tonic-gate cpunode->msram = ECACHE_CPU_NON_MIRROR; 8060Sstevel@tonic-gate 8070Sstevel@tonic-gate if (ddi_prop_exists(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS, "msram")) { 8085037Sjl139090 cpunode->msram = ECACHE_CPU_MIRROR; 8090Sstevel@tonic-gate } else if (ddi_prop_exists(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS, 8105037Sjl139090 "msram-observed")) { 8115037Sjl139090 cpunode->msram = ECACHE_CPU_MIRROR; 8120Sstevel@tonic-gate } 8130Sstevel@tonic-gate 8140Sstevel@tonic-gate ASSERT(ncpunode > 0); /* fiximp not req'd */ 8150Sstevel@tonic-gate 8160Sstevel@tonic-gate cpunode->ecache_setsize = 8170Sstevel@tonic-gate cpunode->ecache_size / cpunode->ecache_associativity; 8180Sstevel@tonic-gate 8190Sstevel@tonic-gate adj_ecache_setsize(cpunode->ecache_setsize); 8200Sstevel@tonic-gate 8210Sstevel@tonic-gate ncpunode++; 8220Sstevel@tonic-gate } 8230Sstevel@tonic-gate 8240Sstevel@tonic-gate void 8250Sstevel@tonic-gate empty_cpu(int cpuid) 8260Sstevel@tonic-gate { 8270Sstevel@tonic-gate bzero(&cpunodes[cpuid], sizeof (struct cpu_node)); 8280Sstevel@tonic-gate ncpunode--; 8290Sstevel@tonic-gate } 8300Sstevel@tonic-gate 8310Sstevel@tonic-gate #ifdef SF_ERRATA_30 /* call causes fp-disabled */ 8320Sstevel@tonic-gate int spitfire_call_bug = 0; 8330Sstevel@tonic-gate #endif 8340Sstevel@tonic-gate #ifdef SF_V9_TABLE_28 /* fp over/underflow traps may cause wrong fsr.cexc */ 8350Sstevel@tonic-gate int spitfire_bb_fsr_bug = 0; 8360Sstevel@tonic-gate #endif 8370Sstevel@tonic-gate 8380Sstevel@tonic-gate #ifdef JALAPENO_ERRATA_85 8390Sstevel@tonic-gate /* 8400Sstevel@tonic-gate * Set the values here assuming we're running 2.4 or later Jalapenos. If 8410Sstevel@tonic-gate * not, they'll be reset below. Either way, the default can be overridden 8420Sstevel@tonic-gate * when we read /etc/system later in boot. 8430Sstevel@tonic-gate */ 8440Sstevel@tonic-gate int jp_errata_85_allow_slow_scrub = 1; 8450Sstevel@tonic-gate int jp_errata_85_enable = 0; 8460Sstevel@tonic-gate #endif /* JALAPENO_ERRATA_85 */ 8470Sstevel@tonic-gate 8480Sstevel@tonic-gate static void 8490Sstevel@tonic-gate check_cpus_ver(void) 8500Sstevel@tonic-gate { 8510Sstevel@tonic-gate int i; 8520Sstevel@tonic-gate int impl, cpuid = getprocessorid(); 8530Sstevel@tonic-gate int min_supported_rev; 8540Sstevel@tonic-gate 8550Sstevel@tonic-gate ASSERT(cpunodes[cpuid].nodeid != 0); 8560Sstevel@tonic-gate 8570Sstevel@tonic-gate impl = cpunodes[cpuid].implementation; 8580Sstevel@tonic-gate switch (impl) { 8590Sstevel@tonic-gate default: 8600Sstevel@tonic-gate min_supported_rev = 0; 8610Sstevel@tonic-gate break; 8620Sstevel@tonic-gate case SPITFIRE_IMPL: 8630Sstevel@tonic-gate min_supported_rev = SPITFIRE_MINREV_SUPPORTED; 8640Sstevel@tonic-gate break; 8650Sstevel@tonic-gate case CHEETAH_IMPL: 8660Sstevel@tonic-gate min_supported_rev = CHEETAH_MINREV_SUPPORTED; 8670Sstevel@tonic-gate break; 8680Sstevel@tonic-gate } 8690Sstevel@tonic-gate 8700Sstevel@tonic-gate for (i = 0; i < NCPU; i++) { 8710Sstevel@tonic-gate if (cpunodes[i].nodeid == 0) 8720Sstevel@tonic-gate continue; 8730Sstevel@tonic-gate 8740Sstevel@tonic-gate if (IS_SPITFIRE(impl)) { 8750Sstevel@tonic-gate if (cpunodes[i].version < min_supported_rev) { 8765037Sjl139090 cmn_err(CE_PANIC, "UltraSPARC versions older " 8775037Sjl139090 "than %d.%d are no longer supported " 8785037Sjl139090 "(cpu #%d)", 8795037Sjl139090 SPITFIRE_MAJOR_VERSION(min_supported_rev), 8805037Sjl139090 SPITFIRE_MINOR_VERSION(min_supported_rev), 8815037Sjl139090 i); 8820Sstevel@tonic-gate } 8830Sstevel@tonic-gate 8840Sstevel@tonic-gate /* 8850Sstevel@tonic-gate * Min supported rev is 2.1 but we've seen problems 8860Sstevel@tonic-gate * with that so we still want to warn if we see one. 8870Sstevel@tonic-gate */ 8880Sstevel@tonic-gate if (cpunodes[i].version < 0x22) { 8890Sstevel@tonic-gate cmn_err(CE_WARN, 8900Sstevel@tonic-gate "UltraSPARC versions older than " 8910Sstevel@tonic-gate "2.2 are not supported (cpu #%d)", i); 8920Sstevel@tonic-gate #ifdef SF_ERRATA_30 /* call causes fp-disabled */ 8930Sstevel@tonic-gate spitfire_call_bug = 1; 8940Sstevel@tonic-gate #endif /* SF_ERRATA_30 */ 8950Sstevel@tonic-gate } 8960Sstevel@tonic-gate } 8970Sstevel@tonic-gate 8980Sstevel@tonic-gate 8990Sstevel@tonic-gate #ifdef SF_V9_TABLE_28 /* fp over/underflow traps may cause wrong fsr.cexc */ 9000Sstevel@tonic-gate if (IS_SPITFIRE(impl) || IS_BLACKBIRD(impl)) 9010Sstevel@tonic-gate spitfire_bb_fsr_bug = 1; 9020Sstevel@tonic-gate #endif /* SF_V9_TABLE_28 */ 9030Sstevel@tonic-gate 9040Sstevel@tonic-gate if (IS_CHEETAH(impl)) { 9050Sstevel@tonic-gate if (cpunodes[i].version < min_supported_rev) { 9065037Sjl139090 cmn_err(CE_PANIC, "UltraSPARC-III versions " 9075037Sjl139090 "older than %d.%d are no longer supported " 9085037Sjl139090 "(cpu #%d)", 9095037Sjl139090 CHEETAH_MAJOR_VERSION(min_supported_rev), 9105037Sjl139090 CHEETAH_MINOR_VERSION(min_supported_rev), 9115037Sjl139090 i); 9120Sstevel@tonic-gate } 9130Sstevel@tonic-gate 9140Sstevel@tonic-gate } 9150Sstevel@tonic-gate 9160Sstevel@tonic-gate #ifdef JALAPENO_ERRATA_85 9170Sstevel@tonic-gate if (IS_JALAPENO(impl) && (cpunodes[i].version < 0x24)) { 9180Sstevel@tonic-gate jp_errata_85_allow_slow_scrub = 0; 9190Sstevel@tonic-gate jp_errata_85_enable = 1; 9200Sstevel@tonic-gate } 9210Sstevel@tonic-gate #endif /* JALAPENO_ERRATA_85 */ 9220Sstevel@tonic-gate } 9230Sstevel@tonic-gate } 9240Sstevel@tonic-gate 9250Sstevel@tonic-gate /* 9260Sstevel@tonic-gate * Check for a legal set of CPUs. 9270Sstevel@tonic-gate */ 9280Sstevel@tonic-gate static void 9290Sstevel@tonic-gate check_cpus_set(void) 9300Sstevel@tonic-gate { 9310Sstevel@tonic-gate int i; 9320Sstevel@tonic-gate int impl; 9330Sstevel@tonic-gate int npanther = 0; 9345037Sjl139090 int njupiter = 0; 9350Sstevel@tonic-gate 9360Sstevel@tonic-gate impl = cpunodes[getprocessorid()].implementation; 9370Sstevel@tonic-gate 9380Sstevel@tonic-gate switch (impl) { 9390Sstevel@tonic-gate case CHEETAH_PLUS_IMPL: 9400Sstevel@tonic-gate case JAGUAR_IMPL: 9410Sstevel@tonic-gate case PANTHER_IMPL: 9420Sstevel@tonic-gate /* 9430Sstevel@tonic-gate * Check for a legal heterogeneous set of CPUs. 9440Sstevel@tonic-gate */ 9450Sstevel@tonic-gate for (i = 0; i < NCPU; i++) { 9460Sstevel@tonic-gate if (cpunodes[i].nodeid == 0) 9470Sstevel@tonic-gate continue; 9480Sstevel@tonic-gate 9490Sstevel@tonic-gate if (IS_PANTHER(cpunodes[i].implementation)) { 9500Sstevel@tonic-gate npanther += 1; 9510Sstevel@tonic-gate } 9520Sstevel@tonic-gate 9530Sstevel@tonic-gate if (!(IS_CHEETAH_PLUS(cpunodes[i].implementation) || 9540Sstevel@tonic-gate IS_JAGUAR(cpunodes[i].implementation) || 9550Sstevel@tonic-gate IS_PANTHER(cpunodes[i].implementation))) { 9560Sstevel@tonic-gate use_mp = 0; 9570Sstevel@tonic-gate break; 9580Sstevel@tonic-gate } 9590Sstevel@tonic-gate } 9600Sstevel@tonic-gate break; 9615037Sjl139090 case OLYMPUS_C_IMPL: 9625037Sjl139090 case JUPITER_IMPL: 9635037Sjl139090 /* 9645037Sjl139090 * Check for a legal heterogeneous set of CPUs on the 9655037Sjl139090 * OPL platform. 9665037Sjl139090 */ 9675037Sjl139090 for (i = 0; i < NCPU; i++) { 9685037Sjl139090 if (cpunodes[i].nodeid == 0) 9695037Sjl139090 continue; 9705037Sjl139090 9715037Sjl139090 if (IS_JUPITER(cpunodes[i].implementation)) { 9725037Sjl139090 njupiter += 1; 9735037Sjl139090 } 9745037Sjl139090 if (!(IS_OLYMPUS_C(cpunodes[i].implementation) || 9755037Sjl139090 IS_JUPITER(cpunodes[i].implementation))) { 9765037Sjl139090 use_mp = 0; 9775037Sjl139090 break; 9785037Sjl139090 } 9795037Sjl139090 } 9805037Sjl139090 break; 9810Sstevel@tonic-gate default: 9820Sstevel@tonic-gate /* 9830Sstevel@tonic-gate * Check for a homogeneous set of CPUs. 9840Sstevel@tonic-gate */ 9850Sstevel@tonic-gate for (i = 0; i < NCPU; i++) { 9860Sstevel@tonic-gate if (cpunodes[i].nodeid == 0) 9870Sstevel@tonic-gate continue; 9880Sstevel@tonic-gate 9890Sstevel@tonic-gate if (cpunodes[i].implementation != impl) { 9900Sstevel@tonic-gate use_mp = 0; 9910Sstevel@tonic-gate break; 9920Sstevel@tonic-gate } 9930Sstevel@tonic-gate } 9940Sstevel@tonic-gate break; 9950Sstevel@tonic-gate } 9960Sstevel@tonic-gate 9970Sstevel@tonic-gate /* 9980Sstevel@tonic-gate * Change from mmu_page_sizes from 4 to 6 for totally-Panther domains, 999106Ssusans * where npanther == ncpunode. Also, set ecache_alignsize (and a few 1000106Ssusans * other globals) to the correct value for totally-Panther domains. 10010Sstevel@tonic-gate */ 10020Sstevel@tonic-gate if (&mmu_init_mmu_page_sizes) { 10030Sstevel@tonic-gate (void) mmu_init_mmu_page_sizes(npanther); 10040Sstevel@tonic-gate } 1005106Ssusans if ((npanther == ncpunode) && (&cpu_fix_allpanther)) { 1006106Ssusans cpu_fix_allpanther(); 1007106Ssusans } 10080Sstevel@tonic-gate 10090Sstevel@tonic-gate /* 10105037Sjl139090 * For all-Jupiter domains the cpu module will update the hwcap features 10115037Sjl139090 * for integer multiply-add instruction support. 10125037Sjl139090 */ 10135037Sjl139090 if ((njupiter == ncpunode) && (&cpu_fix_alljupiter)) { 10145037Sjl139090 cpu_fix_alljupiter(); 10155037Sjl139090 } 10165037Sjl139090 10175037Sjl139090 /* 10180Sstevel@tonic-gate * Set max cpus we can have based on ncpunode and use_mp 10190Sstevel@tonic-gate */ 10200Sstevel@tonic-gate if (use_mp) { 10210Sstevel@tonic-gate int (*set_max_ncpus)(void); 10220Sstevel@tonic-gate 10230Sstevel@tonic-gate set_max_ncpus = (int (*)(void)) 10245037Sjl139090 kobj_getsymvalue("set_platform_max_ncpus", 0); 10250Sstevel@tonic-gate 10260Sstevel@tonic-gate if (set_max_ncpus) { 10270Sstevel@tonic-gate max_ncpus = set_max_ncpus(); 10280Sstevel@tonic-gate if (max_ncpus < ncpunode) 10290Sstevel@tonic-gate max_ncpus = ncpunode; 1030*6880Sdv142724 boot_ncpus = boot_max_ncpus = ncpunode; 10310Sstevel@tonic-gate } else { 10320Sstevel@tonic-gate max_ncpus = ncpunode; 10330Sstevel@tonic-gate } 10340Sstevel@tonic-gate } else { 10350Sstevel@tonic-gate cmn_err(CE_NOTE, "MP not supported on mismatched modules," 10360Sstevel@tonic-gate " booting UP only"); 10370Sstevel@tonic-gate 10380Sstevel@tonic-gate for (i = 0; i < NCPU; i++) { 10390Sstevel@tonic-gate if (cpunodes[i].nodeid == 0) 10400Sstevel@tonic-gate continue; 10410Sstevel@tonic-gate 10420Sstevel@tonic-gate cmn_err(CE_NOTE, "cpu%d: %s version 0x%x", i, 10430Sstevel@tonic-gate cpunodes[i].name, cpunodes[i].version); 10440Sstevel@tonic-gate } 10450Sstevel@tonic-gate 10460Sstevel@tonic-gate max_ncpus = 1; 10470Sstevel@tonic-gate } 10480Sstevel@tonic-gate } 10490Sstevel@tonic-gate 10500Sstevel@tonic-gate /* 10510Sstevel@tonic-gate * The first sysio must always programmed up for the system clock and error 10520Sstevel@tonic-gate * handling purposes, referenced by v_sysio_addr in machdep.c. 10530Sstevel@tonic-gate */ 10540Sstevel@tonic-gate static void 1055789Sahrens have_sbus(pnode_t node) 10560Sstevel@tonic-gate { 10570Sstevel@tonic-gate int size; 10580Sstevel@tonic-gate uint_t portid; 10590Sstevel@tonic-gate 10600Sstevel@tonic-gate size = GETPROPLEN(node, "upa-portid"); 10610Sstevel@tonic-gate if (size == -1 || size > sizeof (portid)) 10620Sstevel@tonic-gate cmn_err(CE_PANIC, "upa-portid size"); 10630Sstevel@tonic-gate if (GETPROP(node, "upa-portid", (caddr_t)&portid) == -1) 10640Sstevel@tonic-gate cmn_err(CE_PANIC, "upa-portid"); 10650Sstevel@tonic-gate 10660Sstevel@tonic-gate niobus++; 10670Sstevel@tonic-gate 10680Sstevel@tonic-gate /* 10690Sstevel@tonic-gate * need one physical TSB 10700Sstevel@tonic-gate */ 10710Sstevel@tonic-gate niommu_tsbs++; 10720Sstevel@tonic-gate } 10730Sstevel@tonic-gate 10740Sstevel@tonic-gate 10750Sstevel@tonic-gate #define IOMMU_PER_SCHIZO 2 10760Sstevel@tonic-gate 10770Sstevel@tonic-gate /* 10780Sstevel@tonic-gate * The first psycho must always programmed up for the system clock and error 10790Sstevel@tonic-gate * handling purposes. 10800Sstevel@tonic-gate */ 10810Sstevel@tonic-gate static void 1082789Sahrens have_pci(pnode_t node) 10830Sstevel@tonic-gate { 10840Sstevel@tonic-gate int size; 10850Sstevel@tonic-gate uint_t portid; 10860Sstevel@tonic-gate char compatible[OBP_MAXDRVNAME]; 10870Sstevel@tonic-gate 10880Sstevel@tonic-gate size = GETPROPLEN(node, "portid"); 10890Sstevel@tonic-gate if (size == -1) size = GETPROPLEN(node, "upa-portid"); 10900Sstevel@tonic-gate if (size == -1) 10910Sstevel@tonic-gate return; 10920Sstevel@tonic-gate if (size > sizeof (portid)) 10930Sstevel@tonic-gate cmn_err(CE_PANIC, "portid size wrong"); 10940Sstevel@tonic-gate 10950Sstevel@tonic-gate if (GETPROP(node, "portid", (caddr_t)&portid) == -1) 10960Sstevel@tonic-gate if (GETPROP(node, "upa-portid", (caddr_t)&portid) == -1) 10970Sstevel@tonic-gate cmn_err(CE_PANIC, "portid not found"); 10980Sstevel@tonic-gate 10990Sstevel@tonic-gate niobus++; 11000Sstevel@tonic-gate 11010Sstevel@tonic-gate 11020Sstevel@tonic-gate /* 11030Sstevel@tonic-gate * Need two physical TSBs for Schizo compatible nodes, 11040Sstevel@tonic-gate * one otherwise. 11050Sstevel@tonic-gate */ 11060Sstevel@tonic-gate compatible[0] = '\0'; 11070Sstevel@tonic-gate (void) prom_getprop(node, OBP_COMPATIBLE, compatible); 11080Sstevel@tonic-gate if (strcmp(compatible, "pci108e,8001") == 0) 11090Sstevel@tonic-gate niommu_tsbs += IOMMU_PER_SCHIZO; 11100Sstevel@tonic-gate else 11110Sstevel@tonic-gate niommu_tsbs++; 11120Sstevel@tonic-gate } 11130Sstevel@tonic-gate 11140Sstevel@tonic-gate /* 11150Sstevel@tonic-gate * The first eeprom is used as the TOD clock, referenced 11160Sstevel@tonic-gate * by v_eeprom_addr in locore.s. 11170Sstevel@tonic-gate */ 11180Sstevel@tonic-gate static void 1119789Sahrens have_eeprom(pnode_t node) 11200Sstevel@tonic-gate { 11210Sstevel@tonic-gate int size; 11220Sstevel@tonic-gate uint32_t eaddr; 11230Sstevel@tonic-gate 11240Sstevel@tonic-gate /* 11250Sstevel@tonic-gate * "todmostek" module will be selected based on finding a "model" 11260Sstevel@tonic-gate * property value of "mk48t59" in the "eeprom" node. 11270Sstevel@tonic-gate */ 11280Sstevel@tonic-gate if (tod_module_name == NULL) { 11290Sstevel@tonic-gate char buf[MAXSYSNAME]; 11300Sstevel@tonic-gate 11310Sstevel@tonic-gate if ((GETPROP(node, "model", buf) != -1) && 11320Sstevel@tonic-gate (strcmp(buf, "mk48t59") == 0)) 11330Sstevel@tonic-gate tod_module_name = "todmostek"; 11340Sstevel@tonic-gate } 11350Sstevel@tonic-gate 11360Sstevel@tonic-gate /* 11370Sstevel@tonic-gate * If we have found two distinct eeprom's, then we're done. 11380Sstevel@tonic-gate */ 11390Sstevel@tonic-gate if (v_eeprom_addr && v_timecheck_addr != v_eeprom_addr) 11400Sstevel@tonic-gate return; 11410Sstevel@tonic-gate 11420Sstevel@tonic-gate /* 11430Sstevel@tonic-gate * multiple eeproms may exist but at least 11440Sstevel@tonic-gate * one must have an "address" property 11450Sstevel@tonic-gate */ 11460Sstevel@tonic-gate if ((size = GETPROPLEN(node, OBP_ADDRESS)) == -1) 11470Sstevel@tonic-gate return; 11480Sstevel@tonic-gate if (size != sizeof (eaddr)) 11490Sstevel@tonic-gate cmn_err(CE_PANIC, "eeprom addr size"); 11500Sstevel@tonic-gate if (GETPROP(node, OBP_ADDRESS, (caddr_t)&eaddr) == -1) 11510Sstevel@tonic-gate cmn_err(CE_PANIC, "eeprom addr"); 11520Sstevel@tonic-gate 11530Sstevel@tonic-gate /* 11540Sstevel@tonic-gate * If we have a chosen eeprom and it is not this node, keep looking. 11550Sstevel@tonic-gate */ 11560Sstevel@tonic-gate if (chosen_eeprom != NULL && chosen_eeprom != node) { 1157501Sesolom v_timecheck_addr = (caddr_t)(uintptr_t)eaddr; 11580Sstevel@tonic-gate return; 11590Sstevel@tonic-gate } 11600Sstevel@tonic-gate 1161501Sesolom v_eeprom_addr = (caddr_t)(uintptr_t)eaddr; 11620Sstevel@tonic-gate 11630Sstevel@tonic-gate /* 11640Sstevel@tonic-gate * If we don't find an I/O board to use to check the clock, 11650Sstevel@tonic-gate * we'll fall back on whichever TOD is available. 11660Sstevel@tonic-gate */ 11670Sstevel@tonic-gate if (v_timecheck_addr == NULL) 11680Sstevel@tonic-gate v_timecheck_addr = v_eeprom_addr; 11690Sstevel@tonic-gate 11700Sstevel@tonic-gate /* 11710Sstevel@tonic-gate * Does this eeprom have watchdog support? 11720Sstevel@tonic-gate */ 11730Sstevel@tonic-gate if (GETPROPLEN(node, WATCHDOG_ENABLE) != -1) 11740Sstevel@tonic-gate watchdog_available = 1; 11750Sstevel@tonic-gate } 11760Sstevel@tonic-gate 11770Sstevel@tonic-gate static void 1178789Sahrens have_rtc(pnode_t node) 11790Sstevel@tonic-gate { 11800Sstevel@tonic-gate int size; 11810Sstevel@tonic-gate uint32_t eaddr; 11820Sstevel@tonic-gate 11830Sstevel@tonic-gate /* 11840Sstevel@tonic-gate * "ds1287" module will be selected based on finding a "model" 11850Sstevel@tonic-gate * property value of "ds1287" in the "rtc" node. 11860Sstevel@tonic-gate */ 11870Sstevel@tonic-gate if (tod_module_name == NULL) { 11880Sstevel@tonic-gate char buf[MAXSYSNAME]; 11890Sstevel@tonic-gate 11900Sstevel@tonic-gate if (GETPROP(node, "model", buf) != -1) { 11910Sstevel@tonic-gate if ((strcmp(buf, "m5819p") == 0) || 11920Sstevel@tonic-gate (strcmp(buf, "m5823") == 0)) 11935037Sjl139090 tod_module_name = "todm5823"; 11940Sstevel@tonic-gate else if (strcmp(buf, "ds1287") == 0) 11955037Sjl139090 tod_module_name = "todds1287"; 11960Sstevel@tonic-gate } 11970Sstevel@tonic-gate } 11980Sstevel@tonic-gate 11990Sstevel@tonic-gate /* 12000Sstevel@tonic-gate * XXX - drives on if address prop doesn't exist, later falls 12010Sstevel@tonic-gate * over in tod module 12020Sstevel@tonic-gate */ 12030Sstevel@tonic-gate if ((size = GETPROPLEN(node, OBP_ADDRESS)) == -1) 12040Sstevel@tonic-gate return; 12050Sstevel@tonic-gate if (size != sizeof (eaddr)) 12060Sstevel@tonic-gate cmn_err(CE_PANIC, "rtc addr size"); 12070Sstevel@tonic-gate if (GETPROP(node, OBP_ADDRESS, (caddr_t)&eaddr) == -1) 12080Sstevel@tonic-gate cmn_err(CE_PANIC, "rtc addr"); 12090Sstevel@tonic-gate 1210501Sesolom v_rtc_addr_reg = (caddr_t)(uintptr_t)eaddr; 1211501Sesolom v_rtc_data_reg = (volatile unsigned char *)(uintptr_t)eaddr + 1; 12120Sstevel@tonic-gate 12130Sstevel@tonic-gate /* 12140Sstevel@tonic-gate * Does this rtc have watchdog support? 12150Sstevel@tonic-gate */ 12160Sstevel@tonic-gate if (GETPROPLEN(node, WATCHDOG_ENABLE) != -1) 12170Sstevel@tonic-gate watchdog_available = 1; 12180Sstevel@tonic-gate } 12190Sstevel@tonic-gate 12200Sstevel@tonic-gate static void 1221789Sahrens have_pmc(pnode_t node) 12220Sstevel@tonic-gate { 12230Sstevel@tonic-gate uint32_t vaddr; 1224789Sahrens pnode_t root; 12250Sstevel@tonic-gate 12260Sstevel@tonic-gate /* 12270Sstevel@tonic-gate * Watchdog property is in the root node. 12280Sstevel@tonic-gate */ 1229789Sahrens root = prom_nextnode((pnode_t)0); 12300Sstevel@tonic-gate if (GETPROPLEN(root, WATCHDOG_ENABLE) != -1) { 12310Sstevel@tonic-gate /* 12320Sstevel@tonic-gate * The hardware watchdog timer resides within logical 12330Sstevel@tonic-gate * unit 8 of SuperI/O. The address property of the node 12340Sstevel@tonic-gate * contains the virtual address that we use to program 12350Sstevel@tonic-gate * the timer. 12360Sstevel@tonic-gate */ 12370Sstevel@tonic-gate if (GETPROP(node, OBP_ADDRESS, (caddr_t)&vaddr) == -1) { 12380Sstevel@tonic-gate watchdog_available = 0; 12390Sstevel@tonic-gate return; 12400Sstevel@tonic-gate } 1241501Sesolom v_pmc_addr_reg = (volatile uint8_t *)(uintptr_t)vaddr; 1242501Sesolom v_pmc_data_reg = (volatile uint8_t *)(uintptr_t)vaddr + 1; 12430Sstevel@tonic-gate watchdog_available = 1; 12440Sstevel@tonic-gate } 12450Sstevel@tonic-gate } 12460Sstevel@tonic-gate 12470Sstevel@tonic-gate static void 1248789Sahrens have_auxio(pnode_t node) 12490Sstevel@tonic-gate { 12500Sstevel@tonic-gate size_t size, n; 12510Sstevel@tonic-gate uint32_t addr[5]; 12520Sstevel@tonic-gate 12530Sstevel@tonic-gate /* 12540Sstevel@tonic-gate * Get the size of the auzio's address property. 12550Sstevel@tonic-gate * On some platforms, the address property contains one 12560Sstevel@tonic-gate * entry and on others it contains five entries. 12570Sstevel@tonic-gate * In all cases, the first entries are compatible. 12580Sstevel@tonic-gate * 12590Sstevel@tonic-gate * This routine gets the address property for the auxio 12600Sstevel@tonic-gate * node and stores the first entry in v_auxio_addr which 12610Sstevel@tonic-gate * is used by the routine set_auxioreg in sun4u/ml/locore.s. 12620Sstevel@tonic-gate */ 12630Sstevel@tonic-gate if ((size = GETPROPLEN(node, OBP_ADDRESS)) == -1) 12640Sstevel@tonic-gate cmn_err(CE_PANIC, "no auxio address property"); 12650Sstevel@tonic-gate 12660Sstevel@tonic-gate switch (n = (size / sizeof (addr[0]))) { 12670Sstevel@tonic-gate case 1: 12680Sstevel@tonic-gate break; 12690Sstevel@tonic-gate case 5: 12700Sstevel@tonic-gate break; 12710Sstevel@tonic-gate default: 12720Sstevel@tonic-gate cmn_err(CE_PANIC, "auxio addr has %lu entries?", n); 12730Sstevel@tonic-gate } 12740Sstevel@tonic-gate 12750Sstevel@tonic-gate if (GETPROP(node, OBP_ADDRESS, (caddr_t)addr) == -1) 12760Sstevel@tonic-gate cmn_err(CE_PANIC, "auxio addr"); 12770Sstevel@tonic-gate 1278501Sesolom v_auxio_addr = (caddr_t)(uintptr_t)(addr[0]); /* make into pointer */ 12790Sstevel@tonic-gate } 12800Sstevel@tonic-gate 12810Sstevel@tonic-gate static void 1282789Sahrens have_tod(pnode_t node) 12830Sstevel@tonic-gate { 12840Sstevel@tonic-gate static char tod_name[MAXSYSNAME]; 12850Sstevel@tonic-gate 12860Sstevel@tonic-gate if (GETPROP(node, OBP_NAME, (caddr_t)tod_name) == -1) 12870Sstevel@tonic-gate cmn_err(CE_PANIC, "tod name"); 12880Sstevel@tonic-gate /* 12890Sstevel@tonic-gate * This is a node with "device_type" property value of "tod". 12900Sstevel@tonic-gate * Name of the tod module is the name from the node. 12910Sstevel@tonic-gate */ 12920Sstevel@tonic-gate tod_module_name = tod_name; 12930Sstevel@tonic-gate } 1294