28 IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
30 OUT UINTN *SizeOfInfo,
31 OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info
34 if (ModeNumber != 0) {
35 DEBUG ((DEBUG_VERBOSE,
"OCC: OcGopDrawQueryMode invalid ModeNumber - %u\n", ModeNumber));
36 return EFI_INVALID_PARAMETER;
39 if ((SizeOfInfo == NULL) || (Info == NULL)) {
40 DEBUG ((DEBUG_VERBOSE,
"OCC: OcGopDrawQueryMode got invalid parameter SizeOfInfo or Info!\n"));
41 return EFI_INVALID_PARAMETER;
44 *SizeOfInfo = This->Mode->SizeOfInfo;
45 *Info = AllocateCopyPool (This->Mode->SizeOfInfo, This->Mode->Info);
47 DEBUG ((DEBUG_VERBOSE,
"OCC: OcGopDrawQueryMode failed to allocate memory for GOP Info!\n"));
48 return EFI_DEVICE_ERROR;
77 IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
78 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer OPTIONAL,
79 IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,
82 IN UINTN DestinationX,
83 IN UINTN DestinationY,
86 IN UINTN Delta OPTIONAL
93 return OcGopDraw->
Uga->Blt (
95 (EFI_UGA_PIXEL *)BltBuffer,
96 (EFI_UGA_BLT_OPERATION)BltOperation,
114 EFI_HANDLE *HandleBuffer;
116 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
117 EFI_UGA_DRAW_PROTOCOL *UgaDraw;
120 EFI_PHYSICAL_ADDRESS FramebufferBase;
121 UINT32 FramebufferSize;
122 UINT32 ScreenRowBytes;
126 UINT32 HorizontalResolution;
127 UINT32 VerticalResolution;
128 EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
131 BOOLEAN HasAppleFramebuffer;
138 Status =
gBS->LocateProtocol (
141 (VOID *)&FramebufferInfo
143 HasAppleFramebuffer = !EFI_ERROR (Status);
147 DEBUG ((DEBUG_INFO,
"OCC: Found %u handles with GOP draw\n", HandleCount));
150 DEBUG ((DEBUG_INFO,
"OCC: Found %u handles with Apple Framebuffer info\n", HandleCount));
152 if (EFI_ERROR (Status)) {
153 DEBUG ((DEBUG_INFO,
"OCC: Failed to locate AppleFramebufferInfo protocol - %r\n", Status));
155 Status = FramebufferInfo->
GetInfo (
164 if (!EFI_ERROR (Status)) {
167 "OCC: AppleFramebufferInfo - Got Base %Lx, Size %u, RowBytes %u, Width %u, Height %u, Depth %u\n",
176 DEBUG ((DEBUG_INFO,
"OCC: AppleFramebufferInfo failed to retrieve info - %r\n", Status));
182 Status =
gBS->LocateHandleBuffer (
189 if (EFI_ERROR (Status)) {
190 DEBUG ((DEBUG_INFO,
"OCC: Failed to find handles with UGA - %r\n", Status));
194 DEBUG ((DEBUG_INFO,
"OCC: Found %u handles with UGA for GOP check\n", (UINT32)HandleCount));
195 for (Index = 0; Index < HandleCount; ++Index) {
196 DEBUG ((DEBUG_INFO,
"OCC: Trying handle %u - %p\n", (UINT32)Index, HandleBuffer[Index]));
198 Status =
gBS->HandleProtocol (
203 if (EFI_ERROR (Status)) {
204 DEBUG ((DEBUG_INFO,
"OCC: No UGA protocol - %r\n", Status));
208 Status =
gBS->HandleProtocol (
211 (VOID **)&GraphicsOutput
213 if (!EFI_ERROR (Status)) {
214 DEBUG ((DEBUG_INFO,
"OCC: Skipping GOP proxying as it is already present on handle %u - %p\n", (UINT32)Index, HandleBuffer[Index]));
221 PixelFormat = PixelBltOnly;
223 Status =
gBS->HandleProtocol (
226 (VOID **)&FramebufferInfo
228 if (EFI_ERROR (Status)) {
231 "OCC: Failed to retrieve AppleFramebufferInfo protocol on handle %u - %p (%r)\n",
236 if (HasAppleFramebuffer || !ForAll) {
242 "OCC: Got AppleFramebufferInfo protocol on handle %u - %p\n",
247 Status = FramebufferInfo->GetInfo (
256 if (!EFI_ERROR (Status)) {
257 PixelFormat = PixelRedGreenBlueReserved8BitPerColor;
261 "OCC: AppleFramebufferInfo - Got Base %Lx, Size %u, RowBytes %u, Width %u, Height %u, Depth %u on handle %u - %p\n",
274 "OCC: Failed to get info from AppleFramebufferInfo protocol on handle %u - %p (%r)\n",
279 if (HasAppleFramebuffer) {
285 Status = UgaDraw->GetMode (
287 &HorizontalResolution,
292 if (EFI_ERROR (Status)) {
293 DEBUG ((DEBUG_INFO,
"OCC: UGA->GetMode returns error - %r\n", Status));
297 OcGopDraw = AllocateZeroPool (
sizeof (*OcGopDraw));
298 if (OcGopDraw == NULL) {
299 DEBUG ((DEBUG_INFO,
"OCC: Failed to allocate GOP protocol\n"));
303 OcGopDraw->
Uga = UgaDraw;
309 FreePool (OcGopDraw);
324 FreePool (OcGopDraw);
329 OcGopDraw->
GraphicsOutput.Mode->Info->HorizontalResolution = HorizontalResolution;
330 OcGopDraw->
GraphicsOutput.Mode->Info->VerticalResolution = VerticalResolution;
340 OcGopDraw->
GraphicsOutput.Mode->Info->PixelsPerScanLine = ScreenRowBytes /
sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
342 OcGopDraw->
GraphicsOutput.Mode->FrameBufferBase = FramebufferBase;
343 OcGopDraw->
GraphicsOutput.Mode->FrameBufferSize = FramebufferSize;
345 Status =
gBS->InstallMultipleProtocolInterfaces (
346 &HandleBuffer[Index],
351 if (EFI_ERROR (Status)) {
354 FreePool (OcGopDraw);
359 "OCC: Installed GOP protocol - %r (Handle %u - %p, Resolution %ux%u, FramebufferBase %Lx, PixelFormat %d)\n",
363 HorizontalResolution,
370 FreePool (HandleBuffer);
STATIC EFI_STATUS EFIAPI OcGopDrawBlt(IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer OPTIONAL, IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation, IN UINTN SourceX, IN UINTN SourceY, IN UINTN DestinationX, IN UINTN DestinationY, IN UINTN Width, IN UINTN Height, IN UINTN Delta OPTIONAL)