kernel: Add launch_fxf_from_open_file
This commit is contained in:
parent
c101b58dea
commit
012511bf5f
|
@ -1,5 +1,33 @@
|
||||||
; FXF launching routines
|
; FXF launching routines
|
||||||
|
|
||||||
|
; launch an FXF binary from an already opened file
|
||||||
|
; inputs:
|
||||||
|
; r0: pointer to file struct
|
||||||
|
; r1: reserved
|
||||||
|
; r2: argument 0
|
||||||
|
; r3: argument 1
|
||||||
|
; r4: argument 2
|
||||||
|
; r5: argument 3
|
||||||
|
; r6: argument 4
|
||||||
|
; outputs:
|
||||||
|
; r0: task ID of the new task, or 0xFFFFFFFF if error
|
||||||
|
launch_fxf_from_open_file:
|
||||||
|
push r1
|
||||||
|
push r2
|
||||||
|
push r3
|
||||||
|
push r4
|
||||||
|
push r5
|
||||||
|
push r6
|
||||||
|
|
||||||
|
push r2
|
||||||
|
push r3
|
||||||
|
push r4
|
||||||
|
push r5
|
||||||
|
push r6
|
||||||
|
|
||||||
|
mov [launch_fxf_struct_ptr], r0
|
||||||
|
jmp launch_fxf_from_open_file_1
|
||||||
|
|
||||||
; launch an FXF binary from a file on disk
|
; launch an FXF binary from a file on disk
|
||||||
; inputs:
|
; inputs:
|
||||||
; r0: pointer to FXF binary name (8.3 format, for example "testfile.fxf" or "test.fxf")
|
; r0: pointer to FXF binary name (8.3 format, for example "testfile.fxf" or "test.fxf")
|
||||||
|
@ -26,13 +54,14 @@ launch_fxf_from_disk:
|
||||||
push r6
|
push r6
|
||||||
|
|
||||||
; open the file
|
; open the file
|
||||||
mov r2, launch_fxf_struct
|
mov [launch_fxf_struct_ptr], launch_fxf_struct
|
||||||
|
mov r2, [launch_fxf_struct_ptr]
|
||||||
call open
|
call open
|
||||||
cmp r0, 0
|
cmp r0, 0
|
||||||
ifz jmp launch_fxf_from_disk_file_error
|
ifz jmp launch_fxf_from_disk_file_error
|
||||||
|
launch_fxf_from_open_file_1:
|
||||||
; allocate memory for the binary
|
; allocate memory for the binary
|
||||||
mov r0, launch_fxf_struct
|
mov r0, [launch_fxf_struct_ptr]
|
||||||
call get_size
|
call get_size
|
||||||
call allocate_memory
|
call allocate_memory
|
||||||
cmp r0, 0
|
cmp r0, 0
|
||||||
|
@ -40,7 +69,7 @@ launch_fxf_from_disk:
|
||||||
mov [launch_fxf_binary_ptr], r0
|
mov [launch_fxf_binary_ptr], r0
|
||||||
|
|
||||||
; read the file into memory
|
; read the file into memory
|
||||||
mov r0, launch_fxf_struct
|
mov r0, [launch_fxf_struct_ptr]
|
||||||
mov r1, [launch_fxf_binary_ptr]
|
mov r1, [launch_fxf_binary_ptr]
|
||||||
call ryfs_read_whole_file
|
call ryfs_read_whole_file
|
||||||
|
|
||||||
|
@ -109,6 +138,7 @@ launch_fxf_from_disk_file_error:
|
||||||
mov r0, 0xFFFFFFFF
|
mov r0, 0xFFFFFFFF
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
launch_fxf_struct_ptr: data.32 0
|
||||||
launch_fxf_struct: data.fill 0, 32
|
launch_fxf_struct: data.fill 0, 32
|
||||||
launch_fxf_task_id: data.8 0
|
launch_fxf_task_id: data.8 0
|
||||||
launch_fxf_binary_ptr: data.32 0
|
launch_fxf_binary_ptr: data.32 0
|
||||||
|
|
|
@ -28,6 +28,7 @@ jump_table:
|
||||||
org.pad 0x00000110
|
org.pad 0x00000110
|
||||||
data.32 parse_fxf_binary
|
data.32 parse_fxf_binary
|
||||||
data.32 launch_fxf_from_disk
|
data.32 launch_fxf_from_disk
|
||||||
|
data.32 launch_fxf_from_open_file
|
||||||
|
|
||||||
; task jump table
|
; task jump table
|
||||||
org.pad 0x00000210
|
org.pad 0x00000210
|
||||||
|
@ -201,47 +202,25 @@ load_startup_task:
|
||||||
mov r2, startup_file_struct
|
mov r2, startup_file_struct
|
||||||
call ryfs_open
|
call ryfs_open
|
||||||
cmp r0, 0
|
cmp r0, 0
|
||||||
ifz jmp boot_disk_1
|
ifz jmp startup_error
|
||||||
|
|
||||||
; allocate memory for the startup file
|
; create a new task and yield to it
|
||||||
mov r0, startup_file_struct
|
mov r0, startup_file_struct
|
||||||
call get_size
|
mov r1, 0
|
||||||
call allocate_memory
|
mov r2, 0
|
||||||
cmp r0, 0
|
mov r3, 0
|
||||||
ifz jmp memory_error
|
mov r4, 0
|
||||||
mov [startup_file_binary_ptr], r0
|
mov r5, 0
|
||||||
|
mov r6, 0
|
||||||
; allocate 64KiB for the startup file's stack
|
call launch_fxf_from_open_file
|
||||||
mov r0, 65536
|
|
||||||
call allocate_memory
|
|
||||||
cmp r0, 0
|
|
||||||
ifz jmp memory_error
|
|
||||||
mov [startup_file_stack_ptr], r0
|
|
||||||
|
|
||||||
; read the startup file into memory
|
|
||||||
mov r0, startup_file_struct
|
|
||||||
mov r1, [startup_file_binary_ptr]
|
|
||||||
call ryfs_read_whole_file
|
|
||||||
|
|
||||||
; relocate and execute it as a new task
|
|
||||||
mov r0, r1
|
|
||||||
call parse_fxf_binary
|
|
||||||
mov r3, r1
|
|
||||||
mov r1, r0
|
|
||||||
movz.8 r0, [next_task_id]
|
|
||||||
mov r2, [startup_file_stack_ptr]
|
|
||||||
add r2, 65536
|
|
||||||
sub r2, 4
|
|
||||||
mov r4, [startup_file_stack_ptr]
|
|
||||||
call new_task
|
|
||||||
|
|
||||||
; when the startup file yields for the first time, we'll end up back here
|
; when the startup file yields for the first time, we'll end up back here
|
||||||
; now, check to see if startup.cfg has any other entries
|
; now, check to see if startup.cfg has any other entries
|
||||||
; we do this by checking to see if the size of startup.cfg is less than or equal to 12 * next_task_id bytes
|
; we do this by checking to see if the size of startup.cfg is less than or equal to 12 * next_task bytes
|
||||||
inc.8 [next_task_id]
|
inc.8 [next_task]
|
||||||
mov r0, startup_cfg_struct
|
mov r0, startup_cfg_struct
|
||||||
call get_size
|
call get_size
|
||||||
movz.8 r1, [next_task_id]
|
movz.8 r1, [next_task]
|
||||||
mul r1, 12
|
mul r1, 12
|
||||||
cmp r0, r1
|
cmp r0, r1
|
||||||
iflteq jmp no_other_tasks
|
iflteq jmp no_other_tasks
|
||||||
|
@ -306,7 +285,7 @@ boot_disk_1_loop:
|
||||||
ifz jmp disk_1_is_not_fxf
|
ifz jmp disk_1_is_not_fxf
|
||||||
mov r3, r1
|
mov r3, r1
|
||||||
mov r1, r0
|
mov r1, r0
|
||||||
movz.8 r0, [next_task_id]
|
movz.8 r0, 0
|
||||||
mov r2, rsp
|
mov r2, rsp
|
||||||
sub r2, 4
|
sub r2, 4
|
||||||
mov r4, 0 ; don't attempt to free any stack block if the task ends
|
mov r4, 0 ; don't attempt to free any stack block if the task ends
|
||||||
|
@ -434,7 +413,7 @@ bottom_bar_patterns:
|
||||||
data.32 0xFFFFFFFF
|
data.32 0xFFFFFFFF
|
||||||
data.32 0xFF674764
|
data.32 0xFF674764
|
||||||
|
|
||||||
next_task_id: data.8 0
|
next_task: data.8 0
|
||||||
current_disk_id: data.8 0
|
current_disk_id: data.8 0
|
||||||
startup_cfg: data.str "startup cfg"
|
startup_cfg: data.str "startup cfg"
|
||||||
startup_cfg_struct: data.32 0 data.32 0
|
startup_cfg_struct: data.32 0 data.32 0
|
||||||
|
|
Loading…
Reference in New Issue
Block a user