Skip to content

Commit fc076d1

Browse files
committed
Fixes and improvements for Limine 9.x
1 parent af8e036 commit fc076d1

File tree

4 files changed

+57
-57
lines changed

4 files changed

+57
-57
lines changed

build/build-iso.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ umount_tempdisk
6666
echo "Rebuilding kernel headers, kernel, OS, and building Distro ISO ..."
6767
$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
6868

69-
LIMINE_BINARY_BRANCH="v8.x-binary"
69+
LIMINE_BINARY_BRANCH="v9.x-binary"
7070

7171
if [ -d "limine" ]
7272
then
@@ -116,13 +116,13 @@ sudo mv $TMPMOUNT/Tmp/DVDKernel.ZXE $TMPISODIR/Boot/Kernel.ZXE
116116
sudo rm $TMPISODIR/Tmp/DVDKernel.ZXE 2> /dev/null
117117
umount_tempdisk
118118

119-
xorriso -joliet "on" -rockridge "on" -as mkisofs -b Boot/Limine-BIOS-CD.BIN \
120-
-no-emul-boot -boot-load-size 4 -boot-info-table \
121-
--efi-boot Boot/Limine-UEFI-CD.BIN \
119+
xorriso -as mkisofs -R -r -J -b Boot/Limine-BIOS-CD.BIN \
120+
-no-emul-boot -boot-load-size 4 -boot-info-table -hfsplus \
121+
-apm-block-size 2048 --efi-boot Boot/Limine-UEFI-CD.BIN \
122122
-efi-boot-part --efi-boot-image --protective-msdos-label \
123123
$TMPISODIR -o ZealOS-limine.iso
124124

125-
./limine/limine bios-install ZealOS-limine.iso
125+
./limine/limine bios-install ZealOS-limine.iso --no-gpt-to-mbr-isohybrid-conversion
126126

127127
if [ "$TESTING" = true ]; then
128128
if [ ! -d "ovmf" ]; then

zealbooter/GNUmakefile

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,41 @@ MAKEFLAGS += -rR
66
# Change as needed.
77
override OUTPUT := kernel
88

9-
# Convenience macro to reliably declare user overridable variables.
10-
override USER_VARIABLE = $(if $(filter $(origin $(1)),default undefined),$(eval override $(1) := $(2)))
11-
129
# User controllable C compiler command.
13-
$(call USER_VARIABLE,KCC,cc)
10+
CC := cc
1411

15-
# User controllable linker command.
16-
$(call USER_VARIABLE,KLD,ld)
12+
# User controllable archiver command.
13+
AR := ar
1714

1815
# User controllable C flags.
19-
$(call USER_VARIABLE,KCFLAGS,-g -O2 -pipe)
16+
CFLAGS := -g -O2 -pipe
2017

2118
# User controllable C preprocessor flags. We set none by default.
22-
$(call USER_VARIABLE,KCPPFLAGS,)
19+
CPPFLAGS :=
2320

2421
# User controllable nasm flags.
25-
$(call USER_VARIABLE,KNASMFLAGS,-F dwarf -g)
22+
NASMFLAGS := -F dwarf -g
2623

2724
# User controllable linker flags. We set none by default.
28-
$(call USER_VARIABLE,KLDFLAGS,)
25+
LDFLAGS :=
2926

30-
# Check if KCC is Clang.
31-
override KCC_IS_CLANG := $(shell ! $(KCC) --version 2>/dev/null | grep 'clang' >/dev/null 2>&1; echo $$?)
27+
# Check if CC is Clang.
28+
override CC_IS_CLANG := $(shell ! $(CC) --version 2>/dev/null | grep 'clang' >/dev/null 2>&1; echo $$?)
3229

3330
# If the C compiler is Clang, set the target as needed.
34-
ifeq ($(KCC_IS_CLANG),1)
35-
override KCC += \
31+
ifeq ($(CC_IS_CLANG),1)
32+
override CC += \
3633
-target x86_64-unknown-none
3734
endif
3835

3936
# Internal C flags that should not be changed by the user.
40-
override KCFLAGS += \
37+
override CFLAGS += \
4138
-Wall \
4239
-Wextra \
4340
-std=gnu11 \
4441
-ffreestanding \
4542
-fno-stack-protector \
4643
-fno-stack-check \
47-
-fno-lto \
4844
-fno-PIC \
4945
-ffunction-sections \
5046
-fdata-sections \
@@ -58,70 +54,74 @@ override KCFLAGS += \
5854
-mcmodel=kernel
5955

6056
# Internal C preprocessor flags that should not be changed by the user.
61-
override KCPPFLAGS := \
57+
override CPPFLAGS := \
6258
-I src \
6359
-I src/lib \
64-
$(KCPPFLAGS) \
60+
$(CPPFLAGS) \
61+
-DLIMINE_API_REVISION=3 \
6562
-MMD \
6663
-MP
6764

6865
# Internal nasm flags that should not be changed by the user.
69-
override KNASMFLAGS += \
66+
override NASMFLAGS += \
7067
-Wall \
7168
-f elf64
7269

7370
# Internal linker flags that should not be changed by the user.
74-
override KLDFLAGS += \
75-
-m elf_x86_64 \
71+
override LDFLAGS += \
72+
-Wl,-m,elf_x86_64 \
73+
-Wl,--build-id=none \
7674
-nostdlib \
7775
-static \
7876
-z max-page-size=0x1000 \
79-
-gc-sections \
77+
-Wl,--gc-sections \
8078
-T linker.ld
8179

8280
# Use "find" to glob all *.c, *.S, and *.asm files in the tree and obtain the
8381
# object and header dependency file names.
84-
override CFILES := $(shell cd src && find -L * -type f -name '*.c' | LC_ALL=C sort)
85-
override ASFILES := $(shell cd src && find -L * -type f -name '*.S' | LC_ALL=C sort)
86-
override NASMFILES := $(shell cd src && find -L * -type f -name '*.asm' | LC_ALL=C sort)
82+
override SRCFILES := $(shell cd src && find -L * -type f | LC_ALL=C sort)
83+
override CFILES := $(filter %.c,$(SRCFILES))
84+
override ASFILES := $(filter %.S,$(SRCFILES))
85+
override NASMFILES := $(filter %.asm,$(SRCFILES))
8786
override OBJ := $(addprefix obj/,$(CFILES:.c=.c.o) $(ASFILES:.S=.S.o) $(NASMFILES:.asm=.asm.o))
8887
override HEADER_DEPS := $(addprefix obj/,$(CFILES:.c=.c.d) $(ASFILES:.S=.S.d))
8988

90-
# Default target.
89+
# Default target. This must come first, before header dependencies.
9190
.PHONY: all
9291
all: bin/$(OUTPUT)
9392

93+
# Include header dependencies.
94+
-include $(HEADER_DEPS)
95+
9496
src/limine.h:
9597
curl -Lo $@ https://github.com/limine-bootloader/limine/raw/trunk/limine.h || cp ../build/limine/limine.h src/limine.h || echo "ERROR"
9698

9799
# Link rules for the final executable.
98100
bin/$(OUTPUT): GNUmakefile linker.ld $(OBJ)
99101
mkdir -p "$$(dirname $@)"
100-
$(KLD) $(OBJ) $(KLDFLAGS) -o $@
101-
102-
# Include header dependencies.
103-
-include $(HEADER_DEPS)
102+
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) -o $@
104103

105104
# Compilation rules for *.c files.
106105
obj/%.c.o: src/%.c GNUmakefile src/limine.h
107106
mkdir -p "$$(dirname $@)"
108-
$(KCC) $(KCFLAGS) $(KCPPFLAGS) -c $< -o $@
107+
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
109108

110109
# Compilation rules for *.S files.
111110
obj/%.S.o: src/%.S GNUmakefile src/limine.h
112111
mkdir -p "$$(dirname $@)"
113-
$(KCC) $(KCFLAGS) $(KCPPFLAGS) -c $< -o $@
112+
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
114113

115114
# Compilation rules for *.asm (nasm) files.
116115
obj/%.asm.o: src/%.asm GNUmakefile
117116
mkdir -p "$$(dirname $@)"
118-
nasm $(KNASMFLAGS) $< -o $@
117+
nasm $(NASMFLAGS) $< -o $@
119118

120119
# Remove object files and the final executable.
121120
.PHONY: clean
122121
clean:
123122
rm -rf bin obj
124123

124+
# Remove everything built and generated including downloaded dependencies.
125125
.PHONY: distclean
126126
distclean: clean
127127
rm -f src/limine.h

zealbooter/linker.ld

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ ENTRY(kmain)
99
/* process. */
1010
PHDRS
1111
{
12-
requests PT_LOAD;
13-
text PT_LOAD;
14-
rodata PT_LOAD;
15-
data PT_LOAD;
12+
limine_requests PT_LOAD;
13+
text PT_LOAD;
14+
rodata PT_LOAD;
15+
data PT_LOAD;
1616
}
1717

1818
SECTIONS
@@ -24,11 +24,11 @@ SECTIONS
2424
. = 0xffffffff80000000;
2525

2626
/* Define a section to contain the Limine requests and assign it to its own PHDR */
27-
.requests : {
28-
KEEP(*(.requests_start_marker))
29-
KEEP(*(.requests))
30-
KEEP(*(.requests_end_marker))
31-
} :requests
27+
.limine_requests : {
28+
KEEP(*(.limine_requests_start))
29+
KEEP(*(.limine_requests))
30+
KEEP(*(.limine_requests_end))
31+
} :limine_requests
3232

3333
/* Move to the next memory page for .text */
3434
. = ALIGN(CONSTANT(MAXPAGESIZE));

zealbooter/src/zealbooter.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,43 @@
44
#include <limine.h>
55
#include <lib.h>
66

7-
__attribute__((used, section(".requests_start_marker")))
7+
__attribute__((used, section(".limine_requests_start")))
88
static volatile LIMINE_REQUESTS_START_MARKER;
99

10-
__attribute__((used, section(".requests_end_marker")))
10+
__attribute__((used, section(".limine_requests_end")))
1111
static volatile LIMINE_REQUESTS_END_MARKER;
1212

13-
__attribute__((used, section(".requests")))
13+
__attribute__((used, section(".limine_requests")))
1414
static volatile struct limine_module_request module_request = {
1515
.id = LIMINE_MODULE_REQUEST,
1616
.revision = 0
1717
};
1818

19-
__attribute__((used, section(".requests")))
19+
__attribute__((used, section(".limine_requests")))
2020
static volatile struct limine_hhdm_request hhdm_request = {
2121
.id = LIMINE_HHDM_REQUEST,
2222
.revision = 0
2323
};
2424

25-
__attribute__((used, section(".requests")))
25+
__attribute__((used, section(".limine_requests")))
2626
static volatile struct limine_memmap_request memmap_request = {
2727
.id = LIMINE_MEMMAP_REQUEST,
2828
.revision = 0
2929
};
3030

31-
__attribute__((used, section(".requests")))
31+
__attribute__((used, section(".limine_requests")))
3232
static volatile struct limine_framebuffer_request framebuffer_request = {
3333
.id = LIMINE_FRAMEBUFFER_REQUEST,
3434
.revision = 0
3535
};
3636

37-
__attribute__((used, section(".requests")))
37+
__attribute__((used, section(".limine_requests")))
3838
static volatile struct limine_smbios_request smbios_request = {
3939
.id = LIMINE_SMBIOS_REQUEST,
4040
.revision = 0
4141
};
4242

43-
__attribute__((used, section(".requests")))
43+
__attribute__((used, section(".limine_requests")))
4444
static volatile struct limine_efi_system_table_request efi_request = {
4545
.id = LIMINE_EFI_SYSTEM_TABLE_REQUEST,
4646
.revision = 0
@@ -292,7 +292,7 @@ void kmain(void) {
292292
printf(" ");
293293
switch (entry->type) {
294294
case LIMINE_MEMMAP_BOOTLOADER_RECLAIMABLE:
295-
case LIMINE_MEMMAP_KERNEL_AND_MODULES:
295+
case LIMINE_MEMMAP_EXECUTABLE_AND_MODULES:
296296
case LIMINE_MEMMAP_USABLE:
297297
zeal_mem_type = MEM_E820T_USABLE;
298298
printf(" USABLE: ");
@@ -343,7 +343,7 @@ void kmain(void) {
343343

344344
printf("sys_gdt_ptr: 0x%X\n", sys_gdt_ptr);
345345

346-
void *sys_smbios_entry = smbios_request.response->entry_32;
346+
void *sys_smbios_entry = (void *)smbios_request.response->entry_32;
347347
if (sys_smbios_entry != NULL) {
348348
kernel->sys_smbios_entry = (uintptr_t)sys_smbios_entry - hhdm_request.response->offset;
349349
}

0 commit comments

Comments
 (0)