mirror of
https://github.com/openbsd/src.git
synced 2026-06-18 15:23:33 +02:00
Pick the correct interrupt for the virtual timer if we're running in EL2.
Based on a diff from Marc Zyngier. ok jsg@
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: agtimer.c,v 1.29 2025/01/31 16:46:41 kettenis Exp $ */
|
||||
/* $OpenBSD: agtimer.c,v 1.30 2026/05/04 20:43:41 kettenis Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2011 Dale Rahn <drahn@openbsd.org>
|
||||
* Copyright (c) 2013 Patrick Wildt <patrick@blueri.se>
|
||||
@@ -289,7 +289,9 @@ agtimer_set_clockrate(int32_t new_frequency)
|
||||
void
|
||||
agtimer_cpu_initclocks(void)
|
||||
{
|
||||
struct agtimer_softc *sc = agtimer_cd.cd_devs[0];
|
||||
struct agtimer_softc *sc = agtimer_cd.cd_devs[0];
|
||||
uint64_t el;
|
||||
int idx;
|
||||
|
||||
stathz = hz;
|
||||
profhz = stathz * 10;
|
||||
@@ -299,8 +301,20 @@ agtimer_cpu_initclocks(void)
|
||||
agtimer_set_clockrate(agtimer_frequency);
|
||||
}
|
||||
|
||||
/* Pick the correct PPI depending on the running EL. */
|
||||
el = READ_SPECIALREG(CurrentEL) & CURRENTEL_EL_MASK;
|
||||
if (el == CURRENTEL_EL_EL2) {
|
||||
idx = OF_getindex(sc->sc_node, "hyp-virt", "interrupt-names");
|
||||
if (idx == -1)
|
||||
idx = 4;
|
||||
} else {
|
||||
idx = OF_getindex(sc->sc_node, "virt", "interrupt-names");
|
||||
if (idx == -1)
|
||||
idx = 2;
|
||||
}
|
||||
|
||||
/* configure virtual timer interrupt */
|
||||
sc->sc_ih = arm_intr_establish_fdt_idx(sc->sc_node, 2,
|
||||
sc->sc_ih = arm_intr_establish_fdt_idx(sc->sc_node, idx,
|
||||
IPL_CLOCK|IPL_MPSAFE, agtimer_intr, NULL, "tick");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: armreg.h,v 1.44 2025/07/22 09:20:41 kettenis Exp $ */
|
||||
/* $OpenBSD: armreg.h,v 1.45 2026/05/04 20:43:42 kettenis Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2013, 2014 Andrew Turner
|
||||
* Copyright (c) 2015 The FreeBSD Foundation
|
||||
@@ -119,6 +119,14 @@
|
||||
#define CTR_ILINE_MASK (0xf << CTR_ILINE_SHIFT)
|
||||
#define CTR_ILINE_SIZE(reg) (((reg) & CTR_ILINE_MASK) >> CTR_ILINE_SHIFT)
|
||||
|
||||
/* CurrentEL - Current Exception Level */
|
||||
#define CURRENTEL_EL_SHIFT 2
|
||||
#define CURRENTEL_EL_MASK (0x3 << CURRENTEL_EL_SHIFT)
|
||||
#define CURRENTEL_EL_EL0 (0x0 << CURRENTEL_EL_SHIFT)
|
||||
#define CURRENTEL_EL_EL1 (0x1 << CURRENTEL_EL_SHIFT)
|
||||
#define CURRENTEL_EL_EL2 (0x2 << CURRENTEL_EL_SHIFT)
|
||||
#define CURRENTEL_EL_EL3 (0x3 << CURRENTEL_EL_SHIFT)
|
||||
|
||||
/* MPIDR_EL1 - Multiprocessor Affinity Register */
|
||||
#define MPIDR_AFF3 (0xFFULL << 32)
|
||||
#define MPIDR_AFF2 (0xFFULL << 16)
|
||||
|
||||
Reference in New Issue
Block a user