build: 1.44MB and 2.88MB floppy
This commit is contained in:
parent
0cf565c93c
commit
d70a9436a0
19
Makefile
19
Makefile
|
@ -17,7 +17,7 @@ MK_COMMIT := \"$(shell git rev-parse --short HEAD)\"
|
|||
|
||||
SUBDIRS := external tools include boot kernel lib bin
|
||||
|
||||
TARGET = stupid.tar.gz floppy_boot.img
|
||||
TARGET = stupid.tar.gz floppy1440.img floppy2880.img
|
||||
ifneq ($(OS),Windows_NT)
|
||||
EXEXT =
|
||||
TARGET += stupid.iso stupid.hdd
|
||||
|
@ -48,14 +48,23 @@ stupid.hdd: $(SUBDIRS)
|
|||
stupid.tar.gz: $(SUBDIRS)
|
||||
tar -czvf $@ sysroot
|
||||
|
||||
.PHONY: floppy_boot.img
|
||||
floppy_boot.img: $(SUBDIRS)
|
||||
.PHONY: floppy1440.img
|
||||
floppy1440.img: $(SUBDIRS)
|
||||
dd if=/dev/zero of=$@ bs=512 count=1440
|
||||
mformat -C -f 1440 -i $@
|
||||
dd if=boot/bootsect/bootsector.bin of=$@ conv=notrunc
|
||||
dd if=boot/bootsect/boot_floppy1440.bin of=$@ conv=notrunc
|
||||
mcopy -i $@ boot/loader/stpdldr.sys ::/STPDLDR.SYS
|
||||
mcopy -i $@ kernel/vmstupid.sys ::/VMSTUPID.SYS
|
||||
|
||||
.PHONY: floppy2880.img
|
||||
floppy2880.img: $(SUBDIRS)
|
||||
dd if=/dev/zero of=$@ bs=512 count=2880
|
||||
mformat -C -f 2880 -i $@
|
||||
dd if=boot/bootsect/boot_floppy2880.bin of=$@ conv=notrunc
|
||||
mcopy -i $@ boot/loader/stpdldr.sys ::/STPDLDR.SYS
|
||||
mcopy -i $@ kernel/vmstupid.sys ::/VMSTUPID.SYS
|
||||
|
||||
|
||||
OVMF32.fd:
|
||||
wget 'https://retrage.github.io/edk2-nightly/bin/DEBUGIa32_OVMF.fd' -O $@
|
||||
|
||||
|
@ -63,7 +72,7 @@ OVMF32.fd:
|
|||
run: all
|
||||
qemu-system-i386 \
|
||||
-rtc base=localtime \
|
||||
-drive file=floppy_boot.img,if=none,format=raw,id=boot \
|
||||
-drive file=floppy1440.img,if=none,format=raw,id=boot \
|
||||
-drive file=fat:rw:./sysroot,if=none,id=hdd \
|
||||
-device floppy,drive=boot \
|
||||
-device ide-hd,drive=hdd \
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
TARGET = bootsector.bin
|
||||
TARGET = boot_floppy1440.bin \
|
||||
boot_floppy2880.bin
|
||||
|
||||
FLOPPY_SRCS = floppy.asm \
|
||||
../common/const.inc \
|
||||
|
@ -7,9 +8,12 @@ FLOPPY_SRCS = floppy.asm \
|
|||
.PHONY: all
|
||||
all: $(TARGET)
|
||||
|
||||
bootsector.bin: $(FLOPPY_SRCS)
|
||||
boot_floppy1440.bin: $(FLOPPY_SRCS)
|
||||
$(AS) floppy.asm $@
|
||||
|
||||
boot_floppy2880.bin: $(FLOPPY_SRCS)
|
||||
$(AS) -DFLOPPY_SIZE=FLOPPY_2880 floppy.asm $@
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(RM) $(TARGET)
|
||||
|
|
|
@ -3,30 +3,42 @@
|
|||
use16
|
||||
|
||||
include '../common/const.inc'
|
||||
include '../common/macro.inc'
|
||||
|
||||
org BOOTSECT_BASE
|
||||
|
||||
jmp short _start
|
||||
nop
|
||||
|
||||
if FLOPPY_SIZE eq FLOPPY_2880
|
||||
SECTORS_PER_CLUSTER = 2
|
||||
ROOT_DIR_ENTRIES = 240
|
||||
TOTAL_SECTORS = 5760
|
||||
SECTORS_PER_TRACK = 36
|
||||
else
|
||||
SECTORS_PER_CLUSTER = 1
|
||||
ROOT_DIR_ENTRIES = 224
|
||||
TOTAL_SECTORS = 2880
|
||||
SECTORS_PER_TRACK = 18
|
||||
end if
|
||||
|
||||
; Boot Record
|
||||
OEM_identifier db 'STUPID '
|
||||
bytes_per_sector dw 512
|
||||
sectors_per_cluster db 1
|
||||
sectors_per_cluster db SECTORS_PER_CLUSTER
|
||||
reserved_sectors dw 1
|
||||
FAT_count db 2
|
||||
root_dir_entries dw 224
|
||||
total_sectors dw 2880
|
||||
root_dir_entries dw ROOT_DIR_ENTRIES
|
||||
total_sectors dw TOTAL_SECTORS
|
||||
media_desc_type db 0xF0
|
||||
sectors_per_FAT dw 9
|
||||
sectors_per_track dw 18
|
||||
sectors_per_track dw SECTORS_PER_TRACK
|
||||
heads_per_cylinder dw 2
|
||||
hidden_sectors dd 0
|
||||
large_sector_count dd 0
|
||||
|
||||
; Extended Boot Record
|
||||
drive_number db 0x0
|
||||
reserved db 0x0
|
||||
drive_number db 0
|
||||
reserved db 0
|
||||
signature db 0x29 ; 0x28 or 0x29
|
||||
volume_id dd 0xB00B135 ; hope mine will grow :'(
|
||||
volume_label db 'Stupid Boot'
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
;;
|
||||
;; Parameters:
|
||||
;;
|
||||
;; si - null-terminated string to print
|
||||
;; SI - null-terminated string to print
|
||||
;;
|
||||
bios_print:
|
||||
lodsb
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
;; File: fat12.inc
|
||||
|
||||
ATTR_READ_ONLY = 0x01
|
||||
ATTR_HIDDEN = 0x02
|
||||
ATTR_SYSTEM = 0x04
|
||||
|
@ -20,22 +22,20 @@
|
|||
.start dw ?
|
||||
.size dd ?
|
||||
}
|
||||
|
||||
virtual at di
|
||||
|
||||
fat_entry fat_entry
|
||||
end virtual
|
||||
|
||||
defn fat_entry
|
||||
|
||||
; CHS to LBA
|
||||
; LBA = (C * HPC + H) * SPT + (S - 1)
|
||||
|
||||
;;; Read sectors from disk to buffer
|
||||
;;;
|
||||
;;; @param AX LBA starting sector
|
||||
;;; @param CX sector count
|
||||
;;; @param ES:BX buffer
|
||||
;;;
|
||||
;; Function: disk_read_sectors
|
||||
;; Read sectors from disk to buffer
|
||||
;;
|
||||
;; Parameters:
|
||||
;;
|
||||
;; AX - LBA starting sector
|
||||
;; CX - sector count
|
||||
;; ES:BX - buffer
|
||||
;;
|
||||
disk_read_sectors:
|
||||
; https://en.wikipedia.org/wiki/Logical_block_addressing
|
||||
; convert LBA to CHS
|
||||
|
@ -84,6 +84,7 @@ C dw 0x00
|
|||
H dw 0x00
|
||||
S dw 0x00
|
||||
|
||||
;; Function: fat_load_root
|
||||
fat_load_root:
|
||||
mov ax, DISK_BUFFER/0x10
|
||||
mov es, ax
|
||||
|
@ -114,7 +115,12 @@ fat_load_root:
|
|||
|
||||
ret
|
||||
|
||||
;; @param SI filename to search
|
||||
;; Function: fat_search_root
|
||||
;;
|
||||
;; Parameters:
|
||||
;;
|
||||
;; SI - file to search
|
||||
;;
|
||||
fat_search_root:
|
||||
mov cx, [root_dir_entries]
|
||||
mov di, 0x0
|
||||
|
@ -134,12 +140,15 @@ fat_search_root:
|
|||
stc
|
||||
ret
|
||||
.file_found:
|
||||
mov ax, [es:fat_entry.start]
|
||||
mov ax, [es:di + fat_entry.start]
|
||||
clc
|
||||
ret
|
||||
|
||||
;;; @param AX cluster
|
||||
;;; @param ES:BX buffer
|
||||
;; Function: fat_load_binary
|
||||
;;
|
||||
;; Parameters:
|
||||
;; AX - cluster
|
||||
;; ES:BX - buffer
|
||||
fat_load_binary:
|
||||
push ax
|
||||
sub ax, 0x2
|
||||
|
|
|
@ -20,7 +20,7 @@ Timestamp: Updated yyyy/mm/dd
|
|||
# These are indexes you deleted, so Natural Docs will not add them again
|
||||
# unless you remove them from this line.
|
||||
|
||||
Don't Index: Macros, Variables, Classes
|
||||
Don't Index: Variables, Macros, Classes
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
|
@ -65,6 +65,7 @@ Group: BootLoader {
|
|||
Group: Common {
|
||||
|
||||
File: bios.inc (boot/common/bios.inc)
|
||||
File: fat12.inc (boot/common/fat12.inc)
|
||||
} # Group: Common
|
||||
|
||||
Group: EFI {
|
||||
|
|
Loading…
Reference in a new issue