From: John Tsiombikas Date: Wed, 16 Nov 2022 20:03:03 +0000 (+0200) Subject: now it should boot on an IBM PC correctly (tested on pcem) X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=eightysix;a=commitdiff_plain;h=de48157cb811c927d7a2af1be1ed15b162a320a2 now it should boot on an IBM PC correctly (tested on pcem) --- diff --git a/.gitignore b/.gitignore index 77c7ebc..a3492c9 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ dis1 dis2 *.log +bootldr diff --git a/Makefile b/Makefile index 8e95cce..5c19343 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,17 @@ -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 $@ $^ @@ -17,12 +25,12 @@ clean: .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) diff --git a/boot/boot.asm b/boot/boot.asm index 2b74db8..96506de 100644 --- a/boot/boot.asm +++ b/boot/boot.asm @@ -27,21 +27,29 @@ cur_cyl equ 7b14h ; 2 bytes - current cylinder %%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