Make bootloader load both kernel and kernel config

This commit is contained in:
Nero 2019-09-24 21:14:29 +00:00
parent 6411dc0c9c
commit a4e6a943b0
1 changed files with 26 additions and 19 deletions

View File

@ -2,11 +2,9 @@
%define self 0x00600 ; 1 sector %define self 0x00600 ; 1 sector
%define fattab 0x01000 ; variable size %define fattab 0x01000 ; variable size
%define rootdir 0x06000 ; variable size %define rootdir 0x06000 ; variable size
%define psp (prog - 0x100) %define config 0x07800
%define prog 0x07C00 %define prog 0x07C00
%define arguments (psp + 0x81)
org self org self
jmp short init jmp short init
@ -61,14 +59,12 @@ times (62 - ($-$$)) nop
init: init:
cli cli
; Stack grows down from PSP + 64k ; Stack grows down from 64k
mov ax, (psp >> 4) xor ax, ax
mov ss, ax mov ss, ax
xor sp, sp mov sp, ax
push sp
; Relocate from [prog] to [self] ; Relocate from [prog] to [self]
xor ax, ax
mov ds, ax mov ds, ax
mov es, ax mov es, ax
mov si, prog mov si, prog
@ -107,20 +103,28 @@ main:
; clusters start after rootdir ; clusters start after rootdir
mov [cluster_offset], ax mov [cluster_offset], ax
mov ax, filename mov bx, prog
mov ax, kernel_name
call load_file call load_file
mov bp, 0x3332 mov bp, 0x3332
jc error jc error
mov si, bx
sub si, prog
push si
mov ax, config_name
call load_file
pop si
int3
; restore boot drive number ; restore boot drive number
mov dl, [fdc.drv] mov dl, [fdc.drv]
; setup segment registers
push ss
pop ds
push ss
pop es
; jump into target ; jump into target
jmp 0x07C0:0x0000 jmp 0x07C0:0x0000
@ -128,6 +132,7 @@ main:
; IN AX pointer to 8.3 filename ; IN AX pointer to 8.3 filename
; ES:BX pointer to target area ; ES:BX pointer to target area
; OUT CF flag set if error ; OUT CF flag set if error
; DI file size in bytes (<64K)
load_file: load_file:
mov si, rootdir mov si, rootdir
mov cx, [fdc.rde] mov cx, [fdc.rde]
@ -142,12 +147,12 @@ load_file:
je .read je .read
add si, 0x20 add si, 0x20
loop .search loop .search
xor di, di
stc stc
ret ret
.read: .read:
add si, 0x1A mov ax, [si+0x1A]
lodsw mov di, [si+0x1C]
mov bx, prog
jmp read_clusters jmp read_clusters
; Read the file given by cluster number ; Read the file given by cluster number
@ -247,7 +252,9 @@ error:
int 0x16 int 0x16
int 0x19 int 0x19
filename: config_name:
db "RCONFIG SYS"
kernel_name:
db "RDOS SYS" db "RDOS SYS"
times (0x1FE - ($-$$)) db 0 times (0x1FE - ($-$$)) db 0