12CHAR16 *mConVarName[] = {
32 UINTN RootBridgeHandleCount;
36 UINTN RootBridgeIndex;
45 Status =
gBS->LocateHandleBuffer (
47 &gEfiPciRootBridgeIoProtocolGuid,
49 &RootBridgeHandleCount,
50 &RootBridgeHandleBuffer
52 if (EFI_ERROR (Status) || (RootBridgeHandleCount == 0)) {
56 VideoController =
NULL;
57 for (RootBridgeIndex = 0; RootBridgeIndex < RootBridgeHandleCount; RootBridgeIndex++) {
58 gBS->ConnectController (RootBridgeHandleBuffer[RootBridgeIndex],
NULL,
NULL,
FALSE);
63 Status =
gBS->LocateHandleBuffer (
65 &gEfiPciIoProtocolGuid,
70 if (EFI_ERROR (Status)) {
74 for (Index = 0; Index < HandleCount; Index++) {
75 Status =
gBS->HandleProtocol (HandleBuffer[Index], &gEfiPciIoProtocolGuid, (VOID **)&PciIo);
76 if (!EFI_ERROR (Status)) {
80 Status = PciIo->Pci.Read (
84 sizeof (Pci) /
sizeof (UINT32),
87 if (!EFI_ERROR (Status) &&
IS_PCI_VGA (&Pci)) {
89 VideoController = HandleBuffer[Index];
97 if (VideoController !=
NULL) {
104 return VideoController;
124 UINTN ProtocolBufferCount;
135 Status =
gBS->ProtocolsPerHandle (
140 if (EFI_ERROR (Status)) {
146 for (ProtocolIndex = 0; ProtocolIndex < ProtocolBufferCount; ProtocolIndex++) {
147 Status =
gBS->OpenProtocolInformation (
149 ProtocolBuffer[ProtocolIndex],
153 if (EFI_ERROR (Status)) {
157 for (Index = 0; Index < EntryCount; Index++) {
161 if ((OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
162 Status =
gBS->OpenProtocol (
163 OpenInfoBuffer[Index].ControllerHandle,
164 &gEfiDevicePathProtocolGuid,
165 (VOID **)&DevicePath,
168 EFI_OPEN_PROTOCOL_GET_PROTOCOL
170 if (EFI_ERROR (Status)) {
179 ASSERT (Previous !=
NULL);
182 Status =
gBS->OpenProtocol (
183 OpenInfoBuffer[Index].ControllerHandle,
184 &gEfiGraphicsOutputProtocolGuid,
188 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
190 if (!EFI_ERROR (Status)) {
194 TempDevicePath = GopPool;
196 gBS->FreePool (TempDevicePath);
204 DEBUG ((DEBUG_INFO,
"[Bds] Looking for GOP child deeper ... \n"));
205 TempDevicePath = GopPool;
208 gBS->FreePool (ReturnDevicePath);
209 gBS->FreePool (TempDevicePath);
238 if (VideoController ==
NULL) {
245 if (VideoController ==
NULL) {
246 return EFI_NOT_FOUND;
259 return EFI_NOT_FOUND;
293 IN OUT VOID **ProtocolInterface
297 UINTN DevicePathSize;
306 ASSERT (VarName !=
NULL);
307 ASSERT (ConsoleHandle !=
NULL);
308 ASSERT (ConsoleGuid !=
NULL);
309 ASSERT (ProtocolInterface !=
NULL);
311 if (*ConsoleHandle !=
NULL) {
312 Status =
gBS->HandleProtocol (
317 if ((Status ==
EFI_SUCCESS) && (Interface == *ProtocolInterface)) {
330 if (VarConsole ==
NULL) {
337 FullDevicePath = VarConsole;
344 if (Instance ==
NULL) {
345 DEBUG ((DEBUG_ERROR,
"[Bds] No valid console instance is found for %s!\n", VarName));
355 FullInstance = Instance;
356 Status =
gBS->LocateDevicePath (
362 if (!EFI_ERROR (Status)) {
366 Status =
gBS->HandleProtocol (
371 if (!EFI_ERROR (Status)) {
375 *ConsoleHandle = NewHandle;
376 *ProtocolInterface = Interface;
377 if (
CompareGuid (ConsoleGuid, &gEfiSimpleTextOutProtocolGuid)) {
383 TextOut->SetMode (TextOut, 0);
391 }
while (Instance !=
NULL);
419 IN CONSOLE_TYPE ConsoleType,
429 if (ConsoleType >=
ARRAY_SIZE (mConVarName)) {
430 return EFI_INVALID_PARAMETER;
437 if (CustomizedConDevicePath == ExclusiveDevicePath) {
438 return EFI_UNSUPPORTED;
448 NewDevicePath = VarConsole;
454 if ((ExclusiveDevicePath !=
NULL) && (VarConsole !=
NULL)) {
461 if (CustomizedConDevicePath !=
NULL) {
471 TempNewDevicePath = NewDevicePath;
473 if (TempNewDevicePath !=
NULL) {
482 Status =
gRT->SetVariable (
483 mConVarName[ConsoleType],
484 &gEfiGlobalVariableGuid,
485 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS
491 if (VarConsole == NewDevicePath) {
492 if (VarConsole !=
NULL) {
496 if (VarConsole !=
NULL) {
500 if (NewDevicePath !=
NULL) {
522 IN CONSOLE_TYPE ConsoleType
534 if ((ConsoleType != ConIn) && (ConsoleType != ConOut) && (ConsoleType != ErrOut)) {
535 return EFI_INVALID_PARAMETER;
546 if (StartDevicePath ==
NULL) {
547 return EFI_UNSUPPORTED;
550 CopyOfDevicePath = StartDevicePath;
556 if (Instance ==
NULL) {
558 return EFI_UNSUPPORTED;
578 if (!EFI_ERROR (Status)) {
601 if (!EFI_ERROR (Status)) {
608 if (EFI_ERROR (Status)) {
619 }
while (CopyOfDevicePath !=
NULL);
624 return EFI_NOT_FOUND;
648 ConDevicePath =
NULL;
653 gBS->LocateHandleBuffer (
655 &gEfiSimpleTextInProtocolGuid,
661 for (Index = 0; Index < HandleCount; Index++) {
662 gBS->HandleProtocol (
664 &gEfiDevicePathProtocolGuid,
665 (VOID **)&ConDevicePath
670 if (HandleBuffer !=
NULL) {
675 gBS->LocateHandleBuffer (
677 &gEfiSimpleTextOutProtocolGuid,
682 for (Index = 0; Index < HandleCount; Index++) {
683 gBS->HandleProtocol (
685 &gEfiDevicePathProtocolGuid,
686 (VOID **)&ConDevicePath
692 if (HandleBuffer !=
NULL) {
717 BOOLEAN OneConnected;
718 BOOLEAN SystemTableUpdated;
720 OneConnected =
FALSE;
723 if (!EFI_ERROR (Status)) {
730 if (!EFI_ERROR (Status)) {
737 if (!EFI_ERROR (Status)) {
743 SystemTableUpdated =
FALSE;
748 SystemTableUpdated =
TRUE;
752 SystemTableUpdated =
TRUE;
756 SystemTableUpdated =
TRUE;
759 if (SystemTableUpdated) {
764 gBS->CalculateCrc32 (
771 return OneConnected ?
EFI_SUCCESS : EFI_DEVICE_ERROR;
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
EFI_STATUS BmConnectUsbShortFormDevicePath(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
EFI_STATUS EFIAPI EfiBootManagerConnectConsoleVariable(IN CONSOLE_TYPE ConsoleType)
EFI_HANDLE BmGetVideoController(VOID)
VOID EFIAPI EfiBootManagerConnectAllConsoles(VOID)
EFI_STATUS EFIAPI EfiBootManagerConnectVideoController(EFI_HANDLE VideoController OPTIONAL)
EFI_STATUS EFIAPI EfiBootManagerConnectAllDefaultConsoles(VOID)
EFI_STATUS EFIAPI EfiBootManagerUpdateConsoleVariable(IN CONSOLE_TYPE ConsoleType, IN EFI_DEVICE_PATH_PROTOCOL *CustomizedConDevicePath, IN EFI_DEVICE_PATH_PROTOCOL *ExclusiveDevicePath)
BOOLEAN BmUpdateSystemTableConsole(IN CHAR16 *VarName, IN EFI_GUID *ConsoleGuid, IN OUT EFI_HANDLE *ConsoleHandle, IN OUT VOID **ProtocolInterface)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI EfiBootManagerGetGopDevicePath(IN EFI_HANDLE VideoController)
EFI_DEVICE_PATH_PROTOCOL * BmDelPartMatchInstance(IN EFI_DEVICE_PATH_PROTOCOL *Multi, IN EFI_DEVICE_PATH_PROTOCOL *Single)
BOOLEAN BmMatchDevicePaths(IN EFI_DEVICE_PATH_PROTOCOL *Multi, IN EFI_DEVICE_PATH_PROTOCOL *Single)
#define HARDWARE_DEVICE_PATH
#define MESSAGING_DEVICE_PATH
UINT8 EFIAPI DevicePathType(IN CONST VOID *Node)
UINT8 EFIAPI DevicePathSubType(IN CONST VOID *Node)
BOOLEAN EFIAPI IsDevicePathEnd(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI NextDevicePathNode(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI AppendDevicePathInstance(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance OPTIONAL)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI GetNextDevicePathInstance(IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, OUT UINTN *Size)
UINTN EFIAPI GetDevicePathSize(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath)
BOOLEAN EFIAPI IsDevicePathEndType(IN CONST VOID *Node)
VOID EFIAPI SetDevicePathEndNode(OUT VOID *Node)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_RUNTIME_SERVICES * gRT
#define ARRAY_SIZE(Array)
#define DEBUG(Expression)
EFI_STATUS EFIAPI EfiBootManagerConnectDevicePath(IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect, OUT EFI_HANDLE *MatchingHandle OPTIONAL)
EFI_STATUS EFIAPI GetEfiGlobalVariable2(IN CONST CHAR16 *Name, OUT VOID **Value, OUT UINTN *Size OPTIONAL)
#define EFI_VARIABLE_NON_VOLATILE
EFI_SIMPLE_TEXT_OUTPUT_MODE * Mode
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * StdErr
EFI_HANDLE ConsoleInHandle
EFI_HANDLE ConsoleOutHandle
EFI_HANDLE StandardErrorHandle
EFI_SIMPLE_TEXT_INPUT_PROTOCOL * ConIn
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * ConOut