Preserve registers and align stack in interrupt handlers

This commit is contained in:
Josh Holtrop 2023-11-02 10:29:27 -04:00
parent 2fa4193517
commit 5d8343ed40

View File

@ -83,19 +83,34 @@ struct Idt
movabs $$1f, %rax
jmp 2f
1:
pushq %rdi
pushq %rsi
pushq %rax
pushq %rcx
pushq %rdx
pushq %rsi
pushq %rdi
pushq %r8
pushq %r9
pushq %r10
pushq %r11
pushq %rbp
mov %rsp, %rbp
and $$0xFFFFFFFFFFFFFFF0, %rsp
mov $$", isr, ", %rdi
" ~ (isr_has_error_code(isr) ? "mov 0x20(%rsp), %rsi" : "") ~ "
" ~ (isr_has_error_code(isr) ? "lea 0x28(%rsp), %rdx" : "lea 0x20(%rsp), %rdx") ~ "
" ~ (isr_has_error_code(isr) ? "mov 0x50(%rbp), %rsi" : "") ~ "
" ~ (isr_has_error_code(isr) ? "lea 0x58(%rbp), %rdx" : "lea 0x50(%rbp), %rdx") ~ "
movabs $$isr, %rax
callq *%rax
popq %rdx
popq %rax
popq %rsi
mov %rbp, %rsp
popq %rbp
popq %r11
popq %r10
popq %r9
popq %r8
popq %rdi
popq %rsi
popq %rdx
popq %rcx
popq %rax
" ~ (isr_has_error_code(isr) ? "add $$8, %rsp" : "") ~ "
iretq
2:`, `={rax}`);");