From eeaf27bbdfe049fbcc05b513697e9c26f24e3f7a Mon Sep 17 00:00:00 2001 From: "Justin C. Miller" Date: Tue, 3 Jan 2017 08:14:16 -0800 Subject: [PATCH] Moved check_status to a header file and properly case/named it --- src/arch/x86_64/main.c | 10 ++++------ src/arch/x86_64/utility.h | 9 +++++++++ 2 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 src/arch/x86_64/utility.h diff --git a/src/arch/x86_64/main.c b/src/arch/x86_64/main.c index 6f42fcc..272bb04 100644 --- a/src/arch/x86_64/main.c +++ b/src/arch/x86_64/main.c @@ -1,9 +1,7 @@ -//#define EFIAPI __attribute__((ms_abi)) - #include #include -#define check_status(s, msg) if(EFI_ERROR((s))){Print(L"EFI_ERROR: " msg L" %d\n", (s)); return (s);} +#include "utility.h" EFI_STATUS efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) @@ -19,7 +17,7 @@ efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) EFI_GRAPHICS_OUTPUT_PROTOCOL *gfx_out_proto; EFI_GUID gfx_out_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; status = SystemTable->BootServices->LocateProtocol(&gfx_out_guid, NULL, (void**)&gfx_out_proto); - check_status(status, "LocateProtocol gfx"); + CHECK_EFI_STATUS_OR_RETURN(status, "LocateProtocol gfx"); const uint32_t modes = gfx_out_proto->Mode->MaxMode; uint32_t res = @@ -31,7 +29,7 @@ efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) UINTN size = 0; EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info = NULL; status = gfx_out_proto->QueryMode(gfx_out_proto, i, &size, &info); - check_status(status, "QueryMode"); + CHECK_EFI_STATUS_OR_RETURN(status, "QueryMode"); const uint32_t new_res = info->HorizontalResolution * @@ -45,7 +43,7 @@ efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) if (best != (uint32_t)-1) { status = gfx_out_proto->SetMode(gfx_out_proto, best); - check_status(status, "SetMode"); + CHECK_EFI_STATUS_OR_RETURN(status, "SetMode"); Print(L"*"); } Print(L"%ux%u\n", diff --git a/src/arch/x86_64/utility.h b/src/arch/x86_64/utility.h new file mode 100644 index 0000000..8cf715c --- /dev/null +++ b/src/arch/x86_64/utility.h @@ -0,0 +1,9 @@ +#include +#include + +#define CHECK_EFI_STATUS_OR_RETURN(s, msg) \ + if (EFI_ERROR((s))) { \ + Print(L"EFI_ERROR: " msg L" %d\n", (s)); \ + return (s); \ + } +