mirror of https://github.com/acidanthera/audk.git
Clean up BDS lib to remove assembly files, remove R8Lib.h & R8Lib.c by applying Mde Lib.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5020 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
fd6a62f3bf
commit
897f0eee20
File diff suppressed because it is too large
Load Diff
|
@ -1,422 +1,408 @@
|
||||||
/** @file
|
/** @file
|
||||||
|
BDS Lib functions which relate with connect the device
|
||||||
Copyright (c) 2004 - 2007, Intel Corporation
|
|
||||||
All rights reserved. This program and the accompanying materials
|
Copyright (c) 2004 - 2008, Intel Corporation. <BR>
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
All rights reserved. This program and the accompanying materials
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
http://opensource.org/licenses/bsd-license.php
|
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.
|
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
|
|
||||||
|
#include "InternalBdsLib.h"
|
||||||
Abstract:
|
|
||||||
|
|
||||||
BDS Lib functions which relate with connect the device
|
/**
|
||||||
|
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.
|
||||||
#include "InternalBdsLib.h"
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
/**
|
EFIAPI
|
||||||
This function will connect all the system driver to controller
|
BdsLibConnectAll (
|
||||||
first, and then special connect the default console, this make
|
VOID
|
||||||
sure all the system controller avialbe and the platform default
|
)
|
||||||
console connected.
|
{
|
||||||
|
//
|
||||||
None
|
// Connect the platform console first
|
||||||
|
//
|
||||||
@return None
|
BdsLibConnectAllDefaultConsoles ();
|
||||||
|
|
||||||
**/
|
//
|
||||||
VOID
|
// Generic way to connect all the drivers
|
||||||
BdsLibConnectAll (
|
//
|
||||||
VOID
|
BdsLibConnectAllDriversToAllControllers ();
|
||||||
)
|
|
||||||
{
|
//
|
||||||
//
|
// Here we have the assumption that we have already had
|
||||||
// Connect the platform console first
|
// platform default console
|
||||||
//
|
//
|
||||||
BdsLibConnectAllDefaultConsoles ();
|
BdsLibConnectAllDefaultConsoles ();
|
||||||
|
}
|
||||||
//
|
|
||||||
// Generic way to connect all the drivers
|
|
||||||
//
|
/**
|
||||||
BdsLibConnectAllDriversToAllControllers ();
|
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
|
||||||
// Here we have the assumption that we have already had
|
if the system have console device.
|
||||||
// platform default console
|
|
||||||
//
|
None
|
||||||
BdsLibConnectAllDefaultConsoles ();
|
|
||||||
}
|
@return None
|
||||||
|
|
||||||
|
**/
|
||||||
/**
|
VOID
|
||||||
This function will connect all the system drivers to all controllers
|
BdsLibGenericConnectAll (
|
||||||
first, and then connect all the console devices the system current
|
VOID
|
||||||
have. After this we should get all the device work and console avariable
|
)
|
||||||
if the system have console device.
|
{
|
||||||
|
//
|
||||||
None
|
// Most generic way to connect all the drivers
|
||||||
|
//
|
||||||
@return None
|
BdsLibConnectAllDriversToAllControllers ();
|
||||||
|
BdsLibConnectAllConsoles ();
|
||||||
**/
|
}
|
||||||
VOID
|
|
||||||
BdsLibGenericConnectAll (
|
|
||||||
VOID
|
/**
|
||||||
)
|
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,
|
||||||
// Most generic way to connect all the drivers
|
which load the missing drivers if possible.
|
||||||
//
|
|
||||||
BdsLibConnectAllDriversToAllControllers ();
|
@param DevicePathToConnect The device path which will be connected, it can be
|
||||||
BdsLibConnectAllConsoles ();
|
a multi-instance device path
|
||||||
}
|
|
||||||
|
@retval EFI_SUCCESS All handles associate with every device path node
|
||||||
|
have been created
|
||||||
/**
|
@retval EFI_OUT_OF_RESOURCES There is no resource to create new handles
|
||||||
This function will create all handles associate with every device
|
@retval EFI_NOT_FOUND Create the handle associate with one device path
|
||||||
path node. If the handle associate with one device path node can not
|
node failed
|
||||||
be created success, then still give one chance to do the dispatch,
|
|
||||||
which load the missing drivers if possible.
|
**/
|
||||||
|
EFI_STATUS
|
||||||
@param DevicePathToConnect The device path which will be connected, it can be
|
EFIAPI
|
||||||
a multi-instance device path
|
BdsLibConnectDevicePath (
|
||||||
|
IN EFI_DEVICE_PATH_PROTOCOL *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
|
EFI_STATUS Status;
|
||||||
@retval EFI_NOT_FOUND Create the handle associate with one device path
|
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||||
node failed
|
EFI_DEVICE_PATH_PROTOCOL *CopyOfDevicePath;
|
||||||
|
EFI_DEVICE_PATH_PROTOCOL *Instance;
|
||||||
**/
|
EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath;
|
||||||
EFI_STATUS
|
EFI_DEVICE_PATH_PROTOCOL *Next;
|
||||||
BdsLibConnectDevicePath (
|
EFI_HANDLE Handle;
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect
|
EFI_HANDLE PreviousHandle;
|
||||||
)
|
UINTN Size;
|
||||||
{
|
|
||||||
EFI_STATUS Status;
|
if (DevicePathToConnect == NULL) {
|
||||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
return EFI_SUCCESS;
|
||||||
EFI_DEVICE_PATH_PROTOCOL *CopyOfDevicePath;
|
}
|
||||||
EFI_DEVICE_PATH_PROTOCOL *Instance;
|
|
||||||
EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath;
|
DevicePath = DuplicateDevicePath (DevicePathToConnect);
|
||||||
EFI_DEVICE_PATH_PROTOCOL *Next;
|
CopyOfDevicePath = DevicePath;
|
||||||
EFI_HANDLE Handle;
|
if (DevicePath == NULL) {
|
||||||
EFI_HANDLE PreviousHandle;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
UINTN Size;
|
}
|
||||||
|
|
||||||
if (DevicePathToConnect == NULL) {
|
do {
|
||||||
return EFI_SUCCESS;
|
//
|
||||||
}
|
// The outer loop handles multi instance device paths.
|
||||||
|
// Only console variables contain multiple instance device paths.
|
||||||
DevicePath = DuplicateDevicePath (DevicePathToConnect);
|
//
|
||||||
CopyOfDevicePath = DevicePath;
|
// After this call DevicePath points to the next Instance
|
||||||
if (DevicePath == NULL) {
|
//
|
||||||
return EFI_OUT_OF_RESOURCES;
|
Instance = GetNextDevicePathInstance (&DevicePath, &Size);
|
||||||
}
|
Next = Instance;
|
||||||
|
while (!IsDevicePathEndType (Next)) {
|
||||||
do {
|
Next = NextDevicePathNode (Next);
|
||||||
//
|
}
|
||||||
// The outer loop handles multi instance device paths.
|
|
||||||
// Only console variables contain multiple instance device paths.
|
SetDevicePathEndNode (Next);
|
||||||
//
|
|
||||||
// After this call DevicePath points to the next Instance
|
//
|
||||||
//
|
// Start the real work of connect with RemainingDevicePath
|
||||||
Instance = GetNextDevicePathInstance (&DevicePath, &Size);
|
//
|
||||||
Next = Instance;
|
PreviousHandle = NULL;
|
||||||
while (!IsDevicePathEndType (Next)) {
|
do {
|
||||||
Next = NextDevicePathNode (Next);
|
//
|
||||||
}
|
// 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
|
||||||
SetDevicePathEndNode (Next);
|
// RemainingDevicePath.
|
||||||
|
//
|
||||||
//
|
RemainingDevicePath = Instance;
|
||||||
// Start the real work of connect with RemainingDevicePath
|
Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &Handle);
|
||||||
//
|
|
||||||
PreviousHandle = NULL;
|
if (!EFI_ERROR (Status)) {
|
||||||
do {
|
if (Handle == PreviousHandle) {
|
||||||
//
|
//
|
||||||
// Find the handle that best matches the Device Path. If it is only a
|
// If no forward progress is made try invoking the Dispatcher.
|
||||||
// partial match the remaining part of the device path is returned in
|
// A new FV may have been added to the system an new drivers
|
||||||
// RemainingDevicePath.
|
// may now be found.
|
||||||
//
|
// Status == EFI_SUCCESS means a driver was dispatched
|
||||||
RemainingDevicePath = Instance;
|
// Status == EFI_NOT_FOUND means no new drivers were dispatched
|
||||||
Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &Handle);
|
//
|
||||||
|
Status = gDS->Dispatch ();
|
||||||
if (!EFI_ERROR (Status)) {
|
}
|
||||||
if (Handle == PreviousHandle) {
|
|
||||||
//
|
if (!EFI_ERROR (Status)) {
|
||||||
// If no forward progress is made try invoking the Dispatcher.
|
PreviousHandle = Handle;
|
||||||
// A new FV may have been added to the system an new drivers
|
//
|
||||||
// may now be found.
|
// Connect all drivers that apply to Handle and RemainingDevicePath,
|
||||||
// Status == EFI_SUCCESS means a driver was dispatched
|
// the Recursive flag is FALSE so only one level will be expanded.
|
||||||
// Status == EFI_NOT_FOUND means no new drivers were dispatched
|
//
|
||||||
//
|
// Do not check the connect status here, if the connect controller fail,
|
||||||
Status = gDS->Dispatch ();
|
// then still give the chance to do dispatch, because partial
|
||||||
}
|
// RemainingDevicepath may be in the new FV
|
||||||
|
//
|
||||||
if (!EFI_ERROR (Status)) {
|
// 1. If the connect fail, RemainingDevicepath and handle will not
|
||||||
PreviousHandle = Handle;
|
// change, so next time will do the dispatch, then dispatch's status
|
||||||
//
|
// will take effect
|
||||||
// Connect all drivers that apply to Handle and RemainingDevicePath,
|
// 2. If the connect success, the RemainingDevicepath and handle will
|
||||||
// the Recursive flag is FALSE so only one level will be expanded.
|
// change, then avoid the dispatch, we have chance to continue the
|
||||||
//
|
// next connection
|
||||||
// Do not check the connect status here, if the connect controller fail,
|
//
|
||||||
// then still give the chance to do dispatch, because partial
|
gBS->ConnectController (Handle, NULL, RemainingDevicePath, FALSE);
|
||||||
// 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
|
// Loop until RemainingDevicePath is an empty device path
|
||||||
// will take effect
|
//
|
||||||
// 2. If the connect success, the RemainingDevicepath and handle will
|
} while (!EFI_ERROR (Status) && !IsDevicePathEnd (RemainingDevicePath));
|
||||||
// change, then avoid the dispatch, we have chance to continue the
|
|
||||||
// next connection
|
} while (DevicePath != NULL);
|
||||||
//
|
|
||||||
gBS->ConnectController (Handle, NULL, RemainingDevicePath, FALSE);
|
if (CopyOfDevicePath != NULL) {
|
||||||
}
|
gBS->FreePool (CopyOfDevicePath);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// Loop until RemainingDevicePath is an empty device path
|
// All handle with DevicePath exists in the handle database
|
||||||
//
|
//
|
||||||
} while (!EFI_ERROR (Status) && !IsDevicePathEnd (RemainingDevicePath));
|
return Status;
|
||||||
|
}
|
||||||
} while (DevicePath != NULL);
|
|
||||||
|
|
||||||
if (CopyOfDevicePath != NULL) {
|
/**
|
||||||
gBS->FreePool (CopyOfDevicePath);
|
This function will connect all current system handles recursively. The
|
||||||
}
|
connection will finish until every handle's child handle created if it have.
|
||||||
//
|
|
||||||
// All handle with DevicePath exists in the handle database
|
@retval EFI_SUCCESS All handles and it's child handle have been
|
||||||
//
|
connected
|
||||||
return Status;
|
@retval EFI_STATUS Return the status of gBS->LocateHandleBuffer().
|
||||||
}
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
/**
|
EFIAPI
|
||||||
This function will connect all current system handles recursively. The
|
BdsLibConnectAllEfi (
|
||||||
connection will finish until every handle's child handle created if it have.
|
VOID
|
||||||
|
)
|
||||||
None
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
@retval EFI_SUCCESS All handles and it's child handle have been
|
UINTN HandleCount;
|
||||||
connected
|
EFI_HANDLE *HandleBuffer;
|
||||||
@retval EFI_STATUS Return the status of gBS->LocateHandleBuffer().
|
UINTN Index;
|
||||||
|
|
||||||
**/
|
Status = gBS->LocateHandleBuffer (
|
||||||
EFI_STATUS
|
AllHandles,
|
||||||
BdsLibConnectAllEfi (
|
NULL,
|
||||||
VOID
|
NULL,
|
||||||
)
|
&HandleCount,
|
||||||
{
|
&HandleBuffer
|
||||||
EFI_STATUS Status;
|
);
|
||||||
UINTN HandleCount;
|
if (EFI_ERROR (Status)) {
|
||||||
EFI_HANDLE *HandleBuffer;
|
return Status;
|
||||||
UINTN Index;
|
}
|
||||||
|
|
||||||
Status = gBS->LocateHandleBuffer (
|
for (Index = 0; Index < HandleCount; Index++) {
|
||||||
AllHandles,
|
Status = gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
|
||||||
NULL,
|
}
|
||||||
NULL,
|
|
||||||
&HandleCount,
|
gBS->FreePool (HandleBuffer);
|
||||||
&HandleBuffer
|
|
||||||
);
|
return EFI_SUCCESS;
|
||||||
if (EFI_ERROR (Status)) {
|
}
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
/**
|
||||||
for (Index = 0; Index < HandleCount; Index++) {
|
This function will disconnect all current system handles. The disconnection
|
||||||
Status = gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
|
will finish until every handle have been disconnected.
|
||||||
}
|
|
||||||
|
@retval EFI_SUCCESS All handles have been disconnected
|
||||||
gBS->FreePool (HandleBuffer);
|
@retval EFI_STATUS Return the status of gBS->LocateHandleBuffer().
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
**/
|
||||||
}
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
BdsLibDisconnectAllEfi (
|
||||||
/**
|
VOID
|
||||||
This function will disconnect all current system handles. The disconnection
|
)
|
||||||
will finish until every handle have been disconnected.
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
None
|
UINTN HandleCount;
|
||||||
|
EFI_HANDLE *HandleBuffer;
|
||||||
@retval EFI_SUCCESS All handles have been disconnected
|
UINTN Index;
|
||||||
@retval EFI_STATUS Return the status of gBS->LocateHandleBuffer().
|
|
||||||
|
//
|
||||||
**/
|
// Disconnect all
|
||||||
EFI_STATUS
|
//
|
||||||
BdsLibDisconnectAllEfi (
|
Status = gBS->LocateHandleBuffer (
|
||||||
VOID
|
AllHandles,
|
||||||
)
|
NULL,
|
||||||
{
|
NULL,
|
||||||
EFI_STATUS Status;
|
&HandleCount,
|
||||||
UINTN HandleCount;
|
&HandleBuffer
|
||||||
EFI_HANDLE *HandleBuffer;
|
);
|
||||||
UINTN Index;
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
//
|
}
|
||||||
// Disconnect all
|
|
||||||
//
|
for (Index = 0; Index < HandleCount; Index++) {
|
||||||
Status = gBS->LocateHandleBuffer (
|
Status = gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);
|
||||||
AllHandles,
|
}
|
||||||
NULL,
|
|
||||||
NULL,
|
gBS->FreePool (HandleBuffer);
|
||||||
&HandleCount,
|
|
||||||
&HandleBuffer
|
return EFI_SUCCESS;
|
||||||
);
|
}
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
return Status;
|
|
||||||
}
|
/**
|
||||||
|
Connects all drivers to all controllers.
|
||||||
for (Index = 0; Index < HandleCount; Index++) {
|
This function make sure all the current system driver will manage
|
||||||
Status = gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);
|
the correspoinding controllers if have. And at the same time, make
|
||||||
}
|
sure all the system controllers have driver to manage it if have.
|
||||||
|
|
||||||
gBS->FreePool (HandleBuffer);
|
**/
|
||||||
|
VOID
|
||||||
return EFI_SUCCESS;
|
EFIAPI
|
||||||
}
|
BdsLibConnectAllDriversToAllControllers (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
/**
|
{
|
||||||
Connects all drivers to all controllers.
|
EFI_STATUS Status;
|
||||||
This function make sure all the current system driver will manage
|
|
||||||
the correspoinding controllers if have. And at the same time, make
|
do {
|
||||||
sure all the system controllers have driver to manage it if have.
|
//
|
||||||
|
// Connect All EFI 1.10 drivers following EFI 1.10 algorithm
|
||||||
None
|
//
|
||||||
|
BdsLibConnectAllEfi ();
|
||||||
@return None
|
|
||||||
|
//
|
||||||
**/
|
// Check to see if it's possible to dispatch an more DXE drivers.
|
||||||
VOID
|
// The BdsLibConnectAllEfi () may have made new DXE drivers show up.
|
||||||
BdsLibConnectAllDriversToAllControllers (
|
// If anything is Dispatched Status == EFI_SUCCESS and we will try
|
||||||
VOID
|
// the connect again.
|
||||||
)
|
//
|
||||||
{
|
Status = gDS->Dispatch ();
|
||||||
EFI_STATUS Status;
|
|
||||||
|
} while (!EFI_ERROR (Status));
|
||||||
do {
|
|
||||||
//
|
}
|
||||||
// Connect All EFI 1.10 drivers following EFI 1.10 algorithm
|
|
||||||
//
|
|
||||||
BdsLibConnectAllEfi ();
|
/**
|
||||||
|
Connect the specific Usb device which match the short form device path,
|
||||||
//
|
and whose bus is determined by Host Controller (Uhci or Ehci)
|
||||||
// Check to see if it's possible to dispatch an more DXE drivers.
|
|
||||||
// The BdsLibConnectAllEfi () may have made new DXE drivers show up.
|
@param HostControllerPI Uhci (0x00) or Ehci (0x20) or Both uhci and ehci
|
||||||
// If anything is Dispatched Status == EFI_SUCCESS and we will try
|
(0xFF)
|
||||||
// the connect again.
|
@param RemainingDevicePath a short-form device path that starts with the first
|
||||||
//
|
element being a USB WWID or a USB Class device
|
||||||
Status = gDS->Dispatch ();
|
path
|
||||||
|
|
||||||
} while (!EFI_ERROR (Status));
|
@return EFI_INVALID_PARAMETER
|
||||||
|
@return EFI_SUCCESS
|
||||||
}
|
@return EFI_NOT_FOUND
|
||||||
|
|
||||||
|
**/
|
||||||
/**
|
EFI_STATUS
|
||||||
Connect the specific Usb device which match the short form device path,
|
EFIAPI
|
||||||
and whose bus is determined by Host Controller (Uhci or Ehci)
|
BdsLibConnectUsbDevByShortFormDP(
|
||||||
|
IN UINT8 HostControllerPI,
|
||||||
@param HostControllerPI Uhci (0x00) or Ehci (0x20) or Both uhci and ehci
|
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||||
(0xFF)
|
)
|
||||||
@param RemainingDevicePath a short-form device path that starts with the first
|
{
|
||||||
element being a USB WWID or a USB Class device
|
EFI_STATUS Status;
|
||||||
path
|
EFI_HANDLE *HandleArray;
|
||||||
|
UINTN HandleArrayCount;
|
||||||
@return EFI_INVALID_PARAMETER
|
UINTN Index;
|
||||||
@return EFI_SUCCESS
|
EFI_PCI_IO_PROTOCOL *PciIo;
|
||||||
@return EFI_NOT_FOUND
|
UINT8 Class[3];
|
||||||
|
BOOLEAN AtLeastOneConnected;
|
||||||
**/
|
|
||||||
EFI_STATUS
|
//
|
||||||
BdsLibConnectUsbDevByShortFormDP(
|
// Check the passed in parameters
|
||||||
IN UINT8 HostControllerPI,
|
//
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
if (RemainingDevicePath == NULL) {
|
||||||
)
|
return EFI_INVALID_PARAMETER;
|
||||||
{
|
}
|
||||||
EFI_STATUS Status;
|
|
||||||
EFI_HANDLE *HandleArray;
|
if ((DevicePathType (RemainingDevicePath) != MESSAGING_DEVICE_PATH) ||
|
||||||
UINTN HandleArrayCount;
|
((DevicePathSubType (RemainingDevicePath) != MSG_USB_CLASS_DP)
|
||||||
UINTN Index;
|
&& (DevicePathSubType (RemainingDevicePath) != MSG_USB_WWID_DP)
|
||||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
)) {
|
||||||
UINT8 Class[3];
|
return EFI_INVALID_PARAMETER;
|
||||||
BOOLEAN AtLeastOneConnected;
|
}
|
||||||
|
|
||||||
//
|
if (HostControllerPI != 0xFF &&
|
||||||
// Check the passed in parameters
|
HostControllerPI != 0x00 &&
|
||||||
//
|
HostControllerPI != 0x20) {
|
||||||
if (RemainingDevicePath == NULL) {
|
return EFI_INVALID_PARAMETER;
|
||||||
return EFI_INVALID_PARAMETER;
|
}
|
||||||
}
|
|
||||||
|
//
|
||||||
if ((DevicePathType (RemainingDevicePath) != MESSAGING_DEVICE_PATH) ||
|
// Find the usb host controller firstly, then connect with the remaining device path
|
||||||
((DevicePathSubType (RemainingDevicePath) != MSG_USB_CLASS_DP)
|
//
|
||||||
&& (DevicePathSubType (RemainingDevicePath) != MSG_USB_WWID_DP)
|
AtLeastOneConnected = FALSE;
|
||||||
)) {
|
Status = gBS->LocateHandleBuffer (
|
||||||
return EFI_INVALID_PARAMETER;
|
ByProtocol,
|
||||||
}
|
&gEfiPciIoProtocolGuid,
|
||||||
|
NULL,
|
||||||
if (HostControllerPI != 0xFF &&
|
&HandleArrayCount,
|
||||||
HostControllerPI != 0x00 &&
|
&HandleArray
|
||||||
HostControllerPI != 0x20) {
|
);
|
||||||
return EFI_INVALID_PARAMETER;
|
if (!EFI_ERROR (Status)) {
|
||||||
}
|
for (Index = 0; Index < HandleArrayCount; Index++) {
|
||||||
|
Status = gBS->HandleProtocol (
|
||||||
//
|
HandleArray[Index],
|
||||||
// Find the usb host controller firstly, then connect with the remaining device path
|
&gEfiPciIoProtocolGuid,
|
||||||
//
|
(VOID **)&PciIo
|
||||||
AtLeastOneConnected = FALSE;
|
);
|
||||||
Status = gBS->LocateHandleBuffer (
|
if (!EFI_ERROR (Status)) {
|
||||||
ByProtocol,
|
//
|
||||||
&gEfiPciIoProtocolGuid,
|
// Check whether the Pci device is the wanted usb host controller
|
||||||
NULL,
|
//
|
||||||
&HandleArrayCount,
|
Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x09, 3, &Class);
|
||||||
&HandleArray
|
if (!EFI_ERROR (Status)) {
|
||||||
);
|
if ((PCI_CLASS_SERIAL == Class[2]) &&
|
||||||
if (!EFI_ERROR (Status)) {
|
(PCI_CLASS_SERIAL_USB == Class[1])) {
|
||||||
for (Index = 0; Index < HandleArrayCount; Index++) {
|
if (HostControllerPI == Class[0] || HostControllerPI == 0xFF) {
|
||||||
Status = gBS->HandleProtocol (
|
Status = gBS->ConnectController (
|
||||||
HandleArray[Index],
|
HandleArray[Index],
|
||||||
&gEfiPciIoProtocolGuid,
|
NULL,
|
||||||
(VOID **)&PciIo
|
RemainingDevicePath,
|
||||||
);
|
FALSE
|
||||||
if (!EFI_ERROR (Status)) {
|
);
|
||||||
//
|
if (!EFI_ERROR(Status)) {
|
||||||
// Check whether the Pci device is the wanted usb host controller
|
AtLeastOneConnected = TRUE;
|
||||||
//
|
}
|
||||||
Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x09, 3, &Class);
|
}
|
||||||
if (!EFI_ERROR (Status)) {
|
}
|
||||||
if ((PCI_CLASS_SERIAL == Class[2]) &&
|
}
|
||||||
(PCI_CLASS_SERIAL_USB == Class[1])) {
|
}
|
||||||
if (HostControllerPI == Class[0] || HostControllerPI == 0xFF) {
|
}
|
||||||
Status = gBS->ConnectController (
|
|
||||||
HandleArray[Index],
|
if (AtLeastOneConnected) {
|
||||||
NULL,
|
return EFI_SUCCESS;
|
||||||
RemainingDevicePath,
|
}
|
||||||
FALSE
|
}
|
||||||
);
|
|
||||||
if (!EFI_ERROR(Status)) {
|
return EFI_NOT_FOUND;
|
||||||
AtLeastOneConnected = TRUE;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (AtLeastOneConnected) {
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return EFI_NOT_FOUND;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,396 +1,386 @@
|
||||||
/** @file
|
/** @file
|
||||||
|
BDS Lib functions which contain all the code to connect console device
|
||||||
Copyright (c) 2004 - 2007, Intel Corporation
|
|
||||||
All rights reserved. This program and the accompanying materials
|
Copyright (c) 2004 - 2008, Intel Corporation. <BR>
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
All rights reserved. This program and the accompanying materials
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
http://opensource.org/licenses/bsd-license.php
|
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.
|
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
|
|
||||||
|
#include "InternalBdsLib.h"
|
||||||
Abstract:
|
|
||||||
|
BOOLEAN
|
||||||
BDS Lib functions which contain all the code to connect console device
|
IsNvNeed (
|
||||||
|
IN CHAR16 *ConVarName
|
||||||
|
)
|
||||||
**/
|
{
|
||||||
|
CHAR16 *Ptr;
|
||||||
#include "InternalBdsLib.h"
|
|
||||||
|
Ptr = ConVarName;
|
||||||
BOOLEAN
|
|
||||||
IsNvNeed (
|
//
|
||||||
IN CHAR16 *ConVarName
|
// If the variable includes "Dev" at last, we consider
|
||||||
)
|
// it does not support NV attribute.
|
||||||
{
|
//
|
||||||
CHAR16 *Ptr;
|
while (*Ptr) {
|
||||||
|
Ptr++;
|
||||||
Ptr = ConVarName;
|
}
|
||||||
|
|
||||||
//
|
if ((*(Ptr-3) == 'D') && (*(Ptr-2) == 'e') && (*(Ptr-1) == 'v')) {
|
||||||
// If the variable includes "Dev" at last, we consider
|
return FALSE;
|
||||||
// it does not support NV attribute.
|
} else {
|
||||||
//
|
return TRUE;
|
||||||
while (*Ptr) {
|
}
|
||||||
Ptr++;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ((*(Ptr-3) == 'D') && (*(Ptr-2) == 'e') && (*(Ptr-1) == 'v')) {
|
/**
|
||||||
return FALSE;
|
This function update console variable based on ConVarName, it can
|
||||||
} else {
|
add or remove one specific console device path from the variable
|
||||||
return TRUE;
|
|
||||||
}
|
@param ConVarName Console related variable name, ConIn, ConOut,
|
||||||
}
|
ErrOut.
|
||||||
|
@param CustomizedConDevicePath The console device path which will be added to
|
||||||
|
the console variable ConVarName, this parameter
|
||||||
/**
|
can not be multi-instance.
|
||||||
This function update console variable based on ConVarName, it can
|
@param ExclusiveDevicePath The console device path which will be removed
|
||||||
add or remove one specific console device path from the variable
|
from the console variable ConVarName, this
|
||||||
|
parameter can not be multi-instance.
|
||||||
@param ConVarName Console related variable name, ConIn, ConOut,
|
|
||||||
ErrOut.
|
@retval EFI_UNSUPPORTED Add or remove the same device path.
|
||||||
@param CustomizedConDevicePath The console device path which will be added to
|
@retval EFI_SUCCESS Success add or remove the device path from the
|
||||||
the console variable ConVarName, this parameter
|
console variable.
|
||||||
can not be multi-instance.
|
|
||||||
@param ExclusiveDevicePath The console device path which will be removed
|
**/
|
||||||
from the console variable ConVarName, this
|
EFI_STATUS
|
||||||
parameter can not be multi-instance.
|
EFIAPI
|
||||||
|
BdsLibUpdateConsoleVariable (
|
||||||
@retval EFI_UNSUPPORTED Add or remove the same device path.
|
IN CHAR16 *ConVarName,
|
||||||
@retval EFI_SUCCESS Success add or remove the device path from the
|
IN EFI_DEVICE_PATH_PROTOCOL *CustomizedConDevicePath,
|
||||||
console variable.
|
IN EFI_DEVICE_PATH_PROTOCOL *ExclusiveDevicePath
|
||||||
|
)
|
||||||
**/
|
{
|
||||||
EFI_STATUS
|
EFI_DEVICE_PATH_PROTOCOL *VarConsole;
|
||||||
BdsLibUpdateConsoleVariable (
|
UINTN DevicePathSize;
|
||||||
IN CHAR16 *ConVarName,
|
EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL *CustomizedConDevicePath,
|
EFI_DEVICE_PATH_PROTOCOL *TempNewDevicePath;
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL *ExclusiveDevicePath
|
UINT32 Attributes;
|
||||||
)
|
|
||||||
{
|
VarConsole = NULL;
|
||||||
EFI_DEVICE_PATH_PROTOCOL *VarConsole;
|
DevicePathSize = 0;
|
||||||
UINTN DevicePathSize;
|
|
||||||
EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
|
//
|
||||||
EFI_DEVICE_PATH_PROTOCOL *TempNewDevicePath;
|
// Notes: check the device path point, here should check
|
||||||
UINT32 Attributes;
|
// with compare memory
|
||||||
|
//
|
||||||
VarConsole = NULL;
|
if (CustomizedConDevicePath == ExclusiveDevicePath) {
|
||||||
DevicePathSize = 0;
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
//
|
//
|
||||||
// Notes: check the device path point, here should check
|
// Delete the ExclusiveDevicePath from current default console
|
||||||
// with compare memory
|
//
|
||||||
//
|
VarConsole = BdsLibGetVariableAndSize (
|
||||||
if (CustomizedConDevicePath == ExclusiveDevicePath) {
|
ConVarName,
|
||||||
return EFI_UNSUPPORTED;
|
&gEfiGlobalVariableGuid,
|
||||||
}
|
&DevicePathSize
|
||||||
//
|
);
|
||||||
// Delete the ExclusiveDevicePath from current default console
|
|
||||||
//
|
//
|
||||||
VarConsole = BdsLibGetVariableAndSize (
|
// Initialize NewDevicePath
|
||||||
ConVarName,
|
//
|
||||||
&gEfiGlobalVariableGuid,
|
NewDevicePath = VarConsole;
|
||||||
&DevicePathSize
|
|
||||||
);
|
//
|
||||||
|
// If ExclusiveDevicePath is even the part of the instance in VarConsole, delete it.
|
||||||
//
|
// In the end, NewDevicePath is the final device path.
|
||||||
// Initialize NewDevicePath
|
//
|
||||||
//
|
if (ExclusiveDevicePath != NULL && VarConsole != NULL) {
|
||||||
NewDevicePath = VarConsole;
|
NewDevicePath = BdsLibDelPartMatchInstance (VarConsole, ExclusiveDevicePath);
|
||||||
|
}
|
||||||
//
|
//
|
||||||
// If ExclusiveDevicePath is even the part of the instance in VarConsole, delete it.
|
// Try to append customized device path to NewDevicePath.
|
||||||
// In the end, NewDevicePath is the final device path.
|
//
|
||||||
//
|
if (CustomizedConDevicePath != NULL) {
|
||||||
if (ExclusiveDevicePath != NULL && VarConsole != NULL) {
|
if (!BdsLibMatchDevicePaths (NewDevicePath, CustomizedConDevicePath)) {
|
||||||
NewDevicePath = BdsLibDelPartMatchInstance (VarConsole, ExclusiveDevicePath);
|
//
|
||||||
}
|
// Check if there is part of CustomizedConDevicePath in NewDevicePath, delete it.
|
||||||
//
|
//
|
||||||
// Try to append customized device path to NewDevicePath.
|
NewDevicePath = BdsLibDelPartMatchInstance (NewDevicePath, CustomizedConDevicePath);
|
||||||
//
|
//
|
||||||
if (CustomizedConDevicePath != NULL) {
|
// In the first check, the default console variable will be _ModuleEntryPoint,
|
||||||
if (!BdsLibMatchDevicePaths (NewDevicePath, CustomizedConDevicePath)) {
|
// just append current customized device path
|
||||||
//
|
//
|
||||||
// Check if there is part of CustomizedConDevicePath in NewDevicePath, delete it.
|
TempNewDevicePath = NewDevicePath;
|
||||||
//
|
NewDevicePath = AppendDevicePathInstance (NewDevicePath, CustomizedConDevicePath);
|
||||||
NewDevicePath = BdsLibDelPartMatchInstance (NewDevicePath, CustomizedConDevicePath);
|
SafeFreePool(TempNewDevicePath);
|
||||||
//
|
}
|
||||||
// In the first check, the default console variable will be _ModuleEntryPoint,
|
}
|
||||||
// just append current customized device path
|
|
||||||
//
|
//
|
||||||
TempNewDevicePath = NewDevicePath;
|
// The attribute for ConInDev, ConOutDev and ErrOutDev does not include NV.
|
||||||
NewDevicePath = AppendDevicePathInstance (NewDevicePath, CustomizedConDevicePath);
|
//
|
||||||
SafeFreePool(TempNewDevicePath);
|
if (IsNvNeed(ConVarName)) {
|
||||||
}
|
//
|
||||||
}
|
// ConVarName has NV attribute.
|
||||||
|
//
|
||||||
//
|
Attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE;
|
||||||
// The attribute for ConInDev, ConOutDev and ErrOutDev does not include NV.
|
} else {
|
||||||
//
|
//
|
||||||
if (IsNvNeed(ConVarName)) {
|
// ConVarName does not have NV attribute.
|
||||||
//
|
//
|
||||||
// ConVarName has NV attribute.
|
Attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;
|
||||||
//
|
}
|
||||||
Attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE;
|
|
||||||
} else {
|
//
|
||||||
//
|
// Finally, Update the variable of the default console by NewDevicePath
|
||||||
// ConVarName does not have NV attribute.
|
//
|
||||||
//
|
gRT->SetVariable (
|
||||||
Attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;
|
ConVarName,
|
||||||
}
|
&gEfiGlobalVariableGuid,
|
||||||
|
Attributes,
|
||||||
//
|
GetDevicePathSize (NewDevicePath),
|
||||||
// Finally, Update the variable of the default console by NewDevicePath
|
NewDevicePath
|
||||||
//
|
);
|
||||||
gRT->SetVariable (
|
|
||||||
ConVarName,
|
if (VarConsole == NewDevicePath) {
|
||||||
&gEfiGlobalVariableGuid,
|
SafeFreePool(VarConsole);
|
||||||
Attributes,
|
} else {
|
||||||
GetDevicePathSize (NewDevicePath),
|
SafeFreePool(VarConsole);
|
||||||
NewDevicePath
|
SafeFreePool(NewDevicePath);
|
||||||
);
|
}
|
||||||
|
|
||||||
if (VarConsole == NewDevicePath) {
|
return EFI_SUCCESS;
|
||||||
SafeFreePool(VarConsole);
|
|
||||||
} else {
|
}
|
||||||
SafeFreePool(VarConsole);
|
|
||||||
SafeFreePool(NewDevicePath);
|
|
||||||
}
|
/**
|
||||||
|
Connect the console device base on the variable ConVarName, if
|
||||||
return EFI_SUCCESS;
|
device path of the ConVarName is multi-instance device path, if
|
||||||
|
anyone of the instances is connected success, then this function
|
||||||
}
|
will return success.
|
||||||
|
|
||||||
|
@param ConVarName Console related variable name, ConIn, ConOut,
|
||||||
/**
|
ErrOut.
|
||||||
Connect the console device base on the variable ConVarName, if
|
|
||||||
device path of the ConVarName is multi-instance device path, if
|
@retval EFI_NOT_FOUND There is not any console devices connected
|
||||||
anyone of the instances is connected success, then this function
|
success
|
||||||
will return success.
|
@retval EFI_SUCCESS Success connect any one instance of the console
|
||||||
|
device path base on the variable ConVarName.
|
||||||
@param ConVarName Console related variable name, ConIn, ConOut,
|
|
||||||
ErrOut.
|
**/
|
||||||
|
EFI_STATUS
|
||||||
@retval EFI_NOT_FOUND There is not any console devices connected
|
EFIAPI
|
||||||
success
|
BdsLibConnectConsoleVariable (
|
||||||
@retval EFI_SUCCESS Success connect any one instance of the console
|
IN CHAR16 *ConVarName
|
||||||
device path base on the variable ConVarName.
|
)
|
||||||
|
{
|
||||||
**/
|
EFI_STATUS Status;
|
||||||
EFI_STATUS
|
EFI_DEVICE_PATH_PROTOCOL *StartDevicePath;
|
||||||
BdsLibConnectConsoleVariable (
|
UINTN VariableSize;
|
||||||
IN CHAR16 *ConVarName
|
EFI_DEVICE_PATH_PROTOCOL *Instance;
|
||||||
)
|
EFI_DEVICE_PATH_PROTOCOL *Next;
|
||||||
{
|
EFI_DEVICE_PATH_PROTOCOL *CopyOfDevicePath;
|
||||||
EFI_STATUS Status;
|
UINTN Size;
|
||||||
EFI_DEVICE_PATH_PROTOCOL *StartDevicePath;
|
BOOLEAN DeviceExist;
|
||||||
UINTN VariableSize;
|
|
||||||
EFI_DEVICE_PATH_PROTOCOL *Instance;
|
Status = EFI_SUCCESS;
|
||||||
EFI_DEVICE_PATH_PROTOCOL *Next;
|
DeviceExist = FALSE;
|
||||||
EFI_DEVICE_PATH_PROTOCOL *CopyOfDevicePath;
|
|
||||||
UINTN Size;
|
//
|
||||||
BOOLEAN DeviceExist;
|
// Check if the console variable exist
|
||||||
|
//
|
||||||
Status = EFI_SUCCESS;
|
StartDevicePath = BdsLibGetVariableAndSize (
|
||||||
DeviceExist = FALSE;
|
ConVarName,
|
||||||
|
&gEfiGlobalVariableGuid,
|
||||||
//
|
&VariableSize
|
||||||
// Check if the console variable exist
|
);
|
||||||
//
|
if (StartDevicePath == NULL) {
|
||||||
StartDevicePath = BdsLibGetVariableAndSize (
|
return EFI_UNSUPPORTED;
|
||||||
ConVarName,
|
}
|
||||||
&gEfiGlobalVariableGuid,
|
|
||||||
&VariableSize
|
CopyOfDevicePath = StartDevicePath;
|
||||||
);
|
do {
|
||||||
if (StartDevicePath == NULL) {
|
//
|
||||||
return EFI_UNSUPPORTED;
|
// Check every instance of the console variable
|
||||||
}
|
//
|
||||||
|
Instance = GetNextDevicePathInstance (&CopyOfDevicePath, &Size);
|
||||||
CopyOfDevicePath = StartDevicePath;
|
Next = Instance;
|
||||||
do {
|
while (!IsDevicePathEndType (Next)) {
|
||||||
//
|
Next = NextDevicePathNode (Next);
|
||||||
// Check every instance of the console variable
|
}
|
||||||
//
|
|
||||||
Instance = GetNextDevicePathInstance (&CopyOfDevicePath, &Size);
|
SetDevicePathEndNode (Next);
|
||||||
Next = Instance;
|
//
|
||||||
while (!IsDevicePathEndType (Next)) {
|
// Check USB1.1 console
|
||||||
Next = NextDevicePathNode (Next);
|
//
|
||||||
}
|
if ((DevicePathType (Instance) == MESSAGING_DEVICE_PATH) &&
|
||||||
|
((DevicePathSubType (Instance) == MSG_USB_CLASS_DP)
|
||||||
SetDevicePathEndNode (Next);
|
|| (DevicePathSubType (Instance) == MSG_USB_WWID_DP)
|
||||||
//
|
)) {
|
||||||
// Check USB1.1 console
|
//
|
||||||
//
|
// Check the Usb console in Usb2.0 bus firstly, then Usb1.1 bus
|
||||||
if ((DevicePathType (Instance) == MESSAGING_DEVICE_PATH) &&
|
//
|
||||||
((DevicePathSubType (Instance) == MSG_USB_CLASS_DP)
|
Status = BdsLibConnectUsbDevByShortFormDP (PCI_CLASSC_PI_EHCI, Instance);
|
||||||
|| (DevicePathSubType (Instance) == MSG_USB_WWID_DP)
|
if (!EFI_ERROR (Status)) {
|
||||||
)) {
|
DeviceExist = TRUE;
|
||||||
//
|
}
|
||||||
// Check the Usb console in Usb2.0 bus firstly, then Usb1.1 bus
|
|
||||||
//
|
Status = BdsLibConnectUsbDevByShortFormDP (PCI_CLASSC_PI_UHCI, Instance);
|
||||||
Status = BdsLibConnectUsbDevByShortFormDP (PCI_CLASSC_PI_EHCI, Instance);
|
if (!EFI_ERROR (Status)) {
|
||||||
if (!EFI_ERROR (Status)) {
|
DeviceExist = TRUE;
|
||||||
DeviceExist = TRUE;
|
}
|
||||||
}
|
} else {
|
||||||
|
//
|
||||||
Status = BdsLibConnectUsbDevByShortFormDP (PCI_CLASSC_PI_UHCI, Instance);
|
// Connect the instance device path
|
||||||
if (!EFI_ERROR (Status)) {
|
//
|
||||||
DeviceExist = TRUE;
|
Status = BdsLibConnectDevicePath (Instance);
|
||||||
}
|
if (EFI_ERROR (Status)) {
|
||||||
} else {
|
//
|
||||||
//
|
// Delete the instance from the console varialbe
|
||||||
// Connect the instance device path
|
//
|
||||||
//
|
BdsLibUpdateConsoleVariable (ConVarName, NULL, Instance);
|
||||||
Status = BdsLibConnectDevicePath (Instance);
|
} else {
|
||||||
if (EFI_ERROR (Status)) {
|
DeviceExist = TRUE;
|
||||||
//
|
}
|
||||||
// Delete the instance from the console varialbe
|
}
|
||||||
//
|
SafeFreePool(Instance);
|
||||||
BdsLibUpdateConsoleVariable (ConVarName, NULL, Instance);
|
} while (CopyOfDevicePath != NULL);
|
||||||
} else {
|
|
||||||
DeviceExist = TRUE;
|
gBS->FreePool (StartDevicePath);
|
||||||
}
|
|
||||||
}
|
if (DeviceExist == FALSE) {
|
||||||
SafeFreePool(Instance);
|
return EFI_NOT_FOUND;
|
||||||
} while (CopyOfDevicePath != NULL);
|
}
|
||||||
|
|
||||||
gBS->FreePool (StartDevicePath);
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
if (DeviceExist == FALSE) {
|
|
||||||
return EFI_NOT_FOUND;
|
|
||||||
}
|
/**
|
||||||
|
This function will search every simpletxt devive in current system,
|
||||||
return EFI_SUCCESS;
|
and make every simpletxt device as pertantial console device.
|
||||||
}
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
/**
|
EFIAPI
|
||||||
This function will search every simpletxt devive in current system,
|
BdsLibConnectAllConsoles (
|
||||||
and make every simpletxt device as pertantial console device.
|
VOID
|
||||||
|
)
|
||||||
None
|
{
|
||||||
|
UINTN Index;
|
||||||
@return None
|
EFI_DEVICE_PATH_PROTOCOL *ConDevicePath;
|
||||||
|
UINTN HandleCount;
|
||||||
**/
|
EFI_HANDLE *HandleBuffer;
|
||||||
VOID
|
|
||||||
BdsLibConnectAllConsoles (
|
Index = 0;
|
||||||
VOID
|
HandleCount = 0;
|
||||||
)
|
HandleBuffer = NULL;
|
||||||
{
|
ConDevicePath = NULL;
|
||||||
UINTN Index;
|
|
||||||
EFI_DEVICE_PATH_PROTOCOL *ConDevicePath;
|
//
|
||||||
UINTN HandleCount;
|
// Update all the console varables
|
||||||
EFI_HANDLE *HandleBuffer;
|
//
|
||||||
|
gBS->LocateHandleBuffer (
|
||||||
Index = 0;
|
ByProtocol,
|
||||||
HandleCount = 0;
|
&gEfiSimpleTextInProtocolGuid,
|
||||||
HandleBuffer = NULL;
|
NULL,
|
||||||
ConDevicePath = NULL;
|
&HandleCount,
|
||||||
|
&HandleBuffer
|
||||||
//
|
);
|
||||||
// Update all the console varables
|
|
||||||
//
|
for (Index = 0; Index < HandleCount; Index++) {
|
||||||
gBS->LocateHandleBuffer (
|
gBS->HandleProtocol (
|
||||||
ByProtocol,
|
HandleBuffer[Index],
|
||||||
&gEfiSimpleTextInProtocolGuid,
|
&gEfiDevicePathProtocolGuid,
|
||||||
NULL,
|
(VOID **) &ConDevicePath
|
||||||
&HandleCount,
|
);
|
||||||
&HandleBuffer
|
BdsLibUpdateConsoleVariable (L"ConIn", ConDevicePath, NULL);
|
||||||
);
|
}
|
||||||
|
|
||||||
for (Index = 0; Index < HandleCount; Index++) {
|
SafeFreePool(HandleBuffer);
|
||||||
gBS->HandleProtocol (
|
|
||||||
HandleBuffer[Index],
|
gBS->LocateHandleBuffer (
|
||||||
&gEfiDevicePathProtocolGuid,
|
ByProtocol,
|
||||||
(VOID **) &ConDevicePath
|
&gEfiSimpleTextOutProtocolGuid,
|
||||||
);
|
NULL,
|
||||||
BdsLibUpdateConsoleVariable (L"ConIn", ConDevicePath, NULL);
|
&HandleCount,
|
||||||
}
|
&HandleBuffer
|
||||||
|
);
|
||||||
SafeFreePool(HandleBuffer);
|
for (Index = 0; Index < HandleCount; Index++) {
|
||||||
|
gBS->HandleProtocol (
|
||||||
gBS->LocateHandleBuffer (
|
HandleBuffer[Index],
|
||||||
ByProtocol,
|
&gEfiDevicePathProtocolGuid,
|
||||||
&gEfiSimpleTextOutProtocolGuid,
|
(VOID **) &ConDevicePath
|
||||||
NULL,
|
);
|
||||||
&HandleCount,
|
BdsLibUpdateConsoleVariable (L"ConOut", ConDevicePath, NULL);
|
||||||
&HandleBuffer
|
BdsLibUpdateConsoleVariable (L"ErrOut", ConDevicePath, NULL);
|
||||||
);
|
}
|
||||||
for (Index = 0; Index < HandleCount; Index++) {
|
|
||||||
gBS->HandleProtocol (
|
SafeFreePool(HandleBuffer);
|
||||||
HandleBuffer[Index],
|
|
||||||
&gEfiDevicePathProtocolGuid,
|
//
|
||||||
(VOID **) &ConDevicePath
|
// Connect all console variables
|
||||||
);
|
//
|
||||||
BdsLibUpdateConsoleVariable (L"ConOut", ConDevicePath, NULL);
|
BdsLibConnectAllDefaultConsoles ();
|
||||||
BdsLibUpdateConsoleVariable (L"ErrOut", ConDevicePath, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SafeFreePool(HandleBuffer);
|
|
||||||
|
/**
|
||||||
//
|
This function will connect console device base on the console
|
||||||
// Connect all console variables
|
device variable ConIn, ConOut and ErrOut.
|
||||||
//
|
|
||||||
BdsLibConnectAllDefaultConsoles ();
|
@retval EFI_SUCCESS At least one of the ConIn and ConOut device have
|
||||||
|
been connected success.
|
||||||
}
|
@retval EFI_STATUS Return the status of
|
||||||
|
BdsLibConnectConsoleVariable ().
|
||||||
|
|
||||||
/**
|
**/
|
||||||
This function will connect console device base on the console
|
EFI_STATUS
|
||||||
device variable ConIn, ConOut and ErrOut.
|
EFIAPI
|
||||||
|
BdsLibConnectAllDefaultConsoles (
|
||||||
None
|
VOID
|
||||||
|
)
|
||||||
@retval EFI_SUCCESS At least one of the ConIn and ConOut device have
|
{
|
||||||
been connected success.
|
EFI_STATUS Status;
|
||||||
@retval EFI_STATUS Return the status of
|
|
||||||
BdsLibConnectConsoleVariable ().
|
//
|
||||||
|
// Connect all default console variables
|
||||||
**/
|
//
|
||||||
EFI_STATUS
|
|
||||||
BdsLibConnectAllDefaultConsoles (
|
//
|
||||||
VOID
|
// It seems impossible not to have any ConOut device on platform,
|
||||||
)
|
// so we check the status here.
|
||||||
{
|
//
|
||||||
EFI_STATUS Status;
|
Status = BdsLibConnectConsoleVariable (L"ConOut");
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
//
|
return Status;
|
||||||
// Connect all default console variables
|
}
|
||||||
//
|
|
||||||
|
//
|
||||||
//
|
// Insert the performance probe for Console Out
|
||||||
// It seems impossible not to have any ConOut device on platform,
|
//
|
||||||
// so we check the status here.
|
PERF_START (NULL, "ConOut", "BDS", 1);
|
||||||
//
|
PERF_END (NULL, "ConOut", "BDS", 0);
|
||||||
Status = BdsLibConnectConsoleVariable (L"ConOut");
|
|
||||||
if (EFI_ERROR (Status)) {
|
//
|
||||||
return Status;
|
// 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.
|
||||||
//
|
//
|
||||||
// Insert the performance probe for Console Out
|
BdsLibConnectConsoleVariable (L"ConIn");
|
||||||
//
|
|
||||||
PERF_START (NULL, "ConOut", "BDS", 1);
|
//
|
||||||
PERF_END (NULL, "ConOut", "BDS", 0);
|
// The _ModuleEntryPoint err out var is legal.
|
||||||
|
//
|
||||||
//
|
BdsLibConnectConsoleVariable (L"ErrOut");
|
||||||
// Because possibly the platform is legacy free, in such case,
|
|
||||||
// ConIn devices (Serial Port and PS2 Keyboard ) does not exist,
|
return EFI_SUCCESS;
|
||||||
// so we need not check the status.
|
|
||||||
//
|
}
|
||||||
BdsLibConnectConsoleVariable (L"ConIn");
|
|
||||||
|
|
||||||
//
|
|
||||||
// The _ModuleEntryPoint 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,35 +1,23 @@
|
||||||
/** @file
|
/** @file
|
||||||
|
Boot Manager Machine type
|
||||||
Copyright (c) 2007, Intel Corporation
|
|
||||||
All rights reserved. This program and the accompanying materials
|
Copyright (c) 2007 - 2008, Intel Corporation. <BR>
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
All rights reserved. This program and the accompanying materials
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
http://opensource.org/licenses/bsd-license.php
|
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.
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
Module Name:
|
|
||||||
|
**/
|
||||||
BmMachine.h
|
|
||||||
|
#ifndef _BM_MACHINE_H
|
||||||
Abstract:
|
#define _BM_MACHINE_H
|
||||||
|
|
||||||
Boot Manager Machine type
|
//
|
||||||
|
// NOTE: This is not defined in UEFI spec.
|
||||||
|
//
|
||||||
|
#define DEFAULT_REMOVABLE_FILE_NAME L"\\EFI\\BOOT\\BOOTEBC.EFI"
|
||||||
Revision History
|
|
||||||
|
#endif
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#ifndef _BM_MACHINE_H
|
|
||||||
#define _BM_MACHINE_H
|
|
||||||
|
|
||||||
//
|
|
||||||
// NOTE: This is not defined in UEFI spec.
|
|
||||||
//
|
|
||||||
#define DEFAULT_REMOVABLE_FILE_NAME L"\\EFI\\BOOT\\BOOTEBC.EFI"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
#/** @file
|
#/** @file
|
||||||
# Component name for module GenericBdsLib
|
|
||||||
#
|
|
||||||
# FIX ME!
|
|
||||||
# Copyright (c) 2007, Intel Corporation. All rights reserved.
|
|
||||||
#
|
|
||||||
# All rights reserved. This program and the accompanying materials
|
|
||||||
# are licensed and made available under the terms and conditions of the BSD License
|
|
||||||
# which accompanies this distribution. The full text of the license may be found at
|
|
||||||
# http://opensource.org/licenses/bsd-license.php
|
|
||||||
#
|
#
|
||||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
# Component name for module GenericBdsLib
|
||||||
|
#
|
||||||
|
# Copyright (c) 2007 - 2008, Intel Corporation. <BR>
|
||||||
|
# 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.
|
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
#
|
#
|
||||||
#
|
|
||||||
#**/
|
#**/
|
||||||
|
|
||||||
[Defines]
|
[Defines]
|
||||||
|
@ -37,18 +35,14 @@
|
||||||
Performance.c
|
Performance.c
|
||||||
BdsConnect.c
|
BdsConnect.c
|
||||||
BdsMisc.c
|
BdsMisc.c
|
||||||
R8Lib.c
|
|
||||||
BdsConsole.c
|
BdsConsole.c
|
||||||
BdsBoot.c
|
BdsBoot.c
|
||||||
InternalBdsLib.h
|
InternalBdsLib.h
|
||||||
R8Lib.h
|
|
||||||
|
|
||||||
[Sources.Ia32]
|
[Sources.Ia32]
|
||||||
Ia32/ClearDr.asm
|
|
||||||
Ia32/BmMachine.h
|
Ia32/BmMachine.h
|
||||||
|
|
||||||
[Sources.X64]
|
[Sources.X64]
|
||||||
x64/ClearDr.asm
|
|
||||||
x64/BmMachine.h
|
x64/BmMachine.h
|
||||||
|
|
||||||
[Sources.IPF]
|
[Sources.IPF]
|
||||||
|
|
|
@ -1,34 +1,22 @@
|
||||||
/** @file
|
/** @file
|
||||||
|
Boot Manager Machine type
|
||||||
Copyright (c) 2004 - 2006, Intel Corporation
|
|
||||||
All rights reserved. This program and the accompanying materials
|
Copyright (c) 2004 - 2008, Intel Corporation. <BR>
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
All rights reserved. This program and the accompanying materials
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
http://opensource.org/licenses/bsd-license.php
|
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.
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
Module Name:
|
|
||||||
|
**/
|
||||||
BmMachine.h
|
|
||||||
|
#ifndef _BM_MACHINE_H
|
||||||
Abstract:
|
#define _BM_MACHINE_H
|
||||||
|
|
||||||
Boot Manager Machine type
|
//@MT:#include "CpuIA32.h"
|
||||||
|
|
||||||
|
#define DEFAULT_REMOVABLE_FILE_NAME L"\\EFI\\BOOT\\BOOTIA32.EFI"
|
||||||
|
|
||||||
Revision History
|
#endif
|
||||||
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#ifndef _BM_MACHINE_H
|
|
||||||
#define _BM_MACHINE_H
|
|
||||||
|
|
||||||
//@MT:#include "CpuIA32.h"
|
|
||||||
|
|
||||||
#define DEFAULT_REMOVABLE_FILE_NAME L"\\EFI\\BOOT\\BOOTIA32.EFI"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
title ClearDr.asm
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
;
|
|
||||||
; Copyright (c) 2004, Intel Corporation
|
|
||||||
; All rights reserved. This program and the accompanying materials
|
|
||||||
; are licensed and made available under the terms and conditions of the BSD License
|
|
||||||
; which accompanies this distribution. The full text of the license may be found at
|
|
||||||
; http://opensource.org/licenses/bsd-license.php
|
|
||||||
;
|
|
||||||
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
||||||
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
||||||
;
|
|
||||||
; Module Name:
|
|
||||||
;
|
|
||||||
; ClearDr.asm
|
|
||||||
;
|
|
||||||
; Abstract:
|
|
||||||
;
|
|
||||||
; Clear dr0 dr1 register
|
|
||||||
;
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
.686
|
|
||||||
.MODEL FLAT,C
|
|
||||||
.CODE
|
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
; VOID
|
|
||||||
; ClearDebugRegisters (
|
|
||||||
; VOID
|
|
||||||
; )
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
ClearDebugRegisters PROC PUBLIC
|
|
||||||
push eax
|
|
||||||
xor eax, eax
|
|
||||||
mov dr0, eax
|
|
||||||
mov dr1, eax
|
|
||||||
pop eax
|
|
||||||
ret
|
|
||||||
ClearDebugRegisters ENDP
|
|
||||||
|
|
||||||
END
|
|
||||||
|
|
|
@ -1,103 +1,93 @@
|
||||||
/** @file
|
/** @file
|
||||||
|
BDS library definition, include the file and data structure
|
||||||
Copyright (c) 2004 - 2007, Intel Corporation
|
|
||||||
All rights reserved. This program and the accompanying materials
|
Copyright (c) 2004 - 2008, Intel Corporation. <BR>
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
All rights reserved. This program and the accompanying materials
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
http://opensource.org/licenses/bsd-license.php
|
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.
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
Module Name:
|
|
||||||
|
**/
|
||||||
InternalBdsLib.h
|
|
||||||
|
#ifndef _INTERNAL_BDS_LIB_H_
|
||||||
Abstract:
|
#define _INTERNAL_BDS_LIB_H_
|
||||||
|
|
||||||
BDS library definition, include the file and data structure
|
#include <PiDxe.h>
|
||||||
|
|
||||||
|
#include <IndustryStandard/Pci22.h>
|
||||||
**/
|
|
||||||
|
#include <Protocol/BlockIo.h>
|
||||||
#ifndef _INTERNAL_BDS_LIB_H_
|
#include <Protocol/LoadedImage.h>
|
||||||
#define _INTERNAL_BDS_LIB_H_
|
#include <Protocol/Cpu.h>
|
||||||
|
#include <Protocol/SimpleFileSystem.h>
|
||||||
#include <PiDxe.h>
|
#include <Protocol/DebugPort.h>
|
||||||
|
#include <Protocol/DevicePath.h>
|
||||||
#include <IndustryStandard/Pci22.h>
|
#include <Protocol/SimpleTextIn.h>
|
||||||
|
#include <Protocol/LegacyBios.h>
|
||||||
#include <Protocol/BlockIo.h>
|
#include <Protocol/SimpleTextOut.h>
|
||||||
#include <Protocol/LoadedImage.h>
|
#include <Protocol/SimpleNetwork.h>
|
||||||
#include <Protocol/Cpu.h>
|
#include <Protocol/DevicePathToText.h>
|
||||||
#include <Protocol/SimpleFileSystem.h>
|
#include <Protocol/FirmwareVolume2.h>
|
||||||
#include <Protocol/DebugPort.h>
|
#include <Protocol/PciIo.h>
|
||||||
#include <Protocol/DevicePath.h>
|
#include <Protocol/AcpiS3Save.h>
|
||||||
#include <Protocol/SimpleTextIn.h>
|
#include <Protocol/Performance.h>
|
||||||
#include <Protocol/LegacyBios.h>
|
#include <Protocol/FirmwareVolumeDispatch.h>
|
||||||
#include <Protocol/SimpleTextOut.h>
|
|
||||||
#include <Protocol/SimpleNetwork.h>
|
#include <Guid/MemoryTypeInformation.h>
|
||||||
#include <Protocol/DevicePathToText.h>
|
#include <Guid/FileInfo.h>
|
||||||
#include <Protocol/FirmwareVolume2.h>
|
#include <Guid/GlobalVariable.h>
|
||||||
#include <Protocol/PciIo.h>
|
#include <Guid/PcAnsi.h>
|
||||||
#include <Protocol/AcpiS3Save.h>
|
#include <Guid/ShellFile.h>
|
||||||
#include <Protocol/Performance.h>
|
#include <Guid/HobList.h>
|
||||||
#include <Protocol/FirmwareVolumeDispatch.h>
|
#include <Guid/GenericPlatformVariable.h>
|
||||||
|
|
||||||
#include <Guid/MemoryTypeInformation.h>
|
#include <Library/PrintLib.h>
|
||||||
#include <Guid/FileInfo.h>
|
#include <Library/DebugLib.h>
|
||||||
#include <Guid/GlobalVariable.h>
|
#include <Library/BaseMemoryLib.h>
|
||||||
#include <Guid/PcAnsi.h>
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
#include <Guid/ShellFile.h>
|
#include <Library/UefiLib.h>
|
||||||
#include <Guid/HobList.h>
|
#include <Library/MemoryAllocationLib.h>
|
||||||
#include <Guid/GenericPlatformVariable.h>
|
#include <Library/DxeServicesTableLib.h>
|
||||||
|
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||||
#include <Library/PrintLib.h>
|
#include <Library/HobLib.h>
|
||||||
#include <Library/DebugLib.h>
|
#include <Library/BaseLib.h>
|
||||||
#include <Library/BaseMemoryLib.h>
|
#include <Library/DevicePathLib.h>
|
||||||
#include <Library/UefiBootServicesTableLib.h>
|
#include <Library/PerformanceLib.h>
|
||||||
#include <Library/UefiLib.h>
|
#include <Library/PcdLib.h>
|
||||||
#include <Library/MemoryAllocationLib.h>
|
#include <Library/IfrSupportLib.h>
|
||||||
#include <Library/DxeServicesTableLib.h>
|
#include <Library/PeCoffGetEntryPointLib.h>
|
||||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
#include <Library/GenericBdsLib.h>
|
||||||
#include <Library/HobLib.h>
|
#include <Library/TimerLib.h>
|
||||||
#include <Library/BaseLib.h>
|
|
||||||
#include <Library/DevicePathLib.h>
|
#include "BmMachine.h"
|
||||||
#include <Library/PerformanceLib.h>
|
|
||||||
#include <Library/PcdLib.h>
|
#define PERFORMANCE_SIGNATURE EFI_SIGNATURE_32 ('P', 'e', 'r', 'f')
|
||||||
#include <Library/IfrSupportLib.h>
|
#define PERF_TOKEN_SIZE 28
|
||||||
#include <Library/PeCoffGetEntryPointLib.h>
|
#define PERF_TOKEN_LENGTH (PERF_TOKEN_SIZE - 1)
|
||||||
#include <Library/GenericBdsLib.h>
|
#define PERF_PEI_ENTRY_MAX_NUM 50
|
||||||
#include <Library/TimerLib.h>
|
|
||||||
|
typedef struct {
|
||||||
#include "BmMachine.h"
|
CHAR8 Token[PERF_TOKEN_SIZE];
|
||||||
|
UINT32 Duration;
|
||||||
#include "R8Lib.h"
|
} PERF_DATA;
|
||||||
|
|
||||||
#define PERFORMANCE_SIGNATURE EFI_SIGNATURE_32 ('P', 'e', 'r', 'f')
|
typedef struct {
|
||||||
#define PERF_TOKEN_SIZE 28
|
UINT64 BootToOs;
|
||||||
#define PERF_TOKEN_LENGTH (PERF_TOKEN_SIZE - 1)
|
UINT64 S3Resume;
|
||||||
#define PERF_PEI_ENTRY_MAX_NUM 50
|
UINT32 S3EntryNum;
|
||||||
|
PERF_DATA S3Entry[PERF_PEI_ENTRY_MAX_NUM];
|
||||||
typedef struct {
|
UINT64 CpuFreq;
|
||||||
CHAR8 Token[PERF_TOKEN_SIZE];
|
UINT64 BDSRaw;
|
||||||
UINT32 Duration;
|
UINT32 Count;
|
||||||
} PERF_DATA;
|
UINT32 Signiture;
|
||||||
|
} PERF_HEADER;
|
||||||
typedef struct {
|
|
||||||
UINT64 BootToOs;
|
VOID
|
||||||
UINT64 S3Resume;
|
WriteBootToOsPerformanceData (
|
||||||
UINT32 S3EntryNum;
|
VOID
|
||||||
PERF_DATA S3Entry[PERF_PEI_ENTRY_MAX_NUM];
|
);
|
||||||
UINT64 CpuFreq;
|
|
||||||
UINT64 BDSRaw;
|
#endif // _BDS_LIB_H_
|
||||||
UINT32 Count;
|
|
||||||
UINT32 Signiture;
|
|
||||||
} PERF_HEADER;
|
|
||||||
|
|
||||||
VOID
|
|
||||||
WriteBootToOsPerformanceData (
|
|
||||||
VOID
|
|
||||||
);
|
|
||||||
|
|
||||||
#endif // _BDS_LIB_H_
|
|
||||||
|
|
|
@ -1,34 +1,22 @@
|
||||||
/** @file
|
/** @file
|
||||||
|
Boot Manager Machine type
|
||||||
Copyright (c) 2004 - 2006, Intel Corporation
|
|
||||||
All rights reserved. This program and the accompanying materials
|
Copyright (c) 2004 - 2008, Intel Corporation. <BR>
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
All rights reserved. This program and the accompanying materials
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
http://opensource.org/licenses/bsd-license.php
|
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.
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
Module Name:
|
|
||||||
|
**/
|
||||||
BmMachine.h
|
|
||||||
|
#ifndef _BM_MACHINE_H
|
||||||
Abstract:
|
#define _BM_MACHINE_H
|
||||||
|
|
||||||
Boot Manager Machine type
|
//@MT:#include "CpuIA64.h"
|
||||||
|
|
||||||
|
#define DEFAULT_REMOVABLE_FILE_NAME L"\\EFI\\BOOT\\BOOTIA64.EFI"
|
||||||
|
|
||||||
Revision History
|
#endif
|
||||||
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#ifndef _BM_MACHINE_H
|
|
||||||
#define _BM_MACHINE_H
|
|
||||||
|
|
||||||
//@MT:#include "CpuIA64.h"
|
|
||||||
|
|
||||||
#define DEFAULT_REMOVABLE_FILE_NAME L"\\EFI\\BOOT\\BOOTIA64.EFI"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,56 +1,46 @@
|
||||||
/** @file
|
/** @file
|
||||||
|
Shadow all option rom
|
||||||
Copyright (c) 2004, Intel Corporation
|
|
||||||
All rights reserved. This program and the accompanying materials
|
Copyright (c) 2004 - 2008, Intel Corporation. <BR>
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
All rights reserved. This program and the accompanying materials
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
http://opensource.org/licenses/bsd-license.php
|
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.
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
Module Name:
|
|
||||||
|
**/
|
||||||
ShadowRom.c
|
|
||||||
|
//@MT:#include "Tiano.h"
|
||||||
Abstract:
|
//@MT:#include "EfiDriverLib.h"
|
||||||
|
|
||||||
Shadow all option rom
|
//@MT:#include EFI_PROTOCOL_DEFINITION (LegacyBios)
|
||||||
|
|
||||||
Revision History
|
#include "InternalBdsLib.h"
|
||||||
|
|
||||||
|
UINT8 mShadowRomFlag = 0;
|
||||||
**/
|
|
||||||
|
VOID
|
||||||
//@MT:#include "Tiano.h"
|
ShadowAllOptionRom()
|
||||||
//@MT:#include "EfiDriverLib.h"
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
//@MT:#include EFI_PROTOCOL_DEFINITION (LegacyBios)
|
EFI_LEGACY_BIOS_PROTOCOL *LegacyBios;
|
||||||
|
//
|
||||||
#include "InternalBdsLib.h"
|
// Rom shadow only do once.
|
||||||
|
//
|
||||||
UINT8 mShadowRomFlag = 0;
|
if (mShadowRomFlag == 0) {
|
||||||
|
Status = gBS->LocateProtocol (
|
||||||
VOID
|
&gEfiLegacyBiosProtocolGuid,
|
||||||
ShadowAllOptionRom()
|
NULL,
|
||||||
{
|
(VOID **) &LegacyBios
|
||||||
EFI_STATUS Status;
|
);
|
||||||
EFI_LEGACY_BIOS_PROTOCOL *LegacyBios;
|
if (!EFI_ERROR (Status)) {
|
||||||
//
|
LegacyBios->PrepareToBootEfi (LegacyBios, NULL, NULL);
|
||||||
// Rom shadow only do once.
|
}
|
||||||
//
|
|
||||||
if (mShadowRomFlag == 0) {
|
mShadowRomFlag = 1;
|
||||||
Status = gBS->LocateProtocol (
|
}
|
||||||
&gEfiLegacyBiosProtocolGuid,
|
|
||||||
NULL,
|
return ;
|
||||||
(VOID **) &LegacyBios
|
}
|
||||||
);
|
|
||||||
if (!EFI_ERROR (Status)) {
|
|
||||||
LegacyBios->PrepareToBootEfi (LegacyBios, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
mShadowRomFlag = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,326 +1,318 @@
|
||||||
/** @file
|
/** @file
|
||||||
|
This file include the file which can help to get the system
|
||||||
Copyright (c) 2004 - 2007, Intel Corporation
|
performance, all the function will only include if the performance
|
||||||
All rights reserved. This program and the accompanying materials
|
switch is set.
|
||||||
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
|
Copyright (c) 2004 - 2008, Intel Corporation. <BR>
|
||||||
http://opensource.org/licenses/bsd-license.php
|
All rights reserved. This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
Module Name:
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
Performance.c
|
|
||||||
|
**/
|
||||||
Abstract:
|
|
||||||
|
#include "InternalBdsLib.h"
|
||||||
This file include the file which can help to get the system
|
|
||||||
performance, all the function will only include if the performance
|
STATIC PERF_HEADER mPerfHeader;
|
||||||
switch is set.
|
STATIC PERF_DATA mPerfData;
|
||||||
|
|
||||||
|
STATIC
|
||||||
**/
|
VOID
|
||||||
|
GetShortPdbFileName (
|
||||||
#include "InternalBdsLib.h"
|
CHAR8 *PdbFileName,
|
||||||
|
CHAR8 *GaugeString
|
||||||
STATIC PERF_HEADER mPerfHeader;
|
)
|
||||||
STATIC PERF_DATA mPerfData;
|
/*++
|
||||||
|
|
||||||
STATIC
|
Routine Description:
|
||||||
VOID
|
|
||||||
GetShortPdbFileName (
|
Arguments:
|
||||||
CHAR8 *PdbFileName,
|
|
||||||
CHAR8 *GaugeString
|
Returns:
|
||||||
)
|
|
||||||
/*++
|
--*/
|
||||||
|
{
|
||||||
Routine Description:
|
UINTN Index;
|
||||||
|
UINTN Index1;
|
||||||
Arguments:
|
UINTN StartIndex;
|
||||||
|
UINTN EndIndex;
|
||||||
Returns:
|
|
||||||
|
if (PdbFileName == NULL) {
|
||||||
--*/
|
AsciiStrCpy (GaugeString, " ");
|
||||||
{
|
} else {
|
||||||
UINTN Index;
|
StartIndex = 0;
|
||||||
UINTN Index1;
|
for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++)
|
||||||
UINTN StartIndex;
|
;
|
||||||
UINTN EndIndex;
|
|
||||||
|
for (Index = 0; PdbFileName[Index] != 0; Index++) {
|
||||||
if (PdbFileName == NULL) {
|
if (PdbFileName[Index] == '\\') {
|
||||||
AsciiStrCpy (GaugeString, " ");
|
StartIndex = Index + 1;
|
||||||
} else {
|
}
|
||||||
StartIndex = 0;
|
|
||||||
for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++)
|
if (PdbFileName[Index] == '.') {
|
||||||
;
|
EndIndex = Index;
|
||||||
|
}
|
||||||
for (Index = 0; PdbFileName[Index] != 0; Index++) {
|
}
|
||||||
if (PdbFileName[Index] == '\\') {
|
|
||||||
StartIndex = Index + 1;
|
Index1 = 0;
|
||||||
}
|
for (Index = StartIndex; Index < EndIndex; Index++) {
|
||||||
|
GaugeString[Index1] = PdbFileName[Index];
|
||||||
if (PdbFileName[Index] == '.') {
|
Index1++;
|
||||||
EndIndex = Index;
|
if (Index1 == PERF_TOKEN_LENGTH - 1) {
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Index1 = 0;
|
|
||||||
for (Index = StartIndex; Index < EndIndex; Index++) {
|
GaugeString[Index1] = 0;
|
||||||
GaugeString[Index1] = PdbFileName[Index];
|
}
|
||||||
Index1++;
|
|
||||||
if (Index1 == PERF_TOKEN_LENGTH - 1) {
|
return ;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
}
|
STATIC
|
||||||
|
VOID
|
||||||
GaugeString[Index1] = 0;
|
GetNameFromHandle (
|
||||||
}
|
IN EFI_HANDLE Handle,
|
||||||
|
OUT CHAR8 *GaugeString
|
||||||
return ;
|
)
|
||||||
}
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
STATIC
|
EFI_LOADED_IMAGE_PROTOCOL *Image;
|
||||||
VOID
|
CHAR8 *PdbFileName;
|
||||||
GetNameFromHandle (
|
EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
|
||||||
IN EFI_HANDLE Handle,
|
|
||||||
OUT CHAR8 *GaugeString
|
AsciiStrCpy (GaugeString, " ");
|
||||||
)
|
|
||||||
{
|
//
|
||||||
EFI_STATUS Status;
|
// Get handle name from image protocol
|
||||||
EFI_LOADED_IMAGE_PROTOCOL *Image;
|
//
|
||||||
CHAR8 *PdbFileName;
|
Status = gBS->HandleProtocol (
|
||||||
EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
|
Handle,
|
||||||
|
&gEfiLoadedImageProtocolGuid,
|
||||||
AsciiStrCpy (GaugeString, " ");
|
(VOID **) &Image
|
||||||
|
);
|
||||||
//
|
|
||||||
// Get handle name from image protocol
|
if (EFI_ERROR (Status)) {
|
||||||
//
|
Status = gBS->OpenProtocol (
|
||||||
Status = gBS->HandleProtocol (
|
Handle,
|
||||||
Handle,
|
&gEfiDriverBindingProtocolGuid,
|
||||||
&gEfiLoadedImageProtocolGuid,
|
(VOID **) &DriverBinding,
|
||||||
(VOID **) &Image
|
NULL,
|
||||||
);
|
NULL,
|
||||||
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||||
if (EFI_ERROR (Status)) {
|
);
|
||||||
Status = gBS->OpenProtocol (
|
if (EFI_ERROR (Status)) {
|
||||||
Handle,
|
return ;
|
||||||
&gEfiDriverBindingProtocolGuid,
|
}
|
||||||
(VOID **) &DriverBinding,
|
//
|
||||||
NULL,
|
// Get handle name from image protocol
|
||||||
NULL,
|
//
|
||||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
Status = gBS->HandleProtocol (
|
||||||
);
|
DriverBinding->ImageHandle,
|
||||||
if (EFI_ERROR (Status)) {
|
&gEfiLoadedImageProtocolGuid,
|
||||||
return ;
|
(VOID **) &Image
|
||||||
}
|
);
|
||||||
//
|
}
|
||||||
// Get handle name from image protocol
|
|
||||||
//
|
PdbFileName = PeCoffLoaderGetPdbPointer (Image->ImageBase);
|
||||||
Status = gBS->HandleProtocol (
|
|
||||||
DriverBinding->ImageHandle,
|
if (PdbFileName != NULL) {
|
||||||
&gEfiLoadedImageProtocolGuid,
|
GetShortPdbFileName (PdbFileName, GaugeString);
|
||||||
(VOID **) &Image
|
}
|
||||||
);
|
|
||||||
}
|
return ;
|
||||||
|
}
|
||||||
PdbFileName = PeCoffLoaderGetPdbPointer (Image->ImageBase);
|
|
||||||
|
VOID
|
||||||
if (PdbFileName != NULL) {
|
WriteBootToOsPerformanceData (
|
||||||
GetShortPdbFileName (PdbFileName, GaugeString);
|
VOID
|
||||||
}
|
)
|
||||||
|
/*++
|
||||||
return ;
|
|
||||||
}
|
Routine Description:
|
||||||
|
|
||||||
VOID
|
Allocates a block of memory and writes performance data of booting to OS into it.
|
||||||
WriteBootToOsPerformanceData (
|
|
||||||
VOID
|
Arguments:
|
||||||
)
|
|
||||||
/*++
|
None
|
||||||
|
|
||||||
Routine Description:
|
Returns:
|
||||||
|
|
||||||
Allocates a block of memory and writes performance data of booting to OS into it.
|
None
|
||||||
|
|
||||||
Arguments:
|
--*/
|
||||||
|
{
|
||||||
None
|
EFI_STATUS Status;
|
||||||
|
EFI_PHYSICAL_ADDRESS AcpiLowMemoryBase;
|
||||||
Returns:
|
UINT32 AcpiLowMemoryLength;
|
||||||
|
UINT32 LimitCount;
|
||||||
None
|
EFI_HANDLE *Handles;
|
||||||
|
UINTN NoHandles;
|
||||||
--*/
|
CHAR8 GaugeString[PERF_TOKEN_LENGTH];
|
||||||
{
|
UINT8 *Ptr;
|
||||||
EFI_STATUS Status;
|
UINT32 Index;
|
||||||
EFI_PHYSICAL_ADDRESS AcpiLowMemoryBase;
|
UINT64 Ticker;
|
||||||
UINT32 AcpiLowMemoryLength;
|
UINT64 Freq;
|
||||||
UINT32 LimitCount;
|
UINT32 Duration;
|
||||||
EFI_HANDLE *Handles;
|
UINTN LogEntryKey;
|
||||||
UINTN NoHandles;
|
CONST VOID *Handle;
|
||||||
CHAR8 GaugeString[PERF_TOKEN_LENGTH];
|
CONST CHAR8 *Token;
|
||||||
UINT8 *Ptr;
|
CONST CHAR8 *Module;
|
||||||
UINT32 Index;
|
UINT64 StartTicker;
|
||||||
UINT64 Ticker;
|
UINT64 EndTicker;
|
||||||
UINT64 Freq;
|
UINT64 StartValue;
|
||||||
UINT32 Duration;
|
UINT64 EndValue;
|
||||||
UINTN LogEntryKey;
|
BOOLEAN CountUp;
|
||||||
CONST VOID *Handle;
|
|
||||||
CONST CHAR8 *Token;
|
//
|
||||||
CONST CHAR8 *Module;
|
// Retrive time stamp count as early as possilbe
|
||||||
UINT64 StartTicker;
|
//
|
||||||
UINT64 EndTicker;
|
Ticker = GetPerformanceCounter ();
|
||||||
UINT64 StartValue;
|
|
||||||
UINT64 EndValue;
|
Freq = GetPerformanceCounterProperties (&StartValue, &EndValue);
|
||||||
BOOLEAN CountUp;
|
|
||||||
|
Freq = DivU64x32 (Freq, 1000);
|
||||||
//
|
|
||||||
// Retrive time stamp count as early as possilbe
|
mPerfHeader.CpuFreq = Freq;
|
||||||
//
|
|
||||||
Ticker = GetPerformanceCounter ();
|
//
|
||||||
|
// Record BDS raw performance data
|
||||||
Freq = GetPerformanceCounterProperties (&StartValue, &EndValue);
|
//
|
||||||
|
if (EndValue >= StartValue) {
|
||||||
Freq = DivU64x32 (Freq, 1000);
|
mPerfHeader.BDSRaw = Ticker - StartValue;
|
||||||
|
CountUp = TRUE;
|
||||||
mPerfHeader.CpuFreq = Freq;
|
} else {
|
||||||
|
mPerfHeader.BDSRaw = StartValue - Ticker;
|
||||||
//
|
CountUp = FALSE;
|
||||||
// Record BDS raw performance data
|
}
|
||||||
//
|
|
||||||
if (EndValue >= StartValue) {
|
AcpiLowMemoryLength = 0x2000;
|
||||||
mPerfHeader.BDSRaw = Ticker - StartValue;
|
|
||||||
CountUp = TRUE;
|
//
|
||||||
} else {
|
// Allocate a block of memory that contain performance data to OS
|
||||||
mPerfHeader.BDSRaw = StartValue - Ticker;
|
//
|
||||||
CountUp = FALSE;
|
Status = gBS->AllocatePages (
|
||||||
}
|
AllocateAnyPages,
|
||||||
|
EfiACPIReclaimMemory,
|
||||||
AcpiLowMemoryLength = 0x2000;
|
EFI_SIZE_TO_PAGES (AcpiLowMemoryLength),
|
||||||
|
&AcpiLowMemoryBase
|
||||||
//
|
);
|
||||||
// Allocate a block of memory that contain performance data to OS
|
if (EFI_ERROR (Status)) {
|
||||||
//
|
return ;
|
||||||
Status = gBS->AllocatePages (
|
}
|
||||||
AllocateAnyPages,
|
|
||||||
EfiACPIReclaimMemory,
|
|
||||||
EFI_SIZE_TO_PAGES (AcpiLowMemoryLength),
|
Ptr = (UINT8 *) ((UINT32) AcpiLowMemoryBase + sizeof (PERF_HEADER));
|
||||||
&AcpiLowMemoryBase
|
LimitCount = (AcpiLowMemoryLength - sizeof (PERF_HEADER)) / sizeof (PERF_DATA);
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
//
|
||||||
return ;
|
// Put Detailed performance data into memory
|
||||||
}
|
//
|
||||||
|
Handles = NULL;
|
||||||
|
Status = gBS->LocateHandleBuffer (
|
||||||
Ptr = (UINT8 *) ((UINT32) AcpiLowMemoryBase + sizeof (PERF_HEADER));
|
AllHandles,
|
||||||
LimitCount = (AcpiLowMemoryLength - sizeof (PERF_HEADER)) / sizeof (PERF_DATA);
|
NULL,
|
||||||
|
NULL,
|
||||||
//
|
&NoHandles,
|
||||||
// Put Detailed performance data into memory
|
&Handles
|
||||||
//
|
);
|
||||||
Handles = NULL;
|
if (EFI_ERROR (Status)) {
|
||||||
Status = gBS->LocateHandleBuffer (
|
gBS->FreePages (AcpiLowMemoryBase, 1);
|
||||||
AllHandles,
|
return ;
|
||||||
NULL,
|
}
|
||||||
NULL,
|
//
|
||||||
&NoHandles,
|
// Get DXE drivers performance
|
||||||
&Handles
|
//
|
||||||
);
|
for (Index = 0; Index < NoHandles; Index++) {
|
||||||
if (EFI_ERROR (Status)) {
|
Ticker = 0;
|
||||||
gBS->FreePages (AcpiLowMemoryBase, 1);
|
LogEntryKey = 0;
|
||||||
return ;
|
while ((LogEntryKey = GetPerformanceMeasurement (
|
||||||
}
|
LogEntryKey,
|
||||||
//
|
&Handle,
|
||||||
// Get DXE drivers performance
|
&Token,
|
||||||
//
|
&Module,
|
||||||
for (Index = 0; Index < NoHandles; Index++) {
|
&StartTicker,
|
||||||
Ticker = 0;
|
&EndTicker)) != 0) {
|
||||||
LogEntryKey = 0;
|
if ((Handle == Handles[Index]) && (EndTicker != 0)) {
|
||||||
while ((LogEntryKey = GetPerformanceMeasurement (
|
Ticker += CountUp ? (EndTicker - StartTicker) : (StartTicker - EndTicker);
|
||||||
LogEntryKey,
|
}
|
||||||
&Handle,
|
}
|
||||||
&Token,
|
|
||||||
&Module,
|
Duration = (UINT32) DivU64x32 (Ticker, (UINT32) Freq);
|
||||||
&StartTicker,
|
|
||||||
&EndTicker)) != 0) {
|
if (Duration > 0) {
|
||||||
if ((Handle == Handles[Index]) && (EndTicker != 0)) {
|
|
||||||
Ticker += CountUp ? (EndTicker - StartTicker) : (StartTicker - EndTicker);
|
GetNameFromHandle (Handles[Index], GaugeString);
|
||||||
}
|
|
||||||
}
|
AsciiStrCpy (mPerfData.Token, GaugeString);
|
||||||
|
mPerfData.Duration = Duration;
|
||||||
Duration = (UINT32) DivU64x32 (Ticker, (UINT32) Freq);
|
|
||||||
|
CopyMem (Ptr, &mPerfData, sizeof (PERF_DATA));
|
||||||
if (Duration > 0) {
|
Ptr += sizeof (PERF_DATA);
|
||||||
|
|
||||||
GetNameFromHandle (Handles[Index], GaugeString);
|
mPerfHeader.Count++;
|
||||||
|
if (mPerfHeader.Count == LimitCount) {
|
||||||
AsciiStrCpy (mPerfData.Token, GaugeString);
|
goto Done;
|
||||||
mPerfData.Duration = Duration;
|
}
|
||||||
|
}
|
||||||
CopyMem (Ptr, &mPerfData, sizeof (PERF_DATA));
|
}
|
||||||
Ptr += sizeof (PERF_DATA);
|
|
||||||
|
FreePool (Handles);
|
||||||
mPerfHeader.Count++;
|
|
||||||
if (mPerfHeader.Count == LimitCount) {
|
//
|
||||||
goto Done;
|
// Get inserted performance data
|
||||||
}
|
//
|
||||||
}
|
LogEntryKey = 0;
|
||||||
}
|
while ((LogEntryKey = GetPerformanceMeasurement (
|
||||||
|
LogEntryKey,
|
||||||
FreePool (Handles);
|
&Handle,
|
||||||
|
&Token,
|
||||||
//
|
&Module,
|
||||||
// Get inserted performance data
|
&StartTicker,
|
||||||
//
|
&EndTicker)) != 0) {
|
||||||
LogEntryKey = 0;
|
if (Handle == NULL && EndTicker != 0) {
|
||||||
while ((LogEntryKey = GetPerformanceMeasurement (
|
|
||||||
LogEntryKey,
|
ZeroMem (&mPerfData, sizeof (PERF_DATA));
|
||||||
&Handle,
|
|
||||||
&Token,
|
AsciiStrnCpy (mPerfData.Token, Token, PERF_TOKEN_LENGTH);
|
||||||
&Module,
|
Ticker = CountUp ? (EndTicker - StartTicker) : (StartTicker - EndTicker);
|
||||||
&StartTicker,
|
|
||||||
&EndTicker)) != 0) {
|
mPerfData.Duration = (UINT32) DivU64x32 (Ticker, (UINT32) Freq);
|
||||||
if (Handle == NULL && EndTicker != 0) {
|
|
||||||
|
CopyMem (Ptr, &mPerfData, sizeof (PERF_DATA));
|
||||||
ZeroMem (&mPerfData, sizeof (PERF_DATA));
|
Ptr += sizeof (PERF_DATA);
|
||||||
|
|
||||||
AsciiStrnCpy (mPerfData.Token, Token, PERF_TOKEN_LENGTH);
|
mPerfHeader.Count++;
|
||||||
Ticker = CountUp ? (EndTicker - StartTicker) : (StartTicker - EndTicker);
|
if (mPerfHeader.Count == LimitCount) {
|
||||||
|
goto Done;
|
||||||
mPerfData.Duration = (UINT32) DivU64x32 (Ticker, (UINT32) Freq);
|
}
|
||||||
|
}
|
||||||
CopyMem (Ptr, &mPerfData, sizeof (PERF_DATA));
|
}
|
||||||
Ptr += sizeof (PERF_DATA);
|
|
||||||
|
Done:
|
||||||
mPerfHeader.Count++;
|
|
||||||
if (mPerfHeader.Count == LimitCount) {
|
mPerfHeader.Signiture = PERFORMANCE_SIGNATURE;
|
||||||
goto Done;
|
|
||||||
}
|
//
|
||||||
}
|
// Put performance data to memory
|
||||||
}
|
//
|
||||||
|
CopyMem (
|
||||||
Done:
|
(UINTN *) (UINTN) AcpiLowMemoryBase,
|
||||||
|
&mPerfHeader,
|
||||||
mPerfHeader.Signiture = PERFORMANCE_SIGNATURE;
|
sizeof (PERF_HEADER)
|
||||||
|
);
|
||||||
//
|
|
||||||
// Put performance data to memory
|
gRT->SetVariable (
|
||||||
//
|
L"PerfDataMemAddr",
|
||||||
CopyMem (
|
&gEfiGenericPlatformVariableGuid,
|
||||||
(UINTN *) (UINTN) AcpiLowMemoryBase,
|
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||||
&mPerfHeader,
|
sizeof (EFI_PHYSICAL_ADDRESS),
|
||||||
sizeof (PERF_HEADER)
|
&AcpiLowMemoryBase
|
||||||
);
|
);
|
||||||
|
|
||||||
gRT->SetVariable (
|
return ;
|
||||||
L"PerfDataMemAddr",
|
}
|
||||||
&gEfiGenericPlatformVariableGuid,
|
|
||||||
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
|
||||||
sizeof (EFI_PHYSICAL_ADDRESS),
|
|
||||||
&AcpiLowMemoryBase
|
|
||||||
);
|
|
||||||
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,114 +0,0 @@
|
||||||
/**@file
|
|
||||||
Copyright (c) 2007, Intel Corporation
|
|
||||||
|
|
||||||
All rights reserved. This program and the accompanying materials
|
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
|
||||||
http://opensource.org/licenses/bsd-license.php
|
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
||||||
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#include "InternalBdsLib.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
Get current boot mode.
|
|
||||||
|
|
||||||
@param HobStart Start pointer of hob list
|
|
||||||
@param BootMode Current boot mode recorded in PHIT hob
|
|
||||||
|
|
||||||
@retval EFI_NOT_FOUND Invalid hob header
|
|
||||||
@retval EFI_SUCCESS Boot mode found
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
R8_GetHobBootMode (
|
|
||||||
IN VOID *HobStart,
|
|
||||||
OUT EFI_BOOT_MODE *BootMode
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Porting Guide:
|
|
||||||
// This library interface is simply obsolete.
|
|
||||||
// Include the source code to user code.
|
|
||||||
// In fact, since EFI_HANDOFF_HOB must be the first Hob,
|
|
||||||
// the following code can retrieve boot mode.
|
|
||||||
//
|
|
||||||
// EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
|
|
||||||
//
|
|
||||||
// HandOffHob = GetHobList ();
|
|
||||||
// ASSERT (HandOffHob->Header.HobType == EFI_HOB_TYPE_HANDOFF);
|
|
||||||
//
|
|
||||||
// BootMode = HandOffHob->BootMode;
|
|
||||||
//
|
|
||||||
EFI_PEI_HOB_POINTERS Hob;
|
|
||||||
|
|
||||||
Hob.Raw = HobStart;
|
|
||||||
if (Hob.Header->HobType != EFI_HOB_TYPE_HANDOFF) {
|
|
||||||
return EFI_NOT_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
*BootMode = Hob.HandoffInformationTable->BootMode;
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Get the next guid hob.
|
|
||||||
|
|
||||||
@param HobStart A pointer to the start hob.
|
|
||||||
@param Guid A pointer to a guid.
|
|
||||||
@param Buffer A pointer to the buffer.
|
|
||||||
@param BufferSize Buffer size.
|
|
||||||
|
|
||||||
@retval EFI_NOT_FOUND Next Guid hob not found
|
|
||||||
@retval EFI_SUCCESS Next Guid hob found and data for this Guid got
|
|
||||||
@retval EFI_INVALID_PARAMETER invalid parameter
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
R8_GetNextGuidHob (
|
|
||||||
IN OUT VOID **HobStart,
|
|
||||||
IN EFI_GUID * Guid,
|
|
||||||
OUT VOID **Buffer,
|
|
||||||
OUT UINTN *BufferSize OPTIONAL
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Porting Guide:
|
|
||||||
// This library interface is changed substantially with R9 counerpart GetNextGuidHob ().
|
|
||||||
// 1. R9 GetNextGuidHob has two parameters and returns the matched GUID HOB from the StartHob.
|
|
||||||
// 2. R9 GetNextGuidHob does not strip the HOB header, so caller is required to apply
|
|
||||||
// GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE () to extract the data section and its
|
|
||||||
// size info respectively.
|
|
||||||
// 3. this function does not skip the starting HOB pointer unconditionally:
|
|
||||||
// it returns HobStart back if HobStart itself meets the requirement;
|
|
||||||
// caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
|
|
||||||
//
|
|
||||||
EFI_PEI_HOB_POINTERS GuidHob;
|
|
||||||
|
|
||||||
if (Buffer == NULL) {
|
|
||||||
return EFI_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
|
|
||||||
GuidHob.Raw = GetNextGuidHob (Guid, *HobStart);
|
|
||||||
if (GuidHob.Raw == NULL) {
|
|
||||||
return EFI_NOT_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
*Buffer = GET_GUID_HOB_DATA (GuidHob.Guid);
|
|
||||||
if (BufferSize != NULL) {
|
|
||||||
*BufferSize = GET_GUID_HOB_DATA_SIZE (GuidHob.Guid);
|
|
||||||
}
|
|
||||||
|
|
||||||
*HobStart = GET_NEXT_HOB (GuidHob);
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,59 +0,0 @@
|
||||||
/**@file
|
|
||||||
Copyright (c) 2007, Intel Corporation
|
|
||||||
|
|
||||||
All rights reserved. This program and the accompanying materials
|
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
|
||||||
http://opensource.org/licenses/bsd-license.php
|
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
||||||
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Get current boot mode.
|
|
||||||
|
|
||||||
@param HobStart Start pointer of hob list
|
|
||||||
@param BootMode Current boot mode recorded in PHIT hob
|
|
||||||
|
|
||||||
@retval EFI_NOT_FOUND Invalid hob header
|
|
||||||
@retval EFI_SUCCESS Boot mode found
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
R8_GetHobBootMode (
|
|
||||||
IN VOID *HobStart,
|
|
||||||
OUT EFI_BOOT_MODE *BootMode
|
|
||||||
)
|
|
||||||
;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Get the next guid hob.
|
|
||||||
|
|
||||||
@param HobStart A pointer to the start hob.
|
|
||||||
@param Guid A pointer to a guid.
|
|
||||||
@param Buffer A pointer to the buffer.
|
|
||||||
@param BufferSize Buffer size.
|
|
||||||
|
|
||||||
@retval EFI_NOT_FOUND Next Guid hob not found
|
|
||||||
@retval EFI_SUCCESS Next Guid hob found and data for this Guid got
|
|
||||||
@retval EFI_INVALID_PARAMETER invalid parameter
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
R8_GetNextGuidHob (
|
|
||||||
IN OUT VOID **HobStart,
|
|
||||||
IN EFI_GUID * Guid,
|
|
||||||
OUT VOID **Buffer,
|
|
||||||
OUT UINTN *BufferSize OPTIONAL
|
|
||||||
)
|
|
||||||
;
|
|
||||||
|
|
||||||
|
|
|
@ -1,34 +1,22 @@
|
||||||
/** @file
|
/** @file
|
||||||
|
Boot Manager Machine type
|
||||||
Copyright (c) 2005 - 2006, Intel Corporation
|
|
||||||
All rights reserved. This program and the accompanying materials
|
Copyright (c) 2005 - 2008, Intel Corporation. <BR>
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
All rights reserved. This program and the accompanying materials
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
http://opensource.org/licenses/bsd-license.php
|
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.
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
Module Name:
|
|
||||||
|
**/
|
||||||
BmMachine.h
|
|
||||||
|
#ifndef _BM_MACHINE_H
|
||||||
Abstract:
|
#define _BM_MACHINE_H
|
||||||
|
|
||||||
Boot Manager Machine type
|
//@MT:#include "CpuIA32.h"
|
||||||
|
|
||||||
|
#define DEFAULT_REMOVABLE_FILE_NAME L"\\EFI\\BOOT\\BOOTX64.EFI"
|
||||||
|
|
||||||
Revision History
|
#endif
|
||||||
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#ifndef _BM_MACHINE_H
|
|
||||||
#define _BM_MACHINE_H
|
|
||||||
|
|
||||||
//@MT:#include "CpuIA32.h"
|
|
||||||
|
|
||||||
#define DEFAULT_REMOVABLE_FILE_NAME L"\\EFI\\BOOT\\BOOTX64.EFI"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
title ClearDr.asm
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
;
|
|
||||||
; Copyright (c) 2005, Intel Corporation
|
|
||||||
; All rights reserved. This program and the accompanying materials
|
|
||||||
; are licensed and made available under the terms and conditions of the BSD License
|
|
||||||
; which accompanies this distribution. The full text of the license may be found at
|
|
||||||
; http://opensource.org/licenses/bsd-license.php
|
|
||||||
;
|
|
||||||
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
||||||
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
||||||
;
|
|
||||||
; Module Name:
|
|
||||||
;
|
|
||||||
; ClearDr.asm
|
|
||||||
;
|
|
||||||
; Abstract:
|
|
||||||
;
|
|
||||||
; Clear dr0 dr1 register
|
|
||||||
;
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
text SEGMENT
|
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
; VOID
|
|
||||||
; ClearDebugRegisters (
|
|
||||||
; VOID
|
|
||||||
; )
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
ClearDebugRegisters PROC PUBLIC
|
|
||||||
push rax
|
|
||||||
xor rax, rax
|
|
||||||
mov dr0, rax
|
|
||||||
mov dr1, rax
|
|
||||||
pop rax
|
|
||||||
ret
|
|
||||||
ClearDebugRegisters ENDP
|
|
||||||
|
|
||||||
END
|
|
||||||
|
|
Loading…
Reference in New Issue