[feat] Use gnu-efi
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
build/
|
build/
|
||||||
vdir/
|
vdir/
|
||||||
.vscode/
|
.vscode/
|
||||||
|
serial.log
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "gnu-efi"]
|
||||||
|
path = gnu-efi
|
||||||
|
url = https://github.com/ncroxon/gnu-efi.git
|
||||||
@@ -1,10 +1,8 @@
|
|||||||
MINGW_GCC = x86_64-w64-mingw32-gcc
|
|
||||||
QEMU = qemu-system-x86_64
|
|
||||||
MINGW_GCC_FLAGS = -Wall -Wextra -e efi_main -nostdinc -nostdlib -fno-builtin -Wl,--subsystem,10
|
|
||||||
|
|
||||||
all:
|
all:
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
x86_64-w64-mingw32-gcc $(MINGW_GCC_FLAGS) -o build/BOOTX64.EFI boot.c
|
gcc -Ignu-efi/inc -fpic -ffreestanding -fno-stack-protector -fno-stack-check -fshort-wchar -mno-red-zone -maccumulate-outgoing-args -c boot.c -o build/boot.o
|
||||||
|
ld -shared -Bsymbolic -Lgnu-efi/x86_64/lib -Lgnu-efi/x86_64/gnuefi -Tgnu-efi/gnuefi/elf_x86_64_efi.lds gnu-efi/x86_64/gnuefi/crt0-efi-x86_64.o build/boot.o -o build/boot.so -lgnuefi -lefi
|
||||||
|
objcopy -j .text -j .sdata -j .data -j .rodata -j .dynamic -j .dynsym -j .rel -j .rela -j .rel.* -j .rela.* -j .reloc --output-target efi-app-x86_64 --subsystem=10 build/boot.so build/BOOTX64.EFI
|
||||||
|
|
||||||
vdir: all
|
vdir: all
|
||||||
mkdir -p vdir
|
mkdir -p vdir
|
||||||
@@ -12,7 +10,9 @@ vdir: all
|
|||||||
cp build/BOOTX64.EFI vdir/EFI/BOOT
|
cp build/BOOTX64.EFI vdir/EFI/BOOT
|
||||||
|
|
||||||
run: vdir
|
run: vdir
|
||||||
$(QEMU) -bios /usr/share/ovmf/OVMF.fd -net none -drive file=fat:rw:vdir,index=0,format=vvfat -serial stdio
|
qemu-system-x86_64 -bios /usr/share/ovmf/OVMF.fd -net none -drive file=fat:rw:vdir,index=0,format=vvfat -serial file:serial.log
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf build vdir
|
rm -rf build vdir
|
||||||
|
|
||||||
|
.PHONY: all vdir run clean
|
||||||
@@ -1,22 +1,9 @@
|
|||||||
#define ull unsigned long long
|
#include <efi.h>
|
||||||
|
#include <efilib.h>
|
||||||
|
|
||||||
struct EFI_SYSTEM_TABLE {
|
EFI_STATUS EFIAPI efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) {
|
||||||
char _buf[60];
|
InitializeLib(ImageHandle, SystemTable);
|
||||||
struct EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL {
|
Print(L"Hello, world!\n");
|
||||||
ull _buf;
|
|
||||||
ull (*OutputString)(
|
|
||||||
struct EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
|
|
||||||
unsigned short *String);
|
|
||||||
ull _buf2[4];
|
|
||||||
ull (*ClearScreen)(
|
|
||||||
struct EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This);
|
|
||||||
} *ConOut;
|
|
||||||
};
|
|
||||||
|
|
||||||
void efi_main(void *ImageHandle __attribute__ ((unused)), struct EFI_SYSTEM_TABLE *SystemTable)
|
|
||||||
{
|
|
||||||
SystemTable->ConOut->ClearScreen(SystemTable->ConOut);
|
|
||||||
SystemTable->ConOut->OutputString(SystemTable->ConOut, L"Hello UEFI!\n");
|
|
||||||
while (1);
|
while (1);
|
||||||
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Submodule
+1
Submodule gnu-efi added at 8a45cdb08c
Reference in New Issue
Block a user