lesson 13, first kernel

This commit is contained in:
Carlos Fenollosa
2014-10-15 19:00:21 +02:00
parent 14f51e8246
commit 2f1378d7a3
7 changed files with 180 additions and 1 deletions

View File

@@ -0,0 +1,32 @@
# $@ = target file
# $< = first dependency
# $^ = all dependencies
# First rule is the one executed when no paramaters are fed to the Makefile
all: run
# Notice how dependencies are built as needed
kernel.bin: kernel_entry.o kernel.o
i386-elf-ld -o $@ -Ttext 0x1000 $^ --oformat binary
kernel_entry.o: kernel_entry.asm
nasm $< -f elf -o $@
kernel.o: kernel.c
i386-elf-gcc -ffreestanding -c $< -o $@
# Rule to disassemble the kernel - may be useful to debug
kernel.dis: kernel.bin
ndisasm -b 32 $< > $@
bootsect.bin: bootsect.asm
nasm $< -f bin -o $@
os-image.bin: bootsect.bin kernel.bin
cat $^ > os-image.bin
run: os-image.bin
qemu-system-i386 -fda $<
clean:
rm *.bin *.o *.dis