I'm developing a DOS-like OS based on queso-fuego's uefi-dev code.
( Oh, by the way - that project uses the Limine bootloader but I removed that from my fork as it is MIT-licensed and I wanted the code to be 100% public-domain.
It shouldn't be needed anyway - the UEFI spec doesn't mandate it...

Anyway - the build is succeeding and the boot process starts but the process drops to the UEFI shell.
I'm developing on Linux Mint and using clang compiler.
Here is what the UEFI environment looks like -
Code: Select all
UEFI Interactive Shell v2.2
EDK II
UEFI v2.70 (Ubuntu distribution of EDK II, 0x00010000)
Mapping table
BLK0: Alias(s):
PciRoot(0x0)/Pci(0x1F,0x2)/Sata(0x0,0xFFFF,0x0)
BLK2: Alias(s):
PciRoot(0x0)/Pci(0x1F,0x2)/Sata(0x2,0xFFFF,0x0)
BLK1: Alias(s):
PciRoot(0x0)/Pci(0x1F,0x2)/Sata(0x0,0xFFFF,0x0)/HD(1,GPT,00000000-0000-0000-0000-000000000000,0x800,0x1F800)
Press ESC in 1 seconds to skip startup.nsh or any other key to continue.
Shell>
BLK1 looks to be my HD image but the boot process isn't jumping to it.
My makefile is here -
Code: Select all
# ---------------------------------------------------------------------------
# Sea‑DOS build system – Linux + clang, x86‑64, public domain (Unlicense)
# ---------------------------------------------------------------------------
ARCH ?= x86_64
ARCH := $(strip $(ARCH))
# ---- arch guard -----------------------------------------------------------
ifeq ($(filter x86_64 amd64,$(ARCH)),)
$(error Only x86‑64 builds supported; invoke make ARCH=x86_64)
endif
# ---- locate OVMF firmware -------------------------------------------------
OVMF ?= $(firstword \
$(wildcard /usr/share/OVMF/OVMF_CODE.fd) \
$(wildcard /usr/share/ovmf/OVMF.fd) \
$(wildcard /usr/share/qemu/OVMF.fd))
ifeq ($(OVMF),)
$(warning *** No OVMF firmware image found – pass OVMF=/path/to/OVMF.fd)
endif
# ---- toolchain triples ----------------------------------------------------
EFI_TRIPLE := $(ARCH)-pc-windows-msvc # PE/COFF
ELF_TRIPLE := $(ARCH)-pc-elf # freestanding ELF
EFICC := clang -target $(EFI_TRIPLE)
EFI_LDFLAGS := -nostdlib -fuse-ld=lld-link \
-Wl,-subsystem:efi_application \
-Wl,-entry:efi_main
ELFCC := clang -target $(ELF_TRIPLE)
ELFLD := ld.lld
CC ?= clang # host compiler for helpers
# ---- directories ----------------------------------------------------------
SEA_IMG_DIR := ../sea_img
BUILD_DIR := ../build
QEMU_SCRIPT := ./qemu_$(ARCH).sh
# -------- create helper dirs (phony, silent) -------------------------------
.PHONY: $(SEA_IMG_DIR) $(BUILD_DIR)
$(SEA_IMG_DIR) $(BUILD_DIR):
@mkdir -p $@
# ---- disk‑image generator -------------------------------------------------
IMG_SIZE_MIB ?= 64
DISK_IMG_PGM := $(SEA_IMG_DIR)/mkseaimg
SEA_DISK := $(BUILD_DIR)/sea-dos.img
$(DISK_IMG_PGM): $(SEA_IMG_DIR)/mkseaimg.c | $(SEA_IMG_DIR)
$(CC) -O2 -static -s -o $@ $<
# ---- sources --------------------------------------------------------------
EFISRC := efi.c
EFIOBJ := $(EFISRC:%.c=%_$(ARCH).o)
EFI_APP := BOOTX64.EFI # PE32+ output
KERNEL_SRC := kernel.c
KERNEL := kernel.elf # ELF64 PIE
FONT := ter-132n.psf # bitmap font
# ---- compiler flags -------------------------------------------------------
COMMON_CFLAGS := -std=c17 -Wall -Wextra -Wpedantic -ffreestanding \
-mno-red-zone -fno-stack-protector -I include \
-DARCH=$(ARCH)
KERNEL_CFLAGS := $(COMMON_CFLAGS) -fPIE
KERNEL_LDFLAGS := -nostdlib -pie -e kmain
DEPENDS := $(EFIOBJ:.o=.d) $(KERNEL_SRC:.c=.d)
# ---- targets --------------------------------------------------------------
all: $(SEA_DISK) # default build
# ----- UEFI application (PE32+)
$(EFI_APP): $(EFIOBJ)
$(EFICC) $(EFI_LDFLAGS) -o $@ $<
$(EFIOBJ): $(EFISRC)
$(EFICC) $(COMMON_CFLAGS) -c -o $@ $<
# ----- Kernel (ELF64 PIE)
$(KERNEL): $(KERNEL_SRC)
$(ELFCC) $(KERNEL_CFLAGS) $(KERNEL_LDFLAGS) -o $@ $<
# ----- Disk image (GPT + FAT32)
$(SEA_DISK): $(DISK_IMG_PGM) $(EFI_APP) $(KERNEL) $(FONT) | $(BUILD_DIR)
$(DISK_IMG_PGM) -o $@ -s $(IMG_SIZE_MIB) \
-ae /EFI/BOOT/$(EFI_APP) $(EFI_APP) \
-ad $(KERNEL) kernel.elf \
-ad $(FONT) $(FONT)
@echo "Disk image created: $@"
# ----- Launch QEMU
.PHONY: run
run: $(SEA_DISK)
@if [ -z "$(OVMF)" ]; then \
echo "ERROR: OVMF firmware not found. Pass OVMF=<file>"; exit 1; fi
$(QEMU_SCRIPT) $(SEA_DISK) $(OVMF)
# ----- clean
.PHONY: clean
clean:
rm -f $(EFI_APP) $(EFIOBJ) $(KERNEL) *.o *.d *.elf *.EFI *.efi
rm -f $(SEA_DISK) $(DISK_IMG_PGM)
-include $(DEPENDS)
If anyone wants to try to fix the problem directly, the project is here -
https://github.com/mooseman/Sea-DOS
If you clone that, go into the /Sea-DOS/efi_c directory and run this command -
make run OVMF=/usr/share/OVMF/OVMF_CODE_4M.fd
It just seems that I'm *so close* to getting things to boot so if anyone is able to help out with this problem, that'd be hugely appreciated!
Many thanks in advance -
- trilobite