1. retried PrimaryConsoleInDeviceGuid, PrimaryConsoleOutDeviceGuid and PrimaryStandardErrorDeviceGuid.

Consplitter will not install these protocols any more.

2. added logic in Bds to check console handles in System table, if no console handle assigned. Bds module will fill these handles in system table accordingly.

3. fixed one bug before call ConsoleControl->SetMode in FrontPage.c.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7841 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
vanjeff
2009-03-10 03:10:15 +00:00
parent 9dca4c66c2
commit dad608335f
9 changed files with 122 additions and 102 deletions

View File

@@ -48,6 +48,117 @@ IsNvNeed (
}
}
/**
Fill console handle in System Table if there are no valid console handle in.
Firstly, check the validation of console handle in System Table. If it is invalid,
update it by the first console device handle from EFI console variable.
@param VarName The name of the EFI console variable.
@param ConsoleGuid Specified Console protocol GUID.
@param ConsoleHandle On IN, console handle in System Table to be checked.
On OUT, new console hanlde in system table.
@param ProtocolInterface On IN, console protocol on console handle in System Table to be checked.
On OUT, new console protocol on new console hanlde in system table.
**/
VOID
UpdateSystemTableConsole (
IN CHAR16 *VarName,
IN EFI_GUID *ConsoleGuid,
IN OUT EFI_HANDLE *ConsoleHandle,
IN OUT VOID **ProtocolInterface
)
{
EFI_STATUS Status;
UINTN DevicePathSize;
EFI_DEVICE_PATH_PROTOCOL *FullDevicePath;
EFI_DEVICE_PATH_PROTOCOL *VarConsole;
EFI_DEVICE_PATH_PROTOCOL *Instance;
VOID *Interface;
EFI_HANDLE NewHandle;
ASSERT (VarName != NULL);
ASSERT (ConsoleHandle != NULL);
ASSERT (ConsoleGuid != NULL);
ASSERT (ProtocolInterface != NULL);
if (*ConsoleHandle != NULL) {
Status = gBS->HandleProtocol (
*ConsoleHandle,
ConsoleGuid,
&Interface
);
if (Status == EFI_SUCCESS && Interface == *ProtocolInterface) {
//
// If ConsoleHandle is valid and console protocol on this handle also
// also matched, just return.
//
return;
}
}
//
// Get all possible consoles device path from EFI variable
//
VarConsole = BdsLibGetVariableAndSize (
VarName,
&gEfiGlobalVariableGuid,
&DevicePathSize
);
if (VarConsole == NULL) {
//
// If there is no any console device, just return.
//
return ;
}
FullDevicePath = VarConsole;
do {
//
// Check every instance of the console variable
//
Instance = GetNextDevicePathInstance (&VarConsole, &DevicePathSize);
if (Instance == NULL) {
FreePool (FullDevicePath);
ASSERT (FALSE);
}
//
// Find console device handle by device path instance
//
Status = gBS->LocateDevicePath (
ConsoleGuid,
&Instance,
&NewHandle
);
if (!EFI_ERROR (Status)) {
//
// Get the console protocol on this console device handle
//
Status = gBS->HandleProtocol (
NewHandle,
ConsoleGuid,
&Interface
);
if (!EFI_ERROR (Status)) {
//
// Update new console handle in System Table.
//
*ConsoleHandle = NewHandle;
*ProtocolInterface = Interface;
return ;
}
}
} while (Instance != NULL);
//
// No any available console devcie found.
//
ASSERT (FALSE);
}
/**
This function update console variable based on ConVarName, it can
add or remove one specific console device path from the variable
@@ -406,6 +517,13 @@ BdsLibConnectAllDefaultConsoles (
//
BdsLibConnectConsoleVariable (L"ErrOut");
//
// Fill console handles in System Table if no console device assignd.
//
UpdateSystemTableConsole (L"ConIn", &gEfiSimpleTextInProtocolGuid, &gST->ConsoleInHandle, (VOID **) &gST->ConIn);
UpdateSystemTableConsole (L"ConOut", &gEfiSimpleTextOutProtocolGuid, &gST->ConsoleOutHandle, (VOID **) &gST->ConOut);
UpdateSystemTableConsole (L"ErrOut", &gEfiSimpleTextOutProtocolGuid, &gST->StandardErrorHandle, (VOID **) &gST->StdErr);
return EFI_SUCCESS;
}