From 1a9201b529dd2f5d650817aa91e4e3e7aab627b3 Mon Sep 17 00:00:00 2001 From: Jarkko Toivanen Date: Sun, 18 Jun 2023 05:37:30 +0300 Subject: [PATCH] Code organizing --- .gitignore | 3 ++- Makefile | 30 ++++++++++++------------------ kernel.c => src/kernel.c | 0 multiboot.h => src/multiboot.h | 0 serial.c => src/serial.c | 0 serial.h => src/serial.h | 0 start32.asm => src/start32.asm | 0 vga.c => src/vga.c | 0 vga.h => src/vga.h | 0 xtoa.c => src/xtoa.c | 0 xtoa.h => src/xtoa.h | 0 11 files changed, 14 insertions(+), 19 deletions(-) rename kernel.c => src/kernel.c (100%) rename multiboot.h => src/multiboot.h (100%) rename serial.c => src/serial.c (100%) rename serial.h => src/serial.h (100%) rename start32.asm => src/start32.asm (100%) rename vga.c => src/vga.c (100%) rename vga.h => src/vga.h (100%) rename xtoa.c => src/xtoa.c (100%) rename xtoa.h => src/xtoa.h (100%) diff --git a/.gitignore b/.gitignore index 7033f9b..bc70311 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.elf *.o *.img -mnt/ \ No newline at end of file +mnt/ +build/ diff --git a/Makefile b/Makefile index 3628d5d..bf5ae48 100644 --- a/Makefile +++ b/Makefile @@ -1,24 +1,16 @@ -all: kernel-i386.elf +all: build/kernel-i386.elf clean: - -@rm *.o *.elf 2> /dev/null || true + -@rm build/*.o build/*.elf 2> /dev/null || true -start32.o: start32.asm - fasm start32.asm -kernel.o: kernel.c - tcc -m32 -c kernel.c -vga.o: vga.c - tcc -m32 -c vga.c -serial.o: serial.c - tcc -m32 -c serial.c -xtoa.o: xtoa.c - tcc -m32 -c xtoa.c -kernel-i386.elf: kernel.o start32.o vga.o serial.o xtoa.o - tcc -m32 -nostdlib -Wl,-Ttext,0x100000 start32.o kernel.o vga.o serial.o xtoa.o -o kernel-i386.elf +build/start32.o: build/ src/start32.asm + fasm src/start32.asm build/start32.o +build/kernel-i386.elf: build/start32.o + tcc -m32 -nostdlib -Wl,-Ttext,0x100000 -o build/kernel-i386.elf src/*.c build/start32.o -qemu-multiboot: kernel-i386.elf - qemu-system-i386 -kernel kernel-i386.elf -serial stdio -qemu-image: kernel-i386.elf mount - cp kernel-i386.elf mnt/ +qemu-multiboot: build/kernel-i386.elf + qemu-system-i386 -kernel build/kernel-i386.elf -serial stdio +qemu-image: build/kernel-i386.elf mount + cp build/kernel-i386.elf mnt/ sync qemu-system-i386 koalemos.img -serial stdio @@ -30,3 +22,5 @@ umount: @sudo umount mnt mnt/: @mkdir mnt +build/: + @mkdir build diff --git a/kernel.c b/src/kernel.c similarity index 100% rename from kernel.c rename to src/kernel.c diff --git a/multiboot.h b/src/multiboot.h similarity index 100% rename from multiboot.h rename to src/multiboot.h diff --git a/serial.c b/src/serial.c similarity index 100% rename from serial.c rename to src/serial.c diff --git a/serial.h b/src/serial.h similarity index 100% rename from serial.h rename to src/serial.h diff --git a/start32.asm b/src/start32.asm similarity index 100% rename from start32.asm rename to src/start32.asm diff --git a/vga.c b/src/vga.c similarity index 100% rename from vga.c rename to src/vga.c diff --git a/vga.h b/src/vga.h similarity index 100% rename from vga.h rename to src/vga.h diff --git a/xtoa.c b/src/xtoa.c similarity index 100% rename from xtoa.c rename to src/xtoa.c diff --git a/xtoa.h b/src/xtoa.h similarity index 100% rename from xtoa.h rename to src/xtoa.h