mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-29 05:38:21 +00:00
cpu: add irq depth counting
Add a way of checking if a cpu is in the middle of handling an irq and how deep it is into it. This will allow for future code to conditionally run only in/outside interrupts.
This commit is contained in:
@@ -147,6 +147,8 @@ void arch_nmi_isr(context_t *ctx) {
|
||||
uint64_t old_gsbase = rdmsr(MSR_GSBASE);
|
||||
wrmsr(MSR_GSBASE, *(uint64_t *)(ctx + 1));
|
||||
|
||||
__atomic_fetch_add(¤t_cpu()->irq_depth, 1, __ATOMIC_RELAXED);
|
||||
|
||||
bool handled = false;
|
||||
|
||||
#ifdef ENABLE_PROFILING
|
||||
@@ -157,6 +159,8 @@ void arch_nmi_isr(context_t *ctx) {
|
||||
if (!handled)
|
||||
_panic("Unhandled NMI", ctx);
|
||||
|
||||
__atomic_fetch_sub(¤t_cpu()->irq_depth, 1, __ATOMIC_RELAXED);
|
||||
|
||||
// restore the old gsbase
|
||||
wrmsr(MSR_GSBASE, old_gsbase);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user