diff options
author | Johannes Stoelp <johannes.stoelp@gmail.com> | 2024-12-23 22:51:52 +0100 |
---|---|---|
committer | Johannes Stoelp <johannes.stoelp@gmail.com> | 2024-12-25 21:25:16 +0100 |
commit | 14845124cf5d4fb42a04cb1262b32bd3d00f45f8 (patch) | |
tree | 13162d26afeb49a9c9b8d9d31049066c0f4b2998 /x86-bare-metal/mbr-palette/Makefile | |
parent | 42b6f9d23ab0f94744a90edb6fd74450f589ca14 (diff) | |
download | zig-playground-14845124cf5d4fb42a04cb1262b32bd3d00f45f8.tar.gz zig-playground-14845124cf5d4fb42a04cb1262b32bd3d00f45f8.zip |
mbr: rm->pm, then jump into zig
Diffstat (limited to 'x86-bare-metal/mbr-palette/Makefile')
-rw-r--r-- | x86-bare-metal/mbr-palette/Makefile | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/x86-bare-metal/mbr-palette/Makefile b/x86-bare-metal/mbr-palette/Makefile new file mode 100644 index 0000000..7642791 --- /dev/null +++ b/x86-bare-metal/mbr-palette/Makefile @@ -0,0 +1,28 @@ +O := BUILD + +$(O)/boot: $(O)/boot.elf | dump_info + objcopy -O binary $< $@ + +$(O)/boot.elf: mbr.ld $(O)/mbr.o $(O)/zmbr.o + ld -o $@ -nostdlib -T $^ + +$(O)/mbr.o: mbr.S | $(O) + gcc -m32 -c -o $@ -ffreestanding mbr.S + +$(O)/zmbr.o: zmbr.zig | $(O) + zig build-obj -femit-bin=$@ -target x86-freestanding-none -O ReleaseSmall $< + +clean: + $(RM) -r $(O) + +$(O): + mkdir -p $(O) + +dump_info: $(O)/boot.elf + objdump -Mintel --disassemble=kmain --visualize-jumps=extended-color $< + readelf -W -l $< + size $< + size $< | awk '/$(notdir $<)/ { print "MBR utilization " $$1/512 "%" }' + +run: $(O)/boot + qemu-system-i386 -hda $< $(QEMU_ARGS) |