feat(boot/loader): preload kernel at 0xF000
This commit is contained in:
parent
87857101d9
commit
7260b03fca
2
.github/workflows/analyze.yml
vendored
2
.github/workflows/analyze.yml
vendored
|
@ -19,7 +19,7 @@ jobs:
|
||||||
|
|
||||||
- name: Run shellcheck
|
- name: Run shellcheck
|
||||||
run: |
|
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
|
- name: Run CppCheck
|
||||||
run: |
|
run: |
|
||||||
|
|
|
@ -65,7 +65,6 @@ efimain:
|
||||||
call [fnOutputStr]
|
call [fnOutputStr]
|
||||||
add esp, 8
|
add esp, 8
|
||||||
|
|
||||||
|
|
||||||
; #=======================#
|
; #=======================#
|
||||||
; search and load kernel
|
; search and load kernel
|
||||||
; openVolume()
|
; openVolume()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
disk_read_sectors:
|
disk_read_sectors:
|
||||||
test byte [bDriveLBA], TRUE
|
; test byte [bDriveLBA], TRUE
|
||||||
je .lba_read
|
; je .lba_read
|
||||||
push ax
|
push ax
|
||||||
push bx
|
push bx
|
||||||
push cx
|
push cx
|
||||||
|
@ -61,11 +61,11 @@ disk_packet:
|
||||||
dd 0
|
dd 0
|
||||||
|
|
||||||
|
|
||||||
sectors_per_track dw 0
|
sectors_per_track dw 18
|
||||||
heads_per_cylinder dw 0
|
heads_per_cylinder dw 2
|
||||||
bytes_per_sector dw 0
|
bytes_per_sector dw 512
|
||||||
sectors_per_FAT dw 0
|
sectors_per_FAT dw 9
|
||||||
FAT_count db 0
|
FAT_count db 2
|
||||||
reserved_sectors dw 0
|
reserved_sectors dw 1
|
||||||
root_dir_entries dw 0
|
root_dir_entries dw 224
|
||||||
sectors_per_cluster db 0
|
sectors_per_cluster db 1
|
||||||
|
|
|
@ -36,8 +36,6 @@ _start:
|
||||||
call a20_enable
|
call a20_enable
|
||||||
jc .error_a20
|
jc .error_a20
|
||||||
|
|
||||||
xchg bx, bx
|
|
||||||
|
|
||||||
; check drive type
|
; check drive type
|
||||||
; dl <= 0x7F == floppy
|
; dl <= 0x7F == floppy
|
||||||
; dl >= 0x80 == hard drive
|
; dl >= 0x80 == hard drive
|
||||||
|
@ -70,7 +68,27 @@ _start:
|
||||||
call fat_search_root
|
call fat_search_root
|
||||||
jc .error_not_found
|
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
|
; fetch memory map from bios
|
||||||
call memory_get_map
|
call memory_get_map
|
||||||
jc .error_memory
|
jc .error_memory
|
||||||
|
@ -122,11 +140,13 @@ _start:
|
||||||
uDrive rb 1
|
uDrive rb 1
|
||||||
bDriveLBA db FALSE
|
bDriveLBA db FALSE
|
||||||
|
|
||||||
szMsgStage2 db "StupidOS Loader %x", 0
|
pKernelStartFat dw 0
|
||||||
|
|
||||||
|
szMsgStage2 db "StupidOS Loader", 0
|
||||||
szKernelFile db "VMSTUPIDSYS", 0
|
szKernelFile db "VMSTUPIDSYS", 0
|
||||||
szMsgErrorA20 db "ERROR: can't enable a20 line", 0
|
szMsgErrorA20 db "ERROR: can't enable a20 line", 0
|
||||||
szMsgErrorMemory db "ERROR: can't detect available memory", 0
|
szMsgErrorMemory db "ERROR: can't detect available memory", 0
|
||||||
szMsgErrorSector db "ERROR: reading sector", CR, LF, 0
|
szMsgErrorSector db "ERROR: reading sector", CR, LF, 0
|
||||||
szMsgErrorNotFound db "ERROR: kernel not found", 0
|
szMsgErrorNotFound db "ERROR: kernel not found", 0
|
||||||
|
|
||||||
use32
|
use32
|
||||||
|
|
|
@ -62,7 +62,6 @@ bios_log_hex:
|
||||||
mov si, szHexBuffer
|
mov si, szHexBuffer
|
||||||
xor cl, cl
|
xor cl, cl
|
||||||
.loop:
|
.loop:
|
||||||
xchg bx, bx
|
|
||||||
cmp cl, 8
|
cmp cl, 8
|
||||||
je .print_number
|
je .print_number
|
||||||
rol edi, 4
|
rol edi, 4
|
||||||
|
|
|
@ -66,8 +66,19 @@ memory_e820_get_map:
|
||||||
;; CX - Configured 1
|
;; CX - Configured 1
|
||||||
;; DX - Configured 2
|
;; DX - Configured 2
|
||||||
memory_get_for_large_conf:
|
memory_get_for_large_conf:
|
||||||
|
clc
|
||||||
mov ax, 0xE801
|
mov ax, 0xE801
|
||||||
int 0x15
|
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
|
;; Function: memory_get_extended_memory_size
|
||||||
;;
|
;;
|
||||||
|
@ -78,5 +89,30 @@ memory_get_for_large_conf:
|
||||||
;; CF - Non-Carry - indicates no error
|
;; CF - Non-Carry - indicates no error
|
||||||
;; AX - Number of contiguous KB above 1MB
|
;; AX - Number of contiguous KB above 1MB
|
||||||
memory_get_map:
|
memory_get_map:
|
||||||
|
call memory_get_for_large_conf
|
||||||
|
jnc .end
|
||||||
clc
|
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
|
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
|
||||||
|
|
Loading…
Reference in a new issue