Load kernel from reserved sectors in fatfs
This commit is contained in:
parent
1ee0637eab
commit
8e87cf0f75
25
Makefile
25
Makefile
@ -1,7 +1,5 @@
|
||||
FLOPPY = 1440
|
||||
|
||||
PROGRAMS = hello.com
|
||||
DISTFILES = $(PROGRAMS) kernel.bs
|
||||
DISTFILES = $(PROGRAMS)
|
||||
ROMS =
|
||||
|
||||
QEMU_ARCH = $(shell uname -m)
|
||||
@ -9,7 +7,7 @@ QEMU = qemu-system-$(QEMU_ARCH)
|
||||
QEMU_ARGS = $(addprefix --option-rom ,$(ROMS))
|
||||
|
||||
NASM = nasm
|
||||
NASM_ARGS = -s -Ilib -DFLOPPY=$(FLOPPY)
|
||||
NASM_ARGS = -s -Ilib
|
||||
|
||||
EMUL = utils/emul
|
||||
|
||||
@ -28,7 +26,7 @@ endif
|
||||
|
||||
.PHONY: default bootstrap clean qemu-rom qemu-floppy qemu-pxe
|
||||
|
||||
default: fdimage.img
|
||||
default: fd1440.img
|
||||
|
||||
# Host utils
|
||||
utils/%: %.c
|
||||
@ -59,14 +57,13 @@ fat6.bs: boot/fat.asm
|
||||
%.rom: rom/%.asm utils/fix-rom
|
||||
$(NASM) $(NASM_ARGS) -o $@ $< && utils/fix-rom $@
|
||||
|
||||
fdimage.img: fat1.bs $(DISTFILES)
|
||||
mformat -C -i $@ -f $(FLOPPY) -B fat1.bs ::
|
||||
mmd -i $@ ::rdos
|
||||
mcopy -i $@ $(DISTFILES) ::rdos
|
||||
mattrib -i $@ +s ::rdos ::rdos/kernel.bs
|
||||
fd%.img: kernel.bs $(DISTFILES)
|
||||
mformat -C -i $@ -f $* -R 8 -B kernel.bs ::
|
||||
dd if=kernel.bs conv=notrunc bs=512 skip=1 seek=1 of=$@
|
||||
mcopy -i $@ $(DISTFILES) ::
|
||||
|
||||
hdimage.img: mbr.bs fdimage.img
|
||||
cat mbr.bs fdimage.img >$@
|
||||
hdimage.img: mbr.bs fd1440.img
|
||||
cat mbr.bs fd1440 >$@
|
||||
|
||||
part.img: fatc.bs $(DISTFILES)
|
||||
dd if=/dev/zero bs=1024 count=33k of=$@
|
||||
@ -82,8 +79,8 @@ clean:
|
||||
rm -f *.com *.bs *.0 *.lst *.img *.bin *.rom
|
||||
rm -rf utils
|
||||
|
||||
qemu-floppy: fdimage.img $(ROMS)
|
||||
$(QEMU) $(QEMU_ARGS) -boot a -fda fdimage.img
|
||||
qemu-floppy: fd1440.img $(ROMS)
|
||||
$(QEMU) $(QEMU_ARGS) -boot a -fda fd1440.img
|
||||
|
||||
qemu-hdd: hdd.img $(ROMS)
|
||||
$(QEMU) $(QEMU_ARGS) -boot c -hda hdd.img
|
||||
|
@ -7,11 +7,12 @@
|
||||
; kernel stack size in words
|
||||
%define stacksize 512
|
||||
|
||||
jmp init
|
||||
jmp near init
|
||||
|
||||
times ( 0x0B - ($-$$) ) db " "
|
||||
db "LOVELAIN"
|
||||
|
||||
times bpb_size db 0
|
||||
; mformat writes stuff until 0x3E
|
||||
params: times ( 0x3E - ($-$$) ) nop
|
||||
|
||||
init: cli
|
||||
xor ax, ax
|
||||
@ -20,11 +21,31 @@ init: cli
|
||||
mov ss, ax
|
||||
mov sp, ( stack+stacksize )
|
||||
|
||||
mov ax, [params+bpb.sectoroffset]
|
||||
mov dx, [params+bpb.sectoroffset+2]
|
||||
|
||||
mov ax, 0x0201
|
||||
mov cx, 0x0002
|
||||
mov dh, 0
|
||||
mov bx, 0x7E00
|
||||
int 0x13
|
||||
|
||||
mov ax, [0x7E00]
|
||||
mov cx, [0x7E02]
|
||||
mov dx, [0x7E04]
|
||||
|
||||
int 3
|
||||
|
||||
hlt: hlt
|
||||
jmp hlt
|
||||
|
||||
times (0x1FE - ($-$$)) db 0
|
||||
dw 0xAA55
|
||||
|
||||
db "rdos kernel"
|
||||
|
||||
end: align 512
|
||||
|
||||
section .bss
|
||||
|
||||
stack: resb stacksize
|
||||
|
@ -131,7 +131,7 @@ part1: db 0x80
|
||||
db 0x01
|
||||
db 0xFF, 0xFF, 0xFF
|
||||
dd 1
|
||||
dd (FLOPPY * 2)
|
||||
dd (1440 * 2)
|
||||
|
||||
times (0x1FE - ($-$$)) db 0
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user