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 5*25cf1a30Sjl139090 * Common Development and Distribution License (the "License"). 6*25cf1a30Sjl139090 * 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 /* 22*25cf1a30Sjl139090 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate #include <sys/errno.h> 297c478bd9Sstevel@tonic-gate #include <sys/types.h> 307c478bd9Sstevel@tonic-gate #include <sys/param.h> 317c478bd9Sstevel@tonic-gate #include <sys/cpu.h> 327c478bd9Sstevel@tonic-gate #include <sys/cpuvar.h> 337c478bd9Sstevel@tonic-gate #include <sys/clock.h> 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #include <sys/promif.h> 367c478bd9Sstevel@tonic-gate #include <sys/promimpl.h> 377c478bd9Sstevel@tonic-gate #include <sys/systm.h> 387c478bd9Sstevel@tonic-gate #include <sys/machsystm.h> 397c478bd9Sstevel@tonic-gate #include <sys/debug.h> 407c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 417c478bd9Sstevel@tonic-gate #include <sys/modctl.h> 427c478bd9Sstevel@tonic-gate #include <sys/spitregs.h> 437c478bd9Sstevel@tonic-gate #include <sys/cheetahregs.h> 447c478bd9Sstevel@tonic-gate #include <sys/cpu_module.h> 457c478bd9Sstevel@tonic-gate #include <sys/kobj.h> 467c478bd9Sstevel@tonic-gate #include <sys/cmp.h> 477c478bd9Sstevel@tonic-gate #include <sys/async.h> 487c478bd9Sstevel@tonic-gate #include <vm/page.h> 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate /* 517c478bd9Sstevel@tonic-gate * The OpenBoot Standalone Interface supplies the kernel with 527c478bd9Sstevel@tonic-gate * implementation dependent parameters through the devinfo/property mechanism 537c478bd9Sstevel@tonic-gate */ 547c478bd9Sstevel@tonic-gate typedef enum { XDRBOOL, XDRINT, XDRSTRING } xdrs; 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate /* 577c478bd9Sstevel@tonic-gate * structure describing properties that we are interested in querying the 587c478bd9Sstevel@tonic-gate * OBP for. 597c478bd9Sstevel@tonic-gate */ 607c478bd9Sstevel@tonic-gate struct getprop_info { 617c478bd9Sstevel@tonic-gate char *name; 627c478bd9Sstevel@tonic-gate xdrs type; 637c478bd9Sstevel@tonic-gate uint_t *var; 647c478bd9Sstevel@tonic-gate }; 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate /* 677c478bd9Sstevel@tonic-gate * structure used to convert between a string returned by the OBP & a type 687c478bd9Sstevel@tonic-gate * used within the kernel. We prefer to paramaterize rather than type. 697c478bd9Sstevel@tonic-gate */ 707c478bd9Sstevel@tonic-gate struct convert_info { 717c478bd9Sstevel@tonic-gate char *name; 727c478bd9Sstevel@tonic-gate uint_t var; 737c478bd9Sstevel@tonic-gate char *realname; 747c478bd9Sstevel@tonic-gate }; 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate /* 777c478bd9Sstevel@tonic-gate * structure describing nodes that we are interested in querying the OBP for 787c478bd9Sstevel@tonic-gate * properties. 797c478bd9Sstevel@tonic-gate */ 807c478bd9Sstevel@tonic-gate struct node_info { 817c478bd9Sstevel@tonic-gate char *name; 827c478bd9Sstevel@tonic-gate int size; 837c478bd9Sstevel@tonic-gate struct getprop_info *prop; 847c478bd9Sstevel@tonic-gate struct getprop_info *prop_end; 857c478bd9Sstevel@tonic-gate unsigned int *value; 867c478bd9Sstevel@tonic-gate }; 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate /* 897c478bd9Sstevel@tonic-gate * macro definitions for routines that form the OBP interface 907c478bd9Sstevel@tonic-gate */ 917c478bd9Sstevel@tonic-gate #define NEXT prom_nextnode 927c478bd9Sstevel@tonic-gate #define CHILD prom_childnode 937c478bd9Sstevel@tonic-gate #define GETPROP prom_getprop 947c478bd9Sstevel@tonic-gate #define GETPROPLEN prom_getproplen 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate /* 0=quiet; 1=verbose; 2=debug */ 987c478bd9Sstevel@tonic-gate int debug_fillsysinfo = 0; 997c478bd9Sstevel@tonic-gate #define VPRINTF if (debug_fillsysinfo) prom_printf 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate int ncpunode; 1027c478bd9Sstevel@tonic-gate struct cpu_node cpunodes[NCPU]; 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate static void check_cpus_ver(void); 1057c478bd9Sstevel@tonic-gate static void check_cpus_set(void); 106fa9e4066Sahrens void fill_cpu(pnode_t); 1077c478bd9Sstevel@tonic-gate void fill_cpu_ddi(dev_info_t *); 1087c478bd9Sstevel@tonic-gate void empty_cpu(int); 109fa9e4066Sahrens void plat_fill_mc(pnode_t); 1107c478bd9Sstevel@tonic-gate #pragma weak plat_fill_mc 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate uint64_t system_clock_freq; 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate /* 1157c478bd9Sstevel@tonic-gate * list of well known devices that must be mapped, and the variables that 1167c478bd9Sstevel@tonic-gate * contain their addresses. 1177c478bd9Sstevel@tonic-gate */ 1187c478bd9Sstevel@tonic-gate caddr_t v_auxio_addr = NULL; 1197c478bd9Sstevel@tonic-gate caddr_t v_eeprom_addr = NULL; 1207c478bd9Sstevel@tonic-gate caddr_t v_timecheck_addr = NULL; 1217c478bd9Sstevel@tonic-gate caddr_t v_rtc_addr_reg = NULL; 1227c478bd9Sstevel@tonic-gate volatile unsigned char *v_rtc_data_reg = NULL; 1237c478bd9Sstevel@tonic-gate volatile uint8_t *v_pmc_addr_reg = NULL; 1247c478bd9Sstevel@tonic-gate volatile uint8_t *v_pmc_data_reg = NULL; 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate int niobus = 0; 1277c478bd9Sstevel@tonic-gate uint_t niommu_tsbs = 0; 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate /* 1307c478bd9Sstevel@tonic-gate * Hardware watchdog support. 1317c478bd9Sstevel@tonic-gate */ 1327c478bd9Sstevel@tonic-gate #define CHOSEN_EEPROM "eeprom" 1337c478bd9Sstevel@tonic-gate #define WATCHDOG_ENABLE "watchdog-enable" 134fa9e4066Sahrens static pnode_t chosen_eeprom; 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate /* 1377c478bd9Sstevel@tonic-gate * Appropriate tod module will be dynamically selected while booting 1387c478bd9Sstevel@tonic-gate * based on finding a device tree node with a "device_type" property value 1397c478bd9Sstevel@tonic-gate * of "tod". If such a node describing tod is not found, for backward 1407c478bd9Sstevel@tonic-gate * compatibility, a node with a "name" property value of "eeprom" and 1417c478bd9Sstevel@tonic-gate * "model" property value of "mk48t59" will be used. Failing to find a 1427c478bd9Sstevel@tonic-gate * node matching either of the above criteria will result in no tod module 1437c478bd9Sstevel@tonic-gate * being selected; this will cause the boot process to halt. 1447c478bd9Sstevel@tonic-gate */ 1457c478bd9Sstevel@tonic-gate char *tod_module_name; 1467c478bd9Sstevel@tonic-gate 1477c478bd9Sstevel@tonic-gate /* 1487c478bd9Sstevel@tonic-gate * If this variable is non-zero, cpr should return "not supported" when 1497c478bd9Sstevel@tonic-gate * it is queried even though it would normally be supported on this platform. 1507c478bd9Sstevel@tonic-gate */ 1517c478bd9Sstevel@tonic-gate int cpr_supported_override; 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gate /* 1547c478bd9Sstevel@tonic-gate * Some platforms may need to support CPR even in the absence of the 1557c478bd9Sstevel@tonic-gate * energystar-v* property (Enchilada server, for example). If this 1567c478bd9Sstevel@tonic-gate * variable is non-zero, cpr should proceed even in the absence 1577c478bd9Sstevel@tonic-gate * of the energystar-v* property. 1587c478bd9Sstevel@tonic-gate */ 1597c478bd9Sstevel@tonic-gate int cpr_platform_enable = 0; 1607c478bd9Sstevel@tonic-gate 1617c478bd9Sstevel@tonic-gate /* 1627c478bd9Sstevel@tonic-gate * Some nodes have functions that need to be called when they're seen. 1637c478bd9Sstevel@tonic-gate */ 164fa9e4066Sahrens static void have_sbus(pnode_t); 165fa9e4066Sahrens static void have_pci(pnode_t); 166fa9e4066Sahrens static void have_eeprom(pnode_t); 167fa9e4066Sahrens static void have_auxio(pnode_t); 168fa9e4066Sahrens static void have_rtc(pnode_t); 169fa9e4066Sahrens static void have_tod(pnode_t); 170fa9e4066Sahrens static void have_pmc(pnode_t); 1717c478bd9Sstevel@tonic-gate 1727c478bd9Sstevel@tonic-gate static struct wkdevice { 1737c478bd9Sstevel@tonic-gate char *wk_namep; 174fa9e4066Sahrens void (*wk_func)(pnode_t); 1757c478bd9Sstevel@tonic-gate caddr_t *wk_vaddrp; 1767c478bd9Sstevel@tonic-gate ushort_t wk_flags; 1777c478bd9Sstevel@tonic-gate #define V_OPTIONAL 0x0000 1787c478bd9Sstevel@tonic-gate #define V_MUSTHAVE 0x0001 1797c478bd9Sstevel@tonic-gate #define V_MAPPED 0x0002 1807c478bd9Sstevel@tonic-gate #define V_MULTI 0x0003 /* optional, may be more than one */ 1817c478bd9Sstevel@tonic-gate } wkdevice[] = { 1827c478bd9Sstevel@tonic-gate { "sbus", have_sbus, NULL, V_MULTI }, 1837c478bd9Sstevel@tonic-gate { "pci", have_pci, NULL, V_MULTI }, 1847c478bd9Sstevel@tonic-gate { "eeprom", have_eeprom, NULL, V_MULTI }, 1857c478bd9Sstevel@tonic-gate { "auxio", have_auxio, NULL, V_OPTIONAL }, 1867c478bd9Sstevel@tonic-gate { "rtc", have_rtc, NULL, V_OPTIONAL }, 1877c478bd9Sstevel@tonic-gate { "pmc", have_pmc, NULL, V_OPTIONAL }, 1887c478bd9Sstevel@tonic-gate { 0, }, 1897c478bd9Sstevel@tonic-gate }; 1907c478bd9Sstevel@tonic-gate 191fa9e4066Sahrens static void map_wellknown(pnode_t); 1927c478bd9Sstevel@tonic-gate 1937c478bd9Sstevel@tonic-gate void 1947c478bd9Sstevel@tonic-gate map_wellknown_devices() 1957c478bd9Sstevel@tonic-gate { 1967c478bd9Sstevel@tonic-gate struct wkdevice *wkp; 1977c478bd9Sstevel@tonic-gate phandle_t ieeprom; 198fa9e4066Sahrens pnode_t root; 1997c478bd9Sstevel@tonic-gate uint_t stick_freq; 2007c478bd9Sstevel@tonic-gate 2017c478bd9Sstevel@tonic-gate /* 2027c478bd9Sstevel@tonic-gate * if there is a chosen eeprom, note it (for have_eeprom()) 2037c478bd9Sstevel@tonic-gate */ 2047c478bd9Sstevel@tonic-gate if (GETPROPLEN(prom_chosennode(), CHOSEN_EEPROM) == 2057c478bd9Sstevel@tonic-gate sizeof (phandle_t) && 2067c478bd9Sstevel@tonic-gate GETPROP(prom_chosennode(), CHOSEN_EEPROM, (caddr_t)&ieeprom) != -1) 207fa9e4066Sahrens chosen_eeprom = (pnode_t)prom_decode_int(ieeprom); 2087c478bd9Sstevel@tonic-gate 209fa9e4066Sahrens root = prom_nextnode((pnode_t)0); 2107c478bd9Sstevel@tonic-gate /* 2117c478bd9Sstevel@tonic-gate * Get System clock frequency from root node if it exists. 2127c478bd9Sstevel@tonic-gate */ 2137c478bd9Sstevel@tonic-gate if (GETPROP(root, "stick-frequency", (caddr_t)&stick_freq) != -1) 2147c478bd9Sstevel@tonic-gate system_clock_freq = stick_freq; 2157c478bd9Sstevel@tonic-gate 216fa9e4066Sahrens map_wellknown(NEXT((pnode_t)0)); 2177c478bd9Sstevel@tonic-gate 2187c478bd9Sstevel@tonic-gate /* 2197c478bd9Sstevel@tonic-gate * See if it worked 2207c478bd9Sstevel@tonic-gate */ 2217c478bd9Sstevel@tonic-gate for (wkp = wkdevice; wkp->wk_namep; ++wkp) { 2227c478bd9Sstevel@tonic-gate if (wkp->wk_flags == V_MUSTHAVE) { 2237c478bd9Sstevel@tonic-gate cmn_err(CE_PANIC, "map_wellknown_devices: required " 2247c478bd9Sstevel@tonic-gate "device %s not mapped", wkp->wk_namep); 2257c478bd9Sstevel@tonic-gate } 2267c478bd9Sstevel@tonic-gate } 2277c478bd9Sstevel@tonic-gate 2287c478bd9Sstevel@tonic-gate /* 2297c478bd9Sstevel@tonic-gate * all sun4u systems must have an IO bus, i.e. sbus or pcibus 2307c478bd9Sstevel@tonic-gate */ 2317c478bd9Sstevel@tonic-gate if (niobus == 0) 2327c478bd9Sstevel@tonic-gate cmn_err(CE_PANIC, "map_wellknown_devices: no i/o bus node"); 2337c478bd9Sstevel@tonic-gate 2347c478bd9Sstevel@tonic-gate check_cpus_ver(); 2357c478bd9Sstevel@tonic-gate check_cpus_set(); 2367c478bd9Sstevel@tonic-gate } 2377c478bd9Sstevel@tonic-gate 2387c478bd9Sstevel@tonic-gate /* 2397c478bd9Sstevel@tonic-gate * map_wellknown - map known devices & registers 2407c478bd9Sstevel@tonic-gate */ 2417c478bd9Sstevel@tonic-gate static void 242fa9e4066Sahrens map_wellknown(pnode_t curnode) 2437c478bd9Sstevel@tonic-gate { 2447c478bd9Sstevel@tonic-gate extern int status_okay(int, char *, int); 2457c478bd9Sstevel@tonic-gate char tmp_name[MAXSYSNAME]; 246fa9e4066Sahrens static void fill_address(pnode_t, char *); 2477c478bd9Sstevel@tonic-gate int sok; 2487c478bd9Sstevel@tonic-gate 2497c478bd9Sstevel@tonic-gate #ifdef VPRINTF 2507c478bd9Sstevel@tonic-gate VPRINTF("map_wellknown(%x)\n", curnode); 2517c478bd9Sstevel@tonic-gate #endif /* VPRINTF */ 2527c478bd9Sstevel@tonic-gate 2537c478bd9Sstevel@tonic-gate for (curnode = CHILD(curnode); curnode; curnode = NEXT(curnode)) { 2547c478bd9Sstevel@tonic-gate /* 2557c478bd9Sstevel@tonic-gate * prune subtree if status property indicating not okay 2567c478bd9Sstevel@tonic-gate */ 2577c478bd9Sstevel@tonic-gate sok = status_okay((int)curnode, (char *)NULL, 0); 2587c478bd9Sstevel@tonic-gate if (!sok) { 2597c478bd9Sstevel@tonic-gate char devtype_buf[OBP_MAXPROPNAME]; 2607c478bd9Sstevel@tonic-gate int size; 2617c478bd9Sstevel@tonic-gate 2627c478bd9Sstevel@tonic-gate #ifdef VPRINTF 2637c478bd9Sstevel@tonic-gate VPRINTF("map_wellknown: !okay status property\n"); 2647c478bd9Sstevel@tonic-gate #endif /* VPRINTF */ 2657c478bd9Sstevel@tonic-gate /* 2667c478bd9Sstevel@tonic-gate * a status property indicating bad memory will be 2677c478bd9Sstevel@tonic-gate * associated with a node which has a "device_type" 2687c478bd9Sstevel@tonic-gate * property with a value of "memory-controller" 2697c478bd9Sstevel@tonic-gate */ 2707c478bd9Sstevel@tonic-gate if ((size = GETPROPLEN(curnode, 2717c478bd9Sstevel@tonic-gate OBP_DEVICETYPE)) == -1) 2727c478bd9Sstevel@tonic-gate continue; 2737c478bd9Sstevel@tonic-gate if (size > OBP_MAXPROPNAME) { 2747c478bd9Sstevel@tonic-gate cmn_err(CE_CONT, "node %x '%s' prop too " 2757c478bd9Sstevel@tonic-gate "big\n", curnode, OBP_DEVICETYPE); 2767c478bd9Sstevel@tonic-gate continue; 2777c478bd9Sstevel@tonic-gate } 2787c478bd9Sstevel@tonic-gate if (GETPROP(curnode, OBP_DEVICETYPE, 2797c478bd9Sstevel@tonic-gate devtype_buf) == -1) { 2807c478bd9Sstevel@tonic-gate cmn_err(CE_CONT, "node %x '%s' get failed\n", 2817c478bd9Sstevel@tonic-gate curnode, OBP_DEVICETYPE); 2827c478bd9Sstevel@tonic-gate continue; 2837c478bd9Sstevel@tonic-gate } 2847c478bd9Sstevel@tonic-gate if (strcmp(devtype_buf, "memory-controller") != 0) 2857c478bd9Sstevel@tonic-gate continue; 2867c478bd9Sstevel@tonic-gate /* 2877c478bd9Sstevel@tonic-gate * ...else fall thru and process the node... 2887c478bd9Sstevel@tonic-gate */ 2897c478bd9Sstevel@tonic-gate } 2907c478bd9Sstevel@tonic-gate bzero(tmp_name, MAXSYSNAME); 2917c478bd9Sstevel@tonic-gate if (GETPROP(curnode, OBP_NAME, (caddr_t)tmp_name) != -1) 2927c478bd9Sstevel@tonic-gate fill_address(curnode, tmp_name); 2937c478bd9Sstevel@tonic-gate if (GETPROP(curnode, OBP_DEVICETYPE, tmp_name) != -1 && 2947c478bd9Sstevel@tonic-gate strcmp(tmp_name, "cpu") == 0) { 2957c478bd9Sstevel@tonic-gate fill_cpu(curnode); 2967c478bd9Sstevel@tonic-gate } 2977c478bd9Sstevel@tonic-gate if (strcmp(tmp_name, "tod") == 0) 2987c478bd9Sstevel@tonic-gate have_tod(curnode); 2997c478bd9Sstevel@tonic-gate if (sok && (strcmp(tmp_name, "memory-controller") == 0) && 3007c478bd9Sstevel@tonic-gate (&plat_fill_mc != NULL)) 3017c478bd9Sstevel@tonic-gate plat_fill_mc(curnode); 3027c478bd9Sstevel@tonic-gate map_wellknown(curnode); 3037c478bd9Sstevel@tonic-gate } 3047c478bd9Sstevel@tonic-gate } 3057c478bd9Sstevel@tonic-gate 3067c478bd9Sstevel@tonic-gate static void 307fa9e4066Sahrens fill_address(pnode_t curnode, char *namep) 3087c478bd9Sstevel@tonic-gate { 3097c478bd9Sstevel@tonic-gate struct wkdevice *wkp; 3107c478bd9Sstevel@tonic-gate int size; 3117c478bd9Sstevel@tonic-gate uint32_t vaddr; 3127c478bd9Sstevel@tonic-gate 3137c478bd9Sstevel@tonic-gate for (wkp = wkdevice; wkp->wk_namep; ++wkp) { 3147c478bd9Sstevel@tonic-gate if (strcmp(wkp->wk_namep, namep) != 0) 3157c478bd9Sstevel@tonic-gate continue; 3167c478bd9Sstevel@tonic-gate if (wkp->wk_flags == V_MAPPED) 3177c478bd9Sstevel@tonic-gate return; 3187c478bd9Sstevel@tonic-gate if (wkp->wk_vaddrp != NULL) { 3197c478bd9Sstevel@tonic-gate if ((size = GETPROPLEN(curnode, OBP_ADDRESS)) == -1) { 3207c478bd9Sstevel@tonic-gate cmn_err(CE_CONT, "device %s size %d\n", 3217c478bd9Sstevel@tonic-gate namep, size); 3227c478bd9Sstevel@tonic-gate continue; 3237c478bd9Sstevel@tonic-gate } 3247c478bd9Sstevel@tonic-gate if (size != sizeof (vaddr)) { 3257c478bd9Sstevel@tonic-gate cmn_err(CE_CONT, "device %s address prop too " 3267c478bd9Sstevel@tonic-gate "big\n", namep); 3277c478bd9Sstevel@tonic-gate continue; 3287c478bd9Sstevel@tonic-gate } 3297c478bd9Sstevel@tonic-gate if (GETPROP(curnode, OBP_ADDRESS, 3307c478bd9Sstevel@tonic-gate (caddr_t)&vaddr) == -1) { 3317c478bd9Sstevel@tonic-gate cmn_err(CE_CONT, "device %s not mapped\n", 3327c478bd9Sstevel@tonic-gate namep); 3337c478bd9Sstevel@tonic-gate continue; 3347c478bd9Sstevel@tonic-gate } 3357c478bd9Sstevel@tonic-gate 3367c478bd9Sstevel@tonic-gate /* make into a native pointer */ 337f166393fSesolom *wkp->wk_vaddrp = (caddr_t)(uintptr_t)vaddr; 3387c478bd9Sstevel@tonic-gate #ifdef VPRINTF 339f166393fSesolom VPRINTF("fill_address: %s mapped to %p\n", namep, 3407c478bd9Sstevel@tonic-gate *wkp->wk_vaddrp); 3417c478bd9Sstevel@tonic-gate #endif /* VPRINTF */ 3427c478bd9Sstevel@tonic-gate } 3437c478bd9Sstevel@tonic-gate if (wkp->wk_func != NULL) 3447c478bd9Sstevel@tonic-gate (*wkp->wk_func)(curnode); 3457c478bd9Sstevel@tonic-gate /* 3467c478bd9Sstevel@tonic-gate * If this one is optional and there may be more than 3477c478bd9Sstevel@tonic-gate * one, don't set V_MAPPED, which would cause us to skip it 3487c478bd9Sstevel@tonic-gate * next time around 3497c478bd9Sstevel@tonic-gate */ 3507c478bd9Sstevel@tonic-gate if (wkp->wk_flags != V_MULTI) 3517c478bd9Sstevel@tonic-gate wkp->wk_flags = V_MAPPED; 3527c478bd9Sstevel@tonic-gate } 3537c478bd9Sstevel@tonic-gate } 3547c478bd9Sstevel@tonic-gate 3557c478bd9Sstevel@tonic-gate int 356fa9e4066Sahrens get_portid(pnode_t node, pnode_t *cmpp) 3577c478bd9Sstevel@tonic-gate { 3587c478bd9Sstevel@tonic-gate int portid; 359*25cf1a30Sjl139090 int i; 3607c478bd9Sstevel@tonic-gate char dev_type[OBP_MAXPROPNAME]; 361*25cf1a30Sjl139090 pnode_t cpu_parent; 3627c478bd9Sstevel@tonic-gate 3637c478bd9Sstevel@tonic-gate if (cmpp != NULL) 3647c478bd9Sstevel@tonic-gate *cmpp = OBP_NONODE; 3657c478bd9Sstevel@tonic-gate 3667c478bd9Sstevel@tonic-gate if (GETPROP(node, "portid", (caddr_t)&portid) != -1) 3677c478bd9Sstevel@tonic-gate return (portid); 3687c478bd9Sstevel@tonic-gate if (GETPROP(node, "upa-portid", (caddr_t)&portid) != -1) 3697c478bd9Sstevel@tonic-gate return (portid); 3707c478bd9Sstevel@tonic-gate if (GETPROP(node, "device_type", (caddr_t)&dev_type) == -1) 3717c478bd9Sstevel@tonic-gate return (-1); 3727c478bd9Sstevel@tonic-gate 373*25cf1a30Sjl139090 /* 374*25cf1a30Sjl139090 * For a virtual cpu node that is a CMP core, the "portid" 375*25cf1a30Sjl139090 * is in the parent node. 376*25cf1a30Sjl139090 * For a virtual cpu node that is a CMT strand, the "portid" is 377*25cf1a30Sjl139090 * in its grandparent node. 378*25cf1a30Sjl139090 * So we iterate up as far as 2 levels to get the "portid". 379*25cf1a30Sjl139090 */ 3807c478bd9Sstevel@tonic-gate if (strcmp(dev_type, "cpu") == 0) { 381*25cf1a30Sjl139090 cpu_parent = node = prom_parentnode(node); 382*25cf1a30Sjl139090 for (i = 0; i < 2; i++) { 383*25cf1a30Sjl139090 if (node == OBP_NONODE || node == OBP_BADNODE) 384*25cf1a30Sjl139090 break; 3857c478bd9Sstevel@tonic-gate if (GETPROP(node, "portid", (caddr_t)&portid) != -1) { 3867c478bd9Sstevel@tonic-gate if (cmpp != NULL) 387*25cf1a30Sjl139090 *cmpp = cpu_parent; 3887c478bd9Sstevel@tonic-gate return (portid); 3897c478bd9Sstevel@tonic-gate } 390*25cf1a30Sjl139090 node = prom_parentnode(node); 391*25cf1a30Sjl139090 } 3927c478bd9Sstevel@tonic-gate } 3937c478bd9Sstevel@tonic-gate 3947c478bd9Sstevel@tonic-gate return (-1); 3957c478bd9Sstevel@tonic-gate } 3967c478bd9Sstevel@tonic-gate 3977c478bd9Sstevel@tonic-gate /* 3987c478bd9Sstevel@tonic-gate * Adjust page coloring variables based on the physical ecache setsize of 3997c478bd9Sstevel@tonic-gate * the configured cpus: 4007c478bd9Sstevel@tonic-gate * 4017c478bd9Sstevel@tonic-gate * Set ecache_setsize to max ecache set size to be used by 4027c478bd9Sstevel@tonic-gate * page_coloring_init() to determine the page colors to configure. 4037c478bd9Sstevel@tonic-gate * The adjustment is unlikely to be necessary... For cheetah+ systems, 4047c478bd9Sstevel@tonic-gate * ecache_setsize should already be set in cpu_fiximp() to the maximum 4057c478bd9Sstevel@tonic-gate * possible ecache setsize of any supported cheetah+ cpus. The adjustment 4067c478bd9Sstevel@tonic-gate * is for the off chance that a non-cheetah+ system may have heterogenous 4077c478bd9Sstevel@tonic-gate * cpus. 4087c478bd9Sstevel@tonic-gate * 4097c478bd9Sstevel@tonic-gate * Set cpu_setsize to the actual cpu setsize if the setsize is homogenous 4107c478bd9Sstevel@tonic-gate * across all cpus otherwise set it to -1 if heterogenous. 4117c478bd9Sstevel@tonic-gate * 4127c478bd9Sstevel@tonic-gate * Set cpu_page_colors to -1 to signify heterogeneity of ecache setsizes 4137c478bd9Sstevel@tonic-gate * to the page_get routines. 4147c478bd9Sstevel@tonic-gate */ 4157c478bd9Sstevel@tonic-gate static void 4167c478bd9Sstevel@tonic-gate adj_ecache_setsize(int ecsetsize) 4177c478bd9Sstevel@tonic-gate { 4187c478bd9Sstevel@tonic-gate if (ecsetsize > ecache_setsize) 4197c478bd9Sstevel@tonic-gate ecache_setsize = ecsetsize; 4207c478bd9Sstevel@tonic-gate 4217c478bd9Sstevel@tonic-gate switch (cpu_setsize) { 4227c478bd9Sstevel@tonic-gate case -1: 4237c478bd9Sstevel@tonic-gate break; 4247c478bd9Sstevel@tonic-gate case 0: 4257c478bd9Sstevel@tonic-gate cpu_setsize = ecsetsize; 4267c478bd9Sstevel@tonic-gate break; 4277c478bd9Sstevel@tonic-gate default: 4287c478bd9Sstevel@tonic-gate /* set to -1 if hetergenous cpus */ 4297c478bd9Sstevel@tonic-gate if (cpu_setsize != ecsetsize) { 4307c478bd9Sstevel@tonic-gate if (do_pg_coloring) 4317c478bd9Sstevel@tonic-gate cpu_page_colors = -1; 4327c478bd9Sstevel@tonic-gate /* 4337c478bd9Sstevel@tonic-gate * if page coloring disabled, cpu_page_colors should 4347c478bd9Sstevel@tonic-gate * remain 0 to prevent page coloring processing. 4357c478bd9Sstevel@tonic-gate */ 4367c478bd9Sstevel@tonic-gate cpu_setsize = -1; 4377c478bd9Sstevel@tonic-gate } 4387c478bd9Sstevel@tonic-gate break; 4397c478bd9Sstevel@tonic-gate } 4407c478bd9Sstevel@tonic-gate } 4417c478bd9Sstevel@tonic-gate 4427c478bd9Sstevel@tonic-gate void 443fa9e4066Sahrens fill_cpu(pnode_t node) 4447c478bd9Sstevel@tonic-gate { 4457c478bd9Sstevel@tonic-gate extern int cpu_get_cpu_unum(int, char *, int, int *); 4467c478bd9Sstevel@tonic-gate struct cpu_node *cpunode; 4477c478bd9Sstevel@tonic-gate processorid_t cpuid; 4487c478bd9Sstevel@tonic-gate int portid; 4497c478bd9Sstevel@tonic-gate int tlbsize; 4507c478bd9Sstevel@tonic-gate int size; 4517c478bd9Sstevel@tonic-gate uint_t clk_freq; 452fa9e4066Sahrens pnode_t cmpnode; 4537c478bd9Sstevel@tonic-gate char namebuf[OBP_MAXPROPNAME], unum[UNUM_NAMLEN]; 4547c478bd9Sstevel@tonic-gate char *namebufp; 4557c478bd9Sstevel@tonic-gate 4567c478bd9Sstevel@tonic-gate if ((portid = get_portid(node, &cmpnode)) == -1) { 4577c478bd9Sstevel@tonic-gate cmn_err(CE_PANIC, "portid not found"); 4587c478bd9Sstevel@tonic-gate } 4597c478bd9Sstevel@tonic-gate 4607c478bd9Sstevel@tonic-gate if (GETPROP(node, "cpuid", (caddr_t)&cpuid) == -1) { 4617c478bd9Sstevel@tonic-gate cpuid = portid; 4627c478bd9Sstevel@tonic-gate } 4637c478bd9Sstevel@tonic-gate 4647c478bd9Sstevel@tonic-gate if (cpuid < 0 || cpuid >= NCPU) { 4657c478bd9Sstevel@tonic-gate cmn_err(CE_PANIC, "cpu node %x: cpuid %d out of range", 4667c478bd9Sstevel@tonic-gate node, cpuid); 4677c478bd9Sstevel@tonic-gate return; 4687c478bd9Sstevel@tonic-gate } 4697c478bd9Sstevel@tonic-gate 4707c478bd9Sstevel@tonic-gate cpunode = &cpunodes[cpuid]; 4717c478bd9Sstevel@tonic-gate cpunode->portid = portid; 472*25cf1a30Sjl139090 cpunode->nodeid = node; 4737c478bd9Sstevel@tonic-gate 4747c478bd9Sstevel@tonic-gate if (cpu_get_cpu_unum(cpuid, unum, UNUM_NAMLEN, &size) != 0) { 4757c478bd9Sstevel@tonic-gate cpunode->fru_fmri[0] = '\0'; 4767c478bd9Sstevel@tonic-gate } else { 4777c478bd9Sstevel@tonic-gate (void) snprintf(cpunode->fru_fmri, sizeof (cpunode->fru_fmri), 4787c478bd9Sstevel@tonic-gate "%s%s", CPU_FRU_FMRI, unum); 4797c478bd9Sstevel@tonic-gate } 4807c478bd9Sstevel@tonic-gate 481*25cf1a30Sjl139090 if (cmpnode) { 482*25cf1a30Sjl139090 /* 483*25cf1a30Sjl139090 * For the CMT case, the parent "core" node contains 484*25cf1a30Sjl139090 * properties needed below, use it instead of the 485*25cf1a30Sjl139090 * cpu node. 486*25cf1a30Sjl139090 */ 487*25cf1a30Sjl139090 if ((GETPROP(cmpnode, "device_type", namebuf) > 0) && 488*25cf1a30Sjl139090 (strcmp(namebuf, "core") == 0)) { 489*25cf1a30Sjl139090 node = cmpnode; 490*25cf1a30Sjl139090 } 491*25cf1a30Sjl139090 } 492*25cf1a30Sjl139090 4937c478bd9Sstevel@tonic-gate (void) GETPROP(node, (cmpnode ? "compatible" : "name"), namebuf); 4947c478bd9Sstevel@tonic-gate namebufp = namebuf; 4957c478bd9Sstevel@tonic-gate if (strncmp(namebufp, "SUNW,", 5) == 0) 4967c478bd9Sstevel@tonic-gate namebufp += 5; 497*25cf1a30Sjl139090 else if (strncmp(namebufp, "FJSV,", 5) == 0) 498*25cf1a30Sjl139090 namebufp += 5; 4997c478bd9Sstevel@tonic-gate (void) strcpy(cpunode->name, namebufp); 5007c478bd9Sstevel@tonic-gate 5017c478bd9Sstevel@tonic-gate (void) GETPROP(node, "implementation#", 5027c478bd9Sstevel@tonic-gate (caddr_t)&cpunode->implementation); 5037c478bd9Sstevel@tonic-gate (void) GETPROP(node, "mask#", (caddr_t)&cpunode->version); 5047c478bd9Sstevel@tonic-gate 5057c478bd9Sstevel@tonic-gate if (IS_CHEETAH(cpunode->implementation)) { 5067c478bd9Sstevel@tonic-gate /* remap mask reg */ 5077c478bd9Sstevel@tonic-gate cpunode->version = REMAP_CHEETAH_MASK(cpunode->version); 5087c478bd9Sstevel@tonic-gate } 5097c478bd9Sstevel@tonic-gate if (GETPROP(node, "clock-frequency", (caddr_t)&clk_freq) == -1) { 5107c478bd9Sstevel@tonic-gate /* 5117c478bd9Sstevel@tonic-gate * If we didn't find it in the CPU node, look in the root node. 5127c478bd9Sstevel@tonic-gate */ 513fa9e4066Sahrens pnode_t root = prom_nextnode((pnode_t)0); 5147c478bd9Sstevel@tonic-gate if (GETPROP(root, "clock-frequency", (caddr_t)&clk_freq) == -1) 5157c478bd9Sstevel@tonic-gate clk_freq = 0; 5167c478bd9Sstevel@tonic-gate } 5177c478bd9Sstevel@tonic-gate cpunode->clock_freq = clk_freq; 5187c478bd9Sstevel@tonic-gate 5197c478bd9Sstevel@tonic-gate ASSERT(cpunode->clock_freq != 0); 5207c478bd9Sstevel@tonic-gate /* 5217c478bd9Sstevel@tonic-gate * Compute scaling factor based on rate of %tick. This is used 5227c478bd9Sstevel@tonic-gate * to convert from ticks derived from %tick to nanoseconds. See 5237c478bd9Sstevel@tonic-gate * comment in sun4u/sys/clock.h for details. 5247c478bd9Sstevel@tonic-gate */ 5257c478bd9Sstevel@tonic-gate cpunode->tick_nsec_scale = (uint_t)(((uint64_t)NANOSEC << 5267c478bd9Sstevel@tonic-gate (32 - TICK_NSEC_SHIFT)) / cpunode->clock_freq); 5277c478bd9Sstevel@tonic-gate 5287c478bd9Sstevel@tonic-gate (void) GETPROP(node, "#itlb-entries", (caddr_t)&tlbsize); 5297c478bd9Sstevel@tonic-gate ASSERT(tlbsize < USHRT_MAX); /* since we cast it */ 5307c478bd9Sstevel@tonic-gate cpunode->itlb_size = (ushort_t)tlbsize; 5317c478bd9Sstevel@tonic-gate 5327c478bd9Sstevel@tonic-gate (void) GETPROP(node, "#dtlb-entries", (caddr_t)&tlbsize); 5337c478bd9Sstevel@tonic-gate ASSERT(tlbsize < USHRT_MAX); /* since we cast it */ 5347c478bd9Sstevel@tonic-gate cpunode->dtlb_size = (ushort_t)tlbsize; 5357c478bd9Sstevel@tonic-gate 5367c478bd9Sstevel@tonic-gate if (cmpnode != OBP_NONODE) { 5377c478bd9Sstevel@tonic-gate /* 5387c478bd9Sstevel@tonic-gate * If the CPU has a level 3 cache, then it will be the 5397c478bd9Sstevel@tonic-gate * external cache. Otherwise the level 2 cache is the 5407c478bd9Sstevel@tonic-gate * external cache. 5417c478bd9Sstevel@tonic-gate */ 5427c478bd9Sstevel@tonic-gate size = 0; 5437c478bd9Sstevel@tonic-gate (void) GETPROP(node, "l3-cache-size", (caddr_t)&size); 5447c478bd9Sstevel@tonic-gate if (size <= 0) 5457c478bd9Sstevel@tonic-gate (void) GETPROP(node, "l2-cache-size", (caddr_t)&size); 5467c478bd9Sstevel@tonic-gate ASSERT(size != 0); 5477c478bd9Sstevel@tonic-gate cpunode->ecache_size = size; 5487c478bd9Sstevel@tonic-gate 5497c478bd9Sstevel@tonic-gate size = 0; 5507c478bd9Sstevel@tonic-gate (void) GETPROP(node, "l3-cache-line-size", (caddr_t)&size); 5517c478bd9Sstevel@tonic-gate if (size <= 0) 5527c478bd9Sstevel@tonic-gate (void) GETPROP(node, "l2-cache-line-size", 5537c478bd9Sstevel@tonic-gate (caddr_t)&size); 5547c478bd9Sstevel@tonic-gate ASSERT(size != 0); 5557c478bd9Sstevel@tonic-gate cpunode->ecache_linesize = size; 5567c478bd9Sstevel@tonic-gate 5577c478bd9Sstevel@tonic-gate size = 0; 5587c478bd9Sstevel@tonic-gate (void) GETPROP(node, "l2-cache-associativity", (caddr_t)&size); 5597c478bd9Sstevel@tonic-gate ASSERT(size != 0); 5607c478bd9Sstevel@tonic-gate cpunode->ecache_associativity = size; 5617c478bd9Sstevel@tonic-gate 5627c478bd9Sstevel@tonic-gate cmp_add_cpu(portid, cpuid); 5637c478bd9Sstevel@tonic-gate } else { 5647c478bd9Sstevel@tonic-gate size = 0; 5657c478bd9Sstevel@tonic-gate (void) GETPROP(node, "ecache-size", (caddr_t)&size); 5667c478bd9Sstevel@tonic-gate ASSERT(size != 0); 5677c478bd9Sstevel@tonic-gate cpunode->ecache_size = size; 5687c478bd9Sstevel@tonic-gate 5697c478bd9Sstevel@tonic-gate size = 0; 5707c478bd9Sstevel@tonic-gate (void) GETPROP(node, "ecache-line-size", (caddr_t)&size); 5717c478bd9Sstevel@tonic-gate ASSERT(size != 0); 5727c478bd9Sstevel@tonic-gate cpunode->ecache_linesize = size; 5737c478bd9Sstevel@tonic-gate 5747c478bd9Sstevel@tonic-gate size = 0; 5757c478bd9Sstevel@tonic-gate (void) GETPROP(node, "ecache-associativity", (caddr_t)&size); 5767c478bd9Sstevel@tonic-gate ASSERT(size != 0); 5777c478bd9Sstevel@tonic-gate cpunode->ecache_associativity = size; 5787c478bd9Sstevel@tonic-gate } 5797c478bd9Sstevel@tonic-gate 5807c478bd9Sstevel@tonic-gate /* by default set msram to non-mirrored one */ 5817c478bd9Sstevel@tonic-gate cpunode->msram = ECACHE_CPU_NON_MIRROR; 5827c478bd9Sstevel@tonic-gate 5837c478bd9Sstevel@tonic-gate if (GETPROPLEN(node, "msram") != -1) { 5847c478bd9Sstevel@tonic-gate cpunode->msram = ECACHE_CPU_MIRROR; 5857c478bd9Sstevel@tonic-gate } 5867c478bd9Sstevel@tonic-gate 5877c478bd9Sstevel@tonic-gate if (GETPROPLEN(node, "msram-observed") != -1) { 5887c478bd9Sstevel@tonic-gate cpunode->msram = ECACHE_CPU_MIRROR; 5897c478bd9Sstevel@tonic-gate } 5907c478bd9Sstevel@tonic-gate 5917c478bd9Sstevel@tonic-gate if (ncpunode == 0) { 5927c478bd9Sstevel@tonic-gate cpu_fiximp(node); 5937c478bd9Sstevel@tonic-gate } 5947c478bd9Sstevel@tonic-gate 5957c478bd9Sstevel@tonic-gate cpunode->ecache_setsize = 5967c478bd9Sstevel@tonic-gate cpunode->ecache_size / cpunode->ecache_associativity; 5977c478bd9Sstevel@tonic-gate 5987c478bd9Sstevel@tonic-gate adj_ecache_setsize(cpunode->ecache_setsize); 5997c478bd9Sstevel@tonic-gate 6007c478bd9Sstevel@tonic-gate ncpunode++; 6017c478bd9Sstevel@tonic-gate } 6027c478bd9Sstevel@tonic-gate 6037c478bd9Sstevel@tonic-gate int 6047c478bd9Sstevel@tonic-gate get_portid_ddi(dev_info_t *dip, dev_info_t **cmpp) 6057c478bd9Sstevel@tonic-gate { 6067c478bd9Sstevel@tonic-gate int portid; 607*25cf1a30Sjl139090 int i; 6087c478bd9Sstevel@tonic-gate char dev_type[OBP_MAXPROPNAME]; 6097c478bd9Sstevel@tonic-gate int len = OBP_MAXPROPNAME; 610*25cf1a30Sjl139090 dev_info_t *cpu_parent; 6117c478bd9Sstevel@tonic-gate 6127c478bd9Sstevel@tonic-gate if (cmpp != NULL) 6137c478bd9Sstevel@tonic-gate *cmpp = NULL; 6147c478bd9Sstevel@tonic-gate 6157c478bd9Sstevel@tonic-gate if ((portid = ddi_prop_get_int(DDI_DEV_T_ANY, dip, 6167c478bd9Sstevel@tonic-gate DDI_PROP_DONTPASS, "portid", -1)) != -1) 6177c478bd9Sstevel@tonic-gate return (portid); 6187c478bd9Sstevel@tonic-gate if ((portid = ddi_prop_get_int(DDI_DEV_T_ANY, dip, 6197c478bd9Sstevel@tonic-gate DDI_PROP_DONTPASS, "upa-portid", -1)) != -1) 6207c478bd9Sstevel@tonic-gate return (portid); 6217c478bd9Sstevel@tonic-gate if (ddi_prop_op(DDI_DEV_T_ANY, dip, PROP_LEN_AND_VAL_BUF, 6227c478bd9Sstevel@tonic-gate DDI_PROP_DONTPASS, "device_type", (caddr_t)dev_type, 6237c478bd9Sstevel@tonic-gate &len) != 0) 6247c478bd9Sstevel@tonic-gate return (-1); 6257c478bd9Sstevel@tonic-gate 626*25cf1a30Sjl139090 /* 627*25cf1a30Sjl139090 * For a virtual cpu node that is a CMP core, the "portid" 628*25cf1a30Sjl139090 * is in the parent node. 629*25cf1a30Sjl139090 * For a virtual cpu node that is a CMT strand, the "portid" is 630*25cf1a30Sjl139090 * in its grandparent node. 631*25cf1a30Sjl139090 * So we iterate up as far as 2 levels to get the "portid". 632*25cf1a30Sjl139090 */ 6337c478bd9Sstevel@tonic-gate if (strcmp(dev_type, "cpu") == 0) { 634*25cf1a30Sjl139090 cpu_parent = dip = ddi_get_parent(dip); 635*25cf1a30Sjl139090 for (i = 0; dip != NULL && i < 2; i++) { 6367c478bd9Sstevel@tonic-gate if ((portid = ddi_prop_get_int(DDI_DEV_T_ANY, dip, 6377c478bd9Sstevel@tonic-gate DDI_PROP_DONTPASS, "portid", -1)) != -1) { 6387c478bd9Sstevel@tonic-gate if (cmpp != NULL) 639*25cf1a30Sjl139090 *cmpp = cpu_parent; 6407c478bd9Sstevel@tonic-gate return (portid); 6417c478bd9Sstevel@tonic-gate } 642*25cf1a30Sjl139090 dip = ddi_get_parent(dip); 643*25cf1a30Sjl139090 } 6447c478bd9Sstevel@tonic-gate } 6457c478bd9Sstevel@tonic-gate 6467c478bd9Sstevel@tonic-gate return (-1); 6477c478bd9Sstevel@tonic-gate } 6487c478bd9Sstevel@tonic-gate 6497c478bd9Sstevel@tonic-gate /* 6507c478bd9Sstevel@tonic-gate * A hotplug version of fill_cpu(). (Doesn't assume that there's a node 6517c478bd9Sstevel@tonic-gate * in the PROM device tree for this CPU.) We still need the PROM version 6527c478bd9Sstevel@tonic-gate * since it is called very early in the boot cycle before (before 6537c478bd9Sstevel@tonic-gate * setup_ddi()). Sigh...someday this will all be cleaned up. 6547c478bd9Sstevel@tonic-gate */ 6557c478bd9Sstevel@tonic-gate void 6567c478bd9Sstevel@tonic-gate fill_cpu_ddi(dev_info_t *dip) 6577c478bd9Sstevel@tonic-gate { 6587c478bd9Sstevel@tonic-gate extern int cpu_get_cpu_unum(int, char *, int, int *); 6597c478bd9Sstevel@tonic-gate struct cpu_node *cpunode; 6607c478bd9Sstevel@tonic-gate processorid_t cpuid; 6617c478bd9Sstevel@tonic-gate int portid; 662*25cf1a30Sjl139090 int len = OBP_MAXPROPNAME; 6637c478bd9Sstevel@tonic-gate int tlbsize; 6647c478bd9Sstevel@tonic-gate dev_info_t *cmpnode; 6657c478bd9Sstevel@tonic-gate char namebuf[OBP_MAXPROPNAME], unum[UNUM_NAMLEN]; 6667c478bd9Sstevel@tonic-gate char *namebufp; 667*25cf1a30Sjl139090 char dev_type[OBP_MAXPROPNAME]; 6687c478bd9Sstevel@tonic-gate 6697c478bd9Sstevel@tonic-gate if ((portid = get_portid_ddi(dip, &cmpnode)) == -1) { 6707c478bd9Sstevel@tonic-gate cmn_err(CE_PANIC, "portid not found"); 6717c478bd9Sstevel@tonic-gate } 6727c478bd9Sstevel@tonic-gate 6737c478bd9Sstevel@tonic-gate if ((cpuid = ddi_prop_get_int(DDI_DEV_T_ANY, dip, 6747c478bd9Sstevel@tonic-gate DDI_PROP_DONTPASS, "cpuid", -1)) == -1) { 6757c478bd9Sstevel@tonic-gate cpuid = portid; 6767c478bd9Sstevel@tonic-gate } 6777c478bd9Sstevel@tonic-gate 6787c478bd9Sstevel@tonic-gate if (cpuid < 0 || cpuid >= NCPU) { 6797c478bd9Sstevel@tonic-gate cmn_err(CE_PANIC, "cpu dip %p: cpuid %d out of range", 6807c478bd9Sstevel@tonic-gate (void *) dip, cpuid); 6817c478bd9Sstevel@tonic-gate return; 6827c478bd9Sstevel@tonic-gate } 6837c478bd9Sstevel@tonic-gate 6847c478bd9Sstevel@tonic-gate cpunode = &cpunodes[cpuid]; 6857c478bd9Sstevel@tonic-gate cpunode->portid = portid; 686*25cf1a30Sjl139090 cpunode->nodeid = ddi_get_nodeid(dip); 687*25cf1a30Sjl139090 688*25cf1a30Sjl139090 if (cmpnode != NULL) { 689*25cf1a30Sjl139090 /* 690*25cf1a30Sjl139090 * For the CMT case, the parent "core" node contains 691*25cf1a30Sjl139090 * properties needed below, use it instead of the 692*25cf1a30Sjl139090 * cpu node. 693*25cf1a30Sjl139090 */ 694*25cf1a30Sjl139090 if ((ddi_prop_op(DDI_DEV_T_ANY, cmpnode, PROP_LEN_AND_VAL_BUF, 695*25cf1a30Sjl139090 DDI_PROP_DONTPASS, "device_type", 696*25cf1a30Sjl139090 (caddr_t)dev_type, &len) == DDI_PROP_SUCCESS) && 697*25cf1a30Sjl139090 (strcmp(dev_type, "core") == 0)) 698*25cf1a30Sjl139090 dip = cmpnode; 699*25cf1a30Sjl139090 } 7007c478bd9Sstevel@tonic-gate 7017c478bd9Sstevel@tonic-gate if (cpu_get_cpu_unum(cpuid, unum, UNUM_NAMLEN, &len) != 0) { 7027c478bd9Sstevel@tonic-gate cpunode->fru_fmri[0] = '\0'; 7037c478bd9Sstevel@tonic-gate } else { 7047c478bd9Sstevel@tonic-gate (void) snprintf(cpunode->fru_fmri, sizeof (cpunode->fru_fmri), 7057c478bd9Sstevel@tonic-gate "%s%s", CPU_FRU_FMRI, unum); 7067c478bd9Sstevel@tonic-gate } 7077c478bd9Sstevel@tonic-gate 7087c478bd9Sstevel@tonic-gate len = sizeof (namebuf); 7097c478bd9Sstevel@tonic-gate (void) ddi_prop_op(DDI_DEV_T_ANY, dip, PROP_LEN_AND_VAL_BUF, 7107c478bd9Sstevel@tonic-gate DDI_PROP_DONTPASS, (cmpnode ? "compatible" : "name"), 7117c478bd9Sstevel@tonic-gate (caddr_t)namebuf, &len); 7127c478bd9Sstevel@tonic-gate 7137c478bd9Sstevel@tonic-gate namebufp = namebuf; 7147c478bd9Sstevel@tonic-gate if (strncmp(namebufp, "SUNW,", 5) == 0) 7157c478bd9Sstevel@tonic-gate namebufp += 5; 716*25cf1a30Sjl139090 else if (strncmp(namebufp, "FJSV,", 5) == 0) 717*25cf1a30Sjl139090 namebufp += 5; 7187c478bd9Sstevel@tonic-gate (void) strcpy(cpunode->name, namebufp); 7197c478bd9Sstevel@tonic-gate 7207c478bd9Sstevel@tonic-gate cpunode->implementation = ddi_prop_get_int(DDI_DEV_T_ANY, dip, 7217c478bd9Sstevel@tonic-gate DDI_PROP_DONTPASS, "implementation#", 0); 7227c478bd9Sstevel@tonic-gate 7237c478bd9Sstevel@tonic-gate cpunode->version = ddi_prop_get_int(DDI_DEV_T_ANY, dip, 7247c478bd9Sstevel@tonic-gate DDI_PROP_DONTPASS, "mask#", 0); 7257c478bd9Sstevel@tonic-gate 7267c478bd9Sstevel@tonic-gate if (IS_CHEETAH(cpunode->implementation)) { 7277c478bd9Sstevel@tonic-gate /* remap mask reg */ 7287c478bd9Sstevel@tonic-gate cpunode->version = REMAP_CHEETAH_MASK(cpunode->version); 7297c478bd9Sstevel@tonic-gate } 7307c478bd9Sstevel@tonic-gate 731*25cf1a30Sjl139090 cpunode->clock_freq = (uint32_t)ddi_prop_get_int(DDI_DEV_T_ANY, dip, 7327c478bd9Sstevel@tonic-gate DDI_PROP_DONTPASS, "clock-frequency", 0); 7337c478bd9Sstevel@tonic-gate 7347c478bd9Sstevel@tonic-gate ASSERT(cpunode->clock_freq != 0); 7357c478bd9Sstevel@tonic-gate /* 7367c478bd9Sstevel@tonic-gate * Compute scaling factor based on rate of %tick. This is used 7377c478bd9Sstevel@tonic-gate * to convert from ticks derived from %tick to nanoseconds. See 7387c478bd9Sstevel@tonic-gate * comment in sun4u/sys/clock.h for details. 7397c478bd9Sstevel@tonic-gate */ 7407c478bd9Sstevel@tonic-gate cpunode->tick_nsec_scale = (uint_t)(((uint64_t)NANOSEC << 7417c478bd9Sstevel@tonic-gate (32 - TICK_NSEC_SHIFT)) / cpunode->clock_freq); 7427c478bd9Sstevel@tonic-gate 7437c478bd9Sstevel@tonic-gate tlbsize = ddi_prop_get_int(DDI_DEV_T_ANY, dip, 7447c478bd9Sstevel@tonic-gate DDI_PROP_DONTPASS, "#itlb-entries", 0); 7457c478bd9Sstevel@tonic-gate ASSERT(tlbsize < USHRT_MAX); /* since we cast it */ 7467c478bd9Sstevel@tonic-gate cpunode->itlb_size = (ushort_t)tlbsize; 7477c478bd9Sstevel@tonic-gate 7487c478bd9Sstevel@tonic-gate tlbsize = ddi_prop_get_int(DDI_DEV_T_ANY, dip, 7497c478bd9Sstevel@tonic-gate DDI_PROP_DONTPASS, "#dtlb-entries", 0); 7507c478bd9Sstevel@tonic-gate ASSERT(tlbsize < USHRT_MAX); /* since we cast it */ 7517c478bd9Sstevel@tonic-gate cpunode->dtlb_size = (ushort_t)tlbsize; 7527c478bd9Sstevel@tonic-gate 7537c478bd9Sstevel@tonic-gate if (cmpnode != NULL) { 7547c478bd9Sstevel@tonic-gate /* 7557c478bd9Sstevel@tonic-gate * If the CPU has a level 3 cache, then that is it's 7567c478bd9Sstevel@tonic-gate * external cache. Otherwise the external cache must 7577c478bd9Sstevel@tonic-gate * be the level 2 cache. 7587c478bd9Sstevel@tonic-gate */ 7597c478bd9Sstevel@tonic-gate cpunode->ecache_size = ddi_prop_get_int(DDI_DEV_T_ANY, 7607c478bd9Sstevel@tonic-gate dip, DDI_PROP_DONTPASS, "l3-cache-size", 0); 7617c478bd9Sstevel@tonic-gate if (cpunode->ecache_size == 0) 7627c478bd9Sstevel@tonic-gate cpunode->ecache_size = ddi_prop_get_int(DDI_DEV_T_ANY, 7637c478bd9Sstevel@tonic-gate dip, DDI_PROP_DONTPASS, "l2-cache-size", 0); 7647c478bd9Sstevel@tonic-gate ASSERT(cpunode->ecache_size != 0); 7657c478bd9Sstevel@tonic-gate 7667c478bd9Sstevel@tonic-gate cpunode->ecache_linesize = ddi_prop_get_int(DDI_DEV_T_ANY, 7677c478bd9Sstevel@tonic-gate dip, DDI_PROP_DONTPASS, "l3-cache-line-size", 0); 7687c478bd9Sstevel@tonic-gate if (cpunode->ecache_linesize == 0) 7697c478bd9Sstevel@tonic-gate cpunode->ecache_linesize = 7707c478bd9Sstevel@tonic-gate ddi_prop_get_int(DDI_DEV_T_ANY, dip, 7717c478bd9Sstevel@tonic-gate DDI_PROP_DONTPASS, "l2-cache-line-size", 0); 7727c478bd9Sstevel@tonic-gate ASSERT(cpunode->ecache_linesize != 0); 7737c478bd9Sstevel@tonic-gate 7747c478bd9Sstevel@tonic-gate cpunode->ecache_associativity = ddi_prop_get_int(DDI_DEV_T_ANY, 7757c478bd9Sstevel@tonic-gate dip, DDI_PROP_DONTPASS, "l2-cache-associativity", 0); 7767c478bd9Sstevel@tonic-gate ASSERT(cpunode->ecache_associativity != 0); 7777c478bd9Sstevel@tonic-gate 7787c478bd9Sstevel@tonic-gate cmp_add_cpu(portid, cpuid); 7797c478bd9Sstevel@tonic-gate } else { 7807c478bd9Sstevel@tonic-gate cpunode->ecache_size = ddi_prop_get_int(DDI_DEV_T_ANY, 7817c478bd9Sstevel@tonic-gate dip, DDI_PROP_DONTPASS, "ecache-size", 0); 7827c478bd9Sstevel@tonic-gate ASSERT(cpunode->ecache_size != 0); 7837c478bd9Sstevel@tonic-gate 7847c478bd9Sstevel@tonic-gate cpunode->ecache_linesize = ddi_prop_get_int(DDI_DEV_T_ANY, 7857c478bd9Sstevel@tonic-gate dip, DDI_PROP_DONTPASS, "ecache-line-size", 0); 7867c478bd9Sstevel@tonic-gate ASSERT(cpunode->ecache_linesize != 0); 7877c478bd9Sstevel@tonic-gate 7887c478bd9Sstevel@tonic-gate cpunode->ecache_associativity = ddi_prop_get_int(DDI_DEV_T_ANY, 7897c478bd9Sstevel@tonic-gate dip, DDI_PROP_DONTPASS, "ecache-associativity", 0); 7907c478bd9Sstevel@tonic-gate ASSERT(cpunode->ecache_associativity != 0); 7917c478bd9Sstevel@tonic-gate } 7927c478bd9Sstevel@tonic-gate 7937c478bd9Sstevel@tonic-gate /* by default set msram to non-mirrored one */ 7947c478bd9Sstevel@tonic-gate cpunode->msram = ECACHE_CPU_NON_MIRROR; 7957c478bd9Sstevel@tonic-gate 7967c478bd9Sstevel@tonic-gate if (ddi_prop_exists(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS, "msram")) { 7977c478bd9Sstevel@tonic-gate cpunode->msram = ECACHE_CPU_MIRROR; 7987c478bd9Sstevel@tonic-gate } else if (ddi_prop_exists(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS, 7997c478bd9Sstevel@tonic-gate "msram-observed")) { 8007c478bd9Sstevel@tonic-gate cpunode->msram = ECACHE_CPU_MIRROR; 8017c478bd9Sstevel@tonic-gate } 8027c478bd9Sstevel@tonic-gate 8037c478bd9Sstevel@tonic-gate ASSERT(ncpunode > 0); /* fiximp not req'd */ 8047c478bd9Sstevel@tonic-gate 8057c478bd9Sstevel@tonic-gate cpunode->ecache_setsize = 8067c478bd9Sstevel@tonic-gate cpunode->ecache_size / cpunode->ecache_associativity; 8077c478bd9Sstevel@tonic-gate 8087c478bd9Sstevel@tonic-gate adj_ecache_setsize(cpunode->ecache_setsize); 8097c478bd9Sstevel@tonic-gate 8107c478bd9Sstevel@tonic-gate ncpunode++; 8117c478bd9Sstevel@tonic-gate } 8127c478bd9Sstevel@tonic-gate 8137c478bd9Sstevel@tonic-gate void 8147c478bd9Sstevel@tonic-gate empty_cpu(int cpuid) 8157c478bd9Sstevel@tonic-gate { 8167c478bd9Sstevel@tonic-gate bzero(&cpunodes[cpuid], sizeof (struct cpu_node)); 8177c478bd9Sstevel@tonic-gate ncpunode--; 8187c478bd9Sstevel@tonic-gate } 8197c478bd9Sstevel@tonic-gate 8207c478bd9Sstevel@tonic-gate #ifdef SF_ERRATA_30 /* call causes fp-disabled */ 8217c478bd9Sstevel@tonic-gate int spitfire_call_bug = 0; 8227c478bd9Sstevel@tonic-gate #endif 8237c478bd9Sstevel@tonic-gate #ifdef SF_V9_TABLE_28 /* fp over/underflow traps may cause wrong fsr.cexc */ 8247c478bd9Sstevel@tonic-gate int spitfire_bb_fsr_bug = 0; 8257c478bd9Sstevel@tonic-gate #endif 8267c478bd9Sstevel@tonic-gate 8277c478bd9Sstevel@tonic-gate #ifdef JALAPENO_ERRATA_85 8287c478bd9Sstevel@tonic-gate /* 8297c478bd9Sstevel@tonic-gate * Set the values here assuming we're running 2.4 or later Jalapenos. If 8307c478bd9Sstevel@tonic-gate * not, they'll be reset below. Either way, the default can be overridden 8317c478bd9Sstevel@tonic-gate * when we read /etc/system later in boot. 8327c478bd9Sstevel@tonic-gate */ 8337c478bd9Sstevel@tonic-gate int jp_errata_85_allow_slow_scrub = 1; 8347c478bd9Sstevel@tonic-gate int jp_errata_85_enable = 0; 8357c478bd9Sstevel@tonic-gate #endif /* JALAPENO_ERRATA_85 */ 8367c478bd9Sstevel@tonic-gate 8377c478bd9Sstevel@tonic-gate static void 8387c478bd9Sstevel@tonic-gate check_cpus_ver(void) 8397c478bd9Sstevel@tonic-gate { 8407c478bd9Sstevel@tonic-gate int i; 8417c478bd9Sstevel@tonic-gate int impl, cpuid = getprocessorid(); 8427c478bd9Sstevel@tonic-gate int min_supported_rev; 8437c478bd9Sstevel@tonic-gate 8447c478bd9Sstevel@tonic-gate ASSERT(cpunodes[cpuid].nodeid != 0); 8457c478bd9Sstevel@tonic-gate 8467c478bd9Sstevel@tonic-gate impl = cpunodes[cpuid].implementation; 8477c478bd9Sstevel@tonic-gate switch (impl) { 8487c478bd9Sstevel@tonic-gate default: 8497c478bd9Sstevel@tonic-gate min_supported_rev = 0; 8507c478bd9Sstevel@tonic-gate break; 8517c478bd9Sstevel@tonic-gate case SPITFIRE_IMPL: 8527c478bd9Sstevel@tonic-gate min_supported_rev = SPITFIRE_MINREV_SUPPORTED; 8537c478bd9Sstevel@tonic-gate break; 8547c478bd9Sstevel@tonic-gate case CHEETAH_IMPL: 8557c478bd9Sstevel@tonic-gate min_supported_rev = CHEETAH_MINREV_SUPPORTED; 8567c478bd9Sstevel@tonic-gate break; 8577c478bd9Sstevel@tonic-gate } 8587c478bd9Sstevel@tonic-gate 8597c478bd9Sstevel@tonic-gate for (i = 0; i < NCPU; i++) { 8607c478bd9Sstevel@tonic-gate if (cpunodes[i].nodeid == 0) 8617c478bd9Sstevel@tonic-gate continue; 8627c478bd9Sstevel@tonic-gate 8637c478bd9Sstevel@tonic-gate if (IS_SPITFIRE(impl)) { 8647c478bd9Sstevel@tonic-gate if (cpunodes[i].version < min_supported_rev) { 8657c478bd9Sstevel@tonic-gate cmn_err(CE_PANIC, 8667c478bd9Sstevel@tonic-gate "UltraSPARC versions older than %d.%d" 8677c478bd9Sstevel@tonic-gate " are no longer supported (cpu #%d)", 8687c478bd9Sstevel@tonic-gate SPITFIRE_MAJOR_VERSION(min_supported_rev), 8697c478bd9Sstevel@tonic-gate SPITFIRE_MINOR_VERSION(min_supported_rev), i); 8707c478bd9Sstevel@tonic-gate } 8717c478bd9Sstevel@tonic-gate 8727c478bd9Sstevel@tonic-gate /* 8737c478bd9Sstevel@tonic-gate * Min supported rev is 2.1 but we've seen problems 8747c478bd9Sstevel@tonic-gate * with that so we still want to warn if we see one. 8757c478bd9Sstevel@tonic-gate */ 8767c478bd9Sstevel@tonic-gate if (cpunodes[i].version < 0x22) { 8777c478bd9Sstevel@tonic-gate cmn_err(CE_WARN, 8787c478bd9Sstevel@tonic-gate "UltraSPARC versions older than " 8797c478bd9Sstevel@tonic-gate "2.2 are not supported (cpu #%d)", i); 8807c478bd9Sstevel@tonic-gate #ifdef SF_ERRATA_30 /* call causes fp-disabled */ 8817c478bd9Sstevel@tonic-gate spitfire_call_bug = 1; 8827c478bd9Sstevel@tonic-gate #endif /* SF_ERRATA_30 */ 8837c478bd9Sstevel@tonic-gate } 8847c478bd9Sstevel@tonic-gate } 8857c478bd9Sstevel@tonic-gate 8867c478bd9Sstevel@tonic-gate 8877c478bd9Sstevel@tonic-gate #ifdef SF_V9_TABLE_28 /* fp over/underflow traps may cause wrong fsr.cexc */ 8887c478bd9Sstevel@tonic-gate if (IS_SPITFIRE(impl) || IS_BLACKBIRD(impl)) 8897c478bd9Sstevel@tonic-gate spitfire_bb_fsr_bug = 1; 8907c478bd9Sstevel@tonic-gate #endif /* SF_V9_TABLE_28 */ 8917c478bd9Sstevel@tonic-gate 8927c478bd9Sstevel@tonic-gate if (IS_CHEETAH(impl)) { 8937c478bd9Sstevel@tonic-gate if (cpunodes[i].version < min_supported_rev) { 8947c478bd9Sstevel@tonic-gate cmn_err(CE_PANIC, 8957c478bd9Sstevel@tonic-gate "UltraSPARC-III versions older than %d.%d" 8967c478bd9Sstevel@tonic-gate " are no longer supported (cpu #%d)", 8977c478bd9Sstevel@tonic-gate CHEETAH_MAJOR_VERSION(min_supported_rev), 8987c478bd9Sstevel@tonic-gate CHEETAH_MINOR_VERSION(min_supported_rev), i); 8997c478bd9Sstevel@tonic-gate } 9007c478bd9Sstevel@tonic-gate 9017c478bd9Sstevel@tonic-gate } 9027c478bd9Sstevel@tonic-gate 9037c478bd9Sstevel@tonic-gate #ifdef JALAPENO_ERRATA_85 9047c478bd9Sstevel@tonic-gate if (IS_JALAPENO(impl) && (cpunodes[i].version < 0x24)) { 9057c478bd9Sstevel@tonic-gate jp_errata_85_allow_slow_scrub = 0; 9067c478bd9Sstevel@tonic-gate jp_errata_85_enable = 1; 9077c478bd9Sstevel@tonic-gate } 9087c478bd9Sstevel@tonic-gate #endif /* JALAPENO_ERRATA_85 */ 9097c478bd9Sstevel@tonic-gate } 9107c478bd9Sstevel@tonic-gate } 9117c478bd9Sstevel@tonic-gate 9127c478bd9Sstevel@tonic-gate /* 9137c478bd9Sstevel@tonic-gate * Check for a legal set of CPUs. 9147c478bd9Sstevel@tonic-gate */ 9157c478bd9Sstevel@tonic-gate static void 9167c478bd9Sstevel@tonic-gate check_cpus_set(void) 9177c478bd9Sstevel@tonic-gate { 9187c478bd9Sstevel@tonic-gate int i; 9197c478bd9Sstevel@tonic-gate int impl; 9207c478bd9Sstevel@tonic-gate int npanther = 0; 9217c478bd9Sstevel@tonic-gate 9227c478bd9Sstevel@tonic-gate impl = cpunodes[getprocessorid()].implementation; 9237c478bd9Sstevel@tonic-gate 9247c478bd9Sstevel@tonic-gate switch (impl) { 9257c478bd9Sstevel@tonic-gate case CHEETAH_PLUS_IMPL: 9267c478bd9Sstevel@tonic-gate case JAGUAR_IMPL: 9277c478bd9Sstevel@tonic-gate case PANTHER_IMPL: 9287c478bd9Sstevel@tonic-gate /* 9297c478bd9Sstevel@tonic-gate * Check for a legal heterogeneous set of CPUs. 9307c478bd9Sstevel@tonic-gate */ 9317c478bd9Sstevel@tonic-gate for (i = 0; i < NCPU; i++) { 9327c478bd9Sstevel@tonic-gate if (cpunodes[i].nodeid == 0) 9337c478bd9Sstevel@tonic-gate continue; 9347c478bd9Sstevel@tonic-gate 9357c478bd9Sstevel@tonic-gate if (IS_PANTHER(cpunodes[i].implementation)) { 9367c478bd9Sstevel@tonic-gate npanther += 1; 9377c478bd9Sstevel@tonic-gate } 9387c478bd9Sstevel@tonic-gate 9397c478bd9Sstevel@tonic-gate if (!(IS_CHEETAH_PLUS(cpunodes[i].implementation) || 9407c478bd9Sstevel@tonic-gate IS_JAGUAR(cpunodes[i].implementation) || 9417c478bd9Sstevel@tonic-gate IS_PANTHER(cpunodes[i].implementation))) { 9427c478bd9Sstevel@tonic-gate use_mp = 0; 9437c478bd9Sstevel@tonic-gate break; 9447c478bd9Sstevel@tonic-gate } 9457c478bd9Sstevel@tonic-gate } 9467c478bd9Sstevel@tonic-gate break; 9477c478bd9Sstevel@tonic-gate default: 9487c478bd9Sstevel@tonic-gate /* 9497c478bd9Sstevel@tonic-gate * Check for a homogeneous set of CPUs. 9507c478bd9Sstevel@tonic-gate */ 9517c478bd9Sstevel@tonic-gate for (i = 0; i < NCPU; i++) { 9527c478bd9Sstevel@tonic-gate if (cpunodes[i].nodeid == 0) 9537c478bd9Sstevel@tonic-gate continue; 9547c478bd9Sstevel@tonic-gate 9557c478bd9Sstevel@tonic-gate if (cpunodes[i].implementation != impl) { 9567c478bd9Sstevel@tonic-gate use_mp = 0; 9577c478bd9Sstevel@tonic-gate break; 9587c478bd9Sstevel@tonic-gate } 9597c478bd9Sstevel@tonic-gate } 9607c478bd9Sstevel@tonic-gate break; 9617c478bd9Sstevel@tonic-gate } 9627c478bd9Sstevel@tonic-gate 9637c478bd9Sstevel@tonic-gate /* 9647c478bd9Sstevel@tonic-gate * Change from mmu_page_sizes from 4 to 6 for totally-Panther domains, 96535b14535Ssusans * where npanther == ncpunode. Also, set ecache_alignsize (and a few 96635b14535Ssusans * other globals) to the correct value for totally-Panther domains. 9677c478bd9Sstevel@tonic-gate */ 9687c478bd9Sstevel@tonic-gate if (&mmu_init_mmu_page_sizes) { 9697c478bd9Sstevel@tonic-gate (void) mmu_init_mmu_page_sizes(npanther); 9707c478bd9Sstevel@tonic-gate } 97135b14535Ssusans if ((npanther == ncpunode) && (&cpu_fix_allpanther)) { 97235b14535Ssusans cpu_fix_allpanther(); 97335b14535Ssusans } 9747c478bd9Sstevel@tonic-gate 9757c478bd9Sstevel@tonic-gate /* 9767c478bd9Sstevel@tonic-gate * Set max cpus we can have based on ncpunode and use_mp 9777c478bd9Sstevel@tonic-gate */ 9787c478bd9Sstevel@tonic-gate if (use_mp) { 9797c478bd9Sstevel@tonic-gate int (*set_max_ncpus)(void); 9807c478bd9Sstevel@tonic-gate 9817c478bd9Sstevel@tonic-gate set_max_ncpus = (int (*)(void)) 9827c478bd9Sstevel@tonic-gate kobj_getsymvalue("set_platform_max_ncpus", 0); 9837c478bd9Sstevel@tonic-gate 9847c478bd9Sstevel@tonic-gate if (set_max_ncpus) { 9857c478bd9Sstevel@tonic-gate max_ncpus = set_max_ncpus(); 9867c478bd9Sstevel@tonic-gate if (max_ncpus < ncpunode) 9877c478bd9Sstevel@tonic-gate max_ncpus = ncpunode; 9887c478bd9Sstevel@tonic-gate boot_max_ncpus = ncpunode; 9897c478bd9Sstevel@tonic-gate } else { 9907c478bd9Sstevel@tonic-gate max_ncpus = ncpunode; 9917c478bd9Sstevel@tonic-gate } 9927c478bd9Sstevel@tonic-gate } else { 9937c478bd9Sstevel@tonic-gate cmn_err(CE_NOTE, "MP not supported on mismatched modules," 9947c478bd9Sstevel@tonic-gate " booting UP only"); 9957c478bd9Sstevel@tonic-gate 9967c478bd9Sstevel@tonic-gate for (i = 0; i < NCPU; i++) { 9977c478bd9Sstevel@tonic-gate if (cpunodes[i].nodeid == 0) 9987c478bd9Sstevel@tonic-gate continue; 9997c478bd9Sstevel@tonic-gate 10007c478bd9Sstevel@tonic-gate cmn_err(CE_NOTE, "cpu%d: %s version 0x%x", i, 10017c478bd9Sstevel@tonic-gate cpunodes[i].name, cpunodes[i].version); 10027c478bd9Sstevel@tonic-gate } 10037c478bd9Sstevel@tonic-gate 10047c478bd9Sstevel@tonic-gate max_ncpus = 1; 10057c478bd9Sstevel@tonic-gate } 10067c478bd9Sstevel@tonic-gate } 10077c478bd9Sstevel@tonic-gate 10087c478bd9Sstevel@tonic-gate /* 10097c478bd9Sstevel@tonic-gate * The first sysio must always programmed up for the system clock and error 10107c478bd9Sstevel@tonic-gate * handling purposes, referenced by v_sysio_addr in machdep.c. 10117c478bd9Sstevel@tonic-gate */ 10127c478bd9Sstevel@tonic-gate static void 1013fa9e4066Sahrens have_sbus(pnode_t node) 10147c478bd9Sstevel@tonic-gate { 10157c478bd9Sstevel@tonic-gate int size; 10167c478bd9Sstevel@tonic-gate uint_t portid; 10177c478bd9Sstevel@tonic-gate 10187c478bd9Sstevel@tonic-gate size = GETPROPLEN(node, "upa-portid"); 10197c478bd9Sstevel@tonic-gate if (size == -1 || size > sizeof (portid)) 10207c478bd9Sstevel@tonic-gate cmn_err(CE_PANIC, "upa-portid size"); 10217c478bd9Sstevel@tonic-gate if (GETPROP(node, "upa-portid", (caddr_t)&portid) == -1) 10227c478bd9Sstevel@tonic-gate cmn_err(CE_PANIC, "upa-portid"); 10237c478bd9Sstevel@tonic-gate 10247c478bd9Sstevel@tonic-gate niobus++; 10257c478bd9Sstevel@tonic-gate 10267c478bd9Sstevel@tonic-gate /* 10277c478bd9Sstevel@tonic-gate * need one physical TSB 10287c478bd9Sstevel@tonic-gate */ 10297c478bd9Sstevel@tonic-gate niommu_tsbs++; 10307c478bd9Sstevel@tonic-gate } 10317c478bd9Sstevel@tonic-gate 10327c478bd9Sstevel@tonic-gate 10337c478bd9Sstevel@tonic-gate #define IOMMU_PER_SCHIZO 2 10347c478bd9Sstevel@tonic-gate 10357c478bd9Sstevel@tonic-gate /* 10367c478bd9Sstevel@tonic-gate * The first psycho must always programmed up for the system clock and error 10377c478bd9Sstevel@tonic-gate * handling purposes. 10387c478bd9Sstevel@tonic-gate */ 10397c478bd9Sstevel@tonic-gate static void 1040fa9e4066Sahrens have_pci(pnode_t node) 10417c478bd9Sstevel@tonic-gate { 10427c478bd9Sstevel@tonic-gate int size; 10437c478bd9Sstevel@tonic-gate uint_t portid; 10447c478bd9Sstevel@tonic-gate char compatible[OBP_MAXDRVNAME]; 10457c478bd9Sstevel@tonic-gate 10467c478bd9Sstevel@tonic-gate size = GETPROPLEN(node, "portid"); 10477c478bd9Sstevel@tonic-gate if (size == -1) size = GETPROPLEN(node, "upa-portid"); 10487c478bd9Sstevel@tonic-gate if (size == -1) 10497c478bd9Sstevel@tonic-gate return; 10507c478bd9Sstevel@tonic-gate if (size > sizeof (portid)) 10517c478bd9Sstevel@tonic-gate cmn_err(CE_PANIC, "portid size wrong"); 10527c478bd9Sstevel@tonic-gate 10537c478bd9Sstevel@tonic-gate if (GETPROP(node, "portid", (caddr_t)&portid) == -1) 10547c478bd9Sstevel@tonic-gate if (GETPROP(node, "upa-portid", (caddr_t)&portid) == -1) 10557c478bd9Sstevel@tonic-gate cmn_err(CE_PANIC, "portid not found"); 10567c478bd9Sstevel@tonic-gate 10577c478bd9Sstevel@tonic-gate niobus++; 10587c478bd9Sstevel@tonic-gate 10597c478bd9Sstevel@tonic-gate 10607c478bd9Sstevel@tonic-gate /* 10617c478bd9Sstevel@tonic-gate * Need two physical TSBs for Schizo compatible nodes, 10627c478bd9Sstevel@tonic-gate * one otherwise. 10637c478bd9Sstevel@tonic-gate */ 10647c478bd9Sstevel@tonic-gate compatible[0] = '\0'; 10657c478bd9Sstevel@tonic-gate (void) prom_getprop(node, OBP_COMPATIBLE, compatible); 10667c478bd9Sstevel@tonic-gate if (strcmp(compatible, "pci108e,8001") == 0) 10677c478bd9Sstevel@tonic-gate niommu_tsbs += IOMMU_PER_SCHIZO; 10687c478bd9Sstevel@tonic-gate else 10697c478bd9Sstevel@tonic-gate niommu_tsbs++; 10707c478bd9Sstevel@tonic-gate } 10717c478bd9Sstevel@tonic-gate 10727c478bd9Sstevel@tonic-gate /* 10737c478bd9Sstevel@tonic-gate * The first eeprom is used as the TOD clock, referenced 10747c478bd9Sstevel@tonic-gate * by v_eeprom_addr in locore.s. 10757c478bd9Sstevel@tonic-gate */ 10767c478bd9Sstevel@tonic-gate static void 1077fa9e4066Sahrens have_eeprom(pnode_t node) 10787c478bd9Sstevel@tonic-gate { 10797c478bd9Sstevel@tonic-gate int size; 10807c478bd9Sstevel@tonic-gate uint32_t eaddr; 10817c478bd9Sstevel@tonic-gate 10827c478bd9Sstevel@tonic-gate /* 10837c478bd9Sstevel@tonic-gate * "todmostek" module will be selected based on finding a "model" 10847c478bd9Sstevel@tonic-gate * property value of "mk48t59" in the "eeprom" node. 10857c478bd9Sstevel@tonic-gate */ 10867c478bd9Sstevel@tonic-gate if (tod_module_name == NULL) { 10877c478bd9Sstevel@tonic-gate char buf[MAXSYSNAME]; 10887c478bd9Sstevel@tonic-gate 10897c478bd9Sstevel@tonic-gate if ((GETPROP(node, "model", buf) != -1) && 10907c478bd9Sstevel@tonic-gate (strcmp(buf, "mk48t59") == 0)) 10917c478bd9Sstevel@tonic-gate tod_module_name = "todmostek"; 10927c478bd9Sstevel@tonic-gate } 10937c478bd9Sstevel@tonic-gate 10947c478bd9Sstevel@tonic-gate /* 10957c478bd9Sstevel@tonic-gate * If we have found two distinct eeprom's, then we're done. 10967c478bd9Sstevel@tonic-gate */ 10977c478bd9Sstevel@tonic-gate if (v_eeprom_addr && v_timecheck_addr != v_eeprom_addr) 10987c478bd9Sstevel@tonic-gate return; 10997c478bd9Sstevel@tonic-gate 11007c478bd9Sstevel@tonic-gate /* 11017c478bd9Sstevel@tonic-gate * multiple eeproms may exist but at least 11027c478bd9Sstevel@tonic-gate * one must have an "address" property 11037c478bd9Sstevel@tonic-gate */ 11047c478bd9Sstevel@tonic-gate if ((size = GETPROPLEN(node, OBP_ADDRESS)) == -1) 11057c478bd9Sstevel@tonic-gate return; 11067c478bd9Sstevel@tonic-gate if (size != sizeof (eaddr)) 11077c478bd9Sstevel@tonic-gate cmn_err(CE_PANIC, "eeprom addr size"); 11087c478bd9Sstevel@tonic-gate if (GETPROP(node, OBP_ADDRESS, (caddr_t)&eaddr) == -1) 11097c478bd9Sstevel@tonic-gate cmn_err(CE_PANIC, "eeprom addr"); 11107c478bd9Sstevel@tonic-gate 11117c478bd9Sstevel@tonic-gate /* 11127c478bd9Sstevel@tonic-gate * If we have a chosen eeprom and it is not this node, keep looking. 11137c478bd9Sstevel@tonic-gate */ 11147c478bd9Sstevel@tonic-gate if (chosen_eeprom != NULL && chosen_eeprom != node) { 1115f166393fSesolom v_timecheck_addr = (caddr_t)(uintptr_t)eaddr; 11167c478bd9Sstevel@tonic-gate return; 11177c478bd9Sstevel@tonic-gate } 11187c478bd9Sstevel@tonic-gate 1119f166393fSesolom v_eeprom_addr = (caddr_t)(uintptr_t)eaddr; 11207c478bd9Sstevel@tonic-gate 11217c478bd9Sstevel@tonic-gate /* 11227c478bd9Sstevel@tonic-gate * If we don't find an I/O board to use to check the clock, 11237c478bd9Sstevel@tonic-gate * we'll fall back on whichever TOD is available. 11247c478bd9Sstevel@tonic-gate */ 11257c478bd9Sstevel@tonic-gate if (v_timecheck_addr == NULL) 11267c478bd9Sstevel@tonic-gate v_timecheck_addr = v_eeprom_addr; 11277c478bd9Sstevel@tonic-gate 11287c478bd9Sstevel@tonic-gate /* 11297c478bd9Sstevel@tonic-gate * Does this eeprom have watchdog support? 11307c478bd9Sstevel@tonic-gate */ 11317c478bd9Sstevel@tonic-gate if (GETPROPLEN(node, WATCHDOG_ENABLE) != -1) 11327c478bd9Sstevel@tonic-gate watchdog_available = 1; 11337c478bd9Sstevel@tonic-gate } 11347c478bd9Sstevel@tonic-gate 11357c478bd9Sstevel@tonic-gate static void 1136fa9e4066Sahrens have_rtc(pnode_t node) 11377c478bd9Sstevel@tonic-gate { 11387c478bd9Sstevel@tonic-gate int size; 11397c478bd9Sstevel@tonic-gate uint32_t eaddr; 11407c478bd9Sstevel@tonic-gate 11417c478bd9Sstevel@tonic-gate /* 11427c478bd9Sstevel@tonic-gate * "ds1287" module will be selected based on finding a "model" 11437c478bd9Sstevel@tonic-gate * property value of "ds1287" in the "rtc" node. 11447c478bd9Sstevel@tonic-gate */ 11457c478bd9Sstevel@tonic-gate if (tod_module_name == NULL) { 11467c478bd9Sstevel@tonic-gate char buf[MAXSYSNAME]; 11477c478bd9Sstevel@tonic-gate 11487c478bd9Sstevel@tonic-gate if (GETPROP(node, "model", buf) != -1) { 11497c478bd9Sstevel@tonic-gate if ((strcmp(buf, "m5819p") == 0) || 11507c478bd9Sstevel@tonic-gate (strcmp(buf, "m5823") == 0)) 11517c478bd9Sstevel@tonic-gate tod_module_name = "todm5823"; 11527c478bd9Sstevel@tonic-gate else if (strcmp(buf, "ds1287") == 0) 11537c478bd9Sstevel@tonic-gate tod_module_name = "todds1287"; 11547c478bd9Sstevel@tonic-gate } 11557c478bd9Sstevel@tonic-gate } 11567c478bd9Sstevel@tonic-gate 11577c478bd9Sstevel@tonic-gate /* 11587c478bd9Sstevel@tonic-gate * XXX - drives on if address prop doesn't exist, later falls 11597c478bd9Sstevel@tonic-gate * over in tod module 11607c478bd9Sstevel@tonic-gate */ 11617c478bd9Sstevel@tonic-gate if ((size = GETPROPLEN(node, OBP_ADDRESS)) == -1) 11627c478bd9Sstevel@tonic-gate return; 11637c478bd9Sstevel@tonic-gate if (size != sizeof (eaddr)) 11647c478bd9Sstevel@tonic-gate cmn_err(CE_PANIC, "rtc addr size"); 11657c478bd9Sstevel@tonic-gate if (GETPROP(node, OBP_ADDRESS, (caddr_t)&eaddr) == -1) 11667c478bd9Sstevel@tonic-gate cmn_err(CE_PANIC, "rtc addr"); 11677c478bd9Sstevel@tonic-gate 1168f166393fSesolom v_rtc_addr_reg = (caddr_t)(uintptr_t)eaddr; 1169f166393fSesolom v_rtc_data_reg = (volatile unsigned char *)(uintptr_t)eaddr + 1; 11707c478bd9Sstevel@tonic-gate 11717c478bd9Sstevel@tonic-gate /* 11727c478bd9Sstevel@tonic-gate * Does this rtc have watchdog support? 11737c478bd9Sstevel@tonic-gate */ 11747c478bd9Sstevel@tonic-gate if (GETPROPLEN(node, WATCHDOG_ENABLE) != -1) 11757c478bd9Sstevel@tonic-gate watchdog_available = 1; 11767c478bd9Sstevel@tonic-gate } 11777c478bd9Sstevel@tonic-gate 11787c478bd9Sstevel@tonic-gate static void 1179fa9e4066Sahrens have_pmc(pnode_t node) 11807c478bd9Sstevel@tonic-gate { 11817c478bd9Sstevel@tonic-gate uint32_t vaddr; 1182fa9e4066Sahrens pnode_t root; 11837c478bd9Sstevel@tonic-gate 11847c478bd9Sstevel@tonic-gate /* 11857c478bd9Sstevel@tonic-gate * Watchdog property is in the root node. 11867c478bd9Sstevel@tonic-gate */ 1187fa9e4066Sahrens root = prom_nextnode((pnode_t)0); 11887c478bd9Sstevel@tonic-gate if (GETPROPLEN(root, WATCHDOG_ENABLE) != -1) { 11897c478bd9Sstevel@tonic-gate /* 11907c478bd9Sstevel@tonic-gate * The hardware watchdog timer resides within logical 11917c478bd9Sstevel@tonic-gate * unit 8 of SuperI/O. The address property of the node 11927c478bd9Sstevel@tonic-gate * contains the virtual address that we use to program 11937c478bd9Sstevel@tonic-gate * the timer. 11947c478bd9Sstevel@tonic-gate */ 11957c478bd9Sstevel@tonic-gate if (GETPROP(node, OBP_ADDRESS, (caddr_t)&vaddr) == -1) { 11967c478bd9Sstevel@tonic-gate watchdog_available = 0; 11977c478bd9Sstevel@tonic-gate return; 11987c478bd9Sstevel@tonic-gate } 1199f166393fSesolom v_pmc_addr_reg = (volatile uint8_t *)(uintptr_t)vaddr; 1200f166393fSesolom v_pmc_data_reg = (volatile uint8_t *)(uintptr_t)vaddr + 1; 12017c478bd9Sstevel@tonic-gate watchdog_available = 1; 12027c478bd9Sstevel@tonic-gate } 12037c478bd9Sstevel@tonic-gate } 12047c478bd9Sstevel@tonic-gate 12057c478bd9Sstevel@tonic-gate static void 1206fa9e4066Sahrens have_auxio(pnode_t node) 12077c478bd9Sstevel@tonic-gate { 12087c478bd9Sstevel@tonic-gate size_t size, n; 12097c478bd9Sstevel@tonic-gate uint32_t addr[5]; 12107c478bd9Sstevel@tonic-gate 12117c478bd9Sstevel@tonic-gate /* 12127c478bd9Sstevel@tonic-gate * Get the size of the auzio's address property. 12137c478bd9Sstevel@tonic-gate * On some platforms, the address property contains one 12147c478bd9Sstevel@tonic-gate * entry and on others it contains five entries. 12157c478bd9Sstevel@tonic-gate * In all cases, the first entries are compatible. 12167c478bd9Sstevel@tonic-gate * 12177c478bd9Sstevel@tonic-gate * This routine gets the address property for the auxio 12187c478bd9Sstevel@tonic-gate * node and stores the first entry in v_auxio_addr which 12197c478bd9Sstevel@tonic-gate * is used by the routine set_auxioreg in sun4u/ml/locore.s. 12207c478bd9Sstevel@tonic-gate */ 12217c478bd9Sstevel@tonic-gate if ((size = GETPROPLEN(node, OBP_ADDRESS)) == -1) 12227c478bd9Sstevel@tonic-gate cmn_err(CE_PANIC, "no auxio address property"); 12237c478bd9Sstevel@tonic-gate 12247c478bd9Sstevel@tonic-gate switch (n = (size / sizeof (addr[0]))) { 12257c478bd9Sstevel@tonic-gate case 1: 12267c478bd9Sstevel@tonic-gate break; 12277c478bd9Sstevel@tonic-gate case 5: 12287c478bd9Sstevel@tonic-gate break; 12297c478bd9Sstevel@tonic-gate default: 12307c478bd9Sstevel@tonic-gate cmn_err(CE_PANIC, "auxio addr has %lu entries?", n); 12317c478bd9Sstevel@tonic-gate } 12327c478bd9Sstevel@tonic-gate 12337c478bd9Sstevel@tonic-gate if (GETPROP(node, OBP_ADDRESS, (caddr_t)addr) == -1) 12347c478bd9Sstevel@tonic-gate cmn_err(CE_PANIC, "auxio addr"); 12357c478bd9Sstevel@tonic-gate 1236f166393fSesolom v_auxio_addr = (caddr_t)(uintptr_t)(addr[0]); /* make into pointer */ 12377c478bd9Sstevel@tonic-gate } 12387c478bd9Sstevel@tonic-gate 12397c478bd9Sstevel@tonic-gate static void 1240fa9e4066Sahrens have_tod(pnode_t node) 12417c478bd9Sstevel@tonic-gate { 12427c478bd9Sstevel@tonic-gate static char tod_name[MAXSYSNAME]; 12437c478bd9Sstevel@tonic-gate 12447c478bd9Sstevel@tonic-gate if (GETPROP(node, OBP_NAME, (caddr_t)tod_name) == -1) 12457c478bd9Sstevel@tonic-gate cmn_err(CE_PANIC, "tod name"); 12467c478bd9Sstevel@tonic-gate /* 12477c478bd9Sstevel@tonic-gate * This is a node with "device_type" property value of "tod". 12487c478bd9Sstevel@tonic-gate * Name of the tod module is the name from the node. 12497c478bd9Sstevel@tonic-gate */ 12507c478bd9Sstevel@tonic-gate tod_module_name = tod_name; 12517c478bd9Sstevel@tonic-gate } 1252