diff --git a/Makefile b/Makefile index bad4f80..29fe117 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,39 @@ all: iso iso: kernel limine + @echo "Copying kernel to isodir..." cp -v ./kernel/bin/cowos ./isodir/boot/ - + @echo "Creating ISO image..." xorriso -as mkisofs -R -r -J -b boot/limine/limine-bios-cd.bin \ - -no-emul-boot -boot-load-size 4 -boot-info-table -hfsplus \ - -apm-block-size 2048 --efi-boot boot/limine/limine-uefi-cd.bin \ - -efi-boot-part --efi-boot-image --protective-msdos-label \ - isodir -o cowos.iso - + -no-emul-boot -boot-load-size 4 -boot-info-table -hfsplus \ + -apm-block-size 2048 --efi-boot boot/limine/limine-uefi-cd.bin \ + -efi-boot-part --efi-boot-image --protective-msdos-label \ + isodir -o cowos.iso + @echo "Installing Limine BIOS..." ./limine/limine bios-install cowos.iso kernel: - make -C ./kernel/ all + @echo "Buliding kernel..." + make -C ./kernel/ limine: kernel + @echo "Setting up Limine..." ./scripts/limine-git.sh clean: + @echo "Cleaning up..." rm cowos.iso make -C ./kernel/ clean + +run: + @echo "Running cowos in QEMU..." + @if [ "$(DEBUG)" = "1" ]; then \ + echo "Debug mode: Starting QEMU with LLDB..."; \ + qemu-system-x86_64 -cdrom cowos.iso -m 512M -serial stdio -s -S & \ + echo "Launching LLDB..."; \ + lldb --arch x86_64 -o "gdb-remote localhost:1234" ./kernel/bin/cowos; \ + else \ + qemu-system-x86_64 -cdrom cowos.iso -m 512M -serial stdio; \ + fi + +.PHONY: all iso kernel limine clean run diff --git a/README.md b/README.md index 534f335..dc5061c 100644 --- a/README.md +++ b/README.md @@ -15,13 +15,41 @@ You'll need a few things: - xorriso (iso creation) - git - make + +### OPTIONAL: - qemu (for virtual machine) +- LLDB (debugging purposes) After acquiring those just run make and it'll do everything for you: ```bash make ``` +By default the kernel is compiled with debug symbols, if you would like to avoid this, you can simply override the CFLAGS: +```bash +cd kernel/ # it is recommended to go to the actual directory yourself +make CFLAGS="-s -O3 -pipe" +cd .. # return to root +make +``` +Eventually in the future this will be changed to be something much more convienent, however for now the inclusion of debug symbols is nessacary for development. + +## RUNNING +There is now a script to automate running cowos, although it's quite simple right now, this is important for the future as cowos will eventually require a root partition and other things as it grows to userspace slowly. To run, simply run this in the root of the repository: +```bash +make run # This will require qemu +``` + +For developers, running with the DEBUG flag will launch lldb with qemu to help debug issues with cowos: +```bash +make DEBUG=1 run +``` +if you do not like LLDB, I included a script called `run-gdb` in the `scripts/` directory for the gdb fans out there. I personally want to keep this project as gnu-free as possible, since I want cowos to not be GNU/cowos, I want it to just be cowos. And this means that I will even avoid anything as simple as the debugger being used to be non-GNU. Run in the root like so: +```bash +./scripts/run-gdb +``` +It will automatically exit qemu if gdb is exited, and by default gdb will run in tui mode. + # Credits - [Limine](https://github.com/limine-bootloader/limine): modern, advanced, portable, multiprotocol bootloader and boot manager. diff --git a/kernel/drivers/video/framebuffer.o b/kernel/drivers/video/framebuffer.o new file mode 100644 index 0000000..93e1be0 Binary files /dev/null and b/kernel/drivers/video/framebuffer.o differ diff --git a/kernel/drivers/video/vga.o b/kernel/drivers/video/vga.o new file mode 100644 index 0000000..5565817 Binary files /dev/null and b/kernel/drivers/video/vga.o differ diff --git a/kernel/init/kernel.o b/kernel/init/kernel.o new file mode 100644 index 0000000..0029209 Binary files /dev/null and b/kernel/init/kernel.o differ diff --git a/kernel/klibc/stdio.o b/kernel/klibc/stdio.o new file mode 100644 index 0000000..7cac39c Binary files /dev/null and b/kernel/klibc/stdio.o differ diff --git a/kernel/klibc/string.o b/kernel/klibc/string.o new file mode 100644 index 0000000..fae87dc Binary files /dev/null and b/kernel/klibc/string.o differ diff --git a/kernel/x86/gdt.o b/kernel/x86/gdt.o new file mode 100644 index 0000000..206a409 Binary files /dev/null and b/kernel/x86/gdt.o differ diff --git a/scripts/limine-git.sh b/scripts/limine-git.sh index 6bc1771..8e7a18e 100755 --- a/scripts/limine-git.sh +++ b/scripts/limine-git.sh @@ -11,4 +11,8 @@ if [ ! -d ./limine/ ]; then cp -v limine/BOOTX64.EFI isodir/EFI/BOOT/ cp -v limine/BOOTIA32.EFI isodir/EFI/BOOT/ +else + echo "Limine is already setup! Skipping..." fi + + diff --git a/scripts/run-gdb b/scripts/run-gdb new file mode 100755 index 0000000..17610f1 --- /dev/null +++ b/scripts/run-gdb @@ -0,0 +1,21 @@ +#!/bin/sh + +echo "Starting QEMU with GDB server (localhost:1234)..." +qemu-system-x86_64 -cdrom cowos.iso -m 512M -serial stdio -s -S & +QEMU_PID=$! + +sleep 1 # just in case so we let it cook + +if ! ps -p $QEMU_PID > /dev/null; then + echo "Error: QEMU failed to start." + exit 1 +fi + +echo "Launching GDB in TUI mode..." +gdb --tui \ + -ex "file ./kernel/bin/cowos" \ + -ex "target remote localhost:1234" \ + +# kill QEMU when GDB exits +echo "GDB exited. Terminating QEMU..." +kill $QEMU_PID 2>/dev/null