diff options
| author | Ada Christine <adachristine18@gmail.com> | 2021-12-19 22:41:15 +0000 |
|---|---|---|
| committer | Ada Christine <adachristine18@gmail.com> | 2021-12-19 22:41:15 +0000 |
| commit | e303a03e7c96bc5bf7fa93f7b46ce63196893d7a (patch) | |
| tree | f187b374feec85015d6df1f94db618a3f5cc893f /kc/core/exceptions.S | |
| parent | bff63a4337eb3388617d230970c5eb2684d6a215 (diff) | |
moving files around
Diffstat (limited to 'kc/core/exceptions.S')
| -rw-r--r-- | kc/core/exceptions.S | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/kc/core/exceptions.S b/kc/core/exceptions.S new file mode 100644 index 0000000..80d49ee --- /dev/null +++ b/kc/core/exceptions.S @@ -0,0 +1,54 @@ +.extern page_fault_handler + +.global page_fault_isr +.type page_fault_isr, @function +page_fault_isr: + /* just in case something tried to be clever before */ + cld + /* push param registers */ + push %rdi + push %rsi + push %rdx + push %rcx + push %r8 + push %r9 + /* collect parameters for page fault handler */ + mov 48(%rsp), %rdi /* error code is first parameter */ + mov %cr2, %rsi /* PFLA is next parameter */ + /* caller-saved registers */ + push %rax + push %r10 + push %r11 + /* callee-saved registers */ + push %rbx + push %rbp + push %r12 + push %r13 + push %r14 + push %r15 + /* stack has to be aligned */ + mov %rsp, %rbp + and $-16, %rsp + call page_fault_handler + mov %rbp, %rsp + /* TODO: test for error code here and panic() */ + pop %r15 + pop %r14 + pop %r13 + pop %r12 + pop %rbp + pop %rbx + pop %r11 + pop %r10 + pop %rax + pop %r9 + pop %r8 + pop %rcx + pop %rdx + pop %rsi + pop %rdi + /* unwind the error code from the stack */ + add $8, %rsp + /* leave the isr */ + iretq +.size page_fault_isr, . - page_fault_isr |
