From 2ff8fc60d0f4615321de73ef832085b24ed36e80 Mon Sep 17 00:00:00 2001 From: Michael Shaw Date: Sun, 9 Feb 2025 19:35:00 -0500 Subject: [PATCH] entry: improve entry flow for interrupts --- sched/entry.S | 47 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/sched/entry.S b/sched/entry.S index e6f8473..b110f06 100644 --- a/sched/entry.S +++ b/sched/entry.S @@ -47,6 +47,24 @@ movq %r15, 112(%rax) .endm +.macro restore_context + movq 8(%rax), %rbx + movq 16(%rax), %rcx + movq 24(%rax), %rdx + movq 32(%rax), %rsi + movq 40(%rax), %rdi + movq 48(%rax), %rbp + movq 56(%rax), %r8 + movq 64(%rax), %r9 + movq 72(%rax), %r10 + movq 80(%rax), %r11 + movq 88(%rax), %r12 + movq 96(%rax), %r13 + movq 104(%rax), %r14 + movq 112(%rax), %r15 + movq 0(%rax), %rax +.endm + .macro save_iretq_frame /* save IRETQ frame */ popq %rdi @@ -62,6 +80,16 @@ movq %rdi, 152(%rax) .endm +.macro restore_iretq_frame + /* restore IRETQ frame */ + call proc_current_regs + pushq 152(%rax) + pushq 144(%rax) + pushq 136(%rax) + pushq 128(%rax) + pushq 120(%rax) +.endm + .macro push_regs pushq %rax pushq %rbx @@ -102,12 +130,13 @@ .global _exception_\nr _exception_\nr: cli - push_regs + save_context + save_iretq_frame movq $\nr, %rdi movq $0, %rsi call exception - call yield - pop_regs + restore_iretq_frame + restore_context iretq .endm @@ -115,12 +144,13 @@ .global _exception_\nr _exception_\nr: cli - push_regs + save_context popq %rsi + pushq %rsi movq $\nr, %rdi call exception - call yield - pop_regs + restore_iretq_frame + restore_context iretq .endm @@ -133,8 +163,9 @@ /* call irq handler */ movq $\nr, %rdi call irq - - call schedule + restore_iretq_frame + restore_context + iretq .endm .global sti