mirror of
https://github.com/acidanthera/audk.git
synced 2025-04-08 17:05:09 +02:00
MdeModulePkg: Fix EOL to be DOS format.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17421 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
30cfc3d0ee
commit
067ed98a73
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
||||
## @file
|
||||
# Library used for sorting routines.
|
||||
#
|
||||
# Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved. <BR>
|
||||
# Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved. <BR>
|
||||
#
|
||||
# This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
@ -19,7 +19,7 @@
|
||||
FILE_GUID = 03F3331B-F12D-494f-BF37-E55A657F2497
|
||||
MODULE_TYPE = UEFI_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = SortLib|DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER
|
||||
LIBRARY_CLASS = SortLib|DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER
|
||||
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
@ -37,5 +37,3 @@
|
||||
BaseLib
|
||||
BaseMemoryLib
|
||||
DebugLib
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,321 +1,321 @@
|
||||
/** @file
|
||||
Library functions which relate with connecting the device.
|
||||
|
||||
Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||
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 "InternalBm.h"
|
||||
|
||||
/**
|
||||
Connect all the drivers to all the controllers.
|
||||
|
||||
This function makes sure all the current system drivers manage the correspoinding
|
||||
controllers if have. And at the same time, makes sure all the system controllers
|
||||
have driver to manage it if have.
|
||||
**/
|
||||
VOID
|
||||
BmConnectAllDriversToAllControllers (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN HandleCount;
|
||||
EFI_HANDLE *HandleBuffer;
|
||||
UINTN Index;
|
||||
|
||||
do {
|
||||
//
|
||||
// Connect All EFI 1.10 drivers following EFI 1.10 algorithm
|
||||
//
|
||||
gBS->LocateHandleBuffer (
|
||||
AllHandles,
|
||||
NULL,
|
||||
NULL,
|
||||
&HandleCount,
|
||||
&HandleBuffer
|
||||
);
|
||||
|
||||
for (Index = 0; Index < HandleCount; Index++) {
|
||||
gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
|
||||
}
|
||||
|
||||
if (HandleBuffer != NULL) {
|
||||
FreePool (HandleBuffer);
|
||||
}
|
||||
|
||||
//
|
||||
// Check to see if it's possible to dispatch an more DXE drivers.
|
||||
// The above code may have made new DXE drivers show up.
|
||||
// If any new driver is dispatched (Status == EFI_SUCCESS) and we will try
|
||||
// the connect again.
|
||||
//
|
||||
Status = gDS->Dispatch ();
|
||||
|
||||
} while (!EFI_ERROR (Status));
|
||||
}
|
||||
|
||||
/**
|
||||
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 available and the platform default
|
||||
console connected.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
EfiBootManagerConnectAll (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
//
|
||||
// Connect the platform console first
|
||||
//
|
||||
EfiBootManagerConnectAllDefaultConsoles ();
|
||||
|
||||
//
|
||||
// Generic way to connect all the drivers
|
||||
//
|
||||
BmConnectAllDriversToAllControllers ();
|
||||
|
||||
//
|
||||
// Here we have the assumption that we have already had
|
||||
// platform default console
|
||||
//
|
||||
EfiBootManagerConnectAllDefaultConsoles ();
|
||||
}
|
||||
|
||||
/**
|
||||
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 successfully, then still give 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
|
||||
@param MatchingHandle Return the controller handle closest to the DevicePathToConnect
|
||||
|
||||
@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.
|
||||
@retval EFI_SECURITY_VIOLATION The user has no permission to start UEFI device
|
||||
drivers on the DevicePath.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EfiBootManagerConnectDevicePath (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect,
|
||||
OUT EFI_HANDLE *MatchingHandle OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath;
|
||||
EFI_HANDLE Handle;
|
||||
EFI_HANDLE PreviousHandle;
|
||||
EFI_TPL CurrentTpl;
|
||||
|
||||
if (DevicePathToConnect == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
CurrentTpl = EfiGetCurrentTpl ();
|
||||
//
|
||||
// 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 = DevicePathToConnect;
|
||||
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
|
||||
//
|
||||
if (CurrentTpl == TPL_APPLICATION) {
|
||||
Status = gDS->Dispatch ();
|
||||
} else {
|
||||
//
|
||||
// Always return EFI_NOT_FOUND here
|
||||
// to prevent dead loop when control handle is found but connection failded case
|
||||
//
|
||||
Status = EFI_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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.
|
||||
//
|
||||
// If ConnectController fails to find a driver, 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
|
||||
//
|
||||
Status = gBS->ConnectController (Handle, NULL, RemainingDevicePath, FALSE);
|
||||
if (Status == EFI_NOT_FOUND) {
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
if (MatchingHandle != NULL) {
|
||||
*MatchingHandle = Handle;
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
// Loop until RemainingDevicePath is an empty device path
|
||||
//
|
||||
} while (!EFI_ERROR (Status) && !IsDevicePathEnd (RemainingDevicePath));
|
||||
|
||||
ASSERT (EFI_ERROR (Status) || IsDevicePathEnd (RemainingDevicePath));
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
This function will disconnect all current system handles.
|
||||
|
||||
gBS->DisconnectController() is invoked for each handle exists in system handle buffer.
|
||||
If handle is a bus type handle, all childrens also are disconnected recursively by
|
||||
gBS->DisconnectController().
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
EfiBootManagerDisconnectAll (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINTN HandleCount;
|
||||
EFI_HANDLE *HandleBuffer;
|
||||
UINTN Index;
|
||||
|
||||
//
|
||||
// Disconnect all
|
||||
//
|
||||
gBS->LocateHandleBuffer (
|
||||
AllHandles,
|
||||
NULL,
|
||||
NULL,
|
||||
&HandleCount,
|
||||
&HandleBuffer
|
||||
);
|
||||
for (Index = 0; Index < HandleCount; Index++) {
|
||||
gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);
|
||||
}
|
||||
|
||||
if (HandleBuffer != NULL) {
|
||||
FreePool (HandleBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Connect the specific Usb device which match the short form device path,
|
||||
and whose bus is determined by Host Controller (Uhci or Ehci).
|
||||
|
||||
@param DevicePath 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 DevicePath is NULL pointer.
|
||||
DevicePath is not a USB device path.
|
||||
|
||||
@return EFI_SUCCESS Success to connect USB device
|
||||
@return EFI_NOT_FOUND Fail to find handle for USB controller to connect.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
BmConnectUsbShortFormDevicePath (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE *Handles;
|
||||
UINTN HandleCount;
|
||||
UINTN Index;
|
||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
||||
UINT8 Class[3];
|
||||
BOOLEAN AtLeastOneConnected;
|
||||
|
||||
//
|
||||
// Check the passed in parameters
|
||||
//
|
||||
if (DevicePath == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ((DevicePathType (DevicePath) != MESSAGING_DEVICE_PATH) ||
|
||||
((DevicePathSubType (DevicePath) != MSG_USB_CLASS_DP) && (DevicePathSubType (DevicePath) != MSG_USB_WWID_DP))
|
||||
) {
|
||||
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,
|
||||
&HandleCount,
|
||||
&Handles
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
for (Index = 0; Index < HandleCount; Index++) {
|
||||
Status = gBS->HandleProtocol (
|
||||
Handles[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) &&
|
||||
((PCI_CLASS_SERIAL == Class[2]) && (PCI_CLASS_SERIAL_USB == Class[1]))
|
||||
) {
|
||||
Status = gBS->ConnectController (
|
||||
Handles[Index],
|
||||
NULL,
|
||||
DevicePath,
|
||||
FALSE
|
||||
);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
AtLeastOneConnected = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Handles != NULL) {
|
||||
FreePool (Handles);
|
||||
}
|
||||
}
|
||||
|
||||
return AtLeastOneConnected ? EFI_SUCCESS : EFI_NOT_FOUND;
|
||||
}
|
||||
/** @file
|
||||
Library functions which relate with connecting the device.
|
||||
|
||||
Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||
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 "InternalBm.h"
|
||||
|
||||
/**
|
||||
Connect all the drivers to all the controllers.
|
||||
|
||||
This function makes sure all the current system drivers manage the correspoinding
|
||||
controllers if have. And at the same time, makes sure all the system controllers
|
||||
have driver to manage it if have.
|
||||
**/
|
||||
VOID
|
||||
BmConnectAllDriversToAllControllers (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN HandleCount;
|
||||
EFI_HANDLE *HandleBuffer;
|
||||
UINTN Index;
|
||||
|
||||
do {
|
||||
//
|
||||
// Connect All EFI 1.10 drivers following EFI 1.10 algorithm
|
||||
//
|
||||
gBS->LocateHandleBuffer (
|
||||
AllHandles,
|
||||
NULL,
|
||||
NULL,
|
||||
&HandleCount,
|
||||
&HandleBuffer
|
||||
);
|
||||
|
||||
for (Index = 0; Index < HandleCount; Index++) {
|
||||
gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
|
||||
}
|
||||
|
||||
if (HandleBuffer != NULL) {
|
||||
FreePool (HandleBuffer);
|
||||
}
|
||||
|
||||
//
|
||||
// Check to see if it's possible to dispatch an more DXE drivers.
|
||||
// The above code may have made new DXE drivers show up.
|
||||
// If any new driver is dispatched (Status == EFI_SUCCESS) and we will try
|
||||
// the connect again.
|
||||
//
|
||||
Status = gDS->Dispatch ();
|
||||
|
||||
} while (!EFI_ERROR (Status));
|
||||
}
|
||||
|
||||
/**
|
||||
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 available and the platform default
|
||||
console connected.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
EfiBootManagerConnectAll (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
//
|
||||
// Connect the platform console first
|
||||
//
|
||||
EfiBootManagerConnectAllDefaultConsoles ();
|
||||
|
||||
//
|
||||
// Generic way to connect all the drivers
|
||||
//
|
||||
BmConnectAllDriversToAllControllers ();
|
||||
|
||||
//
|
||||
// Here we have the assumption that we have already had
|
||||
// platform default console
|
||||
//
|
||||
EfiBootManagerConnectAllDefaultConsoles ();
|
||||
}
|
||||
|
||||
/**
|
||||
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 successfully, then still give 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
|
||||
@param MatchingHandle Return the controller handle closest to the DevicePathToConnect
|
||||
|
||||
@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.
|
||||
@retval EFI_SECURITY_VIOLATION The user has no permission to start UEFI device
|
||||
drivers on the DevicePath.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EfiBootManagerConnectDevicePath (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect,
|
||||
OUT EFI_HANDLE *MatchingHandle OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath;
|
||||
EFI_HANDLE Handle;
|
||||
EFI_HANDLE PreviousHandle;
|
||||
EFI_TPL CurrentTpl;
|
||||
|
||||
if (DevicePathToConnect == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
CurrentTpl = EfiGetCurrentTpl ();
|
||||
//
|
||||
// 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 = DevicePathToConnect;
|
||||
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
|
||||
//
|
||||
if (CurrentTpl == TPL_APPLICATION) {
|
||||
Status = gDS->Dispatch ();
|
||||
} else {
|
||||
//
|
||||
// Always return EFI_NOT_FOUND here
|
||||
// to prevent dead loop when control handle is found but connection failded case
|
||||
//
|
||||
Status = EFI_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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.
|
||||
//
|
||||
// If ConnectController fails to find a driver, 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
|
||||
//
|
||||
Status = gBS->ConnectController (Handle, NULL, RemainingDevicePath, FALSE);
|
||||
if (Status == EFI_NOT_FOUND) {
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
if (MatchingHandle != NULL) {
|
||||
*MatchingHandle = Handle;
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
// Loop until RemainingDevicePath is an empty device path
|
||||
//
|
||||
} while (!EFI_ERROR (Status) && !IsDevicePathEnd (RemainingDevicePath));
|
||||
|
||||
ASSERT (EFI_ERROR (Status) || IsDevicePathEnd (RemainingDevicePath));
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
This function will disconnect all current system handles.
|
||||
|
||||
gBS->DisconnectController() is invoked for each handle exists in system handle buffer.
|
||||
If handle is a bus type handle, all childrens also are disconnected recursively by
|
||||
gBS->DisconnectController().
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
EfiBootManagerDisconnectAll (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINTN HandleCount;
|
||||
EFI_HANDLE *HandleBuffer;
|
||||
UINTN Index;
|
||||
|
||||
//
|
||||
// Disconnect all
|
||||
//
|
||||
gBS->LocateHandleBuffer (
|
||||
AllHandles,
|
||||
NULL,
|
||||
NULL,
|
||||
&HandleCount,
|
||||
&HandleBuffer
|
||||
);
|
||||
for (Index = 0; Index < HandleCount; Index++) {
|
||||
gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);
|
||||
}
|
||||
|
||||
if (HandleBuffer != NULL) {
|
||||
FreePool (HandleBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Connect the specific Usb device which match the short form device path,
|
||||
and whose bus is determined by Host Controller (Uhci or Ehci).
|
||||
|
||||
@param DevicePath 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 DevicePath is NULL pointer.
|
||||
DevicePath is not a USB device path.
|
||||
|
||||
@return EFI_SUCCESS Success to connect USB device
|
||||
@return EFI_NOT_FOUND Fail to find handle for USB controller to connect.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
BmConnectUsbShortFormDevicePath (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE *Handles;
|
||||
UINTN HandleCount;
|
||||
UINTN Index;
|
||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
||||
UINT8 Class[3];
|
||||
BOOLEAN AtLeastOneConnected;
|
||||
|
||||
//
|
||||
// Check the passed in parameters
|
||||
//
|
||||
if (DevicePath == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ((DevicePathType (DevicePath) != MESSAGING_DEVICE_PATH) ||
|
||||
((DevicePathSubType (DevicePath) != MSG_USB_CLASS_DP) && (DevicePathSubType (DevicePath) != MSG_USB_WWID_DP))
|
||||
) {
|
||||
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,
|
||||
&HandleCount,
|
||||
&Handles
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
for (Index = 0; Index < HandleCount; Index++) {
|
||||
Status = gBS->HandleProtocol (
|
||||
Handles[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) &&
|
||||
((PCI_CLASS_SERIAL == Class[2]) && (PCI_CLASS_SERIAL_USB == Class[1]))
|
||||
) {
|
||||
Status = gBS->ConnectController (
|
||||
Handles[Index],
|
||||
NULL,
|
||||
DevicePath,
|
||||
FALSE
|
||||
);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
AtLeastOneConnected = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Handles != NULL) {
|
||||
FreePool (Handles);
|
||||
}
|
||||
}
|
||||
|
||||
return AtLeastOneConnected ? EFI_SUCCESS : EFI_NOT_FOUND;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,386 +1,386 @@
|
||||
/** @file
|
||||
Misc library functions.
|
||||
|
||||
Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||
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 "InternalBm.h"
|
||||
|
||||
/**
|
||||
Delete the instance in Multi which matches partly with Single instance
|
||||
|
||||
@param Multi A pointer to a multi-instance device path data
|
||||
structure.
|
||||
@param Single A pointer to a single-instance device path data
|
||||
structure.
|
||||
|
||||
@return This function will remove the device path instances in Multi which partly
|
||||
match with the Single, and return the result device path. If there is no
|
||||
remaining device path as a result, this function will return NULL.
|
||||
|
||||
**/
|
||||
EFI_DEVICE_PATH_PROTOCOL *
|
||||
BmDelPartMatchInstance (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *Multi,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *Single
|
||||
)
|
||||
{
|
||||
EFI_DEVICE_PATH_PROTOCOL *Instance;
|
||||
EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
|
||||
EFI_DEVICE_PATH_PROTOCOL *TempNewDevicePath;
|
||||
UINTN InstanceSize;
|
||||
UINTN SingleDpSize;
|
||||
|
||||
NewDevicePath = NULL;
|
||||
TempNewDevicePath = NULL;
|
||||
|
||||
if (Multi == NULL || Single == NULL) {
|
||||
return Multi;
|
||||
}
|
||||
|
||||
Instance = GetNextDevicePathInstance (&Multi, &InstanceSize);
|
||||
SingleDpSize = GetDevicePathSize (Single) - END_DEVICE_PATH_LENGTH;
|
||||
InstanceSize -= END_DEVICE_PATH_LENGTH;
|
||||
|
||||
while (Instance != NULL) {
|
||||
|
||||
if (CompareMem (Instance, Single, MIN (SingleDpSize, InstanceSize)) != 0) {
|
||||
//
|
||||
// Append the device path instance which does not match with Single
|
||||
//
|
||||
TempNewDevicePath = NewDevicePath;
|
||||
NewDevicePath = AppendDevicePathInstance (NewDevicePath, Instance);
|
||||
if (TempNewDevicePath != NULL) {
|
||||
FreePool(TempNewDevicePath);
|
||||
}
|
||||
}
|
||||
FreePool(Instance);
|
||||
Instance = GetNextDevicePathInstance (&Multi, &InstanceSize);
|
||||
InstanceSize -= END_DEVICE_PATH_LENGTH;
|
||||
}
|
||||
|
||||
return NewDevicePath;
|
||||
}
|
||||
|
||||
/**
|
||||
Function compares a device path data structure to that of all the nodes of a
|
||||
second device path instance.
|
||||
|
||||
@param Multi A pointer to a multi-instance device path data
|
||||
structure.
|
||||
@param Single A pointer to a single-instance device path data
|
||||
structure.
|
||||
|
||||
@retval TRUE If the Single device path is contained within Multi device path.
|
||||
@retval FALSE The Single device path is not match within Multi device path.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
BmMatchDevicePaths (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *Multi,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *Single
|
||||
)
|
||||
{
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePathInst;
|
||||
UINTN Size;
|
||||
|
||||
if (Multi == NULL || Single == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DevicePath = Multi;
|
||||
DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);
|
||||
|
||||
//
|
||||
// Search for the match of 'Single' in 'Multi'
|
||||
//
|
||||
while (DevicePathInst != NULL) {
|
||||
//
|
||||
// If the single device path is found in multiple device paths,
|
||||
// return success
|
||||
//
|
||||
if (CompareMem (Single, DevicePathInst, Size) == 0) {
|
||||
FreePool (DevicePathInst);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
FreePool (DevicePathInst);
|
||||
DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
This routine adjust the memory information for different memory type and
|
||||
save them into the variables for next boot.
|
||||
**/
|
||||
VOID
|
||||
BmSetMemoryTypeInformationVariable (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_MEMORY_TYPE_INFORMATION *PreviousMemoryTypeInformation;
|
||||
EFI_MEMORY_TYPE_INFORMATION *CurrentMemoryTypeInformation;
|
||||
UINTN VariableSize;
|
||||
UINTN Index;
|
||||
UINTN Index1;
|
||||
UINT32 Previous;
|
||||
UINT32 Current;
|
||||
UINT32 Next;
|
||||
EFI_HOB_GUID_TYPE *GuidHob;
|
||||
BOOLEAN MemoryTypeInformationModified;
|
||||
BOOLEAN MemoryTypeInformationVariableExists;
|
||||
EFI_BOOT_MODE BootMode;
|
||||
|
||||
MemoryTypeInformationModified = FALSE;
|
||||
MemoryTypeInformationVariableExists = FALSE;
|
||||
|
||||
|
||||
BootMode = GetBootModeHob ();
|
||||
//
|
||||
// In BOOT_IN_RECOVERY_MODE, Variable region is not reliable.
|
||||
//
|
||||
if (BootMode == BOOT_IN_RECOVERY_MODE) {
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Only check the the Memory Type Information variable in the boot mode
|
||||
// other than BOOT_WITH_DEFAULT_SETTINGS because the Memory Type
|
||||
// Information is not valid in this boot mode.
|
||||
//
|
||||
if (BootMode != BOOT_WITH_DEFAULT_SETTINGS) {
|
||||
VariableSize = 0;
|
||||
Status = gRT->GetVariable (
|
||||
EFI_MEMORY_TYPE_INFORMATION_VARIABLE_NAME,
|
||||
&gEfiMemoryTypeInformationGuid,
|
||||
NULL,
|
||||
&VariableSize,
|
||||
NULL
|
||||
);
|
||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
MemoryTypeInformationVariableExists = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve the current memory usage statistics. If they are not found, then
|
||||
// no adjustments can be made to the Memory Type Information variable.
|
||||
//
|
||||
Status = EfiGetSystemConfigurationTable (
|
||||
&gEfiMemoryTypeInformationGuid,
|
||||
(VOID **) &CurrentMemoryTypeInformation
|
||||
);
|
||||
if (EFI_ERROR (Status) || CurrentMemoryTypeInformation == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the Memory Type Information settings from Hob if they exist,
|
||||
// PEI is responsible for getting them from variable and build a Hob to save them.
|
||||
// If the previous Memory Type Information is not available, then set defaults
|
||||
//
|
||||
GuidHob = GetFirstGuidHob (&gEfiMemoryTypeInformationGuid);
|
||||
if (GuidHob == NULL) {
|
||||
//
|
||||
// If Platform has not built Memory Type Info into the Hob, just return.
|
||||
//
|
||||
return;
|
||||
}
|
||||
PreviousMemoryTypeInformation = GET_GUID_HOB_DATA (GuidHob);
|
||||
VariableSize = GET_GUID_HOB_DATA_SIZE (GuidHob);
|
||||
|
||||
//
|
||||
// Use a heuristic to adjust the Memory Type Information for the next boot
|
||||
//
|
||||
DEBUG ((EFI_D_INFO, "Memory Previous Current Next \n"));
|
||||
DEBUG ((EFI_D_INFO, " Type Pages Pages Pages \n"));
|
||||
DEBUG ((EFI_D_INFO, "====== ======== ======== ========\n"));
|
||||
|
||||
for (Index = 0; PreviousMemoryTypeInformation[Index].Type != EfiMaxMemoryType; Index++) {
|
||||
|
||||
for (Index1 = 0; CurrentMemoryTypeInformation[Index1].Type != EfiMaxMemoryType; Index1++) {
|
||||
if (PreviousMemoryTypeInformation[Index].Type == CurrentMemoryTypeInformation[Index1].Type) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (CurrentMemoryTypeInformation[Index1].Type == EfiMaxMemoryType) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Previous is the number of pages pre-allocated
|
||||
// Current is the number of pages actually needed
|
||||
//
|
||||
Previous = PreviousMemoryTypeInformation[Index].NumberOfPages;
|
||||
Current = CurrentMemoryTypeInformation[Index1].NumberOfPages;
|
||||
Next = Previous;
|
||||
|
||||
//
|
||||
// Inconsistent Memory Reserved across bootings may lead to S4 fail
|
||||
// Write next varible to 125% * current when the pre-allocated memory is:
|
||||
// 1. More than 150% of needed memory and boot mode is BOOT_WITH_DEFAULT_SETTING
|
||||
// 2. Less than the needed memory
|
||||
//
|
||||
if ((Current + (Current >> 1)) < Previous) {
|
||||
if (BootMode == BOOT_WITH_DEFAULT_SETTINGS) {
|
||||
Next = Current + (Current >> 2);
|
||||
}
|
||||
} else if (Current > Previous) {
|
||||
Next = Current + (Current >> 2);
|
||||
}
|
||||
if (Next > 0 && Next < 4) {
|
||||
Next = 4;
|
||||
}
|
||||
|
||||
if (Next != Previous) {
|
||||
PreviousMemoryTypeInformation[Index].NumberOfPages = Next;
|
||||
MemoryTypeInformationModified = TRUE;
|
||||
}
|
||||
|
||||
DEBUG ((EFI_D_INFO, " %02x %08x %08x %08x\n", PreviousMemoryTypeInformation[Index].Type, Previous, Current, Next));
|
||||
}
|
||||
|
||||
//
|
||||
// If any changes were made to the Memory Type Information settings, then set the new variable value;
|
||||
// Or create the variable in first boot.
|
||||
//
|
||||
if (MemoryTypeInformationModified || !MemoryTypeInformationVariableExists) {
|
||||
Status = BmSetVariableAndReportStatusCodeOnError (
|
||||
EFI_MEMORY_TYPE_INFORMATION_VARIABLE_NAME,
|
||||
&gEfiMemoryTypeInformationGuid,
|
||||
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
|
||||
VariableSize,
|
||||
PreviousMemoryTypeInformation
|
||||
);
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
//
|
||||
// If the Memory Type Information settings have been modified, then reset the platform
|
||||
// so the new Memory Type Information setting will be used to guarantee that an S4
|
||||
// entry/resume cycle will not fail.
|
||||
//
|
||||
if (MemoryTypeInformationModified) {
|
||||
DEBUG ((EFI_D_INFO, "Memory Type Information settings change. Warm Reset!!!\n"));
|
||||
gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);
|
||||
}
|
||||
} else {
|
||||
DEBUG ((EFI_D_ERROR, "Memory Type Information settings cannot be saved. OS S4 may fail!\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Set the variable and report the error through status code upon failure.
|
||||
|
||||
@param VariableName A Null-terminated string that is the name of the vendor's variable.
|
||||
Each VariableName is unique for each VendorGuid. VariableName must
|
||||
contain 1 or more characters. If VariableName is an empty string,
|
||||
then EFI_INVALID_PARAMETER is returned.
|
||||
@param VendorGuid A unique identifier for the vendor.
|
||||
@param Attributes Attributes bitmask to set for the variable.
|
||||
@param DataSize The size in bytes of the Data buffer. Unless the EFI_VARIABLE_APPEND_WRITE,
|
||||
EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS, or
|
||||
EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS attribute is set, a size of zero
|
||||
causes the variable to be deleted. When the EFI_VARIABLE_APPEND_WRITE attribute is
|
||||
set, then a SetVariable() call with a DataSize of zero will not cause any change to
|
||||
the variable value (the timestamp associated with the variable may be updated however
|
||||
even if no new data value is provided,see the description of the
|
||||
EFI_VARIABLE_AUTHENTICATION_2 descriptor below. In this case the DataSize will not
|
||||
be zero since the EFI_VARIABLE_AUTHENTICATION_2 descriptor will be populated).
|
||||
@param Data The contents for the variable.
|
||||
|
||||
@retval EFI_SUCCESS The firmware has successfully stored the variable and its data as
|
||||
defined by the Attributes.
|
||||
@retval EFI_INVALID_PARAMETER An invalid combination of attribute bits, name, and GUID was supplied, or the
|
||||
DataSize exceeds the maximum allowed.
|
||||
@retval EFI_INVALID_PARAMETER VariableName is an empty string.
|
||||
@retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
|
||||
@retval EFI_DEVICE_ERROR The variable could not be retrieved due to a hardware error.
|
||||
@retval EFI_WRITE_PROTECTED The variable in question is read-only.
|
||||
@retval EFI_WRITE_PROTECTED The variable in question cannot be deleted.
|
||||
@retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS
|
||||
or EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS being set, but the AuthInfo
|
||||
does NOT pass the validation check carried out by the firmware.
|
||||
|
||||
@retval EFI_NOT_FOUND The variable trying to be updated or deleted was not found.
|
||||
**/
|
||||
EFI_STATUS
|
||||
BmSetVariableAndReportStatusCodeOnError (
|
||||
IN CHAR16 *VariableName,
|
||||
IN EFI_GUID *VendorGuid,
|
||||
IN UINT32 Attributes,
|
||||
IN UINTN DataSize,
|
||||
IN VOID *Data
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EDKII_SET_VARIABLE_STATUS *SetVariableStatus;
|
||||
UINTN NameSize;
|
||||
|
||||
Status = gRT->SetVariable (
|
||||
VariableName,
|
||||
VendorGuid,
|
||||
Attributes,
|
||||
DataSize,
|
||||
Data
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
NameSize = StrSize (VariableName);
|
||||
SetVariableStatus = AllocatePool (sizeof (EDKII_SET_VARIABLE_STATUS) + NameSize + DataSize);
|
||||
if (SetVariableStatus != NULL) {
|
||||
CopyGuid (&SetVariableStatus->Guid, VendorGuid);
|
||||
SetVariableStatus->NameSize = NameSize;
|
||||
SetVariableStatus->DataSize = DataSize;
|
||||
SetVariableStatus->SetStatus = Status;
|
||||
SetVariableStatus->Attributes = Attributes;
|
||||
CopyMem (SetVariableStatus + 1, VariableName, NameSize);
|
||||
CopyMem (((UINT8 *) (SetVariableStatus + 1)) + NameSize, Data, DataSize);
|
||||
|
||||
REPORT_STATUS_CODE_EX (
|
||||
EFI_ERROR_CODE,
|
||||
PcdGet32 (PcdErrorCodeSetVariable),
|
||||
0,
|
||||
NULL,
|
||||
&gEdkiiStatusCodeDataTypeVariableGuid,
|
||||
SetVariableStatus,
|
||||
sizeof (EDKII_SET_VARIABLE_STATUS) + NameSize + DataSize
|
||||
);
|
||||
|
||||
FreePool (SetVariableStatus);
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Print the device path info.
|
||||
|
||||
@param DevicePath The device path need to print.
|
||||
**/
|
||||
VOID
|
||||
BmPrintDp (
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
CHAR16 *Str;
|
||||
|
||||
Str = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
|
||||
DEBUG ((EFI_D_INFO, "%s", Str));
|
||||
if (Str != NULL) {
|
||||
FreePool (Str);
|
||||
}
|
||||
}
|
||||
/** @file
|
||||
Misc library functions.
|
||||
|
||||
Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||
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 "InternalBm.h"
|
||||
|
||||
/**
|
||||
Delete the instance in Multi which matches partly with Single instance
|
||||
|
||||
@param Multi A pointer to a multi-instance device path data
|
||||
structure.
|
||||
@param Single A pointer to a single-instance device path data
|
||||
structure.
|
||||
|
||||
@return This function will remove the device path instances in Multi which partly
|
||||
match with the Single, and return the result device path. If there is no
|
||||
remaining device path as a result, this function will return NULL.
|
||||
|
||||
**/
|
||||
EFI_DEVICE_PATH_PROTOCOL *
|
||||
BmDelPartMatchInstance (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *Multi,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *Single
|
||||
)
|
||||
{
|
||||
EFI_DEVICE_PATH_PROTOCOL *Instance;
|
||||
EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
|
||||
EFI_DEVICE_PATH_PROTOCOL *TempNewDevicePath;
|
||||
UINTN InstanceSize;
|
||||
UINTN SingleDpSize;
|
||||
|
||||
NewDevicePath = NULL;
|
||||
TempNewDevicePath = NULL;
|
||||
|
||||
if (Multi == NULL || Single == NULL) {
|
||||
return Multi;
|
||||
}
|
||||
|
||||
Instance = GetNextDevicePathInstance (&Multi, &InstanceSize);
|
||||
SingleDpSize = GetDevicePathSize (Single) - END_DEVICE_PATH_LENGTH;
|
||||
InstanceSize -= END_DEVICE_PATH_LENGTH;
|
||||
|
||||
while (Instance != NULL) {
|
||||
|
||||
if (CompareMem (Instance, Single, MIN (SingleDpSize, InstanceSize)) != 0) {
|
||||
//
|
||||
// Append the device path instance which does not match with Single
|
||||
//
|
||||
TempNewDevicePath = NewDevicePath;
|
||||
NewDevicePath = AppendDevicePathInstance (NewDevicePath, Instance);
|
||||
if (TempNewDevicePath != NULL) {
|
||||
FreePool(TempNewDevicePath);
|
||||
}
|
||||
}
|
||||
FreePool(Instance);
|
||||
Instance = GetNextDevicePathInstance (&Multi, &InstanceSize);
|
||||
InstanceSize -= END_DEVICE_PATH_LENGTH;
|
||||
}
|
||||
|
||||
return NewDevicePath;
|
||||
}
|
||||
|
||||
/**
|
||||
Function compares a device path data structure to that of all the nodes of a
|
||||
second device path instance.
|
||||
|
||||
@param Multi A pointer to a multi-instance device path data
|
||||
structure.
|
||||
@param Single A pointer to a single-instance device path data
|
||||
structure.
|
||||
|
||||
@retval TRUE If the Single device path is contained within Multi device path.
|
||||
@retval FALSE The Single device path is not match within Multi device path.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
BmMatchDevicePaths (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *Multi,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *Single
|
||||
)
|
||||
{
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePathInst;
|
||||
UINTN Size;
|
||||
|
||||
if (Multi == NULL || Single == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DevicePath = Multi;
|
||||
DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);
|
||||
|
||||
//
|
||||
// Search for the match of 'Single' in 'Multi'
|
||||
//
|
||||
while (DevicePathInst != NULL) {
|
||||
//
|
||||
// If the single device path is found in multiple device paths,
|
||||
// return success
|
||||
//
|
||||
if (CompareMem (Single, DevicePathInst, Size) == 0) {
|
||||
FreePool (DevicePathInst);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
FreePool (DevicePathInst);
|
||||
DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
This routine adjust the memory information for different memory type and
|
||||
save them into the variables for next boot.
|
||||
**/
|
||||
VOID
|
||||
BmSetMemoryTypeInformationVariable (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_MEMORY_TYPE_INFORMATION *PreviousMemoryTypeInformation;
|
||||
EFI_MEMORY_TYPE_INFORMATION *CurrentMemoryTypeInformation;
|
||||
UINTN VariableSize;
|
||||
UINTN Index;
|
||||
UINTN Index1;
|
||||
UINT32 Previous;
|
||||
UINT32 Current;
|
||||
UINT32 Next;
|
||||
EFI_HOB_GUID_TYPE *GuidHob;
|
||||
BOOLEAN MemoryTypeInformationModified;
|
||||
BOOLEAN MemoryTypeInformationVariableExists;
|
||||
EFI_BOOT_MODE BootMode;
|
||||
|
||||
MemoryTypeInformationModified = FALSE;
|
||||
MemoryTypeInformationVariableExists = FALSE;
|
||||
|
||||
|
||||
BootMode = GetBootModeHob ();
|
||||
//
|
||||
// In BOOT_IN_RECOVERY_MODE, Variable region is not reliable.
|
||||
//
|
||||
if (BootMode == BOOT_IN_RECOVERY_MODE) {
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Only check the the Memory Type Information variable in the boot mode
|
||||
// other than BOOT_WITH_DEFAULT_SETTINGS because the Memory Type
|
||||
// Information is not valid in this boot mode.
|
||||
//
|
||||
if (BootMode != BOOT_WITH_DEFAULT_SETTINGS) {
|
||||
VariableSize = 0;
|
||||
Status = gRT->GetVariable (
|
||||
EFI_MEMORY_TYPE_INFORMATION_VARIABLE_NAME,
|
||||
&gEfiMemoryTypeInformationGuid,
|
||||
NULL,
|
||||
&VariableSize,
|
||||
NULL
|
||||
);
|
||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
MemoryTypeInformationVariableExists = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve the current memory usage statistics. If they are not found, then
|
||||
// no adjustments can be made to the Memory Type Information variable.
|
||||
//
|
||||
Status = EfiGetSystemConfigurationTable (
|
||||
&gEfiMemoryTypeInformationGuid,
|
||||
(VOID **) &CurrentMemoryTypeInformation
|
||||
);
|
||||
if (EFI_ERROR (Status) || CurrentMemoryTypeInformation == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the Memory Type Information settings from Hob if they exist,
|
||||
// PEI is responsible for getting them from variable and build a Hob to save them.
|
||||
// If the previous Memory Type Information is not available, then set defaults
|
||||
//
|
||||
GuidHob = GetFirstGuidHob (&gEfiMemoryTypeInformationGuid);
|
||||
if (GuidHob == NULL) {
|
||||
//
|
||||
// If Platform has not built Memory Type Info into the Hob, just return.
|
||||
//
|
||||
return;
|
||||
}
|
||||
PreviousMemoryTypeInformation = GET_GUID_HOB_DATA (GuidHob);
|
||||
VariableSize = GET_GUID_HOB_DATA_SIZE (GuidHob);
|
||||
|
||||
//
|
||||
// Use a heuristic to adjust the Memory Type Information for the next boot
|
||||
//
|
||||
DEBUG ((EFI_D_INFO, "Memory Previous Current Next \n"));
|
||||
DEBUG ((EFI_D_INFO, " Type Pages Pages Pages \n"));
|
||||
DEBUG ((EFI_D_INFO, "====== ======== ======== ========\n"));
|
||||
|
||||
for (Index = 0; PreviousMemoryTypeInformation[Index].Type != EfiMaxMemoryType; Index++) {
|
||||
|
||||
for (Index1 = 0; CurrentMemoryTypeInformation[Index1].Type != EfiMaxMemoryType; Index1++) {
|
||||
if (PreviousMemoryTypeInformation[Index].Type == CurrentMemoryTypeInformation[Index1].Type) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (CurrentMemoryTypeInformation[Index1].Type == EfiMaxMemoryType) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Previous is the number of pages pre-allocated
|
||||
// Current is the number of pages actually needed
|
||||
//
|
||||
Previous = PreviousMemoryTypeInformation[Index].NumberOfPages;
|
||||
Current = CurrentMemoryTypeInformation[Index1].NumberOfPages;
|
||||
Next = Previous;
|
||||
|
||||
//
|
||||
// Inconsistent Memory Reserved across bootings may lead to S4 fail
|
||||
// Write next varible to 125% * current when the pre-allocated memory is:
|
||||
// 1. More than 150% of needed memory and boot mode is BOOT_WITH_DEFAULT_SETTING
|
||||
// 2. Less than the needed memory
|
||||
//
|
||||
if ((Current + (Current >> 1)) < Previous) {
|
||||
if (BootMode == BOOT_WITH_DEFAULT_SETTINGS) {
|
||||
Next = Current + (Current >> 2);
|
||||
}
|
||||
} else if (Current > Previous) {
|
||||
Next = Current + (Current >> 2);
|
||||
}
|
||||
if (Next > 0 && Next < 4) {
|
||||
Next = 4;
|
||||
}
|
||||
|
||||
if (Next != Previous) {
|
||||
PreviousMemoryTypeInformation[Index].NumberOfPages = Next;
|
||||
MemoryTypeInformationModified = TRUE;
|
||||
}
|
||||
|
||||
DEBUG ((EFI_D_INFO, " %02x %08x %08x %08x\n", PreviousMemoryTypeInformation[Index].Type, Previous, Current, Next));
|
||||
}
|
||||
|
||||
//
|
||||
// If any changes were made to the Memory Type Information settings, then set the new variable value;
|
||||
// Or create the variable in first boot.
|
||||
//
|
||||
if (MemoryTypeInformationModified || !MemoryTypeInformationVariableExists) {
|
||||
Status = BmSetVariableAndReportStatusCodeOnError (
|
||||
EFI_MEMORY_TYPE_INFORMATION_VARIABLE_NAME,
|
||||
&gEfiMemoryTypeInformationGuid,
|
||||
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
|
||||
VariableSize,
|
||||
PreviousMemoryTypeInformation
|
||||
);
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
//
|
||||
// If the Memory Type Information settings have been modified, then reset the platform
|
||||
// so the new Memory Type Information setting will be used to guarantee that an S4
|
||||
// entry/resume cycle will not fail.
|
||||
//
|
||||
if (MemoryTypeInformationModified) {
|
||||
DEBUG ((EFI_D_INFO, "Memory Type Information settings change. Warm Reset!!!\n"));
|
||||
gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);
|
||||
}
|
||||
} else {
|
||||
DEBUG ((EFI_D_ERROR, "Memory Type Information settings cannot be saved. OS S4 may fail!\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Set the variable and report the error through status code upon failure.
|
||||
|
||||
@param VariableName A Null-terminated string that is the name of the vendor's variable.
|
||||
Each VariableName is unique for each VendorGuid. VariableName must
|
||||
contain 1 or more characters. If VariableName is an empty string,
|
||||
then EFI_INVALID_PARAMETER is returned.
|
||||
@param VendorGuid A unique identifier for the vendor.
|
||||
@param Attributes Attributes bitmask to set for the variable.
|
||||
@param DataSize The size in bytes of the Data buffer. Unless the EFI_VARIABLE_APPEND_WRITE,
|
||||
EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS, or
|
||||
EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS attribute is set, a size of zero
|
||||
causes the variable to be deleted. When the EFI_VARIABLE_APPEND_WRITE attribute is
|
||||
set, then a SetVariable() call with a DataSize of zero will not cause any change to
|
||||
the variable value (the timestamp associated with the variable may be updated however
|
||||
even if no new data value is provided,see the description of the
|
||||
EFI_VARIABLE_AUTHENTICATION_2 descriptor below. In this case the DataSize will not
|
||||
be zero since the EFI_VARIABLE_AUTHENTICATION_2 descriptor will be populated).
|
||||
@param Data The contents for the variable.
|
||||
|
||||
@retval EFI_SUCCESS The firmware has successfully stored the variable and its data as
|
||||
defined by the Attributes.
|
||||
@retval EFI_INVALID_PARAMETER An invalid combination of attribute bits, name, and GUID was supplied, or the
|
||||
DataSize exceeds the maximum allowed.
|
||||
@retval EFI_INVALID_PARAMETER VariableName is an empty string.
|
||||
@retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
|
||||
@retval EFI_DEVICE_ERROR The variable could not be retrieved due to a hardware error.
|
||||
@retval EFI_WRITE_PROTECTED The variable in question is read-only.
|
||||
@retval EFI_WRITE_PROTECTED The variable in question cannot be deleted.
|
||||
@retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS
|
||||
or EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS being set, but the AuthInfo
|
||||
does NOT pass the validation check carried out by the firmware.
|
||||
|
||||
@retval EFI_NOT_FOUND The variable trying to be updated or deleted was not found.
|
||||
**/
|
||||
EFI_STATUS
|
||||
BmSetVariableAndReportStatusCodeOnError (
|
||||
IN CHAR16 *VariableName,
|
||||
IN EFI_GUID *VendorGuid,
|
||||
IN UINT32 Attributes,
|
||||
IN UINTN DataSize,
|
||||
IN VOID *Data
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EDKII_SET_VARIABLE_STATUS *SetVariableStatus;
|
||||
UINTN NameSize;
|
||||
|
||||
Status = gRT->SetVariable (
|
||||
VariableName,
|
||||
VendorGuid,
|
||||
Attributes,
|
||||
DataSize,
|
||||
Data
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
NameSize = StrSize (VariableName);
|
||||
SetVariableStatus = AllocatePool (sizeof (EDKII_SET_VARIABLE_STATUS) + NameSize + DataSize);
|
||||
if (SetVariableStatus != NULL) {
|
||||
CopyGuid (&SetVariableStatus->Guid, VendorGuid);
|
||||
SetVariableStatus->NameSize = NameSize;
|
||||
SetVariableStatus->DataSize = DataSize;
|
||||
SetVariableStatus->SetStatus = Status;
|
||||
SetVariableStatus->Attributes = Attributes;
|
||||
CopyMem (SetVariableStatus + 1, VariableName, NameSize);
|
||||
CopyMem (((UINT8 *) (SetVariableStatus + 1)) + NameSize, Data, DataSize);
|
||||
|
||||
REPORT_STATUS_CODE_EX (
|
||||
EFI_ERROR_CODE,
|
||||
PcdGet32 (PcdErrorCodeSetVariable),
|
||||
0,
|
||||
NULL,
|
||||
&gEdkiiStatusCodeDataTypeVariableGuid,
|
||||
SetVariableStatus,
|
||||
sizeof (EDKII_SET_VARIABLE_STATUS) + NameSize + DataSize
|
||||
);
|
||||
|
||||
FreePool (SetVariableStatus);
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Print the device path info.
|
||||
|
||||
@param DevicePath The device path need to print.
|
||||
**/
|
||||
VOID
|
||||
BmPrintDp (
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
CHAR16 *Str;
|
||||
|
||||
Str = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
|
||||
DEBUG ((EFI_D_INFO, "%s", Str));
|
||||
if (Str != NULL) {
|
||||
FreePool (Str);
|
||||
}
|
||||
}
|
||||
|
@ -1,358 +1,358 @@
|
||||
/** @file
|
||||
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.
|
||||
|
||||
Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||
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 "InternalBm.h"
|
||||
|
||||
PERF_HEADER mBmPerfHeader;
|
||||
PERF_DATA mBmPerfData;
|
||||
EFI_PHYSICAL_ADDRESS mBmAcpiLowMemoryBase = 0x0FFFFFFFFULL;
|
||||
|
||||
/**
|
||||
Get the short verion of PDB file name to be
|
||||
used in performance data logging.
|
||||
|
||||
@param PdbFileName The long PDB file name.
|
||||
@param GaugeString The output string to be logged by performance logger.
|
||||
|
||||
**/
|
||||
VOID
|
||||
BmGetShortPdbFileName (
|
||||
IN CONST CHAR8 *PdbFileName,
|
||||
OUT CHAR8 *GaugeString
|
||||
)
|
||||
{
|
||||
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 ;
|
||||
}
|
||||
|
||||
/**
|
||||
Get the name from the Driver handle, which can be a handle with
|
||||
EFI_LOADED_IMAGE_PROTOCOL or EFI_DRIVER_BINDING_PROTOCOL installed.
|
||||
This name can be used in performance data logging.
|
||||
|
||||
@param Handle Driver handle.
|
||||
@param GaugeString The output string to be logged by performance logger.
|
||||
|
||||
**/
|
||||
VOID
|
||||
BmGetNameFromHandle (
|
||||
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) {
|
||||
BmGetShortPdbFileName (PdbFileName, GaugeString);
|
||||
}
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Writes performance data of booting into the allocated memory.
|
||||
OS can process these records.
|
||||
|
||||
@param Event The triggered event.
|
||||
@param Context Context for this event.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
BmWriteBootToOsPerformanceData (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
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;
|
||||
UINTN EntryIndex;
|
||||
UINTN NumPerfEntries;
|
||||
//
|
||||
// List of flags indicating PerfEntry contains DXE handle
|
||||
//
|
||||
BOOLEAN *PerfEntriesAsDxeHandle;
|
||||
UINTN VarSize;
|
||||
|
||||
//
|
||||
// Record the performance data for End of BDS
|
||||
//
|
||||
PERF_END(NULL, "BDS", NULL, 0);
|
||||
|
||||
//
|
||||
// Retrieve time stamp count as early as possible
|
||||
//
|
||||
Ticker = GetPerformanceCounter ();
|
||||
|
||||
Freq = GetPerformanceCounterProperties (&StartValue, &EndValue);
|
||||
|
||||
Freq = DivU64x32 (Freq, 1000);
|
||||
|
||||
mBmPerfHeader.CpuFreq = Freq;
|
||||
|
||||
//
|
||||
// Record BDS raw performance data
|
||||
//
|
||||
if (EndValue >= StartValue) {
|
||||
mBmPerfHeader.BDSRaw = Ticker - StartValue;
|
||||
CountUp = TRUE;
|
||||
} else {
|
||||
mBmPerfHeader.BDSRaw = StartValue - Ticker;
|
||||
CountUp = FALSE;
|
||||
}
|
||||
|
||||
if (mBmAcpiLowMemoryBase == 0x0FFFFFFFF) {
|
||||
VarSize = sizeof (EFI_PHYSICAL_ADDRESS);
|
||||
Status = gRT->GetVariable (
|
||||
L"PerfDataMemAddr",
|
||||
&gPerformanceProtocolGuid,
|
||||
NULL,
|
||||
&VarSize,
|
||||
&mBmAcpiLowMemoryBase
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
//
|
||||
// Fail to get the variable, return.
|
||||
//
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Put Detailed performance data into memory
|
||||
//
|
||||
Handles = NULL;
|
||||
Status = gBS->LocateHandleBuffer (
|
||||
AllHandles,
|
||||
NULL,
|
||||
NULL,
|
||||
&NoHandles,
|
||||
&Handles
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return ;
|
||||
}
|
||||
|
||||
Ptr = (UINT8 *) ((UINT32) mBmAcpiLowMemoryBase + sizeof (PERF_HEADER));
|
||||
LimitCount = (UINT32) (PERF_DATA_MAX_LENGTH - sizeof (PERF_HEADER)) / sizeof (PERF_DATA);
|
||||
|
||||
NumPerfEntries = 0;
|
||||
LogEntryKey = 0;
|
||||
while ((LogEntryKey = GetPerformanceMeasurement (
|
||||
LogEntryKey,
|
||||
&Handle,
|
||||
&Token,
|
||||
&Module,
|
||||
&StartTicker,
|
||||
&EndTicker)) != 0) {
|
||||
NumPerfEntries++;
|
||||
}
|
||||
PerfEntriesAsDxeHandle = AllocateZeroPool (NumPerfEntries * sizeof (BOOLEAN));
|
||||
ASSERT (PerfEntriesAsDxeHandle != NULL);
|
||||
|
||||
//
|
||||
// Get DXE drivers performance
|
||||
//
|
||||
for (Index = 0; Index < NoHandles; Index++) {
|
||||
Ticker = 0;
|
||||
LogEntryKey = 0;
|
||||
EntryIndex = 0;
|
||||
while ((LogEntryKey = GetPerformanceMeasurement (
|
||||
LogEntryKey,
|
||||
&Handle,
|
||||
&Token,
|
||||
&Module,
|
||||
&StartTicker,
|
||||
&EndTicker)) != 0) {
|
||||
if (Handle == Handles[Index] && !PerfEntriesAsDxeHandle[EntryIndex]) {
|
||||
PerfEntriesAsDxeHandle[EntryIndex] = TRUE;
|
||||
}
|
||||
EntryIndex++;
|
||||
if ((Handle == Handles[Index]) && (EndTicker != 0)) {
|
||||
if (StartTicker == 1) {
|
||||
StartTicker = StartValue;
|
||||
}
|
||||
if (EndTicker == 1) {
|
||||
EndTicker = StartValue;
|
||||
}
|
||||
Ticker += CountUp ? (EndTicker - StartTicker) : (StartTicker - EndTicker);
|
||||
}
|
||||
}
|
||||
|
||||
Duration = (UINT32) DivU64x32 (Ticker, (UINT32) Freq);
|
||||
|
||||
if (Duration > 0) {
|
||||
|
||||
BmGetNameFromHandle (Handles[Index], GaugeString);
|
||||
|
||||
AsciiStrCpy (mBmPerfData.Token, GaugeString);
|
||||
mBmPerfData.Duration = Duration;
|
||||
|
||||
CopyMem (Ptr, &mBmPerfData, sizeof (PERF_DATA));
|
||||
Ptr += sizeof (PERF_DATA);
|
||||
|
||||
mBmPerfHeader.Count++;
|
||||
if (mBmPerfHeader.Count == LimitCount) {
|
||||
goto Done;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Get inserted performance data
|
||||
//
|
||||
LogEntryKey = 0;
|
||||
EntryIndex = 0;
|
||||
while ((LogEntryKey = GetPerformanceMeasurement (
|
||||
LogEntryKey,
|
||||
&Handle,
|
||||
&Token,
|
||||
&Module,
|
||||
&StartTicker,
|
||||
&EndTicker)) != 0) {
|
||||
if (!PerfEntriesAsDxeHandle[EntryIndex] && EndTicker != 0) {
|
||||
|
||||
ZeroMem (&mBmPerfData, sizeof (PERF_DATA));
|
||||
|
||||
AsciiStrnCpy (mBmPerfData.Token, Token, PERF_TOKEN_LENGTH);
|
||||
if (StartTicker == 1) {
|
||||
StartTicker = StartValue;
|
||||
}
|
||||
if (EndTicker == 1) {
|
||||
EndTicker = StartValue;
|
||||
}
|
||||
Ticker = CountUp ? (EndTicker - StartTicker) : (StartTicker - EndTicker);
|
||||
|
||||
mBmPerfData.Duration = (UINT32) DivU64x32 (Ticker, (UINT32) Freq);
|
||||
|
||||
CopyMem (Ptr, &mBmPerfData, sizeof (PERF_DATA));
|
||||
Ptr += sizeof (PERF_DATA);
|
||||
|
||||
mBmPerfHeader.Count++;
|
||||
if (mBmPerfHeader.Count == LimitCount) {
|
||||
goto Done;
|
||||
}
|
||||
}
|
||||
EntryIndex++;
|
||||
}
|
||||
|
||||
Done:
|
||||
|
||||
FreePool (Handles);
|
||||
FreePool (PerfEntriesAsDxeHandle);
|
||||
|
||||
mBmPerfHeader.Signiture = PERFORMANCE_SIGNATURE;
|
||||
|
||||
//
|
||||
// Put performance data to Reserved memory
|
||||
//
|
||||
CopyMem (
|
||||
(UINTN *) (UINTN) mBmAcpiLowMemoryBase,
|
||||
&mBmPerfHeader,
|
||||
sizeof (PERF_HEADER)
|
||||
);
|
||||
|
||||
return ;
|
||||
}
|
||||
/** @file
|
||||
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.
|
||||
|
||||
Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||
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 "InternalBm.h"
|
||||
|
||||
PERF_HEADER mBmPerfHeader;
|
||||
PERF_DATA mBmPerfData;
|
||||
EFI_PHYSICAL_ADDRESS mBmAcpiLowMemoryBase = 0x0FFFFFFFFULL;
|
||||
|
||||
/**
|
||||
Get the short verion of PDB file name to be
|
||||
used in performance data logging.
|
||||
|
||||
@param PdbFileName The long PDB file name.
|
||||
@param GaugeString The output string to be logged by performance logger.
|
||||
|
||||
**/
|
||||
VOID
|
||||
BmGetShortPdbFileName (
|
||||
IN CONST CHAR8 *PdbFileName,
|
||||
OUT CHAR8 *GaugeString
|
||||
)
|
||||
{
|
||||
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 ;
|
||||
}
|
||||
|
||||
/**
|
||||
Get the name from the Driver handle, which can be a handle with
|
||||
EFI_LOADED_IMAGE_PROTOCOL or EFI_DRIVER_BINDING_PROTOCOL installed.
|
||||
This name can be used in performance data logging.
|
||||
|
||||
@param Handle Driver handle.
|
||||
@param GaugeString The output string to be logged by performance logger.
|
||||
|
||||
**/
|
||||
VOID
|
||||
BmGetNameFromHandle (
|
||||
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) {
|
||||
BmGetShortPdbFileName (PdbFileName, GaugeString);
|
||||
}
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Writes performance data of booting into the allocated memory.
|
||||
OS can process these records.
|
||||
|
||||
@param Event The triggered event.
|
||||
@param Context Context for this event.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
BmWriteBootToOsPerformanceData (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
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;
|
||||
UINTN EntryIndex;
|
||||
UINTN NumPerfEntries;
|
||||
//
|
||||
// List of flags indicating PerfEntry contains DXE handle
|
||||
//
|
||||
BOOLEAN *PerfEntriesAsDxeHandle;
|
||||
UINTN VarSize;
|
||||
|
||||
//
|
||||
// Record the performance data for End of BDS
|
||||
//
|
||||
PERF_END(NULL, "BDS", NULL, 0);
|
||||
|
||||
//
|
||||
// Retrieve time stamp count as early as possible
|
||||
//
|
||||
Ticker = GetPerformanceCounter ();
|
||||
|
||||
Freq = GetPerformanceCounterProperties (&StartValue, &EndValue);
|
||||
|
||||
Freq = DivU64x32 (Freq, 1000);
|
||||
|
||||
mBmPerfHeader.CpuFreq = Freq;
|
||||
|
||||
//
|
||||
// Record BDS raw performance data
|
||||
//
|
||||
if (EndValue >= StartValue) {
|
||||
mBmPerfHeader.BDSRaw = Ticker - StartValue;
|
||||
CountUp = TRUE;
|
||||
} else {
|
||||
mBmPerfHeader.BDSRaw = StartValue - Ticker;
|
||||
CountUp = FALSE;
|
||||
}
|
||||
|
||||
if (mBmAcpiLowMemoryBase == 0x0FFFFFFFF) {
|
||||
VarSize = sizeof (EFI_PHYSICAL_ADDRESS);
|
||||
Status = gRT->GetVariable (
|
||||
L"PerfDataMemAddr",
|
||||
&gPerformanceProtocolGuid,
|
||||
NULL,
|
||||
&VarSize,
|
||||
&mBmAcpiLowMemoryBase
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
//
|
||||
// Fail to get the variable, return.
|
||||
//
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Put Detailed performance data into memory
|
||||
//
|
||||
Handles = NULL;
|
||||
Status = gBS->LocateHandleBuffer (
|
||||
AllHandles,
|
||||
NULL,
|
||||
NULL,
|
||||
&NoHandles,
|
||||
&Handles
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return ;
|
||||
}
|
||||
|
||||
Ptr = (UINT8 *) ((UINT32) mBmAcpiLowMemoryBase + sizeof (PERF_HEADER));
|
||||
LimitCount = (UINT32) (PERF_DATA_MAX_LENGTH - sizeof (PERF_HEADER)) / sizeof (PERF_DATA);
|
||||
|
||||
NumPerfEntries = 0;
|
||||
LogEntryKey = 0;
|
||||
while ((LogEntryKey = GetPerformanceMeasurement (
|
||||
LogEntryKey,
|
||||
&Handle,
|
||||
&Token,
|
||||
&Module,
|
||||
&StartTicker,
|
||||
&EndTicker)) != 0) {
|
||||
NumPerfEntries++;
|
||||
}
|
||||
PerfEntriesAsDxeHandle = AllocateZeroPool (NumPerfEntries * sizeof (BOOLEAN));
|
||||
ASSERT (PerfEntriesAsDxeHandle != NULL);
|
||||
|
||||
//
|
||||
// Get DXE drivers performance
|
||||
//
|
||||
for (Index = 0; Index < NoHandles; Index++) {
|
||||
Ticker = 0;
|
||||
LogEntryKey = 0;
|
||||
EntryIndex = 0;
|
||||
while ((LogEntryKey = GetPerformanceMeasurement (
|
||||
LogEntryKey,
|
||||
&Handle,
|
||||
&Token,
|
||||
&Module,
|
||||
&StartTicker,
|
||||
&EndTicker)) != 0) {
|
||||
if (Handle == Handles[Index] && !PerfEntriesAsDxeHandle[EntryIndex]) {
|
||||
PerfEntriesAsDxeHandle[EntryIndex] = TRUE;
|
||||
}
|
||||
EntryIndex++;
|
||||
if ((Handle == Handles[Index]) && (EndTicker != 0)) {
|
||||
if (StartTicker == 1) {
|
||||
StartTicker = StartValue;
|
||||
}
|
||||
if (EndTicker == 1) {
|
||||
EndTicker = StartValue;
|
||||
}
|
||||
Ticker += CountUp ? (EndTicker - StartTicker) : (StartTicker - EndTicker);
|
||||
}
|
||||
}
|
||||
|
||||
Duration = (UINT32) DivU64x32 (Ticker, (UINT32) Freq);
|
||||
|
||||
if (Duration > 0) {
|
||||
|
||||
BmGetNameFromHandle (Handles[Index], GaugeString);
|
||||
|
||||
AsciiStrCpy (mBmPerfData.Token, GaugeString);
|
||||
mBmPerfData.Duration = Duration;
|
||||
|
||||
CopyMem (Ptr, &mBmPerfData, sizeof (PERF_DATA));
|
||||
Ptr += sizeof (PERF_DATA);
|
||||
|
||||
mBmPerfHeader.Count++;
|
||||
if (mBmPerfHeader.Count == LimitCount) {
|
||||
goto Done;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Get inserted performance data
|
||||
//
|
||||
LogEntryKey = 0;
|
||||
EntryIndex = 0;
|
||||
while ((LogEntryKey = GetPerformanceMeasurement (
|
||||
LogEntryKey,
|
||||
&Handle,
|
||||
&Token,
|
||||
&Module,
|
||||
&StartTicker,
|
||||
&EndTicker)) != 0) {
|
||||
if (!PerfEntriesAsDxeHandle[EntryIndex] && EndTicker != 0) {
|
||||
|
||||
ZeroMem (&mBmPerfData, sizeof (PERF_DATA));
|
||||
|
||||
AsciiStrnCpy (mBmPerfData.Token, Token, PERF_TOKEN_LENGTH);
|
||||
if (StartTicker == 1) {
|
||||
StartTicker = StartValue;
|
||||
}
|
||||
if (EndTicker == 1) {
|
||||
EndTicker = StartValue;
|
||||
}
|
||||
Ticker = CountUp ? (EndTicker - StartTicker) : (StartTicker - EndTicker);
|
||||
|
||||
mBmPerfData.Duration = (UINT32) DivU64x32 (Ticker, (UINT32) Freq);
|
||||
|
||||
CopyMem (Ptr, &mBmPerfData, sizeof (PERF_DATA));
|
||||
Ptr += sizeof (PERF_DATA);
|
||||
|
||||
mBmPerfHeader.Count++;
|
||||
if (mBmPerfHeader.Count == LimitCount) {
|
||||
goto Done;
|
||||
}
|
||||
}
|
||||
EntryIndex++;
|
||||
}
|
||||
|
||||
Done:
|
||||
|
||||
FreePool (Handles);
|
||||
FreePool (PerfEntriesAsDxeHandle);
|
||||
|
||||
mBmPerfHeader.Signiture = PERFORMANCE_SIGNATURE;
|
||||
|
||||
//
|
||||
// Put performance data to Reserved memory
|
||||
//
|
||||
CopyMem (
|
||||
(UINTN *) (UINTN) mBmAcpiLowMemoryBase,
|
||||
&mBmPerfHeader,
|
||||
sizeof (PERF_HEADER)
|
||||
);
|
||||
|
||||
return ;
|
||||
}
|
||||
|
@ -1,441 +1,441 @@
|
||||
/** @file
|
||||
BDS library definition, include the file and data structure
|
||||
|
||||
Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _INTERNAL_BM_H_
|
||||
#define _INTERNAL_BM_H_
|
||||
|
||||
#include <PiDxe.h>
|
||||
|
||||
#include <IndustryStandard/Pci.h>
|
||||
#include <IndustryStandard/PeImage.h>
|
||||
#include <IndustryStandard/Atapi.h>
|
||||
#include <IndustryStandard/Scsi.h>
|
||||
|
||||
#include <Protocol/PciRootBridgeIo.h>
|
||||
#include <Protocol/BlockIo.h>
|
||||
#include <Protocol/LoadedImage.h>
|
||||
#include <Protocol/SimpleFileSystem.h>
|
||||
#include <Protocol/LoadFile.h>
|
||||
#include <Protocol/DevicePath.h>
|
||||
#include <Protocol/SimpleTextIn.h>
|
||||
#include <Protocol/SimpleTextInEx.h>
|
||||
#include <Protocol/SimpleTextOut.h>
|
||||
#include <Protocol/SimpleNetwork.h>
|
||||
#include <Protocol/FirmwareVolume2.h>
|
||||
#include <Protocol/PciIo.h>
|
||||
#include <Protocol/GraphicsOutput.h>
|
||||
#include <Protocol/UsbIo.h>
|
||||
#include <Protocol/DiskInfo.h>
|
||||
#include <Protocol/IdeControllerInit.h>
|
||||
#include <Protocol/BootLogo.h>
|
||||
#include <Protocol/DriverHealth.h>
|
||||
#include <Protocol/FormBrowser2.h>
|
||||
|
||||
#include <Guid/ZeroGuid.h>
|
||||
#include <Guid/MemoryTypeInformation.h>
|
||||
#include <Guid/FileInfo.h>
|
||||
#include <Guid/GlobalVariable.h>
|
||||
#include <Guid/Performance.h>
|
||||
#include <Guid/StatusCodeDataTypeVariable.h>
|
||||
|
||||
#include <Library/PrintLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/DxeServicesTableLib.h>
|
||||
#include <Library/HobLib.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/PerformanceLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/PeCoffGetEntryPointLib.h>
|
||||
#include <Library/UefiBootManagerLib.h>
|
||||
#include <Library/TimerLib.h>
|
||||
#include <Library/DxeServicesLib.h>
|
||||
#include <Library/ReportStatusCodeLib.h>
|
||||
#include <Library/CapsuleLib.h>
|
||||
#include <Library/PerformanceLib.h>
|
||||
#include <Library/HiiLib.h>
|
||||
|
||||
#if !defined (EFI_REMOVABLE_MEDIA_FILE_NAME)
|
||||
#if defined (MDE_CPU_EBC)
|
||||
//
|
||||
// Uefi specification only defines the default boot file name for IA32, X64
|
||||
// and IPF processor, so need define boot file name for EBC architecture here.
|
||||
//
|
||||
#define EFI_REMOVABLE_MEDIA_FILE_NAME L"\\EFI\\BOOT\\BOOTEBC.EFI"
|
||||
#else
|
||||
#error "Can not determine the default boot file name for unknown processor type!"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
BmAcpiFloppyBoot,
|
||||
BmHardwareDeviceBoot,
|
||||
BmMessageAtapiBoot,
|
||||
BmMessageSataBoot,
|
||||
BmMessageUsbBoot,
|
||||
BmMessageScsiBoot,
|
||||
BmMessageNetworkBoot,
|
||||
BmMiscBoot
|
||||
} BM_BOOT_TYPE;
|
||||
|
||||
typedef
|
||||
CHAR16 *
|
||||
(* BM_GET_BOOT_DESCRIPTION) (
|
||||
IN EFI_HANDLE Handle
|
||||
);
|
||||
|
||||
#define BM_OPTION_NAME_LEN sizeof ("SysPrep####")
|
||||
extern CHAR16 *mBmLoadOptionName[];
|
||||
|
||||
typedef
|
||||
VOID
|
||||
(*VARIABLE_VISITOR) (
|
||||
CHAR16 *Name,
|
||||
EFI_GUID *Guid,
|
||||
VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
Call Visitor function for each variable in variable storage.
|
||||
|
||||
@param Visitor Visitor function.
|
||||
@param Context The context passed to Visitor function.
|
||||
**/
|
||||
VOID
|
||||
ForEachVariable (
|
||||
VARIABLE_VISITOR Visitor,
|
||||
VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
Repair all the controllers according to the Driver Health status queried.
|
||||
**/
|
||||
VOID
|
||||
BmRepairAllControllers (
|
||||
VOID
|
||||
);
|
||||
|
||||
#define BM_HOTKEY_SIGNATURE SIGNATURE_32 ('b', 'm', 'h', 'k')
|
||||
typedef struct {
|
||||
UINT32 Signature;
|
||||
LIST_ENTRY Link;
|
||||
|
||||
BOOLEAN IsContinue;
|
||||
UINT16 BootOption;
|
||||
UINT8 CodeCount;
|
||||
UINT8 WaitingKey;
|
||||
EFI_KEY_DATA KeyData[3];
|
||||
} BM_HOTKEY;
|
||||
|
||||
#define BM_HOTKEY_FROM_LINK(a) CR (a, BM_HOTKEY, Link, BM_HOTKEY_SIGNATURE)
|
||||
|
||||
/**
|
||||
Get the image file buffer data and buffer size by its device path.
|
||||
|
||||
@param FilePath On input, a pointer to an allocated buffer containing the device
|
||||
path of the file.
|
||||
On output the pointer could be NULL when the function fails to
|
||||
load the boot option, or could point to an allocated buffer containing
|
||||
the device path of the file.
|
||||
It could be updated by either short-form device path expanding,
|
||||
or default boot file path appending.
|
||||
Caller is responsible to free it when it's non-NULL.
|
||||
@param FileSize A pointer to the size of the file buffer.
|
||||
|
||||
@retval NULL File is NULL, or FileSize is NULL. Or, the file can't be found.
|
||||
@retval other The file buffer. The caller is responsible to free the memory.
|
||||
**/
|
||||
VOID *
|
||||
BmLoadEfiBootOption (
|
||||
IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,
|
||||
OUT UINTN *FileSize
|
||||
);
|
||||
|
||||
/**
|
||||
Get the Option Number that wasn't used.
|
||||
|
||||
@param LoadOptionType Load option type.
|
||||
@param FreeOptionNumber To receive the minimal free option number.
|
||||
|
||||
@retval EFI_SUCCESS The option number is found
|
||||
@retval EFI_OUT_OF_RESOURCES There is no free option number that can be used.
|
||||
@retval EFI_INVALID_PARAMETER FreeOptionNumber is NULL
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
BmGetFreeOptionNumber (
|
||||
IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE LoadOptionType,
|
||||
OUT UINT16 *FreeOptionNumber
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
Writes performance data of booting into the allocated memory.
|
||||
OS can process these records.
|
||||
|
||||
@param Event The triggered event.
|
||||
@param Context Context for this event.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
BmWriteBootToOsPerformanceData (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Get the headers (dos, image, optional header) from an image
|
||||
|
||||
@param Device SimpleFileSystem device handle
|
||||
@param FileName File name for the image
|
||||
@param DosHeader Pointer to dos header
|
||||
@param Hdr The buffer in which to return the PE32, PE32+, or TE header.
|
||||
|
||||
@retval EFI_SUCCESS Successfully get the machine type.
|
||||
@retval EFI_NOT_FOUND The file is not found.
|
||||
@retval EFI_LOAD_ERROR File is not a valid image file.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
BmGetImageHeader (
|
||||
IN EFI_HANDLE Device,
|
||||
IN CHAR16 *FileName,
|
||||
OUT EFI_IMAGE_DOS_HEADER *DosHeader,
|
||||
OUT EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr
|
||||
);
|
||||
|
||||
/**
|
||||
This routine adjust the memory information for different memory type and
|
||||
save them into the variables for next boot.
|
||||
**/
|
||||
VOID
|
||||
BmSetMemoryTypeInformationVariable (
|
||||
VOID
|
||||
);
|
||||
|
||||
/**
|
||||
Check whether there is a instance in BlockIoDevicePath, which contain multi device path
|
||||
instances, has the same partition node with HardDriveDevicePath device path
|
||||
|
||||
@param BlockIoDevicePath Multi device path instances which need to check
|
||||
@param HardDriveDevicePath A device path which starts with a hard drive media
|
||||
device path.
|
||||
|
||||
@retval TRUE There is a matched device path instance.
|
||||
@retval FALSE There is no matched device path instance.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
BmMatchPartitionDevicePathNode (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *BlockIoDevicePath,
|
||||
IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath
|
||||
);
|
||||
|
||||
/**
|
||||
Connect the specific Usb device which match the short form device path.
|
||||
|
||||
@param DevicePath 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 DevicePath is NULL pointer.
|
||||
DevicePath is not a USB device path.
|
||||
|
||||
@return EFI_SUCCESS Success to connect USB device
|
||||
@return EFI_NOT_FOUND Fail to find handle for USB controller to connect.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
BmConnectUsbShortFormDevicePath (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
);
|
||||
|
||||
/**
|
||||
Stop the hotkey processing.
|
||||
|
||||
@param Event Event pointer related to hotkey service.
|
||||
@param Context Context pass to this function.
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
BmStopHotkeyService (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
Set the variable and report the error through status code upon failure.
|
||||
|
||||
@param VariableName A Null-terminated string that is the name of the vendor's variable.
|
||||
Each VariableName is unique for each VendorGuid. VariableName must
|
||||
contain 1 or more characters. If VariableName is an empty string,
|
||||
then EFI_INVALID_PARAMETER is returned.
|
||||
@param VendorGuid A unique identifier for the vendor.
|
||||
@param Attributes Attributes bitmask to set for the variable.
|
||||
@param DataSize The size in bytes of the Data buffer. Unless the EFI_VARIABLE_APPEND_WRITE,
|
||||
EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS, or
|
||||
EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS attribute is set, a size of zero
|
||||
causes the variable to be deleted. When the EFI_VARIABLE_APPEND_WRITE attribute is
|
||||
set, then a SetVariable() call with a DataSize of zero will not cause any change to
|
||||
the variable value (the timestamp associated with the variable may be updated however
|
||||
even if no new data value is provided,see the description of the
|
||||
EFI_VARIABLE_AUTHENTICATION_2 descriptor below. In this case the DataSize will not
|
||||
be zero since the EFI_VARIABLE_AUTHENTICATION_2 descriptor will be populated).
|
||||
@param Data The contents for the variable.
|
||||
|
||||
@retval EFI_SUCCESS The firmware has successfully stored the variable and its data as
|
||||
defined by the Attributes.
|
||||
@retval EFI_INVALID_PARAMETER An invalid combination of attribute bits, name, and GUID was supplied, or the
|
||||
DataSize exceeds the maximum allowed.
|
||||
@retval EFI_INVALID_PARAMETER VariableName is an empty string.
|
||||
@retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
|
||||
@retval EFI_DEVICE_ERROR The variable could not be retrieved due to a hardware error.
|
||||
@retval EFI_WRITE_PROTECTED The variable in question is read-only.
|
||||
@retval EFI_WRITE_PROTECTED The variable in question cannot be deleted.
|
||||
@retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS
|
||||
or EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS being set, but the AuthInfo
|
||||
does NOT pass the validation check carried out by the firmware.
|
||||
|
||||
@retval EFI_NOT_FOUND The variable trying to be updated or deleted was not found.
|
||||
**/
|
||||
EFI_STATUS
|
||||
BmSetVariableAndReportStatusCodeOnError (
|
||||
IN CHAR16 *VariableName,
|
||||
IN EFI_GUID *VendorGuid,
|
||||
IN UINT32 Attributes,
|
||||
IN UINTN DataSize,
|
||||
IN VOID *Data
|
||||
);
|
||||
|
||||
/**
|
||||
Get the load option by its device path.
|
||||
|
||||
@param FilePath The device path pointing to a load option.
|
||||
It could be a short-form device path.
|
||||
@param FullPath Return the full device path of the load option after
|
||||
short-form device path expanding.
|
||||
Caller is responsible to free it.
|
||||
@param FileSize Return the load option size.
|
||||
|
||||
@return The load option buffer. Caller is responsible to free the memory.
|
||||
**/
|
||||
VOID *
|
||||
BmGetLoadOptionBuffer (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
|
||||
OUT EFI_DEVICE_PATH_PROTOCOL **FullPath,
|
||||
OUT UINTN *FileSize
|
||||
);
|
||||
|
||||
/**
|
||||
Return whether the PE header of the load option is valid or not.
|
||||
|
||||
@param[in] Type The load option type.
|
||||
@param[in] FileBuffer The PE file buffer of the load option.
|
||||
@param[in] FileSize The size of the load option file.
|
||||
|
||||
@retval TRUE The PE header of the load option is valid.
|
||||
@retval FALSE The PE header of the load option is not valid.
|
||||
**/
|
||||
BOOLEAN
|
||||
BmIsLoadOptionPeHeaderValid (
|
||||
IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE Type,
|
||||
IN VOID *FileBuffer,
|
||||
IN UINTN FileSize
|
||||
);
|
||||
|
||||
/**
|
||||
Function compares a device path data structure to that of all the nodes of a
|
||||
second device path instance.
|
||||
|
||||
@param Multi A pointer to a multi-instance device path data
|
||||
structure.
|
||||
@param Single A pointer to a single-instance device path data
|
||||
structure.
|
||||
|
||||
@retval TRUE If the Single device path is contained within Multi device path.
|
||||
@retval FALSE The Single device path is not match within Multi device path.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
BmMatchDevicePaths (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *Multi,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *Single
|
||||
);
|
||||
|
||||
/**
|
||||
Delete the instance in Multi which matches partly with Single instance
|
||||
|
||||
@param Multi A pointer to a multi-instance device path data
|
||||
structure.
|
||||
@param Single A pointer to a single-instance device path data
|
||||
structure.
|
||||
|
||||
@return This function will remove the device path instances in Multi which partly
|
||||
match with the Single, and return the result device path. If there is no
|
||||
remaining device path as a result, this function will return NULL.
|
||||
|
||||
**/
|
||||
EFI_DEVICE_PATH_PROTOCOL *
|
||||
BmDelPartMatchInstance (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *Multi,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *Single
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Return the index of the load option in the load option array.
|
||||
|
||||
The function consider two load options are equal when the
|
||||
OptionType, Attributes, Description, FilePath and OptionalData are equal.
|
||||
|
||||
@param Key Pointer to the load option to be found.
|
||||
@param Array Pointer to the array of load options to be found.
|
||||
@param Count Number of entries in the Array.
|
||||
|
||||
@retval -1 Key wasn't found in the Array.
|
||||
@retval 0 ~ Count-1 The index of the Key in the Array.
|
||||
**/
|
||||
INTN
|
||||
BmFindLoadOption (
|
||||
IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Key,
|
||||
IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Array,
|
||||
IN UINTN Count
|
||||
);
|
||||
|
||||
/**
|
||||
Repair all the controllers according to the Driver Health status queried.
|
||||
**/
|
||||
VOID
|
||||
BmRepairAllControllers (
|
||||
VOID
|
||||
);
|
||||
|
||||
/**
|
||||
Print the device path info.
|
||||
|
||||
@param DevicePath The device path need to print.
|
||||
**/
|
||||
VOID
|
||||
BmPrintDp (
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
);
|
||||
|
||||
#endif // _INTERNAL_BM_H_
|
||||
/** @file
|
||||
BDS library definition, include the file and data structure
|
||||
|
||||
Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _INTERNAL_BM_H_
|
||||
#define _INTERNAL_BM_H_
|
||||
|
||||
#include <PiDxe.h>
|
||||
|
||||
#include <IndustryStandard/Pci.h>
|
||||
#include <IndustryStandard/PeImage.h>
|
||||
#include <IndustryStandard/Atapi.h>
|
||||
#include <IndustryStandard/Scsi.h>
|
||||
|
||||
#include <Protocol/PciRootBridgeIo.h>
|
||||
#include <Protocol/BlockIo.h>
|
||||
#include <Protocol/LoadedImage.h>
|
||||
#include <Protocol/SimpleFileSystem.h>
|
||||
#include <Protocol/LoadFile.h>
|
||||
#include <Protocol/DevicePath.h>
|
||||
#include <Protocol/SimpleTextIn.h>
|
||||
#include <Protocol/SimpleTextInEx.h>
|
||||
#include <Protocol/SimpleTextOut.h>
|
||||
#include <Protocol/SimpleNetwork.h>
|
||||
#include <Protocol/FirmwareVolume2.h>
|
||||
#include <Protocol/PciIo.h>
|
||||
#include <Protocol/GraphicsOutput.h>
|
||||
#include <Protocol/UsbIo.h>
|
||||
#include <Protocol/DiskInfo.h>
|
||||
#include <Protocol/IdeControllerInit.h>
|
||||
#include <Protocol/BootLogo.h>
|
||||
#include <Protocol/DriverHealth.h>
|
||||
#include <Protocol/FormBrowser2.h>
|
||||
|
||||
#include <Guid/ZeroGuid.h>
|
||||
#include <Guid/MemoryTypeInformation.h>
|
||||
#include <Guid/FileInfo.h>
|
||||
#include <Guid/GlobalVariable.h>
|
||||
#include <Guid/Performance.h>
|
||||
#include <Guid/StatusCodeDataTypeVariable.h>
|
||||
|
||||
#include <Library/PrintLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/DxeServicesTableLib.h>
|
||||
#include <Library/HobLib.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/PerformanceLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/PeCoffGetEntryPointLib.h>
|
||||
#include <Library/UefiBootManagerLib.h>
|
||||
#include <Library/TimerLib.h>
|
||||
#include <Library/DxeServicesLib.h>
|
||||
#include <Library/ReportStatusCodeLib.h>
|
||||
#include <Library/CapsuleLib.h>
|
||||
#include <Library/PerformanceLib.h>
|
||||
#include <Library/HiiLib.h>
|
||||
|
||||
#if !defined (EFI_REMOVABLE_MEDIA_FILE_NAME)
|
||||
#if defined (MDE_CPU_EBC)
|
||||
//
|
||||
// Uefi specification only defines the default boot file name for IA32, X64
|
||||
// and IPF processor, so need define boot file name for EBC architecture here.
|
||||
//
|
||||
#define EFI_REMOVABLE_MEDIA_FILE_NAME L"\\EFI\\BOOT\\BOOTEBC.EFI"
|
||||
#else
|
||||
#error "Can not determine the default boot file name for unknown processor type!"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
BmAcpiFloppyBoot,
|
||||
BmHardwareDeviceBoot,
|
||||
BmMessageAtapiBoot,
|
||||
BmMessageSataBoot,
|
||||
BmMessageUsbBoot,
|
||||
BmMessageScsiBoot,
|
||||
BmMessageNetworkBoot,
|
||||
BmMiscBoot
|
||||
} BM_BOOT_TYPE;
|
||||
|
||||
typedef
|
||||
CHAR16 *
|
||||
(* BM_GET_BOOT_DESCRIPTION) (
|
||||
IN EFI_HANDLE Handle
|
||||
);
|
||||
|
||||
#define BM_OPTION_NAME_LEN sizeof ("SysPrep####")
|
||||
extern CHAR16 *mBmLoadOptionName[];
|
||||
|
||||
typedef
|
||||
VOID
|
||||
(*VARIABLE_VISITOR) (
|
||||
CHAR16 *Name,
|
||||
EFI_GUID *Guid,
|
||||
VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
Call Visitor function for each variable in variable storage.
|
||||
|
||||
@param Visitor Visitor function.
|
||||
@param Context The context passed to Visitor function.
|
||||
**/
|
||||
VOID
|
||||
ForEachVariable (
|
||||
VARIABLE_VISITOR Visitor,
|
||||
VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
Repair all the controllers according to the Driver Health status queried.
|
||||
**/
|
||||
VOID
|
||||
BmRepairAllControllers (
|
||||
VOID
|
||||
);
|
||||
|
||||
#define BM_HOTKEY_SIGNATURE SIGNATURE_32 ('b', 'm', 'h', 'k')
|
||||
typedef struct {
|
||||
UINT32 Signature;
|
||||
LIST_ENTRY Link;
|
||||
|
||||
BOOLEAN IsContinue;
|
||||
UINT16 BootOption;
|
||||
UINT8 CodeCount;
|
||||
UINT8 WaitingKey;
|
||||
EFI_KEY_DATA KeyData[3];
|
||||
} BM_HOTKEY;
|
||||
|
||||
#define BM_HOTKEY_FROM_LINK(a) CR (a, BM_HOTKEY, Link, BM_HOTKEY_SIGNATURE)
|
||||
|
||||
/**
|
||||
Get the image file buffer data and buffer size by its device path.
|
||||
|
||||
@param FilePath On input, a pointer to an allocated buffer containing the device
|
||||
path of the file.
|
||||
On output the pointer could be NULL when the function fails to
|
||||
load the boot option, or could point to an allocated buffer containing
|
||||
the device path of the file.
|
||||
It could be updated by either short-form device path expanding,
|
||||
or default boot file path appending.
|
||||
Caller is responsible to free it when it's non-NULL.
|
||||
@param FileSize A pointer to the size of the file buffer.
|
||||
|
||||
@retval NULL File is NULL, or FileSize is NULL. Or, the file can't be found.
|
||||
@retval other The file buffer. The caller is responsible to free the memory.
|
||||
**/
|
||||
VOID *
|
||||
BmLoadEfiBootOption (
|
||||
IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,
|
||||
OUT UINTN *FileSize
|
||||
);
|
||||
|
||||
/**
|
||||
Get the Option Number that wasn't used.
|
||||
|
||||
@param LoadOptionType Load option type.
|
||||
@param FreeOptionNumber To receive the minimal free option number.
|
||||
|
||||
@retval EFI_SUCCESS The option number is found
|
||||
@retval EFI_OUT_OF_RESOURCES There is no free option number that can be used.
|
||||
@retval EFI_INVALID_PARAMETER FreeOptionNumber is NULL
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
BmGetFreeOptionNumber (
|
||||
IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE LoadOptionType,
|
||||
OUT UINT16 *FreeOptionNumber
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
Writes performance data of booting into the allocated memory.
|
||||
OS can process these records.
|
||||
|
||||
@param Event The triggered event.
|
||||
@param Context Context for this event.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
BmWriteBootToOsPerformanceData (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Get the headers (dos, image, optional header) from an image
|
||||
|
||||
@param Device SimpleFileSystem device handle
|
||||
@param FileName File name for the image
|
||||
@param DosHeader Pointer to dos header
|
||||
@param Hdr The buffer in which to return the PE32, PE32+, or TE header.
|
||||
|
||||
@retval EFI_SUCCESS Successfully get the machine type.
|
||||
@retval EFI_NOT_FOUND The file is not found.
|
||||
@retval EFI_LOAD_ERROR File is not a valid image file.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
BmGetImageHeader (
|
||||
IN EFI_HANDLE Device,
|
||||
IN CHAR16 *FileName,
|
||||
OUT EFI_IMAGE_DOS_HEADER *DosHeader,
|
||||
OUT EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr
|
||||
);
|
||||
|
||||
/**
|
||||
This routine adjust the memory information for different memory type and
|
||||
save them into the variables for next boot.
|
||||
**/
|
||||
VOID
|
||||
BmSetMemoryTypeInformationVariable (
|
||||
VOID
|
||||
);
|
||||
|
||||
/**
|
||||
Check whether there is a instance in BlockIoDevicePath, which contain multi device path
|
||||
instances, has the same partition node with HardDriveDevicePath device path
|
||||
|
||||
@param BlockIoDevicePath Multi device path instances which need to check
|
||||
@param HardDriveDevicePath A device path which starts with a hard drive media
|
||||
device path.
|
||||
|
||||
@retval TRUE There is a matched device path instance.
|
||||
@retval FALSE There is no matched device path instance.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
BmMatchPartitionDevicePathNode (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *BlockIoDevicePath,
|
||||
IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath
|
||||
);
|
||||
|
||||
/**
|
||||
Connect the specific Usb device which match the short form device path.
|
||||
|
||||
@param DevicePath 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 DevicePath is NULL pointer.
|
||||
DevicePath is not a USB device path.
|
||||
|
||||
@return EFI_SUCCESS Success to connect USB device
|
||||
@return EFI_NOT_FOUND Fail to find handle for USB controller to connect.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
BmConnectUsbShortFormDevicePath (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
);
|
||||
|
||||
/**
|
||||
Stop the hotkey processing.
|
||||
|
||||
@param Event Event pointer related to hotkey service.
|
||||
@param Context Context pass to this function.
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
BmStopHotkeyService (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
Set the variable and report the error through status code upon failure.
|
||||
|
||||
@param VariableName A Null-terminated string that is the name of the vendor's variable.
|
||||
Each VariableName is unique for each VendorGuid. VariableName must
|
||||
contain 1 or more characters. If VariableName is an empty string,
|
||||
then EFI_INVALID_PARAMETER is returned.
|
||||
@param VendorGuid A unique identifier for the vendor.
|
||||
@param Attributes Attributes bitmask to set for the variable.
|
||||
@param DataSize The size in bytes of the Data buffer. Unless the EFI_VARIABLE_APPEND_WRITE,
|
||||
EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS, or
|
||||
EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS attribute is set, a size of zero
|
||||
causes the variable to be deleted. When the EFI_VARIABLE_APPEND_WRITE attribute is
|
||||
set, then a SetVariable() call with a DataSize of zero will not cause any change to
|
||||
the variable value (the timestamp associated with the variable may be updated however
|
||||
even if no new data value is provided,see the description of the
|
||||
EFI_VARIABLE_AUTHENTICATION_2 descriptor below. In this case the DataSize will not
|
||||
be zero since the EFI_VARIABLE_AUTHENTICATION_2 descriptor will be populated).
|
||||
@param Data The contents for the variable.
|
||||
|
||||
@retval EFI_SUCCESS The firmware has successfully stored the variable and its data as
|
||||
defined by the Attributes.
|
||||
@retval EFI_INVALID_PARAMETER An invalid combination of attribute bits, name, and GUID was supplied, or the
|
||||
DataSize exceeds the maximum allowed.
|
||||
@retval EFI_INVALID_PARAMETER VariableName is an empty string.
|
||||
@retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
|
||||
@retval EFI_DEVICE_ERROR The variable could not be retrieved due to a hardware error.
|
||||
@retval EFI_WRITE_PROTECTED The variable in question is read-only.
|
||||
@retval EFI_WRITE_PROTECTED The variable in question cannot be deleted.
|
||||
@retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS
|
||||
or EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS being set, but the AuthInfo
|
||||
does NOT pass the validation check carried out by the firmware.
|
||||
|
||||
@retval EFI_NOT_FOUND The variable trying to be updated or deleted was not found.
|
||||
**/
|
||||
EFI_STATUS
|
||||
BmSetVariableAndReportStatusCodeOnError (
|
||||
IN CHAR16 *VariableName,
|
||||
IN EFI_GUID *VendorGuid,
|
||||
IN UINT32 Attributes,
|
||||
IN UINTN DataSize,
|
||||
IN VOID *Data
|
||||
);
|
||||
|
||||
/**
|
||||
Get the load option by its device path.
|
||||
|
||||
@param FilePath The device path pointing to a load option.
|
||||
It could be a short-form device path.
|
||||
@param FullPath Return the full device path of the load option after
|
||||
short-form device path expanding.
|
||||
Caller is responsible to free it.
|
||||
@param FileSize Return the load option size.
|
||||
|
||||
@return The load option buffer. Caller is responsible to free the memory.
|
||||
**/
|
||||
VOID *
|
||||
BmGetLoadOptionBuffer (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
|
||||
OUT EFI_DEVICE_PATH_PROTOCOL **FullPath,
|
||||
OUT UINTN *FileSize
|
||||
);
|
||||
|
||||
/**
|
||||
Return whether the PE header of the load option is valid or not.
|
||||
|
||||
@param[in] Type The load option type.
|
||||
@param[in] FileBuffer The PE file buffer of the load option.
|
||||
@param[in] FileSize The size of the load option file.
|
||||
|
||||
@retval TRUE The PE header of the load option is valid.
|
||||
@retval FALSE The PE header of the load option is not valid.
|
||||
**/
|
||||
BOOLEAN
|
||||
BmIsLoadOptionPeHeaderValid (
|
||||
IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE Type,
|
||||
IN VOID *FileBuffer,
|
||||
IN UINTN FileSize
|
||||
);
|
||||
|
||||
/**
|
||||
Function compares a device path data structure to that of all the nodes of a
|
||||
second device path instance.
|
||||
|
||||
@param Multi A pointer to a multi-instance device path data
|
||||
structure.
|
||||
@param Single A pointer to a single-instance device path data
|
||||
structure.
|
||||
|
||||
@retval TRUE If the Single device path is contained within Multi device path.
|
||||
@retval FALSE The Single device path is not match within Multi device path.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
BmMatchDevicePaths (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *Multi,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *Single
|
||||
);
|
||||
|
||||
/**
|
||||
Delete the instance in Multi which matches partly with Single instance
|
||||
|
||||
@param Multi A pointer to a multi-instance device path data
|
||||
structure.
|
||||
@param Single A pointer to a single-instance device path data
|
||||
structure.
|
||||
|
||||
@return This function will remove the device path instances in Multi which partly
|
||||
match with the Single, and return the result device path. If there is no
|
||||
remaining device path as a result, this function will return NULL.
|
||||
|
||||
**/
|
||||
EFI_DEVICE_PATH_PROTOCOL *
|
||||
BmDelPartMatchInstance (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *Multi,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *Single
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Return the index of the load option in the load option array.
|
||||
|
||||
The function consider two load options are equal when the
|
||||
OptionType, Attributes, Description, FilePath and OptionalData are equal.
|
||||
|
||||
@param Key Pointer to the load option to be found.
|
||||
@param Array Pointer to the array of load options to be found.
|
||||
@param Count Number of entries in the Array.
|
||||
|
||||
@retval -1 Key wasn't found in the Array.
|
||||
@retval 0 ~ Count-1 The index of the Key in the Array.
|
||||
**/
|
||||
INTN
|
||||
BmFindLoadOption (
|
||||
IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Key,
|
||||
IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Array,
|
||||
IN UINTN Count
|
||||
);
|
||||
|
||||
/**
|
||||
Repair all the controllers according to the Driver Health status queried.
|
||||
**/
|
||||
VOID
|
||||
BmRepairAllControllers (
|
||||
VOID
|
||||
);
|
||||
|
||||
/**
|
||||
Print the device path info.
|
||||
|
||||
@param DevicePath The device path need to print.
|
||||
**/
|
||||
VOID
|
||||
BmPrintDp (
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
);
|
||||
|
||||
#endif // _INTERNAL_BM_H_
|
||||
|
@ -1,110 +1,110 @@
|
||||
## @file
|
||||
# Define and produce general Boot Manager related interfaces.
|
||||
#
|
||||
# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||
# 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 = UefiBootManagerLib
|
||||
FILE_GUID = 8D4752BC-595E-49a2-B4AF-F3F57B601DE9
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = UefiBootManagerLib|DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
#
|
||||
|
||||
[Sources]
|
||||
BmPerformance.c
|
||||
BmConnect.c
|
||||
BmMisc.c
|
||||
BmConsole.c
|
||||
BmBoot.c
|
||||
BmLoadOption.c
|
||||
BmHotkey.c
|
||||
BmDriverHealth.c
|
||||
InternalBm.h
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
HobLib
|
||||
PcdLib
|
||||
BaseLib
|
||||
UefiLib
|
||||
TimerLib
|
||||
DebugLib
|
||||
PrintLib
|
||||
BaseMemoryLib
|
||||
DevicePathLib
|
||||
PerformanceLib
|
||||
PeCoffGetEntryPointLib
|
||||
UefiBootServicesTableLib
|
||||
UefiRuntimeServicesTableLib
|
||||
DxeServicesTableLib
|
||||
MemoryAllocationLib
|
||||
DxeServicesLib
|
||||
ReportStatusCodeLib
|
||||
PerformanceLib
|
||||
HiiLib
|
||||
SortLib
|
||||
|
||||
[Guids]
|
||||
gEfiMemoryTypeInformationGuid ## CONSUMES ## GUID (The identifier of memory type information type in system table)
|
||||
## CONSUMES ## GUID HOB (The hob holding memory type information)
|
||||
gEfiGlobalVariableGuid ## SOMETIMES_PRODUCES ## Variable:L"BootCurrent" (The boot option of current boot)
|
||||
## SOMETIMES_CONSUMES ## Variable:L"BootXX" (Boot option variable)
|
||||
## CONSUMES ## Variable:L"Timeout" (The time out value in second of showing progress bar)
|
||||
## SOMETIMES_CONSUMES ## Variable:L"BootOrder" (The boot option array)
|
||||
## SOMETIMES_CONSUMES ## Variable:L"DriverOrder" (The driver order list)
|
||||
## SOMETIMES_CONSUMES ## Variable:L"ConIn" (The device path of console in device)
|
||||
## SOMETIMES_CONSUMES ## Variable:L"ConOut" (The device path of console out device)
|
||||
## SOMETIMES_CONSUMES ## Variable:L"ErrOut" (The device path of error out device)
|
||||
gEfiFileInfoGuid ## CONSUMES ## GUID
|
||||
gPerformanceProtocolGuid ## SOMETIMES_PRODUCES ## Variable:L"PerfDataMemAddr" (The ACPI address of performance data)
|
||||
gEdkiiStatusCodeDataTypeVariableGuid ## SOMETIMES_CONSUMES ## GUID
|
||||
gEfiDiskInfoAhciInterfaceGuid ## SOMETIMES_CONSUMES ## GUID
|
||||
gEfiDiskInfoIdeInterfaceGuid ## SOMETIMES_CONSUMES ## GUID
|
||||
gEfiDiskInfoScsiInterfaceGuid ## SOMETIMES_CONSUMES ## GUID
|
||||
gZeroGuid ## CONSUMES ## GUID
|
||||
|
||||
[Protocols]
|
||||
gEfiPciRootBridgeIoProtocolGuid ## CONSUMES
|
||||
gEfiSimpleFileSystemProtocolGuid ## CONSUMES
|
||||
gEfiLoadFileProtocolGuid ## CONSUMES
|
||||
gEfiSimpleTextOutProtocolGuid ## CONSUMES
|
||||
gEfiPciIoProtocolGuid ## CONSUMES
|
||||
gEfiLoadedImageProtocolGuid ## CONSUMES
|
||||
gEfiSimpleNetworkProtocolGuid ## CONSUMES
|
||||
gEfiSimpleTextInProtocolGuid ## CONSUMES
|
||||
gEfiBlockIoProtocolGuid ## CONSUMES
|
||||
gEfiFirmwareVolume2ProtocolGuid ## CONSUMES
|
||||
gEfiDevicePathProtocolGuid ## CONSUMES
|
||||
gEfiBootLogoProtocolGuid ## CONSUMES
|
||||
gEfiSimpleTextInputExProtocolGuid ## CONSUMES
|
||||
gEfiGraphicsOutputProtocolGuid ## SOMETIMES_CONSUMES
|
||||
gEfiUsbIoProtocolGuid ## SOMETIMES_CONSUMES
|
||||
gEfiDiskInfoProtocolGuid ## SOMETIMES_CONSUMES
|
||||
gEfiDriverHealthProtocolGuid ## SOMETIMES_CONSUMES
|
||||
|
||||
[Pcd]
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeOsLoaderLoad ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeOsLoaderStart ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdDriverHealthConfigureForm ## SOMETIMES_CONSUMES
|
||||
|
||||
## @file
|
||||
# Define and produce general Boot Manager related interfaces.
|
||||
#
|
||||
# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||
# 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 = UefiBootManagerLib
|
||||
FILE_GUID = 8D4752BC-595E-49a2-B4AF-F3F57B601DE9
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = UefiBootManagerLib|DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
#
|
||||
|
||||
[Sources]
|
||||
BmPerformance.c
|
||||
BmConnect.c
|
||||
BmMisc.c
|
||||
BmConsole.c
|
||||
BmBoot.c
|
||||
BmLoadOption.c
|
||||
BmHotkey.c
|
||||
BmDriverHealth.c
|
||||
InternalBm.h
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
HobLib
|
||||
PcdLib
|
||||
BaseLib
|
||||
UefiLib
|
||||
TimerLib
|
||||
DebugLib
|
||||
PrintLib
|
||||
BaseMemoryLib
|
||||
DevicePathLib
|
||||
PerformanceLib
|
||||
PeCoffGetEntryPointLib
|
||||
UefiBootServicesTableLib
|
||||
UefiRuntimeServicesTableLib
|
||||
DxeServicesTableLib
|
||||
MemoryAllocationLib
|
||||
DxeServicesLib
|
||||
ReportStatusCodeLib
|
||||
PerformanceLib
|
||||
HiiLib
|
||||
SortLib
|
||||
|
||||
[Guids]
|
||||
gEfiMemoryTypeInformationGuid ## CONSUMES ## GUID (The identifier of memory type information type in system table)
|
||||
## CONSUMES ## GUID HOB (The hob holding memory type information)
|
||||
gEfiGlobalVariableGuid ## SOMETIMES_PRODUCES ## Variable:L"BootCurrent" (The boot option of current boot)
|
||||
## SOMETIMES_CONSUMES ## Variable:L"BootXX" (Boot option variable)
|
||||
## CONSUMES ## Variable:L"Timeout" (The time out value in second of showing progress bar)
|
||||
## SOMETIMES_CONSUMES ## Variable:L"BootOrder" (The boot option array)
|
||||
## SOMETIMES_CONSUMES ## Variable:L"DriverOrder" (The driver order list)
|
||||
## SOMETIMES_CONSUMES ## Variable:L"ConIn" (The device path of console in device)
|
||||
## SOMETIMES_CONSUMES ## Variable:L"ConOut" (The device path of console out device)
|
||||
## SOMETIMES_CONSUMES ## Variable:L"ErrOut" (The device path of error out device)
|
||||
gEfiFileInfoGuid ## CONSUMES ## GUID
|
||||
gPerformanceProtocolGuid ## SOMETIMES_PRODUCES ## Variable:L"PerfDataMemAddr" (The ACPI address of performance data)
|
||||
gEdkiiStatusCodeDataTypeVariableGuid ## SOMETIMES_CONSUMES ## GUID
|
||||
gEfiDiskInfoAhciInterfaceGuid ## SOMETIMES_CONSUMES ## GUID
|
||||
gEfiDiskInfoIdeInterfaceGuid ## SOMETIMES_CONSUMES ## GUID
|
||||
gEfiDiskInfoScsiInterfaceGuid ## SOMETIMES_CONSUMES ## GUID
|
||||
gZeroGuid ## CONSUMES ## GUID
|
||||
|
||||
[Protocols]
|
||||
gEfiPciRootBridgeIoProtocolGuid ## CONSUMES
|
||||
gEfiSimpleFileSystemProtocolGuid ## CONSUMES
|
||||
gEfiLoadFileProtocolGuid ## CONSUMES
|
||||
gEfiSimpleTextOutProtocolGuid ## CONSUMES
|
||||
gEfiPciIoProtocolGuid ## CONSUMES
|
||||
gEfiLoadedImageProtocolGuid ## CONSUMES
|
||||
gEfiSimpleNetworkProtocolGuid ## CONSUMES
|
||||
gEfiSimpleTextInProtocolGuid ## CONSUMES
|
||||
gEfiBlockIoProtocolGuid ## CONSUMES
|
||||
gEfiFirmwareVolume2ProtocolGuid ## CONSUMES
|
||||
gEfiDevicePathProtocolGuid ## CONSUMES
|
||||
gEfiBootLogoProtocolGuid ## CONSUMES
|
||||
gEfiSimpleTextInputExProtocolGuid ## CONSUMES
|
||||
gEfiGraphicsOutputProtocolGuid ## SOMETIMES_CONSUMES
|
||||
gEfiUsbIoProtocolGuid ## SOMETIMES_CONSUMES
|
||||
gEfiDiskInfoProtocolGuid ## SOMETIMES_CONSUMES
|
||||
gEfiDriverHealthProtocolGuid ## SOMETIMES_CONSUMES
|
||||
|
||||
[Pcd]
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeOsLoaderLoad ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeOsLoaderStart ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdDriverHealthConfigureForm ## SOMETIMES_CONSUMES
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user