Introduce a kernel_yield function to use once a scheduler is implemented
This commit is contained in:
parent
88681bdc74
commit
82893fa3a4
@ -19,3 +19,5 @@ namespace CPU
|
||||
void disable_interrupts();
|
||||
void wait_for_interrupt();
|
||||
}
|
||||
|
||||
extern "C" void kernel_yield();
|
@ -48,6 +48,51 @@ load_tr:
|
||||
ltr ax
|
||||
ret
|
||||
|
||||
global switch_task
|
||||
switch_task:
|
||||
cli
|
||||
.loop:
|
||||
hlt
|
||||
jmp .loop
|
||||
|
||||
global kernel_yield
|
||||
kernel_yield:
|
||||
mov rdi, [rsp] ; return address is now in RDI
|
||||
mov rcx, rsp ; save current RSP
|
||||
add rcx, 8 ; skip over the return address
|
||||
|
||||
mov eax, ss
|
||||
push rax ; SS
|
||||
push rcx ; RSP
|
||||
pushfq ; RFLAGS
|
||||
mov eax, cs
|
||||
push rax ; CS
|
||||
push rdi ; RIP
|
||||
|
||||
; ISR and error code
|
||||
push 0
|
||||
push 0
|
||||
|
||||
push 0 ; RAX
|
||||
push rbx ; Preserve RBX
|
||||
push 0 ; RCX
|
||||
push 0 ; RDX
|
||||
push 0 ; RSI
|
||||
push 0 ; RDI
|
||||
push rbp ; Preserve RBP
|
||||
push 0 ; R8
|
||||
push 0 ; R9
|
||||
push 0 ; R10
|
||||
push 0 ; R11
|
||||
push r12 ; Preserve R12
|
||||
push r13 ; Preserve R13
|
||||
push r14 ; Preserve R14
|
||||
push r15 ; Preserve R15
|
||||
|
||||
mov rdi, rsp
|
||||
call switch_task
|
||||
jmp _asm_interrupt_exit
|
||||
|
||||
%macro ISR 1
|
||||
global _isr%1
|
||||
_isr%1:
|
||||
@ -97,6 +142,7 @@ _asm_interrupt_entry:
|
||||
mov rdi, rsp
|
||||
call arch_interrupt_entry
|
||||
|
||||
_asm_interrupt_exit:
|
||||
pop r15
|
||||
pop r14
|
||||
pop r13
|
||||
|
Loading…
Reference in New Issue
Block a user