initial commit
authorJohn Tsiombikas <nuclear@member.fsf.org>
Fri, 22 Mar 2019 23:11:24 +0000 (01:11 +0200)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Fri, 22 Mar 2019 23:11:24 +0000 (01:11 +0200)
.gitignore [new file with mode: 0644]
Makefile [new file with mode: 0644]
test.c [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..17b4882
--- /dev/null
@@ -0,0 +1,6 @@
+*.o
+*.d
+*.swp
+*.img
+*.efi
+*.so
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..787921f
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,27 @@
+obj = test.o
+efiso = test.so
+efibin = bootx64.efi
+
+inc = -I/usr/include/efi -I/usr/include/efi/x86_64 -I/usr/include/efi/protocol
+def = -DEFI_FUNCTION_WRAPPER
+eficrt = /usr/lib/crt0-efi-x86_64.o
+ldscript = /usr/lib/elf_x86_64_efi.lds
+
+CFLAGS = -pedantic -Wall $(inc) $(def) -fno-stack-protector -fPIC -fshort-wchar \
+                -mno-red-zone
+LDFLAGS = -nostdlib -znocombreloc -T $(ldscript) -L/usr/lib $(eficrt) -lefi -lgnuefi
+
+.PHONY: all
+all: $(efibin)
+
+$(efiso): $(obj)
+       $(LD) -o $@ -shared -Bsymbolic $(obj) $(LDFLAGS)
+
+$(efibin): $(efiso)
+       objcopy -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel \
+               -j .rela -j .reloc --target=efi-app-x86_64 $< $@
+
+
+.PHONY: clean
+clean:
+       rm -f $(obj) $(efibin) $(efiso)
diff --git a/test.c b/test.c
new file mode 100644 (file)
index 0000000..2b80863
--- /dev/null
+++ b/test.c
@@ -0,0 +1,16 @@
+#include <efi.h>
+#include <efilib.h>
+#include <efiprot.h>
+
+EFI_STATUS EFIAPI efi_main(EFI_HANDLE img, EFI_SYSTEM_TABLE *systab)
+{
+       InitializeLib(img, systab);
+       Print(L"hello world\n");
+
+       asm volatile("cli");
+       for(;;) {
+               asm volatile("hlt");
+       }
+
+       return EFI_SUCCESS;
+}