diff options
author | Ian Moffett <ian@osmora.org> | 2024-05-07 00:09:14 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-05-07 00:09:14 -0400 |
commit | 198c05c4b8411222502a20fb2ea9d9a88837d11a (patch) | |
tree | 4b58f68546d43ad0cfcf2d4f68271003c5748ea8 /sys | |
parent | 853ca334332eb4312e30de0ff2c59411c35eb418 (diff) |
kernel/amd64: trap: Temporarily disable interrupts
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/amd64/amd64/trap.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/sys/arch/amd64/amd64/trap.c b/sys/arch/amd64/amd64/trap.c index be0493f..ddada75 100644 --- a/sys/arch/amd64/amd64/trap.c +++ b/sys/arch/amd64/amd64/trap.c @@ -35,6 +35,9 @@ #include <sys/signal.h> #include <sys/proc.h> #include <sys/sched.h> +#include <sys/schedvar.h> +#include <sys/timer.h> +#include <sys/machdep.h> #include <vm/fault.h> static const char *trap_type[] = { @@ -146,9 +149,33 @@ void trap_handler(struct trapframe *tf) { struct proc *curtd = this_td(); + struct timer sched_tmr; + tmrr_status_t tmrr_s; int s; /* + * Mask interrupts so we don't get put in a funky + * state as we are dealing with this trap. Then the next + * thing we want to do is fetch the sched timer so we can + * ensure it is running after we unmask the interrupts. + */ + intr_mask(); + tmrr_s = req_timer(TIMER_SCHED, &sched_tmr); + if (__unlikely(tmrr_s != TMRR_SUCCESS)) { + trap_print(tf); + panic("Could not fetch TIMER_SCHED (tmrr_s=0x%x)\n", tmrr_s); + } + + /* + * We should be able to perform a usec oneshot but + * make sure just in case. + */ + if (__unlikely(sched_tmr.oneshot_us == NULL)) { + trap_print(tf); + panic("Timer oneshot_us is NULL!\n"); + } + + /* * XXX: Handle NMIs better. For now we just * panic. */ @@ -177,4 +204,8 @@ trap_handler(struct trapframe *tf) signal_raise(curtd, SIGSEGV); break; } + + /* All good, unmask and start sched timer */ + intr_unmask(); + sched_tmr.oneshot_us(DEFAULT_TIMESLICE_USEC); } |