summaryrefslogtreecommitdiff
path: root/src/Makefile
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-05-11 22:10:07 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2017-05-11 22:10:07 +0200
commit30596991abc9e452fbad8372f1ddcce12b87ce72 (patch)
tree0268ad64556032ce19cddd43d3629e2bc1ea61db /src/Makefile
parent356f485c9cb5f5aa94e39ad25e9e0345682db722 (diff)
downloadabaos-30596991abc9e452fbad8372f1ddcce12b87ce72.tar.gz
abaos-30596991abc9e452fbad8372f1ddcce12b87ce72.tar.bz2
better documentation for the boot loading process and how much
sectors each part needs, fixed truncation problem started a magic signature at the end of the image and started to check it in stage 2 of the boot loader to avoid truncated images in the future
Diffstat (limited to 'src/Makefile')
-rw-r--r--src/Makefile37
1 files changed, 27 insertions, 10 deletions
diff --git a/src/Makefile b/src/Makefile
index c983fb6..4e0755a 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -4,30 +4,47 @@ LD := ld
all: image.bin
-image.bin: boot.bin kernel.bin
- cat boot.bin kernel.bin > image.bin
+image.bin: boot.bin kernel.bin magic.bin
+ cat boot.bin kernel.bin > image.tmp
# truncate to correct number of sectors, we have
- # 512 (boot, first stage) + N * 512 (N currenty is 3) + M * 512 (M is currently 3)
- truncate -s 4096 image.bin
+ # 512 (boot, stage 1) + N * 512 (N currenty is 3, stage 2) = 2048 for boot.bin
+ # + M * 512 (M is currently 7) = 3144 for kernel.bin
+ # + 1 * 512 = 512 for magic.bin
+ # (M + N + 1 is the number of sectors to be read in stage 2, as stage 1
+ # loads only the first sector, so adapt NOF_LOAD_SECTORS to 10)
+ truncate -s 5632 image.tmp
+ cat image.tmp magic.bin > image.bin
boot.bin: boot.asm gdt.asm stage1_functions.asm stage2_functions.asm switch_mode.asm
nasm boot.asm -f bin -o boot.bin
-kernel.bin: kernel.o vga.o string.o
+kernel.bin: kernel.o vga.o port.o port_asm.o string.o stdlib.o
$(LD) -o kernel.bin -n -Ttext 0x8000 --oformat binary \
- kernel.o vga.o string.o
+ kernel.o vga.o port.o port_asm.o string.o stdlib.o
+magic.bin: magic.asm
+ nasm magic.asm -f bin -o magic.bin
+
kernel.o: kernel.c
- $(CC) $(CFLAGS) -O0 -c -o kernel.o kernel.c
+ $(CC) $(CFLAGS) -c -o kernel.o kernel.c
+
+port.o: port.c
+ $(CC) $(CFLAGS) -c -o port.o port.c
vga.o: vga.c
- $(CC) $(CFLAGS) -O0 -c -o vga.o vga.c
+ $(CC) $(CFLAGS) -c -o vga.o vga.c
+
+port_asm.o: port.asm
+ nasm port.asm -f elf32 -o port_asm.o
string.o: string.c
- $(CC) $(CFLAGS) -O0 -c -o string.o string.c
+ $(CC) $(CFLAGS) -c -o string.o string.c
+
+stdlib.o: stdlib.c
+ $(CC) $(CFLAGS) -c -o stdlib.o stdlib.c
clean:
- -rm -f boot.bin kernel.bin image.bin *.o
+ -rm -f boot.bin kernel.bin image.bin magic.bin *.o
run-qemu: image.bin
qemu-system-i386 -m 32 -drive "file=image.bin,if=ide,format=raw"