CorebootPayloadPkg/FbGop: Locate correct framebuffer device

BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1628

Current FbGop driver might bind to the wrong PCI device
if a system has multiple PCI display devices. The original
idea was to reuse the generic GraphicsOutputDxe to address
this issue. However, after exploring different approaches
discussed in the bugzilla, it turned out that the best
approach is to enhance the current FbGop driver to match
the PCI device BAR value with the framebuffer base address.
This patch implemented this enhancement by selecting the
PCI device with matched framebuffer base in its PCI BAR.

This has been tested with coreboot on QEMU and Apollo Lake
platform.

Cc: Prince Agyeman <prince.agyeman@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Maurice Ma <maurice.ma@intel.com>
Reviewed-by: Benjamin You <benjamin.you@intel.com>
This commit is contained in:
Maurice Ma 2019-04-01 15:35:38 -07:00
parent a281361014
commit ae2fb9ead4
1 changed files with 129 additions and 113 deletions

View File

@ -16,7 +16,7 @@ EFI_PIXEL_BITMASK mPixelBitMask = {0x0000FF, 0x00FF00, 0xFF0000, 0x000000};
// //
UINT64 mOriginalPciAttributes; UINT64 mOriginalPciAttributes;
BOOLEAN mPciAttributesSaved = FALSE; BOOLEAN mPciAttributesSaved = FALSE;
FRAME_BUFFER_INFO *mFrameBufferInfo;
// //
// EFI Driver Binding Protocol Instance // EFI Driver Binding Protocol Instance
@ -57,10 +57,12 @@ FbGopDriverBindingSupported (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_PCI_IO_PROTOCOL *PciIo; EFI_PCI_IO_PROTOCOL *PciIo;
PCI_TYPE00 Pci; PCI_TYPE00 Pci;
EFI_DEV_PATH *Node; EFI_DEV_PATH *Node;
UINT8 Index;
EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Resources;
// //
// Open the IO Abstraction(s) needed to perform the supported test // Open the IO Abstraction(s) needed to perform the supported test
@ -94,28 +96,45 @@ FbGopDriverBindingSupported (
} }
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
if (Pci.Hdr.ClassCode[2] == 0x03 || (Pci.Hdr.ClassCode[2] == 0x00 && Pci.Hdr.ClassCode[1] == 0x01)) { if (IS_PCI_DISPLAY (&Pci) || IS_PCI_OLD_VGA (&Pci)) {
//
// Check if PCI BAR matches the framebuffer base
//
Status = EFI_UNSUPPORTED;
for (Index = 0; Index < PCI_MAX_BAR; Index++) {
Status = PciIo->GetBarAttributes (PciIo, Index, NULL, (VOID**) &Resources);
if (!EFI_ERROR (Status)) {
if ((Resources->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) &&
(Resources->Len == (UINT16) (sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3)) &&
(Resources->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) &&
(Resources->AddrRangeMin == mFrameBufferInfo->LinearFrameBuffer)) {
DEBUG ((DEBUG_INFO, "Found matched framebuffer PCI BAR !\n"));
Status = EFI_SUCCESS;
break;
}
}
}
Status = EFI_SUCCESS; if (!EFI_ERROR (Status)) {
//
// If this is a graphics controller,
// go further check RemainingDevicePath validation
//
if (RemainingDevicePath != NULL) {
Node = (EFI_DEV_PATH *) RemainingDevicePath;
// //
// Check if RemainingDevicePath is the End of Device Path Node, // If this is a graphics controller,
// if yes, return EFI_SUCCESS // go further check RemainingDevicePath
// //
if (!IsDevicePathEnd (Node)) { if (RemainingDevicePath != NULL) {
Node = (EFI_DEV_PATH *) RemainingDevicePath;
// //
// If RemainingDevicePath isn't the End of Device Path Node, // Check if RemainingDevicePath is the End of Device Path Node,
// check its validation // if yes, return EFI_SUCCESS
// //
if (Node->DevPath.Type != ACPI_DEVICE_PATH || if (!IsDevicePathEnd (Node)) {
Node->DevPath.SubType != ACPI_ADR_DP || //
DevicePathNodeLength(&Node->DevPath) < sizeof(ACPI_ADR_DEVICE_PATH)) { // Verify RemainingDevicePath
Status = EFI_UNSUPPORTED; //
if (Node->DevPath.Type != ACPI_DEVICE_PATH ||
Node->DevPath.SubType != ACPI_ADR_DP ||
DevicePathNodeLength(&Node->DevPath) < sizeof(ACPI_ADR_DEVICE_PATH)) {
Status = EFI_UNSUPPORTED;
}
} }
} }
} }
@ -154,11 +173,11 @@ FbGopDriverBindingStart (
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
EFI_PCI_IO_PROTOCOL *PciIo; EFI_PCI_IO_PROTOCOL *PciIo;
UINT64 Supports; UINT64 Supports;
DEBUG ((EFI_D_INFO, "GOP START\n")); DEBUG ((DEBUG_INFO, "GOP START\n"));
// //
// Initialize local variables // Initialize local variables
// //
@ -202,7 +221,7 @@ FbGopDriverBindingStart (
0, 0,
&mOriginalPciAttributes &mOriginalPciAttributes
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto Done; goto Done;
} }
@ -226,8 +245,8 @@ FbGopDriverBindingStart (
if (Supports == 0 || Supports == (EFI_PCI_IO_ATTRIBUTE_VGA_IO | EFI_PCI_IO_ATTRIBUTE_VGA_IO_16)) { if (Supports == 0 || Supports == (EFI_PCI_IO_ATTRIBUTE_VGA_IO | EFI_PCI_IO_ATTRIBUTE_VGA_IO_16)) {
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
goto Done; goto Done;
} }
REPORT_STATUS_CODE_WITH_DEVICE_PATH ( REPORT_STATUS_CODE_WITH_DEVICE_PATH (
EFI_PROGRESS_CODE, EFI_PROGRESS_CODE,
EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_PC_ENABLE, EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_PC_ENABLE,
@ -260,7 +279,7 @@ FbGopDriverBindingStart (
goto Done; goto Done;
} }
} }
// //
// Create child handle and install GraphicsOutputProtocol on it // Create child handle and install GraphicsOutputProtocol on it
// //
@ -272,10 +291,10 @@ FbGopDriverBindingStart (
ParentDevicePath, ParentDevicePath,
RemainingDevicePath RemainingDevicePath
); );
Done: Done:
if ((EFI_ERROR (Status)) && (Status != EFI_ALREADY_STARTED)) { if ((EFI_ERROR (Status)) && (Status != EFI_ALREADY_STARTED)) {
REPORT_STATUS_CODE_WITH_DEVICE_PATH ( REPORT_STATUS_CODE_WITH_DEVICE_PATH (
EFI_PROGRESS_CODE, EFI_PROGRESS_CODE,
EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_PC_DISABLE, EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_PC_DISABLE,
@ -358,7 +377,7 @@ FbGopDriverBindingStop (
} }
for (Index = 0; Index < NumberOfChildren; Index++) { for (Index = 0; Index < NumberOfChildren; Index++) {
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
FbGopChildHandleUninstall (This, Controller, ChildHandleBuffer[Index]); FbGopChildHandleUninstall (This, Controller, ChildHandleBuffer[Index]);
@ -380,7 +399,7 @@ FbGopDriverBindingStop (
(VOID **) &PciIo (VOID **) &PciIo
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
// //
// Restore original PCI attributes // Restore original PCI attributes
// //
@ -457,7 +476,7 @@ FbGopChildHandleInstall (
); );
goto Done; goto Done;
} }
// //
// Initialize the child private structure // Initialize the child private structure
// //
@ -465,16 +484,16 @@ FbGopChildHandleInstall (
// //
// Fill in Graphics Output specific mode structures // Fill in Graphics Output specific mode structures
// //
FbGopPrivate->ModeData = NULL; FbGopPrivate->ModeData = NULL;
FbGopPrivate->VbeFrameBuffer = NULL; FbGopPrivate->VbeFrameBuffer = NULL;
FbGopPrivate->EdidDiscovered.SizeOfEdid = 0; FbGopPrivate->EdidDiscovered.SizeOfEdid = 0;
FbGopPrivate->EdidDiscovered.Edid = NULL; FbGopPrivate->EdidDiscovered.Edid = NULL;
FbGopPrivate->EdidActive.SizeOfEdid = 0; FbGopPrivate->EdidActive.SizeOfEdid = 0;
FbGopPrivate->EdidActive.Edid = NULL; FbGopPrivate->EdidActive.Edid = NULL;
// //
// Fill in the Graphics Output Protocol // Fill in the Graphics Output Protocol
// //
@ -511,7 +530,7 @@ FbGopChildHandleInstall (
AcpiDeviceNode.Header.SubType = ACPI_ADR_DP; AcpiDeviceNode.Header.SubType = ACPI_ADR_DP;
AcpiDeviceNode.ADR = ACPI_DISPLAY_ADR (1, 0, 0, 1, 0, ACPI_ADR_DISPLAY_TYPE_VGA, 0, 0); AcpiDeviceNode.ADR = ACPI_DISPLAY_ADR (1, 0, 0, 1, 0, ACPI_ADR_DISPLAY_TYPE_VGA, 0, 0);
SetDevicePathNodeLength (&AcpiDeviceNode.Header, sizeof (ACPI_ADR_DEVICE_PATH)); SetDevicePathNodeLength (&AcpiDeviceNode.Header, sizeof (ACPI_ADR_DEVICE_PATH));
FbGopPrivate->GopDevicePath = AppendDevicePathNode ( FbGopPrivate->GopDevicePath = AppendDevicePathNode (
ParentDevicePath, ParentDevicePath,
(EFI_DEVICE_PATH_PROTOCOL *) &AcpiDeviceNode (EFI_DEVICE_PATH_PROTOCOL *) &AcpiDeviceNode
@ -519,7 +538,7 @@ FbGopChildHandleInstall (
} else { } else {
FbGopPrivate->GopDevicePath = AppendDevicePathNode (ParentDevicePath, RemainingDevicePath); FbGopPrivate->GopDevicePath = AppendDevicePathNode (ParentDevicePath, RemainingDevicePath);
} }
// //
// Creat child handle and device path protocol firstly // Creat child handle and device path protocol firstly
// //
@ -534,7 +553,7 @@ FbGopChildHandleInstall (
goto Done; goto Done;
} }
} }
// //
// When check for VBE, PCI I/O protocol is needed, so use parent's protocol interface temporally // When check for VBE, PCI I/O protocol is needed, so use parent's protocol interface temporally
// //
@ -544,11 +563,11 @@ FbGopChildHandleInstall (
// Check for VESA BIOS Extensions for modes that are compatible with Graphics Output // Check for VESA BIOS Extensions for modes that are compatible with Graphics Output
// //
Status = FbGopCheckForVbe (FbGopPrivate); Status = FbGopCheckForVbe (FbGopPrivate);
DEBUG ((EFI_D_INFO, "FbGopCheckForVbe - %r\n", Status)); DEBUG ((DEBUG_INFO, "FbGopCheckForVbe - %r\n", Status));
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
//goto Done; //goto Done;
} }
// //
@ -557,11 +576,11 @@ FbGopChildHandleInstall (
Status = gBS->InstallMultipleProtocolInterfaces ( Status = gBS->InstallMultipleProtocolInterfaces (
&FbGopPrivate->Handle, &FbGopPrivate->Handle,
&gEfiGraphicsOutputProtocolGuid, &gEfiGraphicsOutputProtocolGuid,
&FbGopPrivate->GraphicsOutput, &FbGopPrivate->GraphicsOutput,
&gEfiEdidDiscoveredProtocolGuid, &gEfiEdidDiscoveredProtocolGuid,
&FbGopPrivate->EdidDiscovered, &FbGopPrivate->EdidDiscovered,
&gEfiEdidActiveProtocolGuid, &gEfiEdidActiveProtocolGuid,
&FbGopPrivate->EdidActive, &FbGopPrivate->EdidActive,
NULL NULL
); );
@ -581,7 +600,7 @@ FbGopChildHandleInstall (
goto Done; goto Done;
} }
} }
Done: Done:
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
// //
@ -612,7 +631,7 @@ FbGopChildHandleUninstall (
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
FB_VIDEO_DEV *FbGopPrivate; FB_VIDEO_DEV *FbGopPrivate;
EFI_PCI_IO_PROTOCOL *PciIo; EFI_PCI_IO_PROTOCOL *PciIo;
@ -632,7 +651,7 @@ FbGopChildHandleUninstall (
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
FbGopPrivate = FB_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS (GraphicsOutput); FbGopPrivate = FB_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS (GraphicsOutput);
} }
if (FbGopPrivate == NULL) { if (FbGopPrivate == NULL) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
@ -658,7 +677,7 @@ FbGopChildHandleUninstall (
&FbGopPrivate->GraphicsOutput, &FbGopPrivate->GraphicsOutput,
NULL NULL
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
gBS->OpenProtocol ( gBS->OpenProtocol (
Controller, Controller,
@ -670,7 +689,7 @@ FbGopChildHandleUninstall (
); );
return Status; return Status;
} }
// //
// Release all allocated resources // Release all allocated resources
// //
@ -698,20 +717,20 @@ FbGopDeviceReleaseResource (
// //
// Release all the resources occupied by the FB_VIDEO_DEV // Release all the resources occupied by the FB_VIDEO_DEV
// //
// //
// Free VBE Frame Buffer // Free VBE Frame Buffer
// //
if (FbGopPrivate->VbeFrameBuffer != NULL) { if (FbGopPrivate->VbeFrameBuffer != NULL) {
FreePool (FbGopPrivate->VbeFrameBuffer); FreePool (FbGopPrivate->VbeFrameBuffer);
} }
// //
// Free mode data // Free mode data
// //
if (FbGopPrivate->ModeData != NULL) { if (FbGopPrivate->ModeData != NULL) {
FreePool (FbGopPrivate->ModeData); FreePool (FbGopPrivate->ModeData);
} }
// //
// Free graphics output protocol occupied resource // Free graphics output protocol occupied resource
@ -723,7 +742,7 @@ FbGopDeviceReleaseResource (
} }
FreePool (FbGopPrivate->GraphicsOutput.Mode); FreePool (FbGopPrivate->GraphicsOutput.Mode);
FbGopPrivate->GraphicsOutput.Mode = NULL; FbGopPrivate->GraphicsOutput.Mode = NULL;
} }
if (FbGopPrivate->GopDevicePath!= NULL) { if (FbGopPrivate->GopDevicePath!= NULL) {
FreePool (FbGopPrivate->GopDevicePath); FreePool (FbGopPrivate->GopDevicePath);
@ -768,7 +787,7 @@ HasChildHandle (
HasChild = TRUE; HasChild = TRUE;
} }
} }
return HasChild; return HasChild;
} }
@ -785,38 +804,33 @@ FbGopCheckForVbe (
IN OUT FB_VIDEO_DEV *FbGopPrivate IN OUT FB_VIDEO_DEV *FbGopPrivate
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
FB_VIDEO_MODE_DATA *ModeBuffer; FB_VIDEO_MODE_DATA *ModeBuffer;
FB_VIDEO_MODE_DATA *CurrentModeData; FB_VIDEO_MODE_DATA *CurrentModeData;
UINTN ModeNumber; UINTN ModeNumber;
UINTN BitsPerPixel; UINTN BitsPerPixel;
UINTN BytesPerScanLine; UINTN BytesPerScanLine;
UINT32 HorizontalResolution; UINT32 HorizontalResolution;
UINT32 VerticalResolution; UINT32 VerticalResolution;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *VbeFrameBuffer; EFI_GRAPHICS_OUTPUT_BLT_PIXEL *VbeFrameBuffer;
EFI_HOB_GUID_TYPE *GuidHob; FRAME_BUFFER_INFO *FbInfo;
FRAME_BUFFER_INFO *pFbInfo;
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
//
// Find the frame buffer information guid hob FbInfo = mFrameBufferInfo;
//
GuidHob = GetFirstGuidHob (&gUefiFrameBufferInfoGuid);
ASSERT (GuidHob != NULL);
pFbInfo = (FRAME_BUFFER_INFO *)GET_GUID_HOB_DATA (GuidHob);
// //
// Add mode to the list of available modes // Add mode to the list of available modes
// //
VbeFrameBuffer = NULL; VbeFrameBuffer = NULL;
ModeBuffer = NULL; ModeBuffer = NULL;
ModeNumber = 1; ModeNumber = 1;
BitsPerPixel = pFbInfo->BitsPerPixel; BitsPerPixel = FbInfo->BitsPerPixel;
HorizontalResolution = pFbInfo->HorizontalResolution; HorizontalResolution = FbInfo->HorizontalResolution;
VerticalResolution = pFbInfo->VerticalResolution; VerticalResolution = FbInfo->VerticalResolution;
BytesPerScanLine = pFbInfo->BytesPerScanLine; BytesPerScanLine = FbInfo->BytesPerScanLine;
ModeBuffer = (FB_VIDEO_MODE_DATA *) AllocatePool ( ModeBuffer = (FB_VIDEO_MODE_DATA *) AllocatePool (
ModeNumber * sizeof (FB_VIDEO_MODE_DATA) ModeNumber * sizeof (FB_VIDEO_MODE_DATA)
); );
@ -833,32 +847,32 @@ FbGopCheckForVbe (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto Done; goto Done;
} }
if (FbGopPrivate->ModeData != NULL) { if (FbGopPrivate->ModeData != NULL) {
FreePool (FbGopPrivate->ModeData); FreePool (FbGopPrivate->ModeData);
} }
if (FbGopPrivate->VbeFrameBuffer != NULL) { if (FbGopPrivate->VbeFrameBuffer != NULL) {
FreePool (FbGopPrivate->VbeFrameBuffer); FreePool (FbGopPrivate->VbeFrameBuffer);
} }
CurrentModeData = &ModeBuffer[ModeNumber - 1]; CurrentModeData = &ModeBuffer[ModeNumber - 1];
CurrentModeData->BytesPerScanLine = (UINT16)BytesPerScanLine; CurrentModeData->BytesPerScanLine = (UINT16)BytesPerScanLine;
CurrentModeData->Red = *(FB_VIDEO_COLOR_PLACEMENT *)&(pFbInfo->Red); CurrentModeData->Red = *(FB_VIDEO_COLOR_PLACEMENT *)&(FbInfo->Red);
CurrentModeData->Blue = *(FB_VIDEO_COLOR_PLACEMENT *)&(pFbInfo->Blue); CurrentModeData->Blue = *(FB_VIDEO_COLOR_PLACEMENT *)&(FbInfo->Blue);
CurrentModeData->Green = *(FB_VIDEO_COLOR_PLACEMENT *)&(pFbInfo->Green); CurrentModeData->Green = *(FB_VIDEO_COLOR_PLACEMENT *)&(FbInfo->Green);
CurrentModeData->Reserved = *(FB_VIDEO_COLOR_PLACEMENT *)&(pFbInfo->Reserved); CurrentModeData->Reserved = *(FB_VIDEO_COLOR_PLACEMENT *)&(FbInfo->Reserved);
CurrentModeData->BitsPerPixel = (UINT32)BitsPerPixel; CurrentModeData->BitsPerPixel = (UINT32)BitsPerPixel;
CurrentModeData->HorizontalResolution = HorizontalResolution; CurrentModeData->HorizontalResolution = HorizontalResolution;
CurrentModeData->VerticalResolution = VerticalResolution; CurrentModeData->VerticalResolution = VerticalResolution;
CurrentModeData->FrameBufferSize = CurrentModeData->BytesPerScanLine * CurrentModeData->VerticalResolution; CurrentModeData->FrameBufferSize = CurrentModeData->BytesPerScanLine * CurrentModeData->VerticalResolution;
CurrentModeData->LinearFrameBuffer = (VOID *) (UINTN) pFbInfo->LinearFrameBuffer; CurrentModeData->LinearFrameBuffer = (VOID *) (UINTN) FbInfo->LinearFrameBuffer;
CurrentModeData->VbeModeNumber = 0; CurrentModeData->VbeModeNumber = 0;
CurrentModeData->ColorDepth = 32; CurrentModeData->ColorDepth = 32;
CurrentModeData->RefreshRate = 60; CurrentModeData->RefreshRate = 60;
CurrentModeData->PixelFormat = PixelBitMask; CurrentModeData->PixelFormat = PixelBitMask;
if ((CurrentModeData->BitsPerPixel == 32) && if ((CurrentModeData->BitsPerPixel == 32) &&
(CurrentModeData->Red.Mask == 0xff) && (CurrentModeData->Green.Mask == 0xff) && (CurrentModeData->Blue.Mask == 0xff)) { (CurrentModeData->Red.Mask == 0xff) && (CurrentModeData->Green.Mask == 0xff) && (CurrentModeData->Blue.Mask == 0xff)) {
@ -867,47 +881,47 @@ FbGopCheckForVbe (
} else if ((CurrentModeData->Blue.Position == 0) && (CurrentModeData->Green.Position == 8) && (CurrentModeData->Red.Position == 16)) { } else if ((CurrentModeData->Blue.Position == 0) && (CurrentModeData->Green.Position == 8) && (CurrentModeData->Red.Position == 16)) {
CurrentModeData->PixelFormat = PixelBlueGreenRedReserved8BitPerColor; CurrentModeData->PixelFormat = PixelBlueGreenRedReserved8BitPerColor;
} }
} }
CopyMem (&(CurrentModeData->PixelBitMask), &mPixelBitMask, sizeof (EFI_PIXEL_BITMASK)); CopyMem (&(CurrentModeData->PixelBitMask), &mPixelBitMask, sizeof (EFI_PIXEL_BITMASK));
FbGopPrivate->ModeData = ModeBuffer; FbGopPrivate->ModeData = ModeBuffer;
FbGopPrivate->VbeFrameBuffer = VbeFrameBuffer; FbGopPrivate->VbeFrameBuffer = VbeFrameBuffer;
// //
// Assign Gop's Blt function // Assign Gop's Blt function
// //
FbGopPrivate->GraphicsOutput.Blt = FbGopGraphicsOutputVbeBlt; FbGopPrivate->GraphicsOutput.Blt = FbGopGraphicsOutputVbeBlt;
FbGopPrivate->GraphicsOutput.Mode->MaxMode = 1; FbGopPrivate->GraphicsOutput.Mode->MaxMode = 1;
FbGopPrivate->GraphicsOutput.Mode->Mode = 0; FbGopPrivate->GraphicsOutput.Mode->Mode = 0;
FbGopPrivate->GraphicsOutput.Mode->Info->Version = 0; FbGopPrivate->GraphicsOutput.Mode->Info->Version = 0;
FbGopPrivate->GraphicsOutput.Mode->Info->HorizontalResolution = HorizontalResolution; FbGopPrivate->GraphicsOutput.Mode->Info->HorizontalResolution = HorizontalResolution;
FbGopPrivate->GraphicsOutput.Mode->Info->VerticalResolution = VerticalResolution; FbGopPrivate->GraphicsOutput.Mode->Info->VerticalResolution = VerticalResolution;
FbGopPrivate->GraphicsOutput.Mode->Info->PixelFormat = CurrentModeData->PixelFormat; FbGopPrivate->GraphicsOutput.Mode->Info->PixelFormat = CurrentModeData->PixelFormat;
CopyMem (&(FbGopPrivate->GraphicsOutput.Mode->Info->PixelInformation), &mPixelBitMask, sizeof (EFI_PIXEL_BITMASK)); CopyMem (&(FbGopPrivate->GraphicsOutput.Mode->Info->PixelInformation), &mPixelBitMask, sizeof (EFI_PIXEL_BITMASK));
FbGopPrivate->GraphicsOutput.Mode->Info->PixelsPerScanLine = (UINT32)(BytesPerScanLine * 8 / BitsPerPixel); FbGopPrivate->GraphicsOutput.Mode->Info->PixelsPerScanLine = (UINT32)(BytesPerScanLine * 8 / BitsPerPixel);
FbGopPrivate->GraphicsOutput.Mode->SizeOfInfo = sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION); FbGopPrivate->GraphicsOutput.Mode->SizeOfInfo = sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
FbGopPrivate->GraphicsOutput.Mode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) (UINTN) CurrentModeData->LinearFrameBuffer; FbGopPrivate->GraphicsOutput.Mode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) (UINTN) CurrentModeData->LinearFrameBuffer;
FbGopPrivate->GraphicsOutput.Mode->FrameBufferSize = CurrentModeData->FrameBufferSize; FbGopPrivate->GraphicsOutput.Mode->FrameBufferSize = CurrentModeData->FrameBufferSize;
// //
// Find the best mode to initialize // Find the best mode to initialize
// //
Done: Done:
// //
// If there was an error, then free the mode structure // If there was an error, then free the mode structure
// //
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
if (VbeFrameBuffer != NULL) { if (VbeFrameBuffer != NULL) {
FreePool (VbeFrameBuffer); FreePool (VbeFrameBuffer);
} }
if (ModeBuffer != NULL) { if (ModeBuffer != NULL) {
FreePool (ModeBuffer); FreePool (ModeBuffer);
} }
} }
return Status; return Status;
@ -992,7 +1006,7 @@ FbGopGraphicsOutputSetMode (
IN EFI_GRAPHICS_OUTPUT_PROTOCOL * This, IN EFI_GRAPHICS_OUTPUT_PROTOCOL * This,
IN UINT32 ModeNumber IN UINT32 ModeNumber
) )
{ {
FB_VIDEO_DEV *FbGopPrivate; FB_VIDEO_DEV *FbGopPrivate;
FB_VIDEO_MODE_DATA *ModeData; FB_VIDEO_MODE_DATA *ModeData;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background; EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;
@ -1008,11 +1022,11 @@ FbGopGraphicsOutputSetMode (
if (ModeNumber >= This->Mode->MaxMode) { if (ModeNumber >= This->Mode->MaxMode) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
if (ModeNumber == This->Mode->Mode) { if (ModeNumber == This->Mode->Mode) {
// //
// Clear screen to black // Clear screen to black
// //
ZeroMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)); ZeroMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
FbGopGraphicsOutputVbeBlt ( FbGopGraphicsOutputVbeBlt (
This, This,
@ -1030,7 +1044,7 @@ FbGopGraphicsOutputSetMode (
} else { } else {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
} }
/** /**
@ -1493,12 +1507,14 @@ FbGopEntryPoint(
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_HOB_GUID_TYPE *GuidHob; EFI_HOB_GUID_TYPE *GuidHob;
// //
// Find the frame buffer information guid hob // Find the frame buffer information guid hob
// //
GuidHob = GetFirstGuidHob (&gUefiFrameBufferInfoGuid); GuidHob = GetFirstGuidHob (&gUefiFrameBufferInfoGuid);
if (GuidHob != NULL) { if (GuidHob != NULL) {
mFrameBufferInfo = (FRAME_BUFFER_INFO *)GET_GUID_HOB_DATA (GuidHob);
// //
// Install driver model protocol(s). // Install driver model protocol(s).
// //
@ -1512,9 +1528,9 @@ FbGopEntryPoint(
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} else { } else {
DEBUG ((EFI_D_ERROR, "No FrameBuffer information from coreboot. NO GOP driver !!!\n")); DEBUG ((DEBUG_ERROR, "No FrameBuffer information from coreboot. NO GOP driver !!!\n"));
Status = EFI_ABORTED; Status = EFI_ABORTED;
} }
return Status; return Status;
} }