diff --git a/kernel.ld b/kernel.ld index d545dda..1bbf63e 100644 --- a/kernel.ld +++ b/kernel.ld @@ -23,7 +23,7 @@ SECTIONS { } . = ALIGN(4); - . += 128 * 1024 /* 128KB */ + . += 128 * 1024; /* 128KB */ __stack_top = .; } diff --git a/run.sh b/run.sh index c7d2d0e..ad42e23 100755 --- a/run.sh +++ b/run.sh @@ -4,4 +4,14 @@ set -xue # QEMU path QEMU=qemu-system-riscv32 -$QEMU -machine virt -bios default -nographic -serial mon:stdio --no-reboot +# Path to clang and compiler flags +CC=clang +CFLAGS="-std=c11 -O2 -g3 -Wall -Wextra --target=riscv32-unknown-elf -fno-stack-protector -ffreestanding -nostdlib" + +# Build the kernel +$CC $CFLAGS -Wl,-Tkernel.ld -Wl,-Map=kernel.map -o kernel.elf \ + kernel.c + +# Start QEMU +$QEMU -machine virt -bios default -nographic -serial mon:stdio --no-reboot \ + -kernel kernel.elf