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