Moved check_status to a header file and properly case/named it

This commit is contained in:
Justin C. Miller
2017-01-03 08:14:16 -08:00
parent 2397618a68
commit eeaf27bbdf
2 changed files with 13 additions and 6 deletions

View File

@@ -1,9 +1,7 @@
//#define EFIAPI __attribute__((ms_abi))
#include <efi.h> #include <efi.h>
#include <efilib.h> #include <efilib.h>
#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_STATUS
efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) 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_GRAPHICS_OUTPUT_PROTOCOL *gfx_out_proto;
EFI_GUID gfx_out_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; EFI_GUID gfx_out_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
status = SystemTable->BootServices->LocateProtocol(&gfx_out_guid, NULL, (void**)&gfx_out_proto); 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; const uint32_t modes = gfx_out_proto->Mode->MaxMode;
uint32_t res = uint32_t res =
@@ -31,7 +29,7 @@ efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
UINTN size = 0; UINTN size = 0;
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info = NULL; EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info = NULL;
status = gfx_out_proto->QueryMode(gfx_out_proto, i, &size, &info); 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 = const uint32_t new_res =
info->HorizontalResolution * info->HorizontalResolution *
@@ -45,7 +43,7 @@ efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
if (best != (uint32_t)-1) { if (best != (uint32_t)-1) {
status = gfx_out_proto->SetMode(gfx_out_proto, best); status = gfx_out_proto->SetMode(gfx_out_proto, best);
check_status(status, "SetMode"); CHECK_EFI_STATUS_OR_RETURN(status, "SetMode");
Print(L"*"); Print(L"*");
} }
Print(L"%ux%u\n", Print(L"%ux%u\n",

View File

@@ -0,0 +1,9 @@
#include <efi.h>
#include <efilib.h>
#define CHECK_EFI_STATUS_OR_RETURN(s, msg) \
if (EFI_ERROR((s))) { \
Print(L"EFI_ERROR: " msg L" %d\n", (s)); \
return (s); \
}