diff --git a/build/build-iso.sh b/build/build-iso.sh index 125d3f8e..af01dd79 100755 --- a/build/build-iso.sh +++ b/build/build-iso.sh @@ -66,7 +66,7 @@ umount_tempdisk echo "Rebuilding kernel headers, kernel, OS, and building Distro ISO ..." $QEMU_BIN_PATH/qemu-system-x86_64 -machine q35 $KVM -drive format=raw,file=$TMPDISK -m 1G -rtc base=localtime -smp 4 -device isa-debug-exit $QEMU_HEADLESS -LIMINE_BINARY_BRANCH="v8.x-binary" +LIMINE_BINARY_BRANCH="v9.x-binary" if [ -d "limine" ] then @@ -116,13 +116,13 @@ sudo mv $TMPMOUNT/Tmp/DVDKernel.ZXE $TMPISODIR/Boot/Kernel.ZXE sudo rm $TMPISODIR/Tmp/DVDKernel.ZXE 2> /dev/null umount_tempdisk -xorriso -joliet "on" -rockridge "on" -as mkisofs -b Boot/Limine-BIOS-CD.BIN \ - -no-emul-boot -boot-load-size 4 -boot-info-table \ - --efi-boot Boot/Limine-UEFI-CD.BIN \ +xorriso -as mkisofs -R -r -J -b Boot/Limine-BIOS-CD.BIN \ + -no-emul-boot -boot-load-size 4 -boot-info-table -hfsplus \ + -apm-block-size 2048 --efi-boot Boot/Limine-UEFI-CD.BIN \ -efi-boot-part --efi-boot-image --protective-msdos-label \ $TMPISODIR -o ZealOS-limine.iso -./limine/limine bios-install ZealOS-limine.iso +./limine/limine bios-install ZealOS-limine.iso --no-gpt-to-mbr-isohybrid-conversion if [ "$TESTING" = true ]; then if [ ! -d "ovmf" ]; then diff --git a/zealbooter/GNUmakefile b/zealbooter/GNUmakefile index 10f5205f..33ab09bc 100644 --- a/zealbooter/GNUmakefile +++ b/zealbooter/GNUmakefile @@ -6,45 +6,41 @@ MAKEFLAGS += -rR # Change as needed. override OUTPUT := kernel -# Convenience macro to reliably declare user overridable variables. -override USER_VARIABLE = $(if $(filter $(origin $(1)),default undefined),$(eval override $(1) := $(2))) - # User controllable C compiler command. -$(call USER_VARIABLE,KCC,cc) +CC := cc -# User controllable linker command. -$(call USER_VARIABLE,KLD,ld) +# User controllable archiver command. +AR := ar # User controllable C flags. -$(call USER_VARIABLE,KCFLAGS,-g -O2 -pipe) +CFLAGS := -g -O2 -pipe # User controllable C preprocessor flags. We set none by default. -$(call USER_VARIABLE,KCPPFLAGS,) +CPPFLAGS := # User controllable nasm flags. -$(call USER_VARIABLE,KNASMFLAGS,-F dwarf -g) +NASMFLAGS := -F dwarf -g # User controllable linker flags. We set none by default. -$(call USER_VARIABLE,KLDFLAGS,) +LDFLAGS := -# Check if KCC is Clang. -override KCC_IS_CLANG := $(shell ! $(KCC) --version 2>/dev/null | grep 'clang' >/dev/null 2>&1; echo $$?) +# Check if CC is Clang. +override CC_IS_CLANG := $(shell ! $(CC) --version 2>/dev/null | grep 'clang' >/dev/null 2>&1; echo $$?) # If the C compiler is Clang, set the target as needed. -ifeq ($(KCC_IS_CLANG),1) - override KCC += \ +ifeq ($(CC_IS_CLANG),1) + override CC += \ -target x86_64-unknown-none endif # Internal C flags that should not be changed by the user. -override KCFLAGS += \ +override CFLAGS += \ -Wall \ -Wextra \ -std=gnu11 \ -ffreestanding \ -fno-stack-protector \ -fno-stack-check \ - -fno-lto \ -fno-PIC \ -ffunction-sections \ -fdata-sections \ @@ -58,70 +54,74 @@ override KCFLAGS += \ -mcmodel=kernel # Internal C preprocessor flags that should not be changed by the user. -override KCPPFLAGS := \ +override CPPFLAGS := \ -I src \ -I src/lib \ - $(KCPPFLAGS) \ + $(CPPFLAGS) \ + -DLIMINE_API_REVISION=3 \ -MMD \ -MP # Internal nasm flags that should not be changed by the user. -override KNASMFLAGS += \ +override NASMFLAGS += \ -Wall \ -f elf64 # Internal linker flags that should not be changed by the user. -override KLDFLAGS += \ - -m elf_x86_64 \ +override LDFLAGS += \ + -Wl,-m,elf_x86_64 \ + -Wl,--build-id=none \ -nostdlib \ -static \ -z max-page-size=0x1000 \ - -gc-sections \ + -Wl,--gc-sections \ -T linker.ld # 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' | LC_ALL=C sort) -override ASFILES := $(shell cd src && find -L * -type f -name '*.S' | LC_ALL=C sort) -override NASMFILES := $(shell cd src && find -L * -type f -name '*.asm' | LC_ALL=C sort) +override SRCFILES := $(shell cd src && find -L * -type f | LC_ALL=C sort) +override CFILES := $(filter %.c,$(SRCFILES)) +override ASFILES := $(filter %.S,$(SRCFILES)) +override NASMFILES := $(filter %.asm,$(SRCFILES)) 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. +# Default target. This must come first, before header dependencies. .PHONY: all all: bin/$(OUTPUT) +# Include header dependencies. +-include $(HEADER_DEPS) + src/limine.h: curl -Lo $@ https://github.com/limine-bootloader/limine/raw/trunk/limine.h || cp ../build/limine/limine.h src/limine.h || echo "ERROR" # Link rules for the final executable. bin/$(OUTPUT): GNUmakefile linker.ld $(OBJ) mkdir -p "$$(dirname $@)" - $(KLD) $(OBJ) $(KLDFLAGS) -o $@ - -# Include header dependencies. --include $(HEADER_DEPS) + $(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) -o $@ # Compilation rules for *.c files. obj/%.c.o: src/%.c GNUmakefile src/limine.h mkdir -p "$$(dirname $@)" - $(KCC) $(KCFLAGS) $(KCPPFLAGS) -c $< -o $@ + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ # Compilation rules for *.S files. obj/%.S.o: src/%.S GNUmakefile src/limine.h mkdir -p "$$(dirname $@)" - $(KCC) $(KCFLAGS) $(KCPPFLAGS) -c $< -o $@ + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ # Compilation rules for *.asm (nasm) files. obj/%.asm.o: src/%.asm GNUmakefile mkdir -p "$$(dirname $@)" - nasm $(KNASMFLAGS) $< -o $@ + nasm $(NASMFLAGS) $< -o $@ # Remove object files and the final executable. .PHONY: clean clean: rm -rf bin obj +# Remove everything built and generated including downloaded dependencies. .PHONY: distclean distclean: clean rm -f src/limine.h diff --git a/zealbooter/linker.ld b/zealbooter/linker.ld index 88ef6241..b8e1485b 100644 --- a/zealbooter/linker.ld +++ b/zealbooter/linker.ld @@ -9,10 +9,10 @@ ENTRY(kmain) /* process. */ PHDRS { - requests PT_LOAD; - text PT_LOAD; - rodata PT_LOAD; - data PT_LOAD; + limine_requests PT_LOAD; + text PT_LOAD; + rodata PT_LOAD; + data PT_LOAD; } SECTIONS @@ -24,11 +24,11 @@ SECTIONS . = 0xffffffff80000000; /* Define a section to contain the Limine requests and assign it to its own PHDR */ - .requests : { - KEEP(*(.requests_start_marker)) - KEEP(*(.requests)) - KEEP(*(.requests_end_marker)) - } :requests + .limine_requests : { + KEEP(*(.limine_requests_start)) + KEEP(*(.limine_requests)) + KEEP(*(.limine_requests_end)) + } :limine_requests /* Move to the next memory page for .text */ . = ALIGN(CONSTANT(MAXPAGESIZE)); diff --git a/zealbooter/src/zealbooter.c b/zealbooter/src/zealbooter.c index 300289f0..9bf44b15 100644 --- a/zealbooter/src/zealbooter.c +++ b/zealbooter/src/zealbooter.c @@ -4,43 +4,43 @@ #include #include -__attribute__((used, section(".requests_start_marker"))) +__attribute__((used, section(".limine_requests_start"))) static volatile LIMINE_REQUESTS_START_MARKER; -__attribute__((used, section(".requests_end_marker"))) +__attribute__((used, section(".limine_requests_end"))) static volatile LIMINE_REQUESTS_END_MARKER; -__attribute__((used, section(".requests"))) +__attribute__((used, section(".limine_requests"))) static volatile struct limine_module_request module_request = { .id = LIMINE_MODULE_REQUEST, .revision = 0 }; -__attribute__((used, section(".requests"))) +__attribute__((used, section(".limine_requests"))) static volatile struct limine_hhdm_request hhdm_request = { .id = LIMINE_HHDM_REQUEST, .revision = 0 }; -__attribute__((used, section(".requests"))) +__attribute__((used, section(".limine_requests"))) static volatile struct limine_memmap_request memmap_request = { .id = LIMINE_MEMMAP_REQUEST, .revision = 0 }; -__attribute__((used, section(".requests"))) +__attribute__((used, section(".limine_requests"))) static volatile struct limine_framebuffer_request framebuffer_request = { .id = LIMINE_FRAMEBUFFER_REQUEST, .revision = 0 }; -__attribute__((used, section(".requests"))) +__attribute__((used, section(".limine_requests"))) static volatile struct limine_smbios_request smbios_request = { .id = LIMINE_SMBIOS_REQUEST, .revision = 0 }; -__attribute__((used, section(".requests"))) +__attribute__((used, section(".limine_requests"))) static volatile struct limine_efi_system_table_request efi_request = { .id = LIMINE_EFI_SYSTEM_TABLE_REQUEST, .revision = 0 @@ -292,7 +292,7 @@ void kmain(void) { printf(" "); switch (entry->type) { case LIMINE_MEMMAP_BOOTLOADER_RECLAIMABLE: - case LIMINE_MEMMAP_KERNEL_AND_MODULES: + case LIMINE_MEMMAP_EXECUTABLE_AND_MODULES: case LIMINE_MEMMAP_USABLE: zeal_mem_type = MEM_E820T_USABLE; printf(" USABLE: "); @@ -343,7 +343,7 @@ void kmain(void) { printf("sys_gdt_ptr: 0x%X\n", sys_gdt_ptr); - void *sys_smbios_entry = smbios_request.response->entry_32; + void *sys_smbios_entry = (void *)smbios_request.response->entry_32; if (sys_smbios_entry != NULL) { kernel->sys_smbios_entry = (uintptr_t)sys_smbios_entry - hhdm_request.response->offset; }