Added missing scripts and C kernel

This commit is contained in:
Nocturn9x 2022-11-16 15:37:01 +01:00
parent c06dbb7280
commit 1e7f6dd22e
4 changed files with 29 additions and 0 deletions

5
build.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
i386-elf-gcc -ffreestanding -c src/kernel/main.c -o main.o
nasm -f elf src/entrypoint.s -o entrypoint.o
i386-elf-ld -o kernel.bin -Ttext 0x1000 entrypoint.o main.o --oformat binary
cat mbr.bin kernel.bin > os.bin

6
env.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
export CC=/usr/bin/gcc
export LD=/usr/bin/gcc
export PREFIX="/usr/local/i386elfgcc"
export TARGET=i386-elf
export PATH="$PREFIX/bin:$PATH"

2
run.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
qemu-system-x86_64 -drive format=raw,file=os.bin,index=0,media=disk

16
src/kernel/main.c Normal file
View File

@ -0,0 +1,16 @@
// C entry point of our kernel
#define VMEM_ADDR 0xb8000
void dummy_test_entrypoint(void) {
}
void kmain(void) {
char* vbuf = (char*)VMEM_ADDR;
vbuf += 480; // We skip the log messages before us
char *s = "Hello from the TSOS kernel!";
for (int i = 0; s[i] != '\0'; i++) {
*vbuf = s[i];
vbuf += 2;
}
}