Apple Screen Info

From OSDev Wiki
Jump to navigation Jump to search

Before the introduction of GOP to Apple Macs in 2009, Apple used a proprietary protocol known as Apple Screen Info to serve graphics information. This is the best way to get framebuffer paramaters on any Mac made before 2009.

Definitions

These should be placed in a header file or in the main EFI program.

#define APPLE_SCREEN_INFO_PROTOCOL_GUID {0xe316e100, 0x0751, 0x4c49, {0x90, 0x56, 0x48, 0x6c, 0x7e, 0x47, 0x29, 0x03}}

typedef struct _APPLE_SCREEN_INFO_PROTOCOL APPLE_SCREEN_INFO_PROTOCOL;

typedef EFI_STATUS (EFIAPI *GetAppleScreenInfo)(APPLE_SCREEN_INFO_PROTOCOL *This, UINT64 *BaseAddress, UINT64 *FrameBufferSize, UINT32 *BytesPerRow, UINT32 *Width, UINT32 *Height, UINT32 *Depth);

struct _APPLE_SCREEN_INFO_PROTOCOL {
    GetAppleScreenInfo GetInfo;
};

Detection

EFI_GUID AppleScreenInfoGuid = APPLE_SCREEN_INFO_PROTOCOL_GUID;
APPLE_SCREEN_INFO_PROTOCOL *AppleScreenInfo;
UINT64 BaseAddress, FrameBufferSize;
UINT32 BytesPerRow, Width, Height, Depth;

Status = uefi_call_wrapper(gBS->LocateProtocol, 3, &AppleScreenInfoGuid, NULL, (VOID **) &AppleScreenInfo); // leave out uefi_call_wrapper if using TianoCore
if (Status != EFI_SUCCESS)
{
    Print(L"Failed to find Apple Screen Info protocol! Status = %d\n", Status);
    return Status;
}
Status = uefi_call_wrapper(AppleScreenInfo->GetInfo, 7, AppleScreenInfo, &BaseAddress, &FrameBufferSize, &BytesPerRow, &Width, &Height, &Depth);
if (Status != UEFI_SUCCESS)
{
    Print(L"Failed to get Apple Screen Information! Status = %d\n", Status);
    return Status;
}

With Apple Screen Info, the framebuffer is always assumed to be a 4bpp BGRA framebuffer.