Merge pull request #100 from Zeal-Operating-System/zealbooter-update

zealbooter: Rebase on latest limine-barebones code
This commit is contained in:
Arrogant Genius 2023-03-29 03:22:12 -04:00 committed by GitHub
commit d085f7b09d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 56 additions and 43 deletions

10
.gitignore vendored
View file

@ -2,17 +2,17 @@
*.bin *.bin
*.ZXE *.ZXE
*.MAP *.MAP
src/Boot/ /src/Boot
*.ELF *.ELF
*.elf *.elf
*.sys *.sys
*.SYS *.SYS
src/EFI/ /src/EFI
build/limine /build/limine
build/ovmf /build/ovmf
*.iso *.iso
*.raw *.raw
*.hdd *.hdd
*.o *.o
*.d *.d
zealbooter/limine.h /zealbooter/limine.h

View file

@ -1,8 +1,11 @@
# Nuke built-in rules and variables.
override MAKEFLAGS += -rR
# This is the name that our final kernel executable will have. # This is the name that our final kernel executable will have.
# Change as needed. # Change as needed.
override KERNEL := zealbooter.elf override KERNEL := zealbooter.elf
# Convenience macro to reliably declare overridable command variables. # Convenience macro to reliably declare user overridable variables.
define DEFAULT_VAR = define DEFAULT_VAR =
ifeq ($(origin $1),default) ifeq ($(origin $1),default)
override $(1) := $(2) override $(1) := $(2)
@ -20,17 +23,17 @@ $(eval $(call DEFAULT_VAR,CC,cc))
# Same thing for "ld" (the linker). # Same thing for "ld" (the linker).
$(eval $(call DEFAULT_VAR,LD,ld)) $(eval $(call DEFAULT_VAR,LD,ld))
# User controllable CFLAGS. # User controllable C flags.
CFLAGS ?= -g -O2 -pipe -Wall -Wextra $(eval $(call DEFAULT_VAR,CFLAGS,-g -O2 -pipe -Wall -Wextra))
# User controllable preprocessor flags. We set none by default. # User controllable C preprocessor flags. We set none by default.
CPPFLAGS ?= $(eval $(call DEFAULT_VAR,CPPFLAGS,))
# User controllable nasm flags. # User controllable nasm flags.
NASMFLAGS ?= -F dwarf -g $(eval $(call DEFAULT_VAR,NASMFLAGS,-F dwarf -g))
# User controllable linker flags. We set none by default. # User controllable linker flags. We set none by default.
LDFLAGS ?= $(eval $(call DEFAULT_VAR,LDFLAGS,))
# Internal C flags that should not be changed by the user. # Internal C flags that should not be changed by the user.
override CFLAGS += \ override CFLAGS += \
@ -49,10 +52,15 @@ override CFLAGS += \
-mno-sse \ -mno-sse \
-mno-sse2 \ -mno-sse2 \
-mno-red-zone \ -mno-red-zone \
-mcmodel=kernel \ -mcmodel=kernel
-MMD \
# Internal C preprocessor flags that should not be changed by the user.
override CPPFLAGS := \
-I. \ -I. \
-I./lib -I./lib \
$(CPPFLAGS) \
-MMD \
-MP
# Internal linker flags that should not be changed by the user. # Internal linker flags that should not be changed by the user.
override LDFLAGS += \ override LDFLAGS += \
@ -62,7 +70,7 @@ override LDFLAGS += \
-z max-page-size=0x1000 \ -z max-page-size=0x1000 \
-T linker.ld -T linker.ld
# Check if the linker supports -no-pie and enable it if it does # Check if the linker supports -no-pie and enable it if it does.
ifeq ($(shell $(LD) --help 2>&1 | grep 'no-pie' >/dev/null 2>&1; echo $$?),0) ifeq ($(shell $(LD) --help 2>&1 | grep 'no-pie' >/dev/null 2>&1; echo $$?),0)
override LDFLAGS += -no-pie override LDFLAGS += -no-pie
endif endif
@ -71,10 +79,11 @@ endif
override NASMFLAGS += \ override NASMFLAGS += \
-f elf64 -f elf64
# Use find to glob all *.c, *.S, and *.asm files in the directory and extract the object names. # Use "find" to glob all *.c, *.S, and *.asm files in the tree and obtain the
override CFILES := $(shell find . -type f -name '*.c') # object and header dependency file names.
override ASFILES := $(shell find . -type f -name '*.S') override CFILES := $(shell find -L . -type f -name '*.c')
override NASMFILES := $(shell find . -type f -name '*.asm') override ASFILES := $(shell find -L . -type f -name '*.S')
override NASMFILES := $(shell find -L . -type f -name '*.asm')
override OBJ := $(CFILES:.c=.o) $(ASFILES:.S=.o) $(NASMFILES:.asm=.o) override OBJ := $(CFILES:.c=.o) $(ASFILES:.S=.o) $(NASMFILES:.asm=.o)
override HEADER_DEPS := $(CFILES:.c=.d) $(ASFILES:.S=.d) override HEADER_DEPS := $(CFILES:.c=.d) $(ASFILES:.S=.d)
@ -83,7 +92,7 @@ override HEADER_DEPS := $(CFILES:.c=.d) $(ASFILES:.S=.d)
all: $(KERNEL) all: $(KERNEL)
limine.h: limine.h:
curl https://raw.githubusercontent.com/limine-bootloader/limine/trunk/limine.h -o $@ || cp ../build/limine/limine.h limine.h || echo "ERROR" curl -Lo $@ https://github.com/limine-bootloader/limine/raw/trunk/limine.h || cp ../build/limine/limine.h limine.h || echo "ERROR"
# Link rules for the final kernel executable. # Link rules for the final kernel executable.
$(KERNEL): $(OBJ) $(KERNEL): $(OBJ)
@ -94,11 +103,11 @@ $(KERNEL): $(OBJ)
# Compilation rules for *.c files. # Compilation rules for *.c files.
%.o: %.c limine.h %.o: %.c limine.h
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
# Compilation rules for *.S files. # Compilation rules for *.S files.
%.o: %.S limine.h %.o: %.S limine.h
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
# Compilation rules for *.asm (nasm) files. # Compilation rules for *.asm (nasm) files.
%.o: %.asm %.o: %.asm

View file

@ -40,6 +40,10 @@ SECTIONS
*(.data .data.*) *(.data .data.*)
} :data } :data
/* NOTE: .bss needs to be the last thing mapped to :data, otherwise lots of */
/* unnecessary zeros will be written to the binary. */
/* If you need, for example, .init_array and .fini_array, those should be placed */
/* above this. */
.bss : { .bss : {
*(COMMON) *(COMMON)
*(.bss .bss.*) *(.bss .bss.*)