qemu-e2k/target/ppc/power8-pmu.c

63 lines
1.4 KiB
C
Raw Normal View History

/*
* PMU emulation helpers for TCG IBM POWER chips
*
* Copyright IBM Corp. 2021
*
* Authors:
* Daniel Henrique Barboza <danielhb413@gmail.com>
*
* This work is licensed under the terms of the GNU GPL, version 2 or later.
* See the COPYING file in the top-level directory.
*/
#include "qemu/osdep.h"
#include "power8-pmu.h"
#include "cpu.h"
#include "helper_regs.h"
#include "exec/exec-all.h"
#include "exec/helper-proto.h"
#include "qemu/error-report.h"
#include "qemu/main-loop.h"
#include "hw/ppc/ppc.h"
#if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY)
static void fire_PMC_interrupt(PowerPCCPU *cpu)
{
CPUPPCState *env = &cpu->env;
if (!(env->spr[SPR_POWER_MMCR0] & MMCR0_EBE)) {
return;
}
/* PMC interrupt not implemented yet */
return;
}
static void cpu_ppc_pmu_timer_cb(void *opaque)
{
PowerPCCPU *cpu = opaque;
fire_PMC_interrupt(cpu);
}
void cpu_ppc_pmu_init(CPUPPCState *env)
{
PowerPCCPU *cpu = env_archcpu(env);
int i, sprn;
for (sprn = SPR_POWER_PMC1; sprn <= SPR_POWER_PMC6; sprn++) {
if (sprn == SPR_POWER_PMC5) {
continue;
}
i = sprn - SPR_POWER_PMC1;
env->pmu_cyc_overflow_timers[i] = timer_new_ns(QEMU_CLOCK_VIRTUAL,
&cpu_ppc_pmu_timer_cb,
cpu);
}
}
#endif /* defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY) */