base + kernel + Fetcher: Use a batch file for defining startup tasks

This commit is contained in:
Ry 2023-12-17 23:39:29 -08:00
parent 956c527391
commit 9b78bc2581
7 changed files with 50 additions and 69 deletions

2
.gitignore vendored
View File

@ -11,4 +11,4 @@
**/fox32os.img.tmp
**/romdisk.img
**/romdisk.img.tmp
**/startup.cfg
**/startup.bat

View File

@ -64,7 +64,7 @@ applications/launcher/icons.inc: applications/launcher/icons.png
bootloader/bootloader.bin: bootloader/main.asm $(wildcard bootloader/*.asm)
$(FOX32ASM) $< $@
base_image/startup.cfg: base_image/startup.cfg.default
base_image/startup.bat: base_image/startup.bat.default
cp $< $@
ICONS := \
@ -78,7 +78,7 @@ base_image/icons.res: applications/icons/icons.res.asm $(ICONS)
$(FOX32ASM) $< $@
FILES = \
base_image/startup.cfg \
base_image/startup.bat \
base_image/icons.res \
base_image/kernel.fxf \
base_image/sh.fxf \
@ -93,7 +93,7 @@ FILES = \
base_image/launcher.fxf
ROM_FILES = \
base_image/startup.cfg \
base_image/startup.bat \
base_image/icons.res \
base_image/kernel.fxf \
base_image/sh.fxf \

View File

@ -23,8 +23,8 @@ MODULE Fetcher;
hasIcons := 1;
END;
IF (terminalStreamPtr = 0) & (arg0Ptr = 0) THEN
(* probably launched from startup.cfg *)
IF (CompareString("boot", arg0Ptr)) THEN
(* launched from startup.bat *)
DesktopMain(hasIcons, iconsRes);
ELSIF (CompareString("open", arg0Ptr)) & (arg1Ptr # 0) & (arg2Ptr # 0) THEN
(* launched from an application wanting to open a file *)

View File

@ -96,7 +96,8 @@ launch_fxf_name_loop_done:
; loop until the launched task ends
launch_fxf_yield_loop:
cmp.8 [launch_fxf_yield_should_suspend], 0
ifz jmp shell_task_return
ifz pop r0 ; pop our return addr off the stack so we return 2 levels up. this is cursed
ifz ret
movz.8 r0, [launch_fxf_task_id]
call is_task_id_used
ifz jmp shell_task_return

View File

@ -0,0 +1,5 @@
*bg;
*barclock;
*fetcher boot;
*terminal;
exit;

View File

@ -1,4 +0,0 @@
bg fxf
barclockfxf
fetcher fxf
terminalfxf

View File

@ -183,67 +183,33 @@ draw_bottom_bar_loop:
call copy_memory_bytes
; check if a disk is inserted as disk 1
; if so, skip checking startup.cfg and just run disk 1
; if so, skip checking startup.bat and just run disk 1
in r31, 0x80001001
cmp r31, 0
ifnz jmp boot_disk_1
try_startup:
; open startup.cfg
call get_current_disk_id
mov r1, r0
mov r0, startup_cfg
mov r2, startup_cfg_struct
call ryfs_open
mov r0, serial_stream
mov r2, serial_stream_struct
call open
mov r0, startup_bat
movz.8 r1, [boot_disk_id]
mov r2, startup_bat_check_struct
call open
cmp r0, 0
ifz jmp startup_error
ifz jmp emergency_shell
; load a startup task
load_startup_task:
; load 11 bytes of startup.cfg into startup_file
mov r0, 11
mov r1, startup_cfg_struct
mov r2, startup_file
call ryfs_read
; open the actual startup file
call get_current_disk_id
mov r1, r0
mov r0, startup_file
mov r2, startup_file_struct
call ryfs_open
cmp r0, 0
ifz jmp startup_error
; create a new task and yield to it
mov r0, startup_file_struct
mov r1, 0
mov r2, 0
mov r3, 0
; run `sh startup.bat` with IO redirected to :serial
mov r0, sh_fxf
movz.8 r1, [boot_disk_id]
mov r2, serial_stream_struct
mov r3, startup_bat
mov r4, 0
mov r5, 0
mov r6, 0
call launch_fxf_from_open_file
; 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
; 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]
mov r0, startup_cfg_struct
call get_size
movz.8 r1, [next_task]
mul r1, 12
cmp r0, r1
iflteq jmp no_other_tasks
; seek forward one byte to skip the linefeed
mov r0, startup_cfg_struct
call ryfs_tell
inc r0
mov r1, startup_cfg_struct
call ryfs_seek
; load the next task
jmp load_startup_task
call launch_fxf_from_disk
cmp r0, 0xFFFFFFFF
ifz jmp startup_error
no_other_tasks:
; start the event manager task
@ -256,6 +222,19 @@ no_other_tasks:
; this does not return.
call end_current_task_no_mark_no_free
emergency_shell:
mov r0, sh_fxf
movz.8 r1, [boot_disk_id]
mov r2, serial_stream_struct
mov r3, 0
mov r4, 0
mov r5, 0
mov r6, 0
call launch_fxf_from_disk
cmp r0, 0xFFFFFFFF
ifz jmp startup_error
jmp no_other_tasks
; try loading the raw contents of disk 1 as an FXF binary
; if disk 1 is not inserted, then fail
boot_disk_1:
@ -387,7 +366,7 @@ get_os_api_version:
bottom_bar_str_0: data.strz "FOX"
bottom_bar_str_1: data.strz "32"
bottom_bar_str_2: data.strz " OS version %u.%u.%u "
startup_error_str: data.strz "fox32 - OS version %u.%u.%u - startup.cfg is invalid!"
startup_error_str: data.strz "fox32 - OS version %u.%u.%u - sh.fxf is missing?"
memory_error_str: data.strz "fox32 - OS version %u.%u.%u - not enough memory to perform operation!"
api_error_str: data.strz "fox32 - OS version %u.%u.%u - fox32rom API version too low!"
kernelception_error_str: data.strz "Error: kernelception?"
@ -428,13 +407,13 @@ bottom_bar_patterns:
data.32 0xFFFFFFFF
data.32 0xFF674764
next_task: data.8 0
current_disk_id: data.8 0
boot_disk_id: data.8 0
startup_cfg: data.str "startup cfg"
startup_cfg_struct: data.fill 0, 32
startup_file: data.str " "
startup_file_struct: data.fill 0, 32
sh_fxf: data.strz "sh.fxf"
startup_bat: data.strz "startup.bat"
startup_bat_check_struct: data.fill 0, 32
serial_stream: data.strz ":serial"
serial_stream_struct: data.fill 0, 32
#include "../../fox32rom/fox32rom.def"