UEFI HII: Merge UEFI HII support changes from branch.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4599 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
1912
MdeModulePkg/Library/GenericBdsLib/BdsBoot.c
Normal file
1912
MdeModulePkg/Library/GenericBdsLib/BdsBoot.c
Normal file
File diff suppressed because it is too large
Load Diff
424
MdeModulePkg/Library/GenericBdsLib/BdsConnect.c
Normal file
424
MdeModulePkg/Library/GenericBdsLib/BdsConnect.c
Normal file
@@ -0,0 +1,424 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2004 - 2007, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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.
|
||||
|
||||
Module Name:
|
||||
|
||||
BdsConnect.c
|
||||
|
||||
Abstract:
|
||||
|
||||
BDS Lib functions which relate with connect the device
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#include "InternalBdsLib.h"
|
||||
|
||||
|
||||
/**
|
||||
This function will connect all the system driver to controller
|
||||
first, and then special connect the default console, this make
|
||||
sure all the system controller avialbe and the platform default
|
||||
console connected.
|
||||
|
||||
None
|
||||
|
||||
@return None
|
||||
|
||||
**/
|
||||
VOID
|
||||
BdsLibConnectAll (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
//
|
||||
// Connect the platform console first
|
||||
//
|
||||
BdsLibConnectAllDefaultConsoles ();
|
||||
|
||||
//
|
||||
// Generic way to connect all the drivers
|
||||
//
|
||||
BdsLibConnectAllDriversToAllControllers ();
|
||||
|
||||
//
|
||||
// Here we have the assumption that we have already had
|
||||
// platform default console
|
||||
//
|
||||
BdsLibConnectAllDefaultConsoles ();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function will connect all the system drivers to all controllers
|
||||
first, and then connect all the console devices the system current
|
||||
have. After this we should get all the device work and console avariable
|
||||
if the system have console device.
|
||||
|
||||
None
|
||||
|
||||
@return None
|
||||
|
||||
**/
|
||||
VOID
|
||||
BdsLibGenericConnectAll (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
//
|
||||
// Most generic way to connect all the drivers
|
||||
//
|
||||
BdsLibConnectAllDriversToAllControllers ();
|
||||
BdsLibConnectAllConsoles ();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function will create all handles associate with every device
|
||||
path node. If the handle associate with one device path node can not
|
||||
be created success, then still give one chance to do the dispatch,
|
||||
which load the missing drivers if possible.
|
||||
|
||||
@param DevicePathToConnect The device path which will be connected, it can be
|
||||
a multi-instance device path
|
||||
|
||||
@retval EFI_SUCCESS All handles associate with every device path node
|
||||
have been created
|
||||
@retval EFI_OUT_OF_RESOURCES There is no resource to create new handles
|
||||
@retval EFI_NOT_FOUND Create the handle associate with one device path
|
||||
node failed
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
BdsLibConnectDevicePath (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
EFI_DEVICE_PATH_PROTOCOL *CopyOfDevicePath;
|
||||
EFI_DEVICE_PATH_PROTOCOL *Instance;
|
||||
EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath;
|
||||
EFI_DEVICE_PATH_PROTOCOL *Next;
|
||||
EFI_HANDLE Handle;
|
||||
EFI_HANDLE PreviousHandle;
|
||||
UINTN Size;
|
||||
|
||||
if (DevicePathToConnect == NULL) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
DevicePath = DuplicateDevicePath (DevicePathToConnect);
|
||||
CopyOfDevicePath = DevicePath;
|
||||
if (DevicePath == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
do {
|
||||
//
|
||||
// The outer loop handles multi instance device paths.
|
||||
// Only console variables contain multiple instance device paths.
|
||||
//
|
||||
// After this call DevicePath points to the next Instance
|
||||
//
|
||||
Instance = GetNextDevicePathInstance (&DevicePath, &Size);
|
||||
Next = Instance;
|
||||
while (!IsDevicePathEndType (Next)) {
|
||||
Next = NextDevicePathNode (Next);
|
||||
}
|
||||
|
||||
SetDevicePathEndNode (Next);
|
||||
|
||||
//
|
||||
// Start the real work of connect with RemainingDevicePath
|
||||
//
|
||||
PreviousHandle = NULL;
|
||||
do {
|
||||
//
|
||||
// Find the handle that best matches the Device Path. If it is only a
|
||||
// partial match the remaining part of the device path is returned in
|
||||
// RemainingDevicePath.
|
||||
//
|
||||
RemainingDevicePath = Instance;
|
||||
Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &Handle);
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
if (Handle == PreviousHandle) {
|
||||
//
|
||||
// If no forward progress is made try invoking the Dispatcher.
|
||||
// A new FV may have been added to the system an new drivers
|
||||
// may now be found.
|
||||
// Status == EFI_SUCCESS means a driver was dispatched
|
||||
// Status == EFI_NOT_FOUND means no new drivers were dispatched
|
||||
//
|
||||
Status = gDS->Dispatch ();
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
PreviousHandle = Handle;
|
||||
//
|
||||
// Connect all drivers that apply to Handle and RemainingDevicePath,
|
||||
// the Recursive flag is FALSE so only one level will be expanded.
|
||||
//
|
||||
// Do not check the connect status here, if the connect controller fail,
|
||||
// then still give the chance to do dispatch, because partial
|
||||
// RemainingDevicepath may be in the new FV
|
||||
//
|
||||
// 1. If the connect fail, RemainingDevicepath and handle will not
|
||||
// change, so next time will do the dispatch, then dispatch's status
|
||||
// will take effect
|
||||
// 2. If the connect success, the RemainingDevicepath and handle will
|
||||
// change, then avoid the dispatch, we have chance to continue the
|
||||
// next connection
|
||||
//
|
||||
gBS->ConnectController (Handle, NULL, RemainingDevicePath, FALSE);
|
||||
}
|
||||
}
|
||||
//
|
||||
// Loop until RemainingDevicePath is an empty device path
|
||||
//
|
||||
} while (!EFI_ERROR (Status) && !IsDevicePathEnd (RemainingDevicePath));
|
||||
|
||||
} while (DevicePath != NULL);
|
||||
|
||||
if (CopyOfDevicePath != NULL) {
|
||||
gBS->FreePool (CopyOfDevicePath);
|
||||
}
|
||||
//
|
||||
// All handle with DevicePath exists in the handle database
|
||||
//
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function will connect all current system handles recursively. The
|
||||
connection will finish until every handle's child handle created if it have.
|
||||
|
||||
None
|
||||
|
||||
@retval EFI_SUCCESS All handles and it's child handle have been
|
||||
connected
|
||||
@retval EFI_STATUS Return the status of gBS->LocateHandleBuffer().
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
BdsLibConnectAllEfi (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN HandleCount;
|
||||
EFI_HANDLE *HandleBuffer;
|
||||
UINTN Index;
|
||||
|
||||
Status = gBS->LocateHandleBuffer (
|
||||
AllHandles,
|
||||
NULL,
|
||||
NULL,
|
||||
&HandleCount,
|
||||
&HandleBuffer
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
for (Index = 0; Index < HandleCount; Index++) {
|
||||
Status = gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
|
||||
}
|
||||
|
||||
gBS->FreePool (HandleBuffer);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function will disconnect all current system handles. The disconnection
|
||||
will finish until every handle have been disconnected.
|
||||
|
||||
None
|
||||
|
||||
@retval EFI_SUCCESS All handles have been disconnected
|
||||
@retval EFI_STATUS Return the status of gBS->LocateHandleBuffer().
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
BdsLibDisconnectAllEfi (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN HandleCount;
|
||||
EFI_HANDLE *HandleBuffer;
|
||||
UINTN Index;
|
||||
|
||||
//
|
||||
// Disconnect all
|
||||
//
|
||||
Status = gBS->LocateHandleBuffer (
|
||||
AllHandles,
|
||||
NULL,
|
||||
NULL,
|
||||
&HandleCount,
|
||||
&HandleBuffer
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
for (Index = 0; Index < HandleCount; Index++) {
|
||||
Status = gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);
|
||||
}
|
||||
|
||||
gBS->FreePool (HandleBuffer);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Connects all drivers to all controllers.
|
||||
This function make sure all the current system driver will manage
|
||||
the correspoinding controllers if have. And at the same time, make
|
||||
sure all the system controllers have driver to manage it if have.
|
||||
|
||||
None
|
||||
|
||||
@return None
|
||||
|
||||
**/
|
||||
VOID
|
||||
BdsLibConnectAllDriversToAllControllers (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
do {
|
||||
//
|
||||
// Connect All EFI 1.10 drivers following EFI 1.10 algorithm
|
||||
//
|
||||
BdsLibConnectAllEfi ();
|
||||
|
||||
//
|
||||
// Check to see if it's possible to dispatch an more DXE drivers.
|
||||
// The BdsLibConnectAllEfi () may have made new DXE drivers show up.
|
||||
// If anything is Dispatched Status == EFI_SUCCESS and we will try
|
||||
// the connect again.
|
||||
//
|
||||
Status = gDS->Dispatch ();
|
||||
|
||||
} while (!EFI_ERROR (Status));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Connect the specific Usb device which match the short form device path,
|
||||
and whose bus is determined by Host Controller (Uhci or Ehci)
|
||||
|
||||
@param HostControllerPI Uhci (0x00) or Ehci (0x20) or Both uhci and ehci
|
||||
(0xFF)
|
||||
@param RemainingDevicePath a short-form device path that starts with the first
|
||||
element being a USB WWID or a USB Class device
|
||||
path
|
||||
|
||||
@return EFI_INVALID_PARAMETER
|
||||
@return EFI_SUCCESS
|
||||
@return EFI_NOT_FOUND
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
BdsLibConnectUsbDevByShortFormDP(
|
||||
IN CHAR8 HostControllerPI,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE *HandleArray;
|
||||
UINTN HandleArrayCount;
|
||||
UINTN Index;
|
||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
||||
UINT8 Class[3];
|
||||
BOOLEAN AtLeastOneConnected;
|
||||
|
||||
//
|
||||
// Check the passed in parameters
|
||||
//
|
||||
if (RemainingDevicePath == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ((DevicePathType (RemainingDevicePath) != MESSAGING_DEVICE_PATH) ||
|
||||
((DevicePathSubType (RemainingDevicePath) != MSG_USB_CLASS_DP)
|
||||
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
|
||||
&& (DevicePathSubType (RemainingDevicePath) != MSG_USB_WWID_DP)
|
||||
#endif
|
||||
)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (HostControllerPI != 0xFF &&
|
||||
HostControllerPI != 0x00 &&
|
||||
HostControllerPI != 0x20) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// Find the usb host controller firstly, then connect with the remaining device path
|
||||
//
|
||||
AtLeastOneConnected = FALSE;
|
||||
Status = gBS->LocateHandleBuffer (
|
||||
ByProtocol,
|
||||
&gEfiPciIoProtocolGuid,
|
||||
NULL,
|
||||
&HandleArrayCount,
|
||||
&HandleArray
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
for (Index = 0; Index < HandleArrayCount; Index++) {
|
||||
Status = gBS->HandleProtocol (
|
||||
HandleArray[Index],
|
||||
&gEfiPciIoProtocolGuid,
|
||||
(VOID **)&PciIo
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
//
|
||||
// Check whether the Pci device is the wanted usb host controller
|
||||
//
|
||||
Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x09, 3, &Class);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
if ((PCI_CLASS_SERIAL == Class[2]) &&
|
||||
(PCI_CLASS_SERIAL_USB == Class[1])) {
|
||||
if (HostControllerPI == Class[0] || HostControllerPI == 0xFF) {
|
||||
Status = gBS->ConnectController (
|
||||
HandleArray[Index],
|
||||
NULL,
|
||||
RemainingDevicePath,
|
||||
FALSE
|
||||
);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
AtLeastOneConnected = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (AtLeastOneConnected) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
399
MdeModulePkg/Library/GenericBdsLib/BdsConsole.c
Normal file
399
MdeModulePkg/Library/GenericBdsLib/BdsConsole.c
Normal file
@@ -0,0 +1,399 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2004 - 2007, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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.
|
||||
|
||||
Module Name:
|
||||
|
||||
BdsConsole.c
|
||||
|
||||
Abstract:
|
||||
|
||||
BDS Lib functions which contain all the code to connect console device
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#include "InternalBdsLib.h"
|
||||
//@MT:#include "EfiPrintLib.h"
|
||||
|
||||
BOOLEAN
|
||||
IsNvNeed (
|
||||
IN CHAR16 *ConVarName
|
||||
)
|
||||
{
|
||||
CHAR16 *Ptr;
|
||||
|
||||
Ptr = ConVarName;
|
||||
|
||||
//
|
||||
// If the variable includes "Dev" at last, we consider
|
||||
// it does not support NV attribute.
|
||||
//
|
||||
while (*Ptr) {
|
||||
Ptr++;
|
||||
}
|
||||
|
||||
if ((*(Ptr-3) == 'D') && (*(Ptr-2) == 'e') && (*(Ptr-1) == 'v')) {
|
||||
return FALSE;
|
||||
} else {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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 Add or remove the same device path.
|
||||
@retval EFI_SUCCESS Success add or remove the device path from the
|
||||
console variable.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
BdsLibUpdateConsoleVariable (
|
||||
IN CHAR16 *ConVarName,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *CustomizedConDevicePath,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *ExclusiveDevicePath
|
||||
)
|
||||
{
|
||||
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);
|
||||
SafeFreePool(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
|
||||
//
|
||||
gRT->SetVariable (
|
||||
ConVarName,
|
||||
&gEfiGlobalVariableGuid,
|
||||
Attributes,
|
||||
GetDevicePathSize (NewDevicePath),
|
||||
NewDevicePath
|
||||
);
|
||||
|
||||
if (VarConsole == NewDevicePath) {
|
||||
SafeFreePool(VarConsole);
|
||||
} else {
|
||||
SafeFreePool(VarConsole);
|
||||
SafeFreePool(NewDevicePath);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
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);
|
||||
Next = Instance;
|
||||
while (!IsDevicePathEndType (Next)) {
|
||||
Next = NextDevicePathNode (Next);
|
||||
}
|
||||
|
||||
SetDevicePathEndNode (Next);
|
||||
//
|
||||
// Check USB1.1 console
|
||||
//
|
||||
if ((DevicePathType (Instance) == MESSAGING_DEVICE_PATH) &&
|
||||
((DevicePathSubType (Instance) == MSG_USB_CLASS_DP)
|
||||
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
|
||||
|| (DevicePathSubType (Instance) == MSG_USB_WWID_DP)
|
||||
#endif
|
||||
)) {
|
||||
//
|
||||
// Check the Usb console in Usb2.0 bus firstly, then Usb1.1 bus
|
||||
//
|
||||
Status = BdsLibConnectUsbDevByShortFormDP (PCI_CLASSC_PI_EHCI, Instance);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
DeviceExist = TRUE;
|
||||
}
|
||||
|
||||
Status = BdsLibConnectUsbDevByShortFormDP (PCI_CLASSC_PI_UHCI, Instance);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
DeviceExist = TRUE;
|
||||
}
|
||||
} else {
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
SafeFreePool(Instance);
|
||||
} while (CopyOfDevicePath != NULL);
|
||||
|
||||
gBS->FreePool (StartDevicePath);
|
||||
|
||||
if (DeviceExist == FALSE) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function will search every simpletxt devive in current system,
|
||||
and make every simpletxt device as pertantial console device.
|
||||
|
||||
None
|
||||
|
||||
@return None
|
||||
|
||||
**/
|
||||
VOID
|
||||
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 varables
|
||||
//
|
||||
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);
|
||||
}
|
||||
|
||||
SafeFreePool(HandleBuffer);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
SafeFreePool(HandleBuffer);
|
||||
|
||||
//
|
||||
// Connect all console variables
|
||||
//
|
||||
BdsLibConnectAllDefaultConsoles ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function will connect console device base on the console
|
||||
device variable ConIn, ConOut and ErrOut.
|
||||
|
||||
None
|
||||
|
||||
@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
|
||||
BdsLibConnectAllDefaultConsoles (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// 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");
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
1415
MdeModulePkg/Library/GenericBdsLib/BdsMisc.c
Normal file
1415
MdeModulePkg/Library/GenericBdsLib/BdsMisc.c
Normal file
File diff suppressed because it is too large
Load Diff
1321
MdeModulePkg/Library/GenericBdsLib/DevicePath.c
Normal file
1321
MdeModulePkg/Library/GenericBdsLib/DevicePath.c
Normal file
File diff suppressed because it is too large
Load Diff
35
MdeModulePkg/Library/GenericBdsLib/Ebc/BmMachine.h
Normal file
35
MdeModulePkg/Library/GenericBdsLib/Ebc/BmMachine.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2007, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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.
|
||||
|
||||
Module Name:
|
||||
|
||||
BmMachine.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Boot Manager Machine type
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _BM_MACHINE_H
|
||||
#define _BM_MACHINE_H
|
||||
|
||||
//
|
||||
// NOTE: This is not defined in UEFI spec.
|
||||
//
|
||||
#define DEFAULT_REMOVABLE_FILE_NAME L"\\EFI\\BOOT\\BOOTEBC.EFI"
|
||||
|
||||
#endif
|
119
MdeModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
Normal file
119
MdeModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
Normal file
@@ -0,0 +1,119 @@
|
||||
#/** @file
|
||||
# Component name for module GenericBdsLib
|
||||
#
|
||||
# FIX ME!
|
||||
# Copyright (c) 2007, Intel Corporation. All rights reserved.
|
||||
#
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
#**/
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = GenericBdsLib
|
||||
FILE_GUID = e405ec31-ccaa-4dd4-83e8-0aec01703f7e
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = GenericBdsLib|DXE_DRIVER
|
||||
EDK_RELEASE_VERSION = 0x00020000
|
||||
EFI_SPECIFICATION_VERSION = 0x0002000A
|
||||
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
#
|
||||
|
||||
[Sources.common]
|
||||
DevicePath.c
|
||||
Performance.c
|
||||
BdsConnect.c
|
||||
BdsMisc.c
|
||||
R8Lib.c
|
||||
BdsConsole.c
|
||||
BdsBoot.c
|
||||
InternalBdsLib.h
|
||||
R8Lib.h
|
||||
|
||||
[Sources.Ia32]
|
||||
Ia32\ClearDr.asm
|
||||
Ia32\BmMachine.h
|
||||
|
||||
[Sources.X64]
|
||||
x64\ClearDr.asm
|
||||
x64\BmMachine.h
|
||||
|
||||
[Sources.IPF]
|
||||
Ipf\ShadowRom.c
|
||||
Ipf\BmMachine.h
|
||||
|
||||
[Sources.EBC]
|
||||
Ebc\BmMachine.h
|
||||
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
#
|
||||
#This dependency is because of gEfiLegacyBiosProtocolGuid. It may be removed if a Library class is created to
|
||||
#abstract away definition in Framework specification or PI spec incorporates the Legacy Booting Protocols.
|
||||
#
|
||||
IntelFrameworkPkg/IntelFrameworkPkg.dec
|
||||
|
||||
|
||||
[LibraryClasses]
|
||||
DevicePathLib
|
||||
PeCoffGetEntryPointLib
|
||||
BaseLib
|
||||
HobLib
|
||||
UefiRuntimeServicesTableLib
|
||||
DxeServicesTableLib
|
||||
MemoryAllocationLib
|
||||
UefiLib
|
||||
UefiBootServicesTableLib
|
||||
BaseMemoryLib
|
||||
DebugLib
|
||||
PrintLib
|
||||
PcdLib
|
||||
PerformanceLib
|
||||
TimerLib
|
||||
|
||||
|
||||
[Guids]
|
||||
gEfiVT100PlusGuid # ALWAYS_CONSUMED
|
||||
gEfiMemoryTypeInformationGuid # ALWAYS_CONSUMED
|
||||
gEfiVTUTF8Guid # ALWAYS_CONSUMED
|
||||
gEfiHobListGuid # ALWAYS_CONSUMED
|
||||
gEfiShellFileGuid # ALWAYS_CONSUMED
|
||||
gEfiGlobalVariableGuid # ALWAYS_CONSUMED
|
||||
gEfiVT100Guid # ALWAYS_CONSUMED
|
||||
gEfiFileInfoGuid # ALWAYS_CONSUMED
|
||||
gEfiPcAnsiGuid # ALWAYS_CONSUMED
|
||||
gEfiGenericPlatformVariableGuid # ALWAYS_CONSUMED
|
||||
|
||||
|
||||
[Protocols]
|
||||
gEfiSimpleFileSystemProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiSimpleTextOutProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiPciIoProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiLoadedImageProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiDevicePathToTextProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiSimpleNetworkProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiDebugPortProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiSimpleTextInProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiBlockIoProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiFirmwareVolume2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiLegacyBiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiCpuArchProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiDevicePathProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
|
||||
[Pcd]
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdPlatformBootTimeOutDefault
|
159
MdeModulePkg/Library/GenericBdsLib/GenericBdsLib.msa
Normal file
159
MdeModulePkg/Library/GenericBdsLib/GenericBdsLib.msa
Normal file
@@ -0,0 +1,159 @@
|
||||
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<MsaHeader>
|
||||
<ModuleName>GenericBdsLib</ModuleName>
|
||||
<ModuleType>DXE_DRIVER</ModuleType>
|
||||
<GuidValue>e405ec31-ccaa-4dd4-83e8-0aec01703f7e</GuidValue>
|
||||
<Version>1.0</Version>
|
||||
<Abstract>Component name for module GenericBdsLib</Abstract>
|
||||
<Description>FIX ME!</Description>
|
||||
<Copyright>Copyright (c) 2007, Intel Corporation. All rights reserved.</Copyright>
|
||||
<License>All rights reserved. This program and the accompanying materials
|
||||
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.</License>
|
||||
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
|
||||
</MsaHeader>
|
||||
<ModuleDefinitions>
|
||||
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
|
||||
<BinaryModule>false</BinaryModule>
|
||||
<OutputFileBasename>GenericBdsLib</OutputFileBasename>
|
||||
</ModuleDefinitions>
|
||||
<LibraryClassDefinitions>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>PrintLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>DebugLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>BaseMemoryLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>UefiBootServicesTableLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>UefiLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>MemoryAllocationLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>DxeServicesTableLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>UefiRuntimeServicesTableLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>HobLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>BaseLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>DevicePathLib</Keyword>
|
||||
</LibraryClass>
|
||||
</LibraryClassDefinitions>
|
||||
<SourceFiles>
|
||||
<Filename SupArchList="IPF">Ipf\BmMachine.h</Filename>
|
||||
<Filename>R8Lib.h</Filename>
|
||||
<Filename SupArchList="X64">x64\BmMachine.h</Filename>
|
||||
<Filename>BdsLib.h</Filename>
|
||||
<Filename>BdsBoot.c</Filename>
|
||||
<Filename SupArchList="IA32">Ia32\BmMachine.h</Filename>
|
||||
<Filename SupArchList="X64">x64\ClearDr.asm</Filename>
|
||||
<Filename SupArchList="EBC">Ebc\BmMachine.h</Filename>
|
||||
<Filename>BdsConsole.c</Filename>
|
||||
<Filename>R8Lib.c</Filename>
|
||||
<Filename SupArchList="IA32">Ia32\ClearDr.asm</Filename>
|
||||
<Filename>BdsMisc.c</Filename>
|
||||
<Filename>BdsConnect.c</Filename>
|
||||
<Filename>Performance.c</Filename>
|
||||
<Filename>DevicePath.c</Filename>
|
||||
<Filename SupArchList="IPF">Ipf\ShadowRom.c</Filename>
|
||||
<Filename>Performance.h</Filename>
|
||||
</SourceFiles>
|
||||
<PackageDependencies>
|
||||
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
|
||||
</PackageDependencies>
|
||||
<Protocols>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiDevicePathProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiCpuArchProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiLegacyBiosProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiFirmwareVolumeProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiBlockIoProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiSimpleTextInProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiDebugPortProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiSimpleNetworkProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiFormBrowserProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiDevicePathToTextProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiLoadedImageProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiPciIoProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiSimpleTextOutProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiSimpleFileSystemProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
</Protocols>
|
||||
<Guids>
|
||||
<GuidCNames Usage="ALWAYS_CONSUMED">
|
||||
<GuidCName>gEfiPcAnsiGuid</GuidCName>
|
||||
</GuidCNames>
|
||||
<GuidCNames Usage="ALWAYS_CONSUMED">
|
||||
<GuidCName>gEfiFileInfoGuid</GuidCName>
|
||||
</GuidCNames>
|
||||
<GuidCNames Usage="ALWAYS_CONSUMED">
|
||||
<GuidCName>gEfiVT100Guid</GuidCName>
|
||||
</GuidCNames>
|
||||
<GuidCNames Usage="ALWAYS_CONSUMED">
|
||||
<GuidCName>gEfiGlobalVariableGuid</GuidCName>
|
||||
</GuidCNames>
|
||||
<GuidCNames Usage="ALWAYS_CONSUMED">
|
||||
<GuidCName>gEfiShellFileGuid</GuidCName>
|
||||
</GuidCNames>
|
||||
<GuidCNames Usage="ALWAYS_CONSUMED">
|
||||
<GuidCName>gEfiHobListGuid</GuidCName>
|
||||
</GuidCNames>
|
||||
<GuidCNames Usage="ALWAYS_CONSUMED">
|
||||
<GuidCName>gEfiVTUTF8Guid</GuidCName>
|
||||
</GuidCNames>
|
||||
<GuidCNames Usage="ALWAYS_CONSUMED">
|
||||
<GuidCName>gEfiMemoryTypeInformationGuid</GuidCName>
|
||||
</GuidCNames>
|
||||
<GuidCNames Usage="ALWAYS_CONSUMED">
|
||||
<GuidCName>gEfiVT100PlusGuid</GuidCName>
|
||||
</GuidCNames>
|
||||
</Guids>
|
||||
<Externs>
|
||||
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
|
||||
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
|
||||
</Externs>
|
||||
</ModuleSurfaceArea>
|
34
MdeModulePkg/Library/GenericBdsLib/Ia32/BmMachine.h
Normal file
34
MdeModulePkg/Library/GenericBdsLib/Ia32/BmMachine.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2004 - 2006, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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.
|
||||
|
||||
Module Name:
|
||||
|
||||
BmMachine.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Boot Manager Machine type
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _BM_MACHINE_H
|
||||
#define _BM_MACHINE_H
|
||||
|
||||
//@MT:#include "CpuIA32.h"
|
||||
|
||||
#define DEFAULT_REMOVABLE_FILE_NAME L"\\EFI\\BOOT\\BOOTIA32.EFI"
|
||||
|
||||
#endif
|
43
MdeModulePkg/Library/GenericBdsLib/Ia32/ClearDr.asm
Normal file
43
MdeModulePkg/Library/GenericBdsLib/Ia32/ClearDr.asm
Normal file
@@ -0,0 +1,43 @@
|
||||
title ClearDr.asm
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Copyright (c) 2004, Intel Corporation
|
||||
; All rights reserved. This program and the accompanying materials
|
||||
; 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.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; ClearDr.asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; Clear dr0 dr1 register
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.686
|
||||
.MODEL FLAT,C
|
||||
.CODE
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; VOID
|
||||
; ClearDebugRegisters (
|
||||
; VOID
|
||||
; )
|
||||
;------------------------------------------------------------------------------
|
||||
ClearDebugRegisters PROC PUBLIC
|
||||
push eax
|
||||
xor eax, eax
|
||||
mov dr0, eax
|
||||
mov dr1, eax
|
||||
pop eax
|
||||
ret
|
||||
ClearDebugRegisters ENDP
|
||||
|
||||
END
|
||||
|
102
MdeModulePkg/Library/GenericBdsLib/InternalBdsLib.h
Normal file
102
MdeModulePkg/Library/GenericBdsLib/InternalBdsLib.h
Normal file
@@ -0,0 +1,102 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2004 - 2007, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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.
|
||||
|
||||
Module Name:
|
||||
|
||||
InternalBdsLib.h
|
||||
|
||||
Abstract:
|
||||
|
||||
BDS library definition, include the file and data structure
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _INTERNAL_BDS_LIB_H_
|
||||
#define _INTERNAL_BDS_LIB_H_
|
||||
|
||||
#include <PiDxe.h>
|
||||
|
||||
#include <IndustryStandard/Pci22.h>
|
||||
|
||||
#include <Protocol/BlockIo.h>
|
||||
#include <Protocol/LoadedImage.h>
|
||||
#include <Protocol/Cpu.h>
|
||||
#include <Protocol/SimpleFileSystem.h>
|
||||
#include <Protocol/DebugPort.h>
|
||||
#include <Protocol/DevicePath.h>
|
||||
#include <Protocol/SimpleTextIn.h>
|
||||
#include <Protocol/LegacyBios.h>
|
||||
#include <Protocol/SimpleTextOut.h>
|
||||
#include <Protocol/SimpleNetwork.h>
|
||||
#include <Protocol/DevicePathToText.h>
|
||||
#include <Protocol/FirmwareVolume2.h>
|
||||
#include <Protocol/PciIo.h>
|
||||
#include <Protocol/AcpiS3Save.h>
|
||||
#include <Protocol/Performance.h>
|
||||
|
||||
#include <Guid/MemoryTypeInformation.h>
|
||||
#include <Guid/FileInfo.h>
|
||||
#include <Guid/GlobalVariable.h>
|
||||
#include <Guid/PcAnsi.h>
|
||||
#include <Guid/ShellFile.h>
|
||||
#include <Guid/HobList.h>
|
||||
#include <Guid/GenericPlatformVariable.h>
|
||||
|
||||
#include <Library/PrintLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/DxeServicesTableLib.h>
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
#include <Library/HobLib.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/PerformanceLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/IfrSupportLib.h>
|
||||
#include <Library/PeCoffGetEntryPointLib.h>
|
||||
#include <Library/GenericBdsLib.h>
|
||||
#include <Library/TimerLib.h>
|
||||
|
||||
#include "BmMachine.h"
|
||||
|
||||
#include "R8Lib.h"
|
||||
|
||||
#define PERFORMANCE_SIGNATURE EFI_SIGNATURE_32 ('P', 'e', 'r', 'f')
|
||||
#define PERF_TOKEN_SIZE 28
|
||||
#define PERF_TOKEN_LENGTH (PERF_TOKEN_SIZE - 1)
|
||||
#define PERF_PEI_ENTRY_MAX_NUM 50
|
||||
|
||||
typedef struct {
|
||||
CHAR8 Token[PERF_TOKEN_SIZE];
|
||||
UINT32 Duration;
|
||||
} PERF_DATA;
|
||||
|
||||
typedef struct {
|
||||
UINT64 BootToOs;
|
||||
UINT64 S3Resume;
|
||||
UINT32 S3EntryNum;
|
||||
PERF_DATA S3Entry[PERF_PEI_ENTRY_MAX_NUM];
|
||||
UINT64 CpuFreq;
|
||||
UINT64 BDSRaw;
|
||||
UINT32 Count;
|
||||
UINT32 Signiture;
|
||||
} PERF_HEADER;
|
||||
|
||||
VOID
|
||||
WriteBootToOsPerformanceData (
|
||||
VOID
|
||||
);
|
||||
|
||||
#endif // _BDS_LIB_H_
|
34
MdeModulePkg/Library/GenericBdsLib/Ipf/BmMachine.h
Normal file
34
MdeModulePkg/Library/GenericBdsLib/Ipf/BmMachine.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2004 - 2006, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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.
|
||||
|
||||
Module Name:
|
||||
|
||||
BmMachine.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Boot Manager Machine type
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _BM_MACHINE_H
|
||||
#define _BM_MACHINE_H
|
||||
|
||||
//@MT:#include "CpuIA64.h"
|
||||
|
||||
#define DEFAULT_REMOVABLE_FILE_NAME L"\\EFI\\BOOT\\BOOTIA64.EFI"
|
||||
|
||||
#endif
|
56
MdeModulePkg/Library/GenericBdsLib/Ipf/ShadowRom.c
Normal file
56
MdeModulePkg/Library/GenericBdsLib/Ipf/ShadowRom.c
Normal file
@@ -0,0 +1,56 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2004, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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.
|
||||
|
||||
Module Name:
|
||||
|
||||
ShadowRom.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Shadow all option rom
|
||||
|
||||
Revision History
|
||||
|
||||
|
||||
**/
|
||||
|
||||
//@MT:#include "Tiano.h"
|
||||
//@MT:#include "EfiDriverLib.h"
|
||||
|
||||
//@MT:#include EFI_PROTOCOL_DEFINITION (LegacyBios)
|
||||
|
||||
#include "InternalBdsLib.h"
|
||||
|
||||
UINT8 mShadowRomFlag = 0;
|
||||
|
||||
VOID
|
||||
ShadowAllOptionRom()
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_LEGACY_BIOS_PROTOCOL *LegacyBios;
|
||||
//
|
||||
// Rom shadow only do once.
|
||||
//
|
||||
if (mShadowRomFlag == 0) {
|
||||
Status = gBS->LocateProtocol (
|
||||
&gEfiLegacyBiosProtocolGuid,
|
||||
NULL,
|
||||
(VOID **) &LegacyBios
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
LegacyBios->PrepareToBootEfi (LegacyBios, NULL, NULL);
|
||||
}
|
||||
|
||||
mShadowRomFlag = 1;
|
||||
}
|
||||
|
||||
return ;
|
||||
}
|
326
MdeModulePkg/Library/GenericBdsLib/Performance.c
Normal file
326
MdeModulePkg/Library/GenericBdsLib/Performance.c
Normal file
@@ -0,0 +1,326 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2004 - 2007, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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.
|
||||
|
||||
Module Name:
|
||||
|
||||
Performance.c
|
||||
|
||||
Abstract:
|
||||
|
||||
This file include the file which can help to get the system
|
||||
performance, all the function will only include if the performance
|
||||
switch is set.
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#include "InternalBdsLib.h"
|
||||
|
||||
STATIC PERF_HEADER mPerfHeader;
|
||||
STATIC PERF_DATA mPerfData;
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
GetShortPdbFileName (
|
||||
CHAR8 *PdbFileName,
|
||||
CHAR8 *GaugeString
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Arguments:
|
||||
|
||||
Returns:
|
||||
|
||||
--*/
|
||||
{
|
||||
UINTN Index;
|
||||
UINTN Index1;
|
||||
UINTN StartIndex;
|
||||
UINTN EndIndex;
|
||||
|
||||
if (PdbFileName == NULL) {
|
||||
AsciiStrCpy (GaugeString, " ");
|
||||
} else {
|
||||
StartIndex = 0;
|
||||
for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++)
|
||||
;
|
||||
|
||||
for (Index = 0; PdbFileName[Index] != 0; Index++) {
|
||||
if (PdbFileName[Index] == '\\') {
|
||||
StartIndex = Index + 1;
|
||||
}
|
||||
|
||||
if (PdbFileName[Index] == '.') {
|
||||
EndIndex = Index;
|
||||
}
|
||||
}
|
||||
|
||||
Index1 = 0;
|
||||
for (Index = StartIndex; Index < EndIndex; Index++) {
|
||||
GaugeString[Index1] = PdbFileName[Index];
|
||||
Index1++;
|
||||
if (Index1 == PERF_TOKEN_LENGTH - 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GaugeString[Index1] = 0;
|
||||
}
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
GetNameFromHandle (
|
||||
IN EFI_HANDLE Handle,
|
||||
OUT CHAR8 *GaugeString
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_LOADED_IMAGE_PROTOCOL *Image;
|
||||
CHAR8 *PdbFileName;
|
||||
EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
|
||||
|
||||
AsciiStrCpy (GaugeString, " ");
|
||||
|
||||
//
|
||||
// Get handle name from image protocol
|
||||
//
|
||||
Status = gBS->HandleProtocol (
|
||||
Handle,
|
||||
&gEfiLoadedImageProtocolGuid,
|
||||
(VOID **) &Image
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = gBS->OpenProtocol (
|
||||
Handle,
|
||||
&gEfiDriverBindingProtocolGuid,
|
||||
(VOID **) &DriverBinding,
|
||||
NULL,
|
||||
NULL,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return ;
|
||||
}
|
||||
//
|
||||
// Get handle name from image protocol
|
||||
//
|
||||
Status = gBS->HandleProtocol (
|
||||
DriverBinding->ImageHandle,
|
||||
&gEfiLoadedImageProtocolGuid,
|
||||
(VOID **) &Image
|
||||
);
|
||||
}
|
||||
|
||||
PdbFileName = PeCoffLoaderGetPdbPointer (Image->ImageBase);
|
||||
|
||||
if (PdbFileName != NULL) {
|
||||
GetShortPdbFileName (PdbFileName, GaugeString);
|
||||
}
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
VOID
|
||||
WriteBootToOsPerformanceData (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Allocates a block of memory and writes performance data of booting to OS into it.
|
||||
|
||||
Arguments:
|
||||
|
||||
None
|
||||
|
||||
Returns:
|
||||
|
||||
None
|
||||
|
||||
--*/
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_PHYSICAL_ADDRESS AcpiLowMemoryBase;
|
||||
UINT32 AcpiLowMemoryLength;
|
||||
UINT32 LimitCount;
|
||||
EFI_HANDLE *Handles;
|
||||
UINTN NoHandles;
|
||||
CHAR8 GaugeString[PERF_TOKEN_LENGTH];
|
||||
UINT8 *Ptr;
|
||||
UINT32 Index;
|
||||
UINT64 Ticker;
|
||||
UINT64 Freq;
|
||||
UINT32 Duration;
|
||||
UINTN LogEntryKey;
|
||||
CONST VOID *Handle;
|
||||
CONST CHAR8 *Token;
|
||||
CONST CHAR8 *Module;
|
||||
UINT64 StartTicker;
|
||||
UINT64 EndTicker;
|
||||
UINT64 StartValue;
|
||||
UINT64 EndValue;
|
||||
BOOLEAN CountUp;
|
||||
|
||||
//
|
||||
// Retrive time stamp count as early as possilbe
|
||||
//
|
||||
Ticker = GetPerformanceCounter ();
|
||||
|
||||
Freq = GetPerformanceCounterProperties (&StartValue, &EndValue);
|
||||
|
||||
Freq = DivU64x32 (Freq, 1000);
|
||||
|
||||
mPerfHeader.CpuFreq = Freq;
|
||||
|
||||
//
|
||||
// Record BDS raw performance data
|
||||
//
|
||||
if (EndValue >= StartValue) {
|
||||
mPerfHeader.BDSRaw = Ticker - StartValue;
|
||||
CountUp = TRUE;
|
||||
} else {
|
||||
mPerfHeader.BDSRaw = StartValue - Ticker;
|
||||
CountUp = FALSE;
|
||||
}
|
||||
|
||||
AcpiLowMemoryLength = 0x2000;
|
||||
|
||||
//
|
||||
// Allocate a block of memory that contain performance data to OS
|
||||
//
|
||||
Status = gBS->AllocatePages (
|
||||
AllocateAnyPages,
|
||||
EfiACPIReclaimMemory,
|
||||
EFI_SIZE_TO_PAGES (AcpiLowMemoryLength),
|
||||
&AcpiLowMemoryBase
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return ;
|
||||
}
|
||||
|
||||
|
||||
Ptr = (UINT8 *) ((UINT32) AcpiLowMemoryBase + sizeof (PERF_HEADER));
|
||||
LimitCount = (AcpiLowMemoryLength - sizeof (PERF_HEADER)) / sizeof (PERF_DATA);
|
||||
|
||||
//
|
||||
// Put Detailed performance data into memory
|
||||
//
|
||||
Handles = NULL;
|
||||
Status = gBS->LocateHandleBuffer (
|
||||
AllHandles,
|
||||
NULL,
|
||||
NULL,
|
||||
&NoHandles,
|
||||
&Handles
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
gBS->FreePages (AcpiLowMemoryBase, 1);
|
||||
return ;
|
||||
}
|
||||
//
|
||||
// Get DXE drivers performance
|
||||
//
|
||||
for (Index = 0; Index < NoHandles; Index++) {
|
||||
Ticker = 0;
|
||||
LogEntryKey = 0;
|
||||
while ((LogEntryKey = GetPerformanceMeasurement (
|
||||
LogEntryKey,
|
||||
&Handle,
|
||||
&Token,
|
||||
&Module,
|
||||
&StartTicker,
|
||||
&EndTicker)) != 0) {
|
||||
if ((Handle == Handles[Index]) && (EndTicker != 0)) {
|
||||
Ticker += CountUp ? (EndTicker - StartTicker) : (StartTicker - EndTicker);
|
||||
}
|
||||
}
|
||||
|
||||
Duration = (UINT32) DivU64x32 (Ticker, (UINT32) Freq);
|
||||
|
||||
if (Duration > 0) {
|
||||
|
||||
GetNameFromHandle (Handles[Index], GaugeString);
|
||||
|
||||
AsciiStrCpy (mPerfData.Token, GaugeString);
|
||||
mPerfData.Duration = Duration;
|
||||
|
||||
CopyMem (Ptr, &mPerfData, sizeof (PERF_DATA));
|
||||
Ptr += sizeof (PERF_DATA);
|
||||
|
||||
mPerfHeader.Count++;
|
||||
if (mPerfHeader.Count == LimitCount) {
|
||||
goto Done;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FreePool (Handles);
|
||||
|
||||
//
|
||||
// Get inserted performance data
|
||||
//
|
||||
LogEntryKey = 0;
|
||||
while ((LogEntryKey = GetPerformanceMeasurement (
|
||||
LogEntryKey,
|
||||
&Handle,
|
||||
&Token,
|
||||
&Module,
|
||||
&StartTicker,
|
||||
&EndTicker)) != 0) {
|
||||
if (Handle == NULL && EndTicker != 0) {
|
||||
|
||||
ZeroMem (&mPerfData, sizeof (PERF_DATA));
|
||||
|
||||
AsciiStrnCpy (mPerfData.Token, Token, PERF_TOKEN_LENGTH);
|
||||
Ticker = CountUp ? (EndTicker - StartTicker) : (StartTicker - EndTicker);
|
||||
|
||||
mPerfData.Duration = (UINT32) DivU64x32 (Ticker, (UINT32) Freq);
|
||||
|
||||
CopyMem (Ptr, &mPerfData, sizeof (PERF_DATA));
|
||||
Ptr += sizeof (PERF_DATA);
|
||||
|
||||
mPerfHeader.Count++;
|
||||
if (mPerfHeader.Count == LimitCount) {
|
||||
goto Done;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Done:
|
||||
|
||||
mPerfHeader.Signiture = PERFORMANCE_SIGNATURE;
|
||||
|
||||
//
|
||||
// Put performance data to memory
|
||||
//
|
||||
CopyMem (
|
||||
(UINTN *) (UINTN) AcpiLowMemoryBase,
|
||||
&mPerfHeader,
|
||||
sizeof (PERF_HEADER)
|
||||
);
|
||||
|
||||
gRT->SetVariable (
|
||||
L"PerfDataMemAddr",
|
||||
&gEfiGenericPlatformVariableGuid,
|
||||
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||
sizeof (EFI_PHYSICAL_ADDRESS),
|
||||
&AcpiLowMemoryBase
|
||||
);
|
||||
|
||||
return ;
|
||||
}
|
114
MdeModulePkg/Library/GenericBdsLib/R8Lib.c
Normal file
114
MdeModulePkg/Library/GenericBdsLib/R8Lib.c
Normal file
@@ -0,0 +1,114 @@
|
||||
/**@file
|
||||
Copyright (c) 2007, Intel Corporation
|
||||
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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"
|
||||
|
||||
/**
|
||||
Get current boot mode.
|
||||
|
||||
@param HobStart Start pointer of hob list
|
||||
@param BootMode Current boot mode recorded in PHIT hob
|
||||
|
||||
@retval EFI_NOT_FOUND Invalid hob header
|
||||
@retval EFI_SUCCESS Boot mode found
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
R8_GetHobBootMode (
|
||||
IN VOID *HobStart,
|
||||
OUT EFI_BOOT_MODE *BootMode
|
||||
)
|
||||
{
|
||||
//
|
||||
// Porting Guide:
|
||||
// This library interface is simply obsolete.
|
||||
// Include the source code to user code.
|
||||
// In fact, since EFI_HANDOFF_HOB must be the first Hob,
|
||||
// the following code can retrieve boot mode.
|
||||
//
|
||||
// EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
|
||||
//
|
||||
// HandOffHob = GetHobList ();
|
||||
// ASSERT (HandOffHob->Header.HobType == EFI_HOB_TYPE_HANDOFF);
|
||||
//
|
||||
// BootMode = HandOffHob->BootMode;
|
||||
//
|
||||
EFI_PEI_HOB_POINTERS Hob;
|
||||
|
||||
Hob.Raw = HobStart;
|
||||
if (Hob.Header->HobType != EFI_HOB_TYPE_HANDOFF) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
*BootMode = Hob.HandoffInformationTable->BootMode;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Get the next guid hob.
|
||||
|
||||
@param HobStart A pointer to the start hob.
|
||||
@param Guid A pointer to a guid.
|
||||
@param Buffer A pointer to the buffer.
|
||||
@param BufferSize Buffer size.
|
||||
|
||||
@retval EFI_NOT_FOUND Next Guid hob not found
|
||||
@retval EFI_SUCCESS Next Guid hob found and data for this Guid got
|
||||
@retval EFI_INVALID_PARAMETER invalid parameter
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
R8_GetNextGuidHob (
|
||||
IN OUT VOID **HobStart,
|
||||
IN EFI_GUID * Guid,
|
||||
OUT VOID **Buffer,
|
||||
OUT UINTN *BufferSize OPTIONAL
|
||||
)
|
||||
{
|
||||
//
|
||||
// Porting Guide:
|
||||
// This library interface is changed substantially with R9 counerpart GetNextGuidHob ().
|
||||
// 1. R9 GetNextGuidHob has two parameters and returns the matched GUID HOB from the StartHob.
|
||||
// 2. R9 GetNextGuidHob does not strip the HOB header, so caller is required to apply
|
||||
// GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE () to extract the data section and its
|
||||
// size info respectively.
|
||||
// 3. this function does not skip the starting HOB pointer unconditionally:
|
||||
// it returns HobStart back if HobStart itself meets the requirement;
|
||||
// caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
|
||||
//
|
||||
EFI_PEI_HOB_POINTERS GuidHob;
|
||||
|
||||
if (Buffer == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
GuidHob.Raw = GetNextGuidHob (Guid, *HobStart);
|
||||
if (GuidHob.Raw == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
*Buffer = GET_GUID_HOB_DATA (GuidHob.Guid);
|
||||
if (BufferSize != NULL) {
|
||||
*BufferSize = GET_GUID_HOB_DATA_SIZE (GuidHob.Guid);
|
||||
}
|
||||
|
||||
*HobStart = GET_NEXT_HOB (GuidHob);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
59
MdeModulePkg/Library/GenericBdsLib/R8Lib.h
Normal file
59
MdeModulePkg/Library/GenericBdsLib/R8Lib.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/**@file
|
||||
Copyright (c) 2007, Intel Corporation
|
||||
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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.
|
||||
|
||||
|
||||
**/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Get current boot mode.
|
||||
|
||||
@param HobStart Start pointer of hob list
|
||||
@param BootMode Current boot mode recorded in PHIT hob
|
||||
|
||||
@retval EFI_NOT_FOUND Invalid hob header
|
||||
@retval EFI_SUCCESS Boot mode found
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
R8_GetHobBootMode (
|
||||
IN VOID *HobStart,
|
||||
OUT EFI_BOOT_MODE *BootMode
|
||||
)
|
||||
;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Get the next guid hob.
|
||||
|
||||
@param HobStart A pointer to the start hob.
|
||||
@param Guid A pointer to a guid.
|
||||
@param Buffer A pointer to the buffer.
|
||||
@param BufferSize Buffer size.
|
||||
|
||||
@retval EFI_NOT_FOUND Next Guid hob not found
|
||||
@retval EFI_SUCCESS Next Guid hob found and data for this Guid got
|
||||
@retval EFI_INVALID_PARAMETER invalid parameter
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
R8_GetNextGuidHob (
|
||||
IN OUT VOID **HobStart,
|
||||
IN EFI_GUID * Guid,
|
||||
OUT VOID **Buffer,
|
||||
OUT UINTN *BufferSize OPTIONAL
|
||||
)
|
||||
;
|
||||
|
||||
|
34
MdeModulePkg/Library/GenericBdsLib/x64/BmMachine.h
Normal file
34
MdeModulePkg/Library/GenericBdsLib/x64/BmMachine.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2005 - 2006, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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.
|
||||
|
||||
Module Name:
|
||||
|
||||
BmMachine.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Boot Manager Machine type
|
||||
|
||||
|
||||
|
||||
Revision History
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _BM_MACHINE_H
|
||||
#define _BM_MACHINE_H
|
||||
|
||||
//@MT:#include "CpuIA32.h"
|
||||
|
||||
#define DEFAULT_REMOVABLE_FILE_NAME L"\\EFI\\BOOT\\BOOTX64.EFI"
|
||||
|
||||
#endif
|
41
MdeModulePkg/Library/GenericBdsLib/x64/ClearDr.asm
Normal file
41
MdeModulePkg/Library/GenericBdsLib/x64/ClearDr.asm
Normal file
@@ -0,0 +1,41 @@
|
||||
title ClearDr.asm
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Copyright (c) 2005, Intel Corporation
|
||||
; All rights reserved. This program and the accompanying materials
|
||||
; 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.
|
||||
;
|
||||
; Module Name:
|
||||
;
|
||||
; ClearDr.asm
|
||||
;
|
||||
; Abstract:
|
||||
;
|
||||
; Clear dr0 dr1 register
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
text SEGMENT
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; VOID
|
||||
; ClearDebugRegisters (
|
||||
; VOID
|
||||
; )
|
||||
;------------------------------------------------------------------------------
|
||||
ClearDebugRegisters PROC PUBLIC
|
||||
push rax
|
||||
xor rax, rax
|
||||
mov dr0, rax
|
||||
mov dr1, rax
|
||||
pop rax
|
||||
ret
|
||||
ClearDebugRegisters ENDP
|
||||
|
||||
END
|
||||
|
892
MdeModulePkg/Library/GraphicsLib/Graphics.c
Normal file
892
MdeModulePkg/Library/GraphicsLib/Graphics.c
Normal file
@@ -0,0 +1,892 @@
|
||||
/**@file
|
||||
Support for Basic Graphics operations.
|
||||
|
||||
BugBug: Currently *.BMP files are supported. This will be replaced
|
||||
when Tiano graphics format is supported.
|
||||
|
||||
|
||||
Copyright (c) 2006, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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 <PiDxe.h>
|
||||
|
||||
#include <Protocol/SimpleTextOut.h>
|
||||
#include <Protocol/OEMBadging.h>
|
||||
#include <Protocol/ConsoleControl.h>
|
||||
#include <Protocol/GraphicsOutput.h>
|
||||
#include <Protocol/FirmwareVolume2.h>
|
||||
#include <Protocol/UgaDraw.h>
|
||||
#include <Protocol/HiiFont.h>
|
||||
#include <Protocol/HiiImage.h>
|
||||
|
||||
#include <Guid/Bmp.h>
|
||||
|
||||
#include <Library/GraphicsLib.h>
|
||||
#include <Library/PrintLib.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/DxePiLib.h>
|
||||
|
||||
STATIC EFI_GRAPHICS_OUTPUT_BLT_PIXEL mEfiColors[16] = {
|
||||
{ 0x00, 0x00, 0x00, 0x00 },
|
||||
{ 0x98, 0x00, 0x00, 0x00 },
|
||||
{ 0x00, 0x98, 0x00, 0x00 },
|
||||
{ 0x98, 0x98, 0x00, 0x00 },
|
||||
{ 0x00, 0x00, 0x98, 0x00 },
|
||||
{ 0x98, 0x00, 0x98, 0x00 },
|
||||
{ 0x00, 0x98, 0x98, 0x00 },
|
||||
{ 0x98, 0x98, 0x98, 0x00 },
|
||||
{ 0x10, 0x10, 0x10, 0x00 },
|
||||
{ 0xff, 0x10, 0x10, 0x00 },
|
||||
{ 0x10, 0xff, 0x10, 0x00 },
|
||||
{ 0xff, 0xff, 0x10, 0x00 },
|
||||
{ 0x10, 0x10, 0xff, 0x00 },
|
||||
{ 0xf0, 0x10, 0xff, 0x00 },
|
||||
{ 0x10, 0xff, 0xff, 0x00 },
|
||||
{ 0xff, 0xff, 0xff, 0x00 }
|
||||
};
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
GetGraphicsBitMapFromFV (
|
||||
IN EFI_GUID *FileNameGuid,
|
||||
OUT VOID **Image,
|
||||
OUT UINTN *ImageSize
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Return the graphics image file named FileNameGuid into Image and return it's
|
||||
size in ImageSize. All Firmware Volumes (FV) in the system are searched for the
|
||||
file name.
|
||||
|
||||
Arguments:
|
||||
|
||||
FileNameGuid - File Name of graphics file in the FV(s).
|
||||
|
||||
Image - Pointer to pointer to return graphics image. If NULL, a
|
||||
buffer will be allocated.
|
||||
|
||||
ImageSize - Size of the graphics Image in bytes. Zero if no image found.
|
||||
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - Image and ImageSize are valid.
|
||||
EFI_BUFFER_TOO_SMALL - Image not big enough. ImageSize has required size
|
||||
EFI_NOT_FOUND - FileNameGuid not found
|
||||
|
||||
--*/
|
||||
{
|
||||
return GetGraphicsBitMapFromFVEx (NULL, FileNameGuid, Image, ImageSize);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
GetGraphicsBitMapFromFVEx (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_GUID *FileNameGuid,
|
||||
OUT VOID **Image,
|
||||
OUT UINTN *ImageSize
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Return the graphics image file named FileNameGuid into Image and return it's
|
||||
size in ImageSize. All Firmware Volumes (FV) in the system are searched for the
|
||||
file name.
|
||||
|
||||
Arguments:
|
||||
|
||||
ImageHandle - The driver image handle of the caller. The parameter is used to
|
||||
optimize the loading of the image file so that the FV from which
|
||||
the driver image is loaded will be tried first.
|
||||
|
||||
FileNameGuid - File Name of graphics file in the FV(s).
|
||||
|
||||
Image - Pointer to pointer to return graphics image. If NULL, a
|
||||
buffer will be allocated.
|
||||
|
||||
ImageSize - Size of the graphics Image in bytes. Zero if no image found.
|
||||
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - Image and ImageSize are valid.
|
||||
EFI_BUFFER_TOO_SMALL - Image not big enough. ImageSize has required size
|
||||
EFI_NOT_FOUND - FileNameGuid not found
|
||||
|
||||
--*/
|
||||
{
|
||||
return PiLibGetSectionFromCurrentFv (
|
||||
FileNameGuid,
|
||||
EFI_SECTION_RAW,
|
||||
0,
|
||||
Image,
|
||||
ImageSize
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
ConvertBmpToGopBlt (
|
||||
IN VOID *BmpImage,
|
||||
IN UINTN BmpImageSize,
|
||||
IN OUT VOID **GopBlt,
|
||||
IN OUT UINTN *GopBltSize,
|
||||
OUT UINTN *PixelHeight,
|
||||
OUT UINTN *PixelWidth
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Convert a *.BMP graphics image to a GOP/UGA 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.
|
||||
|
||||
Arguments:
|
||||
|
||||
BmpImage - Pointer to BMP file
|
||||
|
||||
BmpImageSize - Number of bytes in BmpImage
|
||||
|
||||
GopBlt - Buffer containing GOP version of BmpImage.
|
||||
|
||||
GopBltSize - Size of GopBlt in bytes.
|
||||
|
||||
PixelHeight - Height of GopBlt/BmpImage in pixels
|
||||
|
||||
PixelWidth - Width of GopBlt/BmpImage in pixels
|
||||
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - GopBlt and GopBltSize are returned.
|
||||
EFI_UNSUPPORTED - BmpImage is not a valid *.BMP image
|
||||
EFI_BUFFER_TOO_SMALL - The passed in GopBlt buffer is not big enough.
|
||||
GopBltSize will contain the required size.
|
||||
EFI_OUT_OF_RESOURCES - No enough buffer to allocate
|
||||
|
||||
--*/
|
||||
{
|
||||
UINT8 *Image;
|
||||
UINT8 *ImageHeader;
|
||||
BMP_IMAGE_HEADER *BmpHeader;
|
||||
BMP_COLOR_MAP *BmpColorMap;
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer;
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
|
||||
UINTN BltBufferSize;
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
BltBufferSize = BmpHeader->PixelWidth * BmpHeader->PixelHeight * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
|
||||
IsAllocated = FALSE;
|
||||
if (*GopBlt == NULL) {
|
||||
*GopBltSize = BltBufferSize;
|
||||
*GopBlt = AllocatePool (*GopBltSize);
|
||||
IsAllocated = TRUE;
|
||||
if (*GopBlt == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
} else {
|
||||
if (*GopBltSize < BltBufferSize) {
|
||||
*GopBltSize = BltBufferSize;
|
||||
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 1bit 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 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 BMP Palette to 24-bit color
|
||||
//
|
||||
Blt->Red = BmpColorMap[*Image].Red;
|
||||
Blt->Green = BmpColorMap[*Image].Green;
|
||||
Blt->Blue = BmpColorMap[*Image].Blue;
|
||||
break;
|
||||
|
||||
case 24:
|
||||
Blt->Blue = *Image++;
|
||||
Blt->Green = *Image++;
|
||||
Blt->Red = *Image;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (IsAllocated) {
|
||||
gBS->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;
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
LockKeyboards (
|
||||
IN CHAR16 *Password
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Use Console Control Protocol to lock the Console In Spliter virtual handle.
|
||||
This is the ConInHandle and ConIn handle in the EFI system table. All key
|
||||
presses will be ignored until the Password is typed in. The only way to
|
||||
disable the password is to type it in to a ConIn device.
|
||||
|
||||
Arguments:
|
||||
Password - Password used to lock ConIn device
|
||||
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - ConsoleControl has been flipped to graphics and logo
|
||||
displayed.
|
||||
EFI_UNSUPPORTED - Logo not found
|
||||
|
||||
--*/
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl;
|
||||
|
||||
Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, (VOID **) &ConsoleControl);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
Status = ConsoleControl->LockStdIn (ConsoleControl, Password);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EnableQuietBoot (
|
||||
IN EFI_GUID *LogoFile
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Use Console Control to turn off UGA based Simple Text Out consoles from going
|
||||
to the UGA device. Put up LogoFile on every UGA device that is a console
|
||||
|
||||
Arguments:
|
||||
|
||||
LogoFile - File name of logo to display on the center of the screen.
|
||||
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - ConsoleControl has been flipped to graphics and logo
|
||||
displayed.
|
||||
EFI_UNSUPPORTED - Logo not found
|
||||
|
||||
--*/
|
||||
{
|
||||
return EnableQuietBootEx (LogoFile, NULL);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
EnableQuietBootEx (
|
||||
IN EFI_GUID *LogoFile,
|
||||
IN EFI_HANDLE ImageHandle
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Use Console Control to turn off GOP/UGA based Simple Text Out consoles from going
|
||||
to the GOP/UGA device. Put up LogoFile on every GOP/UGA device that is a console
|
||||
|
||||
Arguments:
|
||||
|
||||
LogoFile - File name of logo to display on the center of the screen.
|
||||
ImageHandle - The driver image handle of the caller. The parameter is used to
|
||||
optimize the loading of the logo file so that the FV from which
|
||||
the driver image is loaded will be tried first.
|
||||
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - ConsoleControl has been flipped to graphics and logo
|
||||
displayed.
|
||||
EFI_UNSUPPORTED - Logo not found
|
||||
|
||||
--*/
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl;
|
||||
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;
|
||||
|
||||
Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, (VOID**)&ConsoleControl);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
UgaDraw = NULL;
|
||||
//
|
||||
// Try to open GOP first
|
||||
//
|
||||
Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, (VOID**)&GraphicsOutput);
|
||||
if (EFI_ERROR (Status)) {
|
||||
GraphicsOutput = NULL;
|
||||
//
|
||||
// Open GOP failed, try to open UGA
|
||||
//
|
||||
Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiUgaDrawProtocolGuid, (VOID**)&UgaDraw);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
Badging = NULL;
|
||||
Status = gBS->LocateProtocol (&gEfiOEMBadgingProtocolGuid, NULL, (VOID**)&Badging);
|
||||
|
||||
ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenGraphics);
|
||||
|
||||
if (GraphicsOutput != NULL) {
|
||||
SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution;
|
||||
SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution;
|
||||
} else {
|
||||
Status = UgaDraw->GetMode (UgaDraw, &SizeOfX, &SizeOfY, &ColorDepth, &RefreshRate);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
Instance = 0;
|
||||
while (1) {
|
||||
ImageData = NULL;
|
||||
ImageSize = 0;
|
||||
|
||||
if (Badging != NULL) {
|
||||
Status = Badging->GetImage (
|
||||
Badging,
|
||||
&Instance,
|
||||
&Format,
|
||||
&ImageData,
|
||||
&ImageSize,
|
||||
&Attribute,
|
||||
&CoordinateX,
|
||||
&CoordinateY
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Currently only support BMP format
|
||||
//
|
||||
if (Format != EfiBadgingFormatBMP) {
|
||||
gBS->FreePool (ImageData);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
Status = GetGraphicsBitMapFromFVEx (ImageHandle, LogoFile, (VOID **) &ImageData, &ImageSize);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
CoordinateX = 0;
|
||||
CoordinateY = 0;
|
||||
Attribute = EfiBadgingDisplayAttributeCenter;
|
||||
}
|
||||
|
||||
Blt = NULL;
|
||||
Status = ConvertBmpToGopBlt (
|
||||
ImageData,
|
||||
ImageSize,
|
||||
(VOID**)&Blt,
|
||||
&BltSize,
|
||||
&Height,
|
||||
&Width
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
gBS->FreePool (ImageData);
|
||||
if (Badging == NULL) {
|
||||
return Status;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
Status = UgaDraw->Blt (
|
||||
UgaDraw,
|
||||
(EFI_UGA_PIXEL *) Blt,
|
||||
EfiUgaBltBufferToVideo,
|
||||
0,
|
||||
0,
|
||||
(UINTN) DestX,
|
||||
(UINTN) DestY,
|
||||
Width,
|
||||
Height,
|
||||
Width * sizeof (EFI_UGA_PIXEL)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
gBS->FreePool (ImageData);
|
||||
gBS->FreePool (Blt);
|
||||
|
||||
if (Badging == NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
DisableQuietBoot (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Use Console Control to turn on GOP/UGA based Simple Text Out consoles. The GOP/UGA
|
||||
Simple Text Out screens will now be synced up with all non GOP/UGA output devices
|
||||
|
||||
Arguments:
|
||||
|
||||
NONE
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - GOP/UGA devices are back in text mode and synced up.
|
||||
EFI_UNSUPPORTED - Logo not found
|
||||
|
||||
--*/
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl;
|
||||
|
||||
Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, (VOID **) &ConsoleControl);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
return ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenText);
|
||||
}
|
||||
|
||||
UINTN
|
||||
_IPrint (
|
||||
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,
|
||||
IN EFI_UGA_DRAW_PROTOCOL *UgaDraw,
|
||||
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Sto,
|
||||
IN UINTN X,
|
||||
IN UINTN Y,
|
||||
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Foreground,
|
||||
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Background,
|
||||
IN CHAR16 *fmt,
|
||||
IN VA_LIST args
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Display string worker for: Print, PrintAt, IPrint, IPrintAt
|
||||
|
||||
Arguments:
|
||||
|
||||
GraphicsOutput - Graphics output protocol interface
|
||||
|
||||
UgaDraw - UGA draw protocol interface
|
||||
|
||||
Sto - Simple text out protocol interface
|
||||
|
||||
X - X coordinate to start printing
|
||||
|
||||
Y - Y coordinate to start printing
|
||||
|
||||
Foreground - Foreground color
|
||||
|
||||
Background - Background color
|
||||
|
||||
fmt - Format string
|
||||
|
||||
args - Print arguments
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - success
|
||||
EFI_OUT_OF_RESOURCES - out of resources
|
||||
|
||||
--*/
|
||||
{
|
||||
VOID *Buffer;
|
||||
EFI_STATUS Status;
|
||||
UINTN Index;
|
||||
CHAR16 *UnicodeWeight;
|
||||
UINT32 HorizontalResolution;
|
||||
UINT32 VerticalResolution;
|
||||
UINT32 ColorDepth;
|
||||
UINT32 RefreshRate;
|
||||
UINTN BufferLen;
|
||||
UINTN LineBufferLen;
|
||||
EFI_HII_FONT_PROTOCOL *HiiFont;
|
||||
EFI_IMAGE_OUTPUT *Blt;
|
||||
EFI_FONT_DISPLAY_INFO *FontInfo;
|
||||
|
||||
//
|
||||
// For now, allocate an arbitrarily long buffer
|
||||
//
|
||||
Buffer = AllocateZeroPool (0x10000);
|
||||
if (Buffer == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
if (GraphicsOutput != NULL) {
|
||||
HorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution;
|
||||
VerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution;
|
||||
} else {
|
||||
UgaDraw->GetMode (UgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate);
|
||||
}
|
||||
ASSERT ((HorizontalResolution != 0) && (VerticalResolution !=0));
|
||||
|
||||
Blt = NULL;
|
||||
FontInfo = NULL;
|
||||
ASSERT (GraphicsOutput != NULL);
|
||||
Status = gBS->LocateProtocol (&gEfiHiiFontProtocolGuid, NULL, (VOID **) &HiiFont);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Error;
|
||||
}
|
||||
|
||||
UnicodeVSPrint (Buffer, 0x10000, fmt, args);
|
||||
|
||||
UnicodeWeight = (CHAR16 *) Buffer;
|
||||
|
||||
for (Index = 0; UnicodeWeight[Index] != 0; Index++) {
|
||||
if (UnicodeWeight[Index] == CHAR_BACKSPACE ||
|
||||
UnicodeWeight[Index] == CHAR_LINEFEED ||
|
||||
UnicodeWeight[Index] == CHAR_CARRIAGE_RETURN) {
|
||||
UnicodeWeight[Index] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
BufferLen = StrLen (Buffer);
|
||||
|
||||
|
||||
LineBufferLen = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * HorizontalResolution * EFI_GLYPH_HEIGHT;
|
||||
if (EFI_GLYPH_WIDTH * EFI_GLYPH_HEIGHT * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * BufferLen > LineBufferLen) {
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto Error;
|
||||
}
|
||||
|
||||
Blt = (EFI_IMAGE_OUTPUT *) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT));
|
||||
if (Blt == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto Error;
|
||||
}
|
||||
|
||||
Blt->Width = (UINT16) (HorizontalResolution);
|
||||
Blt->Height = (UINT16) (VerticalResolution);
|
||||
Blt->Image.Screen = GraphicsOutput;
|
||||
|
||||
FontInfo = (EFI_FONT_DISPLAY_INFO *) AllocateZeroPool (sizeof (EFI_FONT_DISPLAY_INFO));
|
||||
if (FontInfo == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto Error;
|
||||
}
|
||||
if (Foreground != NULL) {
|
||||
CopyMem (&FontInfo->ForegroundColor, Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
|
||||
} else {
|
||||
CopyMem (
|
||||
&FontInfo->ForegroundColor,
|
||||
&mEfiColors[Sto->Mode->Attribute & 0x0f],
|
||||
sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
|
||||
);
|
||||
}
|
||||
if (Background != NULL) {
|
||||
CopyMem (&FontInfo->BackgroundColor, Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
|
||||
} else {
|
||||
CopyMem (
|
||||
&FontInfo->BackgroundColor,
|
||||
&mEfiColors[Sto->Mode->Attribute >> 4],
|
||||
sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
|
||||
);
|
||||
}
|
||||
|
||||
Status = HiiFont->StringToImage (
|
||||
HiiFont,
|
||||
EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_DIRECT_TO_SCREEN,
|
||||
Buffer,
|
||||
FontInfo,
|
||||
&Blt,
|
||||
X,
|
||||
Y,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
|
||||
|
||||
Error:
|
||||
SafeFreePool (Blt);
|
||||
SafeFreePool (FontInfo);
|
||||
gBS->FreePool (Buffer);
|
||||
return Status;
|
||||
}
|
||||
|
||||
UINTN
|
||||
PrintXY (
|
||||
IN UINTN X,
|
||||
IN UINTN Y,
|
||||
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *ForeGround, OPTIONAL
|
||||
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BackGround, OPTIONAL
|
||||
IN CHAR16 *Fmt,
|
||||
...
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Prints a formatted unicode string to the default console
|
||||
|
||||
Arguments:
|
||||
|
||||
X - X coordinate to start printing
|
||||
|
||||
Y - Y coordinate to start printing
|
||||
|
||||
ForeGround - Foreground color
|
||||
|
||||
BackGround - Background color
|
||||
|
||||
Fmt - Format string
|
||||
|
||||
... - Print arguments
|
||||
|
||||
Returns:
|
||||
|
||||
Length of string printed to the console
|
||||
|
||||
--*/
|
||||
{
|
||||
EFI_HANDLE Handle;
|
||||
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
|
||||
EFI_UGA_DRAW_PROTOCOL *UgaDraw;
|
||||
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Sto;
|
||||
EFI_STATUS Status;
|
||||
VA_LIST Args;
|
||||
|
||||
VA_START (Args, Fmt);
|
||||
|
||||
Handle = gST->ConsoleOutHandle;
|
||||
|
||||
Status = gBS->HandleProtocol (
|
||||
Handle,
|
||||
&gEfiGraphicsOutputProtocolGuid,
|
||||
(VOID**)&GraphicsOutput
|
||||
);
|
||||
|
||||
UgaDraw = NULL;
|
||||
if (EFI_ERROR (Status)) {
|
||||
GraphicsOutput = NULL;
|
||||
|
||||
Status = gBS->HandleProtocol (
|
||||
Handle,
|
||||
&gEfiUgaDrawProtocolGuid,
|
||||
(VOID**)&UgaDraw
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
Status = gBS->HandleProtocol (
|
||||
Handle,
|
||||
&gEfiSimpleTextOutProtocolGuid,
|
||||
(VOID**)&Sto
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
return _IPrint (GraphicsOutput, UgaDraw, Sto, X, Y, ForeGround, BackGround, Fmt, Args);
|
||||
}
|
||||
|
57
MdeModulePkg/Library/GraphicsLib/GraphicsLib.inf
Normal file
57
MdeModulePkg/Library/GraphicsLib/GraphicsLib.inf
Normal file
@@ -0,0 +1,57 @@
|
||||
#/** @file
|
||||
# Graphics Library for UEFI drivers
|
||||
#
|
||||
# This library provides supports for basic graphic functions.
|
||||
# Copyright (c) 2006 - 2007, Intel Corporation.
|
||||
#
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
#**/
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = EdkGraphicsLib
|
||||
FILE_GUID = 08c1a0e4-1208-47f8-a2c5-f42eabee653a
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = GraphicsLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
|
||||
EDK_RELEASE_VERSION = 0x00020000
|
||||
EFI_SPECIFICATION_VERSION = 0x00020000
|
||||
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
#
|
||||
|
||||
[Sources.common]
|
||||
Graphics.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
UefiBootServicesTableLib
|
||||
MemoryAllocationLib
|
||||
BaseLib
|
||||
PrintLib
|
||||
DebugLib
|
||||
DxePiLib
|
||||
BaseMemoryLib
|
||||
|
||||
[Protocols]
|
||||
gEfiSimpleTextOutProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiGraphicsOutputProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiUgaDrawProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiConsoleControlProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiFirmwareVolume2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiOEMBadgingProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiHiiFontProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
72
MdeModulePkg/Library/GraphicsLib/GraphicsLib.msa
Normal file
72
MdeModulePkg/Library/GraphicsLib/GraphicsLib.msa
Normal file
@@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<MsaHeader>
|
||||
<ModuleName>EdkGraphicsLib</ModuleName>
|
||||
<ModuleType>DXE_DRIVER</ModuleType>
|
||||
<GuidValue>08c1a0e4-1208-47f8-a2c5-f42eabee653a</GuidValue>
|
||||
<Version>1.0</Version>
|
||||
<Abstract>Graphics Library for UEFI drivers</Abstract>
|
||||
<Description>This library provides supports for basic graphic functions.</Description>
|
||||
<Copyright>Copyright (c) 2006 - 2007, Intel Corporation.</Copyright>
|
||||
<License>All rights reserved. This program and the accompanying materials
|
||||
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.</License>
|
||||
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
|
||||
</MsaHeader>
|
||||
<ModuleDefinitions>
|
||||
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
|
||||
<BinaryModule>false</BinaryModule>
|
||||
<OutputFileBasename>EdkGraphicsLib</OutputFileBasename>
|
||||
</ModuleDefinitions>
|
||||
<LibraryClassDefinitions>
|
||||
<LibraryClass Usage="ALWAYS_PRODUCED" SupModuleList="DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER">
|
||||
<Keyword>EdkGraphicsLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>PrintLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>BaseLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>MemoryAllocationLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>UefiBootServicesTableLib</Keyword>
|
||||
</LibraryClass>
|
||||
</LibraryClassDefinitions>
|
||||
<SourceFiles>
|
||||
<Filename>Graphics.c</Filename>
|
||||
</SourceFiles>
|
||||
<PackageDependencies>
|
||||
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
|
||||
</PackageDependencies>
|
||||
<Protocols>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiOEMBadgingProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiFirmwareVolumeProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiConsoleControlProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiUgaDrawProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiGraphicsOutputProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiSimpleTextOutProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
</Protocols>
|
||||
<Externs>
|
||||
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
|
||||
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
|
||||
</Externs>
|
||||
</ModuleSurfaceArea>
|
71
MdeModulePkg/Library/IfrSupportLib/IfrSupportLib.inf
Normal file
71
MdeModulePkg/Library/IfrSupportLib/IfrSupportLib.inf
Normal file
@@ -0,0 +1,71 @@
|
||||
#/** @file
|
||||
# Component name for module UefiEfiIfrSupportLib
|
||||
#
|
||||
# FIX ME!
|
||||
# Copyright (c) 2007, Intel Corporation. All rights reserved.
|
||||
#
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
#**/
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = IfrSupportLib
|
||||
FILE_GUID = bf38668e-e231-4baa-99e4-8c0e4c35dca6
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = IfrSupportLib
|
||||
EDK_RELEASE_VERSION = 0x00020000
|
||||
EFI_SPECIFICATION_VERSION = 0x00020000
|
||||
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
#
|
||||
|
||||
[Sources.common]
|
||||
UefiIfrCommon.c
|
||||
UefiIfrForm.c
|
||||
UefiIfrLibraryInternal.h
|
||||
UefiIfrOpCodeCreation.c
|
||||
UefiIfrString.c
|
||||
R8Lib.h
|
||||
R8Lib.c
|
||||
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
|
||||
|
||||
[LibraryClasses]
|
||||
MemoryAllocationLib
|
||||
DevicePathLib
|
||||
BaseLib
|
||||
UefiBootServicesTableLib
|
||||
UefiRuntimeServicesTableLib
|
||||
BaseMemoryLib
|
||||
DebugLib
|
||||
PcdLib
|
||||
|
||||
[Guids]
|
||||
gEfiGlobalVariableGuid # ALWAYS_CONSUMED
|
||||
|
||||
[Protocols]
|
||||
gEfiDevicePathProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiHiiDatabaseProtocolGuid
|
||||
gEfiHiiStringProtocolGuid
|
||||
gEfiHiiConfigRoutingProtocolGuid
|
||||
gEfiFormBrowser2ProtocolGuid
|
||||
|
||||
[Pcd]
|
||||
gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLang
|
74
MdeModulePkg/Library/IfrSupportLib/IfrSupportLib.msa
Normal file
74
MdeModulePkg/Library/IfrSupportLib/IfrSupportLib.msa
Normal file
@@ -0,0 +1,74 @@
|
||||
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<MsaHeader>
|
||||
<ModuleName>UefiEfiIfrSupportLib</ModuleName>
|
||||
<ModuleType>DXE_DRIVER</ModuleType>
|
||||
<GuidValue>bf38668e-e231-4baa-99e4-8c0e4c35dca6</GuidValue>
|
||||
<Version>1.0</Version>
|
||||
<Abstract>Component name for module UefiEfiIfrSupportLib</Abstract>
|
||||
<Description>FIX ME!</Description>
|
||||
<Copyright>Copyright (c) 2007, Intel Corporation. All rights reserved.</Copyright>
|
||||
<License>All rights reserved. This program and the accompanying materials
|
||||
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.</License>
|
||||
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
|
||||
</MsaHeader>
|
||||
<ModuleDefinitions>
|
||||
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
|
||||
<BinaryModule>false</BinaryModule>
|
||||
<OutputFileBasename>UefiEfiIfrSupportLib</OutputFileBasename>
|
||||
</ModuleDefinitions>
|
||||
<LibraryClassDefinitions>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>DebugLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>BaseMemoryLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>UefiRuntimeServicesTableLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>UefiBootServicesTableLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>BaseLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>DevicePathLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>MemoryAllocationLib</Keyword>
|
||||
</LibraryClass>
|
||||
</LibraryClassDefinitions>
|
||||
<SourceFiles>
|
||||
<Filename>R8Lib.c</Filename>
|
||||
<Filename>R8Lib.h</Filename>
|
||||
<Filename>UefiIfrString.c</Filename>
|
||||
<Filename>UefiIfrOpCodeCreation.c</Filename>
|
||||
<Filename>UefiIfrLibraryInternal.h</Filename>
|
||||
<Filename>UefiIfrForm.c</Filename>
|
||||
<Filename>UefiIfrCommon.c</Filename>
|
||||
</SourceFiles>
|
||||
<PackageDependencies>
|
||||
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
|
||||
</PackageDependencies>
|
||||
<Protocols>
|
||||
<Protocol Usage="ALWAYS_CONSUMED">
|
||||
<ProtocolCName>gEfiDevicePathProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
</Protocols>
|
||||
<Guids>
|
||||
<GuidCNames Usage="ALWAYS_CONSUMED">
|
||||
<GuidCName>gEfiGlobalVariableGuid</GuidCName>
|
||||
</GuidCNames>
|
||||
</Guids>
|
||||
<Externs>
|
||||
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
|
||||
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
|
||||
</Externs>
|
||||
</ModuleSurfaceArea>
|
241
MdeModulePkg/Library/IfrSupportLib/R8Lib.c
Normal file
241
MdeModulePkg/Library/IfrSupportLib/R8Lib.c
Normal file
@@ -0,0 +1,241 @@
|
||||
/**@file
|
||||
Copyright (c) 2007, Intel Corporation
|
||||
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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 "UefiIfrLibraryInternal.h"
|
||||
|
||||
|
||||
CHAR16
|
||||
InternalNibbleToHexChar (
|
||||
IN UINT8 Nibble
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Converts the low nibble of a byte to hex unicode character.
|
||||
|
||||
Arguments:
|
||||
Nibble - lower nibble of a byte.
|
||||
|
||||
Returns:
|
||||
Hex unicode character.
|
||||
|
||||
--*/
|
||||
{
|
||||
Nibble &= 0x0F;
|
||||
if (Nibble <= 0x9) {
|
||||
return (CHAR16)(Nibble + L'0');
|
||||
}
|
||||
|
||||
return (CHAR16)(Nibble - 0xA + L'A');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Converts binary buffer to Unicode string.
|
||||
At a minimum, any blob of data could be represented as a hex string.
|
||||
|
||||
@param Str Pointer to the string.
|
||||
@param HexStringBufferLength Length in bytes of buffer to hold the hex string.
|
||||
Includes tailing '\0' character. If routine return
|
||||
with EFI_SUCCESS, containing length of hex string
|
||||
buffer. If routine return with
|
||||
EFI_BUFFER_TOO_SMALL, containg length of hex
|
||||
string buffer desired.
|
||||
@param Buf Buffer to be converted from.
|
||||
@param Len Length in bytes of the buffer to be converted.
|
||||
|
||||
@retval EFI_SUCCESS Routine success.
|
||||
@retval EFI_BUFFER_TOO_SMALL The hex string buffer is too small.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
R8_BufToHexString (
|
||||
IN OUT CHAR16 *Str,
|
||||
IN OUT UINTN *HexStringBufferLength,
|
||||
IN UINT8 *Buf,
|
||||
IN UINTN Len
|
||||
)
|
||||
{
|
||||
//
|
||||
// Porting Guide:
|
||||
// This library interface is simply obsolete.
|
||||
// Include the source code to user code.
|
||||
//
|
||||
UINTN Idx;
|
||||
UINT8 Byte;
|
||||
UINTN StrLen;
|
||||
|
||||
//
|
||||
// Make sure string is either passed or allocate enough.
|
||||
// It takes 2 Unicode characters (4 bytes) to represent 1 byte of the binary buffer.
|
||||
// Plus the Unicode termination character.
|
||||
//
|
||||
StrLen = Len * 2;
|
||||
if (StrLen > ((*HexStringBufferLength) - 1)) {
|
||||
*HexStringBufferLength = StrLen + 1;
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
*HexStringBufferLength = StrLen + 1;
|
||||
//
|
||||
// Ends the string.
|
||||
//
|
||||
Str[StrLen] = L'\0';
|
||||
|
||||
for (Idx = 0; Idx < Len; Idx++) {
|
||||
|
||||
Byte = Buf[Idx];
|
||||
Str[StrLen - 1 - Idx * 2] = InternalNibbleToHexChar (Byte);
|
||||
Str[StrLen - 2 - Idx * 2] = InternalNibbleToHexChar ((UINT8)(Byte >> 4));
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Converts Unicode string to binary buffer.
|
||||
The conversion may be partial.
|
||||
The first character in the string that is not hex digit stops the conversion.
|
||||
At a minimum, any blob of data could be represented as a hex string.
|
||||
|
||||
@param Buf Pointer to buffer that receives the data.
|
||||
@param Len Length in bytes of the buffer to hold converted
|
||||
data. If routine return with EFI_SUCCESS,
|
||||
containing length of converted data. If routine
|
||||
return with EFI_BUFFER_TOO_SMALL, containg length
|
||||
of buffer desired.
|
||||
@param Str String to be converted from.
|
||||
@param ConvertedStrLen Length of the Hex String consumed.
|
||||
|
||||
@retval EFI_SUCCESS Routine Success.
|
||||
@retval EFI_BUFFER_TOO_SMALL The buffer is too small to hold converted data.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
R8_HexStringToBuf (
|
||||
IN OUT UINT8 *Buf,
|
||||
IN OUT UINTN *Len,
|
||||
IN CHAR16 *Str,
|
||||
OUT UINTN *ConvertedStrLen OPTIONAL
|
||||
)
|
||||
{
|
||||
//
|
||||
// Porting Guide:
|
||||
// This library interface is simply obsolete.
|
||||
// Include the source code to user code.
|
||||
//
|
||||
|
||||
UINTN HexCnt;
|
||||
UINTN Idx;
|
||||
UINTN BufferLength;
|
||||
UINT8 Digit;
|
||||
UINT8 Byte;
|
||||
|
||||
//
|
||||
// Find out how many hex characters the string has.
|
||||
//
|
||||
for (Idx = 0, HexCnt = 0; R8_IsHexDigit (&Digit, Str[Idx]); Idx++, HexCnt++);
|
||||
|
||||
if (HexCnt == 0) {
|
||||
*Len = 0;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
//
|
||||
// Two Unicode characters make up 1 buffer byte. Round up.
|
||||
//
|
||||
BufferLength = (HexCnt + 1) / 2;
|
||||
|
||||
//
|
||||
// Test if buffer is passed enough.
|
||||
//
|
||||
if (BufferLength > (*Len)) {
|
||||
*Len = BufferLength;
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
*Len = BufferLength;
|
||||
|
||||
for (Idx = 0; Idx < HexCnt; Idx++) {
|
||||
|
||||
R8_IsHexDigit (&Digit, Str[HexCnt - 1 - Idx]);
|
||||
|
||||
//
|
||||
// For odd charaters, write the lower nibble for each buffer byte,
|
||||
// and for even characters, the upper nibble.
|
||||
//
|
||||
if ((Idx & 1) == 0) {
|
||||
Byte = Digit;
|
||||
} else {
|
||||
Byte = Buf[Idx / 2];
|
||||
Byte &= 0x0F;
|
||||
Byte = (UINT8) (Byte | Digit << 4);
|
||||
}
|
||||
|
||||
Buf[Idx / 2] = Byte;
|
||||
}
|
||||
|
||||
if (ConvertedStrLen != NULL) {
|
||||
*ConvertedStrLen = HexCnt;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Determines if a Unicode character is a hexadecimal digit.
|
||||
The test is case insensitive.
|
||||
|
||||
@param Digit Pointer to byte that receives the value of the hex
|
||||
character.
|
||||
@param Char Unicode character to test.
|
||||
|
||||
@retval TRUE If the character is a hexadecimal digit.
|
||||
@retval FALSE Otherwise.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
R8_IsHexDigit (
|
||||
OUT UINT8 *Digit,
|
||||
IN CHAR16 Char
|
||||
)
|
||||
{
|
||||
//
|
||||
// Porting Guide:
|
||||
// This library interface is simply obsolete.
|
||||
// Include the source code to user code.
|
||||
//
|
||||
|
||||
if ((Char >= L'0') && (Char <= L'9')) {
|
||||
*Digit = (UINT8) (Char - L'0');
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ((Char >= L'A') && (Char <= L'F')) {
|
||||
*Digit = (UINT8) (Char - L'A' + 0x0A);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ((Char >= L'a') && (Char <= L'f')) {
|
||||
*Digit = (UINT8) (Char - L'a' + 0x0A);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
93
MdeModulePkg/Library/IfrSupportLib/R8Lib.h
Normal file
93
MdeModulePkg/Library/IfrSupportLib/R8Lib.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/**@file
|
||||
Copyright (c) 2007, Intel Corporation
|
||||
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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.
|
||||
|
||||
|
||||
**/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Converts binary buffer to Unicode string.
|
||||
At a minimum, any blob of data could be represented as a hex string.
|
||||
|
||||
@param Str Pointer to the string.
|
||||
@param HexStringBufferLength Length in bytes of buffer to hold the hex string.
|
||||
Includes tailing '\0' character. If routine return
|
||||
with EFI_SUCCESS, containing length of hex string
|
||||
buffer. If routine return with
|
||||
EFI_BUFFER_TOO_SMALL, containg length of hex
|
||||
string buffer desired.
|
||||
@param Buf Buffer to be converted from.
|
||||
@param Len Length in bytes of the buffer to be converted.
|
||||
|
||||
@retval EFI_SUCCESS Routine success.
|
||||
@retval EFI_BUFFER_TOO_SMALL The hex string buffer is too small.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
R8_BufToHexString (
|
||||
IN OUT CHAR16 *Str,
|
||||
IN OUT UINTN *HexStringBufferLength,
|
||||
IN UINT8 *Buf,
|
||||
IN UINTN Len
|
||||
)
|
||||
;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Converts Unicode string to binary buffer.
|
||||
The conversion may be partial.
|
||||
The first character in the string that is not hex digit stops the conversion.
|
||||
At a minimum, any blob of data could be represented as a hex string.
|
||||
|
||||
@param Buf Pointer to buffer that receives the data.
|
||||
@param Len Length in bytes of the buffer to hold converted
|
||||
data. If routine return with EFI_SUCCESS,
|
||||
containing length of converted data. If routine
|
||||
return with EFI_BUFFER_TOO_SMALL, containg length
|
||||
of buffer desired.
|
||||
@param Str String to be converted from.
|
||||
@param ConvertedStrLen Length of the Hex String consumed.
|
||||
|
||||
@retval EFI_SUCCESS Routine Success.
|
||||
@retval EFI_BUFFER_TOO_SMALL The buffer is too small to hold converted data.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
R8_HexStringToBuf (
|
||||
IN OUT UINT8 *Buf,
|
||||
IN OUT UINTN *Len,
|
||||
IN CHAR16 *Str,
|
||||
OUT UINTN *ConvertedStrLen OPTIONAL
|
||||
)
|
||||
;
|
||||
|
||||
/**
|
||||
Determines if a Unicode character is a hexadecimal digit.
|
||||
The test is case insensitive.
|
||||
|
||||
@param Digit Pointer to byte that receives the value of the hex
|
||||
character.
|
||||
@param Char Unicode character to test.
|
||||
|
||||
@retval TRUE If the character is a hexadecimal digit.
|
||||
@retval FALSE Otherwise.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
R8_IsHexDigit (
|
||||
OUT UINT8 *Digit,
|
||||
IN CHAR16 Char
|
||||
)
|
||||
;
|
||||
|
369
MdeModulePkg/Library/IfrSupportLib/UefiIfrCommon.c
Normal file
369
MdeModulePkg/Library/IfrSupportLib/UefiIfrCommon.c
Normal file
@@ -0,0 +1,369 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2007, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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.
|
||||
|
||||
Module Name:
|
||||
|
||||
UefiIfrCommon.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Common Library Routines to assist handle HII elements.
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#include "UefiIfrLibraryInternal.h"
|
||||
|
||||
//
|
||||
// Hii relative protocols
|
||||
//
|
||||
BOOLEAN mHiiProtocolsInitialized = FALSE;
|
||||
|
||||
EFI_HII_DATABASE_PROTOCOL *gIfrLibHiiDatabase;
|
||||
EFI_HII_STRING_PROTOCOL *gIfrLibHiiString;
|
||||
|
||||
|
||||
/**
|
||||
This function locate Hii relative protocols for later usage.
|
||||
|
||||
None.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
LocateHiiProtocols (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (mHiiProtocolsInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **) &gIfrLibHiiDatabase);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Status = gBS->LocateProtocol (&gEfiHiiStringProtocolGuid, NULL, (VOID **) &gIfrLibHiiString);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
mHiiProtocolsInitialized = TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Assemble EFI_HII_PACKAGE_LIST according to the passed in packages.
|
||||
|
||||
@param NumberOfPackages Number of packages.
|
||||
@param GuidId Package GUID.
|
||||
|
||||
@return Pointer of EFI_HII_PACKAGE_LIST_HEADER.
|
||||
|
||||
**/
|
||||
EFI_HII_PACKAGE_LIST_HEADER *
|
||||
PreparePackageList (
|
||||
IN UINTN NumberOfPackages,
|
||||
IN EFI_GUID *GuidId,
|
||||
...
|
||||
)
|
||||
{
|
||||
VA_LIST Marker;
|
||||
EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
|
||||
UINT8 *PackageListData;
|
||||
UINT32 PackageListLength;
|
||||
UINT32 PackageLength;
|
||||
EFI_HII_PACKAGE_HEADER PackageHeader;
|
||||
UINT8 *PackageArray;
|
||||
UINTN Index;
|
||||
|
||||
PackageListLength = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
|
||||
|
||||
VA_START (Marker, GuidId);
|
||||
for (Index = 0; Index < NumberOfPackages; Index++) {
|
||||
CopyMem (&PackageLength, VA_ARG (Marker, VOID *), sizeof (UINT32));
|
||||
PackageListLength += (PackageLength - sizeof (UINT32));
|
||||
}
|
||||
VA_END (Marker);
|
||||
|
||||
//
|
||||
// Include the lenght of EFI_HII_PACKAGE_END
|
||||
//
|
||||
PackageListLength += sizeof (EFI_HII_PACKAGE_HEADER);
|
||||
PackageListHeader = AllocateZeroPool (PackageListLength);
|
||||
ASSERT (PackageListHeader != NULL);
|
||||
CopyMem (&PackageListHeader->PackageListGuid, GuidId, sizeof (EFI_GUID));
|
||||
PackageListHeader->PackageLength = PackageListLength;
|
||||
|
||||
PackageListData = ((UINT8 *) PackageListHeader) + sizeof (EFI_HII_PACKAGE_LIST_HEADER);
|
||||
|
||||
VA_START (Marker, GuidId);
|
||||
for (Index = 0; Index < NumberOfPackages; Index++) {
|
||||
PackageArray = (UINT8 *) VA_ARG (Marker, VOID *);
|
||||
CopyMem (&PackageLength, PackageArray, sizeof (UINT32));
|
||||
PackageLength -= sizeof (UINT32);
|
||||
PackageArray += sizeof (UINT32);
|
||||
CopyMem (PackageListData, PackageArray, PackageLength);
|
||||
PackageListData += PackageLength;
|
||||
}
|
||||
VA_END (Marker);
|
||||
|
||||
//
|
||||
// Append EFI_HII_PACKAGE_END
|
||||
//
|
||||
PackageHeader.Type = EFI_HII_PACKAGE_END;
|
||||
PackageHeader.Length = sizeof (EFI_HII_PACKAGE_HEADER);
|
||||
CopyMem (PackageListData, &PackageHeader, PackageHeader.Length);
|
||||
|
||||
return PackageListHeader;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Find HII Handle associated with given Device Path.
|
||||
|
||||
@param HiiDatabase Point to EFI_HII_DATABASE_PROTOCOL instance.
|
||||
@param DevicePath Device Path associated with the HII package list
|
||||
handle.
|
||||
|
||||
@retval Handle HII package list Handle associated with the Device
|
||||
Path.
|
||||
@retval NULL Hii Package list handle is not found.
|
||||
|
||||
**/
|
||||
EFI_HII_HANDLE
|
||||
DevicePathToHiiHandle (
|
||||
IN EFI_HII_DATABASE_PROTOCOL *HiiDatabase,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_DEVICE_PATH_PROTOCOL *TmpDevicePath;
|
||||
UINTN BufferSize;
|
||||
UINTN HandleCount;
|
||||
UINTN Index;
|
||||
EFI_HANDLE *Handles;
|
||||
EFI_HANDLE Handle;
|
||||
UINTN Size;
|
||||
EFI_HANDLE DriverHandle;
|
||||
EFI_HII_HANDLE *HiiHandles;
|
||||
EFI_HII_HANDLE HiiHandle;
|
||||
|
||||
//
|
||||
// Locate Device Path Protocol handle buffer
|
||||
//
|
||||
Status = gBS->LocateHandleBuffer (
|
||||
ByProtocol,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
NULL,
|
||||
&HandleCount,
|
||||
&Handles
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Search Driver Handle by Device Path
|
||||
//
|
||||
DriverHandle = NULL;
|
||||
BufferSize = GetDevicePathSize (DevicePath);
|
||||
for(Index = 0; Index < HandleCount; Index++) {
|
||||
Handle = Handles[Index];
|
||||
gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **) &TmpDevicePath);
|
||||
|
||||
//
|
||||
// Check whether DevicePath match
|
||||
//
|
||||
Size = GetDevicePathSize (TmpDevicePath);
|
||||
if ((Size == BufferSize) && CompareMem (DevicePath, TmpDevicePath, Size) == 0) {
|
||||
DriverHandle = Handle;
|
||||
break;
|
||||
}
|
||||
}
|
||||
gBS->FreePool (Handles);
|
||||
|
||||
if (DriverHandle == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve all Hii Handles from HII database
|
||||
//
|
||||
BufferSize = 0x1000;
|
||||
HiiHandles = AllocatePool (BufferSize);
|
||||
ASSERT (HiiHandles != NULL);
|
||||
Status = HiiDatabase->ListPackageLists (
|
||||
HiiDatabase,
|
||||
EFI_HII_PACKAGE_TYPE_ALL,
|
||||
NULL,
|
||||
&BufferSize,
|
||||
HiiHandles
|
||||
);
|
||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
gBS->FreePool (HiiHandles);
|
||||
HiiHandles = AllocatePool (BufferSize);
|
||||
ASSERT (HiiHandles != NULL);
|
||||
|
||||
Status = HiiDatabase->ListPackageLists (
|
||||
HiiDatabase,
|
||||
EFI_HII_PACKAGE_TYPE_ALL,
|
||||
NULL,
|
||||
&BufferSize,
|
||||
HiiHandles
|
||||
);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
gBS->FreePool (HiiHandles);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Search Hii Handle by Driver Handle
|
||||
//
|
||||
HiiHandle = NULL;
|
||||
HandleCount = BufferSize / sizeof (EFI_HII_HANDLE);
|
||||
for (Index = 0; Index < HandleCount; Index++) {
|
||||
Status = HiiDatabase->GetPackageListHandle (
|
||||
HiiDatabase,
|
||||
HiiHandles[Index],
|
||||
&Handle
|
||||
);
|
||||
if (!EFI_ERROR (Status) && (Handle == DriverHandle)) {
|
||||
HiiHandle = HiiHandles[Index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
gBS->FreePool (HiiHandles);
|
||||
return HiiHandle;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Determines the handles that are currently active in the database.
|
||||
It's the caller's responsibility to free handle buffer.
|
||||
|
||||
@param HiiDatabase A pointer to the EFI_HII_DATABASE_PROTOCOL
|
||||
instance.
|
||||
@param HandleBufferLength On input, a pointer to the length of the handle
|
||||
buffer. On output, the length of the handle buffer
|
||||
that is required for the handles found.
|
||||
@param HiiHandleBuffer Pointer to an array of Hii Handles returned.
|
||||
|
||||
@retval EFI_SUCCESS Get an array of Hii Handles successfully.
|
||||
@retval EFI_INVALID_PARAMETER Hii is NULL.
|
||||
@retval EFI_NOT_FOUND Database not found.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
GetHiiHandles (
|
||||
IN OUT UINTN *HandleBufferLength,
|
||||
OUT EFI_HII_HANDLE **HiiHandleBuffer
|
||||
)
|
||||
{
|
||||
UINTN BufferLength;
|
||||
EFI_STATUS Status;
|
||||
|
||||
BufferLength = 0;
|
||||
|
||||
LocateHiiProtocols ();
|
||||
|
||||
//
|
||||
// Try to find the actual buffer size for HiiHandle Buffer.
|
||||
//
|
||||
Status = gIfrLibHiiDatabase->ListPackageLists (
|
||||
gIfrLibHiiDatabase,
|
||||
EFI_HII_PACKAGE_TYPE_ALL,
|
||||
NULL,
|
||||
&BufferLength,
|
||||
*HiiHandleBuffer
|
||||
);
|
||||
|
||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
*HiiHandleBuffer = AllocateZeroPool (BufferLength);
|
||||
Status = gIfrLibHiiDatabase->ListPackageLists (
|
||||
gIfrLibHiiDatabase,
|
||||
EFI_HII_PACKAGE_TYPE_ALL,
|
||||
NULL,
|
||||
&BufferLength,
|
||||
*HiiHandleBuffer
|
||||
);
|
||||
//
|
||||
// we should not fail here.
|
||||
//
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
|
||||
*HandleBufferLength = BufferLength;
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Extract Hii package list GUID for given HII handle.
|
||||
|
||||
@param HiiHandle Hii handle
|
||||
@param Guid Package list GUID
|
||||
|
||||
@retval EFI_SUCCESS Successfully extract GUID from Hii database.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
ExtractGuidFromHiiHandle (
|
||||
IN EFI_HII_HANDLE Handle,
|
||||
OUT EFI_GUID *Guid
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN BufferSize;
|
||||
EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
|
||||
EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
|
||||
|
||||
//
|
||||
// Locate HII Database protocol
|
||||
//
|
||||
Status = gBS->LocateProtocol (
|
||||
&gEfiHiiDatabaseProtocolGuid,
|
||||
NULL,
|
||||
(VOID **) &HiiDatabase
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Get HII PackageList
|
||||
//
|
||||
BufferSize = 0;
|
||||
HiiPackageList = NULL;
|
||||
Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);
|
||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
HiiPackageList = AllocatePool (BufferSize);
|
||||
ASSERT (HiiPackageList != NULL);
|
||||
|
||||
Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);
|
||||
}
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Extract GUID
|
||||
//
|
||||
CopyMem (Guid, &HiiPackageList->PackageListGuid, sizeof (EFI_GUID));
|
||||
|
||||
gBS->FreePool (HiiPackageList);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
1121
MdeModulePkg/Library/IfrSupportLib/UefiIfrForm.c
Normal file
1121
MdeModulePkg/Library/IfrSupportLib/UefiIfrForm.c
Normal file
File diff suppressed because it is too large
Load Diff
64
MdeModulePkg/Library/IfrSupportLib/UefiIfrLibraryInternal.h
Normal file
64
MdeModulePkg/Library/IfrSupportLib/UefiIfrLibraryInternal.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2007, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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.
|
||||
|
||||
Module Name:
|
||||
|
||||
UefiIfrLibraryInternal
|
||||
|
||||
Abstract:
|
||||
|
||||
The file contain all library function for Ifr Operations.
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _IFRLIBRARY_INTERNAL_H
|
||||
#define _IFRLIBRARY_INTERNAL_H
|
||||
|
||||
|
||||
#include <PiDxe.h>
|
||||
|
||||
#include <Guid/GlobalVariable.h>
|
||||
#include <Protocol/DevicePath.h>
|
||||
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/IfrSupportLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
|
||||
#include <MdeModuleHii.h>
|
||||
|
||||
#include "R8Lib.h"
|
||||
|
||||
VOID
|
||||
LocateHiiProtocols (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
This function locate Hii relative protocols for later usage.
|
||||
|
||||
Arguments:
|
||||
None.
|
||||
|
||||
Returns:
|
||||
None.
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
#endif
|
639
MdeModulePkg/Library/IfrSupportLib/UefiIfrOpCodeCreation.c
Normal file
639
MdeModulePkg/Library/IfrSupportLib/UefiIfrOpCodeCreation.c
Normal file
@@ -0,0 +1,639 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2007, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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.
|
||||
|
||||
Module Name:
|
||||
|
||||
UefiIfrOpCodeCreation.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Library Routines to create IFR independent of string data - assume tokens already exist
|
||||
Primarily to be used for exporting op-codes at a label in pre-defined forms.
|
||||
|
||||
Revision History:
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#include "UefiIfrLibraryInternal.h"
|
||||
|
||||
STATIC EFI_GUID mIfrVendorGuid = EFI_IFR_TIANO_GUID;
|
||||
|
||||
STATIC
|
||||
BOOLEAN
|
||||
IsValidQuestionFlags (
|
||||
IN UINT8 Flags
|
||||
)
|
||||
{
|
||||
return (BOOLEAN) ((Flags & (~QUESTION_FLAGS)) ? FALSE : TRUE);
|
||||
}
|
||||
|
||||
STATIC
|
||||
BOOLEAN
|
||||
IsValidValueType (
|
||||
IN UINT8 Type
|
||||
)
|
||||
{
|
||||
return (BOOLEAN) ((Type <= EFI_IFR_TYPE_OTHER) ? TRUE : FALSE);
|
||||
}
|
||||
|
||||
STATIC
|
||||
BOOLEAN
|
||||
IsValidNumricFlags (
|
||||
IN UINT8 Flags
|
||||
)
|
||||
{
|
||||
if (Flags & ~(EFI_IFR_NUMERIC_SIZE | EFI_IFR_DISPLAY)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((Flags & EFI_IFR_DISPLAY) > EFI_IFR_DISPLAY_UINT_HEX) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
STATIC
|
||||
BOOLEAN
|
||||
IsValidCheckboxFlags (
|
||||
IN UINT8 Flags
|
||||
)
|
||||
{
|
||||
return (BOOLEAN) ((Flags <= EFI_IFR_CHECKBOX_DEFAULT_MFG) ? TRUE : FALSE);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
CreateEndOpCode (
|
||||
IN OUT EFI_HII_UPDATE_DATA *Data
|
||||
)
|
||||
{
|
||||
EFI_IFR_END End;
|
||||
UINT8 *LocalBuffer;
|
||||
|
||||
ASSERT (Data != NULL && Data->Data != NULL);
|
||||
|
||||
if (Data->Offset + sizeof (EFI_IFR_END) > Data->BufferSize) {
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
End.Header.Length = sizeof (EFI_IFR_END);
|
||||
End.Header.OpCode = EFI_IFR_END_OP;
|
||||
End.Header.Scope = 0;
|
||||
|
||||
LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
|
||||
CopyMem (LocalBuffer, &End, sizeof (EFI_IFR_END));
|
||||
Data->Offset += sizeof (EFI_IFR_END);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
CreateDefaultOpCode (
|
||||
IN EFI_IFR_TYPE_VALUE *Value,
|
||||
IN UINT8 Type,
|
||||
IN OUT EFI_HII_UPDATE_DATA *Data
|
||||
)
|
||||
{
|
||||
EFI_IFR_DEFAULT Default;
|
||||
UINT8 *LocalBuffer;
|
||||
|
||||
ASSERT (Data != NULL && Data->Data != NULL);
|
||||
|
||||
if ((Value == NULL) || !IsValidValueType (Type)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (Data->Offset + sizeof (EFI_IFR_DEFAULT) > Data->BufferSize) {
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Default.Header.OpCode = EFI_IFR_DEFAULT_OP;
|
||||
Default.Header.Length = sizeof (EFI_IFR_DEFAULT);
|
||||
Default.Header.Scope = 0;
|
||||
Default.Type = Type;
|
||||
Default.DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD;
|
||||
CopyMem (&Default.Value, Value, sizeof(EFI_IFR_TYPE_VALUE));
|
||||
|
||||
LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
|
||||
CopyMem (LocalBuffer, &Default, sizeof (EFI_IFR_DEFAULT));
|
||||
Data->Offset += sizeof (EFI_IFR_DEFAULT);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
CreateActionOpCode (
|
||||
IN EFI_QUESTION_ID QuestionId,
|
||||
IN EFI_STRING_ID Prompt,
|
||||
IN EFI_STRING_ID Help,
|
||||
IN UINT8 QuestionFlags,
|
||||
IN EFI_STRING_ID QuestionConfig,
|
||||
IN OUT EFI_HII_UPDATE_DATA *Data
|
||||
)
|
||||
{
|
||||
EFI_IFR_ACTION Action;
|
||||
UINT8 *LocalBuffer;
|
||||
|
||||
ASSERT (Data != NULL && Data->Data != NULL);
|
||||
|
||||
if (!IsValidQuestionFlags (QuestionFlags)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (Data->Offset + sizeof (EFI_IFR_ACTION) > Data->BufferSize) {
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Action.Header.OpCode = EFI_IFR_ACTION_OP;
|
||||
Action.Header.Length = sizeof (EFI_IFR_ACTION);
|
||||
Action.Header.Scope = 0;
|
||||
Action.Question.QuestionId = QuestionId;
|
||||
Action.Question.Header.Prompt = Prompt;
|
||||
Action.Question.Header.Help = Help;
|
||||
Action.Question.VarStoreId = INVALID_VARSTORE_ID;
|
||||
Action.Question.Flags = QuestionFlags;
|
||||
Action.QuestionConfig = QuestionConfig;
|
||||
|
||||
LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
|
||||
CopyMem (LocalBuffer, &Action, sizeof (EFI_IFR_ACTION));
|
||||
Data->Offset += sizeof (EFI_IFR_ACTION);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
CreateSubTitleOpCode (
|
||||
IN EFI_STRING_ID Prompt,
|
||||
IN EFI_STRING_ID Help,
|
||||
IN UINT8 Flags,
|
||||
IN UINT8 Scope,
|
||||
IN OUT EFI_HII_UPDATE_DATA *Data
|
||||
)
|
||||
{
|
||||
EFI_IFR_SUBTITLE Subtitle;
|
||||
UINT8 *LocalBuffer;
|
||||
|
||||
ASSERT (Data != NULL && Data->Data != NULL);
|
||||
|
||||
if (Data->Offset + sizeof (EFI_IFR_SUBTITLE) > Data->BufferSize) {
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Subtitle.Header.OpCode = EFI_IFR_SUBTITLE_OP;
|
||||
Subtitle.Header.Length = sizeof (EFI_IFR_SUBTITLE);
|
||||
Subtitle.Header.Scope = Scope;
|
||||
Subtitle.Statement.Prompt = Prompt;
|
||||
Subtitle.Statement.Help = Help;
|
||||
Subtitle.Flags = Flags;
|
||||
|
||||
LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
|
||||
CopyMem (LocalBuffer, &Subtitle, sizeof (EFI_IFR_SUBTITLE));
|
||||
Data->Offset += sizeof (EFI_IFR_SUBTITLE);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
CreateTextOpCode (
|
||||
IN EFI_STRING_ID Prompt,
|
||||
IN EFI_STRING_ID Help,
|
||||
IN EFI_STRING_ID TextTwo,
|
||||
IN OUT EFI_HII_UPDATE_DATA *Data
|
||||
)
|
||||
{
|
||||
EFI_IFR_TEXT Text;
|
||||
UINT8 *LocalBuffer;
|
||||
|
||||
ASSERT (Data != NULL && Data->Data != NULL);
|
||||
|
||||
if (Data->Offset + sizeof (EFI_IFR_TEXT) > Data->BufferSize) {
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Text.Header.OpCode = EFI_IFR_TEXT_OP;
|
||||
Text.Header.Length = sizeof (EFI_IFR_TEXT);
|
||||
Text.Header.Scope = 0;
|
||||
Text.Statement.Prompt = Prompt;
|
||||
Text.Statement.Help = Help;
|
||||
Text.TextTwo = TextTwo;
|
||||
|
||||
LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
|
||||
CopyMem (LocalBuffer, &Text, sizeof (EFI_IFR_TEXT));
|
||||
Data->Offset += sizeof (EFI_IFR_TEXT);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
CreateGotoOpCode (
|
||||
IN EFI_FORM_ID FormId,
|
||||
IN EFI_STRING_ID Prompt,
|
||||
IN EFI_STRING_ID Help,
|
||||
IN UINT8 QuestionFlags,
|
||||
IN EFI_QUESTION_ID QuestionId,
|
||||
IN OUT EFI_HII_UPDATE_DATA *Data
|
||||
)
|
||||
{
|
||||
EFI_IFR_REF Goto;
|
||||
UINT8 *LocalBuffer;
|
||||
|
||||
ASSERT (Data != NULL && Data->Data != NULL);
|
||||
|
||||
if (!IsValidQuestionFlags (QuestionFlags)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (Data->Offset + sizeof (EFI_IFR_REF) > Data->BufferSize) {
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Goto.Header.OpCode = EFI_IFR_REF_OP;
|
||||
Goto.Header.Length = sizeof (EFI_IFR_REF);
|
||||
Goto.Header.Scope = 0;
|
||||
Goto.Question.Header.Prompt = Prompt;
|
||||
Goto.Question.Header.Help = Help;
|
||||
Goto.Question.VarStoreId = INVALID_VARSTORE_ID;
|
||||
Goto.Question.QuestionId = QuestionId;
|
||||
Goto.Question.Flags = QuestionFlags;
|
||||
Goto.FormId = FormId;
|
||||
|
||||
LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
|
||||
CopyMem (LocalBuffer, &Goto, sizeof (EFI_IFR_REF));
|
||||
Data->Offset += sizeof (EFI_IFR_REF);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
CreateOneOfOptionOpCode (
|
||||
IN UINTN OptionCount,
|
||||
IN IFR_OPTION *OptionsList,
|
||||
IN UINT8 Type,
|
||||
IN OUT EFI_HII_UPDATE_DATA *Data
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
UINT8 *LocalBuffer;
|
||||
EFI_IFR_ONE_OF_OPTION OneOfOption;
|
||||
|
||||
ASSERT (Data != NULL && Data->Data != NULL);
|
||||
|
||||
if ((OptionCount != 0) && (OptionsList == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (Data->Offset + OptionCount * sizeof (EFI_IFR_ONE_OF_OPTION) > Data->BufferSize) {
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
for (Index = 0; Index < OptionCount; Index++) {
|
||||
OneOfOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP;
|
||||
OneOfOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION);
|
||||
OneOfOption.Header.Scope = 0;
|
||||
|
||||
OneOfOption.Option = OptionsList[Index].StringToken;
|
||||
OneOfOption.Value = OptionsList[Index].Value;
|
||||
OneOfOption.Flags = (UINT8) (OptionsList[Index].Flags & (EFI_IFR_OPTION_DEFAULT | EFI_IFR_OPTION_DEFAULT_MFG));
|
||||
OneOfOption.Type = Type;
|
||||
|
||||
LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
|
||||
CopyMem (LocalBuffer, &OneOfOption, sizeof (EFI_IFR_ONE_OF_OPTION));
|
||||
Data->Offset += sizeof (EFI_IFR_ONE_OF_OPTION);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
CreateOneOfOpCode (
|
||||
IN EFI_QUESTION_ID QuestionId,
|
||||
IN EFI_VARSTORE_ID VarStoreId,
|
||||
IN UINT16 VarOffset,
|
||||
IN EFI_STRING_ID Prompt,
|
||||
IN EFI_STRING_ID Help,
|
||||
IN UINT8 QuestionFlags,
|
||||
IN UINT8 OneOfFlags,
|
||||
IN IFR_OPTION *OptionsList,
|
||||
IN UINTN OptionCount,
|
||||
IN OUT EFI_HII_UPDATE_DATA *Data
|
||||
)
|
||||
{
|
||||
UINTN Length;
|
||||
EFI_IFR_ONE_OF OneOf;
|
||||
UINT8 *LocalBuffer;
|
||||
|
||||
ASSERT (Data != NULL && Data->Data != NULL);
|
||||
|
||||
if (!IsValidNumricFlags (OneOfFlags) ||
|
||||
!IsValidQuestionFlags (QuestionFlags) ||
|
||||
((OptionCount != 0) && (OptionsList == NULL))) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Length = sizeof (EFI_IFR_ONE_OF) + OptionCount * sizeof (EFI_IFR_ONE_OF_OPTION) + sizeof (EFI_IFR_END);
|
||||
if (Data->Offset + Length > Data->BufferSize) {
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
OneOf.Header.OpCode = EFI_IFR_ONE_OF_OP;
|
||||
OneOf.Header.Length = sizeof (EFI_IFR_ONE_OF);
|
||||
OneOf.Header.Scope = 1;
|
||||
OneOf.Question.Header.Prompt = Prompt;
|
||||
OneOf.Question.Header.Help = Help;
|
||||
OneOf.Question.QuestionId = QuestionId;
|
||||
OneOf.Question.VarStoreId = VarStoreId;
|
||||
OneOf.Question.VarStoreInfo.VarOffset = VarOffset;
|
||||
OneOf.Question.Flags = QuestionFlags;
|
||||
OneOf.Flags = OneOfFlags;
|
||||
ZeroMem ((VOID *) &OneOf.data, sizeof (MINMAXSTEP_DATA));
|
||||
|
||||
LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
|
||||
CopyMem (LocalBuffer, &OneOf, sizeof (EFI_IFR_ONE_OF));
|
||||
Data->Offset += sizeof (EFI_IFR_ONE_OF);
|
||||
|
||||
CreateOneOfOptionOpCode (OptionCount, OptionsList, (UINT8) (OneOfFlags & EFI_IFR_NUMERIC_SIZE), Data);
|
||||
|
||||
CreateEndOpCode (Data);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
CreateOrderedListOpCode (
|
||||
IN EFI_QUESTION_ID QuestionId,
|
||||
IN EFI_VARSTORE_ID VarStoreId,
|
||||
IN UINT16 VarOffset,
|
||||
IN EFI_STRING_ID Prompt,
|
||||
IN EFI_STRING_ID Help,
|
||||
IN UINT8 QuestionFlags,
|
||||
IN UINT8 OrderedListFlags,
|
||||
IN UINT8 DataType,
|
||||
IN UINT8 MaxContainers,
|
||||
IN IFR_OPTION *OptionsList,
|
||||
IN UINTN OptionCount,
|
||||
IN OUT EFI_HII_UPDATE_DATA *Data
|
||||
)
|
||||
{
|
||||
UINTN Length;
|
||||
EFI_IFR_ORDERED_LIST OrderedList;
|
||||
UINT8 *LocalBuffer;
|
||||
|
||||
ASSERT (Data != NULL && Data->Data != NULL);
|
||||
|
||||
if (!IsValidQuestionFlags (QuestionFlags) ||
|
||||
((OptionCount != 0) && (OptionsList == NULL))) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ((OrderedListFlags != 0) &&
|
||||
(OrderedListFlags != EFI_IFR_UNIQUE_SET) &&
|
||||
(OrderedListFlags != EFI_IFR_NO_EMPTY_SET)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Length = sizeof (EFI_IFR_ORDERED_LIST) + OptionCount * sizeof (EFI_IFR_ONE_OF_OPTION) + sizeof (EFI_IFR_END);
|
||||
if (Data->Offset + Length > Data->BufferSize) {
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
OrderedList.Header.OpCode = EFI_IFR_ORDERED_LIST_OP;
|
||||
OrderedList.Header.Length = sizeof (EFI_IFR_ORDERED_LIST);
|
||||
OrderedList.Header.Scope = 1;
|
||||
OrderedList.Question.Header.Prompt = Prompt;
|
||||
OrderedList.Question.Header.Help = Help;
|
||||
OrderedList.Question.QuestionId = QuestionId;
|
||||
OrderedList.Question.VarStoreId = VarStoreId;
|
||||
OrderedList.Question.VarStoreInfo.VarOffset = VarOffset;
|
||||
OrderedList.Question.Flags = QuestionFlags;
|
||||
OrderedList.MaxContainers = MaxContainers;
|
||||
OrderedList.Flags = OrderedListFlags;
|
||||
|
||||
LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
|
||||
CopyMem (LocalBuffer, &OrderedList, sizeof (EFI_IFR_ORDERED_LIST));
|
||||
Data->Offset += sizeof (EFI_IFR_ORDERED_LIST);
|
||||
|
||||
CreateOneOfOptionOpCode (OptionCount, OptionsList, DataType, Data);
|
||||
|
||||
CreateEndOpCode (Data);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
CreateCheckBoxOpCode (
|
||||
IN EFI_QUESTION_ID QuestionId,
|
||||
IN EFI_VARSTORE_ID VarStoreId,
|
||||
IN UINT16 VarOffset,
|
||||
IN EFI_STRING_ID Prompt,
|
||||
IN EFI_STRING_ID Help,
|
||||
IN UINT8 QuestionFlags,
|
||||
IN UINT8 CheckBoxFlags,
|
||||
IN OUT EFI_HII_UPDATE_DATA *Data
|
||||
)
|
||||
{
|
||||
EFI_IFR_CHECKBOX CheckBox;
|
||||
UINT8 *LocalBuffer;
|
||||
|
||||
ASSERT (Data != NULL && Data->Data != NULL);
|
||||
|
||||
if (!IsValidQuestionFlags (QuestionFlags) || !IsValidCheckboxFlags (CheckBoxFlags)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (Data->Offset + sizeof (EFI_IFR_CHECKBOX) > Data->BufferSize) {
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
CheckBox.Header.OpCode = EFI_IFR_CHECKBOX_OP;
|
||||
CheckBox.Header.Length = sizeof (EFI_IFR_CHECKBOX);
|
||||
CheckBox.Header.Scope = 0;
|
||||
CheckBox.Question.QuestionId = QuestionId;
|
||||
CheckBox.Question.VarStoreId = VarStoreId;
|
||||
CheckBox.Question.VarStoreInfo.VarOffset = VarOffset;
|
||||
CheckBox.Question.Header.Prompt = Prompt;
|
||||
CheckBox.Question.Header.Help = Help;
|
||||
CheckBox.Question.Flags = QuestionFlags;
|
||||
CheckBox.Flags = CheckBoxFlags;
|
||||
|
||||
LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
|
||||
CopyMem (LocalBuffer, &CheckBox, sizeof (EFI_IFR_CHECKBOX));
|
||||
Data->Offset += sizeof (EFI_IFR_CHECKBOX);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
CreateNumericOpCode (
|
||||
IN EFI_QUESTION_ID QuestionId,
|
||||
IN EFI_VARSTORE_ID VarStoreId,
|
||||
IN UINT16 VarOffset,
|
||||
IN EFI_STRING_ID Prompt,
|
||||
IN EFI_STRING_ID Help,
|
||||
IN UINT8 QuestionFlags,
|
||||
IN UINT8 NumericFlags,
|
||||
IN UINT64 Minimum,
|
||||
IN UINT64 Maximum,
|
||||
IN UINT64 Step,
|
||||
IN UINT64 Default,
|
||||
IN OUT EFI_HII_UPDATE_DATA *Data
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_IFR_NUMERIC Numeric;
|
||||
MINMAXSTEP_DATA MinMaxStep;
|
||||
EFI_IFR_TYPE_VALUE DefaultValue;
|
||||
UINT8 *LocalBuffer;
|
||||
|
||||
ASSERT (Data != NULL && Data->Data != NULL);
|
||||
|
||||
if (!IsValidQuestionFlags (QuestionFlags) || !IsValidNumricFlags (NumericFlags)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (Data->Offset + sizeof (EFI_IFR_CHECKBOX) > Data->BufferSize) {
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Numeric.Header.OpCode = EFI_IFR_NUMERIC_OP;
|
||||
Numeric.Header.Length = sizeof (EFI_IFR_NUMERIC);
|
||||
Numeric.Header.Scope = 1;
|
||||
Numeric.Question.QuestionId = QuestionId;
|
||||
Numeric.Question.VarStoreId = VarStoreId;
|
||||
Numeric.Question.VarStoreInfo.VarOffset = VarOffset;
|
||||
Numeric.Question.Header.Prompt = Prompt;
|
||||
Numeric.Question.Header.Help = Help;
|
||||
Numeric.Question.Flags = QuestionFlags;
|
||||
Numeric.Flags = NumericFlags;
|
||||
|
||||
switch (NumericFlags & EFI_IFR_NUMERIC_SIZE) {
|
||||
case EFI_IFR_NUMERIC_SIZE_1:
|
||||
MinMaxStep.u8.MinValue = (UINT8) Minimum;
|
||||
MinMaxStep.u8.MaxValue = (UINT8) Maximum;
|
||||
MinMaxStep.u8.Step = (UINT8) Step;
|
||||
break;
|
||||
|
||||
case EFI_IFR_NUMERIC_SIZE_2:
|
||||
MinMaxStep.u16.MinValue = (UINT16) Minimum;
|
||||
MinMaxStep.u16.MaxValue = (UINT16) Maximum;
|
||||
MinMaxStep.u16.Step = (UINT16) Step;
|
||||
break;
|
||||
|
||||
case EFI_IFR_NUMERIC_SIZE_4:
|
||||
MinMaxStep.u32.MinValue = (UINT32) Minimum;
|
||||
MinMaxStep.u32.MaxValue = (UINT32) Maximum;
|
||||
MinMaxStep.u32.Step = (UINT32) Step;
|
||||
break;
|
||||
|
||||
case EFI_IFR_NUMERIC_SIZE_8:
|
||||
MinMaxStep.u64.MinValue = Minimum;
|
||||
MinMaxStep.u64.MaxValue = Maximum;
|
||||
MinMaxStep.u64.Step = Step;
|
||||
break;
|
||||
}
|
||||
|
||||
CopyMem (&Numeric.data, &MinMaxStep, sizeof (MINMAXSTEP_DATA));
|
||||
|
||||
LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
|
||||
CopyMem (LocalBuffer, &Numeric, sizeof (EFI_IFR_NUMERIC));
|
||||
Data->Offset += sizeof (EFI_IFR_NUMERIC);
|
||||
|
||||
DefaultValue.u64 = Default;
|
||||
Status = CreateDefaultOpCode (&DefaultValue, (UINT8) (NumericFlags & EFI_IFR_NUMERIC_SIZE), Data);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
CreateEndOpCode (Data);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
CreateStringOpCode (
|
||||
IN EFI_QUESTION_ID QuestionId,
|
||||
IN EFI_VARSTORE_ID VarStoreId,
|
||||
IN UINT16 VarOffset,
|
||||
IN EFI_STRING_ID Prompt,
|
||||
IN EFI_STRING_ID Help,
|
||||
IN UINT8 QuestionFlags,
|
||||
IN UINT8 StringFlags,
|
||||
IN UINT8 MinSize,
|
||||
IN UINT8 MaxSize,
|
||||
IN OUT EFI_HII_UPDATE_DATA *Data
|
||||
)
|
||||
{
|
||||
EFI_IFR_STRING String;
|
||||
UINT8 *LocalBuffer;
|
||||
|
||||
ASSERT (Data != NULL && Data->Data != NULL);
|
||||
|
||||
if (!IsValidQuestionFlags (QuestionFlags) || (StringFlags & (~EFI_IFR_STRING_MULTI_LINE))) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (Data->Offset + sizeof (EFI_IFR_STRING) > Data->BufferSize) {
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
String.Header.OpCode = EFI_IFR_STRING_OP;
|
||||
String.Header.Length = sizeof (EFI_IFR_STRING);
|
||||
String.Header.Scope = 0;
|
||||
String.Question.Header.Prompt = Prompt;
|
||||
String.Question.Header.Help = Help;
|
||||
String.Question.QuestionId = QuestionId;
|
||||
String.Question.VarStoreId = VarStoreId;
|
||||
String.Question.VarStoreInfo.VarOffset = VarOffset;
|
||||
String.Question.Flags = QuestionFlags;
|
||||
String.MinSize = MinSize;
|
||||
String.MaxSize = MaxSize;
|
||||
String.Flags = StringFlags;
|
||||
|
||||
LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
|
||||
CopyMem (LocalBuffer, &String, sizeof (EFI_IFR_STRING));
|
||||
Data->Offset += sizeof (EFI_IFR_STRING);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
CreateBannerOpCode (
|
||||
IN EFI_STRING_ID Title,
|
||||
IN UINT16 LineNumber,
|
||||
IN UINT8 Alignment,
|
||||
IN OUT EFI_HII_UPDATE_DATA *Data
|
||||
)
|
||||
{
|
||||
EFI_IFR_GUID_BANNER Banner;
|
||||
UINT8 *LocalBuffer;
|
||||
|
||||
ASSERT (Data != NULL && Data->Data != NULL);
|
||||
|
||||
if (Data->Offset + sizeof (EFI_IFR_GUID_BANNER) > Data->BufferSize) {
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
Banner.Header.OpCode = EFI_IFR_GUID_OP;
|
||||
Banner.Header.Length = sizeof (EFI_IFR_GUID_BANNER);
|
||||
Banner.Header.Scope = 0;
|
||||
CopyMem (&Banner.Guid, &mIfrVendorGuid, sizeof (EFI_IFR_GUID));
|
||||
Banner.ExtendOpCode = EFI_IFR_EXTEND_OP_BANNER;
|
||||
Banner.Title = Title;
|
||||
Banner.LineNumber = LineNumber;
|
||||
Banner.Alignment = Alignment;
|
||||
|
||||
LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
|
||||
CopyMem (LocalBuffer, &Banner, sizeof (EFI_IFR_GUID_BANNER));
|
||||
Data->Offset += sizeof (EFI_IFR_GUID_BANNER);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
681
MdeModulePkg/Library/IfrSupportLib/UefiIfrString.c
Normal file
681
MdeModulePkg/Library/IfrSupportLib/UefiIfrString.c
Normal file
@@ -0,0 +1,681 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2007, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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.
|
||||
|
||||
Module Name:
|
||||
|
||||
UefiIfrString.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Common Library Routines to assist to handle String and Language.
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#include "UefiIfrLibraryInternal.h"
|
||||
|
||||
//
|
||||
// Lookup table of ISO639-2 3 character language codes to ISO 639-1 2 character language codes
|
||||
// Each entry is 5 CHAR8 values long. The first 3 CHAR8 values are the ISO 639-2 code.
|
||||
// The last 2 CHAR8 values are the ISO 639-1 code.
|
||||
//
|
||||
CHAR8 Iso639ToRfc3066ConversionTable[] =
|
||||
"\
|
||||
aaraa\
|
||||
abkab\
|
||||
afraf\
|
||||
amham\
|
||||
araar\
|
||||
asmas\
|
||||
aymay\
|
||||
azeaz\
|
||||
bakba\
|
||||
belbe\
|
||||
benbn\
|
||||
bihbh\
|
||||
bisbi\
|
||||
bodbo\
|
||||
brebr\
|
||||
bulbg\
|
||||
catca\
|
||||
cescs\
|
||||
corkw\
|
||||
cosco\
|
||||
cymcy\
|
||||
danda\
|
||||
deude\
|
||||
dzodz\
|
||||
ellel\
|
||||
engen\
|
||||
epoeo\
|
||||
estet\
|
||||
euseu\
|
||||
faofo\
|
||||
fasfa\
|
||||
fijfj\
|
||||
finfi\
|
||||
frafr\
|
||||
fryfy\
|
||||
gaiga\
|
||||
gdhgd\
|
||||
glggl\
|
||||
grngn\
|
||||
gujgu\
|
||||
hauha\
|
||||
hebhe\
|
||||
hinhi\
|
||||
hrvhr\
|
||||
hunhu\
|
||||
hyehy\
|
||||
ikuiu\
|
||||
ileie\
|
||||
inaia\
|
||||
indid\
|
||||
ipkik\
|
||||
islis\
|
||||
itait\
|
||||
jawjw\
|
||||
jpnja\
|
||||
kalkl\
|
||||
kankn\
|
||||
kasks\
|
||||
katka\
|
||||
kazkk\
|
||||
khmkm\
|
||||
kinrw\
|
||||
kirky\
|
||||
korko\
|
||||
kurku\
|
||||
laolo\
|
||||
latla\
|
||||
lavlv\
|
||||
linln\
|
||||
litlt\
|
||||
ltzlb\
|
||||
malml\
|
||||
marmr\
|
||||
mkdmk\
|
||||
mlgmg\
|
||||
mltmt\
|
||||
molmo\
|
||||
monmn\
|
||||
mrimi\
|
||||
msams\
|
||||
myamy\
|
||||
nauna\
|
||||
nepne\
|
||||
nldnl\
|
||||
norno\
|
||||
ocioc\
|
||||
ormom\
|
||||
panpa\
|
||||
polpl\
|
||||
porpt\
|
||||
pusps\
|
||||
quequ\
|
||||
rohrm\
|
||||
ronro\
|
||||
runrn\
|
||||
rusru\
|
||||
sagsg\
|
||||
sansa\
|
||||
sinsi\
|
||||
slksk\
|
||||
slvsl\
|
||||
smise\
|
||||
smosm\
|
||||
snasn\
|
||||
sndsd\
|
||||
somso\
|
||||
sotst\
|
||||
spaes\
|
||||
sqisq\
|
||||
srpsr\
|
||||
sswss\
|
||||
sunsu\
|
||||
swasw\
|
||||
swesv\
|
||||
tamta\
|
||||
tattt\
|
||||
telte\
|
||||
tgktg\
|
||||
tgltl\
|
||||
thath\
|
||||
tsnts\
|
||||
tuktk\
|
||||
twitw\
|
||||
uigug\
|
||||
ukruk\
|
||||
urdur\
|
||||
uzbuz\
|
||||
vievi\
|
||||
volvo\
|
||||
wolwo\
|
||||
xhoxh\
|
||||
yidyi\
|
||||
zhaza\
|
||||
zhozh\
|
||||
zulzu\
|
||||
";
|
||||
|
||||
|
||||
/**
|
||||
Convert language code from RFC3066 to ISO639-2.
|
||||
|
||||
@param LanguageRfc3066 RFC3066 language code.
|
||||
@param LanguageIso639 ISO639-2 language code.
|
||||
|
||||
@retval EFI_SUCCESS Language code converted.
|
||||
@retval EFI_NOT_FOUND Language code not found.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
ConvertRfc3066LanguageToIso639Language (
|
||||
CHAR8 *LanguageRfc3066,
|
||||
CHAR8 *LanguageIso639
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
|
||||
if ((LanguageRfc3066[2] != '-') && (LanguageRfc3066[2] != 0)) {
|
||||
CopyMem (LanguageIso639, LanguageRfc3066, 3);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
for (Index = 0; Iso639ToRfc3066ConversionTable[Index] != 0; Index += 5) {
|
||||
if (CompareMem (LanguageRfc3066, &Iso639ToRfc3066ConversionTable[Index + 3], 2) == 0) {
|
||||
CopyMem (LanguageIso639, &Iso639ToRfc3066ConversionTable[Index], 3);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Convert language code list from RFC3066 to ISO639-2, e.g. "en-US;fr-FR" will
|
||||
be converted to "engfra".
|
||||
|
||||
@param SupportedLanguages The RFC3066 language list.
|
||||
|
||||
@return The ISO639-2 language list.
|
||||
|
||||
**/
|
||||
CHAR8 *
|
||||
Rfc3066ToIso639 (
|
||||
CHAR8 *SupportedLanguages
|
||||
)
|
||||
{
|
||||
CHAR8 *Languages;
|
||||
CHAR8 *ReturnValue;
|
||||
CHAR8 *LangCodes;
|
||||
CHAR8 LangRfc3066[RFC_3066_ENTRY_SIZE];
|
||||
CHAR8 LangIso639[ISO_639_2_ENTRY_SIZE];
|
||||
EFI_STATUS Status;
|
||||
|
||||
ReturnValue = AllocateZeroPool (AsciiStrSize (SupportedLanguages));
|
||||
if (ReturnValue == NULL) {
|
||||
return ReturnValue;
|
||||
}
|
||||
|
||||
Languages = ReturnValue;
|
||||
LangCodes = SupportedLanguages;
|
||||
while (*LangCodes != 0) {
|
||||
GetNextLanguage (&LangCodes, LangRfc3066);
|
||||
|
||||
Status = ConvertRfc3066LanguageToIso639Language (LangRfc3066, LangIso639);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
CopyMem (Languages, LangIso639, 3);
|
||||
Languages = Languages + 3;
|
||||
}
|
||||
}
|
||||
|
||||
return ReturnValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Determine what is the current language setting
|
||||
|
||||
@param Lang Pointer of system language
|
||||
|
||||
@return Status code
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
GetCurrentLanguage (
|
||||
OUT CHAR8 *Lang
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN Size;
|
||||
|
||||
//
|
||||
// Get current language setting
|
||||
//
|
||||
Size = RFC_3066_ENTRY_SIZE;
|
||||
Status = gRT->GetVariable (
|
||||
L"PlatformLang",
|
||||
&gEfiGlobalVariableGuid,
|
||||
NULL,
|
||||
&Size,
|
||||
Lang
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
AsciiStrCpy (Lang, (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLang));
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Get next language from language code list (with separator ';').
|
||||
|
||||
@param LangCode On input: point to first language in the list. On
|
||||
output: point to next language in the list, or
|
||||
NULL if no more language in the list.
|
||||
@param Lang The first language in the list.
|
||||
|
||||
@return None.
|
||||
|
||||
**/
|
||||
VOID
|
||||
GetNextLanguage (
|
||||
IN OUT CHAR8 **LangCode,
|
||||
OUT CHAR8 *Lang
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
CHAR8 *StringPtr;
|
||||
|
||||
if (LangCode == NULL || *LangCode == NULL) {
|
||||
*Lang = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
Index = 0;
|
||||
StringPtr = *LangCode;
|
||||
while (StringPtr[Index] != 0 && StringPtr[Index] != ';') {
|
||||
Index++;
|
||||
}
|
||||
|
||||
CopyMem (Lang, StringPtr, Index);
|
||||
Lang[Index] = 0;
|
||||
|
||||
if (StringPtr[Index] == ';') {
|
||||
Index++;
|
||||
}
|
||||
*LangCode = StringPtr + Index;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function returns the list of supported languages, in the format specified
|
||||
in UEFI specification Appendix<69>M.
|
||||
|
||||
@param HiiHandle The HII package list handle.
|
||||
|
||||
@return The supported languages.
|
||||
|
||||
**/
|
||||
CHAR8 *
|
||||
GetSupportedLanguages (
|
||||
IN EFI_HII_HANDLE HiiHandle
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN BufferSize;
|
||||
CHAR8 *LanguageString;
|
||||
|
||||
LocateHiiProtocols ();
|
||||
|
||||
//
|
||||
// Collect current supported Languages for given HII handle
|
||||
//
|
||||
BufferSize = 0x1000;
|
||||
LanguageString = AllocatePool (BufferSize);
|
||||
Status = gIfrLibHiiString->GetLanguages (gIfrLibHiiString, HiiHandle, LanguageString, &BufferSize);
|
||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
gBS->FreePool (LanguageString);
|
||||
LanguageString = AllocatePool (BufferSize);
|
||||
Status = gIfrLibHiiString->GetLanguages (gIfrLibHiiString, HiiHandle, LanguageString, &BufferSize);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
LanguageString = NULL;
|
||||
}
|
||||
|
||||
return LanguageString;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function returns the number of supported languages
|
||||
|
||||
@param HiiHandle The HII package list handle.
|
||||
|
||||
@return The number of supported languages.
|
||||
|
||||
**/
|
||||
UINT16
|
||||
GetSupportedLanguageNumber (
|
||||
IN EFI_HII_HANDLE HiiHandle
|
||||
)
|
||||
{
|
||||
CHAR8 *Languages;
|
||||
CHAR8 *LanguageString;
|
||||
UINT16 LangNumber;
|
||||
CHAR8 Lang[RFC_3066_ENTRY_SIZE];
|
||||
|
||||
Languages = GetSupportedLanguages (HiiHandle);
|
||||
if (Languages == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
LangNumber = 0;
|
||||
LanguageString = Languages;
|
||||
while (*LanguageString != 0) {
|
||||
GetNextLanguage (&LanguageString, Lang);
|
||||
LangNumber++;
|
||||
}
|
||||
gBS->FreePool (Languages);
|
||||
|
||||
return LangNumber;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Get string specified by StringId form the HiiHandle.
|
||||
|
||||
@param HiiHandle The HII handle of package list.
|
||||
@param StringId The String ID.
|
||||
@param String The output string.
|
||||
|
||||
@retval EFI_NOT_FOUND String is not found.
|
||||
@retval EFI_SUCCESS Operation is successful.
|
||||
@retval EFI_OUT_OF_RESOURCES There is not enought memory in the system.
|
||||
@retval EFI_INVALID_PARAMETER The String is NULL.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
GetStringFromHandle (
|
||||
IN EFI_HII_HANDLE HiiHandle,
|
||||
IN EFI_STRING_ID StringId,
|
||||
OUT EFI_STRING *String
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN StringSize;
|
||||
|
||||
if (String == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
StringSize = IFR_LIB_DEFAULT_STRING_SIZE;
|
||||
*String = AllocateZeroPool (StringSize);
|
||||
if (*String == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Status = IfrLibGetString (HiiHandle, StringId, *String, &StringSize);
|
||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
gBS->FreePool (*String);
|
||||
*String = AllocateZeroPool (StringSize);
|
||||
if (*String == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
Status = IfrLibGetString (HiiHandle, StringId, *String, &StringSize);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Get the string given the StringId and String package Producer's Guid.
|
||||
|
||||
@param ProducerGuid The Guid of String package list.
|
||||
@param StringId The String ID.
|
||||
@param String The output string.
|
||||
|
||||
@retval EFI_NOT_FOUND String is not found.
|
||||
@retval EFI_SUCCESS Operation is successful.
|
||||
@retval EFI_OUT_OF_RESOURCES There is not enought memory in the system.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
GetStringFromToken (
|
||||
IN EFI_GUID *ProducerGuid,
|
||||
IN EFI_STRING_ID StringId,
|
||||
OUT EFI_STRING *String
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN Index;
|
||||
UINTN HandleBufferLen;
|
||||
EFI_HII_HANDLE *HiiHandleBuffer;
|
||||
EFI_GUID Guid;
|
||||
|
||||
Status = GetHiiHandles (&HandleBufferLen, &HiiHandleBuffer);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return Status;
|
||||
}
|
||||
for (Index = 0; Index < (HandleBufferLen / sizeof (EFI_HII_HANDLE)); Index++) {
|
||||
Status = ExtractGuidFromHiiHandle (HiiHandleBuffer[Index], &Guid);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return Status;
|
||||
}
|
||||
if (CompareGuid (&Guid, ProducerGuid) == TRUE) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Index >= (HandleBufferLen / sizeof (EFI_HII_HANDLE))) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
goto Out;
|
||||
}
|
||||
|
||||
Status = GetStringFromHandle (HiiHandleBuffer[Index], StringId, String);
|
||||
|
||||
Out:
|
||||
if (HiiHandleBuffer != NULL) {
|
||||
gBS->FreePool (HiiHandleBuffer);
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function adds the string into String Package of each language.
|
||||
|
||||
@param PackageList Handle of the package list where this string will
|
||||
be added.
|
||||
@param StringId On return, contains the new strings id, which is
|
||||
unique within PackageList.
|
||||
@param String Points to the new null-terminated string.
|
||||
|
||||
@retval EFI_SUCCESS The new string was added successfully.
|
||||
@retval EFI_NOT_FOUND The specified PackageList could not be found in
|
||||
database.
|
||||
@retval EFI_OUT_OF_RESOURCES Could not add the string due to lack of resources.
|
||||
@retval EFI_INVALID_PARAMETER String is NULL or StringId is NULL is NULL.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
IfrLibNewString (
|
||||
IN EFI_HII_HANDLE PackageList,
|
||||
OUT EFI_STRING_ID *StringId,
|
||||
IN CONST EFI_STRING String
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
CHAR8 *Languages;
|
||||
CHAR8 *LangStrings;
|
||||
CHAR8 Lang[RFC_3066_ENTRY_SIZE];
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
LocateHiiProtocols ();
|
||||
|
||||
Languages = GetSupportedLanguages (PackageList);
|
||||
|
||||
LangStrings = Languages;
|
||||
while (*LangStrings != 0) {
|
||||
GetNextLanguage (&LangStrings, Lang);
|
||||
|
||||
Status = gIfrLibHiiString->NewString (
|
||||
gIfrLibHiiString,
|
||||
PackageList,
|
||||
StringId,
|
||||
Lang,
|
||||
NULL,
|
||||
String,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
gBS->FreePool (Languages);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function try to retrieve string from String package of current language.
|
||||
If fail, it try to retrieve string from String package of first language it support.
|
||||
|
||||
@param PackageList The package list in the HII database to search for
|
||||
the specified string.
|
||||
@param StringId The string's id, which is unique within
|
||||
PackageList.
|
||||
@param String Points to the new null-terminated string.
|
||||
@param StringSize On entry, points to the size of the buffer pointed
|
||||
to by String, in bytes. On return, points to the
|
||||
length of the string, in bytes.
|
||||
|
||||
@retval EFI_SUCCESS The string was returned successfully.
|
||||
@retval EFI_NOT_FOUND The string specified by StringId is not available.
|
||||
@retval EFI_BUFFER_TOO_SMALL The buffer specified by StringLength is too small
|
||||
to hold the string.
|
||||
@retval EFI_INVALID_PARAMETER The String or StringSize was NULL.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
IfrLibGetString (
|
||||
IN EFI_HII_HANDLE PackageList,
|
||||
IN EFI_STRING_ID StringId,
|
||||
OUT EFI_STRING String,
|
||||
IN OUT UINTN *StringSize
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
CHAR8 *Languages;
|
||||
CHAR8 *LangStrings;
|
||||
CHAR8 Lang[RFC_3066_ENTRY_SIZE];
|
||||
CHAR8 CurrentLang[RFC_3066_ENTRY_SIZE];
|
||||
|
||||
LocateHiiProtocols ();
|
||||
|
||||
GetCurrentLanguage (CurrentLang);
|
||||
|
||||
Status = gIfrLibHiiString->GetString (
|
||||
gIfrLibHiiString,
|
||||
CurrentLang,
|
||||
PackageList,
|
||||
StringId,
|
||||
String,
|
||||
StringSize,
|
||||
NULL
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
|
||||
Languages = GetSupportedLanguages (PackageList);
|
||||
LangStrings = Languages;
|
||||
GetNextLanguage (&LangStrings, Lang);
|
||||
gBS->FreePool (Languages);
|
||||
|
||||
Status = gIfrLibHiiString->GetString (
|
||||
gIfrLibHiiString,
|
||||
Lang,
|
||||
PackageList,
|
||||
StringId,
|
||||
String,
|
||||
StringSize,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function updates the string in String package of each language.
|
||||
|
||||
@param PackageList The package list containing the strings.
|
||||
@param StringId The string's id, which is unique within
|
||||
PackageList.
|
||||
@param String Points to the new null-terminated string.
|
||||
|
||||
@retval EFI_SUCCESS The string was updated successfully.
|
||||
@retval EFI_NOT_FOUND The string specified by StringId is not in the
|
||||
database.
|
||||
@retval EFI_INVALID_PARAMETER The String was NULL.
|
||||
@retval EFI_OUT_OF_RESOURCES The system is out of resources to accomplish the
|
||||
task.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
IfrLibSetString (
|
||||
IN EFI_HII_HANDLE PackageList,
|
||||
IN EFI_STRING_ID StringId,
|
||||
IN CONST EFI_STRING String
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
CHAR8 *Languages;
|
||||
CHAR8 *LangStrings;
|
||||
CHAR8 Lang[RFC_3066_ENTRY_SIZE];
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
LocateHiiProtocols ();
|
||||
|
||||
Languages = GetSupportedLanguages (PackageList);
|
||||
|
||||
LangStrings = Languages;
|
||||
while (*LangStrings != 0) {
|
||||
GetNextLanguage (&LangStrings, Lang);
|
||||
|
||||
Status = gIfrLibHiiString->SetString (
|
||||
gIfrLibHiiString,
|
||||
PackageList,
|
||||
StringId,
|
||||
Lang,
|
||||
String,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
gBS->FreePool (Languages);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
276
MdeModulePkg/Library/PlatformBdsLibNull/BdsPlatform.c
Normal file
276
MdeModulePkg/Library/PlatformBdsLibNull/BdsPlatform.c
Normal file
@@ -0,0 +1,276 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2006, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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.
|
||||
|
||||
Module Name:
|
||||
|
||||
BdsPlatform.c
|
||||
|
||||
Abstract:
|
||||
|
||||
This file include all platform action which can be customized
|
||||
by IBV/OEM.
|
||||
|
||||
--*/
|
||||
|
||||
#include "BdsPlatform.h"
|
||||
|
||||
//
|
||||
// BDS Platform Functions
|
||||
//
|
||||
VOID
|
||||
PlatformBdsInit (
|
||||
IN EFI_BDS_ARCH_PROTOCOL_INSTANCE *PrivateData
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Platform Bds init. Incude the platform firmware vendor, revision
|
||||
and so crc check.
|
||||
|
||||
Arguments:
|
||||
|
||||
PrivateData - The EFI_BDS_ARCH_PROTOCOL_INSTANCE instance
|
||||
|
||||
Returns:
|
||||
|
||||
None.
|
||||
|
||||
--*/
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
PlatformBdsConnectConsole (
|
||||
IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Connect the predefined platform default console device. Always try to find
|
||||
and enable the vga device if have.
|
||||
|
||||
Arguments:
|
||||
|
||||
PlatformConsole - Predfined platform default console device array.
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - Success connect at least one ConIn and ConOut
|
||||
device, there must have one ConOut device is
|
||||
active vga device.
|
||||
|
||||
EFI_STATUS - Return the status of
|
||||
BdsLibConnectAllDefaultConsoles ()
|
||||
|
||||
--*/
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
VOID
|
||||
PlatformBdsConnectSequence (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Connect with predeined platform connect sequence,
|
||||
the OEM/IBV can customize with their own connect sequence.
|
||||
|
||||
Arguments:
|
||||
|
||||
None.
|
||||
|
||||
Returns:
|
||||
|
||||
None.
|
||||
|
||||
--*/
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
VOID
|
||||
PlatformBdsGetDriverOption (
|
||||
IN OUT LIST_ENTRY *BdsDriverLists
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Load the predefined driver option, OEM/IBV can customize this
|
||||
to load their own drivers
|
||||
|
||||
Arguments:
|
||||
|
||||
BdsDriverLists - The header of the driver option link list.
|
||||
|
||||
Returns:
|
||||
|
||||
None.
|
||||
|
||||
--*/
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
VOID
|
||||
PlatformBdsDiagnostics (
|
||||
IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,
|
||||
IN BOOLEAN QuietBoot
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Perform the platform diagnostic, such like test memory. OEM/IBV also
|
||||
can customize this fuction to support specific platform diagnostic.
|
||||
|
||||
Arguments:
|
||||
|
||||
MemoryTestLevel - The memory test intensive level
|
||||
|
||||
QuietBoot - Indicate if need to enable the quiet boot
|
||||
|
||||
Returns:
|
||||
|
||||
None.
|
||||
|
||||
--*/
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
VOID
|
||||
PlatformBdsPolicyBehavior (
|
||||
IN EFI_BDS_ARCH_PROTOCOL_INSTANCE *PrivateData,
|
||||
IN OUT LIST_ENTRY *DriverOptionList,
|
||||
IN OUT LIST_ENTRY *BootOptionList
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
The function will excute with as the platform policy, current policy
|
||||
is driven by boot mode. IBV/OEM can customize this code for their specific
|
||||
policy action.
|
||||
|
||||
Arguments:
|
||||
|
||||
PrivateData - The EFI_BDS_ARCH_PROTOCOL_INSTANCE instance
|
||||
|
||||
DriverOptionList - The header of the driver option link list
|
||||
|
||||
BootOptionList - The header of the boot option link list
|
||||
|
||||
Returns:
|
||||
|
||||
None.
|
||||
|
||||
--*/
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
VOID
|
||||
PlatformBdsBootSuccess (
|
||||
IN BDS_COMMON_OPTION *Option
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Hook point after a boot attempt succeeds. We don't expect a boot option to
|
||||
return, so the EFI 1.0 specification defines that you will default to an
|
||||
interactive mode and stop processing the BootOrder list in this case. This
|
||||
is alos a platform implementation and can be customized by IBV/OEM.
|
||||
|
||||
Arguments:
|
||||
|
||||
Option - Pointer to Boot Option that succeeded to boot.
|
||||
|
||||
Returns:
|
||||
|
||||
None.
|
||||
|
||||
--*/
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
VOID
|
||||
PlatformBdsBootFail (
|
||||
IN BDS_COMMON_OPTION *Option,
|
||||
IN EFI_STATUS Status,
|
||||
IN CHAR16 *ExitData,
|
||||
IN UINTN ExitDataSize
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Hook point after a boot attempt fails.
|
||||
|
||||
Arguments:
|
||||
|
||||
Option - Pointer to Boot Option that failed to boot.
|
||||
|
||||
Status - Status returned from failed boot.
|
||||
|
||||
ExitData - Exit data returned from failed boot.
|
||||
|
||||
ExitDataSize - Exit data size returned from failed boot.
|
||||
|
||||
Returns:
|
||||
|
||||
None.
|
||||
|
||||
--*/
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
PlatformBdsNoConsoleAction (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
This function is remained for IBV/OEM to do some platform action,
|
||||
if there no console device can be connected.
|
||||
|
||||
Arguments:
|
||||
|
||||
None.
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - Direct return success now.
|
||||
|
||||
--*/
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PlatformBdsLockNonUpdatableFlash (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
37
MdeModulePkg/Library/PlatformBdsLibNull/BdsPlatform.h
Normal file
37
MdeModulePkg/Library/PlatformBdsLibNull/BdsPlatform.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2006, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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.
|
||||
|
||||
Module Name:
|
||||
|
||||
BdsPlatform.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Head file for BDS Platform specific code
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _BDS_PLATFORM_H
|
||||
#define _BDS_PLATFORM_H
|
||||
|
||||
#include <PiDxe.h>
|
||||
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/GenericBdsLib.h>
|
||||
#include <Library/PlatformBdsLib.h>
|
||||
#include <Library/GraphicsLib.h>
|
||||
|
||||
#endif // _BDS_PLATFORM_H
|
@@ -0,0 +1,55 @@
|
||||
#/** @file
|
||||
# Component name for module GenericBdsLib
|
||||
#
|
||||
# FIX ME!
|
||||
# Copyright (c) 2007, Intel Corporation. All rights reserved.
|
||||
#
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
#**/
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = PlatformBdsLib
|
||||
FILE_GUID = 143B5044-7C1B-4904-9778-EA16F1F3D554
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = PlatformBdsLib|DXE_DRIVER
|
||||
EDK_RELEASE_VERSION = 0x00020000
|
||||
EFI_SPECIFICATION_VERSION = 0x0002000A
|
||||
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
#
|
||||
|
||||
[Sources.common]
|
||||
BdsPlatform.c
|
||||
PlatformData.c
|
||||
BdsPlatform.h
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
BaseLib
|
||||
MemoryAllocationLib
|
||||
UefiBootServicesTableLib
|
||||
BaseMemoryLib
|
||||
DebugLib
|
||||
PcdLib
|
||||
GraphicsLib
|
||||
GenericBdsLib
|
||||
|
||||
[Guids]
|
||||
gEfiDefaultBmpLogoGuid
|
52
MdeModulePkg/Library/PlatformBdsLibNull/PlatformData.c
Normal file
52
MdeModulePkg/Library/PlatformBdsLibNull/PlatformData.c
Normal file
@@ -0,0 +1,52 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2006, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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.
|
||||
|
||||
Module Name:
|
||||
|
||||
PlatformData.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Defined the platform specific device path which will be used by
|
||||
platform Bbd to perform the platform policy connect.
|
||||
|
||||
--*/
|
||||
|
||||
#include "BdsPlatform.h"
|
||||
|
||||
//
|
||||
// Predefined platform default time out value
|
||||
//
|
||||
UINT16 gPlatformBootTimeOutDefault = 10;
|
||||
|
||||
//
|
||||
// Platform specific keyboard device path
|
||||
//
|
||||
|
||||
//
|
||||
// Predefined platform default console device path
|
||||
//
|
||||
BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = {
|
||||
{
|
||||
NULL,
|
||||
0
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Predefined platform specific driver option
|
||||
//
|
||||
EFI_DEVICE_PATH_PROTOCOL *gPlatformDriverOption[] = { NULL };
|
||||
|
||||
//
|
||||
// Predefined platform connect sequence
|
||||
//
|
||||
EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[] = { NULL };
|
Reference in New Issue
Block a user