aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / native / kernel / x86 / local_enter.S
| 1 | /* MS ABI caller, private Omega user ABI. Intel SDM Vol 3A 7.14. |
| 2 | * Only the BSP enters. Kernel exceptions continue through the ordinary handler. |
| 3 | * Every user exit saves user FP state BEFORE C can touch it and restores the |
| 4 | * caller's FP state, stack and nonvolatile registers before returning. */ |
| 5 | .text |
| 6 | .globl ck_local_enter |
| 7 | ck_local_enter: |
| 8 | pushfq |
| 9 | cli |
| 10 | push %rbx |
| 11 | push %rbp |
| 12 | push %rdi |
| 13 | push %rsi |
| 14 | push %r12 |
| 15 | push %r13 |
| 16 | push %r14 |
| 17 | push %r15 |
| 18 | mov %rsp, ck_local_kernel_sp(%rip) |
| 19 | fxsave64 ck_local_kernel_fp(%rip) |
| 20 | fxrstor64 ck_local_user_fp(%rip) |
| 21 | mov %rcx, %rsp |
| 22 | pop %r15 |
| 23 | pop %r14 |
| 24 | pop %r13 |
| 25 | pop %r12 |
| 26 | pop %r11 |
| 27 | pop %r10 |
| 28 | pop %r9 |
| 29 | pop %r8 |
| 30 | pop %rbp |
| 31 | pop %rdi |
| 32 | pop %rsi |
| 33 | pop %rdx |
| 34 | pop %rcx |
| 35 | pop %rbx |
| 36 | pop %rax |
| 37 | add $16, %rsp |
| 38 | iretq |
| 39 | |
| 40 | .globl ck_local_user_exit |
| 41 | ck_local_user_exit: |
| 42 | /* RCX is the complete frame on the supervisor interrupt stack. */ |
| 43 | fxsave64 ck_local_user_fp(%rip) |
| 44 | fxrstor64 ck_local_kernel_fp(%rip) |
| 45 | and $-16, %rsp |
| 46 | sub $32, %rsp |
| 47 | call ck_local_trap |
| 48 | mov ck_local_kernel_sp(%rip), %rsp |
| 49 | pop %r15 |
| 50 | pop %r14 |
| 51 | pop %r13 |
| 52 | pop %r12 |
| 53 | pop %rsi |
| 54 | pop %rdi |
| 55 | pop %rbp |
| 56 | pop %rbx |
| 57 | popfq |
| 58 | ret |
| 59 | .section .note.GNU-stack,"",@progbits |