Custom OS from scratch in C.
Find a file
2025-04-17 22:31:11 -07:00
isodir/boot/grub Branch sync and push, reformated and made the OS look more "official" 2025-04-17 21:32:48 -07:00
kernel requires -Iinclude flag 2025-04-17 22:31:11 -07:00
LICENSE Initial commit 2025-04-14 12:59:37 -07:00
README.md Branch sync and push, reformated and made the OS look more "official" 2025-04-17 21:32:48 -07:00

cowos

Custom OS from scratch in C

Notes

This only supports 32bit for now, please DO NOT compile with 64bit or it'll fail to boot

compilation of any component

You are required to get your own cross C compiler. This is because normal C compilers for your Linux distro (assuming that you are on Linux) will optimize against your own libs and other things. This OS doesn't exist yet, so this is a big no no in OS development. Another thing is that you want to compile for 32 bit, so you'll need to cross compile anyways...

general c files

i386-elf-gcc -c kernel.c -o kernel.o -std=c99 -ffreestanding -O2 -Wall -Wextra # i386 is the 32 bit version of x86
# also please compile with the -Iinclude flag to include the libraries like string.h in the arch

"compiling" the "boot stub"

i386-elf-as boot.s -o boot.o

linking the "compiled" boot stub w/compiled kernel img

i386-elf-gcc -T linker.ld -o cowos.bin -ffreestanding -O2 -nostdlib boot.o kernel.o

Getting it bootable

You'll need grub and mtools. First move the compiled cowos.bin to isodir/boot. Then run the following command:

grub-mkrescue isodir/ -o cowos.iso

Now you can enjoy running this in qemu lol.