\r
#include "InternalBm.h"\r
\r
-CHAR16 *mConVarName[] = {\r
+CHAR16 *mConVarName[] = {\r
L"ConIn",\r
L"ConOut",\r
L"ErrOut",\r
VOID\r
)\r
{\r
- EFI_STATUS Status;\r
- UINTN RootBridgeHandleCount;\r
- EFI_HANDLE *RootBridgeHandleBuffer;\r
- UINTN HandleCount;\r
- EFI_HANDLE *HandleBuffer;\r
- UINTN RootBridgeIndex;\r
- UINTN Index;\r
- EFI_HANDLE VideoController;\r
- EFI_PCI_IO_PROTOCOL *PciIo;\r
- PCI_TYPE00 Pci;\r
+ EFI_STATUS Status;\r
+ UINTN RootBridgeHandleCount;\r
+ EFI_HANDLE *RootBridgeHandleBuffer;\r
+ UINTN HandleCount;\r
+ EFI_HANDLE *HandleBuffer;\r
+ UINTN RootBridgeIndex;\r
+ UINTN Index;\r
+ EFI_HANDLE VideoController;\r
+ EFI_PCI_IO_PROTOCOL *PciIo;\r
+ PCI_TYPE00 Pci;\r
\r
//\r
// Make all the PCI_IO protocols show up\r
}\r
\r
for (Index = 0; Index < HandleCount; Index++) {\r
- Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiPciIoProtocolGuid, (VOID **) &PciIo);\r
+ Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiPciIoProtocolGuid, (VOID **)&PciIo);\r
if (!EFI_ERROR (Status)) {\r
//\r
// Check for all video controller\r
//\r
Status = PciIo->Pci.Read (\r
- PciIo,\r
- EfiPciIoWidthUint32,\r
- 0,\r
- sizeof (Pci) / sizeof (UINT32),\r
- &Pci\r
- );\r
+ PciIo,\r
+ EfiPciIoWidthUint32,\r
+ 0,\r
+ sizeof (Pci) / sizeof (UINT32),\r
+ &Pci\r
+ );\r
if (!EFI_ERROR (Status) && IS_PCI_VGA (&Pci)) {\r
// TODO: use IS_PCI_DISPLAY??\r
VideoController = HandleBuffer[Index];\r
}\r
}\r
}\r
+\r
FreePool (HandleBuffer);\r
\r
if (VideoController != NULL) {\r
break;\r
}\r
}\r
+\r
FreePool (RootBridgeHandleBuffer);\r
\r
return VideoController;\r
EFI_DEVICE_PATH_PROTOCOL *\r
EFIAPI\r
EfiBootManagerGetGopDevicePath (\r
- IN EFI_HANDLE VideoController\r
+ IN EFI_HANDLE VideoController\r
)\r
{\r
UINTN Index;\r
EFI_DEVICE_PATH_PROTOCOL *GopPool;\r
EFI_DEVICE_PATH_PROTOCOL *ReturnDevicePath;\r
\r
-\r
Status = gBS->ProtocolsPerHandle (\r
VideoController,\r
&ProtocolBuffer,\r
Status = gBS->OpenProtocol (\r
OpenInfoBuffer[Index].ControllerHandle,\r
&gEfiDevicePathProtocolGuid,\r
- (VOID **) &DevicePath,\r
+ (VOID **)&DevicePath,\r
NULL,\r
NULL,\r
EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
for (Next = DevicePath; !IsDevicePathEnd (Next); Next = NextDevicePathNode (Next)) {\r
Previous = Next;\r
}\r
+\r
ASSERT (Previous != NULL);\r
\r
- if (DevicePathType (Previous) == ACPI_DEVICE_PATH && DevicePathSubType (Previous) == ACPI_ADR_DP) {\r
+ if ((DevicePathType (Previous) == ACPI_DEVICE_PATH) && (DevicePathSubType (Previous) == ACPI_ADR_DP)) {\r
Status = gBS->OpenProtocol (\r
OpenInfoBuffer[Index].ControllerHandle,\r
&gEfiGraphicsOutputProtocolGuid,\r
// Append the device path to GOP pool when there is GOP protocol installed.\r
//\r
TempDevicePath = GopPool;\r
- GopPool = AppendDevicePathInstance (GopPool, DevicePath);\r
+ GopPool = AppendDevicePathInstance (GopPool, DevicePath);\r
gBS->FreePool (TempDevicePath);\r
}\r
}\r
\r
- if (DevicePathType (Previous) == HARDWARE_DEVICE_PATH && DevicePathSubType (Previous) == HW_CONTROLLER_DP) {\r
+ if ((DevicePathType (Previous) == HARDWARE_DEVICE_PATH) && (DevicePathSubType (Previous) == HW_CONTROLLER_DP)) {\r
//\r
// Recursively look for GOP child in this frame buffer handle\r
//\r
DEBUG ((DEBUG_INFO, "[Bds] Looking for GOP child deeper ... \n"));\r
- TempDevicePath = GopPool;\r
+ TempDevicePath = GopPool;\r
ReturnDevicePath = EfiBootManagerGetGopDevicePath (OpenInfoBuffer[Index].ControllerHandle);\r
- GopPool = AppendDevicePathInstance (GopPool, ReturnDevicePath);\r
+ GopPool = AppendDevicePathInstance (GopPool, ReturnDevicePath);\r
gBS->FreePool (ReturnDevicePath);\r
gBS->FreePool (TempDevicePath);\r
}\r
EFI_STATUS\r
EFIAPI\r
EfiBootManagerConnectVideoController (\r
- EFI_HANDLE VideoController OPTIONAL\r
+ EFI_HANDLE VideoController OPTIONAL\r
)\r
{\r
- EFI_DEVICE_PATH_PROTOCOL *Gop;\r
+ EFI_DEVICE_PATH_PROTOCOL *Gop;\r
\r
if (VideoController == NULL) {\r
//\r
**/\r
BOOLEAN\r
BmUpdateSystemTableConsole (\r
- IN CHAR16 *VarName,\r
- IN EFI_GUID *ConsoleGuid,\r
- IN OUT EFI_HANDLE *ConsoleHandle,\r
- IN OUT VOID **ProtocolInterface\r
+ IN CHAR16 *VarName,\r
+ IN EFI_GUID *ConsoleGuid,\r
+ IN OUT EFI_HANDLE *ConsoleHandle,\r
+ IN OUT VOID **ProtocolInterface\r
)\r
{\r
- EFI_STATUS Status;\r
- UINTN DevicePathSize;\r
- EFI_DEVICE_PATH_PROTOCOL *FullDevicePath;\r
- EFI_DEVICE_PATH_PROTOCOL *VarConsole;\r
- EFI_DEVICE_PATH_PROTOCOL *Instance;\r
- EFI_DEVICE_PATH_PROTOCOL *FullInstance;\r
- VOID *Interface;\r
- EFI_HANDLE NewHandle;\r
- EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;\r
+ EFI_STATUS Status;\r
+ UINTN DevicePathSize;\r
+ EFI_DEVICE_PATH_PROTOCOL *FullDevicePath;\r
+ EFI_DEVICE_PATH_PROTOCOL *VarConsole;\r
+ EFI_DEVICE_PATH_PROTOCOL *Instance;\r
+ EFI_DEVICE_PATH_PROTOCOL *FullInstance;\r
+ VOID *Interface;\r
+ EFI_HANDLE NewHandle;\r
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;\r
\r
ASSERT (VarName != NULL);\r
ASSERT (ConsoleHandle != NULL);\r
\r
if (*ConsoleHandle != NULL) {\r
Status = gBS->HandleProtocol (\r
- *ConsoleHandle,\r
- ConsoleGuid,\r
- &Interface\r
- );\r
- if (Status == EFI_SUCCESS && Interface == *ProtocolInterface) {\r
+ *ConsoleHandle,\r
+ ConsoleGuid,\r
+ &Interface\r
+ );\r
+ if ((Status == EFI_SUCCESS) && (Interface == *ProtocolInterface)) {\r
//\r
// If ConsoleHandle is valid and console protocol on this handle also\r
// also matched, just return.\r
//\r
// Get all possible consoles device path from EFI variable\r
//\r
- GetEfiGlobalVariable2 (VarName, (VOID **) &VarConsole, NULL);\r
+ GetEfiGlobalVariable2 (VarName, (VOID **)&VarConsole, NULL);\r
if (VarConsole == NULL) {\r
//\r
// If there is no any console device, just return.\r
//\r
// Check every instance of the console variable\r
//\r
- Instance = GetNextDevicePathInstance (&VarConsole, &DevicePathSize);\r
+ Instance = GetNextDevicePathInstance (&VarConsole, &DevicePathSize);\r
if (Instance == NULL) {\r
DEBUG ((DEBUG_ERROR, "[Bds] No valid console instance is found for %s!\n", VarName));\r
// We should not ASSERT when all the console devices are removed.\r
// Find console device handle by device path instance\r
//\r
FullInstance = Instance;\r
- Status = gBS->LocateDevicePath (\r
- ConsoleGuid,\r
- &Instance,\r
- &NewHandle\r
- );\r
+ Status = gBS->LocateDevicePath (\r
+ ConsoleGuid,\r
+ &Instance,\r
+ &NewHandle\r
+ );\r
FreePool (FullInstance);\r
if (!EFI_ERROR (Status)) {\r
//\r
//\r
// If it is console out device, set console mode 80x25 if current mode is invalid.\r
//\r
- TextOut = (EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *) Interface;\r
+ TextOut = (EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)Interface;\r
if (TextOut->Mode->Mode == -1) {\r
TextOut->SetMode (TextOut, 0);\r
}\r
}\r
+\r
FreePool (FullDevicePath);\r
return TRUE;\r
}\r
}\r
-\r
} while (Instance != NULL);\r
\r
//\r
if (CustomizedConDevicePath == ExclusiveDevicePath) {\r
return EFI_UNSUPPORTED;\r
}\r
+\r
//\r
// Delete the ExclusiveDevicePath from current default console\r
//\r
- GetEfiGlobalVariable2 (mConVarName[ConsoleType], (VOID **) &VarConsole, NULL);\r
+ GetEfiGlobalVariable2 (mConVarName[ConsoleType], (VOID **)&VarConsole, NULL);\r
//\r
// Initialize NewDevicePath\r
//\r
// If ExclusiveDevicePath is even the part of the instance in VarConsole, delete it.\r
// In the end, NewDevicePath is the final device path.\r
//\r
- if (ExclusiveDevicePath != NULL && VarConsole != NULL) {\r
- NewDevicePath = BmDelPartMatchInstance (VarConsole, ExclusiveDevicePath);\r
+ if ((ExclusiveDevicePath != NULL) && (VarConsole != NULL)) {\r
+ NewDevicePath = BmDelPartMatchInstance (VarConsole, ExclusiveDevicePath);\r
}\r
+\r
//\r
// Try to append customized device path to NewDevicePath.\r
//\r
// just append current customized device path\r
//\r
TempNewDevicePath = NewDevicePath;\r
- NewDevicePath = AppendDevicePathInstance (NewDevicePath, CustomizedConDevicePath);\r
+ NewDevicePath = AppendDevicePathInstance (NewDevicePath, CustomizedConDevicePath);\r
if (TempNewDevicePath != NULL) {\r
- FreePool(TempNewDevicePath);\r
+ FreePool (TempNewDevicePath);\r
}\r
}\r
}\r
mConVarName[ConsoleType],\r
&gEfiGlobalVariableGuid,\r
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS\r
- | ((ConsoleType < ConInDev) ? EFI_VARIABLE_NON_VOLATILE : 0),\r
+ | ((ConsoleType < ConInDev) ? EFI_VARIABLE_NON_VOLATILE : 0),\r
GetDevicePathSize (NewDevicePath),\r
NewDevicePath\r
);\r
\r
if (VarConsole == NewDevicePath) {\r
if (VarConsole != NULL) {\r
- FreePool(VarConsole);\r
+ FreePool (VarConsole);\r
}\r
} else {\r
if (VarConsole != NULL) {\r
- FreePool(VarConsole);\r
+ FreePool (VarConsole);\r
}\r
+\r
if (NewDevicePath != NULL) {\r
- FreePool(NewDevicePath);\r
+ FreePool (NewDevicePath);\r
}\r
}\r
\r
return Status;\r
}\r
\r
-\r
/**\r
Connect the console device base on the variable ConsoleType.\r
\r
EFI_STATUS\r
EFIAPI\r
EfiBootManagerConnectConsoleVariable (\r
- IN CONSOLE_TYPE ConsoleType\r
+ IN CONSOLE_TYPE ConsoleType\r
)\r
{\r
EFI_STATUS Status;\r
//\r
// Check if the console variable exist\r
//\r
- GetEfiGlobalVariable2 (mConVarName[ConsoleType], (VOID **) &StartDevicePath, NULL);\r
+ GetEfiGlobalVariable2 (mConVarName[ConsoleType], (VOID **)&StartDevicePath, NULL);\r
if (StartDevicePath == NULL) {\r
return EFI_UNSUPPORTED;\r
}\r
//\r
// Check every instance of the console variable\r
//\r
- Instance = GetNextDevicePathInstance (&CopyOfDevicePath, &Size);\r
+ Instance = GetNextDevicePathInstance (&CopyOfDevicePath, &Size);\r
if (Instance == NULL) {\r
FreePool (StartDevicePath);\r
return EFI_UNSUPPORTED;\r
}\r
\r
- Next = Instance;\r
+ Next = Instance;\r
while (!IsDevicePathEndType (Next)) {\r
Next = NextDevicePathNode (Next);\r
}\r
//\r
if ((DevicePathType (Instance) == MESSAGING_DEVICE_PATH) &&\r
((DevicePathSubType (Instance) == MSG_USB_CLASS_DP) || (DevicePathSubType (Instance) == MSG_USB_WWID_DP))\r
- ) {\r
+ )\r
+ {\r
Status = BmConnectUsbShortFormDevicePath (Instance);\r
if (!EFI_ERROR (Status)) {\r
DeviceExist = TRUE;\r
}\r
} else {\r
for (Next = Instance; !IsDevicePathEnd (Next); Next = NextDevicePathNode (Next)) {\r
- if (DevicePathType (Next) == ACPI_DEVICE_PATH && DevicePathSubType (Next) == ACPI_ADR_DP) {\r
+ if ((DevicePathType (Next) == ACPI_DEVICE_PATH) && (DevicePathSubType (Next) == ACPI_ADR_DP)) {\r
break;\r
- } else if (DevicePathType (Next) == HARDWARE_DEVICE_PATH &&\r
- DevicePathSubType (Next) == HW_CONTROLLER_DP &&\r
- DevicePathType (NextDevicePathNode (Next)) == ACPI_DEVICE_PATH &&\r
- DevicePathSubType (NextDevicePathNode (Next)) == ACPI_ADR_DP\r
- ) {\r
+ } else if ((DevicePathType (Next) == HARDWARE_DEVICE_PATH) &&\r
+ (DevicePathSubType (Next) == HW_CONTROLLER_DP) &&\r
+ (DevicePathType (NextDevicePathNode (Next)) == ACPI_DEVICE_PATH) &&\r
+ (DevicePathSubType (NextDevicePathNode (Next)) == ACPI_ADR_DP)\r
+ )\r
+ {\r
break;\r
}\r
}\r
+\r
if (!IsDevicePathEnd (Next)) {\r
//\r
// For GOP device path, start the video driver with NULL remaining device path\r
} else {\r
Status = EfiBootManagerConnectDevicePath (Instance, NULL);\r
}\r
+\r
if (EFI_ERROR (Status)) {\r
//\r
// Delete the instance from the console varialbe\r
DeviceExist = TRUE;\r
}\r
}\r
- FreePool(Instance);\r
+\r
+ FreePool (Instance);\r
} while (CopyOfDevicePath != NULL);\r
\r
FreePool (StartDevicePath);\r
return EFI_SUCCESS;\r
}\r
\r
-\r
/**\r
This function will search every input/output device in current system,\r
and make every input/output device as potential console device.\r
// Update all the console variables\r
//\r
gBS->LocateHandleBuffer (\r
- ByProtocol,\r
- &gEfiSimpleTextInProtocolGuid,\r
- NULL,\r
- &HandleCount,\r
- &HandleBuffer\r
- );\r
+ ByProtocol,\r
+ &gEfiSimpleTextInProtocolGuid,\r
+ NULL,\r
+ &HandleCount,\r
+ &HandleBuffer\r
+ );\r
\r
for (Index = 0; Index < HandleCount; Index++) {\r
gBS->HandleProtocol (\r
- HandleBuffer[Index],\r
- &gEfiDevicePathProtocolGuid,\r
- (VOID **) &ConDevicePath\r
- );\r
+ HandleBuffer[Index],\r
+ &gEfiDevicePathProtocolGuid,\r
+ (VOID **)&ConDevicePath\r
+ );\r
EfiBootManagerUpdateConsoleVariable (ConIn, ConDevicePath, NULL);\r
}\r
\r
if (HandleBuffer != NULL) {\r
- FreePool(HandleBuffer);\r
+ FreePool (HandleBuffer);\r
HandleBuffer = NULL;\r
}\r
\r
gBS->LocateHandleBuffer (\r
- ByProtocol,\r
- &gEfiSimpleTextOutProtocolGuid,\r
- NULL,\r
- &HandleCount,\r
- &HandleBuffer\r
- );\r
+ ByProtocol,\r
+ &gEfiSimpleTextOutProtocolGuid,\r
+ NULL,\r
+ &HandleCount,\r
+ &HandleBuffer\r
+ );\r
for (Index = 0; Index < HandleCount; Index++) {\r
gBS->HandleProtocol (\r
- HandleBuffer[Index],\r
- &gEfiDevicePathProtocolGuid,\r
- (VOID **) &ConDevicePath\r
- );\r
+ HandleBuffer[Index],\r
+ &gEfiDevicePathProtocolGuid,\r
+ (VOID **)&ConDevicePath\r
+ );\r
EfiBootManagerUpdateConsoleVariable (ConOut, ConDevicePath, NULL);\r
EfiBootManagerUpdateConsoleVariable (ErrOut, ConDevicePath, NULL);\r
}\r
\r
if (HandleBuffer != NULL) {\r
- FreePool(HandleBuffer);\r
+ FreePool (HandleBuffer);\r
}\r
\r
//\r
EfiBootManagerConnectAllDefaultConsoles ();\r
}\r
\r
-\r
/**\r
This function will connect all the console devices base on the console\r
device variable ConIn, ConOut and ErrOut.\r
VOID\r
)\r
{\r
- EFI_STATUS Status;\r
- BOOLEAN OneConnected;\r
- BOOLEAN SystemTableUpdated;\r
+ EFI_STATUS Status;\r
+ BOOLEAN OneConnected;\r
+ BOOLEAN SystemTableUpdated;\r
\r
OneConnected = FALSE;\r
\r
if (!EFI_ERROR (Status)) {\r
OneConnected = TRUE;\r
}\r
- PERF_EVENT ("ConOutReady");\r
\r
+ PERF_EVENT ("ConOutReady");\r
\r
Status = EfiBootManagerConnectConsoleVariable (ConIn);\r
if (!EFI_ERROR (Status)) {\r
OneConnected = TRUE;\r
}\r
+\r
PERF_EVENT ("ConInReady");\r
\r
Status = EfiBootManagerConnectConsoleVariable (ErrOut);\r
if (!EFI_ERROR (Status)) {\r
OneConnected = TRUE;\r
}\r
+\r
PERF_EVENT ("ErrOutReady");\r
\r
SystemTableUpdated = FALSE;\r
//\r
// Fill console handles in System Table if no console device assignd.\r
//\r
- if (BmUpdateSystemTableConsole (L"ConIn", &gEfiSimpleTextInProtocolGuid, &gST->ConsoleInHandle, (VOID **) &gST->ConIn)) {\r
+ if (BmUpdateSystemTableConsole (L"ConIn", &gEfiSimpleTextInProtocolGuid, &gST->ConsoleInHandle, (VOID **)&gST->ConIn)) {\r
SystemTableUpdated = TRUE;\r
}\r
- if (BmUpdateSystemTableConsole (L"ConOut", &gEfiSimpleTextOutProtocolGuid, &gST->ConsoleOutHandle, (VOID **) &gST->ConOut)) {\r
+\r
+ if (BmUpdateSystemTableConsole (L"ConOut", &gEfiSimpleTextOutProtocolGuid, &gST->ConsoleOutHandle, (VOID **)&gST->ConOut)) {\r
SystemTableUpdated = TRUE;\r
}\r
- if (BmUpdateSystemTableConsole (L"ErrOut", &gEfiSimpleTextOutProtocolGuid, &gST->StandardErrorHandle, (VOID **) &gST->StdErr)) {\r
+\r
+ if (BmUpdateSystemTableConsole (L"ErrOut", &gEfiSimpleTextOutProtocolGuid, &gST->StandardErrorHandle, (VOID **)&gST->StdErr)) {\r
SystemTableUpdated = TRUE;\r
}\r
\r
//\r
gST->Hdr.CRC32 = 0;\r
gBS->CalculateCrc32 (\r
- (UINT8 *) &gST->Hdr,\r
- gST->Hdr.HeaderSize,\r
- &gST->Hdr.CRC32\r
- );\r
+ (UINT8 *)&gST->Hdr,\r
+ gST->Hdr.HeaderSize,\r
+ &gST->Hdr.CRC32\r
+ );\r
}\r
\r
return OneConnected ? EFI_SUCCESS : EFI_DEVICE_ERROR;\r