-bin = boot.img
+disk_numsec = 720
+#disk_numsec = 2880
+
+bin = bootldr
+img = bootldr.img
CC = ia16-elf-gcc
LD = ia16-elf-ld
-CFLAGS = -march=i8088 -mtune=i8088
+CFLAGS = -march=i8088 -mtune=i8088 -DFLOPPY360
+
+$(img): $(bin)
+ dd if=/dev/zero of=$@ bs=512 count=$(disk_numsec)
+ dd if=$< of=$@ bs=512 conv=notrunc
$(bin): boot/boot.o boot/boot2.o boot/main.o
$(LD) -T boot.ld -Map boot.map -o $@ $^
.PHONY: run
-run: $(bin)
- qemu-system-i386 -fda $(bin) -serial file:serial.log
+run: $(img)
+ qemu-system-i386 -fda $(img) -serial file:serial.log
.PHONY: debug
-debug: $(bin)
- qemu-system-i386 -fda $(bin) -serial file:serial.log -s -S
+debug: $(img)
+ qemu-system-i386 -fda $(img) -serial file:serial.log -s -S
.PHONY: disasm
disasm: $(bin)
%%end: popf
%endmacro
+; 5.25" 360K floppy
+BPB_DISK_SECTORS equ 720
+BPB_TRACK_SECTORS equ 9
+BPB_MEDIA_TYPE equ 0fdh
+; 3.5" 1.44M floppy
+;BPB_DISK_SECTORS equ 2880
+;BPB_TRACK_SECTORS equ 18
+;BPB_MEDIA_TYPE equ 0f0h
bios_param_block:
jmp start ; 2 bytes
nop ; 1 byte
; start of BPB at offset 3
- db "BSPL 0.1" ; 03h: OEM ident, 8 bytes
+ db "86BOOT00" ; 03h: OEM ident, 8 bytes
dw 512 ; 0bh: bytes per sector
db 1 ; 0dh: sectors per cluster
dw 1 ; 0eh: reserved sectors (including boot record)
db 2 ; 10h: number of FATs
dw 224 ; 11h: number of dir entries
- dw 2880 ; 13h: number of sectors in volume
- db 0fh ; 15h: media descriptor type (f = 3.5" HD floppy)
+ dw BPB_DISK_SECTORS ; 13h: number of sectors in volume
+ db BPB_MEDIA_TYPE ; 15h: media descriptor type (f0 = 3.5" HD floppy)
dw 9 ; 16h: number of sectors per FAT
- dw 18 ; 18h: number of sectors per track
+ dw BPB_TRACK_SECTORS ; 18h: number of sectors per track
dw 2 ; 1ah: number of heads
dd 0 ; 1ch: number of hidden sectors
dd 0 ; 20h: high bits of sector count