}\r
} else {\r
//\r
- // If it is not a hot-plug device, first append the device path to the\r
- // ConOutDev environment variable\r
+ // If it is not a hot-plug device, append the device path to \r
+ // the ConOutDev and ErrOutDev environment variable.\r
+ // For GOP device path, append the sibling device path as well.\r
//\r
- ConPlatformUpdateDeviceVariable (\r
- L"ConOutDev",\r
- DevicePath,\r
- Append\r
- );\r
- //\r
- // Then append the device path to the ErrOutDev environment variable\r
- //\r
- ConPlatformUpdateDeviceVariable (\r
- L"ErrOutDev",\r
- DevicePath,\r
- Append\r
- );\r
+ if (!ConPlatformUpdateGopCandidate (DevicePath)) {\r
+ ConPlatformUpdateDeviceVariable (\r
+ L"ConOutDev",\r
+ DevicePath,\r
+ Append\r
+ );\r
+ //\r
+ // Then append the device path to the ErrOutDev environment variable\r
+ //\r
+ ConPlatformUpdateDeviceVariable (\r
+ L"ErrOutDev",\r
+ DevicePath,\r
+ Append\r
+ );\r
+ }\r
\r
//\r
// If the device path is an instance in the ConOut environment variable,\r
return FALSE;\r
}\r
\r
+/**\r
+ Update ConOutDev and ErrOutDev variables to add the device path of\r
+ GOP controller itself and the sibling controllers.\r
+\r
+ @param DevicePath Pointer to device's device path.\r
+\r
+ @retval TRUE The devcie is a GOP device.\r
+ @retval FALSE The devcie is not a GOP device.\r
+\r
+**/\r
+BOOLEAN\r
+ConPlatformUpdateGopCandidate (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_HANDLE PciHandle;\r
+ EFI_HANDLE GopHandle;\r
+ EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;\r
+ UINTN EntryCount;\r
+ UINTN Index;\r
+ EFI_DEVICE_PATH_PROTOCOL *ChildDevicePath;\r
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;\r
+\r
+ //\r
+ // Check whether it's a GOP device.\r
+ //\r
+ TempDevicePath = DevicePath;\r
+ Status = gBS->LocateDevicePath (&gEfiGraphicsOutputProtocolGuid, &TempDevicePath, &GopHandle);\r
+ if (EFI_ERROR (Status)) {\r
+ return FALSE;\r
+ }\r
+ //\r
+ // Get the parent PciIo handle in order to find all the children\r
+ //\r
+ Status = gBS->LocateDevicePath (&gEfiPciIoProtocolGuid, &DevicePath, &PciHandle);\r
+ if (EFI_ERROR (Status)) {\r
+ return FALSE;\r
+ }\r
+\r
+ Status = gBS->OpenProtocolInformation (\r
+ PciHandle,\r
+ &gEfiPciIoProtocolGuid,\r
+ &OpenInfoBuffer,\r
+ &EntryCount\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return FALSE;\r
+ }\r
+\r
+ for (Index = 0; Index < EntryCount; Index++) {\r
+ //\r
+ // Query all the children created by the GOP driver\r
+ //\r
+ if ((OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {\r
+ Status = gBS->OpenProtocol (\r
+ OpenInfoBuffer[Index].ControllerHandle,\r
+ &gEfiDevicePathProtocolGuid,\r
+ (VOID **) &ChildDevicePath,\r
+ NULL,\r
+ NULL,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ //\r
+ // Append the device path to ConOutDev and ErrOutDev\r
+ //\r
+ ConPlatformUpdateDeviceVariable (L"ConOutDev", ChildDevicePath, Append);\r
+ ConPlatformUpdateDeviceVariable (L"ErrOutDev", ChildDevicePath, Append);\r
+ }\r
+ }\r
+ }\r
+ FreePool (OpenInfoBuffer);\r
+\r
+ return TRUE;\r
+}\r
#include <Protocol/SimpleTextOut.h>\r
#include <Protocol/DevicePath.h>\r
#include <Protocol/SimpleTextIn.h>\r
+#include <Protocol/PciIo.h>\r
+#include <Protocol/GraphicsOutput.h>\r
\r
#include <Guid/GlobalVariable.h>\r
#include <Guid/ConsoleInDevice.h>\r
OUT CHAR16 **ControllerName\r
);\r
\r
+/**\r
+ Update ConOutDev and ErrOutDev variables to add the device path of\r
+ GOP controller itself and the sibling controllers.\r
+\r
+ @param DevicePath Pointer to device's device path.\r
+\r
+ @retval TRUE The devcie is a GOP device.\r
+ @retval FALSE The devcie is not a GOP device.\r
+\r
+**/\r
+BOOLEAN\r
+ConPlatformUpdateGopCandidate (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
+ );\r
\r
#endif\r