sched: thread: add cpu context pointer usable during interrupts and syscalls

This commit is contained in:
2026-04-01 18:22:23 +01:00
parent 7bcd1577be
commit 876f91d8be
2 changed files with 19 additions and 0 deletions
+14
View File
@@ -8,6 +8,7 @@
#include <kernel/panic.h>
#include <kernel/sched.h>
#include <kernel/syscall.h>
#include <kernel/thread.h>
#include <stddef.h>
#define MAX_ISR_HANDLERS 16
@@ -166,6 +167,12 @@ int idt_load(struct idt_ptr *ptr)
void isr_dispatch(struct ml_cpu_context *regs)
{
struct thread *thr = get_current_thread();
if (thr) {
thr->tr_irqctx = regs;
put_current_thread(thr);
}
int_hook h = isr_handlers[regs->int_no];
if (h) {
h(regs);
@@ -188,6 +195,13 @@ void irq_dispatch(struct ml_cpu_context *regs)
end_charge_period();
irq_ack(regs->int_no);
struct thread *thr = get_current_thread();
if (thr) {
thr->tr_irqctx = regs;
put_current_thread(thr);
}
struct queue *hooks = &irq_hooks[regs->int_no - IRQ0];
queue_foreach(struct irq_hook, hook, hooks, irq_entry)
{