Add first steps for VBR bootloader

This commit is contained in:
Nero 2019-03-25 08:51:37 +00:00
parent 414f35a1ce
commit 2229c319b6
3 changed files with 59 additions and 1 deletions

View File

@ -1,7 +1,14 @@
default: kernel.com
kernel.com: kernel/*.asm
nasm -s -o kernel.com -I kernel kernel/main.asm
nasm -s -o $@ -I kernel kernel/main.asm
vbr.bin: boot/vbr.asm
nasm -s -o $@ -I lib $<
fdimage.img: vbr.bin kernel.com
dd if=/dev/zero bs=512 count=720 of=$@
dd if=vbr.bin bs=512 count=1 conv=notrunc of=$@
clean:
rm -f *.com

49
boot/vbr.asm Normal file
View File

@ -0,0 +1,49 @@
org 0x7C00
bpb:
jmp _startup ; 2 bytes
nop ; 1 byte
.oem:
db "2A " ; OEM
.bps:
dw 0x200 ; bytes per sector
.spc:
db 1 ; sectors per cluster
.rsectors:
dw 2 ; number of reserved sectors
.fatcnt:
db 2 ; number of file allocation tables
.dirents:
dw 2 ; Number of directory entries
.seccnt:
dw 720 ; total number of sectors
.mtd: ; media descriptor type
db 0xFD ; 5.25-inch Double sided, 40 tracks per side, 9 sectors per track (360 KB)
.spfat: ; sectors per fat
dw 0
.spt:
dw 9 ; sectors per track
.headcnt:
dw 2 ; number of heads
.hidseccnt:
dd 0 ; number of hidden sectors
.lrgseccnt:
dd 0 ; large sector count
times (0x3E - ($-$$)) nop
_startup:
mov ah, 0x08
mov dl, 0x00
int 0x13
mov ax, cx
and ax, 0x003F
call print16
.end:
hlt
jmp .end
%include "print.asm"
times (0x1FE - ($-$$)) nop
dw 0xAA55

2
run-floppy.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
exec qemu-system-x86_64 -fda fdimage.img