Kernel: Write isr handler for x86_32 and cleanup x86_64

This commit is contained in:
2024-03-26 16:36:51 +02:00
parent 1943c3e7a1
commit d7bf34ecd0
3 changed files with 97 additions and 43 deletions

View File

@@ -1,15 +1,42 @@
isr_stub:
ud2
pusha
movl %cr0, %eax; pushl %eax
movl %cr2, %eax; pushl %eax
movl %cr3, %eax; pushl %eax
movl %cr4, %eax; pushl %eax
movl %esp, %eax // register ptr
leal 56(%esp), %ebx // interrupt stack ptr
movl 52(%esp), %ecx // error code
movl 48(%esp), %edx // isr number
subl $12, %esp
pushl %eax
pushl %ebx
pushl %ecx
pushl %edx
call cpp_isr_handler
addl $44, %esp
popa
addl $8, %esp
iret
irq_stub:
ud2
pusha
leal 40(%esp), %eax // interrupt stack ptr
movl 32(%esp), %ebx // irq number
subl $12, %esp
pushl %eax
pushl %ebx
call cpp_irq_handler
addl $20, %esp
popa
addl $8, %esp
iret
// arguments in EAX, EBX, ECX, EDX, ESI, EDI

View File

@@ -1,11 +1,11 @@
.macro pushaq
pushq %rax
pushq %rbx
pushq %rcx
pushq %rdx
pushq %rbx
pushq %rbp
pushq %rdi
pushq %rsi
pushq %rdi
pushq %r8
pushq %r9
pushq %r10
@@ -25,12 +25,12 @@
popq %r10
popq %r9
popq %r8
popq %rsi
popq %rdi
popq %rsi
popq %rbp
popq %rbx
popq %rdx
popq %rcx
popq %rbx
popq %rax
.endm
@@ -43,35 +43,29 @@
popq %r10
popq %r9
popq %r8
popq %rsi
popq %rdi
popq %rsi
popq %rbp
popq %rbx
popq %rdx
popq %rcx
popq %rbx
.endm
isr_stub:
pushaq
movq %cr0, %rax; pushq %rax
movq %cr2, %rax; pushq %rax
movq %cr3, %rax; pushq %rax
movq %cr4, %rax; pushq %rax
movq 184(%rsp), %rax; pushq %rax
movq 176(%rsp), %rax; pushq %rax
movq 208(%rsp), %rax; pushq %rax
movq 176(%rsp), %rdi
movq 184(%rsp), %rsi
movq %rsp, %rdx
addq $192, %rdx
movq %rsp, %rcx
movq %cr0, %rax; pushq %rax
movq %cr2, %rax; pushq %rax
movq %cr3, %rax; pushq %rax
movq %cr4, %rax; pushq %rax
movq 152(%rsp), %rdi // isr number
movq 160(%rsp), %rsi // error code
leaq 168(%rsp), %rdx // interrupt stack ptr
movq %rsp, %rcx // register ptr
call cpp_isr_handler
addq $56, %rsp
addq $32, %rsp
popaq
addq $16, %rsp
iretq