2009-01-23 08:24:55 +01:00
|
|
|
/** @file
|
|
|
|
BDS Lib functions which contain all the code to connect console device
|
|
|
|
|
2011-06-02 03:48:33 +02:00
|
|
|
Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
|
2010-04-23 18:28:26 +02:00
|
|
|
This program and the accompanying materials
|
2009-01-23 08:24:55 +01:00
|
|
|
are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
which accompanies this distribution. The full text of the license may be found at
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include "InternalBdsLib.h"
|
2011-11-04 09:28:09 +01:00
|
|
|
#include <IndustryStandard/Bmp.h>
|
|
|
|
|
|
|
|
#include <Protocol/BootLogo.h>
|
2009-01-23 08:24:55 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
Check if we need to save the EFI variable with "ConVarName" as name
|
|
|
|
as NV type
|
2009-06-24 09:04:45 +02:00
|
|
|
If ConVarName is NULL, then ASSERT().
|
|
|
|
|
2009-01-23 08:24:55 +01:00
|
|
|
@param ConVarName The name of the EFI variable.
|
|
|
|
|
|
|
|
@retval TRUE Set the EFI variable as NV type.
|
|
|
|
@retval FALSE EFI variable as NV type can be set NonNV.
|
|
|
|
**/
|
|
|
|
BOOLEAN
|
|
|
|
IsNvNeed (
|
|
|
|
IN CHAR16 *ConVarName
|
|
|
|
)
|
|
|
|
{
|
|
|
|
CHAR16 *Ptr;
|
|
|
|
|
2009-06-24 09:04:45 +02:00
|
|
|
ASSERT (ConVarName != NULL);
|
|
|
|
|
2009-01-23 08:24:55 +01:00
|
|
|
Ptr = ConVarName;
|
|
|
|
|
|
|
|
//
|
|
|
|
// If the variable includes "Dev" at last, we consider
|
|
|
|
// it does not support NV attribute.
|
|
|
|
//
|
|
|
|
while (*Ptr != L'\0') {
|
|
|
|
Ptr++;
|
|
|
|
}
|
|
|
|
|
2009-06-24 09:50:36 +02:00
|
|
|
if (((INTN)((UINTN)Ptr - (UINTN)ConVarName) / sizeof (CHAR16)) <= 3) {
|
2009-06-23 10:42:38 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-01-23 08:24:55 +01:00
|
|
|
if ((*(Ptr - 3) == 'D') && (*(Ptr - 2) == 'e') && (*(Ptr - 1) == 'v')) {
|
|
|
|
return FALSE;
|
|
|
|
} else {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-10 04:10:15 +01:00
|
|
|
/**
|
|
|
|
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.
|
2009-04-07 10:42:15 +02:00
|
|
|
|
|
|
|
@retval TRUE System Table has been updated.
|
|
|
|
@retval FALSE System Table hasn't been updated.
|
|
|
|
|
2009-03-10 04:10:15 +01:00
|
|
|
**/
|
2009-04-07 10:42:15 +02:00
|
|
|
BOOLEAN
|
2009-03-10 04:10:15 +01:00
|
|
|
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.
|
|
|
|
//
|
2009-04-07 10:42:15 +02:00
|
|
|
return FALSE;
|
2009-03-10 04:10:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
2009-04-07 10:42:15 +02:00
|
|
|
return FALSE;
|
2009-03-10 04:10:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2009-04-07 10:42:15 +02:00
|
|
|
return TRUE;
|
2009-03-10 04:10:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} while (Instance != NULL);
|
|
|
|
|
|
|
|
//
|
|
|
|
// No any available console devcie found.
|
|
|
|
//
|
2009-04-07 10:42:15 +02:00
|
|
|
return FALSE;
|
2009-03-10 04:10:15 +01:00
|
|
|
}
|
|
|
|
|
2009-01-23 08:24:55 +01:00
|
|
|
/**
|
|
|
|
This function update console variable based on ConVarName, it can
|
|
|
|
add or remove one specific console device path from the variable
|
|
|
|
|
|
|
|
@param ConVarName Console related variable name, ConIn, ConOut,
|
|
|
|
ErrOut.
|
|
|
|
@param CustomizedConDevicePath The console device path which will be added to
|
|
|
|
the console variable ConVarName, this parameter
|
|
|
|
can not be multi-instance.
|
|
|
|
@param ExclusiveDevicePath The console device path which will be removed
|
|
|
|
from the console variable ConVarName, this
|
|
|
|
parameter can not be multi-instance.
|
|
|
|
|
|
|
|
@retval EFI_UNSUPPORTED The added device path is same to the removed one.
|
|
|
|
@retval EFI_SUCCESS Success add or remove the device path from the
|
|
|
|
console variable.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
BdsLibUpdateConsoleVariable (
|
|
|
|
IN CHAR16 *ConVarName,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *CustomizedConDevicePath,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *ExclusiveDevicePath
|
|
|
|
)
|
|
|
|
{
|
2011-06-02 03:48:33 +02:00
|
|
|
EFI_STATUS Status;
|
2009-01-23 08:24:55 +01:00
|
|
|
EFI_DEVICE_PATH_PROTOCOL *VarConsole;
|
|
|
|
UINTN DevicePathSize;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *TempNewDevicePath;
|
|
|
|
UINT32 Attributes;
|
|
|
|
|
|
|
|
VarConsole = NULL;
|
|
|
|
DevicePathSize = 0;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Notes: check the device path point, here should check
|
|
|
|
// with compare memory
|
|
|
|
//
|
|
|
|
if (CustomizedConDevicePath == ExclusiveDevicePath) {
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Delete the ExclusiveDevicePath from current default console
|
|
|
|
//
|
|
|
|
VarConsole = BdsLibGetVariableAndSize (
|
|
|
|
ConVarName,
|
|
|
|
&gEfiGlobalVariableGuid,
|
|
|
|
&DevicePathSize
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Initialize NewDevicePath
|
|
|
|
//
|
|
|
|
NewDevicePath = VarConsole;
|
|
|
|
|
|
|
|
//
|
|
|
|
// If ExclusiveDevicePath is even the part of the instance in VarConsole, delete it.
|
|
|
|
// In the end, NewDevicePath is the final device path.
|
|
|
|
//
|
|
|
|
if (ExclusiveDevicePath != NULL && VarConsole != NULL) {
|
|
|
|
NewDevicePath = BdsLibDelPartMatchInstance (VarConsole, ExclusiveDevicePath);
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Try to append customized device path to NewDevicePath.
|
|
|
|
//
|
|
|
|
if (CustomizedConDevicePath != NULL) {
|
|
|
|
if (!BdsLibMatchDevicePaths (NewDevicePath, CustomizedConDevicePath)) {
|
|
|
|
//
|
|
|
|
// Check if there is part of CustomizedConDevicePath in NewDevicePath, delete it.
|
|
|
|
//
|
|
|
|
NewDevicePath = BdsLibDelPartMatchInstance (NewDevicePath, CustomizedConDevicePath);
|
|
|
|
//
|
|
|
|
// In the first check, the default console variable will be _ModuleEntryPoint,
|
|
|
|
// just append current customized device path
|
|
|
|
//
|
|
|
|
TempNewDevicePath = NewDevicePath;
|
|
|
|
NewDevicePath = AppendDevicePathInstance (NewDevicePath, CustomizedConDevicePath);
|
|
|
|
if (TempNewDevicePath != NULL) {
|
|
|
|
FreePool(TempNewDevicePath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// The attribute for ConInDev, ConOutDev and ErrOutDev does not include NV.
|
|
|
|
//
|
|
|
|
if (IsNvNeed(ConVarName)) {
|
|
|
|
//
|
|
|
|
// ConVarName has NV attribute.
|
|
|
|
//
|
|
|
|
Attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE;
|
|
|
|
} else {
|
|
|
|
//
|
|
|
|
// ConVarName does not have NV attribute.
|
|
|
|
//
|
|
|
|
Attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Finally, Update the variable of the default console by NewDevicePath
|
|
|
|
//
|
2011-06-17 00:44:27 +02:00
|
|
|
DevicePathSize = GetDevicePathSize (NewDevicePath);
|
2011-06-02 03:48:33 +02:00
|
|
|
Status = gRT->SetVariable (
|
|
|
|
ConVarName,
|
|
|
|
&gEfiGlobalVariableGuid,
|
|
|
|
Attributes,
|
2011-06-17 00:44:27 +02:00
|
|
|
DevicePathSize,
|
2011-06-02 03:48:33 +02:00
|
|
|
NewDevicePath
|
|
|
|
);
|
2011-06-17 00:44:27 +02:00
|
|
|
if ((DevicePathSize == 0) && (Status == EFI_NOT_FOUND)) {
|
|
|
|
Status = EFI_SUCCESS;
|
|
|
|
}
|
2011-06-02 03:48:33 +02:00
|
|
|
ASSERT_EFI_ERROR (Status);
|
2009-01-23 08:24:55 +01:00
|
|
|
|
|
|
|
if (VarConsole == NewDevicePath) {
|
|
|
|
if (VarConsole != NULL) {
|
|
|
|
FreePool(VarConsole);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (VarConsole != NULL) {
|
|
|
|
FreePool(VarConsole);
|
|
|
|
}
|
|
|
|
if (NewDevicePath != NULL) {
|
|
|
|
FreePool(NewDevicePath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-17 00:44:27 +02:00
|
|
|
return Status;
|
2009-01-23 08:24:55 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Connect the console device base on the variable ConVarName, if
|
|
|
|
device path of the ConVarName is multi-instance device path, if
|
|
|
|
anyone of the instances is connected success, then this function
|
|
|
|
will return success.
|
|
|
|
|
|
|
|
@param ConVarName Console related variable name, ConIn, ConOut,
|
|
|
|
ErrOut.
|
|
|
|
|
|
|
|
@retval EFI_NOT_FOUND There is not any console devices connected
|
|
|
|
success
|
|
|
|
@retval EFI_SUCCESS Success connect any one instance of the console
|
|
|
|
device path base on the variable ConVarName.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
BdsLibConnectConsoleVariable (
|
|
|
|
IN CHAR16 *ConVarName
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *StartDevicePath;
|
|
|
|
UINTN VariableSize;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *Instance;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *Next;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *CopyOfDevicePath;
|
|
|
|
UINTN Size;
|
|
|
|
BOOLEAN DeviceExist;
|
|
|
|
|
|
|
|
Status = EFI_SUCCESS;
|
|
|
|
DeviceExist = FALSE;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Check if the console variable exist
|
|
|
|
//
|
|
|
|
StartDevicePath = BdsLibGetVariableAndSize (
|
|
|
|
ConVarName,
|
|
|
|
&gEfiGlobalVariableGuid,
|
|
|
|
&VariableSize
|
|
|
|
);
|
|
|
|
if (StartDevicePath == NULL) {
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
CopyOfDevicePath = StartDevicePath;
|
|
|
|
do {
|
|
|
|
//
|
|
|
|
// Check every instance of the console variable
|
|
|
|
//
|
|
|
|
Instance = GetNextDevicePathInstance (&CopyOfDevicePath, &Size);
|
|
|
|
if (Instance == NULL) {
|
|
|
|
FreePool (StartDevicePath);
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
Next = Instance;
|
|
|
|
while (!IsDevicePathEndType (Next)) {
|
|
|
|
Next = NextDevicePathNode (Next);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetDevicePathEndNode (Next);
|
|
|
|
//
|
2010-08-09 09:21:50 +02:00
|
|
|
// Connect the USB console
|
|
|
|
// USB console device path is a short-form device path that
|
|
|
|
// starts with the first element being a USB WWID
|
|
|
|
// or a USB Class device path
|
2009-01-23 08:24:55 +01:00
|
|
|
//
|
2009-08-31 04:39:56 +02:00
|
|
|
if ((DevicePathType (Instance) == MESSAGING_DEVICE_PATH) &&
|
|
|
|
((DevicePathSubType (Instance) == MSG_USB_CLASS_DP)
|
|
|
|
|| (DevicePathSubType (Instance) == MSG_USB_WWID_DP)
|
|
|
|
)) {
|
2010-08-09 09:21:50 +02:00
|
|
|
Status = BdsLibConnectUsbDevByShortFormDP (0xFF, Instance);
|
2009-08-31 04:39:56 +02:00
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
DeviceExist = TRUE;
|
|
|
|
}
|
2009-01-23 08:24:55 +01:00
|
|
|
} else {
|
2009-08-31 04:39:56 +02:00
|
|
|
//
|
|
|
|
// Connect the instance device path
|
|
|
|
//
|
|
|
|
Status = BdsLibConnectDevicePath (Instance);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
//
|
|
|
|
// Delete the instance from the console varialbe
|
|
|
|
//
|
|
|
|
BdsLibUpdateConsoleVariable (ConVarName, NULL, Instance);
|
|
|
|
} else {
|
|
|
|
DeviceExist = TRUE;
|
|
|
|
}
|
2009-01-23 08:24:55 +01:00
|
|
|
}
|
|
|
|
FreePool(Instance);
|
|
|
|
} while (CopyOfDevicePath != NULL);
|
|
|
|
|
|
|
|
FreePool (StartDevicePath);
|
|
|
|
|
|
|
|
if (!DeviceExist) {
|
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
This function will search every simpletext device in current system,
|
|
|
|
and make every simpletext device as pertantial console device.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
BdsLibConnectAllConsoles (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINTN Index;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *ConDevicePath;
|
|
|
|
UINTN HandleCount;
|
|
|
|
EFI_HANDLE *HandleBuffer;
|
|
|
|
|
|
|
|
Index = 0;
|
|
|
|
HandleCount = 0;
|
|
|
|
HandleBuffer = NULL;
|
|
|
|
ConDevicePath = NULL;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Update all the console variables
|
|
|
|
//
|
|
|
|
gBS->LocateHandleBuffer (
|
|
|
|
ByProtocol,
|
|
|
|
&gEfiSimpleTextInProtocolGuid,
|
|
|
|
NULL,
|
|
|
|
&HandleCount,
|
|
|
|
&HandleBuffer
|
|
|
|
);
|
|
|
|
|
|
|
|
for (Index = 0; Index < HandleCount; Index++) {
|
|
|
|
gBS->HandleProtocol (
|
|
|
|
HandleBuffer[Index],
|
|
|
|
&gEfiDevicePathProtocolGuid,
|
|
|
|
(VOID **) &ConDevicePath
|
|
|
|
);
|
|
|
|
BdsLibUpdateConsoleVariable (L"ConIn", ConDevicePath, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (HandleBuffer != NULL) {
|
|
|
|
FreePool(HandleBuffer);
|
|
|
|
HandleBuffer = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
gBS->LocateHandleBuffer (
|
|
|
|
ByProtocol,
|
|
|
|
&gEfiSimpleTextOutProtocolGuid,
|
|
|
|
NULL,
|
|
|
|
&HandleCount,
|
|
|
|
&HandleBuffer
|
|
|
|
);
|
|
|
|
for (Index = 0; Index < HandleCount; Index++) {
|
|
|
|
gBS->HandleProtocol (
|
|
|
|
HandleBuffer[Index],
|
|
|
|
&gEfiDevicePathProtocolGuid,
|
|
|
|
(VOID **) &ConDevicePath
|
|
|
|
);
|
|
|
|
BdsLibUpdateConsoleVariable (L"ConOut", ConDevicePath, NULL);
|
|
|
|
BdsLibUpdateConsoleVariable (L"ErrOut", ConDevicePath, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (HandleBuffer != NULL) {
|
|
|
|
FreePool(HandleBuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Connect all console variables
|
|
|
|
//
|
|
|
|
BdsLibConnectAllDefaultConsoles ();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
This function will connect console device base on the console
|
|
|
|
device variable ConIn, ConOut and ErrOut.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS At least one of the ConIn and ConOut device have
|
|
|
|
been connected success.
|
|
|
|
@retval EFI_STATUS Return the status of BdsLibConnectConsoleVariable ().
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
BdsLibConnectAllDefaultConsoles (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
2009-04-07 10:42:15 +02:00
|
|
|
BOOLEAN SystemTableUpdated;
|
2009-01-23 08:24:55 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Connect all default console variables
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
// It seems impossible not to have any ConOut device on platform,
|
|
|
|
// so we check the status here.
|
|
|
|
//
|
|
|
|
Status = BdsLibConnectConsoleVariable (L"ConOut");
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Insert the performance probe for Console Out
|
|
|
|
//
|
|
|
|
PERF_START (NULL, "ConOut", "BDS", 1);
|
|
|
|
PERF_END (NULL, "ConOut", "BDS", 0);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Because possibly the platform is legacy free, in such case,
|
|
|
|
// ConIn devices (Serial Port and PS2 Keyboard ) does not exist,
|
|
|
|
// so we need not check the status.
|
|
|
|
//
|
|
|
|
BdsLibConnectConsoleVariable (L"ConIn");
|
|
|
|
|
|
|
|
//
|
|
|
|
// The _ModuleEntryPoint err out var is legal.
|
|
|
|
//
|
|
|
|
BdsLibConnectConsoleVariable (L"ErrOut");
|
|
|
|
|
2009-04-07 10:42:15 +02:00
|
|
|
SystemTableUpdated = FALSE;
|
2009-03-10 04:10:15 +01:00
|
|
|
//
|
|
|
|
// Fill console handles in System Table if no console device assignd.
|
|
|
|
//
|
2009-04-07 10:42:15 +02:00
|
|
|
if (UpdateSystemTableConsole (L"ConIn", &gEfiSimpleTextInProtocolGuid, &gST->ConsoleInHandle, (VOID **) &gST->ConIn)) {
|
|
|
|
SystemTableUpdated = TRUE;
|
|
|
|
}
|
|
|
|
if (UpdateSystemTableConsole (L"ConOut", &gEfiSimpleTextOutProtocolGuid, &gST->ConsoleOutHandle, (VOID **) &gST->ConOut)) {
|
|
|
|
SystemTableUpdated = TRUE;
|
|
|
|
}
|
|
|
|
if (UpdateSystemTableConsole (L"ErrOut", &gEfiSimpleTextOutProtocolGuid, &gST->StandardErrorHandle, (VOID **) &gST->StdErr)) {
|
|
|
|
SystemTableUpdated = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SystemTableUpdated) {
|
|
|
|
//
|
|
|
|
// Update the CRC32 in the EFI System Table header
|
|
|
|
//
|
|
|
|
gST->Hdr.CRC32 = 0;
|
|
|
|
gBS->CalculateCrc32 (
|
|
|
|
(UINT8 *) &gST->Hdr,
|
|
|
|
gST->Hdr.HeaderSize,
|
|
|
|
&gST->Hdr.CRC32
|
|
|
|
);
|
|
|
|
}
|
2009-03-10 04:10:15 +01:00
|
|
|
|
2009-01-23 08:24:55 +01:00
|
|
|
return EFI_SUCCESS;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Convert a *.BMP graphics image to a GOP blt buffer. If a NULL Blt buffer
|
|
|
|
is passed in a GopBlt buffer will be allocated by this routine. If a GopBlt
|
|
|
|
buffer is passed in it will be used if it is big enough.
|
|
|
|
|
|
|
|
@param BmpImage Pointer to BMP file
|
|
|
|
@param BmpImageSize Number of bytes in BmpImage
|
|
|
|
@param GopBlt Buffer containing GOP version of BmpImage.
|
|
|
|
@param GopBltSize Size of GopBlt in bytes.
|
|
|
|
@param PixelHeight Height of GopBlt/BmpImage in pixels
|
|
|
|
@param PixelWidth Width of GopBlt/BmpImage in pixels
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS GopBlt and GopBltSize are returned.
|
|
|
|
@retval EFI_UNSUPPORTED BmpImage is not a valid *.BMP image
|
|
|
|
@retval EFI_BUFFER_TOO_SMALL The passed in GopBlt buffer is not big enough.
|
|
|
|
GopBltSize will contain the required size.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES No enough buffer to allocate.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
ConvertBmpToGopBlt (
|
|
|
|
IN VOID *BmpImage,
|
|
|
|
IN UINTN BmpImageSize,
|
|
|
|
IN OUT VOID **GopBlt,
|
|
|
|
IN OUT UINTN *GopBltSize,
|
|
|
|
OUT UINTN *PixelHeight,
|
|
|
|
OUT UINTN *PixelWidth
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINT8 *Image;
|
|
|
|
UINT8 *ImageHeader;
|
|
|
|
BMP_IMAGE_HEADER *BmpHeader;
|
|
|
|
BMP_COLOR_MAP *BmpColorMap;
|
|
|
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer;
|
|
|
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
|
2009-04-15 05:03:28 +02:00
|
|
|
UINT64 BltBufferSize;
|
2009-01-23 08:24:55 +01:00
|
|
|
UINTN Index;
|
|
|
|
UINTN Height;
|
|
|
|
UINTN Width;
|
|
|
|
UINTN ImageIndex;
|
|
|
|
BOOLEAN IsAllocated;
|
|
|
|
|
|
|
|
BmpHeader = (BMP_IMAGE_HEADER *) BmpImage;
|
|
|
|
|
|
|
|
if (BmpHeader->CharB != 'B' || BmpHeader->CharM != 'M') {
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Doesn't support compress.
|
|
|
|
//
|
|
|
|
if (BmpHeader->CompressionType != 0) {
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Calculate Color Map offset in the image.
|
|
|
|
//
|
|
|
|
Image = BmpImage;
|
|
|
|
BmpColorMap = (BMP_COLOR_MAP *) (Image + sizeof (BMP_IMAGE_HEADER));
|
|
|
|
|
|
|
|
//
|
|
|
|
// Calculate graphics image data address in the image
|
|
|
|
//
|
|
|
|
Image = ((UINT8 *) BmpImage) + BmpHeader->ImageOffset;
|
|
|
|
ImageHeader = Image;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Calculate the BltBuffer needed size.
|
|
|
|
//
|
2009-07-10 07:03:24 +02:00
|
|
|
BltBufferSize = MultU64x32 ((UINT64) BmpHeader->PixelWidth, BmpHeader->PixelHeight);
|
|
|
|
//
|
|
|
|
// Ensure the BltBufferSize * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) doesn't overflow
|
|
|
|
//
|
|
|
|
if (BltBufferSize > DivU64x32 ((UINTN) ~0, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL))) {
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
BltBufferSize = MultU64x32 (BltBufferSize, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
|
|
|
|
|
2009-01-23 08:24:55 +01:00
|
|
|
IsAllocated = FALSE;
|
|
|
|
if (*GopBlt == NULL) {
|
|
|
|
//
|
|
|
|
// GopBlt is not allocated by caller.
|
|
|
|
//
|
2009-04-15 05:03:28 +02:00
|
|
|
*GopBltSize = (UINTN) BltBufferSize;
|
2009-01-23 08:24:55 +01:00
|
|
|
*GopBlt = AllocatePool (*GopBltSize);
|
|
|
|
IsAllocated = TRUE;
|
|
|
|
if (*GopBlt == NULL) {
|
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//
|
|
|
|
// GopBlt has been allocated by caller.
|
|
|
|
//
|
2009-04-23 09:55:50 +02:00
|
|
|
if (*GopBltSize < (UINTN) BltBufferSize) {
|
2009-04-15 05:03:28 +02:00
|
|
|
*GopBltSize = (UINTN) BltBufferSize;
|
2009-01-23 08:24:55 +01:00
|
|
|
return EFI_BUFFER_TOO_SMALL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*PixelWidth = BmpHeader->PixelWidth;
|
|
|
|
*PixelHeight = BmpHeader->PixelHeight;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Convert image from BMP to Blt buffer format
|
|
|
|
//
|
|
|
|
BltBuffer = *GopBlt;
|
|
|
|
for (Height = 0; Height < BmpHeader->PixelHeight; Height++) {
|
|
|
|
Blt = &BltBuffer[(BmpHeader->PixelHeight - Height - 1) * BmpHeader->PixelWidth];
|
|
|
|
for (Width = 0; Width < BmpHeader->PixelWidth; Width++, Image++, Blt++) {
|
|
|
|
switch (BmpHeader->BitPerPixel) {
|
|
|
|
case 1:
|
|
|
|
//
|
|
|
|
// Convert 1-bit (2 colors) BMP to 24-bit color
|
|
|
|
//
|
|
|
|
for (Index = 0; Index < 8 && Width < BmpHeader->PixelWidth; Index++) {
|
|
|
|
Blt->Red = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Red;
|
|
|
|
Blt->Green = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Green;
|
|
|
|
Blt->Blue = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Blue;
|
|
|
|
Blt++;
|
|
|
|
Width++;
|
|
|
|
}
|
|
|
|
|
|
|
|
Blt--;
|
|
|
|
Width--;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
//
|
|
|
|
// Convert 4-bit (16 colors) BMP Palette to 24-bit color
|
|
|
|
//
|
|
|
|
Index = (*Image) >> 4;
|
|
|
|
Blt->Red = BmpColorMap[Index].Red;
|
|
|
|
Blt->Green = BmpColorMap[Index].Green;
|
|
|
|
Blt->Blue = BmpColorMap[Index].Blue;
|
|
|
|
if (Width < (BmpHeader->PixelWidth - 1)) {
|
|
|
|
Blt++;
|
|
|
|
Width++;
|
|
|
|
Index = (*Image) & 0x0f;
|
|
|
|
Blt->Red = BmpColorMap[Index].Red;
|
|
|
|
Blt->Green = BmpColorMap[Index].Green;
|
|
|
|
Blt->Blue = BmpColorMap[Index].Blue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
//
|
|
|
|
// Convert 8-bit (256 colors) BMP Palette to 24-bit color
|
|
|
|
//
|
|
|
|
Blt->Red = BmpColorMap[*Image].Red;
|
|
|
|
Blt->Green = BmpColorMap[*Image].Green;
|
|
|
|
Blt->Blue = BmpColorMap[*Image].Blue;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 24:
|
|
|
|
//
|
|
|
|
// It is 24-bit BMP.
|
|
|
|
//
|
|
|
|
Blt->Blue = *Image++;
|
|
|
|
Blt->Green = *Image++;
|
|
|
|
Blt->Red = *Image;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
//
|
|
|
|
// Other bit format BMP is not supported.
|
|
|
|
//
|
|
|
|
if (IsAllocated) {
|
|
|
|
FreePool (*GopBlt);
|
|
|
|
*GopBlt = NULL;
|
|
|
|
}
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ImageIndex = (UINTN) (Image - ImageHeader);
|
|
|
|
if ((ImageIndex % 4) != 0) {
|
|
|
|
//
|
|
|
|
// Bmp Image starts each row on a 32-bit boundary!
|
|
|
|
//
|
|
|
|
Image = Image + (4 - (ImageIndex % 4));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-07-10 05:26:52 +02:00
|
|
|
Use SystemTable Conout to stop video based Simple Text Out consoles from going
|
|
|
|
to the video device. Put up LogoFile on every video device that is a console.
|
2009-01-23 08:24:55 +01:00
|
|
|
|
|
|
|
@param[in] LogoFile File name of logo to display on the center of the screen.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS ConsoleControl has been flipped to graphics and logo displayed.
|
|
|
|
@retval EFI_UNSUPPORTED Logo not found
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
EnableQuietBoot (
|
|
|
|
IN EFI_GUID *LogoFile
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_OEM_BADGING_PROTOCOL *Badging;
|
|
|
|
UINT32 SizeOfX;
|
|
|
|
UINT32 SizeOfY;
|
|
|
|
INTN DestX;
|
|
|
|
INTN DestY;
|
|
|
|
UINT8 *ImageData;
|
|
|
|
UINTN ImageSize;
|
|
|
|
UINTN BltSize;
|
|
|
|
UINT32 Instance;
|
|
|
|
EFI_BADGING_FORMAT Format;
|
|
|
|
EFI_BADGING_DISPLAY_ATTRIBUTE Attribute;
|
|
|
|
UINTN CoordinateX;
|
|
|
|
UINTN CoordinateY;
|
|
|
|
UINTN Height;
|
|
|
|
UINTN Width;
|
|
|
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
|
|
|
|
EFI_UGA_DRAW_PROTOCOL *UgaDraw;
|
|
|
|
UINT32 ColorDepth;
|
|
|
|
UINT32 RefreshRate;
|
|
|
|
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
|
2011-11-04 09:28:09 +01:00
|
|
|
EFI_BOOT_LOGO_PROTOCOL *BootLogo;
|
|
|
|
UINTN NumberOfLogos;
|
|
|
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *LogoBlt;
|
|
|
|
UINTN LogoDestX;
|
|
|
|
UINTN LogoDestY;
|
|
|
|
UINTN LogoHeight;
|
|
|
|
UINTN LogoWidth;
|
|
|
|
UINTN NewDestX;
|
|
|
|
UINTN NewDestY;
|
|
|
|
UINTN NewHeight;
|
|
|
|
UINTN NewWidth;
|
2009-01-23 08:24:55 +01:00
|
|
|
|
|
|
|
UgaDraw = NULL;
|
|
|
|
//
|
|
|
|
// Try to open GOP first
|
|
|
|
//
|
|
|
|
Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, (VOID **) &GraphicsOutput);
|
|
|
|
if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {
|
|
|
|
GraphicsOutput = NULL;
|
|
|
|
//
|
|
|
|
// Open GOP failed, try to open UGA
|
|
|
|
//
|
|
|
|
Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiUgaDrawProtocolGuid, (VOID **) &UgaDraw);
|
|
|
|
}
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
2011-11-04 09:28:09 +01:00
|
|
|
//
|
|
|
|
// Try to open Boot Logo Protocol.
|
|
|
|
//
|
|
|
|
BootLogo = NULL;
|
|
|
|
gBS->LocateProtocol (&gEfiBootLogoProtocolGuid, NULL, (VOID **) &BootLogo);
|
|
|
|
|
2009-01-23 08:24:55 +01:00
|
|
|
//
|
2009-03-20 10:25:28 +01:00
|
|
|
// Erase Cursor from screen
|
2009-01-23 08:24:55 +01:00
|
|
|
//
|
2009-03-20 10:25:28 +01:00
|
|
|
gST->ConOut->EnableCursor (gST->ConOut, FALSE);
|
|
|
|
|
|
|
|
Badging = NULL;
|
|
|
|
Status = gBS->LocateProtocol (&gEfiOEMBadgingProtocolGuid, NULL, (VOID **) &Badging);
|
2009-01-23 08:24:55 +01:00
|
|
|
|
|
|
|
if (GraphicsOutput != NULL) {
|
|
|
|
SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution;
|
|
|
|
SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution;
|
|
|
|
|
|
|
|
} else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {
|
|
|
|
Status = UgaDraw->GetMode (UgaDraw, &SizeOfX, &SizeOfY, &ColorDepth, &RefreshRate);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
2011-11-04 09:28:09 +01:00
|
|
|
Blt = NULL;
|
|
|
|
NumberOfLogos = 0;
|
|
|
|
LogoDestX = 0;
|
|
|
|
LogoDestY = 0;
|
|
|
|
LogoHeight = 0;
|
|
|
|
LogoWidth = 0;
|
|
|
|
NewDestX = 0;
|
|
|
|
NewDestY = 0;
|
|
|
|
NewHeight = 0;
|
|
|
|
NewWidth = 0;
|
2009-01-23 08:24:55 +01:00
|
|
|
Instance = 0;
|
|
|
|
while (1) {
|
|
|
|
ImageData = NULL;
|
|
|
|
ImageSize = 0;
|
|
|
|
|
|
|
|
if (Badging != NULL) {
|
|
|
|
//
|
|
|
|
// Get image from OEMBadging protocol.
|
|
|
|
//
|
|
|
|
Status = Badging->GetImage (
|
|
|
|
Badging,
|
|
|
|
&Instance,
|
|
|
|
&Format,
|
|
|
|
&ImageData,
|
|
|
|
&ImageSize,
|
|
|
|
&Attribute,
|
|
|
|
&CoordinateX,
|
|
|
|
&CoordinateY
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
2011-11-04 09:28:09 +01:00
|
|
|
goto Done;
|
2009-01-23 08:24:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Currently only support BMP format.
|
|
|
|
//
|
|
|
|
if (Format != EfiBadgingFormatBMP) {
|
|
|
|
if (ImageData != NULL) {
|
|
|
|
FreePool (ImageData);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//
|
|
|
|
// Get the specified image from FV.
|
|
|
|
//
|
|
|
|
Status = GetSectionFromAnyFv (LogoFile, EFI_SECTION_RAW, 0, (VOID **) &ImageData, &ImageSize);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
CoordinateX = 0;
|
|
|
|
CoordinateY = 0;
|
|
|
|
Attribute = EfiBadgingDisplayAttributeCenter;
|
|
|
|
}
|
|
|
|
|
2011-11-04 09:28:09 +01:00
|
|
|
if (Blt != NULL) {
|
|
|
|
FreePool (Blt);
|
|
|
|
}
|
2009-01-23 08:24:55 +01:00
|
|
|
Blt = NULL;
|
|
|
|
Status = ConvertBmpToGopBlt (
|
|
|
|
ImageData,
|
|
|
|
ImageSize,
|
|
|
|
(VOID **) &Blt,
|
|
|
|
&BltSize,
|
|
|
|
&Height,
|
|
|
|
&Width
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
FreePool (ImageData);
|
|
|
|
|
|
|
|
if (Badging == NULL) {
|
|
|
|
return Status;
|
|
|
|
} else {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Calculate the display position according to Attribute.
|
|
|
|
//
|
|
|
|
switch (Attribute) {
|
|
|
|
case EfiBadgingDisplayAttributeLeftTop:
|
|
|
|
DestX = CoordinateX;
|
|
|
|
DestY = CoordinateY;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EfiBadgingDisplayAttributeCenterTop:
|
|
|
|
DestX = (SizeOfX - Width) / 2;
|
|
|
|
DestY = CoordinateY;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EfiBadgingDisplayAttributeRightTop:
|
|
|
|
DestX = (SizeOfX - Width - CoordinateX);
|
|
|
|
DestY = CoordinateY;;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EfiBadgingDisplayAttributeCenterRight:
|
|
|
|
DestX = (SizeOfX - Width - CoordinateX);
|
|
|
|
DestY = (SizeOfY - Height) / 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EfiBadgingDisplayAttributeRightBottom:
|
|
|
|
DestX = (SizeOfX - Width - CoordinateX);
|
|
|
|
DestY = (SizeOfY - Height - CoordinateY);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EfiBadgingDisplayAttributeCenterBottom:
|
|
|
|
DestX = (SizeOfX - Width) / 2;
|
|
|
|
DestY = (SizeOfY - Height - CoordinateY);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EfiBadgingDisplayAttributeLeftBottom:
|
|
|
|
DestX = CoordinateX;
|
|
|
|
DestY = (SizeOfY - Height - CoordinateY);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EfiBadgingDisplayAttributeCenterLeft:
|
|
|
|
DestX = CoordinateX;
|
|
|
|
DestY = (SizeOfY - Height) / 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EfiBadgingDisplayAttributeCenter:
|
|
|
|
DestX = (SizeOfX - Width) / 2;
|
|
|
|
DestY = (SizeOfY - Height) / 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DestX = CoordinateX;
|
|
|
|
DestY = CoordinateY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((DestX >= 0) && (DestY >= 0)) {
|
|
|
|
if (GraphicsOutput != NULL) {
|
|
|
|
Status = GraphicsOutput->Blt (
|
|
|
|
GraphicsOutput,
|
|
|
|
Blt,
|
|
|
|
EfiBltBufferToVideo,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
(UINTN) DestX,
|
|
|
|
(UINTN) DestY,
|
|
|
|
Width,
|
|
|
|
Height,
|
|
|
|
Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
|
|
|
|
);
|
|
|
|
} else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {
|
|
|
|
Status = UgaDraw->Blt (
|
|
|
|
UgaDraw,
|
|
|
|
(EFI_UGA_PIXEL *) Blt,
|
|
|
|
EfiUgaBltBufferToVideo,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
(UINTN) DestX,
|
|
|
|
(UINTN) DestY,
|
|
|
|
Width,
|
|
|
|
Height,
|
|
|
|
Width * sizeof (EFI_UGA_PIXEL)
|
|
|
|
);
|
|
|
|
} else {
|
2011-11-04 09:28:09 +01:00
|
|
|
Status = EFI_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Report displayed Logo information.
|
|
|
|
//
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
NumberOfLogos++;
|
|
|
|
|
|
|
|
if (LogoWidth == 0) {
|
|
|
|
//
|
|
|
|
// The first Logo.
|
|
|
|
//
|
2011-11-07 04:35:21 +01:00
|
|
|
LogoDestX = (UINTN) DestX;
|
|
|
|
LogoDestY = (UINTN) DestY;
|
2011-11-04 09:28:09 +01:00
|
|
|
LogoWidth = Width;
|
|
|
|
LogoHeight = Height;
|
|
|
|
} else {
|
|
|
|
//
|
|
|
|
// Merge new logo with old one.
|
|
|
|
//
|
|
|
|
NewDestX = MIN ((UINTN) DestX, LogoDestX);
|
|
|
|
NewDestY = MIN ((UINTN) DestY, LogoDestY);
|
|
|
|
NewWidth = MAX ((UINTN) DestX + Width, LogoDestX + LogoWidth) - NewDestX;
|
|
|
|
NewHeight = MAX ((UINTN) DestY + Height, LogoDestY + LogoHeight) - NewDestY;
|
|
|
|
|
|
|
|
LogoDestX = NewDestX;
|
|
|
|
LogoDestY = NewDestY;
|
|
|
|
LogoWidth = NewWidth;
|
|
|
|
LogoHeight = NewHeight;
|
|
|
|
}
|
2009-01-23 08:24:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FreePool (ImageData);
|
|
|
|
|
2011-11-04 09:28:09 +01:00
|
|
|
if (Badging == NULL) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Done:
|
|
|
|
if (BootLogo == NULL || NumberOfLogos == 0) {
|
|
|
|
//
|
|
|
|
// No logo displayed.
|
|
|
|
//
|
2009-01-23 08:24:55 +01:00
|
|
|
if (Blt != NULL) {
|
|
|
|
FreePool (Blt);
|
|
|
|
}
|
|
|
|
|
2011-11-04 09:28:09 +01:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Advertise displayed Logo information.
|
|
|
|
//
|
|
|
|
if (NumberOfLogos == 1) {
|
|
|
|
//
|
|
|
|
// Only one logo displayed, use its Blt buffer directly for BootLogo protocol.
|
|
|
|
//
|
|
|
|
LogoBlt = Blt;
|
|
|
|
Status = EFI_SUCCESS;
|
|
|
|
} else {
|
|
|
|
//
|
|
|
|
// More than one Logo displayed, get merged BltBuffer using VideoToBuffer operation.
|
|
|
|
//
|
|
|
|
if (Blt != NULL) {
|
|
|
|
FreePool (Blt);
|
|
|
|
}
|
|
|
|
|
|
|
|
LogoBlt = AllocateZeroPool (LogoWidth * LogoHeight * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
|
|
|
|
if (LogoBlt == NULL) {
|
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GraphicsOutput != NULL) {
|
|
|
|
Status = GraphicsOutput->Blt (
|
|
|
|
GraphicsOutput,
|
|
|
|
LogoBlt,
|
|
|
|
EfiBltVideoToBltBuffer,
|
|
|
|
LogoDestX,
|
|
|
|
LogoDestY,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
LogoWidth,
|
|
|
|
LogoHeight,
|
|
|
|
LogoWidth * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
|
|
|
|
);
|
|
|
|
} else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {
|
|
|
|
Status = UgaDraw->Blt (
|
|
|
|
UgaDraw,
|
|
|
|
(EFI_UGA_PIXEL *) LogoBlt,
|
|
|
|
EfiUgaVideoToBltBuffer,
|
|
|
|
LogoDestX,
|
|
|
|
LogoDestY,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
LogoWidth,
|
|
|
|
LogoHeight,
|
|
|
|
LogoWidth * sizeof (EFI_UGA_PIXEL)
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
Status = EFI_UNSUPPORTED;
|
2009-01-23 08:24:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-04 09:28:09 +01:00
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
BootLogo->SetBootLogo (BootLogo, LogoBlt, LogoDestX, LogoDestY, LogoWidth, LogoHeight);
|
|
|
|
}
|
|
|
|
FreePool (LogoBlt);
|
|
|
|
|
2009-01-23 08:24:55 +01:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-07-10 05:26:52 +02:00
|
|
|
Use SystemTable Conout to turn on video based Simple Text Out consoles. The
|
|
|
|
Simple Text Out screens will now be synced up with all non video output devices
|
2009-01-23 08:24:55 +01:00
|
|
|
|
|
|
|
@retval EFI_SUCCESS UGA devices are back in text mode and synced up.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
DisableQuietBoot (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
|
|
|
|
//
|
2009-03-20 10:25:28 +01:00
|
|
|
// Enable Cursor on Screen
|
2009-01-23 08:24:55 +01:00
|
|
|
//
|
2009-03-20 10:25:28 +01:00
|
|
|
gST->ConOut->EnableCursor (gST->ConOut, TRUE);
|
|
|
|
return EFI_SUCCESS;
|
2009-01-23 08:24:55 +01:00
|
|
|
}
|
|
|
|
|