Misc updates for Limine 5.x and Zealbooter

This commit is contained in:
mintsuki 2023-07-15 08:12:16 +02:00
parent c3aaa3e621
commit 3f61ca6932
7 changed files with 49 additions and 44 deletions

View file

@ -64,7 +64,7 @@ umount_tempdisk
echo "Rebuilding kernel headers, kernel, OS, and building Distro ISO ..." echo "Rebuilding kernel headers, kernel, OS, and building Distro ISO ..."
$QEMU_BIN_PATH/qemu-system-x86_64 -machine q35,accel=kvm -drive format=raw,file=$TMPDISK -m 1G -rtc base=localtime -smp 4 -device isa-debug-exit $QEMU_BIN_PATH/qemu-system-x86_64 -machine q35,accel=kvm -drive format=raw,file=$TMPDISK -m 1G -rtc base=localtime -smp 4 -device isa-debug-exit
LIMINE_BINARY_BRANCH="v4.x-branch-binary" LIMINE_BINARY_BRANCH="v5.x-branch-binary"
if [ -d "limine" ] if [ -d "limine" ]
then then
@ -74,8 +74,7 @@ then
git remote set-head origin $LIMINE_BINARY_BRANCH git remote set-head origin $LIMINE_BINARY_BRANCH
git switch $LIMINE_BINARY_BRANCH git switch $LIMINE_BINARY_BRANCH
git pull git pull
rm limine-deploy rm limine
rm limine-version
cd .. cd ..
fi fi
@ -84,13 +83,13 @@ if [ ! -d "limine" ]; then
fi fi
make -C limine make -C limine
touch limine/Limine-HDD.HH touch limine/Limine-BIOS-HDD.HH
echo "/*\$WW,1\$" > limine/Limine-HDD.HH echo "/*\$WW,1\$" > limine/Limine-BIOS-HDD.HH
cat limine/LICENSE.md >> limine/Limine-HDD.HH cat limine/LICENSE >> limine/Limine-BIOS-HDD.HH
echo "*/\$WW,0\$" >> limine/Limine-HDD.HH echo "*/\$WW,0\$" >> limine/Limine-BIOS-HDD.HH
cat limine/limine-hdd.h >> limine/Limine-HDD.HH cat limine/limine-bios-hdd.h >> limine/Limine-BIOS-HDD.HH
sed -i 's/const uint8_t/U8/g' limine/Limine-HDD.HH sed -i 's/const uint8_t/U8/g' limine/Limine-BIOS-HDD.HH
sed -i "s/\[\]/\[$(grep -o "0x" ./limine/limine-hdd.h | wc -l)\]/g" limine/Limine-HDD.HH sed -i "s/\[\]/\[$(grep -o "0x" ./limine/limine-bios-hdd.h | wc -l)\]/g" limine/Limine-BIOS-HDD.HH
mount_tempdisk mount_tempdisk
echo "Extracting MyDistro ISO from vdisk ..." echo "Extracting MyDistro ISO from vdisk ..."
@ -101,11 +100,11 @@ sudo cp -rf $TMPMOUNT/* $TMPISODIR
sudo rm $TMPISODIR/Boot/OldMBR.BIN 2> /dev/null sudo rm $TMPISODIR/Boot/OldMBR.BIN 2> /dev/null
sudo rm $TMPISODIR/Boot/BootMHD2.BIN 2> /dev/null sudo rm $TMPISODIR/Boot/BootMHD2.BIN 2> /dev/null
sudo mkdir -p $TMPISODIR/EFI/BOOT sudo mkdir -p $TMPISODIR/EFI/BOOT
sudo cp limine/Limine-HDD.HH $TMPISODIR/Boot/Limine-HDD.HH sudo cp limine/Limine-BIOS-HDD.HH $TMPISODIR/Boot/Limine-BIOS-HDD.HH
sudo cp limine/BOOTX64.EFI $TMPISODIR/EFI/BOOT/BOOTX64.EFI sudo cp limine/BOOTX64.EFI $TMPISODIR/EFI/BOOT/BOOTX64.EFI
sudo cp limine/limine-cd-efi.bin $TMPISODIR/Boot/Limine-CD-EFI.BIN sudo cp limine/limine-uefi-cd.bin $TMPISODIR/Boot/Limine-UEFI-CD.BIN
sudo cp limine/limine-cd.bin $TMPISODIR/Boot/Limine-CD.BIN sudo cp limine/limine-bios-cd.bin $TMPISODIR/Boot/Limine-BIOS-CD.BIN
sudo cp limine/limine.sys $TMPISODIR/Boot/Limine.SYS sudo cp limine/limine-bios.sys $TMPISODIR/Boot/Limine-BIOS.SYS
sudo cp ../zealbooter/zealbooter.elf $TMPISODIR/Boot/ZealBooter.ELF sudo cp ../zealbooter/zealbooter.elf $TMPISODIR/Boot/ZealBooter.ELF
sudo cp ../zealbooter/Limine.CFG $TMPISODIR/Boot/Limine.CFG sudo cp ../zealbooter/Limine.CFG $TMPISODIR/Boot/Limine.CFG
echo "Copying DVDKernel.ZXE over ISO Boot/Kernel.ZXE ..." echo "Copying DVDKernel.ZXE over ISO Boot/Kernel.ZXE ..."
@ -113,13 +112,13 @@ sudo mv $TMPMOUNT/Tmp/DVDKernel.ZXE $TMPISODIR/Boot/Kernel.ZXE
sudo rm $TMPISODIR/Tmp/DVDKernel.ZXE 2> /dev/null sudo rm $TMPISODIR/Tmp/DVDKernel.ZXE 2> /dev/null
umount_tempdisk umount_tempdisk
xorriso -joliet "on" -rockridge "on" -as mkisofs -b Boot/Limine-CD.BIN \ xorriso -joliet "on" -rockridge "on" -as mkisofs -b Boot/Limine-BIOS-CD.BIN \
-no-emul-boot -boot-load-size 4 -boot-info-table \ -no-emul-boot -boot-load-size 4 -boot-info-table \
--efi-boot Boot/Limine-CD-EFI.BIN \ --efi-boot Boot/Limine-UEFI-CD.BIN \
-efi-boot-part --efi-boot-image --protective-msdos-label \ -efi-boot-part --efi-boot-image --protective-msdos-label \
$TMPISODIR -o ZealOS-limine.iso $TMPISODIR -o ZealOS-limine.iso
./limine/limine-deploy ZealOS-limine.iso ./limine/limine bios-install ZealOS-limine.iso
if [ "$TESTING" = true ]; then if [ "$TESTING" = true ]; then
if [ ! -d "ovmf" ]; then if [ ! -d "ovmf" ]; then

View file

@ -1,5 +1,5 @@
#define LIMINE_HDD_FILE "/Boot/Limine-HDD.HH" #define LIMINE_HDD_FILE "/Boot/Limine-BIOS-HDD.HH"
#define LIMINE_HDD_INSTALLER "/System/Boot/LimineMHDIns.ZC" #define LIMINE_HDD_INSTALLER "/System/Boot/LimineMHDIns.ZC"
#include LIMINE_HDD_FILE #include LIMINE_HDD_FILE
#include LIMINE_HDD_INSTALLER #include LIMINE_HDD_INSTALLER
@ -127,8 +127,8 @@ U0 OSMerge(U8 dst_drv, U8 src_drv=':')
CopyTree("B:/", dst); CopyTree("B:/", dst);
ExePrint("Del(\"%C:/Boot/Limine-CD.BIN\");", dst_drv); ExePrint("Del(\"%C:/Boot/Limine-BIOS-CD.BIN\");", dst_drv);
ExePrint("Del(\"%C:/Boot/Limine-CD-EFI.BIN\");", dst_drv); ExePrint("Del(\"%C:/Boot/Limine-UEFI-CD.BIN\");", dst_drv);
ExePrint("Del(\"%C:/Boot/Limine.CFG\");", dst_drv); ExePrint("Del(\"%C:/Boot/Limine.CFG\");", dst_drv);
ExePrint("Del(\"%C:/boot.catalog\");", dst_drv); ExePrint("Del(\"%C:/boot.catalog\");", dst_drv);
@ -245,8 +245,8 @@ U0 InstallDrive(U8 drv_let)
ExePrint("CopyTree(\"::/\",\"%C:/\");", drv_let); ExePrint("CopyTree(\"::/\",\"%C:/\");", drv_let);
ExePrint("Del(\"%C:/Boot/Limine-CD.BIN\");", drv_let); ExePrint("Del(\"%C:/Boot/Limine-BIOS-CD.BIN\");", drv_let);
ExePrint("Del(\"%C:/Boot/Limine-CD-EFI.BIN\");", drv_let); ExePrint("Del(\"%C:/Boot/Limine-UEFI-CD.BIN\");", drv_let);
ExePrint("Del(\"%C:/Boot/Limine.CFG\");", drv_let); ExePrint("Del(\"%C:/Boot/Limine.CFG\");", drv_let);
ExePrint("Del(\"%C:/boot.catalog\");", drv_let); ExePrint("Del(\"%C:/boot.catalog\");", drv_let);

View file

@ -34,7 +34,7 @@ Bool LimineCFGMake(U8 drv_let)
bd = drive->bd; bd = drive->bd;
drv_let = Drive2Letter(drive); drv_let = Drive2Letter(drive);
filename_sys = MStrPrint("%C:/Boot/Limine.SYS", drv_let); filename_sys = MStrPrint("%C:/Boot/Limine-BIOS.SYS", drv_let);
filename_elf = MStrPrint("%C:/Boot/ZealBooter.ELF", drv_let); filename_elf = MStrPrint("%C:/Boot/ZealBooter.ELF", drv_let);
filename_zxe = MStrPrint("%C:/Boot/Kernel.ZXE", drv_let); filename_zxe = MStrPrint("%C:/Boot/Kernel.ZXE", drv_let);
if (FileFind(filename_sys) && FileFind(filename_elf) && FileFind(filename_zxe)) if (FileFind(filename_sys) && FileFind(filename_elf) && FileFind(filename_zxe))

View file

@ -18,22 +18,28 @@ endef
# It is highly recommended to use a custom built cross toolchain to build a kernel. # It is highly recommended to use a custom built cross toolchain to build a kernel.
# We are only using "cc" as a placeholder here. It may work by using # We are only using "cc" as a placeholder here. It may work by using
# the host system's toolchain, but this is not guaranteed. # the host system's toolchain, but this is not guaranteed.
$(eval $(call DEFAULT_VAR,CC,cc)) override DEFAULT_CC := cc
$(eval $(call DEFAULT_VAR,CC,$(DEFAULT_CC)))
# Same thing for "ld" (the linker). # Same thing for "ld" (the linker).
$(eval $(call DEFAULT_VAR,LD,ld)) override DEFAULT_LD := ld
$(eval $(call DEFAULT_VAR,LD,$(DEFAULT_LD)))
# User controllable C flags. # User controllable C flags.
$(eval $(call DEFAULT_VAR,CFLAGS,-g -O2 -pipe)) override DEFAULT_CFLAGS := -g -O2 -pipe
$(eval $(call DEFAULT_VAR,CFLAGS,$(DEFAULT_CFLAGS)))
# User controllable C preprocessor flags. We set none by default. # User controllable C preprocessor flags. We set none by default.
$(eval $(call DEFAULT_VAR,CPPFLAGS,)) override DEFAULT_CPPFLAGS :=
$(eval $(call DEFAULT_VAR,CPPFLAGS,$(DEFAULT_CPPFLAGS)))
# User controllable nasm flags. # User controllable nasm flags.
$(eval $(call DEFAULT_VAR,NASMFLAGS,-F dwarf -g)) override DEFAULT_NASMFLAGS := -F dwarf -g
$(eval $(call DEFAULT_VAR,NASMFLAGS,$(DEFAULT_NASMFLAGS)))
# User controllable linker flags. We set none by default. # User controllable linker flags. We set none by default.
$(eval $(call DEFAULT_VAR,LDFLAGS,)) override DEFAULT_LDFLAGS :=
$(eval $(call DEFAULT_VAR,LDFLAGS,$(DEFAULT_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 += \
@ -66,9 +72,9 @@ override CPPFLAGS := \
# 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 += \
-m elf_x86_64 \
-nostdlib \ -nostdlib \
-static \ -static \
-m elf_x86_64 \
-z max-page-size=0x1000 \ -z max-page-size=0x1000 \
-T linker.ld -T linker.ld
@ -87,8 +93,8 @@ override NASMFLAGS += \
override CFILES := $(shell find -L . -type f -name '*.c') override CFILES := $(shell find -L . -type f -name '*.c')
override ASFILES := $(shell find -L . -type f -name '*.S') override ASFILES := $(shell find -L . -type f -name '*.S')
override NASMFILES := $(shell find -L . -type f -name '*.asm') override NASMFILES := $(shell find -L . -type f -name '*.asm')
override OBJ := $(CFILES:.c=.o) $(ASFILES:.S=.o) $(NASMFILES:.asm=.o) override OBJ := $(CFILES:.c=.c.o) $(ASFILES:.S=.S.o) $(NASMFILES:.asm=.asm.o)
override HEADER_DEPS := $(CFILES:.c=.d) $(ASFILES:.S=.d) override HEADER_DEPS := $(CFILES:.c=.c.d) $(ASFILES:.S=.S.d)
# Default target. # Default target.
.PHONY: all .PHONY: all
@ -105,15 +111,15 @@ $(KERNEL): $(OBJ)
-include $(HEADER_DEPS) -include $(HEADER_DEPS)
# Compilation rules for *.c files. # Compilation rules for *.c files.
%.o: %.c limine.h %.c.o: %.c limine.h
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
# Compilation rules for *.S files. # Compilation rules for *.S files.
%.o: %.S limine.h %.S.o: %.S limine.h
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
# Compilation rules for *.asm (nasm) files. # Compilation rules for *.asm (nasm) files.
%.o: %.asm %.asm.o: %.asm
nasm $(NASMFLAGS) $< -o $@ nasm $(NASMFLAGS) $< -o $@
# Remove object files and the final executable. # Remove object files and the final executable.

View file

@ -4,10 +4,10 @@
#include <stb_sprintf.h> #include <stb_sprintf.h>
#include <limine.h> #include <limine.h>
static volatile struct limine_terminal_request terminal_request = { //static volatile struct limine_terminal_request terminal_request = {
.id = LIMINE_TERMINAL_REQUEST, // .id = LIMINE_TERMINAL_REQUEST,
.revision = 0 // .revision = 0
}; //};
#define PRINT_BUFFER_SIZE 8192 #define PRINT_BUFFER_SIZE 8192
@ -15,14 +15,14 @@ int printf(const char *format, ...)
{ {
va_list args; va_list args;
char buffer[PRINT_BUFFER_SIZE]; char buffer[PRINT_BUFFER_SIZE];
struct limine_terminal *terminal; //struct limine_terminal *terminal;
size_t length; size_t length;
va_start(args, format); va_start(args, format);
length = vsnprintf(buffer, PRINT_BUFFER_SIZE, format, args); length = vsnprintf(buffer, PRINT_BUFFER_SIZE, format, args);
terminal = terminal_request.response->terminals[0]; //terminal = terminal_request.response->terminals[0];
terminal_request.response->write(terminal, buffer, length); //terminal_request.response->write(terminal, buffer, length);
va_end(args); va_end(args);

View file

@ -45,8 +45,8 @@ SECTIONS
/* If you need, for example, .init_array and .fini_array, those should be placed */ /* If you need, for example, .init_array and .fini_array, those should be placed */
/* above this. */ /* above this. */
.bss : { .bss : {
*(COMMON)
*(.bss .bss.*) *(.bss .bss.*)
*(COMMON)
} :data } :data
/* Discard .note.* and .eh_frame since they may cause issues on some hosts. */ /* Discard .note.* and .eh_frame since they may cause issues on some hosts. */

View file

@ -21,7 +21,7 @@ static volatile struct limine_memmap_request memmap_request = {
static volatile struct limine_framebuffer_request framebuffer_request = { static volatile struct limine_framebuffer_request framebuffer_request = {
.id = LIMINE_FRAMEBUFFER_REQUEST, .id = LIMINE_FRAMEBUFFER_REQUEST,
.revision = 1 .revision = 0
}; };
static volatile struct limine_smbios_request smbios_request = { static volatile struct limine_smbios_request smbios_request = {