kernel/task: Add save_state_and_yield_task

This commit is contained in:
Ry 2023-02-07 15:58:13 -08:00
parent b919faaeb4
commit 2ed47446a0
3 changed files with 79 additions and 0 deletions

View File

@ -13,6 +13,7 @@ end_current_task: jmp [0x00000A18]
get_current_task_id: jmp [0x00000A1C] get_current_task_id: jmp [0x00000A1C]
get_unused_task_id: jmp [0x00000A20] get_unused_task_id: jmp [0x00000A20]
is_task_id_used: jmp [0x00000A24] is_task_id_used: jmp [0x00000A24]
save_state_and_yield_task: jmp [0x00000A28]
; memory jump table ; memory jump table
allocate_memory: jmp [0x00000B10] allocate_memory: jmp [0x00000B10]

View File

@ -29,6 +29,7 @@ jump_table:
data.32 get_current_task_id data.32 get_current_task_id
data.32 get_unused_task_id data.32 get_unused_task_id
data.32 is_task_id_used data.32 is_task_id_used
data.32 save_state_and_yield_task
; memory jump table ; memory jump table
org.pad 0x00000310 org.pad 0x00000310

View File

@ -45,6 +45,83 @@ yield_task:
jmp yield_task_0 jmp yield_task_0
; push all registers and switch to the next task in the queue
; inputs:
; none
; outputs:
; none
save_state_and_yield_task:
push rfp
push r31
push r30
push r29
push r28
push r27
push r26
push r25
push r24
push r23
push r22
push r21
push r20
push r19
push r18
push r17
push r16
push r15
push r14
push r13
push r12
push r11
push r10
push r9
push r8
push r7
push r6
push r5
push r4
push r3
push r2
push r1
push r0
call yield_task
pop r0
pop r1
pop r2
pop r3
pop r4
pop r5
pop r6
pop r7
pop r8
pop r9
pop r10
pop r11
pop r12
pop r13
pop r14
pop r15
pop r16
pop r17
pop r18
pop r19
pop r20
pop r21
pop r22
pop r23
pop r24
pop r25
pop r26
pop r27
pop r28
pop r29
pop r30
pop r31
pop rfp
ret
; switch to the next task without adding the current task back into the queue ; switch to the next task without adding the current task back into the queue
; this will automatically free the task's code and stack blocks ; this will automatically free the task's code and stack blocks
; inputs: ; inputs: