InOsEmuPkg: Rename package to EmulatorPkg & Sec to Host
* Rename InOsEmuPkg to EmulatorPkg * Rename Unix/Sec to Unix/Host Signed-off-by: jljusten Reviewed-by: andrewfish Reviewed-by: geekboy15a git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11918 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
183
EmulatorPkg/Library/DevicePathTextLib/DevicePathTextLib.c
Normal file
183
EmulatorPkg/Library/DevicePathTextLib/DevicePathTextLib.c
Normal file
@@ -0,0 +1,183 @@
|
||||
/** @file
|
||||
Null Platform Hook Library instance.
|
||||
|
||||
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include <Base.h>
|
||||
|
||||
#include <Protocol/EmuThunk.h>
|
||||
#include <Protocol/EmuGraphicsWindow.h>
|
||||
#include <Protocol/EmuBlockIo.h>
|
||||
#include <Protocol/SimpleFileSystem.h>
|
||||
#include <Protocol/EmuThread.h>
|
||||
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/DevicePathToTextLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
|
||||
|
||||
/**
|
||||
Converts a Vendor device path structure to its string representative.
|
||||
|
||||
@param Str The string representative of input device.
|
||||
@param DevPath The input device path structure.
|
||||
@param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
|
||||
of the display node is used, where applicable. If DisplayOnly
|
||||
is FALSE, then the longer text representation of the display node
|
||||
is used.
|
||||
@param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
|
||||
representation for a device node can be used, where applicable.
|
||||
|
||||
@return EFI_NOT_FOUND if no string representation exists.
|
||||
@return EFI_SUCCESS a string representation was created.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
DevPathToTextVendorLib (
|
||||
IN OUT POOL_PRINT *Str,
|
||||
IN VOID *DevPath,
|
||||
IN BOOLEAN DisplayOnly,
|
||||
IN BOOLEAN AllowShortcuts
|
||||
)
|
||||
{
|
||||
EMU_VENDOR_DEVICE_PATH_NODE *Vendor;
|
||||
CHAR16 *Type;
|
||||
|
||||
Vendor = (EMU_VENDOR_DEVICE_PATH_NODE *)DevPath;
|
||||
if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuThunkProtocolGuid)) {
|
||||
CatPrint (Str, L"EmuThunk()");
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuGraphicsWindowProtocolGuid)) {
|
||||
CatPrint (Str, L"EmuGraphics(%d)", Vendor->Instance);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEfiSimpleFileSystemProtocolGuid)) {
|
||||
CatPrint (Str, L"EmuFs(%d)", Vendor->Instance);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuBlockIoProtocolGuid)) {
|
||||
CatPrint (Str, L"EmuBlk(%d)", Vendor->Instance);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuThreadThunkProtocolGuid)) {
|
||||
CatPrint (Str, L"EmuThread()");
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
/**
|
||||
Converts a text device path node to Hardware Vendor device path structure.
|
||||
|
||||
@param TextDeviceNode The input Text device path node.
|
||||
|
||||
@return A pointer to the newly-created Hardware Vendor device path structure.
|
||||
|
||||
**/
|
||||
EFI_DEVICE_PATH_PROTOCOL *
|
||||
DevPathFromTextEmuThunk (
|
||||
IN CHAR16 *TextDeviceNode
|
||||
)
|
||||
{
|
||||
CHAR16 *Str;
|
||||
VENDOR_DEVICE_PATH *Vendor;
|
||||
|
||||
Str = GetNextParamStr (&TextDeviceNode);
|
||||
Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
|
||||
HARDWARE_DEVICE_PATH,
|
||||
HW_VENDOR_DP,
|
||||
(UINT16) sizeof (VENDOR_DEVICE_PATH)
|
||||
);
|
||||
CopyGuid (&Vendor->Guid, &gEmuThunkProtocolGuid);
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
|
||||
}
|
||||
|
||||
/**
|
||||
Converts a text device path node to Hardware Vendor device path structure.
|
||||
|
||||
@param TextDeviceNode The input Text device path node.
|
||||
|
||||
@return A pointer to the newly-created Hardware Vendor device path structure.
|
||||
|
||||
**/
|
||||
EFI_DEVICE_PATH_PROTOCOL *
|
||||
DevPathFromTextEmuThread (
|
||||
IN CHAR16 *TextDeviceNode
|
||||
)
|
||||
{
|
||||
CHAR16 *Str;
|
||||
VENDOR_DEVICE_PATH *Vendor;
|
||||
|
||||
Str = GetNextParamStr (&TextDeviceNode);
|
||||
Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (
|
||||
HARDWARE_DEVICE_PATH,
|
||||
HW_VENDOR_DP,
|
||||
(UINT16) sizeof (VENDOR_DEVICE_PATH)
|
||||
);
|
||||
CopyGuid (&Vendor->Guid, &gEmuThreadThunkProtocolGuid);
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
|
||||
}
|
||||
|
||||
/**
|
||||
Converts a text device path node to Hardware Vendor device path structure.
|
||||
|
||||
@param TextDeviceNode The input Text device path node.
|
||||
|
||||
@return A pointer to the newly-created Hardware Vendor device path structure.
|
||||
|
||||
**/
|
||||
EFI_DEVICE_PATH_PROTOCOL *
|
||||
DevPathFromTextEmuFs (
|
||||
IN CHAR16 *TextDeviceNode
|
||||
)
|
||||
{
|
||||
CHAR16 *Str;
|
||||
EMU_VENDOR_DEVICE_PATH_NODE *Vendor;
|
||||
|
||||
Str = GetNextParamStr (&TextDeviceNode);
|
||||
Vendor = (EMU_VENDOR_DEVICE_PATH_NODE *) CreateDeviceNode (
|
||||
HARDWARE_DEVICE_PATH,
|
||||
HW_VENDOR_DP,
|
||||
(UINT16) sizeof (EMU_VENDOR_DEVICE_PATH_NODE)
|
||||
);
|
||||
CopyGuid (&Vendor->VendorDevicePath.Guid, &gEfiSimpleFileSystemProtocolGuid);
|
||||
Vendor->Instance = (UINT32) StrDecimalToUintn (Str);
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
|
||||
}
|
||||
|
||||
/**
|
||||
Register the Filter function
|
||||
|
||||
@param ImageHandle The firmware allocated handle for the EFI image.
|
||||
@param SystemTable A pointer to the EFI System Table.
|
||||
|
||||
@retval EFI_SUCCESS The constructor executed correctly.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
DevicePathToTextLibConstructor (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
|
||||
{
|
||||
DevPathToTextSetVendorDevicePathFilter (DevPathToTextVendorLib);
|
||||
DevicePathFromTextAddFilter (L"EmuThunk", DevPathFromTextEmuThunk);
|
||||
DevicePathFromTextAddFilter (L"EmuThread", DevPathFromTextEmuThread);
|
||||
DevicePathFromTextAddFilter (L"EmuFs", DevPathFromTextEmuFs);
|
||||
return EFI_SUCCESS;
|
||||
}
|
48
EmulatorPkg/Library/DevicePathTextLib/DevicePathTextLib.inf
Normal file
48
EmulatorPkg/Library/DevicePathTextLib/DevicePathTextLib.inf
Normal file
@@ -0,0 +1,48 @@
|
||||
## @file
|
||||
# Null DevicePathToText library.
|
||||
#
|
||||
# Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
##
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = DevicePathTextLib
|
||||
FILE_GUID = DCD1F939-1732-CA4D-81B7-C757AEC84DBC
|
||||
MODULE_TYPE = UEFI_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = NULL|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE
|
||||
CONSTRUCTOR = DevicePathToTextLibConstructor
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
#
|
||||
|
||||
[Sources]
|
||||
DevicePathTextLib.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
EmulatorPkg/EmulatorPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
BaseLib
|
||||
DebugLib
|
||||
DevicePathLib
|
||||
|
||||
[Protocols]
|
||||
gEmuThunkProtocolGuid
|
||||
gEmuGraphicsWindowProtocolGuid
|
||||
gEfiSimpleFileSystemProtocolGuid
|
||||
gEmuBlockIoProtocolGuid
|
||||
gEmuThreadThunkProtocolGuid
|
128
EmulatorPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.c
Normal file
128
EmulatorPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.c
Normal file
@@ -0,0 +1,128 @@
|
||||
/** @file
|
||||
A non-functional instance of the Timer Library.
|
||||
|
||||
Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php.
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include <PiPei.h>
|
||||
#include <Library/TimerLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/EmuThunkLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
|
||||
#include <Protocol/Timer.h>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Stalls the CPU for at least the given number of microseconds.
|
||||
|
||||
Stalls the CPU for the number of microseconds specified by MicroSeconds.
|
||||
|
||||
@param MicroSeconds The minimum number of microseconds to delay.
|
||||
|
||||
@return The value of MicroSeconds inputted.
|
||||
|
||||
**/
|
||||
UINTN
|
||||
EFIAPI
|
||||
MicroSecondDelay (
|
||||
IN UINTN MicroSeconds
|
||||
)
|
||||
{
|
||||
return NanoSecondDelay (MicroSeconds * 1000);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Stalls the CPU for at least the given number of nanoseconds.
|
||||
|
||||
Stalls the CPU for the number of nanoseconds specified by NanoSeconds.
|
||||
|
||||
@param NanoSeconds The minimum number of nanoseconds to delay.
|
||||
|
||||
@return The value of NanoSeconds inputted.
|
||||
|
||||
**/
|
||||
UINTN
|
||||
EFIAPI
|
||||
NanoSecondDelay (
|
||||
IN UINTN NanoSeconds
|
||||
)
|
||||
{
|
||||
gEmuThunk->Sleep (NanoSeconds);
|
||||
return NanoSeconds;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Retrieves the current value of a 64-bit free running performance counter.
|
||||
|
||||
The counter can either count up by 1 or count down by 1. If the physical
|
||||
performance counter counts by a larger increment, then the counter values
|
||||
must be translated. The properties of the counter can be retrieved from
|
||||
GetPerformanceCounterProperties().
|
||||
|
||||
@return The current value of the free running performance counter.
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
GetPerformanceCounter (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return gEmuThunk->QueryPerformanceCounter ();
|
||||
}
|
||||
|
||||
/**
|
||||
Retrieves the 64-bit frequency in Hz and the range of performance counter
|
||||
values.
|
||||
|
||||
If StartValue is not NULL, then the value that the performance counter starts
|
||||
with immediately after is it rolls over is returned in StartValue. If
|
||||
EndValue is not NULL, then the value that the performance counter end with
|
||||
immediately before it rolls over is returned in EndValue. The 64-bit
|
||||
frequency of the performance counter in Hz is always returned. If StartValue
|
||||
is less than EndValue, then the performance counter counts up. If StartValue
|
||||
is greater than EndValue, then the performance counter counts down. For
|
||||
example, a 64-bit free running counter that counts up would have a StartValue
|
||||
of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter
|
||||
that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0.
|
||||
|
||||
@param StartValue The value the performance counter starts with when it
|
||||
rolls over.
|
||||
@param EndValue The value that the performance counter ends with before
|
||||
it rolls over.
|
||||
|
||||
@return The frequency in Hz.
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
GetPerformanceCounterProperties (
|
||||
OUT UINT64 *StartValue, OPTIONAL
|
||||
OUT UINT64 *EndValue OPTIONAL
|
||||
)
|
||||
{
|
||||
|
||||
if (StartValue != NULL) {
|
||||
*StartValue = 0ULL;
|
||||
}
|
||||
if (EndValue != NULL) {
|
||||
*EndValue = (UINT64)-1LL;
|
||||
}
|
||||
|
||||
return gEmuThunk->QueryPerformanceFrequency ();
|
||||
}
|
||||
|
||||
|
44
EmulatorPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.inf
Normal file
44
EmulatorPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.inf
Normal file
@@ -0,0 +1,44 @@
|
||||
## @file
|
||||
# NULL instance of Timer Library as a template.
|
||||
#
|
||||
# A non-functional instance of the Timer Library that can be used as a template
|
||||
# for the implementation of a functional timer library instance. This library instance can
|
||||
# also be used to test build DXE, Runtime, DXE SAL, and DXE SMM modules that require timer
|
||||
# services as well as EBC modules that require timer services.
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php.
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
#
|
||||
##
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = EmuDxeCodeTimerLib
|
||||
FILE_GUID = FB184AF4-A2F2-EE4E-8885-E81E5D8B0135
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = TimerLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_DRIVER UEFI_APPLICATION
|
||||
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
#
|
||||
|
||||
[Sources]
|
||||
DxeCoreTimerLib.c
|
||||
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
EmulatorPkg/EmulatorPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
DebugLib
|
||||
EmuThunkLib
|
||||
|
88
EmulatorPkg/Library/DxeEmuLib/DxeEmuLib.c
Normal file
88
EmulatorPkg/Library/DxeEmuLib/DxeEmuLib.c
Normal file
@@ -0,0 +1,88 @@
|
||||
/*++ @file
|
||||
|
||||
Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
|
||||
Portions copyright (c) 2011, Apple Inc. All rights reserved.
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include <PiDxe.h>
|
||||
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/HobLib.h>
|
||||
#include <Library/EmuThunkLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
|
||||
EMU_THUNK_PROTOCOL *gEmuThunk = NULL;
|
||||
|
||||
|
||||
/**
|
||||
The constructor function caches the pointer of EMU Thunk protocol.
|
||||
|
||||
@param ImageHandle The firmware allocated handle for the EFI image.
|
||||
@param SystemTable A pointer to the EFI System Table.
|
||||
|
||||
@retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
DxeEmuLibConstructor (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_HOB_GUID_TYPE *GuidHob;
|
||||
|
||||
GuidHob = GetFirstGuidHob (&gEmuThunkProtocolGuid);
|
||||
ASSERT (GuidHob != NULL);
|
||||
|
||||
gEmuThunk = (EMU_THUNK_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob)));
|
||||
ASSERT (gEmuThunk != NULL);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Serach the EMU IO Thunk database for a matching EMU IO Thunk
|
||||
Protocol instance.
|
||||
|
||||
@param Protocol Protocol to search for.
|
||||
@param Instance Instance of protocol to search for.
|
||||
|
||||
@retval NULL Protocol and Instance not found.
|
||||
@retval other EMU IO Thunk protocol that matched.
|
||||
|
||||
**/
|
||||
EMU_IO_THUNK_PROTOCOL *
|
||||
EFIAPI
|
||||
GetIoThunkInstance (
|
||||
IN EFI_GUID *Protocol,
|
||||
IN UINTN Instance
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EMU_IO_THUNK_PROTOCOL *EmuIoThunk;
|
||||
|
||||
for (Status = EFI_SUCCESS, EmuIoThunk = NULL; !EFI_ERROR (Status); ) {
|
||||
Status = gEmuThunk->GetNextProtocol (FALSE, &EmuIoThunk);
|
||||
if (EFI_ERROR (Status)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (EmuIoThunk->Instance == Instance) {
|
||||
if (CompareGuid (EmuIoThunk->Protocol, Protocol)) {
|
||||
return EmuIoThunk;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
46
EmulatorPkg/Library/DxeEmuLib/DxeEmuLib.inf
Normal file
46
EmulatorPkg/Library/DxeEmuLib/DxeEmuLib.inf
Normal file
@@ -0,0 +1,46 @@
|
||||
## @file
|
||||
# A library to produce the global variable 'gEmuThunk'
|
||||
#
|
||||
# This library contains a single global variable 'gEmuThunk' along with a constructor to
|
||||
# initialize that global.
|
||||
# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
# Portions copyright (c) 2011, Apple Inc. 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 = DxeEmuLib
|
||||
FILE_GUID = 31479AFD-B06F-4E4A-863B-A8F7E7710778
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = EmuThunkLib
|
||||
|
||||
CONSTRUCTOR = DxeEmuLibConstructor
|
||||
|
||||
|
||||
[Sources]
|
||||
DxeEmuLib.c
|
||||
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
EmulatorPkg/EmulatorPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
HobLib
|
||||
DebugLib
|
||||
BaseMemoryLib
|
||||
|
||||
|
||||
[Protocols]
|
||||
gEmuThunkProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
|
@@ -0,0 +1,103 @@
|
||||
/** @file
|
||||
Provides services to perform additional actions to relocate and unload
|
||||
PE/Coff image for Emu environment specific purpose such as souce level debug.
|
||||
This version only works for DXE phase
|
||||
|
||||
Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
|
||||
Portions copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include <PiDxe.h>
|
||||
|
||||
#include <Protocol/EmuThunk.h>
|
||||
|
||||
#include <Library/PeCoffLib.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/HobLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/PeCoffExtraActionLib.h>
|
||||
|
||||
//
|
||||
// Cache of UnixThunk protocol
|
||||
//
|
||||
EMU_THUNK_PROTOCOL *mThunk = NULL;
|
||||
|
||||
|
||||
/**
|
||||
The constructor function gets the pointer of the WinNT thunk functions
|
||||
It will ASSERT() if Unix thunk protocol is not installed.
|
||||
|
||||
@retval EFI_SUCCESS Unix thunk protocol is found and cached.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
DxeEmuPeCoffLibExtraActionConstructor (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_HOB_GUID_TYPE *GuidHob;
|
||||
|
||||
//
|
||||
// Retrieve EmuThunkProtocol from GUID'ed HOB
|
||||
//
|
||||
GuidHob = GetFirstGuidHob (&gEmuThunkProtocolGuid);
|
||||
ASSERT (GuidHob != NULL);
|
||||
mThunk = (EMU_THUNK_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob)));
|
||||
ASSERT (mThunk != NULL);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Performs additional actions after a PE/COFF image has been loaded and relocated.
|
||||
|
||||
If ImageContext is NULL, then ASSERT().
|
||||
|
||||
@param ImageContext Pointer to the image context structure that describes the
|
||||
PE/COFF image that has already been loaded and relocated.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
PeCoffLoaderRelocateImageExtraAction (
|
||||
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
|
||||
)
|
||||
{
|
||||
if (mThunk != NULL) {
|
||||
mThunk->PeCoffRelocateImageExtraAction (ImageContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Performs additional actions just before a PE/COFF image is unloaded. Any resources
|
||||
that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.
|
||||
|
||||
If ImageContext is NULL, then ASSERT().
|
||||
|
||||
@param ImageContext Pointer to the image context structure that describes the
|
||||
PE/COFF image that is being unloaded.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
PeCoffLoaderUnloadImageExtraAction (
|
||||
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
|
||||
)
|
||||
{
|
||||
if (mThunk != NULL) {
|
||||
mThunk->PeCoffUnloadImageExtraAction (ImageContext);
|
||||
}
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
## @file
|
||||
# PeCoff extra action libary for DXE phase that run Emu emulator.
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
# Portions copyright (c) 2011, Apple Inc. 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 = DxeEmuPeCoffExtraActionLib
|
||||
FILE_GUID = 68FCD487-D230-6846-95B1-5E1F2EF942C4
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = PeCoffExtraActionLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_DRIVER
|
||||
|
||||
CONSTRUCTOR = DxeEmuPeCoffLibExtraActionConstructor
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32
|
||||
#
|
||||
|
||||
[Sources]
|
||||
DxeEmuPeCoffExtraActionLib.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
EmulatorPkg/EmulatorPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
DebugLib
|
||||
HobLib
|
||||
BaseMemoryLib
|
||||
|
||||
[Protocols]
|
||||
gEmuThunkProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
|
119
EmulatorPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.c
Normal file
119
EmulatorPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.c
Normal file
@@ -0,0 +1,119 @@
|
||||
/** @file
|
||||
Serial Port Lib that thunks back to Emulator services to write to StdErr.
|
||||
All read functions are stubed out.
|
||||
|
||||
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Portions copyright (c) 2011, Apple Inc. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php.
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include <PiDxe.h>
|
||||
#include <Library/SerialPortLib.h>
|
||||
#include <Library/EmuThunkLib.h>
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Initialize the serial device hardware.
|
||||
|
||||
If no initialization is required, then return RETURN_SUCCESS.
|
||||
If the serial device was successfully initialized, then return RETURN_SUCCESS.
|
||||
If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.
|
||||
|
||||
@retval RETURN_SUCCESS The serial device was initialized.
|
||||
@retval RETURN_DEVICE_ERROR The serial device could not be initialized.
|
||||
|
||||
**/
|
||||
RETURN_STATUS
|
||||
EFIAPI
|
||||
SerialPortInitialize (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return gEmuThunk->ConfigStdIn ();
|
||||
}
|
||||
|
||||
/**
|
||||
Write data from buffer to serial device.
|
||||
|
||||
Writes NumberOfBytes data bytes from Buffer to the serial device.
|
||||
The number of bytes actually written to the serial device is returned.
|
||||
If the return value is less than NumberOfBytes, then the write operation failed.
|
||||
If Buffer is NULL, then ASSERT().
|
||||
If NumberOfBytes is zero, then return 0.
|
||||
|
||||
@param Buffer The pointer to the data buffer to be written.
|
||||
@param NumberOfBytes The number of bytes to written to the serial device.
|
||||
|
||||
@retval 0 NumberOfBytes is 0.
|
||||
@retval >0 The number of bytes written to the serial device.
|
||||
If this value is less than NumberOfBytes, then the read operation failed.
|
||||
|
||||
**/
|
||||
UINTN
|
||||
EFIAPI
|
||||
SerialPortWrite (
|
||||
IN UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
)
|
||||
{
|
||||
return gEmuThunk->WriteStdOut (Buffer, NumberOfBytes);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Read data from serial device and save the datas in buffer.
|
||||
|
||||
Reads NumberOfBytes data bytes from a serial device into the buffer
|
||||
specified by Buffer. The number of bytes actually read is returned.
|
||||
If the return value is less than NumberOfBytes, then the rest operation failed.
|
||||
If Buffer is NULL, then ASSERT().
|
||||
If NumberOfBytes is zero, then return 0.
|
||||
|
||||
@param Buffer The pointer to the data buffer to store the data read from the serial device.
|
||||
@param NumberOfBytes The number of bytes which will be read.
|
||||
|
||||
@retval 0 Read data failed; No data is to be read.
|
||||
@retval >0 The actual number of bytes read from serial device.
|
||||
|
||||
**/
|
||||
UINTN
|
||||
EFIAPI
|
||||
SerialPortRead (
|
||||
OUT UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
)
|
||||
{
|
||||
return gEmuThunk->ReadStdIn (Buffer, NumberOfBytes);
|
||||
}
|
||||
|
||||
/**
|
||||
Polls a serial device to see if there is any data waiting to be read.
|
||||
|
||||
Polls a serial device to see if there is any data waiting to be read.
|
||||
If there is data waiting to be read from the serial device, then TRUE is returned.
|
||||
If there is no data waiting to be read from the serial device, then FALSE is returned.
|
||||
|
||||
@retval TRUE Data is waiting to be read from the serial device.
|
||||
@retval FALSE There is no data waiting to be read from the serial device.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
SerialPortPoll (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return gEmuThunk->PollStdIn ();
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,40 @@
|
||||
## @file
|
||||
# Write only instance of Serial Port Library with empty functions.
|
||||
#
|
||||
# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
# Portions copyright (c) 2011, Apple Inc. 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 = DxeEmuSerialPortLib
|
||||
FILE_GUID = DF08A29A-F60B-E649-AA79-A1490E863A5D
|
||||
MODULE_TYPE = PEIM
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = SerialPortLib| DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER SMM_CORE UEFI_APPLICATION UEFI_DRIVE
|
||||
|
||||
|
||||
[Sources]
|
||||
DxeEmuSerialPortLib.c
|
||||
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
EmulatorPkg/EmulatorPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
EmuThunkLib
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -0,0 +1,119 @@
|
||||
/** @file
|
||||
Serial Port Lib that thunks back to Emulator services to write to StdErr.
|
||||
All read functions are stubed out.
|
||||
|
||||
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Portions copyright (c) 2011, Apple Inc. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php.
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include <PiDxe.h>
|
||||
#include <Library/SerialPortLib.h>
|
||||
#include <Library/EmuThunkLib.h>
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Initialize the serial device hardware.
|
||||
|
||||
If no initialization is required, then return RETURN_SUCCESS.
|
||||
If the serial device was successfully initialized, then return RETURN_SUCCESS.
|
||||
If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.
|
||||
|
||||
@retval RETURN_SUCCESS The serial device was initialized.
|
||||
@retval RETURN_DEVICE_ERROR The serial device could not be initialized.
|
||||
|
||||
**/
|
||||
RETURN_STATUS
|
||||
EFIAPI
|
||||
SerialPortInitialize (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Write data from buffer to serial device.
|
||||
|
||||
Writes NumberOfBytes data bytes from Buffer to the serial device.
|
||||
The number of bytes actually written to the serial device is returned.
|
||||
If the return value is less than NumberOfBytes, then the write operation failed.
|
||||
If Buffer is NULL, then ASSERT().
|
||||
If NumberOfBytes is zero, then return 0.
|
||||
|
||||
@param Buffer The pointer to the data buffer to be written.
|
||||
@param NumberOfBytes The number of bytes to written to the serial device.
|
||||
|
||||
@retval 0 NumberOfBytes is 0.
|
||||
@retval >0 The number of bytes written to the serial device.
|
||||
If this value is less than NumberOfBytes, then the read operation failed.
|
||||
|
||||
**/
|
||||
UINTN
|
||||
EFIAPI
|
||||
SerialPortWrite (
|
||||
IN UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
)
|
||||
{
|
||||
return gEmuThunk->WriteStdErr (Buffer, NumberOfBytes);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Read data from serial device and save the datas in buffer.
|
||||
|
||||
Reads NumberOfBytes data bytes from a serial device into the buffer
|
||||
specified by Buffer. The number of bytes actually read is returned.
|
||||
If the return value is less than NumberOfBytes, then the rest operation failed.
|
||||
If Buffer is NULL, then ASSERT().
|
||||
If NumberOfBytes is zero, then return 0.
|
||||
|
||||
@param Buffer The pointer to the data buffer to store the data read from the serial device.
|
||||
@param NumberOfBytes The number of bytes which will be read.
|
||||
|
||||
@retval 0 Read data failed; No data is to be read.
|
||||
@retval >0 The actual number of bytes read from serial device.
|
||||
|
||||
**/
|
||||
UINTN
|
||||
EFIAPI
|
||||
SerialPortRead (
|
||||
OUT UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
Polls a serial device to see if there is any data waiting to be read.
|
||||
|
||||
Polls a serial device to see if there is any data waiting to be read.
|
||||
If there is data waiting to be read from the serial device, then TRUE is returned.
|
||||
If there is no data waiting to be read from the serial device, then FALSE is returned.
|
||||
|
||||
@retval TRUE Data is waiting to be read from the serial device.
|
||||
@retval FALSE There is no data waiting to be read from the serial device.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
SerialPortPoll (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,40 @@
|
||||
## @file
|
||||
# Write only instance of Serial Port Library with empty functions.
|
||||
#
|
||||
# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
# Portions copyright (c) 2011, Apple Inc. 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 = DxeEmuStdErrSerialPortLib
|
||||
FILE_GUID = 4EED5138-C512-9E4F-AB13-149B87D40453
|
||||
MODULE_TYPE = PEIM
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = SerialPortLib| DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER SMM_CORE UEFI_APPLICATION UEFI_DRIVE
|
||||
|
||||
|
||||
[Sources]
|
||||
DxeEmuStdErrSerialPortLib.c
|
||||
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
EmulatorPkg/EmulatorPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
EmuThunkLib
|
||||
|
||||
|
||||
|
||||
|
||||
|
206
EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.c
Normal file
206
EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.c
Normal file
@@ -0,0 +1,206 @@
|
||||
/** @file
|
||||
A non-functional instance of the Timer Library.
|
||||
|
||||
Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php.
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include <PiPei.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/TimerLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/EmuThunkLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
|
||||
#include <Protocol/Timer.h>
|
||||
|
||||
|
||||
STATIC UINT64 gTimerPeriod = 0;
|
||||
STATIC EFI_TIMER_ARCH_PROTOCOL *gTimerAp = NULL;
|
||||
STATIC EFI_EVENT gTimerEvent = NULL;
|
||||
STATIC VOID *gRegistration = NULL;
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
RegisterTimerArchProtocol (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = gBS->LocateProtocol (&gEfiTimerArchProtocolGuid, NULL, (VOID **)&gTimerAp);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = gTimerAp->GetTimerPeriod (gTimerAp, &gTimerPeriod);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
// Convert to Nanoseconds.
|
||||
gTimerPeriod = MultU64x32 (gTimerPeriod, 100);
|
||||
|
||||
if (gTimerEvent == NULL) {
|
||||
Status = gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, (VOID **)&gTimerEvent);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Stalls the CPU for at least the given number of microseconds.
|
||||
|
||||
Stalls the CPU for the number of microseconds specified by MicroSeconds.
|
||||
|
||||
@param MicroSeconds The minimum number of microseconds to delay.
|
||||
|
||||
@return The value of MicroSeconds inputted.
|
||||
|
||||
**/
|
||||
UINTN
|
||||
EFIAPI
|
||||
MicroSecondDelay (
|
||||
IN UINTN MicroSeconds
|
||||
)
|
||||
{
|
||||
return NanoSecondDelay (MicroSeconds * 1000);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Stalls the CPU for at least the given number of nanoseconds.
|
||||
|
||||
Stalls the CPU for the number of nanoseconds specified by NanoSeconds.
|
||||
|
||||
@param NanoSeconds The minimum number of nanoseconds to delay.
|
||||
|
||||
@return The value of NanoSeconds inputted.
|
||||
|
||||
**/
|
||||
UINTN
|
||||
EFIAPI
|
||||
NanoSecondDelay (
|
||||
IN UINTN NanoSeconds
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT64 HundredNanoseconds;
|
||||
UINTN Index;
|
||||
|
||||
if ((gTimerPeriod != 0) &&
|
||||
((UINT64)NanoSeconds > gTimerPeriod) &&
|
||||
(EfiGetCurrentTpl () == TPL_APPLICATION)) {
|
||||
//
|
||||
// This stall is long, so use gBS->WaitForEvent () to yield CPU to DXE Core
|
||||
//
|
||||
|
||||
HundredNanoseconds = DivU64x32 (NanoSeconds, 100);
|
||||
Status = gBS->SetTimer (gTimerEvent, TimerRelative, HundredNanoseconds);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Status = gBS->WaitForEvent (sizeof (gTimerEvent)/sizeof (EFI_EVENT), &gTimerEvent, &Index);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
} else {
|
||||
gEmuThunk->Sleep (NanoSeconds);
|
||||
}
|
||||
return NanoSeconds;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Retrieves the current value of a 64-bit free running performance counter.
|
||||
|
||||
The counter can either count up by 1 or count down by 1. If the physical
|
||||
performance counter counts by a larger increment, then the counter values
|
||||
must be translated. The properties of the counter can be retrieved from
|
||||
GetPerformanceCounterProperties().
|
||||
|
||||
@return The current value of the free running performance counter.
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
GetPerformanceCounter (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return gEmuThunk->QueryPerformanceCounter ();
|
||||
}
|
||||
|
||||
/**
|
||||
Retrieves the 64-bit frequency in Hz and the range of performance counter
|
||||
values.
|
||||
|
||||
If StartValue is not NULL, then the value that the performance counter starts
|
||||
with immediately after is it rolls over is returned in StartValue. If
|
||||
EndValue is not NULL, then the value that the performance counter end with
|
||||
immediately before it rolls over is returned in EndValue. The 64-bit
|
||||
frequency of the performance counter in Hz is always returned. If StartValue
|
||||
is less than EndValue, then the performance counter counts up. If StartValue
|
||||
is greater than EndValue, then the performance counter counts down. For
|
||||
example, a 64-bit free running counter that counts up would have a StartValue
|
||||
of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter
|
||||
that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0.
|
||||
|
||||
@param StartValue The value the performance counter starts with when it
|
||||
rolls over.
|
||||
@param EndValue The value that the performance counter ends with before
|
||||
it rolls over.
|
||||
|
||||
@return The frequency in Hz.
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
GetPerformanceCounterProperties (
|
||||
OUT UINT64 *StartValue, OPTIONAL
|
||||
OUT UINT64 *EndValue OPTIONAL
|
||||
)
|
||||
{
|
||||
|
||||
if (StartValue != NULL) {
|
||||
*StartValue = 0ULL;
|
||||
}
|
||||
if (EndValue != NULL) {
|
||||
*EndValue = (UINT64)-1LL;
|
||||
}
|
||||
|
||||
return gEmuThunk->QueryPerformanceFrequency ();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Register for the Timer AP protocol.
|
||||
|
||||
@param ImageHandle The firmware allocated handle for the EFI image.
|
||||
@param SystemTable A pointer to the EFI System Table.
|
||||
|
||||
@retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
DxeTimerLibConstructor (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EfiCreateProtocolNotifyEvent (
|
||||
&gEfiTimerArchProtocolGuid,
|
||||
TPL_CALLBACK,
|
||||
RegisterTimerArchProtocol,
|
||||
NULL,
|
||||
&gRegistration
|
||||
);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
51
EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.inf
Normal file
51
EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.inf
Normal file
@@ -0,0 +1,51 @@
|
||||
## @file
|
||||
# NULL instance of Timer Library as a template.
|
||||
#
|
||||
# A non-functional instance of the Timer Library that can be used as a template
|
||||
# for the implementation of a functional timer library instance. This library instance can
|
||||
# also be used to test build DXE, Runtime, DXE SAL, and DXE SMM modules that require timer
|
||||
# services as well as EBC modules that require timer services.
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php.
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
#
|
||||
##
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = EmuDxeTimerLib
|
||||
FILE_GUID = 74B62391-AD0D-1B4D-8784-151404F9D538
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = TimerLib|DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_DRIVER UEFI_APPLICATION
|
||||
|
||||
CONSTRUCTOR = DxeTimerLibConstructor
|
||||
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
#
|
||||
|
||||
[Sources]
|
||||
DxeTimerLib.c
|
||||
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
EmulatorPkg/EmulatorPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
BaseLib
|
||||
DebugLib
|
||||
EmuThunkLib
|
||||
UefiLib
|
||||
UefiBootServicesTableLib
|
||||
|
||||
[Protocols]
|
||||
gEfiTimerArchProtocolGuid
|
557
EmulatorPkg/Library/EmuBdsLib/BdsPlatform.c
Normal file
557
EmulatorPkg/Library/EmuBdsLib/BdsPlatform.c
Normal file
@@ -0,0 +1,557 @@
|
||||
/*++ @file
|
||||
|
||||
Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
|
||||
Portions copyright (c) 2011, Apple Inc. 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 "BdsPlatform.h"
|
||||
|
||||
EMU_SYSTEM_CONFIGURATION mSystemConfigData;
|
||||
|
||||
VOID
|
||||
SetupVariableInit (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN Size;
|
||||
|
||||
Size = sizeof (mSystemConfigData);
|
||||
Status = gRT->GetVariable (
|
||||
L"Setup",
|
||||
&gEmuSystemConfigGuid,
|
||||
NULL,
|
||||
&Size,
|
||||
(VOID *) &mSystemConfigData
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
//
|
||||
// SetupVariable is corrupt
|
||||
//
|
||||
mSystemConfigData.ConOutRow = PcdGet32 (PcdConOutColumn);
|
||||
mSystemConfigData.ConOutColumn = PcdGet32 (PcdConOutRow);
|
||||
|
||||
Status = gRT->SetVariable (
|
||||
L"Setup",
|
||||
&gEmuSystemConfigGuid,
|
||||
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||
sizeof (mSystemConfigData),
|
||||
(VOID *) &mSystemConfigData
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((EFI_D_ERROR, "Failed to save Setup Variable to non-volatile storage, Status = %r\n", Status));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// BDS Platform Functions
|
||||
//
|
||||
VOID
|
||||
EFIAPI
|
||||
PlatformBdsInit (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Platform Bds init. Include the platform firmware vendor, revision
|
||||
and so crc check.
|
||||
|
||||
Arguments:
|
||||
|
||||
Returns:
|
||||
|
||||
None.
|
||||
|
||||
**/
|
||||
{
|
||||
SetupVariableInit ();
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
PlatformBdsConnectConsole (
|
||||
IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Connect the predefined platform default console device. Always try to find
|
||||
and enable the vga device if have.
|
||||
|
||||
Arguments:
|
||||
|
||||
PlatformConsole - Predfined platform default console device array.
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - Success connect at least one ConIn and ConOut
|
||||
device, there must have one ConOut device is
|
||||
active vga device.
|
||||
|
||||
EFI_STATUS - Return the status of
|
||||
BdsLibConnectAllDefaultConsoles ()
|
||||
|
||||
**/
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN Index;
|
||||
|
||||
Index = 0;
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
//
|
||||
// Have chance to connect the platform default console,
|
||||
// the platform default console is the minimue device group
|
||||
// the platform should support
|
||||
//
|
||||
while (PlatformConsole[Index].DevicePath != NULL) {
|
||||
//
|
||||
// Update the console variable with the connect type
|
||||
//
|
||||
if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {
|
||||
BdsLibUpdateConsoleVariable (L"ConIn", PlatformConsole[Index].DevicePath, NULL);
|
||||
}
|
||||
|
||||
if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {
|
||||
BdsLibUpdateConsoleVariable (L"ConOut", PlatformConsole[Index].DevicePath, NULL);
|
||||
}
|
||||
|
||||
if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {
|
||||
BdsLibUpdateConsoleVariable (L"ErrOut", PlatformConsole[Index].DevicePath, NULL);
|
||||
}
|
||||
|
||||
Index++;
|
||||
}
|
||||
//
|
||||
// Connect the all the default console with current cosole variable
|
||||
//
|
||||
Status = BdsLibConnectAllDefaultConsoles ();
|
||||
return Status;
|
||||
}
|
||||
|
||||
VOID
|
||||
PlatformBdsConnectSequence (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Connect with predeined platform connect sequence,
|
||||
the OEM/IBV can customize with their own connect sequence.
|
||||
|
||||
Arguments:
|
||||
|
||||
None.
|
||||
|
||||
Returns:
|
||||
|
||||
None.
|
||||
|
||||
**/
|
||||
{
|
||||
UINTN Index;
|
||||
|
||||
Index = 0;
|
||||
|
||||
//
|
||||
// Here we can get the customized platform connect sequence
|
||||
// Notes: we can connect with new variable which record the
|
||||
// last time boots connect device path sequence
|
||||
//
|
||||
while (gPlatformConnectSequence[Index] != NULL) {
|
||||
//
|
||||
// Build the platform boot option
|
||||
//
|
||||
BdsLibConnectDevicePath (gPlatformConnectSequence[Index]);
|
||||
Index++;
|
||||
}
|
||||
|
||||
//
|
||||
// Just use the simple policy to connect all devices
|
||||
//
|
||||
BdsLibConnectAll ();
|
||||
}
|
||||
|
||||
VOID
|
||||
PlatformBdsGetDriverOption (
|
||||
IN OUT LIST_ENTRY *BdsDriverLists
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Load the predefined driver option, OEM/IBV can customize this
|
||||
to load their own drivers
|
||||
|
||||
Arguments:
|
||||
|
||||
BdsDriverLists - The header of the driver option link list.
|
||||
|
||||
Returns:
|
||||
|
||||
None.
|
||||
|
||||
**/
|
||||
{
|
||||
UINTN Index;
|
||||
|
||||
Index = 0;
|
||||
|
||||
//
|
||||
// Here we can get the customized platform driver option
|
||||
//
|
||||
while (gPlatformDriverOption[Index] != NULL) {
|
||||
//
|
||||
// Build the platform boot option
|
||||
//
|
||||
BdsLibRegisterNewOption (BdsDriverLists, gPlatformDriverOption[Index], NULL, L"DriverOrder");
|
||||
Index++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
VOID
|
||||
PlatformBdsDiagnostics (
|
||||
IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,
|
||||
IN BOOLEAN QuietBoot,
|
||||
IN BASEM_MEMORY_TEST BaseMemoryTest
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Perform the platform diagnostic, such like test memory. OEM/IBV also
|
||||
can customize this fuction to support specific platform diagnostic.
|
||||
|
||||
Arguments:
|
||||
|
||||
MemoryTestLevel - The memory test intensive level
|
||||
|
||||
QuietBoot - Indicate if need to enable the quiet boot
|
||||
|
||||
BaseMemoryTest - A pointer to BdsMemoryTest()
|
||||
|
||||
Returns:
|
||||
|
||||
None.
|
||||
|
||||
**/
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Here we can decide if we need to show
|
||||
// the diagnostics screen
|
||||
// Notes: this quiet boot code should be remove
|
||||
// from the graphic lib
|
||||
//
|
||||
if (QuietBoot) {
|
||||
EnableQuietBoot (PcdGetPtr(PcdLogoFile));
|
||||
//
|
||||
// Perform system diagnostic
|
||||
//
|
||||
Status = BaseMemoryTest (MemoryTestLevel);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DisableQuietBoot ();
|
||||
}
|
||||
|
||||
return ;
|
||||
}
|
||||
//
|
||||
// Perform system diagnostic
|
||||
//
|
||||
Status = BaseMemoryTest (MemoryTestLevel);
|
||||
}
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
PlatformBdsPolicyBehavior (
|
||||
IN OUT LIST_ENTRY *DriverOptionList,
|
||||
IN OUT LIST_ENTRY *BootOptionList,
|
||||
IN PROCESS_CAPSULES ProcessCapsules,
|
||||
IN BASEM_MEMORY_TEST BaseMemoryTest
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
The function will excute with as the platform policy, current policy
|
||||
is driven by boot mode. IBV/OEM can customize this code for their specific
|
||||
policy action.
|
||||
|
||||
Arguments:
|
||||
|
||||
DriverOptionList - The header of the driver option link list
|
||||
|
||||
BootOptionList - The header of the boot option link list
|
||||
|
||||
ProcessCapsules - A pointer to ProcessCapsules()
|
||||
|
||||
BaseMemoryTest - A pointer to BaseMemoryTest()
|
||||
|
||||
Returns:
|
||||
|
||||
None.
|
||||
|
||||
**/
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT16 Timeout;
|
||||
EFI_BOOT_MODE BootMode;
|
||||
|
||||
//
|
||||
// Init the time out value
|
||||
//
|
||||
Timeout = PcdGet16 (PcdPlatformBootTimeOut);
|
||||
|
||||
//
|
||||
// Load the driver option as the driver option list
|
||||
//
|
||||
PlatformBdsGetDriverOption (DriverOptionList);
|
||||
|
||||
//
|
||||
// Get current Boot Mode
|
||||
//
|
||||
Status = BdsLibGetBootMode (&BootMode);
|
||||
|
||||
//
|
||||
// Go the different platform policy with different boot mode
|
||||
// Notes: this part code can be change with the table policy
|
||||
//
|
||||
switch (BootMode) {
|
||||
|
||||
case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:
|
||||
case BOOT_WITH_MINIMAL_CONFIGURATION:
|
||||
//
|
||||
// In no-configuration boot mode, we can connect the
|
||||
// console directly.
|
||||
//
|
||||
BdsLibConnectAllDefaultConsoles ();
|
||||
PlatformBdsDiagnostics (IGNORE, TRUE, BaseMemoryTest);
|
||||
|
||||
//
|
||||
// Perform some platform specific connect sequence
|
||||
//
|
||||
PlatformBdsConnectSequence ();
|
||||
|
||||
//
|
||||
// Notes: current time out = 0 can not enter the
|
||||
// front page
|
||||
//
|
||||
PlatformBdsEnterFrontPage (Timeout, FALSE);
|
||||
|
||||
//
|
||||
// Check the boot option with the boot option list
|
||||
//
|
||||
BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");
|
||||
break;
|
||||
|
||||
case BOOT_ON_FLASH_UPDATE:
|
||||
//
|
||||
// Boot with the specific configuration
|
||||
//
|
||||
PlatformBdsConnectConsole (gPlatformConsole);
|
||||
PlatformBdsDiagnostics (EXTENSIVE, FALSE, BaseMemoryTest);
|
||||
BdsLibConnectAll ();
|
||||
ProcessCapsules (BOOT_ON_FLASH_UPDATE);
|
||||
break;
|
||||
|
||||
case BOOT_IN_RECOVERY_MODE:
|
||||
//
|
||||
// In recovery mode, just connect platform console
|
||||
// and show up the front page
|
||||
//
|
||||
PlatformBdsConnectConsole (gPlatformConsole);
|
||||
PlatformBdsDiagnostics (EXTENSIVE, FALSE, BaseMemoryTest);
|
||||
|
||||
//
|
||||
// In recovery boot mode, we still enter to the
|
||||
// frong page now
|
||||
//
|
||||
PlatformBdsEnterFrontPage (Timeout, FALSE);
|
||||
break;
|
||||
|
||||
case BOOT_WITH_FULL_CONFIGURATION:
|
||||
case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:
|
||||
case BOOT_WITH_DEFAULT_SETTINGS:
|
||||
default:
|
||||
//
|
||||
// Connect platform console
|
||||
//
|
||||
Status = PlatformBdsConnectConsole (gPlatformConsole);
|
||||
if (EFI_ERROR (Status)) {
|
||||
//
|
||||
// Here OEM/IBV can customize with defined action
|
||||
//
|
||||
PlatformBdsNoConsoleAction ();
|
||||
}
|
||||
|
||||
PlatformBdsDiagnostics (IGNORE, TRUE, BaseMemoryTest);
|
||||
|
||||
//
|
||||
// Perform some platform specific connect sequence
|
||||
//
|
||||
PlatformBdsConnectSequence ();
|
||||
|
||||
//
|
||||
// Give one chance to enter the setup if we
|
||||
// have the time out
|
||||
//
|
||||
PlatformBdsEnterFrontPage (Timeout, FALSE);
|
||||
|
||||
//
|
||||
// Here we have enough time to do the enumeration of boot device
|
||||
//
|
||||
BdsLibEnumerateAllBootOption (BootOptionList);
|
||||
break;
|
||||
}
|
||||
|
||||
return ;
|
||||
|
||||
}
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
PlatformBdsBootSuccess (
|
||||
IN BDS_COMMON_OPTION *Option
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Hook point after a boot attempt succeeds. We don't expect a boot option to
|
||||
return, so the EFI 1.0 specification defines that you will default to an
|
||||
interactive mode and stop processing the BootOrder list in this case. This
|
||||
is alos a platform implementation and can be customized by IBV/OEM.
|
||||
|
||||
Arguments:
|
||||
|
||||
Option - Pointer to Boot Option that succeeded to boot.
|
||||
|
||||
Returns:
|
||||
|
||||
None.
|
||||
|
||||
**/
|
||||
{
|
||||
CHAR16 *TmpStr;
|
||||
|
||||
//
|
||||
// If Boot returned with EFI_SUCCESS and there is not in the boot device
|
||||
// select loop then we need to pop up a UI and wait for user input.
|
||||
//
|
||||
TmpStr = Option->StatusString;
|
||||
if (TmpStr != NULL) {
|
||||
BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);
|
||||
FreePool (TmpStr);
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
PlatformBdsBootFail (
|
||||
IN BDS_COMMON_OPTION *Option,
|
||||
IN EFI_STATUS Status,
|
||||
IN CHAR16 *ExitData,
|
||||
IN UINTN ExitDataSize
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Hook point after a boot attempt fails.
|
||||
|
||||
Arguments:
|
||||
|
||||
Option - Pointer to Boot Option that failed to boot.
|
||||
|
||||
Status - Status returned from failed boot.
|
||||
|
||||
ExitData - Exit data returned from failed boot.
|
||||
|
||||
ExitDataSize - Exit data size returned from failed boot.
|
||||
|
||||
Returns:
|
||||
|
||||
None.
|
||||
|
||||
**/
|
||||
{
|
||||
CHAR16 *TmpStr;
|
||||
|
||||
//
|
||||
// If Boot returned with failed status then we need to pop up a UI and wait
|
||||
// for user input.
|
||||
//
|
||||
TmpStr = Option->StatusString;
|
||||
if (TmpStr != NULL) {
|
||||
BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);
|
||||
FreePool (TmpStr);
|
||||
}
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
PlatformBdsNoConsoleAction (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
This function is remained for IBV/OEM to do some platform action,
|
||||
if there no console device can be connected.
|
||||
|
||||
Arguments:
|
||||
|
||||
None.
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - Direct return success now.
|
||||
|
||||
**/
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
PlatformBdsLockNonUpdatableFlash (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
Lock the ConsoleIn device in system table. All key
|
||||
presses will be ignored until the Password is typed in. The only way to
|
||||
disable the password is to type it in to a ConIn device.
|
||||
|
||||
@param Password Password used to lock ConIn device.
|
||||
|
||||
@retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.
|
||||
@retval EFI_UNSUPPORTED Password not found
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
LockKeyboards (
|
||||
IN CHAR16 *Password
|
||||
)
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
97
EmulatorPkg/Library/EmuBdsLib/BdsPlatform.h
Normal file
97
EmulatorPkg/Library/EmuBdsLib/BdsPlatform.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/*++ @file
|
||||
|
||||
Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
|
||||
Portions copyright (c) 2011, Apple Inc. 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 _BDS_PLATFORM_H
|
||||
#define _BDS_PLATFORM_H
|
||||
|
||||
#include <PiDxe.h>
|
||||
|
||||
#include <Guid/EmuSystemConfig.h>
|
||||
#include <Protocol/EmuThunk.h>
|
||||
#include <Protocol/EmuIoThunk.h>
|
||||
#include <Protocol/EmuGraphicsWindow.h>
|
||||
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/GenericBdsLib.h>
|
||||
#include <Library/PlatformBdsLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
|
||||
|
||||
extern BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[];
|
||||
extern EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[];
|
||||
extern EFI_DEVICE_PATH_PROTOCOL *gPlatformDriverOption[];
|
||||
|
||||
#define gEndEntire \
|
||||
{ \
|
||||
END_DEVICE_PATH_TYPE,\
|
||||
END_ENTIRE_DEVICE_PATH_SUBTYPE,\
|
||||
END_DEVICE_PATH_LENGTH,\
|
||||
0\
|
||||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
EMU_VENDOR_DEVICE_PATH_NODE EmuBus;
|
||||
EMU_VENDOR_DEVICE_PATH_NODE EmuGraphicsWindow;
|
||||
EFI_DEVICE_PATH_PROTOCOL End;
|
||||
} EMU_PLATFORM_UGA_DEVICE_PATH;
|
||||
|
||||
|
||||
//
|
||||
// Platform BDS Functions
|
||||
//
|
||||
VOID
|
||||
PlatformBdsGetDriverOption (
|
||||
IN LIST_ENTRY *BdsDriverLists
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
BdsMemoryTest (
|
||||
EXTENDMEM_COVERAGE_LEVEL Level
|
||||
);
|
||||
|
||||
|
||||
VOID
|
||||
PlatformBdsConnectSequence (
|
||||
VOID
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
ProcessCapsules (
|
||||
EFI_BOOT_MODE BootMode
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
PlatformBdsConnectConsole (
|
||||
IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
PlatformBdsNoConsoleAction (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
PlatformBdsEnterFrontPage (
|
||||
IN UINT16 TimeoutDefault,
|
||||
IN BOOLEAN ConnectAllHappened
|
||||
);
|
||||
|
||||
#endif // _BDS_PLATFORM_H
|
66
EmulatorPkg/Library/EmuBdsLib/EmuBdsLib.inf
Normal file
66
EmulatorPkg/Library/EmuBdsLib/EmuBdsLib.inf
Normal file
@@ -0,0 +1,66 @@
|
||||
## @file
|
||||
# Platfrom BDS driver
|
||||
#
|
||||
# Do platform action customized by IBV/OEM.
|
||||
# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
# Portions copyright (c) 2011, Apple Inc. 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 = EmuBdsLib
|
||||
FILE_GUID = 59569181-CBF8-2E44-9C3E-C2AB2F5608E1
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = PlatformBdsLib|DXE_DRIVER
|
||||
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
#
|
||||
|
||||
[Sources]
|
||||
BdsPlatform.c
|
||||
PlatformData.c
|
||||
BdsPlatform.h
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
EmulatorPkg/EmulatorPkg.dec
|
||||
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
BaseLib
|
||||
MemoryAllocationLib
|
||||
UefiBootServicesTableLib
|
||||
UefiRuntimeServicesTableLib
|
||||
BaseMemoryLib
|
||||
DebugLib
|
||||
PcdLib
|
||||
GenericBdsLib
|
||||
DevicePathLib
|
||||
|
||||
|
||||
[Guids]
|
||||
gEmuSystemConfigGuid
|
||||
|
||||
[Pcd]
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn
|
||||
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdPlatformBootTimeOut
|
||||
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile
|
||||
|
||||
[Depex]
|
||||
gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid
|
69
EmulatorPkg/Library/EmuBdsLib/PlatformData.c
Normal file
69
EmulatorPkg/Library/EmuBdsLib/PlatformData.c
Normal file
@@ -0,0 +1,69 @@
|
||||
/*++ @file
|
||||
|
||||
Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
|
||||
Portions copyright (c) 2011, Apple Inc. 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 "BdsPlatform.h"
|
||||
|
||||
|
||||
|
||||
EMU_PLATFORM_UGA_DEVICE_PATH gGopDevicePath = {
|
||||
{
|
||||
{
|
||||
{
|
||||
HARDWARE_DEVICE_PATH,
|
||||
HW_VENDOR_DP,
|
||||
{
|
||||
(UINT8) (sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),
|
||||
(UINT8) ((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)
|
||||
}
|
||||
},
|
||||
EMU_THUNK_PROTOCOL_GUID
|
||||
},
|
||||
0
|
||||
},
|
||||
{
|
||||
HARDWARE_DEVICE_PATH,
|
||||
HW_VENDOR_DP,
|
||||
{
|
||||
(UINT8) (sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),
|
||||
(UINT8) ((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)
|
||||
},
|
||||
EMU_GRAPHICS_WINDOW_PROTOCOL_GUID,
|
||||
0
|
||||
},
|
||||
gEndEntire
|
||||
};
|
||||
|
||||
//
|
||||
// Predefined platform default console device path
|
||||
//
|
||||
BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = {
|
||||
{
|
||||
(EFI_DEVICE_PATH_PROTOCOL *) &gGopDevicePath,
|
||||
(CONSOLE_OUT | CONSOLE_IN)
|
||||
},
|
||||
{
|
||||
NULL,
|
||||
0
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Predefined platform specific driver option
|
||||
//
|
||||
EFI_DEVICE_PATH_PROTOCOL *gPlatformDriverOption[] = { NULL };
|
||||
|
||||
//
|
||||
// Predefined platform connect sequence
|
||||
//
|
||||
EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[] = { NULL };
|
@@ -0,0 +1,42 @@
|
||||
## @file
|
||||
# Instance of Memory Allocation Library using EFI Boot Services.
|
||||
#
|
||||
# Memory Allocation Library that uses EFI Boot Services to allocate
|
||||
# and free memory. Calls OS malloc to enable OS based debug tools
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php.
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
#
|
||||
##
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = GuardUefiMemoryAllocationLib
|
||||
FILE_GUID = DB290230-3EFA-064F-A317-E146925684FE
|
||||
MODULE_TYPE = UEFI_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = MemoryAllocationLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER DXE_CORE
|
||||
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
#
|
||||
|
||||
[Sources]
|
||||
MemoryAllocationLib.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
EmulatorPkg/EmulatorPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
DebugLib
|
||||
BaseMemoryLib
|
||||
UefiBootServicesTableLib
|
||||
EmuThunkLib
|
@@ -0,0 +1,819 @@
|
||||
/** @file
|
||||
Support routines for memory allocation routines based
|
||||
on boot services for Dxe phase drivers using OS malloc.
|
||||
|
||||
OS malloc is used so OS based malloc debugging tools can be used.
|
||||
If a single driver links against this lib protocols from other
|
||||
drivers, or EFI boot services can return a buffer that needs to
|
||||
freed using the EFI scheme. This is why the gEmuThunk->Free ()
|
||||
can detect if the memory rang is for EFI so the right free can be
|
||||
called.
|
||||
|
||||
Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
|
||||
Portions copyright (c) 2011, Apple Inc. 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 <Uefi.h>
|
||||
|
||||
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/EmuThunkLib.h>
|
||||
|
||||
/**
|
||||
Allocates one or more 4KB pages of a certain memory type.
|
||||
|
||||
Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated
|
||||
buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned.
|
||||
If there is not enough memory remaining to satisfy the request, then NULL is returned.
|
||||
|
||||
@param MemoryType The type of memory to allocate.
|
||||
@param Pages The number of 4 KB pages to allocate.
|
||||
|
||||
@return A pointer to the allocated buffer or NULL if allocation fails.
|
||||
|
||||
**/
|
||||
VOID *
|
||||
InternalAllocatePages (
|
||||
IN EFI_MEMORY_TYPE MemoryType,
|
||||
IN UINTN Pages
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_PHYSICAL_ADDRESS Memory;
|
||||
|
||||
if (Pages == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return gEmuThunk->Valloc (Pages * EFI_PAGE_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
Allocates one or more 4KB pages of type EfiBootServicesData.
|
||||
|
||||
Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the
|
||||
allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
|
||||
is returned. If there is not enough memory remaining to satisfy the request, then NULL is
|
||||
returned.
|
||||
|
||||
@param Pages The number of 4 KB pages to allocate.
|
||||
|
||||
@return A pointer to the allocated buffer or NULL if allocation fails.
|
||||
|
||||
**/
|
||||
VOID *
|
||||
EFIAPI
|
||||
AllocatePages (
|
||||
IN UINTN Pages
|
||||
)
|
||||
{
|
||||
return InternalAllocatePages (EfiBootServicesData, Pages);
|
||||
}
|
||||
|
||||
/**
|
||||
Allocates one or more 4KB pages of type EfiRuntimeServicesData.
|
||||
|
||||
Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the
|
||||
allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
|
||||
is returned. If there is not enough memory remaining to satisfy the request, then NULL is
|
||||
returned.
|
||||
|
||||
@param Pages The number of 4 KB pages to allocate.
|
||||
|
||||
@return A pointer to the allocated buffer or NULL if allocation fails.
|
||||
|
||||
**/
|
||||
VOID *
|
||||
EFIAPI
|
||||
AllocateRuntimePages (
|
||||
IN UINTN Pages
|
||||
)
|
||||
{
|
||||
return InternalAllocatePages (EfiRuntimeServicesData, Pages);
|
||||
}
|
||||
|
||||
/**
|
||||
Allocates one or more 4KB pages of type EfiReservedMemoryType.
|
||||
|
||||
Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the
|
||||
allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
|
||||
is returned. If there is not enough memory remaining to satisfy the request, then NULL is
|
||||
returned.
|
||||
|
||||
@param Pages The number of 4 KB pages to allocate.
|
||||
|
||||
@return A pointer to the allocated buffer or NULL if allocation fails.
|
||||
|
||||
**/
|
||||
VOID *
|
||||
EFIAPI
|
||||
AllocateReservedPages (
|
||||
IN UINTN Pages
|
||||
)
|
||||
{
|
||||
return InternalAllocatePages (EfiReservedMemoryType, Pages);
|
||||
}
|
||||
|
||||
/**
|
||||
Frees one or more 4KB pages that were previously allocated with one of the page allocation
|
||||
functions in the Memory Allocation Library.
|
||||
|
||||
Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
|
||||
must have been allocated on a previous call to the page allocation services of the Memory
|
||||
Allocation Library. If it is not possible to free allocated pages, then this function will
|
||||
perform no actions.
|
||||
|
||||
If Buffer was not allocated with a page allocation function in the Memory Allocation Library,
|
||||
then ASSERT().
|
||||
If Pages is zero, then ASSERT().
|
||||
|
||||
@param Buffer The pointer to the buffer of pages to free.
|
||||
@param Pages The number of 4 KB pages to free.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
FreePages (
|
||||
IN VOID *Buffer,
|
||||
IN UINTN Pages
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
ASSERT (Pages != 0);
|
||||
if (!gEmuThunk->Free (Buffer)) {
|
||||
// The Free thunk will not free memory allocated in emulated EFI memory.
|
||||
// The assmuption is this was allocated directly by EFI. We need this as some
|
||||
// times protocols or EFI BootServices can return dynamically allocated buffers.
|
||||
Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Allocates one or more 4KB pages of a certain memory type at a specified alignment.
|
||||
|
||||
Allocates the number of 4KB pages specified by Pages of a certain memory type with an alignment
|
||||
specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is returned.
|
||||
If there is not enough memory at the specified alignment remaining to satisfy the request, then
|
||||
NULL is returned.
|
||||
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
|
||||
|
||||
@param MemoryType The type of memory to allocate.
|
||||
@param Pages The number of 4 KB pages to allocate.
|
||||
@param Alignment The requested alignment of the allocation. Must be a power of two.
|
||||
If Alignment is zero, then byte alignment is used.
|
||||
|
||||
@return A pointer to the allocated buffer or NULL if allocation fails.
|
||||
|
||||
**/
|
||||
VOID *
|
||||
InternalAllocateAlignedPages (
|
||||
IN EFI_MEMORY_TYPE MemoryType,
|
||||
IN UINTN Pages,
|
||||
IN UINTN Alignment
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
VOID *Memory;
|
||||
UINTN AlignedMemory;
|
||||
UINTN AlignmentMask;
|
||||
UINTN UnalignedPages;
|
||||
UINTN RealPages;
|
||||
|
||||
//
|
||||
// Alignment must be a power of two or zero.
|
||||
//
|
||||
ASSERT ((Alignment & (Alignment - 1)) == 0);
|
||||
|
||||
if (Pages == 0) {
|
||||
return NULL;
|
||||
}
|
||||
if (Alignment > EFI_PAGE_SIZE) {
|
||||
//
|
||||
// Caculate the total number of pages since alignment is larger than page size.
|
||||
//
|
||||
AlignmentMask = Alignment - 1;
|
||||
RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment);
|
||||
//
|
||||
// Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.
|
||||
//
|
||||
ASSERT (RealPages > Pages);
|
||||
|
||||
Memory = gEmuThunk->Valloc (Pages * EFI_PAGE_SIZE);
|
||||
if (Memory != NULL) {
|
||||
return NULL;
|
||||
}
|
||||
AlignedMemory = ((UINTN) Memory + AlignmentMask) & ~AlignmentMask;
|
||||
UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN) Memory);
|
||||
if (UnalignedPages > 0) {
|
||||
//
|
||||
// Free first unaligned page(s).
|
||||
//
|
||||
FreePages (Memory, UnalignedPages);
|
||||
}
|
||||
Memory = (VOID *) (AlignedMemory + EFI_PAGES_TO_SIZE (Pages));
|
||||
UnalignedPages = RealPages - Pages - UnalignedPages;
|
||||
if (UnalignedPages > 0) {
|
||||
//
|
||||
// Free last unaligned page(s).
|
||||
//
|
||||
FreePages (Memory, UnalignedPages);
|
||||
}
|
||||
} else {
|
||||
//
|
||||
// Do not over-allocate pages in this case.
|
||||
//
|
||||
Memory = gEmuThunk->Valloc (Pages * EFI_PAGE_SIZE);
|
||||
if (Memory != NULL) {
|
||||
return NULL;
|
||||
}
|
||||
AlignedMemory = (UINTN) Memory;
|
||||
}
|
||||
return (VOID *) AlignedMemory;
|
||||
}
|
||||
|
||||
/**
|
||||
Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.
|
||||
|
||||
Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an
|
||||
alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
|
||||
returned. If there is not enough memory at the specified alignment remaining to satisfy the
|
||||
request, then NULL is returned.
|
||||
|
||||
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
|
||||
|
||||
@param Pages The number of 4 KB pages to allocate.
|
||||
@param Alignment The requested alignment of the allocation. Must be a power of two.
|
||||
If Alignment is zero, then byte alignment is used.
|
||||
|
||||
@return A pointer to the allocated buffer or NULL if allocation fails.
|
||||
|
||||
**/
|
||||
VOID *
|
||||
EFIAPI
|
||||
AllocateAlignedPages (
|
||||
IN UINTN Pages,
|
||||
IN UINTN Alignment
|
||||
)
|
||||
{
|
||||
return InternalAllocateAlignedPages (EfiBootServicesData, Pages, Alignment);
|
||||
}
|
||||
|
||||
/**
|
||||
Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.
|
||||
|
||||
Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an
|
||||
alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
|
||||
returned. If there is not enough memory at the specified alignment remaining to satisfy the
|
||||
request, then NULL is returned.
|
||||
|
||||
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
|
||||
|
||||
@param Pages The number of 4 KB pages to allocate.
|
||||
@param Alignment The requested alignment of the allocation. Must be a power of two.
|
||||
If Alignment is zero, then byte alignment is used.
|
||||
|
||||
@return A pointer to the allocated buffer or NULL if allocation fails.
|
||||
|
||||
**/
|
||||
VOID *
|
||||
EFIAPI
|
||||
AllocateAlignedRuntimePages (
|
||||
IN UINTN Pages,
|
||||
IN UINTN Alignment
|
||||
)
|
||||
{
|
||||
return InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment);
|
||||
}
|
||||
|
||||
/**
|
||||
Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.
|
||||
|
||||
Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an
|
||||
alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
|
||||
returned. If there is not enough memory at the specified alignment remaining to satisfy the
|
||||
request, then NULL is returned.
|
||||
|
||||
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
|
||||
|
||||
@param Pages The number of 4 KB pages to allocate.
|
||||
@param Alignment The requested alignment of the allocation. Must be a power of two.
|
||||
If Alignment is zero, then byte alignment is used.
|
||||
|
||||
@return A pointer to the allocated buffer or NULL if allocation fails.
|
||||
|
||||
**/
|
||||
VOID *
|
||||
EFIAPI
|
||||
AllocateAlignedReservedPages (
|
||||
IN UINTN Pages,
|
||||
IN UINTN Alignment
|
||||
)
|
||||
{
|
||||
return InternalAllocateAlignedPages (EfiReservedMemoryType, Pages, Alignment);
|
||||
}
|
||||
|
||||
/**
|
||||
Frees one or more 4KB pages that were previously allocated with one of the aligned page
|
||||
allocation functions in the Memory Allocation Library.
|
||||
|
||||
Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
|
||||
must have been allocated on a previous call to the aligned page allocation services of the Memory
|
||||
Allocation Library. If it is not possible to free allocated pages, then this function will
|
||||
perform no actions.
|
||||
|
||||
If Buffer was not allocated with an aligned page allocation function in the Memory Allocation
|
||||
Library, then ASSERT().
|
||||
If Pages is zero, then ASSERT().
|
||||
|
||||
@param Buffer The pointer to the buffer of pages to free.
|
||||
@param Pages The number of 4 KB pages to free.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
FreeAlignedPages (
|
||||
IN VOID *Buffer,
|
||||
IN UINTN Pages
|
||||
)
|
||||
{
|
||||
FreePages (Buffer, Pages);
|
||||
}
|
||||
|
||||
/**
|
||||
Allocates a buffer of a certain pool type.
|
||||
|
||||
Allocates the number bytes specified by AllocationSize of a certain pool type and returns a
|
||||
pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
|
||||
returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
|
||||
|
||||
@param MemoryType The type of memory to allocate.
|
||||
@param AllocationSize The number of bytes to allocate.
|
||||
|
||||
@return A pointer to the allocated buffer or NULL if allocation fails.
|
||||
|
||||
**/
|
||||
VOID *
|
||||
InternalAllocatePool (
|
||||
IN EFI_MEMORY_TYPE MemoryType,
|
||||
IN UINTN AllocationSize
|
||||
)
|
||||
{
|
||||
return gEmuThunk->Malloc (AllocationSize);
|
||||
}
|
||||
|
||||
/**
|
||||
Allocates a buffer of type EfiBootServicesData.
|
||||
|
||||
Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a
|
||||
pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
|
||||
returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
|
||||
|
||||
@param AllocationSize The number of bytes to allocate.
|
||||
|
||||
@return A pointer to the allocated buffer or NULL if allocation fails.
|
||||
|
||||
**/
|
||||
VOID *
|
||||
EFIAPI
|
||||
AllocatePool (
|
||||
IN UINTN AllocationSize
|
||||
)
|
||||
{
|
||||
return InternalAllocatePool (EfiBootServicesData, AllocationSize);
|
||||
}
|
||||
|
||||
/**
|
||||
Allocates a buffer of type EfiRuntimeServicesData.
|
||||
|
||||
Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns
|
||||
a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
|
||||
returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
|
||||
|
||||
@param AllocationSize The number of bytes to allocate.
|
||||
|
||||
@return A pointer to the allocated buffer or NULL if allocation fails.
|
||||
|
||||
**/
|
||||
VOID *
|
||||
EFIAPI
|
||||
AllocateRuntimePool (
|
||||
IN UINTN AllocationSize
|
||||
)
|
||||
{
|
||||
return InternalAllocatePool (EfiRuntimeServicesData, AllocationSize);
|
||||
}
|
||||
|
||||
/**
|
||||
Allocates a buffer of type EfiReservedMemoryType.
|
||||
|
||||
Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType and returns
|
||||
a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
|
||||
returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
|
||||
|
||||
@param AllocationSize The number of bytes to allocate.
|
||||
|
||||
@return A pointer to the allocated buffer or NULL if allocation fails.
|
||||
|
||||
**/
|
||||
VOID *
|
||||
EFIAPI
|
||||
AllocateReservedPool (
|
||||
IN UINTN AllocationSize
|
||||
)
|
||||
{
|
||||
return InternalAllocatePool (EfiReservedMemoryType, AllocationSize);
|
||||
}
|
||||
|
||||
/**
|
||||
Allocates and zeros a buffer of a certain pool type.
|
||||
|
||||
Allocates the number bytes specified by AllocationSize of a certain pool type, clears the buffer
|
||||
with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid
|
||||
buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request,
|
||||
then NULL is returned.
|
||||
|
||||
@param PoolType The type of memory to allocate.
|
||||
@param AllocationSize The number of bytes to allocate and zero.
|
||||
|
||||
@return A pointer to the allocated buffer or NULL if allocation fails.
|
||||
|
||||
**/
|
||||
VOID *
|
||||
InternalAllocateZeroPool (
|
||||
IN EFI_MEMORY_TYPE PoolType,
|
||||
IN UINTN AllocationSize
|
||||
)
|
||||
{
|
||||
VOID *Memory;
|
||||
|
||||
Memory = InternalAllocatePool (PoolType, AllocationSize);
|
||||
if (Memory != NULL) {
|
||||
Memory = ZeroMem (Memory, AllocationSize);
|
||||
}
|
||||
return Memory;
|
||||
}
|
||||
|
||||
/**
|
||||
Allocates and zeros a buffer of type EfiBootServicesData.
|
||||
|
||||
Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the
|
||||
buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
|
||||
valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
|
||||
request, then NULL is returned.
|
||||
|
||||
@param AllocationSize The number of bytes to allocate and zero.
|
||||
|
||||
@return A pointer to the allocated buffer or NULL if allocation fails.
|
||||
|
||||
**/
|
||||
VOID *
|
||||
EFIAPI
|
||||
AllocateZeroPool (
|
||||
IN UINTN AllocationSize
|
||||
)
|
||||
{
|
||||
return InternalAllocateZeroPool (EfiBootServicesData, AllocationSize);
|
||||
}
|
||||
|
||||
/**
|
||||
Allocates and zeros a buffer of type EfiRuntimeServicesData.
|
||||
|
||||
Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the
|
||||
buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
|
||||
valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
|
||||
request, then NULL is returned.
|
||||
|
||||
@param AllocationSize The number of bytes to allocate and zero.
|
||||
|
||||
@return A pointer to the allocated buffer or NULL if allocation fails.
|
||||
|
||||
**/
|
||||
VOID *
|
||||
EFIAPI
|
||||
AllocateRuntimeZeroPool (
|
||||
IN UINTN AllocationSize
|
||||
)
|
||||
{
|
||||
return InternalAllocateZeroPool (EfiRuntimeServicesData, AllocationSize);
|
||||
}
|
||||
|
||||
/**
|
||||
Allocates and zeros a buffer of type EfiReservedMemoryType.
|
||||
|
||||
Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the
|
||||
buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
|
||||
valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
|
||||
request, then NULL is returned.
|
||||
|
||||
@param AllocationSize The number of bytes to allocate and zero.
|
||||
|
||||
@return A pointer to the allocated buffer or NULL if allocation fails.
|
||||
|
||||
**/
|
||||
VOID *
|
||||
EFIAPI
|
||||
AllocateReservedZeroPool (
|
||||
IN UINTN AllocationSize
|
||||
)
|
||||
{
|
||||
return InternalAllocateZeroPool (EfiReservedMemoryType, AllocationSize);
|
||||
}
|
||||
|
||||
/**
|
||||
Copies a buffer to an allocated buffer of a certain pool type.
|
||||
|
||||
Allocates the number bytes specified by AllocationSize of a certain pool type, copies
|
||||
AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
|
||||
allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
|
||||
is not enough memory remaining to satisfy the request, then NULL is returned.
|
||||
If Buffer is NULL, then ASSERT().
|
||||
If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
|
||||
|
||||
@param PoolType The type of pool to allocate.
|
||||
@param AllocationSize The number of bytes to allocate and zero.
|
||||
@param Buffer The buffer to copy to the allocated buffer.
|
||||
|
||||
@return A pointer to the allocated buffer or NULL if allocation fails.
|
||||
|
||||
**/
|
||||
VOID *
|
||||
InternalAllocateCopyPool (
|
||||
IN EFI_MEMORY_TYPE PoolType,
|
||||
IN UINTN AllocationSize,
|
||||
IN CONST VOID *Buffer
|
||||
)
|
||||
{
|
||||
VOID *Memory;
|
||||
|
||||
ASSERT (Buffer != NULL);
|
||||
ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));
|
||||
|
||||
Memory = InternalAllocatePool (PoolType, AllocationSize);
|
||||
if (Memory != NULL) {
|
||||
Memory = CopyMem (Memory, Buffer, AllocationSize);
|
||||
}
|
||||
return Memory;
|
||||
}
|
||||
|
||||
/**
|
||||
Copies a buffer to an allocated buffer of type EfiBootServicesData.
|
||||
|
||||
Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies
|
||||
AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
|
||||
allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
|
||||
is not enough memory remaining to satisfy the request, then NULL is returned.
|
||||
|
||||
If Buffer is NULL, then ASSERT().
|
||||
If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
|
||||
|
||||
@param AllocationSize The number of bytes to allocate and zero.
|
||||
@param Buffer The buffer to copy to the allocated buffer.
|
||||
|
||||
@return A pointer to the allocated buffer or NULL if allocation fails.
|
||||
|
||||
**/
|
||||
VOID *
|
||||
EFIAPI
|
||||
AllocateCopyPool (
|
||||
IN UINTN AllocationSize,
|
||||
IN CONST VOID *Buffer
|
||||
)
|
||||
{
|
||||
return InternalAllocateCopyPool (EfiBootServicesData, AllocationSize, Buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.
|
||||
|
||||
Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies
|
||||
AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
|
||||
allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
|
||||
is not enough memory remaining to satisfy the request, then NULL is returned.
|
||||
|
||||
If Buffer is NULL, then ASSERT().
|
||||
If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
|
||||
|
||||
@param AllocationSize The number of bytes to allocate and zero.
|
||||
@param Buffer The buffer to copy to the allocated buffer.
|
||||
|
||||
@return A pointer to the allocated buffer or NULL if allocation fails.
|
||||
|
||||
**/
|
||||
VOID *
|
||||
EFIAPI
|
||||
AllocateRuntimeCopyPool (
|
||||
IN UINTN AllocationSize,
|
||||
IN CONST VOID *Buffer
|
||||
)
|
||||
{
|
||||
return InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
Copies a buffer to an allocated buffer of type EfiReservedMemoryType.
|
||||
|
||||
Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies
|
||||
AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
|
||||
allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
|
||||
is not enough memory remaining to satisfy the request, then NULL is returned.
|
||||
|
||||
If Buffer is NULL, then ASSERT().
|
||||
If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
|
||||
|
||||
@param AllocationSize The number of bytes to allocate and zero.
|
||||
@param Buffer The buffer to copy to the allocated buffer.
|
||||
|
||||
@return A pointer to the allocated buffer or NULL if allocation fails.
|
||||
|
||||
**/
|
||||
VOID *
|
||||
EFIAPI
|
||||
AllocateReservedCopyPool (
|
||||
IN UINTN AllocationSize,
|
||||
IN CONST VOID *Buffer
|
||||
)
|
||||
{
|
||||
return InternalAllocateCopyPool (EfiReservedMemoryType, AllocationSize, Buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
Reallocates a buffer of a specified memory type.
|
||||
|
||||
Allocates and zeros the number bytes specified by NewSize from memory of the type
|
||||
specified by PoolType. If OldBuffer is not NULL, then the smaller of OldSize and
|
||||
NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
|
||||
OldBuffer is freed. A pointer to the newly allocated buffer is returned.
|
||||
If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
|
||||
enough memory remaining to satisfy the request, then NULL is returned.
|
||||
|
||||
If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
|
||||
is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
|
||||
|
||||
@param PoolType The type of pool to allocate.
|
||||
@param OldSize The size, in bytes, of OldBuffer.
|
||||
@param NewSize The size, in bytes, of the buffer to reallocate.
|
||||
@param OldBuffer The buffer to copy to the allocated buffer. This is an optional
|
||||
parameter that may be NULL.
|
||||
|
||||
@return A pointer to the allocated buffer or NULL if allocation fails.
|
||||
|
||||
**/
|
||||
VOID *
|
||||
InternalReallocatePool (
|
||||
IN EFI_MEMORY_TYPE PoolType,
|
||||
IN UINTN OldSize,
|
||||
IN UINTN NewSize,
|
||||
IN VOID *OldBuffer OPTIONAL
|
||||
)
|
||||
{
|
||||
VOID *NewBuffer;
|
||||
|
||||
NewBuffer = InternalAllocateZeroPool (PoolType, NewSize);
|
||||
if (NewBuffer != NULL && OldBuffer != NULL) {
|
||||
CopyMem (NewBuffer, OldBuffer, MIN (OldSize, NewSize));
|
||||
FreePool (OldBuffer);
|
||||
}
|
||||
return NewBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
Reallocates a buffer of type EfiBootServicesData.
|
||||
|
||||
Allocates and zeros the number bytes specified by NewSize from memory of type
|
||||
EfiBootServicesData. If OldBuffer is not NULL, then the smaller of OldSize and
|
||||
NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
|
||||
OldBuffer is freed. A pointer to the newly allocated buffer is returned.
|
||||
If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
|
||||
enough memory remaining to satisfy the request, then NULL is returned.
|
||||
|
||||
If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
|
||||
is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
|
||||
|
||||
@param OldSize The size, in bytes, of OldBuffer.
|
||||
@param NewSize The size, in bytes, of the buffer to reallocate.
|
||||
@param OldBuffer The buffer to copy to the allocated buffer. This is an optional
|
||||
parameter that may be NULL.
|
||||
|
||||
@return A pointer to the allocated buffer or NULL if allocation fails.
|
||||
|
||||
**/
|
||||
VOID *
|
||||
EFIAPI
|
||||
ReallocatePool (
|
||||
IN UINTN OldSize,
|
||||
IN UINTN NewSize,
|
||||
IN VOID *OldBuffer OPTIONAL
|
||||
)
|
||||
{
|
||||
return InternalReallocatePool (EfiBootServicesData, OldSize, NewSize, OldBuffer);
|
||||
}
|
||||
|
||||
/**
|
||||
Reallocates a buffer of type EfiRuntimeServicesData.
|
||||
|
||||
Allocates and zeros the number bytes specified by NewSize from memory of type
|
||||
EfiRuntimeServicesData. If OldBuffer is not NULL, then the smaller of OldSize and
|
||||
NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
|
||||
OldBuffer is freed. A pointer to the newly allocated buffer is returned.
|
||||
If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
|
||||
enough memory remaining to satisfy the request, then NULL is returned.
|
||||
|
||||
If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
|
||||
is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
|
||||
|
||||
@param OldSize The size, in bytes, of OldBuffer.
|
||||
@param NewSize The size, in bytes, of the buffer to reallocate.
|
||||
@param OldBuffer The buffer to copy to the allocated buffer. This is an optional
|
||||
parameter that may be NULL.
|
||||
|
||||
@return A pointer to the allocated buffer or NULL if allocation fails.
|
||||
|
||||
**/
|
||||
VOID *
|
||||
EFIAPI
|
||||
ReallocateRuntimePool (
|
||||
IN UINTN OldSize,
|
||||
IN UINTN NewSize,
|
||||
IN VOID *OldBuffer OPTIONAL
|
||||
)
|
||||
{
|
||||
return InternalReallocatePool (EfiRuntimeServicesData, OldSize, NewSize, OldBuffer);
|
||||
}
|
||||
|
||||
/**
|
||||
Reallocates a buffer of type EfiReservedMemoryType.
|
||||
|
||||
Allocates and zeros the number bytes specified by NewSize from memory of type
|
||||
EfiReservedMemoryType. If OldBuffer is not NULL, then the smaller of OldSize and
|
||||
NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
|
||||
OldBuffer is freed. A pointer to the newly allocated buffer is returned.
|
||||
If NewSize is 0, then a valid buffer of 0 size is returned. If there is not
|
||||
enough memory remaining to satisfy the request, then NULL is returned.
|
||||
|
||||
If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
|
||||
is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
|
||||
|
||||
@param OldSize The size, in bytes, of OldBuffer.
|
||||
@param NewSize The size, in bytes, of the buffer to reallocate.
|
||||
@param OldBuffer The buffer to copy to the allocated buffer. This is an optional
|
||||
parameter that may be NULL.
|
||||
|
||||
@return A pointer to the allocated buffer or NULL if allocation fails.
|
||||
|
||||
**/
|
||||
VOID *
|
||||
EFIAPI
|
||||
ReallocateReservedPool (
|
||||
IN UINTN OldSize,
|
||||
IN UINTN NewSize,
|
||||
IN VOID *OldBuffer OPTIONAL
|
||||
)
|
||||
{
|
||||
return InternalReallocatePool (EfiReservedMemoryType, OldSize, NewSize, OldBuffer);
|
||||
}
|
||||
|
||||
/**
|
||||
Frees a buffer that was previously allocated with one of the pool allocation functions in the
|
||||
Memory Allocation Library.
|
||||
|
||||
Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the
|
||||
pool allocation services of the Memory Allocation Library. If it is not possible to free pool
|
||||
resources, then this function will perform no actions.
|
||||
|
||||
If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,
|
||||
then ASSERT().
|
||||
|
||||
@param Buffer The pointer to the buffer to free.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
FreePool (
|
||||
IN VOID *Buffer
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (!gEmuThunk->Free (Buffer)) {
|
||||
// The Free thunk will not free memory allocated in emulated EFI memory.
|
||||
// The assmuption is this was allocated directly by EFI. We need this as some
|
||||
// times protocols or EFI BootServices can return dynamically allocated buffers.
|
||||
Status = gBS->FreePool (Buffer);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
}
|
||||
|
50
EmulatorPkg/Library/KeyMapLibNull/KeyMapLibNull.c
Normal file
50
EmulatorPkg/Library/KeyMapLibNull/KeyMapLibNull.c
Normal file
@@ -0,0 +1,50 @@
|
||||
/*++ @file
|
||||
|
||||
Copyright (c) 2011, Apple Inc. 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 <Uefi.h>
|
||||
#include <Protocol/SimpleTextInEx.h>
|
||||
|
||||
|
||||
/**
|
||||
KeyMapMake gets called on key presses.
|
||||
|
||||
@param KeyData Key that was pressed.
|
||||
|
||||
@retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
KeyMapMake (
|
||||
IN EFI_KEY_DATA *KeyData
|
||||
)
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
KeyMapBreak gets called on key releases.
|
||||
|
||||
@param KeyData Key that was pressed.
|
||||
|
||||
@retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
KeyMapBreak (
|
||||
IN EFI_KEY_DATA *KeyData
|
||||
)
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
39
EmulatorPkg/Library/KeyMapLibNull/KeyMapLibNull.inf
Normal file
39
EmulatorPkg/Library/KeyMapLibNull/KeyMapLibNull.inf
Normal file
@@ -0,0 +1,39 @@
|
||||
## @file
|
||||
# A library to produce the global variable 'gEmuThunk'
|
||||
#
|
||||
# This library contains a single global variable 'gEmuThunk' along with a constructor to
|
||||
# initialize that global.
|
||||
# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
# Portions copyright (c) 2011, Apple Inc. 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 = KeyMapLibNull
|
||||
FILE_GUID = 6B7067C7-A843-A34C-9530-48446963B740
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = KeyMapLib
|
||||
|
||||
[Sources]
|
||||
KeyMapLibNull.c
|
||||
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
EmulatorPkg/EmulatorPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
HobLib
|
||||
DebugLib
|
||||
|
||||
|
@@ -0,0 +1,41 @@
|
||||
## @file
|
||||
# Instance of PEI Services Table Pointer Library using global variable for the table pointer.
|
||||
#
|
||||
# PEI Services Table Pointer Library implementation that retrieves a pointer to the
|
||||
# PEI Services Table from a global variable. Not available to modules that execute from
|
||||
# read-only memory.
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
# Portions copyright (c) 2011, Apple Inc. 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 = EmulatorPkgPeiCoreServicesTablePointerLib
|
||||
FILE_GUID = E9A22529-44FA-3E4A-A66B-1E918E7AB26A
|
||||
MODULE_TYPE = PEIM
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = PeiServicesTablePointerLib|PEI_CORE
|
||||
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC (EBC is for build only)
|
||||
#
|
||||
|
||||
[Sources]
|
||||
PeiServicesTablePointer.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
DebugLib
|
||||
|
@@ -0,0 +1,91 @@
|
||||
/** @file
|
||||
PEI Services Table Pointer Library.
|
||||
|
||||
This library is used for PEIM which does executed from flash device directly but
|
||||
executed in memory.
|
||||
|
||||
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php.
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include <PiPei.h>
|
||||
#include <Library/PeiServicesTablePointerLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
|
||||
CONST EFI_PEI_SERVICES **gPeiServices;
|
||||
|
||||
/**
|
||||
Caches a pointer PEI Services Table.
|
||||
|
||||
Caches the pointer to the PEI Services Table specified by PeiServicesTablePointer
|
||||
in a CPU specific manner as specified in the CPU binding section of the Platform Initialization
|
||||
Pre-EFI Initialization Core Interface Specification.
|
||||
|
||||
If PeiServicesTablePointer is NULL, then ASSERT().
|
||||
|
||||
@param PeiServicesTablePointer The address of PeiServices pointer.
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
SetPeiServicesTablePointer (
|
||||
IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer
|
||||
)
|
||||
{
|
||||
ASSERT (PeiServicesTablePointer != NULL);
|
||||
gPeiServices = PeiServicesTablePointer;
|
||||
}
|
||||
|
||||
/**
|
||||
Retrieves the cached value of the PEI Services Table pointer.
|
||||
|
||||
Returns the cached value of the PEI Services Table pointer in a CPU specific manner
|
||||
as specified in the CPU binding section of the Platform Initialization Pre-EFI
|
||||
Initialization Core Interface Specification.
|
||||
|
||||
If the cached PEI Services Table pointer is NULL, then ASSERT().
|
||||
|
||||
@return The pointer to PeiServices.
|
||||
|
||||
**/
|
||||
CONST EFI_PEI_SERVICES **
|
||||
EFIAPI
|
||||
GetPeiServicesTablePointer (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
ASSERT (gPeiServices != NULL);
|
||||
return gPeiServices;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
The constructor function caches the pointer to PEI services.
|
||||
|
||||
The constructor function caches the pointer to PEI services.
|
||||
It will always return EFI_SUCCESS.
|
||||
|
||||
@param FileHandle The handle of FFS header the loaded driver.
|
||||
@param PeiServices The pointer to the PEI services.
|
||||
|
||||
@retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesTablePointerLibConstructor (
|
||||
IN EFI_PEI_FILE_HANDLE FileHandle,
|
||||
IN CONST EFI_PEI_SERVICES **PeiServices
|
||||
)
|
||||
{
|
||||
gPeiServices = PeiServices;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,107 @@
|
||||
/** @file
|
||||
Provides services to perform additional actions to relocate and unload
|
||||
PE/Coff image for Emu environment specific purpose such as souce level debug.
|
||||
This version only works for PEI phase
|
||||
|
||||
Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
|
||||
Portions copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
#include <PiPei.h>
|
||||
#include <Ppi/EmuThunk.h>
|
||||
#include <Protocol/EmuThunk.h>
|
||||
|
||||
#include <Library/PeCoffLib.h>
|
||||
#include <Library/PeiServicesLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/PeCoffExtraActionLib.h>
|
||||
#include <Library/EmuMagicPageLib.h>
|
||||
|
||||
//
|
||||
// Cache of UnixThunk protocol
|
||||
//
|
||||
EMU_THUNK_PROTOCOL *mThunk = NULL;
|
||||
|
||||
/**
|
||||
The function caches the pointer of the Unix thunk functions
|
||||
It will ASSERT() if Unix thunk ppi is not installed.
|
||||
|
||||
@retval EFI_SUCCESS WinNT thunk protocol is found and cached.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EmuPeCoffGetThunkStucture (
|
||||
)
|
||||
{
|
||||
EMU_THUNK_PPI *ThunkPpi;
|
||||
EFI_STATUS Status;
|
||||
|
||||
|
||||
//
|
||||
// Locate Unix ThunkPpi for retrieving standard output handle
|
||||
//
|
||||
Status = PeiServicesLocatePpi (
|
||||
&gEmuThunkPpiGuid,
|
||||
0,
|
||||
NULL,
|
||||
(VOID **) &ThunkPpi
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
EMU_MAGIC_PAGE()->Thunk = (EMU_THUNK_PROTOCOL *) ThunkPpi->Thunk ();
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Performs additional actions after a PE/COFF image has been loaded and relocated.
|
||||
|
||||
If ImageContext is NULL, then ASSERT().
|
||||
|
||||
@param ImageContext Pointer to the image context structure that describes the
|
||||
PE/COFF image that has already been loaded and relocated.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
PeCoffLoaderRelocateImageExtraAction (
|
||||
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
|
||||
)
|
||||
{
|
||||
if (EMU_MAGIC_PAGE()->Thunk == NULL) {
|
||||
EmuPeCoffGetThunkStucture ();
|
||||
}
|
||||
EMU_MAGIC_PAGE()->Thunk->PeCoffRelocateImageExtraAction (ImageContext);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Performs additional actions just before a PE/COFF image is unloaded. Any resources
|
||||
that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.
|
||||
|
||||
If ImageContext is NULL, then ASSERT().
|
||||
|
||||
@param ImageContext Pointer to the image context structure that describes the
|
||||
PE/COFF image that is being unloaded.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
PeCoffLoaderUnloadImageExtraAction (
|
||||
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
|
||||
)
|
||||
{
|
||||
if (EMU_MAGIC_PAGE()->Thunk == NULL) {
|
||||
EmuPeCoffGetThunkStucture ();
|
||||
}
|
||||
EMU_MAGIC_PAGE()->Thunk->PeCoffUnloadImageExtraAction (ImageContext);
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
## @file
|
||||
# PeCoff extra action libary for Pei phase that run Emu emulator.
|
||||
#
|
||||
# Lib to provide memory journal status code reporting Routines
|
||||
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
# Portions copyright (c) 2011, Apple Inc. 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 = PeiEmuPeCoffExtraActionLib
|
||||
FILE_GUID = 79C4E72A-730B-F040-8129-95877B3A97A8
|
||||
MODULE_TYPE = PEIM
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = PeCoffExtraActionLib|PEI_CORE PEIM
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32
|
||||
#
|
||||
|
||||
[Sources]
|
||||
PeiEmuPeCoffExtraActionLib.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
EmulatorPkg/EmulatorPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
BaseLib
|
||||
PeiServicesLib
|
||||
DebugLib
|
||||
|
||||
[Ppis]
|
||||
gEmuThunkPpiGuid # PPI ALWAYS_CONSUMED
|
||||
|
||||
[Pcd]
|
||||
gEmulatorPkgTokenSpaceGuid.PcdPeiServicesTablePage
|
@@ -0,0 +1,297 @@
|
||||
/*++ @file
|
||||
|
||||
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Portions copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include "PiPei.h"
|
||||
#include <Library/PeCoffGetEntryPointLib.h>
|
||||
#include <Library/PeiServicesLib.h>
|
||||
#include <IndustryStandard/PeImage.h>
|
||||
#include <Library/DebugLib.h>
|
||||
|
||||
#include <Ppi/EmuThunk.h>
|
||||
#include <Protocol/EmuThunk.h>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Retrieves and returns a pointer to the entry point to a PE/COFF image that has been loaded
|
||||
into system memory with the PE/COFF Loader Library functions.
|
||||
|
||||
Retrieves the entry point to the PE/COFF image specified by Pe32Data and returns this entry
|
||||
point in EntryPoint. If the entry point could not be retrieved from the PE/COFF image, then
|
||||
return RETURN_INVALID_PARAMETER. Otherwise return RETURN_SUCCESS.
|
||||
If Pe32Data is NULL, then ASSERT().
|
||||
If EntryPoint is NULL, then ASSERT().
|
||||
|
||||
@param Pe32Data The pointer to the PE/COFF image that is loaded in system memory.
|
||||
@param EntryPoint The pointer to entry point to the PE/COFF image to return.
|
||||
|
||||
@retval RETURN_SUCCESS EntryPoint was returned.
|
||||
@retval RETURN_INVALID_PARAMETER The entry point could not be found in the PE/COFF image.
|
||||
|
||||
**/
|
||||
RETURN_STATUS
|
||||
EFIAPI
|
||||
PeCoffLoaderGetEntryPoint (
|
||||
IN VOID *Pe32Data,
|
||||
IN OUT VOID **EntryPoint
|
||||
)
|
||||
{
|
||||
EMU_THUNK_PPI *ThunkPpi;
|
||||
EFI_STATUS Status;
|
||||
EMU_THUNK_PROTOCOL *Thunk;
|
||||
|
||||
//
|
||||
// Locate EmuThunkPpi for retrieving standard output handle
|
||||
//
|
||||
Status = PeiServicesLocatePpi (
|
||||
&gEmuThunkPpiGuid,
|
||||
0,
|
||||
NULL,
|
||||
(VOID **) &ThunkPpi
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
|
||||
|
||||
return Thunk->PeCoffGetEntryPoint (Pe32Data, EntryPoint);
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the machine type of PE/COFF image.
|
||||
This is copied from MDE BasePeCoffGetEntryPointLib, the code should be sync with it.
|
||||
The reason is Emu package needs to load the image to memory to support source
|
||||
level debug.
|
||||
|
||||
|
||||
@param Pe32Data Pointer to a PE/COFF header
|
||||
|
||||
@return Machine type or zero if not a valid iamge
|
||||
|
||||
**/
|
||||
UINT16
|
||||
EFIAPI
|
||||
PeCoffLoaderGetMachineType (
|
||||
IN VOID *Pe32Data
|
||||
)
|
||||
{
|
||||
EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
|
||||
EFI_IMAGE_DOS_HEADER *DosHdr;
|
||||
|
||||
ASSERT (Pe32Data != NULL);
|
||||
|
||||
DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data;
|
||||
if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
|
||||
Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));
|
||||
|
||||
} else {
|
||||
Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)(Pe32Data);
|
||||
}
|
||||
|
||||
if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {
|
||||
return Hdr.Te->Machine;
|
||||
} else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
|
||||
return Hdr.Pe32->FileHeader.Machine;
|
||||
}
|
||||
|
||||
return 0x0000;
|
||||
}
|
||||
|
||||
/**
|
||||
Returns a pointer to the PDB file name for a PE/COFF image that has been
|
||||
loaded into system memory with the PE/COFF Loader Library functions.
|
||||
|
||||
Returns the PDB file name for the PE/COFF image specified by Pe32Data. If
|
||||
the PE/COFF image specified by Pe32Data is not a valid, then NULL is
|
||||
returned. If the PE/COFF image specified by Pe32Data does not contain a
|
||||
debug directory entry, then NULL is returned. If the debug directory entry
|
||||
in the PE/COFF image specified by Pe32Data does not contain a PDB file name,
|
||||
then NULL is returned.
|
||||
If Pe32Data is NULL, then ASSERT().
|
||||
|
||||
@param Pe32Data Pointer to the PE/COFF image that is loaded in system
|
||||
memory.
|
||||
|
||||
@return The PDB file name for the PE/COFF image specified by Pe32Data or NULL
|
||||
if it cannot be retrieved.
|
||||
|
||||
**/
|
||||
VOID *
|
||||
EFIAPI
|
||||
PeCoffLoaderGetPdbPointer (
|
||||
IN VOID *Pe32Data
|
||||
)
|
||||
{
|
||||
EFI_IMAGE_DOS_HEADER *DosHdr;
|
||||
EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
|
||||
EFI_IMAGE_DATA_DIRECTORY *DirectoryEntry;
|
||||
EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry;
|
||||
UINTN DirCount;
|
||||
VOID *CodeViewEntryPointer;
|
||||
INTN TEImageAdjust;
|
||||
UINT32 NumberOfRvaAndSizes;
|
||||
UINT16 Magic;
|
||||
|
||||
ASSERT (Pe32Data != NULL);
|
||||
|
||||
TEImageAdjust = 0;
|
||||
DirectoryEntry = NULL;
|
||||
DebugEntry = NULL;
|
||||
NumberOfRvaAndSizes = 0;
|
||||
|
||||
DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data;
|
||||
if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
|
||||
//
|
||||
// DOS image header is present, so read the PE header after the DOS image header.
|
||||
//
|
||||
Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));
|
||||
} else {
|
||||
//
|
||||
// DOS image header is not present, so PE header is at the image base.
|
||||
//
|
||||
Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data;
|
||||
}
|
||||
|
||||
if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {
|
||||
if (Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress != 0) {
|
||||
DirectoryEntry = &Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG];
|
||||
TEImageAdjust = sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize;
|
||||
DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN) Hdr.Te +
|
||||
Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress +
|
||||
TEImageAdjust);
|
||||
}
|
||||
} else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
|
||||
//
|
||||
// NOTE: We use Machine field to identify PE32/PE32+, instead of Magic.
|
||||
// It is due to backward-compatibility, for some system might
|
||||
// generate PE32+ image with PE32 Magic.
|
||||
//
|
||||
switch (Hdr.Pe32->FileHeader.Machine) {
|
||||
case EFI_IMAGE_MACHINE_IA32:
|
||||
//
|
||||
// Assume PE32 image with IA32 Machine field.
|
||||
//
|
||||
Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
|
||||
break;
|
||||
case EFI_IMAGE_MACHINE_X64:
|
||||
case EFI_IMAGE_MACHINE_IA64:
|
||||
//
|
||||
// Assume PE32+ image with X64 or IA64 Machine field
|
||||
//
|
||||
Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
|
||||
break;
|
||||
default:
|
||||
//
|
||||
// For unknow Machine field, use Magic in optional Header
|
||||
//
|
||||
Magic = Hdr.Pe32->OptionalHeader.Magic;
|
||||
}
|
||||
|
||||
if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
|
||||
//
|
||||
// Use PE32 offset get Debug Directory Entry
|
||||
//
|
||||
NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;
|
||||
DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
|
||||
DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress);
|
||||
} else if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {
|
||||
//
|
||||
// Use PE32+ offset get Debug Directory Entry
|
||||
//
|
||||
NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;
|
||||
DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
|
||||
DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress);
|
||||
}
|
||||
|
||||
if (NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {
|
||||
DirectoryEntry = NULL;
|
||||
DebugEntry = NULL;
|
||||
}
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (DebugEntry == NULL || DirectoryEntry == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (DirCount = 0; DirCount < DirectoryEntry->Size; DirCount += sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY), DebugEntry++) {
|
||||
if (DebugEntry->Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {
|
||||
if (DebugEntry->SizeOfData > 0) {
|
||||
CodeViewEntryPointer = (VOID *) ((UINTN) DebugEntry->RVA + ((UINTN)Pe32Data) + (UINTN)TEImageAdjust);
|
||||
switch (* (UINT32 *) CodeViewEntryPointer) {
|
||||
case CODEVIEW_SIGNATURE_NB10:
|
||||
return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY));
|
||||
case CODEVIEW_SIGNATURE_RSDS:
|
||||
return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY));
|
||||
case CODEVIEW_SIGNATURE_MTOC:
|
||||
return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Returns the size of the PE/COFF headers
|
||||
|
||||
Returns the size of the PE/COFF header specified by Pe32Data.
|
||||
If Pe32Data is NULL, then ASSERT().
|
||||
|
||||
@param Pe32Data Pointer to the PE/COFF image that is loaded in system
|
||||
memory.
|
||||
|
||||
@return Size of PE/COFF header in bytes or zero if not a valid image.
|
||||
|
||||
**/
|
||||
UINT32
|
||||
EFIAPI
|
||||
PeCoffGetSizeOfHeaders (
|
||||
IN VOID *Pe32Data
|
||||
)
|
||||
{
|
||||
EFI_IMAGE_DOS_HEADER *DosHdr;
|
||||
EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
|
||||
UINTN SizeOfHeaders;
|
||||
|
||||
ASSERT (Pe32Data != NULL);
|
||||
|
||||
DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data;
|
||||
if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
|
||||
//
|
||||
// DOS image header is present, so read the PE header after the DOS image header.
|
||||
//
|
||||
Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));
|
||||
} else {
|
||||
//
|
||||
// DOS image header is not present, so PE header is at the image base.
|
||||
//
|
||||
Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data;
|
||||
}
|
||||
|
||||
if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {
|
||||
SizeOfHeaders = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN)Hdr.Te->BaseOfCode - (UINTN)Hdr.Te->StrippedSize;
|
||||
} else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
|
||||
SizeOfHeaders = Hdr.Pe32->OptionalHeader.SizeOfHeaders;
|
||||
} else {
|
||||
SizeOfHeaders = 0;
|
||||
}
|
||||
|
||||
return SizeOfHeaders;
|
||||
}
|
||||
|
@@ -0,0 +1,49 @@
|
||||
## @file
|
||||
# Component description file for the EdkNt32PeiPeCoffGetEntryPointLib library.
|
||||
#
|
||||
# PeCoffGetEntryPointLib library class for NT32 instance implemented by use NTPeiLoadFile PPI.
|
||||
# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
# Portions copyright (c) 2011, Apple Inc. 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 = PeiEmuPeCoffGetEntryPointLib
|
||||
FILE_GUID = 1CBED347-7DE6-BC48-AC68-3758598124D2
|
||||
MODULE_TYPE = PEIM
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = PeCoffGetEntryPointLib
|
||||
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
#
|
||||
|
||||
[Sources]
|
||||
PeiEmuPeCoffGetEntryPointLib.c
|
||||
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
EmulatorPkg/EmulatorPkg.dec
|
||||
|
||||
|
||||
[LibraryClasses]
|
||||
PeiServicesLib
|
||||
DebugLib
|
||||
|
||||
|
||||
[Ppis]
|
||||
gEmuThunkPpiGuid # PPI ALWAYS_CONSUMED
|
||||
|
140
EmulatorPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.c
Normal file
140
EmulatorPkg/Library/PeiEmuSerialPortLib/PeiEmuSerialPortLib.c
Normal file
@@ -0,0 +1,140 @@
|
||||
/** @file
|
||||
Serial Port Lib that thunks back to Emulator services to write to StdErr.
|
||||
All read functions are stubed out. There is no constructor so this lib can
|
||||
be linked with PEI Core.
|
||||
|
||||
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Portions copyright (c) 2011, Apple Inc. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php.
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include <PiPei.h>
|
||||
#include <Library/SerialPortLib.h>
|
||||
#include <Library/PeiServicesLib.h>
|
||||
|
||||
#include <Ppi/EmuThunk.h>
|
||||
#include <Protocol/EmuThunk.h>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Initialize the serial device hardware.
|
||||
|
||||
If no initialization is required, then return RETURN_SUCCESS.
|
||||
If the serial device was successfully initialized, then return RETURN_SUCCESS.
|
||||
If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.
|
||||
|
||||
@retval RETURN_SUCCESS The serial device was initialized.
|
||||
@retval RETURN_DEVICE_ERROR The serial device could not be initialized.
|
||||
|
||||
**/
|
||||
RETURN_STATUS
|
||||
EFIAPI
|
||||
SerialPortInitialize (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Write data from buffer to serial device.
|
||||
|
||||
Writes NumberOfBytes data bytes from Buffer to the serial device.
|
||||
The number of bytes actually written to the serial device is returned.
|
||||
If the return value is less than NumberOfBytes, then the write operation failed.
|
||||
If Buffer is NULL, then ASSERT().
|
||||
If NumberOfBytes is zero, then return 0.
|
||||
|
||||
@param Buffer The pointer to the data buffer to be written.
|
||||
@param NumberOfBytes The number of bytes to written to the serial device.
|
||||
|
||||
@retval 0 NumberOfBytes is 0.
|
||||
@retval >0 The number of bytes written to the serial device.
|
||||
If this value is less than NumberOfBytes, then the read operation failed.
|
||||
|
||||
**/
|
||||
UINTN
|
||||
EFIAPI
|
||||
SerialPortWrite (
|
||||
IN UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
)
|
||||
{
|
||||
EMU_THUNK_PPI *ThunkPpi;
|
||||
EFI_STATUS Status;
|
||||
EMU_THUNK_PROTOCOL *Thunk;
|
||||
|
||||
//
|
||||
// Locate EmuThunkPpi for retrieving standard output handle
|
||||
//
|
||||
Status = PeiServicesLocatePpi (
|
||||
&gEmuThunkPpiGuid,
|
||||
0,
|
||||
NULL,
|
||||
(VOID **) &ThunkPpi
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
|
||||
return Thunk->WriteStdErr (Buffer, NumberOfBytes);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Read data from serial device and save the datas in buffer.
|
||||
|
||||
Reads NumberOfBytes data bytes from a serial device into the buffer
|
||||
specified by Buffer. The number of bytes actually read is returned.
|
||||
If the return value is less than NumberOfBytes, then the rest operation failed.
|
||||
If Buffer is NULL, then ASSERT().
|
||||
If NumberOfBytes is zero, then return 0.
|
||||
|
||||
@param Buffer The pointer to the data buffer to store the data read from the serial device.
|
||||
@param NumberOfBytes The number of bytes which will be read.
|
||||
|
||||
@retval 0 Read data failed; No data is to be read.
|
||||
@retval >0 The actual number of bytes read from serial device.
|
||||
|
||||
**/
|
||||
UINTN
|
||||
EFIAPI
|
||||
SerialPortRead (
|
||||
OUT UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
Polls a serial device to see if there is any data waiting to be read.
|
||||
|
||||
Polls a serial device to see if there is any data waiting to be read.
|
||||
If there is data waiting to be read from the serial device, then TRUE is returned.
|
||||
If there is no data waiting to be read from the serial device, then FALSE is returned.
|
||||
|
||||
@retval TRUE Data is waiting to be read from the serial device.
|
||||
@retval FALSE There is no data waiting to be read from the serial device.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
SerialPortPoll (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,45 @@
|
||||
## @file
|
||||
# Write only instance of Serial Port Library with empty functions.
|
||||
#
|
||||
# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
# Portions copyright (c) 2011, Apple Inc. 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 = PeiEmuSerialPortLibNull
|
||||
FILE_GUID = E4541241-8897-411a-91F8-7D7E45837146
|
||||
MODULE_TYPE = PEIM
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = SerialPortLib| PEI_CORE PEIM SEC
|
||||
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
#
|
||||
|
||||
[Sources]
|
||||
PeiEmuSerialPortLib.c
|
||||
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
EmulatorPkg/EmulatorPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
PeiServicesLib
|
||||
|
||||
[Ppis]
|
||||
gEmuThunkPpiGuid # PPI ALWAYS_CONSUMED
|
||||
|
||||
|
||||
|
||||
|
@@ -0,0 +1,136 @@
|
||||
/** @file
|
||||
PEI Services Table Pointer Library.
|
||||
|
||||
This library is used for PEIM which does executed from flash device directly but
|
||||
executed in memory.
|
||||
|
||||
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Portiions copyrigth (c) 2011, Apple Inc. 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 <PiPei.h>
|
||||
#include <Library/PeiServicesTablePointerLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
|
||||
#include <Ppi/MemoryDiscovered.h>
|
||||
|
||||
|
||||
CONST EFI_PEI_SERVICES **gPeiServices = NULL;
|
||||
|
||||
/**
|
||||
Caches a pointer PEI Services Table.
|
||||
|
||||
Caches the pointer to the PEI Services Table specified by PeiServicesTablePointer
|
||||
in a CPU specific manner as specified in the CPU binding section of the Platform Initialization
|
||||
Pre-EFI Initialization Core Interface Specification.
|
||||
|
||||
If PeiServicesTablePointer is NULL, then ASSERT().
|
||||
|
||||
@param PeiServicesTablePointer The address of PeiServices pointer.
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
SetPeiServicesTablePointer (
|
||||
IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer
|
||||
)
|
||||
{
|
||||
ASSERT (PeiServicesTablePointer != NULL);
|
||||
ASSERT (*PeiServicesTablePointer != NULL);
|
||||
gPeiServices = PeiServicesTablePointer;
|
||||
}
|
||||
|
||||
/**
|
||||
Retrieves the cached value of the PEI Services Table pointer.
|
||||
|
||||
Returns the cached value of the PEI Services Table pointer in a CPU specific manner
|
||||
as specified in the CPU binding section of the Platform Initialization Pre-EFI
|
||||
Initialization Core Interface Specification.
|
||||
|
||||
If the cached PEI Services Table pointer is NULL, then ASSERT().
|
||||
|
||||
@return The pointer to PeiServices.
|
||||
|
||||
**/
|
||||
CONST EFI_PEI_SERVICES **
|
||||
EFIAPI
|
||||
GetPeiServicesTablePointer (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
ASSERT (gPeiServices != NULL);
|
||||
ASSERT (*gPeiServices != NULL);
|
||||
return gPeiServices;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Notification service to be called when gEmuThunkPpiGuid is installed.
|
||||
|
||||
@param PeiServices Indirect reference to the PEI Services Table.
|
||||
@param NotifyDescriptor Address of the notification descriptor data structure. Type
|
||||
EFI_PEI_NOTIFY_DESCRIPTOR is defined above.
|
||||
@param Ppi Address of the PPI that was installed.
|
||||
|
||||
@retval EFI_STATUS This function will install a PPI to PPI database. The status
|
||||
code will be the code for (*PeiServices)->InstallPpi.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesTablePointerNotifyCallback (
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
|
||||
IN VOID *Ppi
|
||||
)
|
||||
{
|
||||
gPeiServices = (CONST EFI_PEI_SERVICES **)PeiServices;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnThunkList = {
|
||||
(EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
|
||||
&gEfiPeiMemoryDiscoveredPpiGuid,
|
||||
PeiServicesTablePointerNotifyCallback
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Constructor register notification on when PPI updates. If PPI is
|
||||
alreay installed registering the notify will cause the handle to
|
||||
run.
|
||||
|
||||
@param FileHandle The handle of FFS header the loaded driver.
|
||||
@param PeiServices The pointer to the PEI services.
|
||||
|
||||
@retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesTablePointerLibConstructor (
|
||||
IN EFI_PEI_FILE_HANDLE FileHandle,
|
||||
IN CONST EFI_PEI_SERVICES **PeiServices
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
gPeiServices = (CONST EFI_PEI_SERVICES **)PeiServices;
|
||||
|
||||
// register to be told when PeiServices pointer is updated
|
||||
Status = (*PeiServices)->NotifyPpi (PeiServices, &mNotifyOnThunkList);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,46 @@
|
||||
## @file
|
||||
# Instance of PEI Services Table Pointer Library using global variable for the table pointer.
|
||||
#
|
||||
# PEI Services Table Pointer Library implementation that retrieves a pointer to the
|
||||
# PEI Services Table from a global variable. Not available to modules that execute from
|
||||
# read-only memory.
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
# Portions copyright (c) 2011, Apple Inc. 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 = EmulatorPkgPeiServicesTablePointerLib
|
||||
FILE_GUID = 5FD8B4ED-D66F-C144-9953-AC557C649925
|
||||
MODULE_TYPE = PEIM
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = PeiServicesTablePointerLib|PEIM
|
||||
|
||||
CONSTRUCTOR = PeiServicesTablePointerLibConstructor
|
||||
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC (EBC is for build only)
|
||||
#
|
||||
|
||||
[Sources]
|
||||
PeiServicesTablePointer.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
DebugLib
|
||||
|
||||
[Ppis]
|
||||
gEfiPeiMemoryDiscoveredPpiGuid
|
||||
|
@@ -0,0 +1,75 @@
|
||||
/** @file
|
||||
PEI Services Table Pointer Library.
|
||||
|
||||
Store PEI Services Table pointer via gEmulatorPkgTokenSpaceGuid.PcdPeiServicesTablePage.
|
||||
This emulates a platform SRAM. The PI mechaism does not work in the emulator due to
|
||||
lack of privledge.
|
||||
|
||||
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Portiions copyrigth (c) 2011, Apple Inc. 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 <PiPei.h>
|
||||
#include <Library/PeiServicesTablePointerLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/EmuMagicPageLib.h>
|
||||
|
||||
|
||||
/**
|
||||
Caches a pointer PEI Services Table.
|
||||
|
||||
Caches the pointer to the PEI Services Table specified by PeiServicesTablePointer
|
||||
in a CPU specific manner as specified in the CPU binding section of the Platform Initialization
|
||||
Pre-EFI Initialization Core Interface Specification.
|
||||
|
||||
If PeiServicesTablePointer is NULL, then ASSERT().
|
||||
|
||||
@param PeiServicesTablePointer The address of PeiServices pointer.
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
SetPeiServicesTablePointer (
|
||||
IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer
|
||||
)
|
||||
{
|
||||
ASSERT (PeiServicesTablePointer != NULL);
|
||||
ASSERT (*PeiServicesTablePointer != NULL);
|
||||
EMU_MAGIC_PAGE()->PeiServicesTablePointer = PeiServicesTablePointer;
|
||||
}
|
||||
|
||||
/**
|
||||
Retrieves the cached value of the PEI Services Table pointer.
|
||||
|
||||
Returns the cached value of the PEI Services Table pointer in a CPU specific manner
|
||||
as specified in the CPU binding section of the Platform Initialization Pre-EFI
|
||||
Initialization Core Interface Specification.
|
||||
|
||||
If the cached PEI Services Table pointer is NULL, then ASSERT().
|
||||
|
||||
@return The pointer to PeiServices.
|
||||
|
||||
**/
|
||||
CONST EFI_PEI_SERVICES **
|
||||
EFIAPI
|
||||
GetPeiServicesTablePointer (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
CONST EFI_PEI_SERVICES **PeiServicesTablePointer;
|
||||
|
||||
PeiServicesTablePointer = EMU_MAGIC_PAGE()->PeiServicesTablePointer;
|
||||
ASSERT (PeiServicesTablePointer != NULL);
|
||||
ASSERT (*PeiServicesTablePointer != NULL);
|
||||
return PeiServicesTablePointer;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -0,0 +1,44 @@
|
||||
## @file
|
||||
# PEI Services Table Pointer Library.
|
||||
#
|
||||
# Store PEI Services Table pointer via gEmulatorPkgTokenSpaceGuid.PcdPeiServicesTablePage.
|
||||
# This emulates a platform SRAM. The PI mechaism does not work in the emulator due to
|
||||
# lack of privledge.
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
# Portions copyright (c) 2011, Apple Inc. 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 = EmulatorPkgPeiServicesTablePointerLib
|
||||
FILE_GUID = 7488FC06-370A-1C41-B05C-7395559A535A
|
||||
MODULE_TYPE = PEIM
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = PeiServicesTablePointerLib|PEIM PEI_CORE SEC
|
||||
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC (EBC is for build only)
|
||||
#
|
||||
|
||||
[Sources]
|
||||
PeiServicesTablePointer.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
EmulatorPkg/EmulatorPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
DebugLib
|
||||
|
||||
[Pcd]
|
||||
gEmulatorPkgTokenSpaceGuid.PcdPeiServicesTablePage
|
174
EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.c
Normal file
174
EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.c
Normal file
@@ -0,0 +1,174 @@
|
||||
/** @file
|
||||
A non-functional instance of the Timer Library.
|
||||
|
||||
Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php.
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include <PiPei.h>
|
||||
#include <Library/TimerLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/PeiServicesLib.h>
|
||||
|
||||
#include <Ppi/EmuThunk.h>
|
||||
#include <Protocol/EmuThunk.h>
|
||||
|
||||
/**
|
||||
Stalls the CPU for at least the given number of microseconds.
|
||||
|
||||
Stalls the CPU for the number of microseconds specified by MicroSeconds.
|
||||
|
||||
@param MicroSeconds The minimum number of microseconds to delay.
|
||||
|
||||
@return The value of MicroSeconds inputted.
|
||||
|
||||
**/
|
||||
UINTN
|
||||
EFIAPI
|
||||
MicroSecondDelay (
|
||||
IN UINTN MicroSeconds
|
||||
)
|
||||
{
|
||||
return NanoSecondDelay (MicroSeconds * 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
Stalls the CPU for at least the given number of nanoseconds.
|
||||
|
||||
Stalls the CPU for the number of nanoseconds specified by NanoSeconds.
|
||||
|
||||
@param NanoSeconds The minimum number of nanoseconds to delay.
|
||||
|
||||
@return The value of NanoSeconds inputted.
|
||||
|
||||
**/
|
||||
UINTN
|
||||
EFIAPI
|
||||
NanoSecondDelay (
|
||||
IN UINTN NanoSeconds
|
||||
)
|
||||
{
|
||||
EMU_THUNK_PPI *ThunkPpi;
|
||||
EFI_STATUS Status;
|
||||
EMU_THUNK_PROTOCOL *Thunk;
|
||||
|
||||
//
|
||||
// Locate EmuThunkPpi for
|
||||
//
|
||||
Status = PeiServicesLocatePpi (
|
||||
&gEmuThunkPpiGuid,
|
||||
0,
|
||||
NULL,
|
||||
(VOID **) &ThunkPpi
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
|
||||
Thunk->Sleep (NanoSeconds * 100);
|
||||
return NanoSeconds;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
Retrieves the current value of a 64-bit free running performance counter.
|
||||
|
||||
The counter can either count up by 1 or count down by 1. If the physical
|
||||
performance counter counts by a larger increment, then the counter values
|
||||
must be translated. The properties of the counter can be retrieved from
|
||||
GetPerformanceCounterProperties().
|
||||
|
||||
@return The current value of the free running performance counter.
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
GetPerformanceCounter (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EMU_THUNK_PPI *ThunkPpi;
|
||||
EFI_STATUS Status;
|
||||
EMU_THUNK_PROTOCOL *Thunk;
|
||||
|
||||
//
|
||||
// Locate EmuThunkPpi for
|
||||
//
|
||||
Status = PeiServicesLocatePpi (
|
||||
&gEmuThunkPpiGuid,
|
||||
0,
|
||||
NULL,
|
||||
(VOID **) &ThunkPpi
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
|
||||
return Thunk->QueryPerformanceCounter ();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
Retrieves the 64-bit frequency in Hz and the range of performance counter
|
||||
values.
|
||||
|
||||
If StartValue is not NULL, then the value that the performance counter starts
|
||||
with immediately after is it rolls over is returned in StartValue. If
|
||||
EndValue is not NULL, then the value that the performance counter end with
|
||||
immediately before it rolls over is returned in EndValue. The 64-bit
|
||||
frequency of the performance counter in Hz is always returned. If StartValue
|
||||
is less than EndValue, then the performance counter counts up. If StartValue
|
||||
is greater than EndValue, then the performance counter counts down. For
|
||||
example, a 64-bit free running counter that counts up would have a StartValue
|
||||
of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter
|
||||
that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0.
|
||||
|
||||
@param StartValue The value the performance counter starts with when it
|
||||
rolls over.
|
||||
@param EndValue The value that the performance counter ends with before
|
||||
it rolls over.
|
||||
|
||||
@return The frequency in Hz.
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
GetPerformanceCounterProperties (
|
||||
OUT UINT64 *StartValue, OPTIONAL
|
||||
OUT UINT64 *EndValue OPTIONAL
|
||||
)
|
||||
{
|
||||
EMU_THUNK_PPI *ThunkPpi;
|
||||
EFI_STATUS Status;
|
||||
EMU_THUNK_PROTOCOL *Thunk;
|
||||
|
||||
//
|
||||
// Locate EmuThunkPpi for
|
||||
//
|
||||
Status = PeiServicesLocatePpi (
|
||||
&gEmuThunkPpiGuid,
|
||||
0,
|
||||
NULL,
|
||||
(VOID **) &ThunkPpi
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
if (StartValue != NULL) {
|
||||
*StartValue = 0ULL;
|
||||
}
|
||||
if (EndValue != NULL) {
|
||||
*EndValue = (UINT64)-1LL;
|
||||
}
|
||||
|
||||
Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
|
||||
return Thunk->QueryPerformanceFrequency ();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
47
EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.inf
Normal file
47
EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.inf
Normal file
@@ -0,0 +1,47 @@
|
||||
## @file
|
||||
# NULL instance of Timer Library as a template.
|
||||
#
|
||||
# A non-functional instance of the Timer Library that can be used as a template
|
||||
# for the implementation of a functional timer library instance. This library instance can
|
||||
# also be used to test build DXE, Runtime, DXE SAL, and DXE SMM modules that require timer
|
||||
# services as well as EBC modules that require timer services.
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php.
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
#
|
||||
##
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = EmuPeiTimerLib
|
||||
FILE_GUID = 6ABE5FDC-AE4B-474E-8E52-9546C96AE536
|
||||
MODULE_TYPE = BASE
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = TimerLib|PEIM PEI_CORE SEC
|
||||
|
||||
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
#
|
||||
|
||||
[Sources]
|
||||
PeiTimerLib.c
|
||||
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
EmulatorPkg/EmulatorPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
DebugLib
|
||||
PeiServicesLib
|
||||
|
||||
[Ppis]
|
||||
gEmuThunkPpiGuid
|
281
EmulatorPkg/Library/SecPeiServicesLib/FwVol.c
Normal file
281
EmulatorPkg/Library/SecPeiServicesLib/FwVol.c
Normal file
@@ -0,0 +1,281 @@
|
||||
/*++ @file
|
||||
A simple FV stack so the SEC can extract the SEC Core from an
|
||||
FV.
|
||||
|
||||
Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include <PiPei.h>
|
||||
|
||||
|
||||
#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \
|
||||
(ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1))
|
||||
|
||||
EFI_FFS_FILE_STATE
|
||||
GetFileState (
|
||||
IN UINT8 ErasePolarity,
|
||||
IN EFI_FFS_FILE_HEADER *FfsHeader
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Returns the highest bit set of the State field
|
||||
|
||||
Arguments:
|
||||
ErasePolarity - Erase Polarity as defined by EFI_FVB2_ERASE_POLARITY
|
||||
in the Attributes field.
|
||||
FfsHeader - Pointer to FFS File Header.
|
||||
|
||||
Returns:
|
||||
Returns the highest bit in the State field
|
||||
|
||||
**/
|
||||
{
|
||||
EFI_FFS_FILE_STATE FileState;
|
||||
EFI_FFS_FILE_STATE HighestBit;
|
||||
|
||||
FileState = FfsHeader->State;
|
||||
|
||||
if (ErasePolarity != 0) {
|
||||
FileState = (EFI_FFS_FILE_STATE)~FileState;
|
||||
}
|
||||
|
||||
HighestBit = 0x80;
|
||||
while (HighestBit != 0 && (HighestBit & FileState) == 0) {
|
||||
HighestBit >>= 1;
|
||||
}
|
||||
|
||||
return HighestBit;
|
||||
}
|
||||
|
||||
UINT8
|
||||
CalculateHeaderChecksum (
|
||||
IN EFI_FFS_FILE_HEADER *FileHeader
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Calculates the checksum of the header of a file.
|
||||
|
||||
Arguments:
|
||||
FileHeader - Pointer to FFS File Header.
|
||||
|
||||
Returns:
|
||||
Checksum of the header.
|
||||
|
||||
**/
|
||||
{
|
||||
UINT8 *ptr;
|
||||
UINTN Index;
|
||||
UINT8 Sum;
|
||||
|
||||
Sum = 0;
|
||||
ptr = (UINT8 *) FileHeader;
|
||||
|
||||
for (Index = 0; Index < sizeof (EFI_FFS_FILE_HEADER) - 3; Index += 4) {
|
||||
Sum = (UINT8) (Sum + ptr[Index]);
|
||||
Sum = (UINT8) (Sum + ptr[Index + 1]);
|
||||
Sum = (UINT8) (Sum + ptr[Index + 2]);
|
||||
Sum = (UINT8) (Sum + ptr[Index + 3]);
|
||||
}
|
||||
|
||||
for (; Index < sizeof (EFI_FFS_FILE_HEADER); Index++) {
|
||||
Sum = (UINT8) (Sum + ptr[Index]);
|
||||
}
|
||||
//
|
||||
// State field (since this indicates the different state of file).
|
||||
//
|
||||
Sum = (UINT8) (Sum - FileHeader->State);
|
||||
//
|
||||
// Checksum field of the file is not part of the header checksum.
|
||||
//
|
||||
Sum = (UINT8) (Sum - FileHeader->IntegrityCheck.Checksum.File);
|
||||
|
||||
return Sum;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
SecFfsFindNextFile (
|
||||
IN EFI_FV_FILETYPE SearchType,
|
||||
IN EFI_PEI_FV_HANDLE FvHandle,
|
||||
IN OUT EFI_PEI_FILE_HANDLE *FileHandle
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Given the input file pointer, search for the next matching file in the
|
||||
FFS volume as defined by SearchType. The search starts from FileHeader inside
|
||||
the Firmware Volume defined by FwVolHeader.
|
||||
|
||||
Arguments:
|
||||
SearchType - Filter to find only files of this type.
|
||||
Type EFI_FV_FILETYPE_ALL causes no filtering to be done.
|
||||
FwVolHeader - Pointer to the FV header of the volume to search.
|
||||
This parameter must point to a valid FFS volume.
|
||||
FileHeader - Pointer to the current file from which to begin searching.
|
||||
This pointer will be updated upon return to reflect the file
|
||||
found.
|
||||
|
||||
Returns:
|
||||
EFI_NOT_FOUND - No files matching the search criteria were found
|
||||
EFI_SUCCESS
|
||||
|
||||
**/
|
||||
{
|
||||
EFI_FFS_FILE_HEADER *FfsFileHeader;
|
||||
UINT32 FileLength;
|
||||
UINT32 FileOccupiedSize;
|
||||
UINT32 FileOffset;
|
||||
UINT64 FvLength;
|
||||
UINT8 ErasePolarity;
|
||||
UINT8 FileState;
|
||||
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
|
||||
EFI_FFS_FILE_HEADER **FileHeader;
|
||||
|
||||
//
|
||||
// Convert the handle of FV to FV header for memory-mapped firmware volume
|
||||
//
|
||||
FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) FvHandle;
|
||||
FileHeader = (EFI_FFS_FILE_HEADER **)FileHandle;
|
||||
|
||||
FvLength = FwVolHeader->FvLength;
|
||||
if (FwVolHeader->Attributes & EFI_FVB2_ERASE_POLARITY) {
|
||||
ErasePolarity = 1;
|
||||
} else {
|
||||
ErasePolarity = 0;
|
||||
}
|
||||
//
|
||||
// If FileHeader is not specified (NULL) start with the first file in the
|
||||
// firmware volume. Otherwise, start from the FileHeader.
|
||||
//
|
||||
if (*FileHeader == NULL) {
|
||||
FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FwVolHeader + FwVolHeader->HeaderLength);
|
||||
} else {
|
||||
//
|
||||
// Length is 24 bits wide so mask upper 8 bits
|
||||
// FileLength is adjusted to FileOccupiedSize as it is 8 byte aligned.
|
||||
//
|
||||
FileLength = *(UINT32 *) (*FileHeader)->Size & 0x00FFFFFF;
|
||||
FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
|
||||
FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) *FileHeader + FileOccupiedSize);
|
||||
}
|
||||
|
||||
FileOffset = (UINT32) ((UINT8 *) FfsFileHeader - (UINT8 *) FwVolHeader);
|
||||
|
||||
while (FileOffset < (FvLength - sizeof (EFI_FFS_FILE_HEADER))) {
|
||||
//
|
||||
// Get FileState which is the highest bit of the State
|
||||
//
|
||||
FileState = GetFileState (ErasePolarity, FfsFileHeader);
|
||||
|
||||
switch (FileState) {
|
||||
|
||||
case EFI_FILE_HEADER_INVALID:
|
||||
FileOffset += sizeof (EFI_FFS_FILE_HEADER);
|
||||
FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + sizeof (EFI_FFS_FILE_HEADER));
|
||||
break;
|
||||
|
||||
case EFI_FILE_DATA_VALID:
|
||||
case EFI_FILE_MARKED_FOR_UPDATE:
|
||||
if (CalculateHeaderChecksum (FfsFileHeader) == 0) {
|
||||
FileLength = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF;
|
||||
FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
|
||||
|
||||
if ((SearchType == FfsFileHeader->Type) || (SearchType == EFI_FV_FILETYPE_ALL)) {
|
||||
|
||||
*FileHeader = FfsFileHeader;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
FileOffset += FileOccupiedSize;
|
||||
FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + FileOccupiedSize);
|
||||
} else {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
break;
|
||||
|
||||
case EFI_FILE_DELETED:
|
||||
FileLength = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF;
|
||||
FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
|
||||
FileOffset += FileOccupiedSize;
|
||||
FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + FileOccupiedSize);
|
||||
break;
|
||||
|
||||
default:
|
||||
return EFI_NOT_FOUND;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
SecFfsFindSectionData (
|
||||
IN EFI_SECTION_TYPE SectionType,
|
||||
IN EFI_FFS_FILE_HEADER *FfsFileHeader,
|
||||
IN OUT VOID **SectionData
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Given the input file pointer, search for the next matching section in the
|
||||
FFS volume.
|
||||
|
||||
Arguments:
|
||||
SearchType - Filter to find only sections of this type.
|
||||
FfsFileHeader - Pointer to the current file to search.
|
||||
SectionData - Pointer to the Section matching SectionType in FfsFileHeader.
|
||||
NULL if section not found
|
||||
|
||||
Returns:
|
||||
EFI_NOT_FOUND - No files matching the search criteria were found
|
||||
EFI_SUCCESS
|
||||
|
||||
**/
|
||||
{
|
||||
UINT32 FileSize;
|
||||
EFI_COMMON_SECTION_HEADER *Section;
|
||||
UINT32 SectionLength;
|
||||
UINT32 ParsedLength;
|
||||
|
||||
//
|
||||
// Size is 24 bits wide so mask upper 8 bits.
|
||||
// Does not include FfsFileHeader header size
|
||||
// FileSize is adjusted to FileOccupiedSize as it is 8 byte aligned.
|
||||
//
|
||||
Section = (EFI_COMMON_SECTION_HEADER *) (FfsFileHeader + 1);
|
||||
FileSize = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF;
|
||||
FileSize -= sizeof (EFI_FFS_FILE_HEADER);
|
||||
|
||||
*SectionData = NULL;
|
||||
ParsedLength = 0;
|
||||
while (ParsedLength < FileSize) {
|
||||
if (Section->Type == SectionType) {
|
||||
*SectionData = (VOID *) (Section + 1);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
//
|
||||
// Size is 24 bits wide so mask upper 8 bits.
|
||||
// SectionLength is adjusted it is 4 byte aligned.
|
||||
// Go to the next section
|
||||
//
|
||||
SectionLength = *(UINT32 *) Section->Size & 0x00FFFFFF;
|
||||
SectionLength = GET_OCCUPIED_SIZE (SectionLength, 4);
|
||||
|
||||
ParsedLength += SectionLength;
|
||||
Section = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) Section + SectionLength);
|
||||
}
|
||||
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
567
EmulatorPkg/Library/SecPeiServicesLib/PeiServicesLib.c
Normal file
567
EmulatorPkg/Library/SecPeiServicesLib/PeiServicesLib.c
Normal file
@@ -0,0 +1,567 @@
|
||||
/** @file
|
||||
Implementation for PEI Services Library.
|
||||
|
||||
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php.
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include <PiPei.h>
|
||||
#include <Library/EmuMagicPageLib.h>
|
||||
#include <Library/PeiServicesLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
SecFfsFindNextFile (
|
||||
IN EFI_FV_FILETYPE SearchType,
|
||||
IN EFI_PEI_FV_HANDLE VolumeHandle,
|
||||
IN OUT EFI_PEI_FILE_HANDLE *FileHandle
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
SecFfsFindSectionData (
|
||||
IN EFI_SECTION_TYPE SectionType,
|
||||
IN EFI_PEI_FILE_HANDLE FileHandle,
|
||||
OUT VOID **SectionData
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
This service enables a given PEIM to register an interface into the PEI Foundation.
|
||||
|
||||
@param PpiList A pointer to the list of interfaces that the caller shall install.
|
||||
|
||||
@retval EFI_SUCCESS The interface was successfully installed.
|
||||
@retval EFI_INVALID_PARAMETER The PpiList pointer is NULL.
|
||||
@retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the
|
||||
EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
|
||||
@retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesInstallPpi (
|
||||
IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
/**
|
||||
This service enables PEIMs to replace an entry in the PPI database with an alternate entry.
|
||||
|
||||
@param OldPpi The pointer to the old PEI PPI Descriptors.
|
||||
@param NewPpi The pointer to the new PEI PPI Descriptors.
|
||||
|
||||
@retval EFI_SUCCESS The interface was successfully installed.
|
||||
@retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL.
|
||||
@retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the
|
||||
EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
|
||||
@retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
|
||||
@retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been
|
||||
installed.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesReInstallPpi (
|
||||
IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi,
|
||||
IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
/**
|
||||
This service enables PEIMs to discover a given instance of an interface.
|
||||
|
||||
So this is, well a hack, so we can reuse the same libraries as the PEI Core
|
||||
for XIP modules....
|
||||
|
||||
@param Guid A pointer to the GUID whose corresponding interface needs to be
|
||||
found.
|
||||
@param Instance The N-th instance of the interface that is required.
|
||||
@param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR.
|
||||
@param Ppi A pointer to the instance of the interface.
|
||||
|
||||
@retval EFI_SUCCESS The interface was successfully returned.
|
||||
@retval EFI_NOT_FOUND The PPI descriptor is not found in the database.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesLocatePpi (
|
||||
IN CONST EFI_GUID *Guid,
|
||||
IN UINTN Instance,
|
||||
IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,
|
||||
IN OUT VOID **Ppi
|
||||
)
|
||||
{
|
||||
EFI_PEI_PPI_DESCRIPTOR *PpiList;
|
||||
|
||||
if (Instance != 0) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
for (PpiList = EMU_MAGIC_PAGE()->PpiList; ; PpiList++) {
|
||||
if (CompareGuid (PpiList->Guid, Guid)) {
|
||||
if (PpiDescriptor != NULL) {
|
||||
*PpiDescriptor = PpiList;
|
||||
}
|
||||
if (Ppi != NULL) {
|
||||
*Ppi = PpiList->Ppi;
|
||||
}
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) == EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
/**
|
||||
This service enables PEIMs to register a given service to be invoked when another service is
|
||||
installed or reinstalled.
|
||||
|
||||
@param NotifyList A pointer to the list of notification interfaces
|
||||
that the caller shall install.
|
||||
|
||||
@retval EFI_SUCCESS The interface was successfully installed.
|
||||
@retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL.
|
||||
@retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do
|
||||
not have the EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES
|
||||
bit set in the Flags field.
|
||||
@retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesNotifyPpi (
|
||||
IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
/**
|
||||
This service enables PEIMs to ascertain the present value of the boot mode.
|
||||
|
||||
@param BootMode A pointer to contain the value of the boot mode.
|
||||
|
||||
@retval EFI_SUCCESS The boot mode was returned successfully.
|
||||
@retval EFI_INVALID_PARAMETER BootMode is NULL.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesGetBootMode (
|
||||
OUT EFI_BOOT_MODE *BootMode
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
/**
|
||||
This service enables PEIMs to update the boot mode variable.
|
||||
|
||||
@param BootMode The value of the boot mode to set.
|
||||
|
||||
@retval EFI_SUCCESS The value was successfully updated
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesSetBootMode (
|
||||
IN EFI_BOOT_MODE BootMode
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
/**
|
||||
This service enables a PEIM to ascertain the address of the list of HOBs in memory.
|
||||
|
||||
@param HobList A pointer to the list of HOBs that the PEI Foundation
|
||||
will initialize.
|
||||
|
||||
@retval EFI_SUCCESS The list was successfully returned.
|
||||
@retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesGetHobList (
|
||||
OUT VOID **HobList
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
/**
|
||||
This service enables PEIMs to create various types of HOBs.
|
||||
|
||||
@param Type The type of HOB to be installed.
|
||||
@param Length The length of the HOB to be added.
|
||||
@param Hob The address of a pointer that will contain the
|
||||
HOB header.
|
||||
|
||||
@retval EFI_SUCCESS The HOB was successfully created.
|
||||
@retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesCreateHob (
|
||||
IN UINT16 Type,
|
||||
IN UINT16 Length,
|
||||
OUT VOID **Hob
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
/**
|
||||
This service enables PEIMs to discover additional firmware volumes.
|
||||
|
||||
@param Instance This instance of the firmware volume to find. The
|
||||
value 0 is the Boot Firmware Volume (BFV).
|
||||
@param VolumeHandle Handle of the firmware volume header of the volume
|
||||
to return.
|
||||
|
||||
@retval EFI_SUCCESS The volume was found.
|
||||
@retval EFI_NOT_FOUND The volume was not found.
|
||||
@retval EFI_INVALID_PARAMETER FwVolHeader is NULL.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesFfsFindNextVolume (
|
||||
IN UINTN Instance,
|
||||
IN OUT EFI_PEI_FV_HANDLE *VolumeHandle
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
/**
|
||||
This service enables PEIMs to discover additional firmware files.
|
||||
|
||||
@param SearchType A filter to find files only of this type.
|
||||
@param VolumeHandle The pointer to the firmware volume header of the
|
||||
volume to search. This parameter must point to a
|
||||
valid FFS volume.
|
||||
@param FileHandle Handle of the current file from which to begin searching.
|
||||
|
||||
@retval EFI_SUCCESS The file was found.
|
||||
@retval EFI_NOT_FOUND The file was not found.
|
||||
@retval EFI_NOT_FOUND The header checksum was not zero.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesFfsFindNextFile (
|
||||
IN EFI_FV_FILETYPE SearchType,
|
||||
IN EFI_PEI_FV_HANDLE VolumeHandle,
|
||||
IN OUT EFI_PEI_FILE_HANDLE *FileHandle
|
||||
)
|
||||
{
|
||||
return SecFfsFindNextFile (SearchType, VolumeHandle, FileHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
This service enables PEIMs to discover sections of a given type within a valid FFS file.
|
||||
|
||||
@param SectionType The value of the section type to find.
|
||||
@param FileHandle A pointer to the file header that contains the set
|
||||
of sections to be searched.
|
||||
@param SectionData A pointer to the discovered section, if successful.
|
||||
|
||||
@retval EFI_SUCCESS The section was found.
|
||||
@retval EFI_NOT_FOUND The section was not found.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesFfsFindSectionData (
|
||||
IN EFI_SECTION_TYPE SectionType,
|
||||
IN EFI_PEI_FILE_HANDLE FileHandle,
|
||||
OUT VOID **SectionData
|
||||
)
|
||||
{
|
||||
return SecFfsFindSectionData (SectionType, FileHandle, SectionData);
|
||||
}
|
||||
|
||||
/**
|
||||
This service enables PEIMs to register the permanent memory configuration
|
||||
that has been initialized with the PEI Foundation.
|
||||
|
||||
@param MemoryBegin The value of a region of installed memory.
|
||||
@param MemoryLength The corresponding length of a region of installed memory.
|
||||
|
||||
@retval EFI_SUCCESS The region was successfully installed in a HOB.
|
||||
@retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system.
|
||||
@retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesInstallPeiMemory (
|
||||
IN EFI_PHYSICAL_ADDRESS MemoryBegin,
|
||||
IN UINT64 MemoryLength
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
/**
|
||||
This service enables PEIMs to allocate memory after the permanent memory has been
|
||||
installed by a PEIM.
|
||||
|
||||
@param MemoryType Type of memory to allocate.
|
||||
@param Pages The number of pages to allocate.
|
||||
@param Memory Pointer of memory allocated.
|
||||
|
||||
@retval EFI_SUCCESS The memory range was successfully allocated.
|
||||
@retval EFI_INVALID_PARAMETER Type is not equal to AllocateAnyPages.
|
||||
@retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available.
|
||||
@retval EFI_OUT_OF_RESOURCES The pages could not be allocated.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesAllocatePages (
|
||||
IN EFI_MEMORY_TYPE MemoryType,
|
||||
IN UINTN Pages,
|
||||
OUT EFI_PHYSICAL_ADDRESS *Memory
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
/**
|
||||
This service allocates memory from the Hand-Off Block (HOB) heap.
|
||||
|
||||
@param Size The number of bytes to allocate from the pool.
|
||||
@param Buffer If the call succeeds, a pointer to a pointer to
|
||||
the allocate buffer; otherwise, undefined.
|
||||
|
||||
@retval EFI_SUCCESS The allocation was successful
|
||||
@retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesAllocatePool (
|
||||
IN UINTN Size,
|
||||
OUT VOID **Buffer
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
/**
|
||||
Resets the entire platform.
|
||||
|
||||
@retval EFI_SUCCESS The function completed successfully.
|
||||
@retval EFI_NOT_AVAILABLE_YET The service has not been installed yet.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesResetSystem (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
/**
|
||||
This service is a wrapper for the PEI Service RegisterForShadow(), except the
|
||||
pointer to the PEI Services Table has been removed. See the Platform
|
||||
Initialization Pre-EFI Initialization Core Interface Specification for details.
|
||||
|
||||
@param FileHandle PEIM's file handle. Must be the currently
|
||||
executing PEIM.
|
||||
|
||||
@retval EFI_SUCCESS The PEIM was successfully registered for
|
||||
shadowing.
|
||||
|
||||
@retval EFI_ALREADY_STARTED The PEIM was previously
|
||||
registered for shadowing.
|
||||
|
||||
@retval EFI_NOT_FOUND The FileHandle does not refer to a
|
||||
valid file handle.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesRegisterForShadow (
|
||||
IN EFI_PEI_FILE_HANDLE FileHandle
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
/**
|
||||
This service is a wrapper for the PEI Service FfsGetFileInfo(), except the pointer to the PEI Services
|
||||
Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
|
||||
Specification for details.
|
||||
|
||||
@param FileHandle The handle of the file.
|
||||
|
||||
@param FileInfo Upon exit, points to the file's
|
||||
information.
|
||||
|
||||
@retval EFI_SUCCESS File information returned.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER If FileHandle does not
|
||||
represent a valid file.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER FileInfo is NULL.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesFfsGetFileInfo (
|
||||
IN CONST EFI_PEI_FILE_HANDLE FileHandle,
|
||||
OUT EFI_FV_FILE_INFO *FileInfo
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This service is a wrapper for the PEI Service FfsFindByName(), except the pointer to the PEI Services
|
||||
Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
|
||||
Specification for details.
|
||||
|
||||
@param FileName A pointer to the name of the file to
|
||||
find within the firmware volume.
|
||||
|
||||
@param VolumeHandle The firmware volume to search FileHandle
|
||||
Upon exit, points to the found file's
|
||||
handle or NULL if it could not be found.
|
||||
@param FileHandle The pointer to found file handle
|
||||
|
||||
@retval EFI_SUCCESS File was found.
|
||||
|
||||
@retval EFI_NOT_FOUND File was not found.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER VolumeHandle or FileHandle or
|
||||
FileName was NULL.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesFfsFindFileByName (
|
||||
IN CONST EFI_GUID *FileName,
|
||||
IN CONST EFI_PEI_FV_HANDLE VolumeHandle,
|
||||
OUT EFI_PEI_FILE_HANDLE *FileHandle
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This service is a wrapper for the PEI Service FfsGetVolumeInfo(), except the pointer to the PEI Services
|
||||
Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
|
||||
Specification for details.
|
||||
|
||||
@param VolumeHandle Handle of the volume.
|
||||
|
||||
@param VolumeInfo Upon exit, points to the volume's
|
||||
information.
|
||||
|
||||
@retval EFI_SUCCESS File information returned.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER If FileHandle does not
|
||||
represent a valid file.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER If FileInfo is NULL.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesFfsGetVolumeInfo (
|
||||
IN EFI_PEI_FV_HANDLE VolumeHandle,
|
||||
OUT EFI_FV_INFO *VolumeInfo
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
/**
|
||||
Install a EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance so the PEI Core will be notified about a new firmware volume.
|
||||
|
||||
This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO_PPI using
|
||||
the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance.
|
||||
If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO_PPI, then ASSERT().
|
||||
If the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI can not be installed, then ASSERT().
|
||||
|
||||
|
||||
@param FvFormat Unique identifier of the format of the memory-mapped
|
||||
firmware volume. This parameter is optional and
|
||||
may be NULL. If NULL is specified, the
|
||||
EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.
|
||||
@param FvInfo Points to a buffer which allows the
|
||||
EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.
|
||||
The format of this buffer is specific to the FvFormat.
|
||||
For memory-mapped firmware volumes, this typically
|
||||
points to the first byte of the firmware volume.
|
||||
@param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped
|
||||
firmware volumes, this is typically the size of
|
||||
the firmware volume.
|
||||
@param ParentFvName If the new firmware volume originated from a file
|
||||
in a different firmware volume, then this parameter
|
||||
specifies the GUID name of the originating firmware
|
||||
volume. Otherwise, this parameter must be NULL.
|
||||
@param ParentFileName If the new firmware volume originated from a file
|
||||
in a different firmware volume, then this parameter
|
||||
specifies the GUID file name of the originating
|
||||
firmware file. Otherwise, this parameter must be NULL.
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
PeiServicesInstallFvInfoPpi (
|
||||
IN CONST EFI_GUID *FvFormat, OPTIONAL
|
||||
IN CONST VOID *FvInfo,
|
||||
IN UINT32 FvInfoSize,
|
||||
IN CONST EFI_GUID *ParentFvName, OPTIONAL
|
||||
IN CONST EFI_GUID *ParentFileName OPTIONAL
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
return;
|
||||
}
|
||||
|
49
EmulatorPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf
Normal file
49
EmulatorPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf
Normal file
@@ -0,0 +1,49 @@
|
||||
## @file
|
||||
# PEI Services Library implementation.
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php.
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
#
|
||||
##
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = SecPeiServicesLib
|
||||
FILE_GUID = E3E4A441-8465-0F41-8AF4-F67EBE984099
|
||||
MODULE_TYPE = PEIM
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = PeiServicesLib|SEC PEIM PEI_CORE
|
||||
PI_SPECIFICATION_VERSION = 0x0001000A
|
||||
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC (EBC is for build only)
|
||||
#
|
||||
|
||||
[Sources]
|
||||
PeiServicesLib.c
|
||||
FwVol.c
|
||||
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
EmulatorPkg/EmulatorPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
DebugLib
|
||||
BaseMemoryLib
|
||||
PpiListLib
|
||||
|
||||
[Pcd]
|
||||
gEmulatorPkgTokenSpaceGuid.PcdPeiServicesTablePage
|
||||
|
||||
|
||||
|
||||
|
||||
|
17
EmulatorPkg/Library/SecPpiListLib/PpiListLib.c
Normal file
17
EmulatorPkg/Library/SecPpiListLib/PpiListLib.c
Normal file
@@ -0,0 +1,17 @@
|
||||
/*++ @file
|
||||
|
||||
Copyright (c) 2011, Apple Inc. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include <PiPei.h>
|
||||
|
||||
CONST EFI_PEI_PPI_DESCRIPTOR *gPpiList = NULL;
|
||||
|
31
EmulatorPkg/Library/SecPpiListLib/SecPpiListLib.inf
Normal file
31
EmulatorPkg/Library/SecPpiListLib/SecPpiListLib.inf
Normal file
@@ -0,0 +1,31 @@
|
||||
## @file
|
||||
# Place thunk PPI in HOB.
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
# Portions copyright (c) 2011, Apple Inc. 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 = SecPpiListLib
|
||||
FILE_GUID = F950E820-0457-8143-86AD-30E4A45FD4BF
|
||||
MODULE_TYPE = BASE
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = PpiListLib|SEC BASE USER_DEFINED
|
||||
|
||||
[Sources]
|
||||
PpiListLib.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
EmulatorPkg/EmulatorPkg.dec
|
||||
|
76
EmulatorPkg/Library/ThunkPpiList/ThunkPpiList.c
Normal file
76
EmulatorPkg/Library/ThunkPpiList/ThunkPpiList.c
Normal file
@@ -0,0 +1,76 @@
|
||||
/** @file
|
||||
Emulator Thunk to abstract OS services from pure EFI code
|
||||
|
||||
Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
|
||||
Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include <PiPei.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
|
||||
|
||||
UINTN gThunkPpiListSize = 0;
|
||||
EFI_PEI_PPI_DESCRIPTOR *gThunkPpiList = NULL;
|
||||
|
||||
|
||||
|
||||
EFI_PEI_PPI_DESCRIPTOR *
|
||||
GetThunkPpiList (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
|
||||
if (gThunkPpiList == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Index = (gThunkPpiListSize/sizeof (EFI_PEI_PPI_DESCRIPTOR)) - 1;
|
||||
gThunkPpiList[Index].Flags |= EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
|
||||
|
||||
return gThunkPpiList;
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
AddThunkPpi (
|
||||
IN UINTN Flags,
|
||||
IN EFI_GUID *Guid,
|
||||
IN VOID *Ppi
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
|
||||
gThunkPpiList = ReallocatePool (
|
||||
gThunkPpiListSize,
|
||||
gThunkPpiListSize + sizeof (EFI_PEI_PPI_DESCRIPTOR),
|
||||
gThunkPpiList
|
||||
);
|
||||
if (gThunkPpiList == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Index = (gThunkPpiListSize/sizeof (EFI_PEI_PPI_DESCRIPTOR));
|
||||
gThunkPpiList[Index].Flags = Flags;
|
||||
gThunkPpiList[Index].Guid = Guid;
|
||||
gThunkPpiList[Index].Ppi = Ppi;
|
||||
gThunkPpiListSize += sizeof (EFI_PEI_PPI_DESCRIPTOR);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
38
EmulatorPkg/Library/ThunkPpiList/ThunkPpiList.inf
Normal file
38
EmulatorPkg/Library/ThunkPpiList/ThunkPpiList.inf
Normal file
@@ -0,0 +1,38 @@
|
||||
## @file
|
||||
# Place thunk PPI in HOB.
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
# Portions copyright (c) 2011, Apple Inc. 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 = ThunkPpiList
|
||||
FILE_GUID = 465FDE84-E8B0-B04B-A843-A03F68F617A9
|
||||
MODULE_TYPE = BASE
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = MemoryAllocationLib|SEC BASE USER_DEFINED
|
||||
|
||||
[Sources]
|
||||
ThunkPpiList.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
EmulatorPkg/EmulatorPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
BaseLib
|
||||
BaseMemoryLib
|
||||
|
||||
[BuildOptions]
|
||||
XCODE:*_*_*_DLINK_PATH == gcc
|
||||
|
138
EmulatorPkg/Library/ThunkProtocolList/ThunkProtocolList.c
Normal file
138
EmulatorPkg/Library/ThunkProtocolList/ThunkProtocolList.c
Normal file
@@ -0,0 +1,138 @@
|
||||
/** @file
|
||||
Emulator Thunk to abstract OS services from pure EFI code
|
||||
|
||||
Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
|
||||
Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include <Uefi.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
|
||||
#include <Protocol/EmuIoThunk.h>
|
||||
|
||||
|
||||
#define EMU_IO_THUNK_PROTOCOL_DATA_SIGNATURE SIGNATURE_32('E','m','u','T')
|
||||
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
EMU_IO_THUNK_PROTOCOL Data;
|
||||
BOOLEAN EmuBusDriver;
|
||||
LIST_ENTRY Link;
|
||||
} EMU_IO_THUNK_PROTOCOL_DATA;
|
||||
|
||||
LIST_ENTRY mThunkList = INITIALIZE_LIST_HEAD_VARIABLE (mThunkList);
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
AddThunkProtocol (
|
||||
IN EMU_IO_THUNK_PROTOCOL *ThunkIo,
|
||||
IN CHAR16 *ConfigString,
|
||||
IN BOOLEAN EmuBusDriver
|
||||
)
|
||||
{
|
||||
CHAR16 *StartString;
|
||||
CHAR16 *SubString;
|
||||
UINTN Instance;
|
||||
EMU_IO_THUNK_PROTOCOL_DATA *Private;
|
||||
|
||||
if (ThunkIo == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Instance = 0;
|
||||
StartString = AllocatePool (StrSize (ConfigString));
|
||||
StrCpy (StartString, ConfigString);
|
||||
while (*StartString != '\0') {
|
||||
|
||||
//
|
||||
// Find the end of the sub string
|
||||
//
|
||||
SubString = StartString;
|
||||
while (*SubString != '\0' && *SubString != '!') {
|
||||
SubString++;
|
||||
}
|
||||
|
||||
if (*SubString == '!') {
|
||||
//
|
||||
// Replace token with '\0' to make sub strings. If this is the end
|
||||
// of the string SubString will already point to NULL.
|
||||
//
|
||||
*SubString = '\0';
|
||||
SubString++;
|
||||
}
|
||||
|
||||
Private = AllocatePool (sizeof (EMU_IO_THUNK_PROTOCOL_DATA));
|
||||
if (Private == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
Private->Signature = EMU_IO_THUNK_PROTOCOL_DATA_SIGNATURE;
|
||||
Private->EmuBusDriver = EmuBusDriver;
|
||||
|
||||
CopyMem (&Private->Data, ThunkIo, sizeof (EMU_IO_THUNK_PROTOCOL));
|
||||
Private->Data.Instance = Instance++;
|
||||
Private->Data.ConfigString = StartString;
|
||||
|
||||
InsertTailList (&mThunkList, &Private->Link);
|
||||
|
||||
//
|
||||
// Parse Next sub string. This will point to '\0' if we are at the end.
|
||||
//
|
||||
StartString = SubString;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
GetNextThunkProtocol (
|
||||
IN BOOLEAN EmuBusDriver,
|
||||
OUT EMU_IO_THUNK_PROTOCOL **Instance OPTIONAL
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Link;
|
||||
EMU_IO_THUNK_PROTOCOL_DATA *Private;
|
||||
|
||||
if (mThunkList.ForwardLink == &mThunkList) {
|
||||
// Skip parsing an empty list
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
for (Link = mThunkList.ForwardLink; Link != &mThunkList; Link = Link->ForwardLink) {
|
||||
Private = CR (Link, EMU_IO_THUNK_PROTOCOL_DATA, Link, EMU_IO_THUNK_PROTOCOL_DATA_SIGNATURE);
|
||||
if (EmuBusDriver & !Private->EmuBusDriver) {
|
||||
continue;
|
||||
} else if (*Instance == NULL) {
|
||||
// Find 1st match in list
|
||||
*Instance = &Private->Data;
|
||||
return EFI_SUCCESS;
|
||||
} else if (*Instance == &Private->Data) {
|
||||
// Matched previous call so look for valid next entry
|
||||
Link = Link->ForwardLink;
|
||||
if (Link == &mThunkList) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
Private = CR (Link, EMU_IO_THUNK_PROTOCOL_DATA, Link, EMU_IO_THUNK_PROTOCOL_DATA_SIGNATURE);
|
||||
*Instance = &Private->Data;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
36
EmulatorPkg/Library/ThunkProtocolList/ThunkProtocolList.inf
Normal file
36
EmulatorPkg/Library/ThunkProtocolList/ThunkProtocolList.inf
Normal file
@@ -0,0 +1,36 @@
|
||||
## @file
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
# Portions copyright (c) 2011, Apple Inc. 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 = ThunkProtocolList
|
||||
FILE_GUID = 7833616E-AE0D-594F-870C-80E68682D587
|
||||
MODULE_TYPE = BASE
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = MemoryAllocationLib|BASE SEC USER_DEFINED
|
||||
|
||||
[Sources]
|
||||
ThunkProtocolList.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
EmulatorPkg/EmulatorPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
BaseLib
|
||||
BaseMemoryLib
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user