Apple Screen Info: Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content added Content deleted
(Created page with "Before the introduction of GOP to Apple Macs in 2009, Apple used a proprietary protocol known as Apple Screen Info to serve graphics information === Definitions === These...")
 
m (Bot: Replace deprecated source tag with syntaxhighlight)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
Before the introduction of [[GOP]] to Apple Macs in 2009, Apple used a proprietary protocol known as Apple Screen Info to serve graphics information
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 ===
=== Definitions ===
These should be placed in a header file or in the main EFI program.
These should be placed in a header file or in the main EFI program.


<source lang="c">
<syntaxhighlight lang="c">
#define APPLE_SCREEN_INFO_PROTOCOL_GUID {0xe316e100, 0x0751, 0x4c49, {0x90, 0x56, 0x48, 0x6c, 0x7e, 0x47, 0x29, 0x03}}
#define APPLE_SCREEN_INFO_PROTOCOL_GUID {0xe316e100, 0x0751, 0x4c49, {0x90, 0x56, 0x48, 0x6c, 0x7e, 0x47, 0x29, 0x03}}


Line 14: Line 14:
GetAppleScreenInfo GetInfo;
GetAppleScreenInfo GetInfo;
};
};
</syntaxhighlight>
</source>


=== Detection ===
=== Detection ===
<source lang="c">
<syntaxhighlight lang="c">
EFI_GUID AppleScreenInfoGuid = APPLE_SCREEN_INFO_PROTOCOL_GUID;
EFI_GUID AppleScreenInfoGuid = APPLE_SCREEN_INFO_PROTOCOL_GUID;
APPLE_SCREEN_INFO_PROTOCOL *AppleScreenInfo;
APPLE_SCREEN_INFO_PROTOCOL *AppleScreenInfo;
UINT64 BaseAddress, FrameBufferSize;
UINT64 BaseAddress, FrameBufferSize;
UINT32 BytesPerRow, Width, Height, Depth;
UINT32 BytesPerRow, Width, Height, Depth;


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

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

Latest revision as of 04:12, 9 June 2024

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.