2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A/*
2N/A * sun4u common CPC subroutines.
2N/A */
2N/A
2N/A#include <sys/types.h>
2N/A#include <sys/time.h>
2N/A#include <sys/atomic.h>
2N/A#include <sys/thread.h>
2N/A#include <sys/regset.h>
2N/A#include <sys/archsystm.h>
2N/A#include <sys/machsystm.h>
2N/A#include <sys/cpc_impl.h>
2N/A#include <sys/cpc_ultra.h>
2N/A#include <sys/sunddi.h>
2N/A#include <sys/intr.h>
2N/A#include <sys/ivintr.h>
2N/A#include <sys/x_call.h>
2N/A#include <sys/cpuvar.h>
2N/A#include <sys/machcpuvar.h>
2N/A#include <sys/cpc_pcbe.h>
2N/A#include <sys/modctl.h>
2N/A#include <sys/sdt.h>
2N/A
2N/Auint64_t cpc_level15_inum = 0; /* used in interrupt.s */
2N/Aint cpc_has_overflow_intr; /* set in cheetah.c */
2N/A
2N/Aextern kcpc_ctx_t *kcpc_overflow_intr(caddr_t arg, uint64_t bitmap);
2N/Aextern int kcpc_counts_include_idle;
2N/A
2N/A/*
2N/A * Called on the boot CPU during startup.
2N/A */
2N/Avoid
2N/Akcpc_hw_init(void)
2N/A{
2N/A if ((cpc_has_overflow_intr) && (cpc_level15_inum == 0)) {
2N/A cpc_level15_inum = add_softintr(PIL_15,
2N/A kcpc_hw_overflow_intr, NULL, SOFTINT_MT);
2N/A }
2N/A
2N/A /*
2N/A * Make sure the boot CPU gets set up.
2N/A */
2N/A kcpc_hw_startup_cpu(CPU->cpu_flags);
2N/A}
2N/A
2N/A/*
2N/A * Prepare for CPC interrupts and install an idle thread CPC context.
2N/A */
2N/Avoid
2N/Akcpc_hw_startup_cpu(ushort_t cpflags)
2N/A{
2N/A cpu_t *cp = CPU;
2N/A kthread_t *t = cp->cpu_idle_thread;
2N/A
2N/A ASSERT(t->t_bound_cpu == cp);
2N/A
2N/A if (cpc_has_overflow_intr && (cpflags & CPU_FROZEN) == 0) {
2N/A int pstate_save = disable_vec_intr();
2N/A
2N/A ASSERT(cpc_level15_inum != 0);
2N/A
2N/A intr_enqueue_req(PIL_15, cpc_level15_inum);
2N/A enable_vec_intr(pstate_save);
2N/A }
2N/A
2N/A mutex_init(&cp->cpu_cpc_ctxlock, "cpu_cpc_ctxlock", MUTEX_DEFAULT, 0);
2N/A
2N/A if (kcpc_counts_include_idle)
2N/A return;
2N/A
2N/A installctx(t, cp, kcpc_idle_save, kcpc_idle_restore, NULL, NULL,
NULL, NULL);
}
/*
* Examine the processor and load an appropriate PCBE.
*/
int
kcpc_hw_load_pcbe(void)
{
char modname[MODMAXNAMELEN+1];
char *p, *q;
int len, stat;
extern char *boot_cpu_compatible_list;
for (stat = -1, p = boot_cpu_compatible_list; p != NULL; p = q) {
/*
* Get next CPU module name from boot_cpu_compatible_list
*/
q = strchr(p, ':');
len = (q) ? (q - p) : strlen(p);
if (len < sizeof (modname)) {
(void) strncpy(modname, p, len);
modname[len] = '\0';
stat = kcpc_pcbe_tryload(modname, 0, 0, 0);
if (stat == 0)
break;
}
if (q)
q++; /* skip over ':' */
}
return (stat);
}
/*ARGSUSED*/
int
kcpc_hw_cpu_hook(processorid_t cpuid, ulong_t *kcpc_cpumap)
{
return (0);
}
int
kcpc_hw_lwp_hook(void)
{
return (0);
}