diff --git a/.gitignore b/.gitignore index 20c4ba4..9e24fba 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,3 @@ obj/ bin/ -iso_root/ -image.iso -image.hdd -limine/ \ No newline at end of file +iso_root/ \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..6ff1c0d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "vendor/limine"] + path = vendor/limine + url = https://github.com/limine-bootloader/limine.git + branch = v6.x-branch-binary diff --git a/GNUmakefile b/GNUmakefile index c3f5eb7..8c1304e 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -65,7 +65,7 @@ override CPPFLAGS := \ $(CPPFLAGS) \ -MMD \ -MP - + # Internal linker flags that should not be changed by the user. override LDFLAGS += \ -m elf_x86_64 \ @@ -81,7 +81,7 @@ override LDFLAGS += \ override NASMFLAGS += \ -Wall \ -f elf64 - + # Use "find" to glob all *.c, *.S, and *.asm files in the tree and obtain the # object and header dependency file names. override CFILES := $(shell cd src && find -L * -type f -name '*.c') @@ -89,13 +89,13 @@ override ASFILES := $(shell cd src && find -L * -type f -name '*.S') override NASMFILES := $(shell cd src && find -L * -type f -name '*.asm') override OBJ := $(addprefix obj/,$(CFILES:.c=.c.o) $(ASFILES:.S=.S.o) $(NASMFILES:.asm=.asm.o)) override HEADER_DEPS := $(addprefix obj/,$(CFILES:.c=.c.d) $(ASFILES:.S=.S.d)) - + # Default target. .PHONY: all all: bin/$(KERNEL) iso hdd - + # Link rules for the final kernel executable. -bin/$(KERNEL): GNUmakefile linker.ld $(OBJ) +bin/$(KERNEL): submodules GNUmakefile linker.ld $(OBJ) mkdir -p "$$(dirname $@)" $(LD) $(OBJ) $(LDFLAGS) -o $@ @@ -120,25 +120,29 @@ obj/%.asm.o: src/%.asm GNUmakefile # Remove object files and the final executable. .PHONY: clean clean: - rm -rf bin obj iso_root image.iso image.hdd limine + rm -rf bin obj iso_root vendor/* + +# Initialize and update git submodules. +.PHONY: submodules +submodules: + git submodule update --init --recursive + +# The `limine` target builds the Limine bootloader. +.PHONY: limine +limine: submodules + $(MAKE) -C vendor/limine # The `iso` target builds the bootable ISO image using Limine. .PHONY: iso -iso: bin/$(KERNEL) - # Clone the Limine repository - git clone https://github.com/limine-bootloader/limine.git --branch=v6.x-branch-binary --depth=1 - - # Build the Limine bootloader binaries. - $(MAKE) -C limine - +iso: bin/$(KERNEL) limine # Create the iso_root directory and copy relevant files. mkdir -p iso_root - cp -v bin/$(KERNEL) limine.cfg limine/limine-bios.sys limine/limine-bios-cd.bin limine/limine-uefi-cd.bin iso_root/ + cp -v bin/$(KERNEL) limine.cfg vendor/limine/limine-bios.sys vendor/limine/limine-bios-cd.bin vendor/limine/limine-uefi-cd.bin iso_root/ # Create the EFI boot directory and copy EFI executables. mkdir -p iso_root/EFI/BOOT - cp -v limine/BOOTX64.EFI iso_root/EFI/BOOT/ - cp -v limine/BOOTIA32.EFI iso_root/EFI/BOOT/ + cp -v vendor/limine/BOOTX64.EFI iso_root/EFI/BOOT/ + cp -v vendor/limine/BOOTIA32.EFI iso_root/EFI/BOOT/ # Create the bootable ISO. xorriso -as mkisofs -b limine-bios-cd.bin -no-emul-boot \ @@ -147,7 +151,7 @@ iso: bin/$(KERNEL) iso_root -o image.iso # Install Limine stage 1 and 2 for legacy BIOS boot. - ./limine/limine bios-install image.iso + ./vendor/limine/limine bios-install image.iso mv image.iso bin/$(KERNEL).iso @@ -155,23 +159,15 @@ iso: bin/$(KERNEL) # The `hdd` target builds the bootable HDD image using Limine. .PHONY: hdd -hdd: bin/$(KERNEL) +hdd: bin/$(KERNEL) limine # Create empty HDD image file. dd if=/dev/zero bs=1M count=0 seek=64 of=image.hdd # Create GPT partition. sgdisk image.hdd -n 1:2048 -t 1:ef00 - # Clone Limine if it doesn't already exist. - if [ ! -d "limine" ]; then \ - git clone https://github.com/limine-bootloader/limine.git --branch=v6.x-branch-binary --depth=1; \ - fi - - # Build the Limine bootloader binaries, if not already built. - $(MAKE) -C limine - # Install Limine BIOS stages. - ./limine/limine bios-install image.hdd + ./vendor/limine/limine bios-install image.hdd # Format the partition to fat32 filesystem. mformat -i image.hdd@@1M -F :: @@ -180,9 +176,9 @@ hdd: bin/$(KERNEL) mmd -i image.hdd@@1M ::/EFI ::/EFI/BOOT # Copy kernel and Limine config over to the HDD image. - mcopy -i image.hdd@@1M bin/$(KERNEL) limine.cfg limine/limine-bios.sys ::/ - mcopy -i image.hdd@@1M limine/BOOTX64.EFI ::/EFI/BOOT - mcopy -i image.hdd@@1M limine/BOOTIA32.EFI ::/EFI/BOOT + mcopy -i image.hdd@@1M bin/$(KERNEL) limine.cfg vendor/limine/limine-bios.sys ::/ + mcopy -i image.hdd@@1M vendor/limine/BOOTX64.EFI ::/EFI/BOOT + mcopy -i image.hdd@@1M vendor/limine/BOOTIA32.EFI ::/EFI/BOOT mv image.hdd bin/$(KERNEL).hdd diff --git a/src/console/fonts.c b/src/console/fonts.c new file mode 100644 index 0000000..e69de29 diff --git a/src/kernel.c b/src/kernel.c index cb08e64..d2dec58 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -3,6 +3,8 @@ #include #include +#include + // Set the base revision to 1, this is recommended as this is the latest // base revision described by the Limine boot protocol specification. // See specification for further info. @@ -107,6 +109,6 @@ void _start(void) { fb_ptr[i * (framebuffer->pitch / 4) + i] = 0xffffff; } - // We're done, just hang... - hcf(); + // Write to framebuffer + } \ No newline at end of file diff --git a/vendor/limine b/vendor/limine new file mode 160000 index 0000000..1fbee19 --- /dev/null +++ b/vendor/limine @@ -0,0 +1 @@ +Subproject commit 1fbee19c25393a7948039b8ee99cb98daa6684dc