summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile78
-rw-r--r--Makefile.common1
-rw-r--r--asm/NOTES2
-rw-r--r--asm/kernel_entry.asm (renamed from boot2/kernel_entry.asm)0
4 files changed, 52 insertions, 29 deletions
diff --git a/Makefile b/Makefile
index 090e85f..123fa77 100644
--- a/Makefile
+++ b/Makefile
@@ -1,10 +1,14 @@
+
+
#####################
# #
# FoolOS Build Sys. #
# #
#####################
+
+
############ some constants ############
#take care to set this properly!
@@ -28,7 +32,9 @@ CFLAGS+=-Werror-implicit-function-declaration
#CFLAGS+=-fdata-sections -ffunction-sections
#CFLAGS+= -Werror
-############ source and object files ############
+
+
+############ source and object files and their deps ############
#kernel sources (asm and c)
SOURCES=
@@ -37,25 +43,35 @@ SOURCES+=$(wildcard ./video/*.c)
SOURCES+=$(wildcard ./lib/*/*.c)
SOURCES+=$(wildcard ./fs/*.c)
-ASMSOURCES=$(wildcard ./asm/*.asm)
-
-#kernel object files
+#derive kernel object files
OBJECTS=$(patsubst %.c, %.o, $(SOURCES))
-ASMOBJECTS=$(patsubst %.asm, %.o, $(ASMSOURCES))
-KERNEL_ENTRY=./boot2/kernel_entry.o
-# deps
+#derive deps
DEPS=$(patsubst %.c, %.d, $(SOURCES))
-############ final image (default target) ############
-all: FoolOS.vdi
+
+####### ASM STUFF #####
+
+ASM_SOURCES=$(wildcard ./asm/*.asm)
+ASM_OBJECTS=$(patsubst %.asm, %.o, $(ASM_SOURCES))
+KERNEL_ENTRY=./asm/kernel_entry.o
+
+
+
+############ Final Targets ############
+
+all: FoolOS.vdi FoolOS.img
new: clean all
-newrun: clean run
+
+
+########### INCLUDES ###################3
include Makefile.common
-include $(DEPS)
+
+
######### RECURSIVE MAKES ########################
# master boot record
@@ -83,33 +99,37 @@ USERSPACE=./userspace/ext2.img
$(USERSPACE):
make -C userspace ext2.img
+
+
############ linking kernel binary ############
+# the kernel_entry.o needs to be FIRST!!
+kernel.bin: $(KERNEL_ENTRY) $(ASM_OBJECTS) $(OBJECTS)
+ $(CC) $(CFLAGS) -o $@ -Wl,-Ttext,$(KERNEL_START),--oformat,binary $^
+
+
+
+######## generate empty image ~25MB ###############
+
FILLUP=fill.img
$(FILLUP):
dd if=/dev/zero of=$(FILLUP) bs=512 count=50000
-# the kernel_entry.o needs to be FIRST!!
-kernel.bin: $(KERNEL_ENTRY) $(ASMOBJECTS) $(OBJECTS)
- $(CC) $(CFLAGS) -o $@ -Wl,-Ttext,$(KERNEL_START),--oformat,binary $^
-
############ assembling of final image ############
# master boot record, kernel binary and fool-font
-
-FoolOS.img: $(MBR) $(STAGE2) kernel.bin $(FILLUP) FoolData.img
+FoolOS.img: $(MBR) $(STAGE2) kernel.bin $(FILLUP) $(FOOLFONT) $(MP_BIN) $(USERSPACE)
cp $(FILLUP) $@
dd if=$(MBR) of=$@ bs=512 seek=0 conv=notrunc
dd if=$(STAGE2) of=$@ bs=512 seek=1 conv=notrunc
dd if=kernel.bin of=$@ bs=512 seek=10 conv=notrunc #will end up at 0x100000 in ram (this is what the booloader starts loading secotr: 10)
- dd if=FoolData.img of=$@ bs=512 seek=842 conv=notrunc #data starts at 0x168000
+ #data starts at 0x168000
+ dd if=$(MP_BIN) of=$@ bs=512 seek=842 conv=notrunc
+ dd if=$(FOOLFONT) of=$@ bs=512 seek=843 conv=notrunc
+ dd if=$(USERSPACE) of=$@ bs=512 seek=846 conv=notrunc #will end up at 0x80800 in ram
-FoolData.img: $(FOOLFONT) $(MP_BIN) $(USERSPACE)
- dd if=$(MP_BIN) of=$@ bs=512 seek=0 conv=notrunc
- dd if=$(FOOLFONT) of=$@ bs=512 seek=1 conv=notrunc
- dd if=$(USERSPACE) of=$@ bs=512 seek=4 conv=notrunc #will end up at 0x80800 in ram
############ virtual machines stuff ############
@@ -123,25 +143,25 @@ FoolOS.vdi: FoolOS.img
run: all
~/opt/bochs-2.6.6/bochs -q -f bochs/bochsrc -rc bochs/bochsdebug
+newrun: clean run
+
+
############ create bootable usb image ############
stick: FoolOS.img
cat FoolOS.img > $(USB_STICK) && sync
xxd $(USB_STICK) | head -n 50
+
+
############ cleanup ############
-clean_release:
- -rm *.bin FoolData.img bochs.log $(KERNEL_ENTRY) $(ASMOBJECTS) $(OBJECTS) $(FILLUP) $(MBR) $(MP_BIN) bochs.out ne2k-tx.log ne2k-txdump.txt $(STAGE2) $(DEPS)
+clean:
+ -rm *.bin FoolData.img bochs.log $(KERNEL_ENTRY) $(ASMOBJECTS) $(OBJECTS) $(FILLUP) $(MBR) $(MP_BIN) bochs.out ne2k-tx.log ne2k-txdump.txt $(STAGE2) $(DEPS) $(ASM_OBJECTS)
+ -rm FoolOS.img FoolOS.vdi
make -C boot1 clean
make -C boot2 clean
make -C userspace clean
make -C font clean
-clean: clean_release
- -rm FoolOS.img FoolOS.vdi
-
-release: new
- -mv FoolOS.img release/
- make clean_release
diff --git a/Makefile.common b/Makefile.common
index 304356b..4cd411d 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -1,3 +1,4 @@
+### implicit rules ###
%.o: %.asm
nasm -f elf $*.asm -o $@
diff --git a/asm/NOTES b/asm/NOTES
new file mode 100644
index 0000000..23e7ebf
--- /dev/null
+++ b/asm/NOTES
@@ -0,0 +1,2 @@
+files in this directory should not depend on any other files.
+Also this is not supported by the build-system by now.
diff --git a/boot2/kernel_entry.asm b/asm/kernel_entry.asm
index 53f63ad..53f63ad 100644
--- a/boot2/kernel_entry.asm
+++ b/asm/kernel_entry.asm