Add UEFI support

This is mutually exclusive with Windows support. Documentation for how
to use it has been written in libc/runtime/efimain.c
This commit is contained in:
Justine Tunney 2021-02-21 16:26:36 -08:00 committed by Justine Tunney
parent c6c9b5dfde
commit 537c21338b
24 changed files with 1381 additions and 391 deletions

View file

@ -104,7 +104,7 @@ __systemfive:
.privileged
.Lanchorpoint:
#if SupportsLinux() || SupportsMetal()
#if SupportsLinux() || SupportsMetal() || SupportsUefi()
systemfive_linux:
and $0xfff,%eax
cmp $0xfff,%eax
@ -194,14 +194,18 @@ systemfive_xnu:
.init.start 300,_init_systemfive
push %rbx
push %rsi
#if SupportsMetal()
testb $METAL,(%rdi) # @see ape/ape.S
jnz _init_systemfive_metal
#endif
#if SupportsXnu()
testb $XNU,(%rdi) # @see libc/crt/crt.S
jnz _init_systemfive_xnu
#endif
#if SupportsUefi()
testb $UEFI,(%rdi) # @see ape/ape.S
jnz _init_systemfive_uefi
#endif
#if SupportsMetal()
testb $METAL,(%rdi) # @see ape/ape.S
jnz _init_systemfive_metal
#endif
#if SupportsFreebsd()
testb $FREEBSD,(%rdi) # @see libc/crt/crt.S
jnz _init_systemfive_freebsd
@ -222,7 +226,7 @@ systemfive_xnu:
lea 2(%eax),%eax
jnz 0b
#endif
#if SupportsLinux() || SupportsMetal()
#if SupportsLinux()
_init_systemfive_linux:
pushb systemfive_linux-.Lanchorpoint
push $LINUX
@ -236,6 +240,13 @@ _init_systemfive_metal:
ezlea syscon_linux,si
jmp _init_systemfive_os
#endif
#if SupportsUefi()
_init_systemfive_uefi:
pushb systemfive_linux-.Lanchorpoint
push $UEFI
ezlea syscon_linux,si
jmp _init_systemfive_os
#endif
#if SupportsWindows()
_init_systemfive_windows:
pushb systemfive_enosys-.Lanchorpoint
@ -312,8 +323,8 @@ _init_systemfive_magnums:
// 𝑠𝑙𝑖𝑑𝑒
#if SupportsSystemv() && !defined(TINY)
_init_systemfive_stack: # determinism ftw!
#if SupportsWindows()
testb IsWindows() # already did this
#if SupportsWindows() || SupportsMetal() || SupportsUefi()
testb $WINDOWS|METAL|UEFI,__hostos(%rip)
jnz _init_systemfive_done
#endif
push %rdi
@ -403,7 +414,7 @@ syscon_end:
.type syscon_end,@object
.globl syscon_start
.globl syscon_end
#if SupportsLinux() || SupportsMetal()
#if SupportsLinux() || SupportsMetal() || SupportsUefi()
.section .sort.rodata.syscon.linux.1,"a",@progbits
.align 1
syscon_linux:/*