Initial commit - UEFI application building

This commit is contained in:
Justin C. Miller
2017-01-02 13:40:42 -08:00
commit 89c2c70c28
13 changed files with 596 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
AS := nasm
ASFLAGS := -felf
LDFLAGS := -m elf_x86_64
CFLAGS := -march=nocona -m64
# vim:ft=make

32
src/arch/x86_64/kernel.ld Normal file
View File

@@ -0,0 +1,32 @@
ENTRY(start)
SECTIONS
{
. = 0x100000;
.__mbHeader : {
mboot = .;
*(.__mbHeader)
. = ALIGN(4096);
}
.text : {
code = .;
*(.text)
. = ALIGN(4096);
}
.data : {
data = .;
*(.data)
*(.rodata)
. = ALIGN(4096);
}
.bss : {
bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .;
}

30
src/arch/x86_64/main.c Normal file
View File

@@ -0,0 +1,30 @@
//#define EFIAPI __attribute__((ms_abi))
#include <efi.h>
#include <efilib.h>
#define check_status(s, msg) if(EFI_ERROR((s))){Print(L"EFI_ERROR: " msg L" %d\n", (s)); return (s);}
EFI_STATUS
efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
EFI_STATUS status;
InitializeLib(ImageHandle, SystemTable);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
status = ST->ConOut->OutputString(ST->ConOut, L"Hello from UEFI\n\r");
#pragma GCC diagnostic pop
check_status(status, L"OutputString");
Print(L" SystemTable: %x\n", SystemTable);
if (SystemTable)
Print(L" ConOut: %x\n", SystemTable->ConOut);
if (SystemTable->ConOut)
Print(L"OutputString: %x\n", SystemTable->ConOut->OutputString);
while (1) __asm__("hlt");
return status;
}