Update ConPlatform driver to support GOP driver which creates multiple children.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10936 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
niruiyu 2010-10-14 04:49:31 +00:00
parent 5dec0c688e
commit 5b7183efb1
3 changed files with 112 additions and 16 deletions

View File

@ -450,9 +450,11 @@ ConPlatformTextOutDriverBindingStart (
} }
} else { } else {
// //
// If it is not a hot-plug device, first append the device path to the // If it is not a hot-plug device, append the device path to
// ConOutDev environment variable // the ConOutDev and ErrOutDev environment variable.
// For GOP device path, append the sibling device path as well.
// //
if (!ConPlatformUpdateGopCandidate (DevicePath)) {
ConPlatformUpdateDeviceVariable ( ConPlatformUpdateDeviceVariable (
L"ConOutDev", L"ConOutDev",
DevicePath, DevicePath,
@ -466,6 +468,7 @@ ConPlatformTextOutDriverBindingStart (
DevicePath, DevicePath,
Append Append
); );
}
// //
// If the device path is an instance in the ConOut environment variable, // If the device path is an instance in the ConOut environment variable,
@ -1022,3 +1025,79 @@ IsHotPlugDevice (
return FALSE; return FALSE;
} }
/**
Update ConOutDev and ErrOutDev variables to add the device path of
GOP controller itself and the sibling controllers.
@param DevicePath Pointer to device's device path.
@retval TRUE The devcie is a GOP device.
@retval FALSE The devcie is not a GOP device.
**/
BOOLEAN
ConPlatformUpdateGopCandidate (
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
EFI_STATUS Status;
EFI_HANDLE PciHandle;
EFI_HANDLE GopHandle;
EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;
UINTN EntryCount;
UINTN Index;
EFI_DEVICE_PATH_PROTOCOL *ChildDevicePath;
EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
//
// Check whether it's a GOP device.
//
TempDevicePath = DevicePath;
Status = gBS->LocateDevicePath (&gEfiGraphicsOutputProtocolGuid, &TempDevicePath, &GopHandle);
if (EFI_ERROR (Status)) {
return FALSE;
}
//
// Get the parent PciIo handle in order to find all the children
//
Status = gBS->LocateDevicePath (&gEfiPciIoProtocolGuid, &DevicePath, &PciHandle);
if (EFI_ERROR (Status)) {
return FALSE;
}
Status = gBS->OpenProtocolInformation (
PciHandle,
&gEfiPciIoProtocolGuid,
&OpenInfoBuffer,
&EntryCount
);
if (EFI_ERROR (Status)) {
return FALSE;
}
for (Index = 0; Index < EntryCount; Index++) {
//
// Query all the children created by the GOP driver
//
if ((OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
Status = gBS->OpenProtocol (
OpenInfoBuffer[Index].ControllerHandle,
&gEfiDevicePathProtocolGuid,
(VOID **) &ChildDevicePath,
NULL,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (!EFI_ERROR (Status)) {
//
// Append the device path to ConOutDev and ErrOutDev
//
ConPlatformUpdateDeviceVariable (L"ConOutDev", ChildDevicePath, Append);
ConPlatformUpdateDeviceVariable (L"ErrOutDev", ChildDevicePath, Append);
}
}
}
FreePool (OpenInfoBuffer);
return TRUE;
}

View File

@ -20,6 +20,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Protocol/SimpleTextOut.h> #include <Protocol/SimpleTextOut.h>
#include <Protocol/DevicePath.h> #include <Protocol/DevicePath.h>
#include <Protocol/SimpleTextIn.h> #include <Protocol/SimpleTextIn.h>
#include <Protocol/PciIo.h>
#include <Protocol/GraphicsOutput.h>
#include <Guid/GlobalVariable.h> #include <Guid/GlobalVariable.h>
#include <Guid/ConsoleInDevice.h> #include <Guid/ConsoleInDevice.h>
@ -422,5 +424,19 @@ ConPlatformComponentNameGetControllerName (
OUT CHAR16 **ControllerName OUT CHAR16 **ControllerName
); );
/**
Update ConOutDev and ErrOutDev variables to add the device path of
GOP controller itself and the sibling controllers.
@param DevicePath Pointer to device's device path.
@retval TRUE The devcie is a GOP device.
@retval FALSE The devcie is not a GOP device.
**/
BOOLEAN
ConPlatformUpdateGopCandidate (
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
);
#endif #endif

View File

@ -87,4 +87,5 @@
gEfiDevicePathProtocolGuid ## TO_START gEfiDevicePathProtocolGuid ## TO_START
gEfiSimpleTextInProtocolGuid ## TO_START gEfiSimpleTextInProtocolGuid ## TO_START
gEfiSimpleTextOutProtocolGuid ## TO_START gEfiSimpleTextOutProtocolGuid ## TO_START
gEfiPciIoProtocolGuid ## TO_START
gEfiGraphicsOutputProtocolGuid ## TO_START