feat(boot/loader): preload kernel at 0xF000

This commit is contained in:
d0p1 🏳️‍⚧️ 2024-06-11 11:53:34 +02:00
parent 87857101d9
commit 7260b03fca
6 changed files with 71 additions and 17 deletions

View file

@ -19,7 +19,7 @@ jobs:
- name: Run shellcheck
run: |
shellcheck ./releasetools/cdimage.sh ./releasetools/floppyimage.sh ./releasetools/hdimages.sh ./releasetools/image.defaults ./releasetools/image.functions
shellcheck ./releasetools/cdimage.sh ./releasetools/floppyimage.sh ./releasetools/hdimage.sh ./releasetools/image.defaults ./releasetools/image.functions
- name: Run CppCheck
run: |

View file

@ -65,7 +65,6 @@ efimain:
call [fnOutputStr]
add esp, 8
; #=======================#
; search and load kernel
; openVolume()

View file

@ -1,7 +1,7 @@
disk_read_sectors:
test byte [bDriveLBA], TRUE
je .lba_read
; test byte [bDriveLBA], TRUE
; je .lba_read
push ax
push bx
push cx
@ -61,11 +61,11 @@ disk_packet:
dd 0
sectors_per_track dw 0
heads_per_cylinder dw 0
bytes_per_sector dw 0
sectors_per_FAT dw 0
FAT_count db 0
reserved_sectors dw 0
root_dir_entries dw 0
sectors_per_cluster db 0
sectors_per_track dw 18
heads_per_cylinder dw 2
bytes_per_sector dw 512
sectors_per_FAT dw 9
FAT_count db 2
reserved_sectors dw 1
root_dir_entries dw 224
sectors_per_cluster db 1

View file

@ -36,8 +36,6 @@ _start:
call a20_enable
jc .error_a20
xchg bx, bx
; check drive type
; dl <= 0x7F == floppy
; dl >= 0x80 == hard drive
@ -70,7 +68,27 @@ _start:
call fat_search_root
jc .error_not_found
mov [pKernelStartFat], ax
; load fat
xor ax, ax
mov al, [FAT_count]
mul word [sectors_per_FAT]
mov cx, ax
mov ax, [reserved_sectors]
xor bx, bx
call disk_read_sectors
; load stage 2
mov ax, KERNEL_PRELOAD/0x10
mov es, ax
mov ax, [pKernelStartFat]
xor bx, bx
call fat_load_binary
xchg bx, bx
; fetch memory map from bios
call memory_get_map
jc .error_memory
@ -122,7 +140,9 @@ _start:
uDrive rb 1
bDriveLBA db FALSE
szMsgStage2 db "StupidOS Loader %x", 0
pKernelStartFat dw 0
szMsgStage2 db "StupidOS Loader", 0
szKernelFile db "VMSTUPIDSYS", 0
szMsgErrorA20 db "ERROR: can't enable a20 line", 0
szMsgErrorMemory db "ERROR: can't detect available memory", 0

View file

@ -62,7 +62,6 @@ bios_log_hex:
mov si, szHexBuffer
xor cl, cl
.loop:
xchg bx, bx
cmp cl, 8
je .print_number
rol edi, 4

View file

@ -66,8 +66,19 @@ memory_e820_get_map:
;; CX - Configured 1
;; DX - Configured 2
memory_get_for_large_conf:
clc
mov ax, 0xE801
int 0x15
jc @f
xor ecx, ecx
mov cx, ax
push ecx
mov cx, bx
push ecx
mov si, szMsgLarge
call bios_log
@@:
ret
;; Function: memory_get_extended_memory_size
;;
@ -78,5 +89,30 @@ memory_get_for_large_conf:
;; CF - Non-Carry - indicates no error
;; AX - Number of contiguous KB above 1MB
memory_get_map:
call memory_get_for_large_conf
jnc .end
clc
mov ah, 0x88
int 0x15
jc .end
xor ebx, ebx
mov bx, ax
push ebx
mov si, szMsgMaxMemKB
call bios_log
shr ebx, 2
push ebx
mov si, szMsgMaxPage
call bios_log
.end:
ret
szMsgMaxMemKB db "%x KB above 1MB", 0
szMsgMaxPage db "%x pages", 0
szMsgLarge db "%x KB above 1MB - %x * 64 KB above 16MB", 0