summaryrefslogtreecommitdiffstats
path: root/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c
diff options
context:
space:
mode:
authorAndrei Warkentin <andrei.warkentin@intel.com>2023-02-17 18:42:29 -0600
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-03-08 18:10:34 +0000
commit69da506c927f8092ea8f783a092a694a3582e3ef (patch)
tree73435cd25e6a0e9c4a71fdba0c1872cde8d58259 /UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c
parent5ad2592ab370b6c9030d1239940046bdeec9c2c6 (diff)
downloadedk2-69da506c927f8092ea8f783a092a694a3582e3ef.tar.gz
edk2-69da506c927f8092ea8f783a092a694a3582e3ef.tar.bz2
edk2-69da506c927f8092ea8f783a092a694a3582e3ef.zip
UefiCpuPkg: BaseRiscV64CpuExceptionHandlerLib: clean up
RegisterCpuInterruptHandler did not allow setting exception handlers for anything beyond the timer IRQ. Beyond that, it didn't meet the spec around handling of inputs. RiscVSupervisorModeTrapHandler now will invoke set handlers for both exceptions and interrupts. Two arrays of handlers are maintained - one for exceptions and one for interrupts. For unhandled traps, RiscVSupervisorModeTrapHandler dumps state using the now implemented DumpCpuContext. For EFI_SYSTEM_CONTEXT_RISCV64, extend this with the trapped PC address (SEPC), just like on AArch64 (ELR). This is necessary for X86EmulatorPkg to work as it allows a trap handler to return execution to a different place. Add SSTATUS/STVAL as well, at least for debugging purposes. There is no value in hiding this. Fix nested exception handling. Handler code should not be saving SIE (the value is saved in SSTATUS.SPIE) or directly restored (that's done by SRET). Save and restore the entire SSTATUS and STVAL, too. Cc: Daniel Schaefer <git@danielschaefer.me> Reviewed-by: Sunil V L <sunilvl@ventanamicro.com> Signed-off-by: Andrei Warkentin <andrei.warkentin@intel.com>
Diffstat (limited to 'UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c')
-rw-r--r--UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c b/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c
index 287e7e1330..fa957ba5e3 100644
--- a/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c
+++ b/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c
@@ -278,7 +278,11 @@ TimerDriverInitialize (
//
// Install interrupt handler for RISC-V Timer.
//
- Status = mCpu->RegisterInterruptHandler (mCpu, EXCEPT_RISCV_TIMER_INT, TimerInterruptHandler);
+ Status = mCpu->RegisterInterruptHandler (
+ mCpu,
+ EXCEPT_RISCV_IRQ_TIMER_FROM_SMODE,
+ TimerInterruptHandler
+ );
ASSERT_EFI_ERROR (Status);
//