mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
Initial commit - UEFI application building
This commit is contained in:
6
src/arch/x86_64/config.mk
Normal file
6
src/arch/x86_64/config.mk
Normal 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
32
src/arch/x86_64/kernel.ld
Normal 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
30
src/arch/x86_64/main.c
Normal 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user