Add get_current_task_id

This commit is contained in:
Ry 2022-06-24 17:40:52 -07:00
parent df95829e83
commit 887ebc4553
3 changed files with 35 additions and 8 deletions

View File

@ -1,16 +1,18 @@
; fox32os routine definitions ; fox32os routine definitions
; system jump table ; system jump table
get_os_version: jmp [0x00000810] get_os_version: jmp [0x00000810]
; FXF jump table ; FXF jump table
parse_fxf_binary: jmp [0x00000910] parse_fxf_binary: jmp [0x00000910]
; task jump table ; task jump table
new_task: jmp [0x00000A10] new_task: jmp [0x00000A10]
yield_task: jmp [0x00000A14] yield_task: jmp [0x00000A14]
end_current_task: jmp [0x00000A18] end_current_task: jmp [0x00000A18]
get_current_task_id: jmp [0x00000A1C]
get_unused_task_id: jmp [0x00000A20]
; memory jump table ; memory jump table
allocate_memory: jmp [0x00000B10] allocate_memory: jmp [0x00000B10]
free_memory: jmp [0x00000B14] free_memory: jmp [0x00000B14]

View File

@ -26,6 +26,8 @@ jump_table:
data.32 new_task data.32 new_task
data.32 yield_task data.32 yield_task
data.32 end_current_task data.32 end_current_task
data.32 get_current_task_id
data.32 get_unused_task_id
; memory jump table ; memory jump table
org.pad 0x00000B10 org.pad 0x00000B10

View File

@ -106,10 +106,33 @@ get_unused_task_id_loop:
inc r0 inc r0
cmp r0, 32 cmp r0, 32
iflt jmp get_unused_task_id_loop iflt jmp get_unused_task_id_loop
; if we reach this point, then add task IDs are used ; if we reach this point, then all task IDs are used
mov r0, 0 mov r0, 0
ret ret
; get the task ID of the currently running task
; inputs:
; none
; outputs:
; r0: task ID
get_current_task_id:
push r2
push r3
push r4
push r5
push r6
mov r0, current_task
call task_load
mov r0, r2
pop r6
pop r5
pop r4
pop r3
pop r2
ret
task_load: task_load:
mov r2, [r0] ; task ID mov r2, [r0] ; task ID
add r0, 4 add r0, 4