Skip to content

Commit

Permalink
Implement minimum version detection (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelherodev authored Jan 29, 2020
1 parent b387340 commit 2f65d75
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions src/00/thread.asm
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,12 @@ launchProgram:
push de
push ix
call openFileRead
jr nz, .error
jp nz, .error

call getStreamInfo
; TODO: If E > 0, then the file is too large. Error out before we ask malloc about it.
call malloc
jr nz, .error_pop2
jp nz, .error_pop2
call getNewThreadId
call reassignMemory

Expand All @@ -401,8 +401,31 @@ launchProgram:
cp (ix + 3)
jr nz, .magic_error

; TODO: Check minimum required kernel version, if present

; Check minimum required kernel version, if present
ld b, KEXC_KERNEL_VER
push ix \ call _getThreadHeader \ pop ix
jr nz, .no_minimum_ver
ex hl, de
call getKernelMajorVersion
jr nz, .unknown_ver
; If running minimum ver is less than required, abort load
; TODO on major ver: decide what to do if major ver is greater
ld a, e
cp l
jr c, .kernel_too_low

call getKernelMinorVersion
jr nz, .unknown_ver
ld a, d
cp l
jr c, .kernel_too_low
; Running version meets requirements

; Running version is unknown
.unknown_ver:
; no minimum version is specified by the executable
.no_minimum_ver:
; Grab header info
ld b, KEXC_ENTRY_POINT
push ix \ call _getThreadHeader \ pop ix
Expand Down Expand Up @@ -436,6 +459,9 @@ _: ld a, b
pop bc
cp a
ret
.kernel_too_low:
ld a, errKernelMismatch
jr .error
.no_entry_point:
ld a, errNoEntryPoint
jr .error
Expand Down

0 comments on commit 2f65d75

Please sign in to comment.