kernel/main: Add a fox32rom API version check

This commit is contained in:
Ry 2023-03-06 17:29:06 -08:00
parent 6253b60762
commit f47892c133
2 changed files with 38 additions and 2 deletions

View File

@ -2,8 +2,9 @@
; system jump table ; system jump table
get_os_version: jmp [0x00000810] get_os_version: jmp [0x00000810]
get_current_disk_id: jmp [0x00000814] get_os_api_version: jmp [0x00000814]
set_current_disk_id: jmp [0x00000818] get_current_disk_id: jmp [0x00000818]
set_current_disk_id: jmp [0x0000081C]
; FXF jump table ; FXF jump table
parse_fxf_binary: jmp [0x00000910] parse_fxf_binary: jmp [0x00000910]

View File

@ -6,6 +6,10 @@ const FOX32OS_VERSION_MAJOR: 0
const FOX32OS_VERSION_MINOR: 1 const FOX32OS_VERSION_MINOR: 1
const FOX32OS_VERSION_PATCH: 1 const FOX32OS_VERSION_PATCH: 1
const FOX32OS_API_VERSION: 1
const REQUIRED_FOX32ROM_API_VERSION: 1
const SYSTEM_STACK: 0x01FFF800 const SYSTEM_STACK: 0x01FFF800
const BACKGROUND_COLOR: 0xFF674764 const BACKGROUND_COLOR: 0xFF674764
const TEXT_COLOR: 0xFFFFFFFF const TEXT_COLOR: 0xFFFFFFFF
@ -16,6 +20,7 @@ const TEXT_COLOR: 0xFFFFFFFF
org.pad 0x00000010 org.pad 0x00000010
jump_table: jump_table:
data.32 get_os_version data.32 get_os_version
data.32 get_os_api_version
data.32 get_current_disk_id data.32 get_current_disk_id
data.32 set_current_disk_id data.32 set_current_disk_id
@ -99,6 +104,16 @@ entry_ok:
mov r0, BACKGROUND_COLOR mov r0, BACKGROUND_COLOR
call fill_background call fill_background
; check for the required fox32rom API version
mov r0, get_rom_api_version
add r0, 2
mov r0, [r0]
cmp [r0], 0
ifz jmp api_version_too_low_error
call get_rom_api_version
cmp r0, REQUIRED_FOX32ROM_API_VERSION
iflt jmp api_version_too_low_error
; initialize the memory allocator ; initialize the memory allocator
call initialize_allocator call initialize_allocator
@ -333,6 +348,21 @@ memory_error:
call draw_format_str_to_background call draw_format_str_to_background
rjmp 0 rjmp 0
api_version_too_low_error:
mov r0, BACKGROUND_COLOR
call fill_background
mov r0, api_error_str
mov r1, 16
mov r2, 464
mov r3, TEXT_COLOR
mov r4, 0x00000000
mov r10, FOX32OS_VERSION_MAJOR
mov r11, FOX32OS_VERSION_MINOR
mov r12, FOX32OS_VERSION_PATCH
call draw_format_str_to_background
rjmp 0
get_current_disk_id: get_current_disk_id:
movz.8 r0, [current_disk_id] movz.8 r0, [current_disk_id]
ret ret
@ -347,6 +377,10 @@ get_os_version:
mov r2, FOX32OS_VERSION_PATCH mov r2, FOX32OS_VERSION_PATCH
ret ret
get_os_api_version:
mov r0, FOX32OS_API_VERSION
ret
#include "allocator.asm" #include "allocator.asm"
#include "fxf/fxf.asm" #include "fxf/fxf.asm"
#include "task.asm" #include "task.asm"
@ -359,6 +393,7 @@ 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 - startup.cfg is invalid!"
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!"
kernelception_error_str: data.strz "Error: kernelception?" kernelception_error_str: data.strz "Error: kernelception?"
bottom_bar_patterns: bottom_bar_patterns:
; 1x16 tile ; 1x16 tile