Skip to content

Commit

Permalink
feat(bootload): load next stage and preload kernel from FAT
Browse files Browse the repository at this point in the history
  • Loading branch information
d0p1s4m4 committed Feb 8, 2024
1 parent d94d9fb commit 7f88017
Show file tree
Hide file tree
Showing 10 changed files with 590 additions and 363 deletions.
80 changes: 42 additions & 38 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,39 +1,43 @@
TOPDIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
SYSROOTDIR := $(TOPDIR)/sysroot
TOOLSDIR := $(TOPDIR)/tools

RM = echo

SUBDIRS := boot kernel lib bin

TARGET = stupid.tar.gz floppy_boot.img
ifneq ($(OS),Windows_NT)
TARGET += stupid.iso
endif

.PHONY: all
all: $(TARGET)

GOAL:=install
clean: GOAL:=clean

.PHONY: $(SUBDIRS)
$(SUBDIRS):
@echo "📁 $@"
DESTDIR=$(SYSROOTDIR) $(MAKE) -C $@ $(GOAL)

.PHONY: stupid.iso
stupid.iso: $(SUBDIRS)
$(TOPDIR)/tools/create-iso $@ sysroot

.PHONY: stupid.tar.gz
stupid.tar.gz: $(SUBDIRS)
tar -czvf $@ sysroot

.PHONY: floppy_boot.img
floppy_boot.img:
@ echo

.PHONY: clean
clean: $(SUBDIRS)
TOPDIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
SYSROOTDIR := $(TOPDIR)/sysroot
TOOLSDIR := $(TOPDIR)/tools

RM = echo

SUBDIRS := boot kernel lib bin

TARGET = stupid.tar.gz floppy_boot.img
ifneq ($(OS),Windows_NT)
TARGET += stupid.iso
endif

.PHONY: all
all: $(TARGET)

GOAL:=install
clean: GOAL:=clean

.PHONY: $(SUBDIRS)
$(SUBDIRS):
@echo "📁 $@"
DESTDIR=$(SYSROOTDIR) $(MAKE) -C $@ $(GOAL)

.PHONY: stupid.iso
stupid.iso: $(SUBDIRS)
$(TOPDIR)/tools/create-iso $@ sysroot

.PHONY: stupid.tar.gz
stupid.tar.gz: $(SUBDIRS)
tar -czvf $@ sysroot

.PHONY: floppy_boot.img
floppy_boot.img:
dd if=/dev/zero of=$@ bs=512 count=1440
mformat -C -f 1440 -i $@
dd if=boot/bootsector.bin of=$@ conv=notrunc
mcopy -i $@ boot/stpdboot.sys ::/STPDBOOT.SYS
mcopy -i $@ kernel/vmstupid ::/VMSTUPID.SYS

.PHONY: clean
clean: $(SUBDIRS)
$(RM) $(TARGET) $(SYSROOTDIR)
51 changes: 29 additions & 22 deletions boot/Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
AS = fasm
RM = rm

TARGET = bootcode.bin

SRCS = boot.asm \
const.inc \
a20.inc

.PHONY: all
all: $(TARGET)

$(TARGET): $(SRCS)
$(AS) boot.asm $@

.PHONY: clean
clean:
$(RM) $(TARGET)

.PHONY: install
install: $(TARGET)
@ mkdir -p $(DESTDIR)
AS = fasm
RM = rm

TARGET = bootsector.bin stpdboot.sys

STAGE0_SRCS = boot0.asm \
const.inc \
fat12.inc

STAGE1_SRCS = boot1.asm \
const.inc \
a20.inc

.PHONY: all
all: $(TARGET)

bootsector.bin: $(STAGE0_SRCS)
$(AS) boot0.asm $@

stpdboot.sys: $(STAGE1_SRCS)
$(AS) boot1.asm $@

.PHONY: clean
clean:
$(RM) $(TARGET)

.PHONY: install
install: $(TARGET)
@ mkdir -p $(DESTDIR)
2 changes: 2 additions & 0 deletions boot/README.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#+TITLE: StupidOS Bootloader

Loading

0 comments on commit 7f88017

Please sign in to comment.