4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
26 * sun4u common CPC subroutines.
29 #include <sys/types.h>
31 #include <sys/atomic.h>
32 #include <sys/thread.h>
33 #include <sys/regset.h>
34 #include <sys/archsystm.h>
35 #include <sys/machsystm.h>
36 #include <sys/cpc_impl.h>
37 #include <sys/cpc_ultra.h>
38 #include <sys/sunddi.h>
40 #include <sys/ivintr.h>
41 #include <sys/x_call.h>
42 #include <sys/cpuvar.h>
43 #include <sys/machcpuvar.h>
44 #include <sys/cpc_pcbe.h>
45 #include <sys/modctl.h>
49 uint64_t cpc_level15_inum
= 0; /* used in interrupt.s */
50 int cpc_has_overflow_intr
; /* set in cheetah.c */
52 extern kcpc_ctx_t
*kcpc_overflow_intr(caddr_t arg
, uint64_t bitmap
);
53 extern int kcpc_counts_include_idle
;
56 * Called on the boot CPU during startup.
61 if ((cpc_has_overflow_intr
) && (cpc_level15_inum
== 0)) {
62 cpc_level15_inum
= add_softintr(PIL_15
,
63 kcpc_hw_overflow_intr
, NULL
, SOFTINT_MT
);
67 * Make sure the boot CPU gets set up.
69 kcpc_hw_startup_cpu(CPU
->cpu_flags
);
73 * Prepare for CPC interrupts and install an idle thread CPC context.
76 kcpc_hw_startup_cpu(ushort_t cpflags
)
79 kthread_t
*t
= cp
->cpu_idle_thread
;
81 ASSERT(t
->t_bound_cpu
== cp
);
83 if (cpc_has_overflow_intr
&& (cpflags
& CPU_FROZEN
) == 0) {
84 int pstate_save
= disable_vec_intr();
86 ASSERT(cpc_level15_inum
!= 0);
88 intr_enqueue_req(PIL_15
, cpc_level15_inum
);
89 enable_vec_intr(pstate_save
);
92 mutex_init(&cp
->cpu_cpc_ctxlock
, "cpu_cpc_ctxlock", MUTEX_DEFAULT
, 0);
94 if (kcpc_counts_include_idle
)
97 installctx(t
, cp
, kcpc_idle_save
, kcpc_idle_restore
, NULL
, NULL
,
102 * Examine the processor and load an appropriate PCBE.
105 kcpc_hw_load_pcbe(void)
107 uint64_t ver
= ultra_getver();
109 return (kcpc_pcbe_tryload(NULL
, ULTRA_VER_MANUF(ver
),
110 ULTRA_VER_IMPL(ver
), ULTRA_VER_MASK(ver
)));
115 kcpc_hw_cpu_hook(processorid_t cpuid
, ulong_t
*kcpc_cpumap
)
121 kcpc_hw_lwp_hook(void)