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