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 5b0fc0e77Sgovinda * Common Development and Distribution License (the "License"). 6b0fc0e77Sgovinda * 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*1f10d449SChristopher Baumbauer - Oracle America - San Diego United States * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 237c478bd9Sstevel@tonic-gate */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate /* 267c478bd9Sstevel@tonic-gate * sun4u common CPC subroutines. 277c478bd9Sstevel@tonic-gate */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #include <sys/types.h> 307c478bd9Sstevel@tonic-gate #include <sys/time.h> 317c478bd9Sstevel@tonic-gate #include <sys/atomic.h> 327c478bd9Sstevel@tonic-gate #include <sys/thread.h> 337c478bd9Sstevel@tonic-gate #include <sys/regset.h> 347c478bd9Sstevel@tonic-gate #include <sys/archsystm.h> 357c478bd9Sstevel@tonic-gate #include <sys/machsystm.h> 367c478bd9Sstevel@tonic-gate #include <sys/cpc_impl.h> 377c478bd9Sstevel@tonic-gate #include <sys/cpc_ultra.h> 387c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 397c478bd9Sstevel@tonic-gate #include <sys/intr.h> 407c478bd9Sstevel@tonic-gate #include <sys/ivintr.h> 417c478bd9Sstevel@tonic-gate #include <sys/x_call.h> 427c478bd9Sstevel@tonic-gate #include <sys/cpuvar.h> 437c478bd9Sstevel@tonic-gate #include <sys/machcpuvar.h> 447c478bd9Sstevel@tonic-gate #include <sys/cpc_pcbe.h> 457c478bd9Sstevel@tonic-gate #include <sys/modctl.h> 467c478bd9Sstevel@tonic-gate #include <sys/sdt.h> 477c478bd9Sstevel@tonic-gate 48*1f10d449SChristopher Baumbauer - Oracle America - San Diego United States uint64_t cpc_level15_inum = 0; /* used in interrupt.s */ 497c478bd9Sstevel@tonic-gate int cpc_has_overflow_intr; /* set in cheetah.c */ 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate extern kcpc_ctx_t *kcpc_overflow_intr(caddr_t arg, uint64_t bitmap); 527c478bd9Sstevel@tonic-gate extern int kcpc_counts_include_idle; 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate /* 557c478bd9Sstevel@tonic-gate * Called on the boot CPU during startup. 567c478bd9Sstevel@tonic-gate */ 577c478bd9Sstevel@tonic-gate void 587c478bd9Sstevel@tonic-gate kcpc_hw_init(void) 597c478bd9Sstevel@tonic-gate { 60*1f10d449SChristopher Baumbauer - Oracle America - San Diego United States if ((cpc_has_overflow_intr) && (cpc_level15_inum == 0)) { 617c478bd9Sstevel@tonic-gate cpc_level15_inum = add_softintr(PIL_15, 62b0fc0e77Sgovinda kcpc_hw_overflow_intr, NULL, SOFTINT_MT); 637c478bd9Sstevel@tonic-gate } 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate /* 667c478bd9Sstevel@tonic-gate * Make sure the boot CPU gets set up. 677c478bd9Sstevel@tonic-gate */ 687c478bd9Sstevel@tonic-gate kcpc_hw_startup_cpu(CPU->cpu_flags); 697c478bd9Sstevel@tonic-gate } 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate /* 727c478bd9Sstevel@tonic-gate * Prepare for CPC interrupts and install an idle thread CPC context. 737c478bd9Sstevel@tonic-gate */ 747c478bd9Sstevel@tonic-gate void 757c478bd9Sstevel@tonic-gate kcpc_hw_startup_cpu(ushort_t cpflags) 767c478bd9Sstevel@tonic-gate { 777c478bd9Sstevel@tonic-gate cpu_t *cp = CPU; 787c478bd9Sstevel@tonic-gate kthread_t *t = cp->cpu_idle_thread; 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate ASSERT(t->t_bound_cpu == cp); 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate if (cpc_has_overflow_intr && (cpflags & CPU_FROZEN) == 0) { 837c478bd9Sstevel@tonic-gate int pstate_save = disable_vec_intr(); 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate ASSERT(cpc_level15_inum != 0); 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate intr_enqueue_req(PIL_15, cpc_level15_inum); 887c478bd9Sstevel@tonic-gate enable_vec_intr(pstate_save); 897c478bd9Sstevel@tonic-gate } 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate mutex_init(&cp->cpu_cpc_ctxlock, "cpu_cpc_ctxlock", MUTEX_DEFAULT, 0); 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate if (kcpc_counts_include_idle) 947c478bd9Sstevel@tonic-gate return; 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate installctx(t, cp, kcpc_idle_save, kcpc_idle_restore, NULL, NULL, 977c478bd9Sstevel@tonic-gate NULL, NULL); 987c478bd9Sstevel@tonic-gate } 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate /* 1017c478bd9Sstevel@tonic-gate * Examine the processor and load an appropriate PCBE. 1027c478bd9Sstevel@tonic-gate */ 1037c478bd9Sstevel@tonic-gate int 1047c478bd9Sstevel@tonic-gate kcpc_hw_load_pcbe(void) 1057c478bd9Sstevel@tonic-gate { 1067c478bd9Sstevel@tonic-gate char modname[MODMAXNAMELEN+1]; 1077c478bd9Sstevel@tonic-gate char *p, *q; 1087c478bd9Sstevel@tonic-gate int len, stat; 1097c478bd9Sstevel@tonic-gate extern char *boot_cpu_compatible_list; 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate for (stat = -1, p = boot_cpu_compatible_list; p != NULL; p = q) { 1127c478bd9Sstevel@tonic-gate /* 1137c478bd9Sstevel@tonic-gate * Get next CPU module name from boot_cpu_compatible_list 1147c478bd9Sstevel@tonic-gate */ 1157c478bd9Sstevel@tonic-gate q = strchr(p, ':'); 1167c478bd9Sstevel@tonic-gate len = (q) ? (q - p) : strlen(p); 1177c478bd9Sstevel@tonic-gate if (len < sizeof (modname)) { 1187c478bd9Sstevel@tonic-gate (void) strncpy(modname, p, len); 1197c478bd9Sstevel@tonic-gate modname[len] = '\0'; 1207c478bd9Sstevel@tonic-gate stat = kcpc_pcbe_tryload(modname, 0, 0, 0); 1217c478bd9Sstevel@tonic-gate if (stat == 0) 1227c478bd9Sstevel@tonic-gate break; 1237c478bd9Sstevel@tonic-gate } 1247c478bd9Sstevel@tonic-gate if (q) 1257c478bd9Sstevel@tonic-gate q++; /* skip over ':' */ 1267c478bd9Sstevel@tonic-gate } 1277c478bd9Sstevel@tonic-gate return (stat); 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate } 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 1327c478bd9Sstevel@tonic-gate int 1337c478bd9Sstevel@tonic-gate kcpc_hw_cpu_hook(processorid_t cpuid, ulong_t *kcpc_cpumap) 1347c478bd9Sstevel@tonic-gate { 1357c478bd9Sstevel@tonic-gate return (0); 1367c478bd9Sstevel@tonic-gate } 1377c478bd9Sstevel@tonic-gate 1387c478bd9Sstevel@tonic-gate int 1397c478bd9Sstevel@tonic-gate kcpc_hw_lwp_hook(void) 1407c478bd9Sstevel@tonic-gate { 1417c478bd9Sstevel@tonic-gate return (0); 1427c478bd9Sstevel@tonic-gate } 143