base + kernel + Fetcher: Use a batch file for defining startup tasks
This commit is contained in:
parent
956c527391
commit
9b78bc2581
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -11,4 +11,4 @@
|
||||||
**/fox32os.img.tmp
|
**/fox32os.img.tmp
|
||||||
**/romdisk.img
|
**/romdisk.img
|
||||||
**/romdisk.img.tmp
|
**/romdisk.img.tmp
|
||||||
**/startup.cfg
|
**/startup.bat
|
||||||
|
|
6
Makefile
6
Makefile
|
@ -64,7 +64,7 @@ applications/launcher/icons.inc: applications/launcher/icons.png
|
||||||
bootloader/bootloader.bin: bootloader/main.asm $(wildcard bootloader/*.asm)
|
bootloader/bootloader.bin: bootloader/main.asm $(wildcard bootloader/*.asm)
|
||||||
$(FOX32ASM) $< $@
|
$(FOX32ASM) $< $@
|
||||||
|
|
||||||
base_image/startup.cfg: base_image/startup.cfg.default
|
base_image/startup.bat: base_image/startup.bat.default
|
||||||
cp $< $@
|
cp $< $@
|
||||||
|
|
||||||
ICONS := \
|
ICONS := \
|
||||||
|
@ -78,7 +78,7 @@ base_image/icons.res: applications/icons/icons.res.asm $(ICONS)
|
||||||
$(FOX32ASM) $< $@
|
$(FOX32ASM) $< $@
|
||||||
|
|
||||||
FILES = \
|
FILES = \
|
||||||
base_image/startup.cfg \
|
base_image/startup.bat \
|
||||||
base_image/icons.res \
|
base_image/icons.res \
|
||||||
base_image/kernel.fxf \
|
base_image/kernel.fxf \
|
||||||
base_image/sh.fxf \
|
base_image/sh.fxf \
|
||||||
|
@ -93,7 +93,7 @@ FILES = \
|
||||||
base_image/launcher.fxf
|
base_image/launcher.fxf
|
||||||
|
|
||||||
ROM_FILES = \
|
ROM_FILES = \
|
||||||
base_image/startup.cfg \
|
base_image/startup.bat \
|
||||||
base_image/icons.res \
|
base_image/icons.res \
|
||||||
base_image/kernel.fxf \
|
base_image/kernel.fxf \
|
||||||
base_image/sh.fxf \
|
base_image/sh.fxf \
|
||||||
|
|
|
@ -23,8 +23,8 @@ MODULE Fetcher;
|
||||||
hasIcons := 1;
|
hasIcons := 1;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
IF (terminalStreamPtr = 0) & (arg0Ptr = 0) THEN
|
IF (CompareString("boot", arg0Ptr)) THEN
|
||||||
(* probably launched from startup.cfg *)
|
(* launched from startup.bat *)
|
||||||
DesktopMain(hasIcons, iconsRes);
|
DesktopMain(hasIcons, iconsRes);
|
||||||
ELSIF (CompareString("open", arg0Ptr)) & (arg1Ptr # 0) & (arg2Ptr # 0) THEN
|
ELSIF (CompareString("open", arg0Ptr)) & (arg1Ptr # 0) & (arg2Ptr # 0) THEN
|
||||||
(* launched from an application wanting to open a file *)
|
(* launched from an application wanting to open a file *)
|
||||||
|
|
|
@ -96,7 +96,8 @@ launch_fxf_name_loop_done:
|
||||||
; loop until the launched task ends
|
; loop until the launched task ends
|
||||||
launch_fxf_yield_loop:
|
launch_fxf_yield_loop:
|
||||||
cmp.8 [launch_fxf_yield_should_suspend], 0
|
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]
|
movz.8 r0, [launch_fxf_task_id]
|
||||||
call is_task_id_used
|
call is_task_id_used
|
||||||
ifz jmp shell_task_return
|
ifz jmp shell_task_return
|
||||||
|
|
5
base_image/startup.bat.default
Normal file
5
base_image/startup.bat.default
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
*bg;
|
||||||
|
*barclock;
|
||||||
|
*fetcher boot;
|
||||||
|
*terminal;
|
||||||
|
exit;
|
|
@ -1,4 +0,0 @@
|
||||||
bg fxf
|
|
||||||
barclockfxf
|
|
||||||
fetcher fxf
|
|
||||||
terminalfxf
|
|
|
@ -183,67 +183,33 @@ draw_bottom_bar_loop:
|
||||||
call copy_memory_bytes
|
call copy_memory_bytes
|
||||||
|
|
||||||
; check if a disk is inserted as disk 1
|
; 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
|
in r31, 0x80001001
|
||||||
cmp r31, 0
|
cmp r31, 0
|
||||||
ifnz jmp boot_disk_1
|
ifnz jmp boot_disk_1
|
||||||
try_startup:
|
try_startup:
|
||||||
; open startup.cfg
|
mov r0, serial_stream
|
||||||
call get_current_disk_id
|
mov r2, serial_stream_struct
|
||||||
mov r1, r0
|
call open
|
||||||
mov r0, startup_cfg
|
|
||||||
mov r2, startup_cfg_struct
|
mov r0, startup_bat
|
||||||
call ryfs_open
|
movz.8 r1, [boot_disk_id]
|
||||||
|
mov r2, startup_bat_check_struct
|
||||||
|
call open
|
||||||
cmp r0, 0
|
cmp r0, 0
|
||||||
ifz jmp startup_error
|
ifz jmp emergency_shell
|
||||||
|
|
||||||
; load a startup task
|
; run `sh startup.bat` with IO redirected to :serial
|
||||||
load_startup_task:
|
mov r0, sh_fxf
|
||||||
; load 11 bytes of startup.cfg into startup_file
|
movz.8 r1, [boot_disk_id]
|
||||||
mov r0, 11
|
mov r2, serial_stream_struct
|
||||||
mov r1, startup_cfg_struct
|
mov r3, startup_bat
|
||||||
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
|
|
||||||
mov r4, 0
|
mov r4, 0
|
||||||
mov r5, 0
|
mov r5, 0
|
||||||
mov r6, 0
|
mov r6, 0
|
||||||
call launch_fxf_from_open_file
|
call launch_fxf_from_disk
|
||||||
|
cmp r0, 0xFFFFFFFF
|
||||||
; when the startup file yields for the first time, we'll end up back here
|
ifz jmp startup_error
|
||||||
; 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
|
|
||||||
|
|
||||||
no_other_tasks:
|
no_other_tasks:
|
||||||
; start the event manager task
|
; start the event manager task
|
||||||
|
@ -256,6 +222,19 @@ no_other_tasks:
|
||||||
; this does not return.
|
; this does not return.
|
||||||
call end_current_task_no_mark_no_free
|
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
|
; try loading the raw contents of disk 1 as an FXF binary
|
||||||
; if disk 1 is not inserted, then fail
|
; if disk 1 is not inserted, then fail
|
||||||
boot_disk_1:
|
boot_disk_1:
|
||||||
|
@ -387,7 +366,7 @@ get_os_api_version:
|
||||||
bottom_bar_str_0: data.strz "FOX"
|
bottom_bar_str_0: data.strz "FOX"
|
||||||
bottom_bar_str_1: data.strz "32"
|
bottom_bar_str_1: data.strz "32"
|
||||||
bottom_bar_str_2: data.strz " OS version %u.%u.%u "
|
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!"
|
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!"
|
api_error_str: data.strz "fox32 - OS version %u.%u.%u - fox32rom API version too low!"
|
||||||
kernelception_error_str: data.strz "Error: kernelception?"
|
kernelception_error_str: data.strz "Error: kernelception?"
|
||||||
|
@ -428,13 +407,13 @@ bottom_bar_patterns:
|
||||||
data.32 0xFFFFFFFF
|
data.32 0xFFFFFFFF
|
||||||
data.32 0xFF674764
|
data.32 0xFF674764
|
||||||
|
|
||||||
next_task: data.8 0
|
|
||||||
current_disk_id: data.8 0
|
current_disk_id: data.8 0
|
||||||
boot_disk_id: data.8 0
|
boot_disk_id: data.8 0
|
||||||
startup_cfg: data.str "startup cfg"
|
sh_fxf: data.strz "sh.fxf"
|
||||||
startup_cfg_struct: data.fill 0, 32
|
startup_bat: data.strz "startup.bat"
|
||||||
startup_file: data.str " "
|
startup_bat_check_struct: data.fill 0, 32
|
||||||
startup_file_struct: data.fill 0, 32
|
serial_stream: data.strz ":serial"
|
||||||
|
serial_stream_struct: data.fill 0, 32
|
||||||
|
|
||||||
#include "../../fox32rom/fox32rom.def"
|
#include "../../fox32rom/fox32rom.def"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user