Files
kern/build.sh
T
Tom-on 90ac82eebc Project restructure (no new code added)
Moved all header files into include/ and removed their C counterparts -> code inside .h files
Also added a kernel.ld linker file
since we don't have many code files in src/ now, i removed src/kernel/
only real code change is that i moved memcopy() and memset() into string.h from system.h
2024-04-14 18:27:53 +02:00

34 lines
851 B
Bash

#!/bin/bash
[[ -d ./build ]] || mkdir build
rm -rf ./build/**
# Bootloader
echo "Assembling ./src/boot.asm..."
nasm -fbin ./src/boot.asm -o ./build/boot.bin
# Kernel
echo "Assembling ./src/entry.asm..."
nasm -felf32 ./src/entry.asm -o ./build/entry.o
for file in ./src/*.c; do
filename=$(basename "$file" .c)
echo "Compiling $file..."
i386-elf-gcc -ffreestanding -Wall -Wextra -m32 -Iinclude -c "$file" -o "./build/$filename.o"
done
i386-elf-ld -o ./build/kernel.bin -Tkernel.ld --oformat binary ./build/*.o
# OS Image
echo "Creating kern.iso disk image..."
cat build/boot.bin build/kernel.bin > build/os.bin
dd if=/dev/zero of=./kern.iso bs=512 count=2880
dd if=./build/os.bin of=./kern.iso conv=notrunc
echo -e "\nDone!\n"
# Run QEMU
qemu-system-x86_64 -drive format=raw,file="./kern.iso",index=0,media=disk -m 256M -accel tcg