Reduce dependency on efi library functions

This commit is contained in:
Justin C. Miller
2018-03-31 17:32:10 -07:00
parent a09a25d3e6
commit 165ed28cd3
10 changed files with 375 additions and 109 deletions

View File

@@ -6,27 +6,27 @@
const CHAR16 *util_error_message(EFI_STATUS status);
#define CHECK_EFI_STATUS_OR_RETURN(s, msg, ...) \
if (EFI_ERROR((s))) { \
Print(L"EFI_ERROR: " msg L": %s\n", ##__VA_ARGS__, util_error_message(s)); \
return (s); \
#define CHECK_EFI_STATUS_OR_RETURN(s, msg, ...) \
if (EFI_ERROR((s))) { \
con_printf(L"EFI_ERROR: " msg L": %s\n", ##__VA_ARGS__, util_error_message(s)); \
return (s); \
}
#define CHECK_EFI_STATUS_OR_FAIL(s) \
if (EFI_ERROR((s))) { \
#define CHECK_EFI_STATUS_OR_FAIL(s) \
if (EFI_ERROR((s))) { \
con_status_fail(util_error_message(s)); \
while (1) __asm__("hlt"); \
while (1) __asm__("hlt"); \
}
#define CHECK_EFI_STATUS_OR_ASSERT(s, d) \
if (EFI_ERROR((s))) { \
__asm__ __volatile__( \
"movq %0, %%r8;" \
"movq %1, %%r9;" \
"movq %2, %%r10;" \
"movq $0, %%rdx;" \
"divq %%rdx;" \
: \
#define CHECK_EFI_STATUS_OR_ASSERT(s, d) \
if (EFI_ERROR((s))) { \
__asm__ __volatile__( \
"movq %0, %%r8;" \
"movq %1, %%r9;" \
"movq %2, %%r10;" \
"movq $0, %%rdx;" \
"divq %%rdx;" \
: \
: "r"((uint64_t)s), "r"((uint64_t)d), "r"((uint64_t)__LINE__) \
: "rax", "rdx", "r8", "r9", "r10"); \
: "rax", "rdx", "r8", "r9", "r10"); \
}