mirror of
https://github.com/badcf00d/UEFI-helloworld
synced 2026-08-26 10:26:04 -04:00
Refactoring to make the project more friendly
This commit is contained in:
parent
06c51f7a10
commit
331c735f0c
7 changed files with 26 additions and 17 deletions
32
Makefile
32
Makefile
|
|
@ -1,27 +1,27 @@
|
|||
NASM = nasm
|
||||
NASMFLAGS = -f win64
|
||||
STANDALONE_FLAGS = -Dfill_sector
|
||||
ASM = nasm
|
||||
ASMFLAGS = -f win64
|
||||
|
||||
LINKER = clang
|
||||
LLD-FLAGS = --target=x86_64-unknown-windows -nostdlib -Wl,-entry:_start -Wl,-subsystem:efi_application -fuse-ld=lld
|
||||
|
||||
SRC_DIR = .
|
||||
SRC_DIR = src
|
||||
OBJ_DIR = obj
|
||||
EFI_DIR = efi
|
||||
INC_DIR = inc
|
||||
|
||||
SRC = $(wildcard $(SRC_DIR)/*.asm)
|
||||
|
||||
OBJ_DIR = .
|
||||
OBJ = $(SRC:.asm=.obj)
|
||||
OBJ = $(SRC:$(SRC_DIR)/%.asm=$(OBJ_DIR)/%.obj)
|
||||
|
||||
EFI = uefi.efi
|
||||
BIOS = bios.bin
|
||||
EFI = $(EFI_DIR)/uefi.efi
|
||||
BIOS = $(wildcard $(INC_DIR)/*.bios)
|
||||
BOOT_DRIVE = uefi.img
|
||||
|
||||
.PHONY: clean qemu all standalone vhd
|
||||
.PHONY: clean qemu all img
|
||||
|
||||
all: $(OBJ)
|
||||
$(LINKER) $(LLD-FLAGS) -o $(EFI) $<
|
||||
|
||||
standalone: NASMFLAGS += $(STANDALONE_FLAGS)
|
||||
standalone: $(OBJ)
|
||||
make img
|
||||
|
||||
clean:
|
||||
rm -f $(OBJ) $(BOOT_DRIVE) $(EFI)
|
||||
|
|
@ -30,12 +30,12 @@ qemu:
|
|||
qemu-system-x86_64 -bios $(BIOS) -drive file=$(BOOT_DRIVE),format=raw
|
||||
|
||||
# needs dosfstools and mtools
|
||||
vhd:
|
||||
img:
|
||||
dd if=/dev/zero of=$(BOOT_DRIVE) bs=1M count=1
|
||||
mkfs.vfat $(BOOT_DRIVE)
|
||||
mmd -i $(BOOT_DRIVE) ::EFI
|
||||
mmd -i $(BOOT_DRIVE) ::EFI/BOOT
|
||||
mcopy -i $(BOOT_DRIVE) uefi.efi ::EFI/BOOT/BOOTX64.EFI
|
||||
mcopy -i $(BOOT_DRIVE) $(EFI) ::EFI/BOOT/BOOTX64.EFI
|
||||
|
||||
%.obj: %.asm
|
||||
$(NASM) $(NASMFLAGS) -o $@ $<
|
||||
$(OBJ_DIR)/%.obj: $(SRC_DIR)/%.asm
|
||||
$(ASM) $(ASMFLAGS) -o $@ $<
|
||||
|
|
|
|||
11
README.md
11
README.md
|
|
@ -1,2 +1,11 @@
|
|||
# UEFI-helloworld
|
||||
A hello world example for UEFI
|
||||
A hello world example for UEFI written in x86 NASM assembly
|
||||
|
||||
#### How to use:
|
||||
Running `make` will:
|
||||
- Assemble the files from `src` into win64 object files, and put them in `obj`
|
||||
- Link the win64 object files from `obj` into a PE32+ executable, and put it in `efi`
|
||||
- Create a FAT32 .img file and move the PE32+ executable into that .img file at the location `EFI/BOOT/BOOTX64.EFI`
|
||||
|
||||
You can then run `make qemu` to boot that PE32+ executable with the UEFI provided by the <a href="https://github.com/tianocore/tianocore.github.io/wiki/OVMF">OVMF project</a> that's stored in `inc`.
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
BIN
uefi.img
BIN
uefi.img
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue