summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRemy Noel <mocramis@gmail.com>2018-03-26 05:45:36 +0200
committerRemy Noel <mocramis@gmail.com>2018-04-21 00:04:20 +0200
commitb6ee3f35eb82e826e800cdc4ba483c1428a6e6d6 (patch)
treeff6f1aec7558b6af553273a720d80f77b548d019
parentc59b444cf25e01de7911514af9ebc15d342197b5 (diff)
perfmon: add perfmon overflow interrupt.
-rw-r--r--arch/x86/machine/lapic.c11
-rw-r--r--arch/x86/machine/lapic.h1
-rw-r--r--arch/x86/machine/trap.c1
-rw-r--r--arch/x86/machine/trap.h1
4 files changed, 13 insertions, 1 deletions
diff --git a/arch/x86/machine/lapic.c b/arch/x86/machine/lapic.c
index 3f6d0c2..ebff5fc 100644
--- a/arch/x86/machine/lapic.c
+++ b/arch/x86/machine/lapic.c
@@ -25,6 +25,7 @@
#include <kern/log.h>
#include <kern/macros.h>
#include <kern/panic.h>
+#include <kern/perfmon.h>
#include <machine/cpu.h>
#include <machine/lapic.h>
#include <machine/pmap.h>
@@ -159,7 +160,7 @@ struct lapic_map {
struct lapic_register icr_high;
struct lapic_register lvt_timer;
const struct lapic_register reserved14; /* Thermal sensor register */
- const struct lapic_register reserved15; /* Performance counters register */
+ struct lapic_register lvt_pmc; /* Performance counters register */
struct lapic_register lvt_lint0;
struct lapic_register lvt_lint1;
struct lapic_register lvt_error;
@@ -239,6 +240,7 @@ lapic_setup_registers(void)
lapic_write(&lapic_map->lvt_error, TRAP_LAPIC_ERROR);
lapic_write(&lapic_map->timer_dcr, LAPIC_TIMER_DCR_DIV1);
lapic_write(&lapic_map->timer_icr, lapic_bus_freq / CLOCK_FREQ);
+ lapic_write(&lapic_map->lvt_pmc, TRAP_LAPIC_PMC_OF);
}
void __init
@@ -334,6 +336,13 @@ lapic_ipi_broadcast(uint32_t vector)
}
void
+lapic_pmc_of_intr(struct trap_frame *frame)
+{
+ perfmon_handle_of_intr(frame);
+ lapic_eoi();
+}
+
+void
lapic_timer_intr(struct trap_frame *frame)
{
(void)frame;
diff --git a/arch/x86/machine/lapic.h b/arch/x86/machine/lapic.h
index 6355da4..4b8385c 100644
--- a/arch/x86/machine/lapic.h
+++ b/arch/x86/machine/lapic.h
@@ -54,6 +54,7 @@ void lapic_ipi_broadcast(uint32_t vector);
/*
* Interrupt handlers.
*/
+void lapic_pmc_of_intr(struct trap_frame *frame);
void lapic_timer_intr(struct trap_frame *frame);
void lapic_error_intr(struct trap_frame *frame);
void lapic_spurious_intr(struct trap_frame *frame);
diff --git a/arch/x86/machine/trap.c b/arch/x86/machine/trap.c
index 878f20c..0e98015 100644
--- a/arch/x86/machine/trap.c
+++ b/arch/x86/machine/trap.c
@@ -210,6 +210,7 @@ trap_setup(void)
trap_install(TRAP_XCALL, TRAP_HF_INTR, cpu_xcall_intr);
trap_install(TRAP_THREAD_SCHEDULE, TRAP_HF_INTR, cpu_thread_schedule_intr);
trap_install(TRAP_CPU_HALT, TRAP_HF_INTR, cpu_halt_intr);
+ trap_install(TRAP_LAPIC_PMC_OF, TRAP_HF_INTR, lapic_pmc_of_intr);
trap_install(TRAP_LAPIC_TIMER, TRAP_HF_INTR, lapic_timer_intr);
trap_install(TRAP_LAPIC_ERROR, TRAP_HF_INTR, lapic_error_intr);
trap_install(TRAP_LAPIC_SPURIOUS, TRAP_HF_INTR, lapic_spurious_intr);
diff --git a/arch/x86/machine/trap.h b/arch/x86/machine/trap.h
index af6fd6b..c5bdc1f 100644
--- a/arch/x86/machine/trap.h
+++ b/arch/x86/machine/trap.h
@@ -62,6 +62,7 @@
#define TRAP_XCALL 238
#define TRAP_THREAD_SCHEDULE 239
#define TRAP_CPU_HALT 240
+#define TRAP_LAPIC_PMC_OF 252
#define TRAP_LAPIC_TIMER 253
#define TRAP_LAPIC_ERROR 254
#define TRAP_LAPIC_SPURIOUS 255