summaryrefslogtreecommitdiff
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>2010-10-14 04:49:31 +0000
committerniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>2010-10-14 04:49:31 +0000
commit5b7183efb1e24f3d32f97c9a619ae69f61f4c0a1 (patch)
treec0af9b9b28d668f34fe9955538968b8fd291235c /MdeModulePkg
parent5dec0c688ea92257e721eecdaf4fe4bcb15274dc (diff)
downloadedk2-platforms-5b7183efb1e24f3d32f97c9a619ae69f61f4c0a1.tar.xz
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
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c109
-rw-r--r--MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.h16
-rw-r--r--MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf3
3 files changed, 112 insertions, 16 deletions
diff --git a/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c b/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c
index 597ec1fec9..0644ee38b9 100644
--- a/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c
+++ b/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c
@@ -450,22 +450,25 @@ ConPlatformTextOutDriverBindingStart (
}
} else {
//
- // If it is not a hot-plug device, first append the device path to the
- // ConOutDev environment variable
+ // If it is not a hot-plug device, append the device path to
+ // the ConOutDev and ErrOutDev environment variable.
+ // For GOP device path, append the sibling device path as well.
//
- ConPlatformUpdateDeviceVariable (
- L"ConOutDev",
- DevicePath,
- Append
- );
- //
- // Then append the device path to the ErrOutDev environment variable
- //
- ConPlatformUpdateDeviceVariable (
- L"ErrOutDev",
- DevicePath,
- Append
- );
+ if (!ConPlatformUpdateGopCandidate (DevicePath)) {
+ ConPlatformUpdateDeviceVariable (
+ L"ConOutDev",
+ DevicePath,
+ Append
+ );
+ //
+ // Then append the device path to the ErrOutDev environment variable
+ //
+ ConPlatformUpdateDeviceVariable (
+ L"ErrOutDev",
+ DevicePath,
+ Append
+ );
+ }
//
// If the device path is an instance in the ConOut environment variable,
@@ -1022,3 +1025,79 @@ IsHotPlugDevice (
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;
+}
diff --git a/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.h b/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.h
index 28261730ab..b04dce73e3 100644
--- a/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.h
+++ b/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.h
@@ -20,6 +20,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Protocol/SimpleTextOut.h>
#include <Protocol/DevicePath.h>
#include <Protocol/SimpleTextIn.h>
+#include <Protocol/PciIo.h>
+#include <Protocol/GraphicsOutput.h>
#include <Guid/GlobalVariable.h>
#include <Guid/ConsoleInDevice.h>
@@ -422,5 +424,19 @@ ConPlatformComponentNameGetControllerName (
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
diff --git a/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf b/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
index 9c789906ba..83fae1ead7 100644
--- a/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
+++ b/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
@@ -87,4 +87,5 @@
gEfiDevicePathProtocolGuid ## TO_START
gEfiSimpleTextInProtocolGuid ## TO_START
gEfiSimpleTextOutProtocolGuid ## TO_START
- \ No newline at end of file
+ gEfiPciIoProtocolGuid ## TO_START
+ gEfiGraphicsOutputProtocolGuid ## TO_START \ No newline at end of file