mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-27 07:34:06 +02:00
Replaced by Y:\work\MdeModulePkg\Library\GenericBdsLib\GenericBdsLib.inf
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4772 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
725a03bd4a
commit
0a9e9295d9
File diff suppressed because it is too large
Load Diff
@ -1,359 +0,0 @@
|
|||||||
/*++
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2007, Intel Corporation
|
|
||||||
All rights reserved. This program and the accompanying materials
|
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
|
||||||
http://opensource.org/licenses/bsd-license.php
|
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
||||||
|
|
||||||
Module Name:
|
|
||||||
|
|
||||||
BdsConnect.c
|
|
||||||
|
|
||||||
Abstract:
|
|
||||||
|
|
||||||
BDS Lib functions which relate with connect the device
|
|
||||||
|
|
||||||
--*/
|
|
||||||
|
|
||||||
#include <EdkGenericBdsLibInternal.h>
|
|
||||||
|
|
||||||
VOID
|
|
||||||
BdsLibConnectAll (
|
|
||||||
VOID
|
|
||||||
)
|
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
|
|
||||||
This function will connect all the system driver to controller
|
|
||||||
first, and then special connect the default console, this make
|
|
||||||
sure all the system controller avialbe and the platform default
|
|
||||||
console connected.
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
None
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
None
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Connect the platform console first
|
|
||||||
//
|
|
||||||
BdsLibConnectAllDefaultConsoles ();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Generic way to connect all the drivers
|
|
||||||
//
|
|
||||||
BdsLibConnectAllDriversToAllControllers ();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Here we have the assumption that we have already had
|
|
||||||
// platform default console
|
|
||||||
//
|
|
||||||
BdsLibConnectAllDefaultConsoles ();
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID
|
|
||||||
BdsLibGenericConnectAll (
|
|
||||||
VOID
|
|
||||||
)
|
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
|
|
||||||
This function will connect all the system drivers to all controllers
|
|
||||||
first, and then connect all the console devices the system current
|
|
||||||
have. After this we should get all the device work and console avariable
|
|
||||||
if the system have console device.
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
None
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
None
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Most generic way to connect all the drivers
|
|
||||||
//
|
|
||||||
BdsLibConnectAllDriversToAllControllers ();
|
|
||||||
BdsLibConnectAllConsoles ();
|
|
||||||
}
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
BdsLibConnectDevicePath (
|
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect
|
|
||||||
)
|
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
This function will create all handles associate with every device
|
|
||||||
path node. If the handle associate with one device path node can not
|
|
||||||
be created success, then still give one chance to do the dispatch,
|
|
||||||
which load the missing drivers if possible.
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
DevicePathToConnect - The device path which will be connected, it can
|
|
||||||
be a multi-instance device path
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
EFI_SUCCESS - All handles associate with every device path
|
|
||||||
node have been created
|
|
||||||
|
|
||||||
EFI_OUT_OF_RESOURCES - There is no resource to create new handles
|
|
||||||
|
|
||||||
EFI_NOT_FOUND - Create the handle associate with one device
|
|
||||||
path node failed
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
|
||||||
EFI_STATUS Status;
|
|
||||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
|
||||||
EFI_DEVICE_PATH_PROTOCOL *CopyOfDevicePath;
|
|
||||||
EFI_DEVICE_PATH_PROTOCOL *Instance;
|
|
||||||
EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath;
|
|
||||||
EFI_DEVICE_PATH_PROTOCOL *Next;
|
|
||||||
EFI_HANDLE Handle;
|
|
||||||
EFI_HANDLE PreviousHandle;
|
|
||||||
UINTN Size;
|
|
||||||
|
|
||||||
if (DevicePathToConnect == NULL) {
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
DevicePath = DuplicateDevicePath (DevicePathToConnect);
|
|
||||||
CopyOfDevicePath = DevicePath;
|
|
||||||
if (DevicePath == NULL) {
|
|
||||||
return EFI_OUT_OF_RESOURCES;
|
|
||||||
}
|
|
||||||
|
|
||||||
do {
|
|
||||||
//
|
|
||||||
// The outer loop handles multi instance device paths.
|
|
||||||
// Only console variables contain multiple instance device paths.
|
|
||||||
//
|
|
||||||
// After this call DevicePath points to the next Instance
|
|
||||||
//
|
|
||||||
Instance = GetNextDevicePathInstance (&DevicePath, &Size);
|
|
||||||
Next = Instance;
|
|
||||||
while (!IsDevicePathEndType (Next)) {
|
|
||||||
Next = NextDevicePathNode (Next);
|
|
||||||
}
|
|
||||||
|
|
||||||
SetDevicePathEndNode (Next);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Start the real work of connect with RemainingDevicePath
|
|
||||||
//
|
|
||||||
PreviousHandle = NULL;
|
|
||||||
do {
|
|
||||||
//
|
|
||||||
// Find the handle that best matches the Device Path. If it is only a
|
|
||||||
// partial match the remaining part of the device path is returned in
|
|
||||||
// RemainingDevicePath.
|
|
||||||
//
|
|
||||||
RemainingDevicePath = Instance;
|
|
||||||
Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &Handle);
|
|
||||||
|
|
||||||
if (!EFI_ERROR (Status)) {
|
|
||||||
if (Handle == PreviousHandle) {
|
|
||||||
//
|
|
||||||
// If no forward progress is made try invoking the Dispatcher.
|
|
||||||
// A new FV may have been added to the system an new drivers
|
|
||||||
// may now be found.
|
|
||||||
// Status == EFI_SUCCESS means a driver was dispatched
|
|
||||||
// Status == EFI_NOT_FOUND means no new drivers were dispatched
|
|
||||||
//
|
|
||||||
Status = gDS->Dispatch ();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!EFI_ERROR (Status)) {
|
|
||||||
PreviousHandle = Handle;
|
|
||||||
//
|
|
||||||
// Connect all drivers that apply to Handle and RemainingDevicePath,
|
|
||||||
// the Recursive flag is FALSE so only one level will be expanded.
|
|
||||||
//
|
|
||||||
// Do not check the connect status here, if the connect controller fail,
|
|
||||||
// then still give the chance to do dispatch, because partial
|
|
||||||
// RemainingDevicepath may be in the new FV
|
|
||||||
//
|
|
||||||
// 1. If the connect fail, RemainingDevicepath and handle will not
|
|
||||||
// change, so next time will do the dispatch, then dispatch's status
|
|
||||||
// will take effect
|
|
||||||
// 2. If the connect success, the RemainingDevicepath and handle will
|
|
||||||
// change, then avoid the dispatch, we have chance to continue the
|
|
||||||
// next connection
|
|
||||||
//
|
|
||||||
gBS->ConnectController (Handle, NULL, RemainingDevicePath, FALSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Loop until RemainingDevicePath is an empty device path
|
|
||||||
//
|
|
||||||
} while (!EFI_ERROR (Status) && !IsDevicePathEnd (RemainingDevicePath));
|
|
||||||
|
|
||||||
} while (DevicePath != NULL);
|
|
||||||
|
|
||||||
if (CopyOfDevicePath != NULL) {
|
|
||||||
FreePool (CopyOfDevicePath);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// All handle with DevicePath exists in the handle database
|
|
||||||
//
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
BdsLibConnectAllEfi (
|
|
||||||
VOID
|
|
||||||
)
|
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
|
|
||||||
This function will connect all current system handles recursively. The
|
|
||||||
connection will finish until every handle's child handle created if it have.
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
None
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
EFI_SUCCESS - All handles and it's child handle have been connected
|
|
||||||
|
|
||||||
EFI_STATUS - Return the status of gBS->LocateHandleBuffer().
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
|
||||||
EFI_STATUS Status;
|
|
||||||
UINTN HandleCount;
|
|
||||||
EFI_HANDLE *HandleBuffer;
|
|
||||||
UINTN Index;
|
|
||||||
|
|
||||||
Status = gBS->LocateHandleBuffer (
|
|
||||||
AllHandles,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
&HandleCount,
|
|
||||||
&HandleBuffer
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Index = 0; Index < HandleCount; Index++) {
|
|
||||||
Status = gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
FreePool (HandleBuffer);
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
BdsLibDisconnectAllEfi (
|
|
||||||
VOID
|
|
||||||
)
|
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
|
|
||||||
This function will disconnect all current system handles. The disconnection
|
|
||||||
will finish until every handle have been disconnected.
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
None
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
EFI_SUCCESS - All handles have been disconnected
|
|
||||||
|
|
||||||
EFI_STATUS - Return the status of gBS->LocateHandleBuffer().
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
|
||||||
EFI_STATUS Status;
|
|
||||||
UINTN HandleCount;
|
|
||||||
EFI_HANDLE *HandleBuffer;
|
|
||||||
UINTN Index;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Disconnect all
|
|
||||||
//
|
|
||||||
Status = gBS->LocateHandleBuffer (
|
|
||||||
AllHandles,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
&HandleCount,
|
|
||||||
&HandleBuffer
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Index = 0; Index < HandleCount; Index++) {
|
|
||||||
Status = gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
FreePool (HandleBuffer);
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID
|
|
||||||
BdsLibConnectAllDriversToAllControllers (
|
|
||||||
VOID
|
|
||||||
)
|
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
|
|
||||||
Connects all drivers to all controllers.
|
|
||||||
This function make sure all the current system driver will manage
|
|
||||||
the correspoinding controllers if have. And at the same time, make
|
|
||||||
sure all the system controllers have driver to manage it if have.
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
None
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
None
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
|
||||||
EFI_STATUS Status;
|
|
||||||
|
|
||||||
do {
|
|
||||||
//
|
|
||||||
// Connect All UEFI 2.0 drivers following UEFI 2.0 algorithm
|
|
||||||
//
|
|
||||||
BdsLibConnectAllEfi ();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Check to see if it's possible to dispatch an more DXE drivers.
|
|
||||||
// The BdsLibConnectAllEfi () may have made new DXE drivers show up.
|
|
||||||
// If anything is Dispatched Status == EFI_SUCCESS and we will try
|
|
||||||
// the connect again.
|
|
||||||
//
|
|
||||||
Status = gDS->Dispatch ();
|
|
||||||
|
|
||||||
} while (!EFI_ERROR (Status));
|
|
||||||
|
|
||||||
}
|
|
@ -1,396 +0,0 @@
|
|||||||
/*++
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2007, Intel Corporation
|
|
||||||
All rights reserved. This program and the accompanying materials
|
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
|
||||||
http://opensource.org/licenses/bsd-license.php
|
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
||||||
|
|
||||||
Module Name:
|
|
||||||
|
|
||||||
BdsConsole.c
|
|
||||||
|
|
||||||
Abstract:
|
|
||||||
|
|
||||||
BDS Lib functions which contain all the code to connect console device
|
|
||||||
|
|
||||||
--*/
|
|
||||||
|
|
||||||
#include <EdkGenericBdsLibInternal.h>
|
|
||||||
|
|
||||||
BOOLEAN
|
|
||||||
IsNvNeed (
|
|
||||||
IN CHAR16 *ConVarName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
CHAR16 *Ptr;
|
|
||||||
|
|
||||||
Ptr = ConVarName;
|
|
||||||
|
|
||||||
//
|
|
||||||
// If the variable includes "Dev" at last, we consider
|
|
||||||
// it does not support NV attribute.
|
|
||||||
//
|
|
||||||
while (*Ptr) {
|
|
||||||
Ptr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((*(Ptr - 3) == 'D') && (*(Ptr - 2) == 'e') && (*(Ptr - 1) == 'v')) {
|
|
||||||
return FALSE;
|
|
||||||
} else {
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
BdsLibUpdateConsoleVariable (
|
|
||||||
IN CHAR16 *ConVarName,
|
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL *CustomizedConDevicePath,
|
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL *ExclusiveDevicePath
|
|
||||||
)
|
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
|
|
||||||
This function update console variable based on ConVarName, it can
|
|
||||||
add or remove one specific console device path from the variable
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
ConVarName - Console related variable name, ConIn, ConOut, ErrOut.
|
|
||||||
|
|
||||||
CustomizedConDevicePath - The console device path which will be added to
|
|
||||||
the console variable ConVarName, this parameter
|
|
||||||
can not be multi-instance.
|
|
||||||
|
|
||||||
ExclusiveDevicePath - The console device path which will be removed
|
|
||||||
from the console variable ConVarName, this
|
|
||||||
parameter can not be multi-instance.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
EFI_UNSUPPORTED - Add or remove the same device path.
|
|
||||||
|
|
||||||
EFI_SUCCESS - Success add or remove the device path from
|
|
||||||
the console variable.
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
|
||||||
EFI_STATUS Status;
|
|
||||||
EFI_DEVICE_PATH_PROTOCOL *VarConsole;
|
|
||||||
UINTN DevicePathSize;
|
|
||||||
EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
|
|
||||||
EFI_DEVICE_PATH_PROTOCOL *TempNewDevicePath;
|
|
||||||
UINT32 Attributes;
|
|
||||||
|
|
||||||
VarConsole = NULL;
|
|
||||||
DevicePathSize = 0;
|
|
||||||
Status = EFI_UNSUPPORTED;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Notes: check the device path point, here should check
|
|
||||||
// with compare memory
|
|
||||||
//
|
|
||||||
if (CustomizedConDevicePath == ExclusiveDevicePath) {
|
|
||||||
return EFI_UNSUPPORTED;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Delete the ExclusiveDevicePath from current default console
|
|
||||||
//
|
|
||||||
VarConsole = BdsLibGetVariableAndSize (
|
|
||||||
ConVarName,
|
|
||||||
&gEfiGlobalVariableGuid,
|
|
||||||
&DevicePathSize
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Initialize NewDevicePath
|
|
||||||
//
|
|
||||||
NewDevicePath = VarConsole;
|
|
||||||
|
|
||||||
//
|
|
||||||
// If ExclusiveDevicePath is even the part of the instance in VarConsole, delete it.
|
|
||||||
// In the end, NewDevicePath is the final device path.
|
|
||||||
//
|
|
||||||
if (ExclusiveDevicePath != NULL && VarConsole != NULL) {
|
|
||||||
NewDevicePath = BdsLibDelPartMatchInstance (VarConsole, ExclusiveDevicePath);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Try to append customized device path to NewDevicePath.
|
|
||||||
//
|
|
||||||
if (CustomizedConDevicePath != NULL) {
|
|
||||||
if (!BdsLibMatchDevicePaths (NewDevicePath, CustomizedConDevicePath)) {
|
|
||||||
//
|
|
||||||
// Check if there is part of CustomizedConDevicePath in NewDevicePath, delete it.
|
|
||||||
//
|
|
||||||
NewDevicePath = BdsLibDelPartMatchInstance (NewDevicePath, CustomizedConDevicePath);
|
|
||||||
//
|
|
||||||
// In the first check, the default console variable will be null,
|
|
||||||
// just append current customized device path
|
|
||||||
//
|
|
||||||
TempNewDevicePath = NewDevicePath;
|
|
||||||
NewDevicePath = AppendDevicePathInstance (NewDevicePath, CustomizedConDevicePath);
|
|
||||||
BdsLibSafeFreePool(TempNewDevicePath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// The attribute for ConInDev, ConOutDev and ErrOutDev does not include NV.
|
|
||||||
//
|
|
||||||
if (IsNvNeed(ConVarName)) {
|
|
||||||
//
|
|
||||||
// ConVarName has NV attribute.
|
|
||||||
//
|
|
||||||
Attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE;
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// ConVarName does not have NV attribute.
|
|
||||||
//
|
|
||||||
Attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Finally, Update the variable of the default console by NewDevicePath
|
|
||||||
//
|
|
||||||
gRT->SetVariable (
|
|
||||||
ConVarName,
|
|
||||||
&gEfiGlobalVariableGuid,
|
|
||||||
Attributes,
|
|
||||||
GetDevicePathSize (NewDevicePath),
|
|
||||||
NewDevicePath
|
|
||||||
);
|
|
||||||
|
|
||||||
if (VarConsole == NewDevicePath) {
|
|
||||||
BdsLibSafeFreePool(VarConsole);
|
|
||||||
} else {
|
|
||||||
BdsLibSafeFreePool(VarConsole);
|
|
||||||
BdsLibSafeFreePool(NewDevicePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
BdsLibConnectConsoleVariable (
|
|
||||||
IN CHAR16 *ConVarName
|
|
||||||
)
|
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
|
|
||||||
Connect the console device base on the variable ConVarName, if
|
|
||||||
device path of the ConVarName is multi-instance device path, if
|
|
||||||
anyone of the instances is connected success, then this function
|
|
||||||
will return success.
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
ConVarName - Console related variable name, ConIn, ConOut, ErrOut.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
EFI_NOT_FOUND - There is not any console devices connected success
|
|
||||||
|
|
||||||
EFI_SUCCESS - Success connect any one instance of the console
|
|
||||||
device path base on the variable ConVarName.
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
|
||||||
EFI_STATUS Status;
|
|
||||||
EFI_DEVICE_PATH_PROTOCOL *StartDevicePath;
|
|
||||||
UINTN VariableSize;
|
|
||||||
EFI_DEVICE_PATH_PROTOCOL *Instance;
|
|
||||||
EFI_DEVICE_PATH_PROTOCOL *Next;
|
|
||||||
EFI_DEVICE_PATH_PROTOCOL *CopyOfDevicePath;
|
|
||||||
UINTN Size;
|
|
||||||
BOOLEAN DeviceExist;
|
|
||||||
|
|
||||||
Status = EFI_SUCCESS;
|
|
||||||
DeviceExist = FALSE;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Check if the console variable exist
|
|
||||||
//
|
|
||||||
StartDevicePath = BdsLibGetVariableAndSize (
|
|
||||||
ConVarName,
|
|
||||||
&gEfiGlobalVariableGuid,
|
|
||||||
&VariableSize
|
|
||||||
);
|
|
||||||
if (StartDevicePath == NULL) {
|
|
||||||
return EFI_UNSUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
CopyOfDevicePath = StartDevicePath;
|
|
||||||
do {
|
|
||||||
//
|
|
||||||
// Check every instance of the console variable
|
|
||||||
//
|
|
||||||
Instance = GetNextDevicePathInstance (&CopyOfDevicePath, &Size);
|
|
||||||
Next = Instance;
|
|
||||||
while (!IsDevicePathEndType (Next)) {
|
|
||||||
Next = NextDevicePathNode (Next);
|
|
||||||
}
|
|
||||||
|
|
||||||
SetDevicePathEndNode (Next);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Connect the instance device path
|
|
||||||
//
|
|
||||||
Status = BdsLibConnectDevicePath (Instance);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
//
|
|
||||||
// Delete the instance from the console varialbe
|
|
||||||
//
|
|
||||||
BdsLibUpdateConsoleVariable (ConVarName, NULL, Instance);
|
|
||||||
} else {
|
|
||||||
DeviceExist = TRUE;
|
|
||||||
}
|
|
||||||
BdsLibSafeFreePool(Instance);
|
|
||||||
} while (CopyOfDevicePath != NULL);
|
|
||||||
|
|
||||||
FreePool (StartDevicePath);
|
|
||||||
|
|
||||||
if (DeviceExist == FALSE) {
|
|
||||||
return EFI_NOT_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID
|
|
||||||
BdsLibConnectAllConsoles (
|
|
||||||
VOID
|
|
||||||
)
|
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
|
|
||||||
This function will search every simpletxt devive in current system,
|
|
||||||
and make every simpletxt device as pertantial console device.
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
None
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
None
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
|
||||||
EFI_STATUS Status;
|
|
||||||
UINTN Index;
|
|
||||||
EFI_DEVICE_PATH_PROTOCOL *ConDevicePath;
|
|
||||||
UINTN HandleCount;
|
|
||||||
EFI_HANDLE *HandleBuffer;
|
|
||||||
|
|
||||||
Index = 0;
|
|
||||||
HandleCount = 0;
|
|
||||||
HandleBuffer = NULL;
|
|
||||||
ConDevicePath = NULL;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Update all the console varables
|
|
||||||
//
|
|
||||||
Status = gBS->LocateHandleBuffer (
|
|
||||||
ByProtocol,
|
|
||||||
&gEfiSimpleTextInProtocolGuid,
|
|
||||||
NULL,
|
|
||||||
&HandleCount,
|
|
||||||
&HandleBuffer
|
|
||||||
);
|
|
||||||
for (Index = 0; Index < HandleCount; Index++) {
|
|
||||||
Status = gBS->HandleProtocol (
|
|
||||||
HandleBuffer[Index],
|
|
||||||
&gEfiDevicePathProtocolGuid,
|
|
||||||
(VOID **) &ConDevicePath
|
|
||||||
);
|
|
||||||
BdsLibUpdateConsoleVariable (L"ConIn", ConDevicePath, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
BdsLibSafeFreePool(HandleBuffer);
|
|
||||||
|
|
||||||
Status = gBS->LocateHandleBuffer (
|
|
||||||
ByProtocol,
|
|
||||||
&gEfiSimpleTextOutProtocolGuid,
|
|
||||||
NULL,
|
|
||||||
&HandleCount,
|
|
||||||
&HandleBuffer
|
|
||||||
);
|
|
||||||
for (Index = 0; Index < HandleCount; Index++) {
|
|
||||||
Status = gBS->HandleProtocol (
|
|
||||||
HandleBuffer[Index],
|
|
||||||
&gEfiDevicePathProtocolGuid,
|
|
||||||
(VOID **) &ConDevicePath
|
|
||||||
);
|
|
||||||
BdsLibUpdateConsoleVariable (L"ConOut", ConDevicePath, NULL);
|
|
||||||
BdsLibUpdateConsoleVariable (L"ErrOut", ConDevicePath, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
BdsLibSafeFreePool(HandleBuffer);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Connect all console variables
|
|
||||||
//
|
|
||||||
BdsLibConnectAllDefaultConsoles ();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
BdsLibConnectAllDefaultConsoles (
|
|
||||||
VOID
|
|
||||||
)
|
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
|
|
||||||
This function will connect console device base on the console
|
|
||||||
device variable ConIn, ConOut and ErrOut.
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
None
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
EFI_SUCCESS - At least one of the ConIn and ConOut device have
|
|
||||||
been connected success.
|
|
||||||
|
|
||||||
EFI_STATUS - Return the status of BdsLibConnectConsoleVariable ().
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
|
||||||
EFI_STATUS Status;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Connect all default console variables
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// Because possibly the platform is legacy free, in such case,
|
|
||||||
// ConIn devices (Serial Port and PS2 Keyboard ) does not exist,
|
|
||||||
// so we need not check the status.
|
|
||||||
//
|
|
||||||
BdsLibConnectConsoleVariable (L"ConIn");
|
|
||||||
|
|
||||||
//
|
|
||||||
// It seems impossible not to have any ConOut device on platform,
|
|
||||||
// so we check the status here.
|
|
||||||
//
|
|
||||||
Status = BdsLibConnectConsoleVariable (L"ConOut");
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Special treat the err out device, becaues the null
|
|
||||||
// err out var is legal.
|
|
||||||
//
|
|
||||||
BdsLibConnectConsoleVariable (L"ErrOut");
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,89 +0,0 @@
|
|||||||
#/** @file
|
|
||||||
# EDK Generic BDS Common APIs Library Instance.
|
|
||||||
#
|
|
||||||
# The library instance provides common library routines help in
|
|
||||||
# performance measurement, device path debug print, boot device selections,
|
|
||||||
# boot device connection, console supports in BDS phase and boot from boot
|
|
||||||
# device.
|
|
||||||
# Copyright (c) 2006 - 2007, Intel Corporation.
|
|
||||||
#
|
|
||||||
# All rights reserved. This program and the accompanying materials
|
|
||||||
# are licensed and made available under the terms and conditions of the BSD License
|
|
||||||
# which accompanies this distribution. The full text of the license may be found at
|
|
||||||
# http://opensource.org/licenses/bsd-license.php
|
|
||||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#**/
|
|
||||||
|
|
||||||
[Defines]
|
|
||||||
INF_VERSION = 0x00010005
|
|
||||||
BASE_NAME = EdkGenericBdsLib
|
|
||||||
FILE_GUID = 1ec995b2-d15b-44f6-abd2-050ea7dd37d2
|
|
||||||
MODULE_TYPE = DXE_DRIVER
|
|
||||||
VERSION_STRING = 1.0
|
|
||||||
LIBRARY_CLASS = EdkGenericBdsLib|DXE_DRIVER
|
|
||||||
EDK_RELEASE_VERSION = 0x00020000
|
|
||||||
EFI_SPECIFICATION_VERSION = 0x00020000
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# The following information is for reference only and not required by the build tools.
|
|
||||||
#
|
|
||||||
# VALID_ARCHITECTURES = IA32
|
|
||||||
#
|
|
||||||
|
|
||||||
[Sources.common]
|
|
||||||
BdsMisc.c
|
|
||||||
Performance.c
|
|
||||||
DevicePath.c
|
|
||||||
BdsConnect.c
|
|
||||||
BdsConsole.c
|
|
||||||
BdsBoot.c
|
|
||||||
EdkGenericBdsLibInternal.h
|
|
||||||
|
|
||||||
[Packages]
|
|
||||||
MdePkg/MdePkg.dec
|
|
||||||
MdeModulePkg/MdeModulePkg.dec
|
|
||||||
IntelFrameworkPkg/IntelFrameworkPkg.dec
|
|
||||||
Nt32Pkg/Nt32Pkg.dec
|
|
||||||
|
|
||||||
[LibraryClasses]
|
|
||||||
PeCoffLib
|
|
||||||
PerformanceLib
|
|
||||||
DevicePathLib
|
|
||||||
UefiRuntimeServicesTableLib
|
|
||||||
UefiBootServicesTableLib
|
|
||||||
MemoryAllocationLib
|
|
||||||
BaseMemoryLib
|
|
||||||
HobLib
|
|
||||||
PrintLib
|
|
||||||
DebugLib
|
|
||||||
DxeServicesTableLib
|
|
||||||
UefiLib
|
|
||||||
BaseLib
|
|
||||||
PcdLib
|
|
||||||
|
|
||||||
[Guids]
|
|
||||||
gEfiGlobalVariableGuid # ALWAYS_CONSUMED
|
|
||||||
gEfiGenericPlatformVariableGuid # ALWAYS_CONSUMED
|
|
||||||
gEfiShellFileGuid # ALWAYS_CONSUMED
|
|
||||||
|
|
||||||
[Protocols]
|
|
||||||
gEfiSimpleFileSystemProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
|
|
||||||
gEfiLoadFileProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
|
|
||||||
gEfiFormBrowserProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
|
||||||
gEfiDriverBindingProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
|
|
||||||
gEfiBlockIoProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
|
||||||
gEfiLegacyBiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
|
||||||
gEfiCpuArchProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
|
||||||
gEfiDevicePathProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
|
||||||
gEfiSimpleNetworkProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
|
|
||||||
gEfiSimpleTextInProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
|
|
||||||
gEfiSimpleTextOutProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
|
|
||||||
gEfiFirmwareVolumeProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
|
|
||||||
gEfiLoadedImageProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
|
||||||
|
|
||||||
[FixedPcd.common]
|
|
||||||
gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultTimeout
|
|
@ -1,144 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
||||||
<MsaHeader>
|
|
||||||
<ModuleName>EdkGenericBdsLib</ModuleName>
|
|
||||||
<ModuleType>DXE_DRIVER</ModuleType>
|
|
||||||
<GuidValue>1ec995b2-d15b-44f6-abd2-050ea7dd37d2</GuidValue>
|
|
||||||
<Version>1.0</Version>
|
|
||||||
<Abstract>EDK Generic BDS Common APIs Library Instance.</Abstract>
|
|
||||||
<Description>The library instance provides common library routines help in
|
|
||||||
performance measurement, device path debug print, boot device selections,
|
|
||||||
boot device connection, console supports in BDS phase and boot from boot
|
|
||||||
device.</Description>
|
|
||||||
<Copyright>Copyright (c) 2006 - 2007, Intel Corporation.</Copyright>
|
|
||||||
<License>All rights reserved. This program and the accompanying materials
|
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
|
||||||
http://opensource.org/licenses/bsd-license.php
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>
|
|
||||||
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
|
|
||||||
</MsaHeader>
|
|
||||||
<ModuleDefinitions>
|
|
||||||
<SupportedArchitectures>IA32</SupportedArchitectures>
|
|
||||||
<BinaryModule>false</BinaryModule>
|
|
||||||
<OutputFileBasename>EdkGenericBdsLib</OutputFileBasename>
|
|
||||||
</ModuleDefinitions>
|
|
||||||
<LibraryClassDefinitions>
|
|
||||||
<LibraryClass Usage="ALWAYS_PRODUCED" SupModuleList="DXE_DRIVER">
|
|
||||||
<Keyword>EdkGenericBdsLib</Keyword>
|
|
||||||
</LibraryClass>
|
|
||||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
|
||||||
<Keyword>BaseLib</Keyword>
|
|
||||||
</LibraryClass>
|
|
||||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
|
||||||
<Keyword>UefiLib</Keyword>
|
|
||||||
</LibraryClass>
|
|
||||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
|
||||||
<Keyword>DxeServicesTableLib</Keyword>
|
|
||||||
</LibraryClass>
|
|
||||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
|
||||||
<Keyword>DebugLib</Keyword>
|
|
||||||
</LibraryClass>
|
|
||||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
|
||||||
<Keyword>PrintLib</Keyword>
|
|
||||||
</LibraryClass>
|
|
||||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
|
||||||
<Keyword>HobLib</Keyword>
|
|
||||||
</LibraryClass>
|
|
||||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
|
||||||
<Keyword>BaseMemoryLib</Keyword>
|
|
||||||
</LibraryClass>
|
|
||||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
|
||||||
<Keyword>MemoryAllocationLib</Keyword>
|
|
||||||
</LibraryClass>
|
|
||||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
|
||||||
<Keyword>UefiBootServicesTableLib</Keyword>
|
|
||||||
</LibraryClass>
|
|
||||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
|
||||||
<Keyword>UefiRuntimeServicesTableLib</Keyword>
|
|
||||||
</LibraryClass>
|
|
||||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
|
||||||
<Keyword>DevicePathLib</Keyword>
|
|
||||||
</LibraryClass>
|
|
||||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
|
||||||
<Keyword>PerformanceLib</Keyword>
|
|
||||||
</LibraryClass>
|
|
||||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
|
||||||
<Keyword>PeCoffLib</Keyword>
|
|
||||||
</LibraryClass>
|
|
||||||
</LibraryClassDefinitions>
|
|
||||||
<SourceFiles>
|
|
||||||
<Filename>BdsBoot.c</Filename>
|
|
||||||
<Filename>BdsConsole.c</Filename>
|
|
||||||
<Filename>BdsConnect.c</Filename>
|
|
||||||
<Filename>DevicePath.c</Filename>
|
|
||||||
<Filename>Performance.h</Filename>
|
|
||||||
<Filename>Performance.c</Filename>
|
|
||||||
<Filename>BdsMisc.c</Filename>
|
|
||||||
</SourceFiles>
|
|
||||||
<PackageDependencies>
|
|
||||||
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
|
||||||
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
|
|
||||||
<Package PackageGuid="0fb2aa2d-10d5-40a5-a9dc-060c12a4a3f3"/>
|
|
||||||
</PackageDependencies>
|
|
||||||
<Protocols>
|
|
||||||
<Protocol Usage="ALWAYS_CONSUMED">
|
|
||||||
<ProtocolCName>gEfiLoadedImageProtocolGuid</ProtocolCName>
|
|
||||||
</Protocol>
|
|
||||||
<Protocol Usage="SOMETIMES_CONSUMED">
|
|
||||||
<ProtocolCName>gEfiFirmwareVolumeProtocolGuid</ProtocolCName>
|
|
||||||
</Protocol>
|
|
||||||
<Protocol Usage="SOMETIMES_CONSUMED">
|
|
||||||
<ProtocolCName>gEfiAcpiS3SaveProtocolGuid</ProtocolCName>
|
|
||||||
</Protocol>
|
|
||||||
<Protocol Usage="SOMETIMES_CONSUMED">
|
|
||||||
<ProtocolCName>gEfiSimpleTextOutProtocolGuid</ProtocolCName>
|
|
||||||
</Protocol>
|
|
||||||
<Protocol Usage="SOMETIMES_CONSUMED">
|
|
||||||
<ProtocolCName>gEfiSimpleTextInProtocolGuid</ProtocolCName>
|
|
||||||
</Protocol>
|
|
||||||
<Protocol Usage="SOMETIMES_CONSUMED">
|
|
||||||
<ProtocolCName>gEfiSimpleNetworkProtocolGuid</ProtocolCName>
|
|
||||||
</Protocol>
|
|
||||||
<Protocol Usage="ALWAYS_CONSUMED">
|
|
||||||
<ProtocolCName>gEfiDevicePathProtocolGuid</ProtocolCName>
|
|
||||||
</Protocol>
|
|
||||||
<Protocol Usage="ALWAYS_CONSUMED">
|
|
||||||
<ProtocolCName>gEfiCpuArchProtocolGuid</ProtocolCName>
|
|
||||||
</Protocol>
|
|
||||||
<Protocol Usage="ALWAYS_CONSUMED">
|
|
||||||
<ProtocolCName>gEfiLegacyBiosProtocolGuid</ProtocolCName>
|
|
||||||
</Protocol>
|
|
||||||
<Protocol Usage="ALWAYS_CONSUMED">
|
|
||||||
<ProtocolCName>gEfiBlockIoProtocolGuid</ProtocolCName>
|
|
||||||
</Protocol>
|
|
||||||
<Protocol Usage="SOMETIMES_CONSUMED">
|
|
||||||
<ProtocolCName>gEfiDriverBindingProtocolGuid</ProtocolCName>
|
|
||||||
</Protocol>
|
|
||||||
<Protocol Usage="ALWAYS_CONSUMED">
|
|
||||||
<ProtocolCName>gEfiFormBrowserProtocolGuid</ProtocolCName>
|
|
||||||
</Protocol>
|
|
||||||
<Protocol Usage="SOMETIMES_CONSUMED">
|
|
||||||
<ProtocolCName>gEfiLoadFileProtocolGuid</ProtocolCName>
|
|
||||||
</Protocol>
|
|
||||||
<Protocol Usage="SOMETIMES_CONSUMED">
|
|
||||||
<ProtocolCName>gEfiSimpleFileSystemProtocolGuid</ProtocolCName>
|
|
||||||
</Protocol>
|
|
||||||
</Protocols>
|
|
||||||
<Guids>
|
|
||||||
<GuidCNames Usage="ALWAYS_CONSUMED">
|
|
||||||
<GuidCName>gEfiShellFileGuid</GuidCName>
|
|
||||||
</GuidCNames>
|
|
||||||
<GuidCNames Usage="ALWAYS_CONSUMED">
|
|
||||||
<GuidCName>gEfiGenericPlatformVariableGuid</GuidCName>
|
|
||||||
</GuidCNames>
|
|
||||||
<GuidCNames Usage="ALWAYS_CONSUMED">
|
|
||||||
<GuidCName>gEfiGlobalVariableGuid</GuidCName>
|
|
||||||
</GuidCNames>
|
|
||||||
</Guids>
|
|
||||||
<Externs>
|
|
||||||
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
|
|
||||||
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
|
|
||||||
</Externs>
|
|
||||||
</ModuleSurfaceArea>
|
|
@ -1,96 +0,0 @@
|
|||||||
/**@file
|
|
||||||
Common header file shared by all source files.
|
|
||||||
|
|
||||||
This file includes package header files, library classes and protocol, PPI & GUID definitions.
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2007, Intel Corporation.
|
|
||||||
All rights reserved. This program and the accompanying materials
|
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
|
||||||
http://opensource.org/licenses/bsd-license.php
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
||||||
**/
|
|
||||||
|
|
||||||
#ifndef __EDK_GENERIC_BDS_LIB_INTERNAL_H_
|
|
||||||
#define __EDK_GENERIC_BDS_LIB_INTERNAL_H_
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// The package level header files this module uses
|
|
||||||
//
|
|
||||||
#include <PiDxe.h>
|
|
||||||
#include <WinNtDxe.h>
|
|
||||||
#include <Protocol/Cpu.h>
|
|
||||||
#include <Protocol/SimpleTextIn.h>
|
|
||||||
#include <Protocol/SimpleTextOut.h>
|
|
||||||
#include <Protocol/LoadedImage.h>
|
|
||||||
#include <Protocol/SimpleFileSystem.h>
|
|
||||||
#include <Protocol/BlockIo.h>
|
|
||||||
#include <Protocol/SimpleNetwork.h>
|
|
||||||
#include <Protocol/FrameworkFormBrowser.h>
|
|
||||||
#include <Protocol/LegacyBios.h>
|
|
||||||
#include <Protocol/DriverBinding.h>
|
|
||||||
#include <Protocol/LoadFile.h>
|
|
||||||
#include <Protocol/DevicePath.h>
|
|
||||||
#include <Protocol/FirmwareVolume2.h>
|
|
||||||
#include <Protocol/Performance.h>
|
|
||||||
#include <Protocol/WinNtIo.h>
|
|
||||||
#include <Guid/PcAnsi.h>
|
|
||||||
#include <Guid/GlobalVariable.h>
|
|
||||||
#include <Guid/GenericPlatformVariable.h>
|
|
||||||
#include <Guid/ShellFile.h>
|
|
||||||
#include <Library/EdkGenericBdsLib.h>
|
|
||||||
#include <Library/BaseLib.h>
|
|
||||||
#include <Library/UefiLib.h>
|
|
||||||
#include <Library/DxeServicesTableLib.h>
|
|
||||||
#include <Library/DebugLib.h>
|
|
||||||
#include <Library/PrintLib.h>
|
|
||||||
#include <Library/HobLib.h>
|
|
||||||
#include <Library/BaseMemoryLib.h>
|
|
||||||
#include <Library/MemoryAllocationLib.h>
|
|
||||||
#include <Library/UefiBootServicesTableLib.h>
|
|
||||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
|
||||||
#include <Library/DevicePathLib.h>
|
|
||||||
#include <Library/PerformanceLib.h>
|
|
||||||
#include <Library/PeCoffLib.h>
|
|
||||||
#include <Library/PcdLib.h>
|
|
||||||
|
|
||||||
|
|
||||||
#define PERF_TOKEN_LENGTH 28
|
|
||||||
#define PERF_PEI_ENTRY_MAX_NUM 50
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
CHAR8 Token[PERF_TOKEN_LENGTH];
|
|
||||||
UINT32 Duration;
|
|
||||||
} PERF_DATA;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
UINT64 BootToOs;
|
|
||||||
UINT64 S3Resume;
|
|
||||||
UINT32 S3EntryNum;
|
|
||||||
PERF_DATA S3Entry[PERF_PEI_ENTRY_MAX_NUM];
|
|
||||||
UINT64 CpuFreq;
|
|
||||||
UINT64 BDSRaw;
|
|
||||||
UINT32 Count;
|
|
||||||
UINT32 Signiture;
|
|
||||||
} PERF_HEADER;
|
|
||||||
|
|
||||||
VOID
|
|
||||||
WriteBootToOsPerformanceData (
|
|
||||||
VOID
|
|
||||||
);
|
|
||||||
|
|
||||||
VOID
|
|
||||||
ClearDebugRegisters (
|
|
||||||
VOID
|
|
||||||
);
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
UpdateFvFileDevicePath (
|
|
||||||
IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,
|
|
||||||
IN EFI_GUID *FileGuid
|
|
||||||
);
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,386 +0,0 @@
|
|||||||
/*++
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2007, Intel Corporation
|
|
||||||
All rights reserved. This program and the accompanying materials
|
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
|
||||||
http://opensource.org/licenses/bsd-license.php
|
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
||||||
|
|
||||||
Module Name:
|
|
||||||
|
|
||||||
Performance.c
|
|
||||||
|
|
||||||
Abstract:
|
|
||||||
|
|
||||||
This file include the file which can help to get the system
|
|
||||||
performance, all the function will only include if the performance
|
|
||||||
switch is set.
|
|
||||||
|
|
||||||
--*/
|
|
||||||
|
|
||||||
#include <EdkGenericBdsLibInternal.h>
|
|
||||||
|
|
||||||
|
|
||||||
STATIC
|
|
||||||
VOID
|
|
||||||
GetShortPdbFileName (
|
|
||||||
CHAR8 *PdbFileName,
|
|
||||||
CHAR8 *GaugeString
|
|
||||||
)
|
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
|
||||||
UINTN Index;
|
|
||||||
UINTN Index1;
|
|
||||||
UINTN StartIndex;
|
|
||||||
UINTN EndIndex;
|
|
||||||
|
|
||||||
if (PdbFileName == NULL) {
|
|
||||||
AsciiStrCpy (GaugeString, " ");
|
|
||||||
} else {
|
|
||||||
StartIndex = 0;
|
|
||||||
for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++)
|
|
||||||
;
|
|
||||||
|
|
||||||
for (Index = 0; PdbFileName[Index] != 0; Index++) {
|
|
||||||
if (PdbFileName[Index] == '\\') {
|
|
||||||
StartIndex = Index + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PdbFileName[Index] == '.') {
|
|
||||||
EndIndex = Index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Index1 = 0;
|
|
||||||
for (Index = StartIndex; Index < EndIndex; Index++) {
|
|
||||||
GaugeString[Index1] = PdbFileName[Index];
|
|
||||||
Index1++;
|
|
||||||
if (Index1 == PERF_TOKEN_LENGTH - 1) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GaugeString[Index1] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
STATIC
|
|
||||||
CHAR8 *
|
|
||||||
GetPdbPath (
|
|
||||||
VOID *ImageBase
|
|
||||||
)
|
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
|
|
||||||
Located PDB path name in PE image
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
ImageBase - base of PE to search
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
Pointer into image at offset of PDB file name if PDB file name is found,
|
|
||||||
Otherwise a pointer to an empty string.
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
|
||||||
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
|
|
||||||
|
|
||||||
ZeroMem (&ImageContext, sizeof (ImageContext));
|
|
||||||
ImageContext.Handle = ImageBase;
|
|
||||||
ImageContext.ImageRead = PeCoffLoaderImageReadFromMemory;
|
|
||||||
|
|
||||||
PeCoffLoaderGetImageInfo (&ImageContext);
|
|
||||||
|
|
||||||
return ImageContext.PdbPointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
STATIC
|
|
||||||
VOID
|
|
||||||
GetNameFromHandle (
|
|
||||||
IN EFI_HANDLE Handle,
|
|
||||||
OUT CHAR8 *GaugeString
|
|
||||||
)
|
|
||||||
{
|
|
||||||
EFI_STATUS Status;
|
|
||||||
EFI_LOADED_IMAGE_PROTOCOL *Image;
|
|
||||||
CHAR8 *PdbFileName;
|
|
||||||
EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
|
|
||||||
|
|
||||||
AsciiStrCpy (GaugeString, " ");
|
|
||||||
|
|
||||||
//
|
|
||||||
// Get handle name from image protocol
|
|
||||||
//
|
|
||||||
Status = gBS->HandleProtocol (
|
|
||||||
Handle,
|
|
||||||
&gEfiLoadedImageProtocolGuid,
|
|
||||||
&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,
|
|
||||||
&Image
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
PdbFileName = GetPdbPath (Image->ImageBase);
|
|
||||||
|
|
||||||
if (PdbFileName != NULL) {
|
|
||||||
GetShortPdbFileName (PdbFileName, GaugeString);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VOID
|
|
||||||
WriteBootToOsPerformanceData (
|
|
||||||
VOID
|
|
||||||
)
|
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
|
|
||||||
Allocates a block of memory and writes performance data of booting to OS into it.
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
None
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
None
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
|
||||||
EFI_STATUS Status;
|
|
||||||
EFI_CPU_ARCH_PROTOCOL *Cpu;
|
|
||||||
EFI_PHYSICAL_ADDRESS mAcpiLowMemoryBase;
|
|
||||||
UINT32 mAcpiLowMemoryLength;
|
|
||||||
UINT32 LimitCount;
|
|
||||||
PERF_HEADER mPerfHeader;
|
|
||||||
PERF_DATA mPerfData;
|
|
||||||
EFI_HANDLE *Handles;
|
|
||||||
UINTN NoHandles;
|
|
||||||
CHAR8 GaugeString[PERF_TOKEN_LENGTH];
|
|
||||||
UINT8 *Ptr;
|
|
||||||
UINT32 mIndex;
|
|
||||||
UINT64 Ticker;
|
|
||||||
UINT64 Freq;
|
|
||||||
UINT32 Duration;
|
|
||||||
UINT64 CurrentTicker;
|
|
||||||
UINT64 TimerPeriod;
|
|
||||||
UINTN LogEntryKey;
|
|
||||||
CONST VOID *Handle;
|
|
||||||
CONST CHAR8 *Token;
|
|
||||||
CONST CHAR8 *Module;
|
|
||||||
UINT64 StartTicker;
|
|
||||||
UINT64 EndTicker;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Retrive time stamp count as early as possilbe
|
|
||||||
//
|
|
||||||
Ticker = AsmReadTsc ();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Allocate a block of memory that contain performance data to OS
|
|
||||||
//
|
|
||||||
mAcpiLowMemoryBase = 0xFFFFFFFF;
|
|
||||||
Status = gBS->AllocatePages (
|
|
||||||
AllocateMaxAddress,
|
|
||||||
EfiReservedMemoryType,
|
|
||||||
4,
|
|
||||||
&mAcpiLowMemoryBase
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
mAcpiLowMemoryLength = EFI_PAGES_TO_SIZE(4);
|
|
||||||
|
|
||||||
Ptr = (UINT8 *) ((UINT32) mAcpiLowMemoryBase + sizeof (PERF_HEADER));
|
|
||||||
LimitCount = (mAcpiLowMemoryLength - sizeof (PERF_HEADER)) / sizeof (PERF_DATA);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Initialize performance data structure
|
|
||||||
//
|
|
||||||
ZeroMem (&mPerfHeader, sizeof (PERF_HEADER));
|
|
||||||
|
|
||||||
//
|
|
||||||
// Get CPU frequency
|
|
||||||
//
|
|
||||||
Status = gBS->LocateProtocol (
|
|
||||||
&gEfiCpuArchProtocolGuid,
|
|
||||||
NULL,
|
|
||||||
&Cpu
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
gBS->FreePages (mAcpiLowMemoryBase, 4);
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Get Cpu Frequency
|
|
||||||
//
|
|
||||||
Status = Cpu->GetTimerValue (Cpu, 0, &(CurrentTicker), &TimerPeriod);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
gBS->FreePages (mAcpiLowMemoryBase, 4);
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
Freq = DivU64x32 (1000000000000, (UINTN) TimerPeriod);
|
|
||||||
|
|
||||||
mPerfHeader.CpuFreq = Freq;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Record BDS raw performance data
|
|
||||||
//
|
|
||||||
mPerfHeader.BDSRaw = Ticker;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Put Detailed performance data into memory
|
|
||||||
//
|
|
||||||
Handles = NULL;
|
|
||||||
Status = gBS->LocateHandleBuffer (
|
|
||||||
AllHandles,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
&NoHandles,
|
|
||||||
&Handles
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
gBS->FreePages (mAcpiLowMemoryBase, 4);
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Get DXE drivers performance
|
|
||||||
//
|
|
||||||
for (mIndex = 0; mIndex < NoHandles; mIndex++) {
|
|
||||||
Ticker = 0;
|
|
||||||
LogEntryKey = 0;
|
|
||||||
while ((LogEntryKey = GetPerformanceMeasurement (
|
|
||||||
LogEntryKey,
|
|
||||||
&Handle,
|
|
||||||
&Token,
|
|
||||||
&Module,
|
|
||||||
&StartTicker,
|
|
||||||
&EndTicker)) != 0) {
|
|
||||||
if ((Handle == Handles[mIndex]) && (StartTicker < EndTicker)) {
|
|
||||||
Ticker += (EndTicker - StartTicker);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Duration = (UINT32) DivU64x32 (
|
|
||||||
Ticker,
|
|
||||||
(UINT32) Freq
|
|
||||||
);
|
|
||||||
|
|
||||||
if (Duration > 0) {
|
|
||||||
ZeroMem (&mPerfData, sizeof (PERF_DATA));
|
|
||||||
|
|
||||||
GetNameFromHandle (Handles[mIndex], GaugeString);
|
|
||||||
|
|
||||||
AsciiStrCpy (mPerfData.Token, GaugeString);
|
|
||||||
mPerfData.Duration = Duration;
|
|
||||||
|
|
||||||
CopyMem (Ptr, &mPerfData, sizeof (PERF_DATA));
|
|
||||||
Ptr += sizeof (PERF_DATA);
|
|
||||||
|
|
||||||
mPerfHeader.Count++;
|
|
||||||
if (mPerfHeader.Count == LimitCount) {
|
|
||||||
goto Done;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FreePool (Handles);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Get inserted performance data
|
|
||||||
//
|
|
||||||
LogEntryKey = 0;
|
|
||||||
while ((LogEntryKey = GetPerformanceMeasurement (
|
|
||||||
LogEntryKey,
|
|
||||||
&Handle,
|
|
||||||
&Token,
|
|
||||||
&Module,
|
|
||||||
&StartTicker,
|
|
||||||
&EndTicker)) != 0) {
|
|
||||||
if ((Handle == NULL) && (StartTicker <= EndTicker)) {
|
|
||||||
|
|
||||||
ZeroMem (&mPerfData, sizeof (PERF_DATA));
|
|
||||||
|
|
||||||
AsciiStrnCpy (mPerfData.Token, Token, DXE_PERFORMANCE_STRING_SIZE);
|
|
||||||
mPerfData.Duration = (UINT32) DivU64x32 (
|
|
||||||
EndTicker - StartTicker,
|
|
||||||
(UINT32) Freq
|
|
||||||
);
|
|
||||||
|
|
||||||
CopyMem (Ptr, &mPerfData, sizeof (PERF_DATA));
|
|
||||||
Ptr += sizeof (PERF_DATA);
|
|
||||||
|
|
||||||
mPerfHeader.Count++;
|
|
||||||
if (mPerfHeader.Count == LimitCount) {
|
|
||||||
goto Done;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Done:
|
|
||||||
|
|
||||||
mPerfHeader.Signiture = 0x66726550;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Put performance data to memory
|
|
||||||
//
|
|
||||||
CopyMem (
|
|
||||||
(UINT32 *) (UINT32) mAcpiLowMemoryBase,
|
|
||||||
&mPerfHeader,
|
|
||||||
sizeof (PERF_HEADER)
|
|
||||||
);
|
|
||||||
|
|
||||||
gRT->SetVariable (
|
|
||||||
L"PerfDataMemAddr",
|
|
||||||
&gEfiGenericPlatformVariableGuid,
|
|
||||||
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
|
||||||
sizeof (UINT32),
|
|
||||||
(VOID *) &mAcpiLowMemoryBase
|
|
||||||
);
|
|
||||||
|
|
||||||
return ;
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user