EmulatorPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the EmulatorPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
This commit is contained in:
committed by
mergify[bot]
parent
e7108d0e96
commit
a550d468a6
@@ -19,7 +19,6 @@
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
|
||||
|
||||
/**
|
||||
Converts a Vendor device path structure to its string representative.
|
||||
|
||||
@@ -52,18 +51,22 @@ DevPathToTextVendorLib (
|
||||
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;
|
||||
@@ -82,20 +85,20 @@ DevPathToTextVendorLib (
|
||||
**/
|
||||
EFI_DEVICE_PATH_PROTOCOL *
|
||||
DevPathFromTextEmuThunk (
|
||||
IN CHAR16 *TextDeviceNode
|
||||
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)
|
||||
);
|
||||
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;
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Vendor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,20 +111,20 @@ DevPathFromTextEmuThunk (
|
||||
**/
|
||||
EFI_DEVICE_PATH_PROTOCOL *
|
||||
DevPathFromTextEmuThread (
|
||||
IN CHAR16 *TextDeviceNode
|
||||
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)
|
||||
);
|
||||
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;
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Vendor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,22 +137,22 @@ DevPathFromTextEmuThread (
|
||||
**/
|
||||
EFI_DEVICE_PATH_PROTOCOL *
|
||||
DevPathFromTextEmuFs (
|
||||
IN CHAR16 *TextDeviceNode
|
||||
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)
|
||||
);
|
||||
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);
|
||||
Vendor->Instance = (UINT32)StrDecimalToUintn (Str);
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)Vendor;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -16,8 +16,6 @@
|
||||
|
||||
#include <Protocol/Timer.h>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Stalls the CPU for at least the given number of microseconds.
|
||||
|
||||
@@ -31,13 +29,12 @@
|
||||
UINTN
|
||||
EFIAPI
|
||||
MicroSecondDelay (
|
||||
IN UINTN MicroSeconds
|
||||
IN UINTN MicroSeconds
|
||||
)
|
||||
{
|
||||
return NanoSecondDelay (MicroSeconds * 1000);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Stalls the CPU for at least the given number of nanoseconds.
|
||||
|
||||
@@ -51,14 +48,13 @@ MicroSecondDelay (
|
||||
UINTN
|
||||
EFIAPI
|
||||
NanoSecondDelay (
|
||||
IN UINTN NanoSeconds
|
||||
IN UINTN NanoSeconds
|
||||
)
|
||||
{
|
||||
gEmuThunk->Sleep (NanoSeconds);
|
||||
return NanoSeconds;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Retrieves the current value of a 64-bit free running performance counter.
|
||||
|
||||
@@ -105,14 +101,14 @@ GetPerformanceCounter (
|
||||
UINT64
|
||||
EFIAPI
|
||||
GetPerformanceCounterProperties (
|
||||
OUT UINT64 *StartValue OPTIONAL,
|
||||
OUT UINT64 *EndValue OPTIONAL
|
||||
OUT UINT64 *StartValue OPTIONAL,
|
||||
OUT UINT64 *EndValue OPTIONAL
|
||||
)
|
||||
{
|
||||
|
||||
if (StartValue != NULL) {
|
||||
*StartValue = 0ULL;
|
||||
}
|
||||
|
||||
if (EndValue != NULL) {
|
||||
*EndValue = (UINT64)-1LL;
|
||||
}
|
||||
@@ -156,9 +152,9 @@ GetTimeInNanoSecond (
|
||||
// Since 2^29 < 1,000,000,000 = 0x3B9ACA00 < 2^30, Remainder should < 2^(64-30) = 2^34,
|
||||
// i.e. highest bit set in Remainder should <= 33.
|
||||
//
|
||||
Shift = MAX (0, HighBitSet64 (Remainder) - 33);
|
||||
Remainder = RShiftU64 (Remainder, (UINTN) Shift);
|
||||
Frequency = RShiftU64 (Frequency, (UINTN) Shift);
|
||||
Shift = MAX (0, HighBitSet64 (Remainder) - 33);
|
||||
Remainder = RShiftU64 (Remainder, (UINTN)Shift);
|
||||
Frequency = RShiftU64 (Frequency, (UINTN)Shift);
|
||||
NanoSeconds += DivU64x64Remainder (MultU64x32 (Remainder, 1000000000u), Frequency, NULL);
|
||||
|
||||
return NanoSeconds;
|
||||
|
@@ -13,8 +13,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#include <Library/EmuThunkLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
|
||||
EMU_THUNK_PROTOCOL *gEmuThunk = NULL;
|
||||
|
||||
EMU_THUNK_PROTOCOL *gEmuThunk = NULL;
|
||||
|
||||
/**
|
||||
The constructor function caches the pointer of EMU Thunk protocol.
|
||||
@@ -32,7 +31,7 @@ DxeEmuLibConstructor (
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_HOB_GUID_TYPE *GuidHob;
|
||||
EFI_HOB_GUID_TYPE *GuidHob;
|
||||
|
||||
GuidHob = GetFirstGuidHob (&gEmuThunkProtocolGuid);
|
||||
ASSERT (GuidHob != NULL);
|
||||
@@ -43,7 +42,6 @@ DxeEmuLibConstructor (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Serach the EMU IO Thunk database for a matching EMU IO Thunk
|
||||
Protocol instance.
|
||||
@@ -62,8 +60,8 @@ GetIoThunkInstance (
|
||||
IN UINTN Instance
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EMU_IO_THUNK_PROTOCOL *EmuIoThunk;
|
||||
EFI_STATUS Status;
|
||||
EMU_IO_THUNK_PROTOCOL *EmuIoThunk;
|
||||
|
||||
for (Status = EFI_SUCCESS, EmuIoThunk = NULL; !EFI_ERROR (Status); ) {
|
||||
Status = gEmuThunk->GetNextProtocol (FALSE, &EmuIoThunk);
|
||||
|
@@ -23,8 +23,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
// Cache of UnixThunk protocol
|
||||
//
|
||||
EMU_THUNK_PROTOCOL *mThunk = NULL;
|
||||
|
||||
EMU_THUNK_PROTOCOL *mThunk = NULL;
|
||||
|
||||
/**
|
||||
The constructor function gets the pointer of the WinNT thunk functions
|
||||
@@ -40,7 +39,7 @@ DxeEmuPeCoffLibExtraActionConstructor (
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_HOB_GUID_TYPE *GuidHob;
|
||||
EFI_HOB_GUID_TYPE *GuidHob;
|
||||
|
||||
//
|
||||
// Retrieve EmuThunkProtocol from GUID'ed HOB
|
||||
@@ -73,8 +72,6 @@ PeCoffLoaderRelocateImageExtraAction (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Performs additional actions just before a PE/COFF image is unloaded. Any resources
|
||||
that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.
|
||||
|
@@ -8,14 +8,10 @@
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include <PiDxe.h>
|
||||
#include <Library/SerialPortLib.h>
|
||||
#include <Library/EmuThunkLib.h>
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Initialize the serial device hardware.
|
||||
|
||||
@@ -56,14 +52,13 @@ SerialPortInitialize (
|
||||
UINTN
|
||||
EFIAPI
|
||||
SerialPortWrite (
|
||||
IN UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
IN UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
)
|
||||
{
|
||||
return gEmuThunk->WriteStdOut (Buffer, NumberOfBytes);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Read data from serial device and save the datas in buffer.
|
||||
|
||||
@@ -83,8 +78,8 @@ SerialPortWrite (
|
||||
UINTN
|
||||
EFIAPI
|
||||
SerialPortRead (
|
||||
OUT UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
OUT UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
)
|
||||
{
|
||||
return gEmuThunk->ReadStdIn (Buffer, NumberOfBytes);
|
||||
@@ -123,7 +118,7 @@ SerialPortPoll (
|
||||
RETURN_STATUS
|
||||
EFIAPI
|
||||
SerialPortSetControl (
|
||||
IN UINT32 Control
|
||||
IN UINT32 Control
|
||||
)
|
||||
{
|
||||
return RETURN_UNSUPPORTED;
|
||||
@@ -142,13 +137,14 @@ SerialPortSetControl (
|
||||
RETURN_STATUS
|
||||
EFIAPI
|
||||
SerialPortGetControl (
|
||||
OUT UINT32 *Control
|
||||
OUT UINT32 *Control
|
||||
)
|
||||
{
|
||||
*Control = 0;
|
||||
if (!SerialPortPoll ()) {
|
||||
*Control = EFI_SERIAL_INPUT_BUFFER_EMPTY;
|
||||
}
|
||||
|
||||
return RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -188,14 +184,13 @@ SerialPortGetControl (
|
||||
RETURN_STATUS
|
||||
EFIAPI
|
||||
SerialPortSetAttributes (
|
||||
IN OUT UINT64 *BaudRate,
|
||||
IN OUT UINT32 *ReceiveFifoDepth,
|
||||
IN OUT UINT32 *Timeout,
|
||||
IN OUT EFI_PARITY_TYPE *Parity,
|
||||
IN OUT UINT8 *DataBits,
|
||||
IN OUT EFI_STOP_BITS_TYPE *StopBits
|
||||
IN OUT UINT64 *BaudRate,
|
||||
IN OUT UINT32 *ReceiveFifoDepth,
|
||||
IN OUT UINT32 *Timeout,
|
||||
IN OUT EFI_PARITY_TYPE *Parity,
|
||||
IN OUT UINT8 *DataBits,
|
||||
IN OUT EFI_STOP_BITS_TYPE *StopBits
|
||||
)
|
||||
{
|
||||
return RETURN_UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
@@ -8,14 +8,10 @@
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include <PiDxe.h>
|
||||
#include <Library/SerialPortLib.h>
|
||||
#include <Library/EmuThunkLib.h>
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Initialize the serial device hardware.
|
||||
|
||||
@@ -56,8 +52,8 @@ SerialPortInitialize (
|
||||
UINTN
|
||||
EFIAPI
|
||||
SerialPortWrite (
|
||||
IN UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
IN UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
)
|
||||
{
|
||||
if (gEmuThunk == NULL) {
|
||||
@@ -67,7 +63,6 @@ SerialPortWrite (
|
||||
return gEmuThunk->WriteStdErr (Buffer, NumberOfBytes);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Read data from serial device and save the datas in buffer.
|
||||
|
||||
@@ -87,8 +82,8 @@ SerialPortWrite (
|
||||
UINTN
|
||||
EFIAPI
|
||||
SerialPortRead (
|
||||
OUT UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
OUT UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
@@ -113,5 +108,3 @@ SerialPortPoll (
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -16,17 +16,16 @@
|
||||
|
||||
#include <Protocol/Timer.h>
|
||||
|
||||
|
||||
STATIC UINT64 gTimerPeriod = 0;
|
||||
STATIC EFI_TIMER_ARCH_PROTOCOL *gTimerAp = NULL;
|
||||
STATIC EFI_EVENT gTimerEvent = NULL;
|
||||
STATIC VOID *gRegistration = NULL;
|
||||
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
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
@@ -46,8 +45,6 @@ RegisterTimerArchProtocol (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Stalls the CPU for at least the given number of microseconds.
|
||||
|
||||
@@ -61,13 +58,12 @@ RegisterTimerArchProtocol (
|
||||
UINTN
|
||||
EFIAPI
|
||||
MicroSecondDelay (
|
||||
IN UINTN MicroSeconds
|
||||
IN UINTN MicroSeconds
|
||||
)
|
||||
{
|
||||
return NanoSecondDelay (MicroSeconds * 1000);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Stalls the CPU for at least the given number of nanoseconds.
|
||||
|
||||
@@ -81,7 +77,7 @@ MicroSecondDelay (
|
||||
UINTN
|
||||
EFIAPI
|
||||
NanoSecondDelay (
|
||||
IN UINTN NanoSeconds
|
||||
IN UINTN NanoSeconds
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
@@ -90,25 +86,25 @@ NanoSecondDelay (
|
||||
|
||||
if ((gTimerPeriod != 0) &&
|
||||
((UINT64)NanoSeconds > gTimerPeriod) &&
|
||||
(EfiGetCurrentTpl () == TPL_APPLICATION)) {
|
||||
(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);
|
||||
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.
|
||||
|
||||
@@ -155,14 +151,14 @@ GetPerformanceCounter (
|
||||
UINT64
|
||||
EFIAPI
|
||||
GetPerformanceCounterProperties (
|
||||
OUT UINT64 *StartValue OPTIONAL,
|
||||
OUT UINT64 *EndValue OPTIONAL
|
||||
OUT UINT64 *StartValue OPTIONAL,
|
||||
OUT UINT64 *EndValue OPTIONAL
|
||||
)
|
||||
{
|
||||
|
||||
if (StartValue != NULL) {
|
||||
*StartValue = 0ULL;
|
||||
}
|
||||
|
||||
if (EndValue != NULL) {
|
||||
*EndValue = (UINT64)-1LL;
|
||||
}
|
||||
@@ -170,7 +166,6 @@ GetPerformanceCounterProperties (
|
||||
return gEmuThunk->QueryPerformanceFrequency ();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Register for the Timer AP protocol.
|
||||
|
||||
@@ -234,9 +229,9 @@ GetTimeInNanoSecond (
|
||||
// Since 2^29 < 1,000,000,000 = 0x3B9ACA00 < 2^30, Remainder should < 2^(64-30) = 2^34,
|
||||
// i.e. highest bit set in Remainder should <= 33.
|
||||
//
|
||||
Shift = MAX (0, HighBitSet64 (Remainder) - 33);
|
||||
Remainder = RShiftU64 (Remainder, (UINTN) Shift);
|
||||
Frequency = RShiftU64 (Frequency, (UINTN) Shift);
|
||||
Shift = MAX (0, HighBitSet64 (Remainder) - 33);
|
||||
Remainder = RShiftU64 (Remainder, (UINTN)Shift);
|
||||
Frequency = RShiftU64 (Frequency, (UINTN)Shift);
|
||||
NanoSeconds += DivU64x64Remainder (MultU64x32 (Remainder, 1000000000u), Frequency, NULL);
|
||||
|
||||
return NanoSeconds;
|
||||
|
@@ -15,10 +15,8 @@
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include <Uefi.h>
|
||||
|
||||
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
@@ -144,14 +142,14 @@ FreePages (
|
||||
IN UINTN Pages
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
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);
|
||||
Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
}
|
||||
@@ -180,12 +178,12 @@ InternalAllocateAlignedPages (
|
||||
IN UINTN Alignment
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
VOID *Memory;
|
||||
UINTN AlignedMemory;
|
||||
UINTN AlignmentMask;
|
||||
UINTN UnalignedPages;
|
||||
UINTN RealPages;
|
||||
EFI_STATUS Status;
|
||||
VOID *Memory;
|
||||
UINTN AlignedMemory;
|
||||
UINTN AlignmentMask;
|
||||
UINTN UnalignedPages;
|
||||
UINTN RealPages;
|
||||
|
||||
//
|
||||
// Alignment must be a power of two or zero.
|
||||
@@ -195,12 +193,13 @@ InternalAllocateAlignedPages (
|
||||
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);
|
||||
AlignmentMask = Alignment - 1;
|
||||
RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment);
|
||||
//
|
||||
// Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.
|
||||
//
|
||||
@@ -210,15 +209,17 @@ InternalAllocateAlignedPages (
|
||||
if (Memory != NULL) {
|
||||
return NULL;
|
||||
}
|
||||
AlignedMemory = ((UINTN) Memory + AlignmentMask) & ~AlignmentMask;
|
||||
UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN) Memory);
|
||||
|
||||
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));
|
||||
|
||||
Memory = (VOID *)(AlignedMemory + EFI_PAGES_TO_SIZE (Pages));
|
||||
UnalignedPages = RealPages - Pages - UnalignedPages;
|
||||
if (UnalignedPages > 0) {
|
||||
//
|
||||
@@ -234,9 +235,11 @@ InternalAllocateAlignedPages (
|
||||
if (Memory != NULL) {
|
||||
return NULL;
|
||||
}
|
||||
AlignedMemory = (UINTN) Memory;
|
||||
|
||||
AlignedMemory = (UINTN)Memory;
|
||||
}
|
||||
return (VOID *) AlignedMemory;
|
||||
|
||||
return (VOID *)AlignedMemory;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -458,6 +461,7 @@ InternalAllocateZeroPool (
|
||||
if (Memory != NULL) {
|
||||
Memory = ZeroMem (Memory, AllocationSize);
|
||||
}
|
||||
|
||||
return Memory;
|
||||
}
|
||||
|
||||
@@ -554,12 +558,13 @@ InternalAllocateCopyPool (
|
||||
VOID *Memory;
|
||||
|
||||
ASSERT (Buffer != NULL);
|
||||
ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));
|
||||
ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN)Buffer + 1));
|
||||
|
||||
Memory = InternalAllocatePool (PoolType, AllocationSize);
|
||||
if (Memory != NULL) {
|
||||
Memory = CopyMem (Memory, Buffer, AllocationSize);
|
||||
Memory = CopyMem (Memory, Buffer, AllocationSize);
|
||||
}
|
||||
|
||||
return Memory;
|
||||
}
|
||||
|
||||
@@ -677,10 +682,11 @@ InternalReallocatePool (
|
||||
VOID *NewBuffer;
|
||||
|
||||
NewBuffer = InternalAllocateZeroPool (PoolType, NewSize);
|
||||
if (NewBuffer != NULL && OldBuffer != NULL) {
|
||||
if ((NewBuffer != NULL) && (OldBuffer != NULL)) {
|
||||
CopyMem (NewBuffer, OldBuffer, MIN (OldSize, NewSize));
|
||||
FreePool (OldBuffer);
|
||||
}
|
||||
|
||||
return NewBuffer;
|
||||
}
|
||||
|
||||
@@ -797,10 +803,10 @@ ReallocateReservedPool (
|
||||
VOID
|
||||
EFIAPI
|
||||
FreePool (
|
||||
IN VOID *Buffer
|
||||
IN VOID *Buffer
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (!gEmuThunk->Free (Buffer)) {
|
||||
// The Free thunk will not free memory allocated in emulated EFI memory.
|
||||
@@ -810,4 +816,3 @@ FreePool (
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#include <Uefi.h>
|
||||
#include <Protocol/SimpleTextInEx.h>
|
||||
|
||||
|
||||
/**
|
||||
KeyMapMake gets called on key presses.
|
||||
|
||||
@@ -20,7 +19,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
KeyMapMake (
|
||||
IN EFI_KEY_DATA *KeyData
|
||||
IN EFI_KEY_DATA *KeyData
|
||||
)
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
@@ -37,7 +36,7 @@ KeyMapMake (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
KeyMapBreak (
|
||||
IN EFI_KEY_DATA *KeyData
|
||||
IN EFI_KEY_DATA *KeyData
|
||||
)
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
|
@@ -29,7 +29,7 @@ CONST EFI_PEI_SERVICES **gPeiServices;
|
||||
VOID
|
||||
EFIAPI
|
||||
SetPeiServicesTablePointer (
|
||||
IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer
|
||||
IN CONST EFI_PEI_SERVICES **PeiServicesTablePointer
|
||||
)
|
||||
{
|
||||
ASSERT (PeiServicesTablePointer != NULL);
|
||||
@@ -58,7 +58,6 @@ GetPeiServicesTablePointer (
|
||||
return gPeiServices;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
The constructor function caches the pointer to PEI services.
|
||||
|
||||
@@ -74,8 +73,8 @@ GetPeiServicesTablePointer (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesTablePointerLibConstructor (
|
||||
IN EFI_PEI_FILE_HANDLE FileHandle,
|
||||
IN CONST EFI_PEI_SERVICES **PeiServices
|
||||
IN EFI_PEI_FILE_HANDLE FileHandle,
|
||||
IN CONST EFI_PEI_SERVICES **PeiServices
|
||||
)
|
||||
{
|
||||
gPeiServices = PeiServices;
|
||||
@@ -108,4 +107,3 @@ MigratePeiServicesTablePointer (
|
||||
//
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -22,7 +22,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
// Cache of UnixThunk protocol
|
||||
//
|
||||
EMU_THUNK_PROTOCOL *mThunk = NULL;
|
||||
EMU_THUNK_PROTOCOL *mThunk = NULL;
|
||||
|
||||
/**
|
||||
The function caches the pointer of the Unix thunk functions
|
||||
@@ -36,22 +36,21 @@ EFIAPI
|
||||
EmuPeCoffGetThunkStucture (
|
||||
)
|
||||
{
|
||||
EMU_THUNK_PPI *ThunkPpi;
|
||||
EFI_STATUS Status;
|
||||
|
||||
EMU_THUNK_PPI *ThunkPpi;
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Locate Unix ThunkPpi for retrieving standard output handle
|
||||
//
|
||||
Status = PeiServicesLocatePpi (
|
||||
&gEmuThunkPpiGuid,
|
||||
0,
|
||||
NULL,
|
||||
(VOID **) &ThunkPpi
|
||||
);
|
||||
&gEmuThunkPpiGuid,
|
||||
0,
|
||||
NULL,
|
||||
(VOID **)&ThunkPpi
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
EMU_MAGIC_PAGE()->Thunk = (EMU_THUNK_PROTOCOL *) ThunkPpi->Thunk ();
|
||||
EMU_MAGIC_PAGE ()->Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@@ -71,12 +70,12 @@ PeCoffLoaderRelocateImageExtraAction (
|
||||
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
|
||||
)
|
||||
{
|
||||
if (EMU_MAGIC_PAGE()->Thunk == NULL) {
|
||||
if (EMU_MAGIC_PAGE ()->Thunk == NULL) {
|
||||
EmuPeCoffGetThunkStucture ();
|
||||
}
|
||||
EMU_MAGIC_PAGE()->Thunk->PeCoffRelocateImageExtraAction (ImageContext);
|
||||
}
|
||||
|
||||
EMU_MAGIC_PAGE ()->Thunk->PeCoffRelocateImageExtraAction (ImageContext);
|
||||
}
|
||||
|
||||
/**
|
||||
Performs additional actions just before a PE/COFF image is unloaded. Any resources
|
||||
@@ -94,8 +93,9 @@ PeCoffLoaderUnloadImageExtraAction (
|
||||
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
|
||||
)
|
||||
{
|
||||
if (EMU_MAGIC_PAGE()->Thunk == NULL) {
|
||||
if (EMU_MAGIC_PAGE ()->Thunk == NULL) {
|
||||
EmuPeCoffGetThunkStucture ();
|
||||
}
|
||||
EMU_MAGIC_PAGE()->Thunk->PeCoffUnloadImageExtraAction (ImageContext);
|
||||
|
||||
EMU_MAGIC_PAGE ()->Thunk->PeCoffUnloadImageExtraAction (ImageContext);
|
||||
}
|
||||
|
@@ -15,8 +15,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#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.
|
||||
@@ -41,22 +39,22 @@ PeCoffLoaderGetEntryPoint (
|
||||
IN OUT VOID **EntryPoint
|
||||
)
|
||||
{
|
||||
EMU_THUNK_PPI *ThunkPpi;
|
||||
EFI_STATUS Status;
|
||||
EMU_THUNK_PROTOCOL *Thunk;
|
||||
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
|
||||
&gEmuThunkPpiGuid,
|
||||
0,
|
||||
NULL,
|
||||
(VOID **)&ThunkPpi
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
|
||||
Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
|
||||
|
||||
return Thunk->PeCoffGetEntryPoint (Pe32Data, EntryPoint);
|
||||
}
|
||||
@@ -86,15 +84,14 @@ PeCoffLoaderGetMachineType (
|
||||
|
||||
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));
|
||||
|
||||
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) {
|
||||
} else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
|
||||
return Hdr.Pe32->FileHeader.Machine;
|
||||
}
|
||||
|
||||
@@ -126,15 +123,15 @@ 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;
|
||||
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);
|
||||
|
||||
@@ -148,7 +145,7 @@ PeCoffLoaderGetPdbPointer (
|
||||
//
|
||||
// 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));
|
||||
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.
|
||||
@@ -158,11 +155,11 @@ PeCoffLoaderGetPdbPointer (
|
||||
|
||||
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);
|
||||
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) {
|
||||
//
|
||||
@@ -171,24 +168,24 @@ PeCoffLoaderGetPdbPointer (
|
||||
// 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;
|
||||
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) {
|
||||
@@ -196,42 +193,42 @@ PeCoffLoaderGetPdbPointer (
|
||||
// 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);
|
||||
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);
|
||||
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;
|
||||
DebugEntry = NULL;
|
||||
}
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (DebugEntry == NULL || DirectoryEntry == 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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -240,7 +237,6 @@ PeCoffLoaderGetPdbPointer (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Returns the size of the PE/COFF headers
|
||||
|
||||
@@ -256,12 +252,12 @@ PeCoffLoaderGetPdbPointer (
|
||||
UINT32
|
||||
EFIAPI
|
||||
PeCoffGetSizeOfHeaders (
|
||||
IN VOID *Pe32Data
|
||||
IN VOID *Pe32Data
|
||||
)
|
||||
{
|
||||
EFI_IMAGE_DOS_HEADER *DosHdr;
|
||||
EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
|
||||
UINTN SizeOfHeaders;
|
||||
EFI_IMAGE_DOS_HEADER *DosHdr;
|
||||
EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
|
||||
UINTN SizeOfHeaders;
|
||||
|
||||
ASSERT (Pe32Data != NULL);
|
||||
|
||||
@@ -270,7 +266,7 @@ PeCoffGetSizeOfHeaders (
|
||||
//
|
||||
// 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));
|
||||
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.
|
||||
@@ -286,6 +282,5 @@ PeCoffGetSizeOfHeaders (
|
||||
SizeOfHeaders = 0;
|
||||
}
|
||||
|
||||
return (UINT32) SizeOfHeaders;
|
||||
return (UINT32)SizeOfHeaders;
|
||||
}
|
||||
|
||||
|
@@ -9,7 +9,6 @@
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include <PiPei.h>
|
||||
#include <Library/SerialPortLib.h>
|
||||
#include <Library/PeiServicesLib.h>
|
||||
@@ -17,8 +16,6 @@
|
||||
#include <Ppi/EmuThunk.h>
|
||||
#include <Protocol/EmuThunk.h>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Initialize the serial device hardware.
|
||||
|
||||
@@ -59,32 +56,31 @@ SerialPortInitialize (
|
||||
UINTN
|
||||
EFIAPI
|
||||
SerialPortWrite (
|
||||
IN UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
IN UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
)
|
||||
{
|
||||
EMU_THUNK_PPI *ThunkPpi;
|
||||
EFI_STATUS Status;
|
||||
EMU_THUNK_PROTOCOL *Thunk;
|
||||
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
|
||||
&gEmuThunkPpiGuid,
|
||||
0,
|
||||
NULL,
|
||||
(VOID **)&ThunkPpi
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
|
||||
Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
|
||||
return Thunk->WriteStdErr (Buffer, NumberOfBytes);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Read data from serial device and save the datas in buffer.
|
||||
|
||||
@@ -104,8 +100,8 @@ SerialPortWrite (
|
||||
UINTN
|
||||
EFIAPI
|
||||
SerialPortRead (
|
||||
OUT UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
OUT UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
@@ -130,4 +126,3 @@ SerialPortPoll (
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@@ -16,7 +16,6 @@
|
||||
|
||||
#include <Ppi/MemoryDiscovered.h>
|
||||
|
||||
|
||||
CONST EFI_PEI_SERVICES **gPeiServices = NULL;
|
||||
|
||||
/**
|
||||
@@ -33,7 +32,7 @@ CONST EFI_PEI_SERVICES **gPeiServices = NULL;
|
||||
VOID
|
||||
EFIAPI
|
||||
SetPeiServicesTablePointer (
|
||||
IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer
|
||||
IN CONST EFI_PEI_SERVICES **PeiServicesTablePointer
|
||||
)
|
||||
{
|
||||
ASSERT (PeiServicesTablePointer != NULL);
|
||||
@@ -64,8 +63,6 @@ GetPeiServicesTablePointer (
|
||||
return gPeiServices;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Notification service to be called when gEmuThunkPpiGuid is installed.
|
||||
|
||||
@@ -81,9 +78,9 @@ GetPeiServicesTablePointer (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesTablePointerNotifyCallback (
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
|
||||
IN VOID *Ppi
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
|
||||
IN VOID *Ppi
|
||||
)
|
||||
{
|
||||
gPeiServices = (CONST EFI_PEI_SERVICES **)PeiServices;
|
||||
@@ -91,14 +88,12 @@ PeiServicesTablePointerNotifyCallback (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnThunkList = {
|
||||
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
|
||||
@@ -113,11 +108,11 @@ EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnThunkList = {
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesTablePointerLibConstructor (
|
||||
IN EFI_PEI_FILE_HANDLE FileHandle,
|
||||
IN CONST EFI_PEI_SERVICES **PeiServices
|
||||
IN EFI_PEI_FILE_HANDLE FileHandle,
|
||||
IN CONST EFI_PEI_SERVICES **PeiServices
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
gPeiServices = (CONST EFI_PEI_SERVICES **)PeiServices;
|
||||
|
||||
@@ -153,4 +148,3 @@ MigratePeiServicesTablePointer (
|
||||
//
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -16,7 +16,6 @@
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/EmuMagicPageLib.h>
|
||||
|
||||
|
||||
/**
|
||||
Caches a pointer PEI Services Table.
|
||||
|
||||
@@ -31,12 +30,12 @@
|
||||
VOID
|
||||
EFIAPI
|
||||
SetPeiServicesTablePointer (
|
||||
IN CONST EFI_PEI_SERVICES ** PeiServicesTablePointer
|
||||
IN CONST EFI_PEI_SERVICES **PeiServicesTablePointer
|
||||
)
|
||||
{
|
||||
ASSERT (PeiServicesTablePointer != NULL);
|
||||
ASSERT (*PeiServicesTablePointer != NULL);
|
||||
EMU_MAGIC_PAGE()->PeiServicesTablePointer = PeiServicesTablePointer;
|
||||
EMU_MAGIC_PAGE ()->PeiServicesTablePointer = PeiServicesTablePointer;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,9 +56,9 @@ GetPeiServicesTablePointer (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
CONST EFI_PEI_SERVICES **PeiServicesTablePointer;
|
||||
CONST EFI_PEI_SERVICES **PeiServicesTablePointer;
|
||||
|
||||
PeiServicesTablePointer = EMU_MAGIC_PAGE()->PeiServicesTablePointer;
|
||||
PeiServicesTablePointer = EMU_MAGIC_PAGE ()->PeiServicesTablePointer;
|
||||
ASSERT (PeiServicesTablePointer != NULL);
|
||||
ASSERT (*PeiServicesTablePointer != NULL);
|
||||
return PeiServicesTablePointer;
|
||||
@@ -91,5 +90,3 @@ MigratePeiServicesTablePointer (
|
||||
//
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -28,7 +28,7 @@
|
||||
UINTN
|
||||
EFIAPI
|
||||
MicroSecondDelay (
|
||||
IN UINTN MicroSeconds
|
||||
IN UINTN MicroSeconds
|
||||
)
|
||||
{
|
||||
return NanoSecondDelay (MicroSeconds * 1000);
|
||||
@@ -47,24 +47,24 @@ MicroSecondDelay (
|
||||
UINTN
|
||||
EFIAPI
|
||||
NanoSecondDelay (
|
||||
IN UINTN NanoSeconds
|
||||
IN UINTN NanoSeconds
|
||||
)
|
||||
{
|
||||
EMU_THUNK_PPI *ThunkPpi;
|
||||
EFI_STATUS Status;
|
||||
EMU_THUNK_PROTOCOL *Thunk;
|
||||
EMU_THUNK_PPI *ThunkPpi;
|
||||
EFI_STATUS Status;
|
||||
EMU_THUNK_PROTOCOL *Thunk;
|
||||
|
||||
//
|
||||
// Locate EmuThunkPpi for
|
||||
//
|
||||
Status = PeiServicesLocatePpi (
|
||||
&gEmuThunkPpiGuid,
|
||||
0,
|
||||
NULL,
|
||||
(VOID **) &ThunkPpi
|
||||
&gEmuThunkPpiGuid,
|
||||
0,
|
||||
NULL,
|
||||
(VOID **)&ThunkPpi
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
|
||||
Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
|
||||
Thunk->Sleep (NanoSeconds * 100);
|
||||
return NanoSeconds;
|
||||
}
|
||||
@@ -89,22 +89,22 @@ GetPerformanceCounter (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EMU_THUNK_PPI *ThunkPpi;
|
||||
EFI_STATUS Status;
|
||||
EMU_THUNK_PROTOCOL *Thunk;
|
||||
EMU_THUNK_PPI *ThunkPpi;
|
||||
EFI_STATUS Status;
|
||||
EMU_THUNK_PROTOCOL *Thunk;
|
||||
|
||||
//
|
||||
// Locate EmuThunkPpi for
|
||||
//
|
||||
Status = PeiServicesLocatePpi (
|
||||
&gEmuThunkPpiGuid,
|
||||
0,
|
||||
NULL,
|
||||
(VOID **) &ThunkPpi
|
||||
&gEmuThunkPpiGuid,
|
||||
0,
|
||||
NULL,
|
||||
(VOID **)&ThunkPpi
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
|
||||
return Thunk->QueryPerformanceCounter ();
|
||||
Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
|
||||
return Thunk->QueryPerformanceCounter ();
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -136,33 +136,34 @@ GetPerformanceCounter (
|
||||
UINT64
|
||||
EFIAPI
|
||||
GetPerformanceCounterProperties (
|
||||
OUT UINT64 *StartValue OPTIONAL,
|
||||
OUT UINT64 *EndValue OPTIONAL
|
||||
OUT UINT64 *StartValue OPTIONAL,
|
||||
OUT UINT64 *EndValue OPTIONAL
|
||||
)
|
||||
{
|
||||
EMU_THUNK_PPI *ThunkPpi;
|
||||
EFI_STATUS Status;
|
||||
EMU_THUNK_PROTOCOL *Thunk;
|
||||
EMU_THUNK_PPI *ThunkPpi;
|
||||
EFI_STATUS Status;
|
||||
EMU_THUNK_PROTOCOL *Thunk;
|
||||
|
||||
//
|
||||
// Locate EmuThunkPpi for
|
||||
//
|
||||
Status = PeiServicesLocatePpi (
|
||||
&gEmuThunkPpiGuid,
|
||||
0,
|
||||
NULL,
|
||||
(VOID **) &ThunkPpi
|
||||
&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 ();
|
||||
Thunk = (EMU_THUNK_PROTOCOL *)ThunkPpi->Thunk ();
|
||||
return Thunk->QueryPerformanceFrequency ();
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -204,9 +205,9 @@ GetTimeInNanoSecond (
|
||||
// Since 2^29 < 1,000,000,000 = 0x3B9ACA00 < 2^30, Remainder should < 2^(64-30) = 2^34,
|
||||
// i.e. highest bit set in Remainder should <= 33.
|
||||
//
|
||||
Shift = MAX (0, HighBitSet64 (Remainder) - 33);
|
||||
Remainder = RShiftU64 (Remainder, (UINTN) Shift);
|
||||
Frequency = RShiftU64 (Frequency, (UINTN) Shift);
|
||||
Shift = MAX (0, HighBitSet64 (Remainder) - 33);
|
||||
Remainder = RShiftU64 (Remainder, (UINTN)Shift);
|
||||
Frequency = RShiftU64 (Frequency, (UINTN)Shift);
|
||||
NanoSeconds += DivU64x64Remainder (MultU64x32 (Remainder, 1000000000u), Frequency, NULL);
|
||||
|
||||
return NanoSeconds;
|
||||
|
@@ -8,7 +8,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include "PlatformBm.h"
|
||||
|
||||
EFI_GUID mBootMenuFile = {
|
||||
EFI_GUID mBootMenuFile = {
|
||||
0xEEC25BDC, 0x67F2, 0x4D95, { 0xB1, 0xD5, 0xF8, 0x1B, 0x20, 0x39, 0xD1, 0x1D }
|
||||
};
|
||||
|
||||
@@ -20,24 +20,24 @@ SetupVariableInit (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN Size;
|
||||
EMU_SYSTEM_CONFIGURATION SystemConfigData;
|
||||
EFI_STATUS Status;
|
||||
UINTN Size;
|
||||
EMU_SYSTEM_CONFIGURATION SystemConfigData;
|
||||
|
||||
Size = sizeof (SystemConfigData);
|
||||
Size = sizeof (SystemConfigData);
|
||||
Status = gRT->GetVariable (
|
||||
L"Setup",
|
||||
&gEmuSystemConfigGuid,
|
||||
NULL,
|
||||
&Size,
|
||||
(VOID *) &SystemConfigData
|
||||
(VOID *)&SystemConfigData
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
//
|
||||
// SetupVariable is corrupt
|
||||
//
|
||||
SystemConfigData.ConOutRow = PcdGet32 (PcdConOutColumn);
|
||||
SystemConfigData.ConOutRow = PcdGet32 (PcdConOutColumn);
|
||||
SystemConfigData.ConOutColumn = PcdGet32 (PcdConOutRow);
|
||||
|
||||
Status = gRT->SetVariable (
|
||||
@@ -45,7 +45,7 @@ SetupVariableInit (
|
||||
&gEmuSystemConfigGuid,
|
||||
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||
sizeof (SystemConfigData),
|
||||
(VOID *) &SystemConfigData
|
||||
(VOID *)&SystemConfigData
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "Failed to save Setup Variable to non-volatile storage, Status = %r\n", Status));
|
||||
@@ -55,10 +55,9 @@ SetupVariableInit (
|
||||
|
||||
EFI_DEVICE_PATH *
|
||||
FvFilePath (
|
||||
EFI_GUID *FileGuid
|
||||
EFI_GUID *FileGuid
|
||||
)
|
||||
{
|
||||
|
||||
EFI_STATUS Status;
|
||||
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
|
||||
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
|
||||
@@ -68,12 +67,12 @@ FvFilePath (
|
||||
Status = gBS->HandleProtocol (
|
||||
gImageHandle,
|
||||
&gEfiLoadedImageProtocolGuid,
|
||||
(VOID **) &LoadedImage
|
||||
(VOID **)&LoadedImage
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
return AppendDevicePathNode (
|
||||
DevicePathFromHandle (LoadedImage->DeviceHandle),
|
||||
(EFI_DEVICE_PATH_PROTOCOL *) &FileNode
|
||||
(EFI_DEVICE_PATH_PROTOCOL *)&FileNode
|
||||
);
|
||||
}
|
||||
|
||||
@@ -91,28 +90,28 @@ FvFilePath (
|
||||
**/
|
||||
UINTN
|
||||
RegisterBootManagerMenuAppBootOption (
|
||||
EFI_GUID *FileGuid,
|
||||
CHAR16 *Description,
|
||||
UINTN Position,
|
||||
BOOLEAN IsBootCategory
|
||||
EFI_GUID *FileGuid,
|
||||
CHAR16 *Description,
|
||||
UINTN Position,
|
||||
BOOLEAN IsBootCategory
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
UINTN OptionNumber;
|
||||
EFI_STATUS Status;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
UINTN OptionNumber;
|
||||
|
||||
DevicePath = FvFilePath (FileGuid);
|
||||
Status = EfiBootManagerInitializeLoadOption (
|
||||
&NewOption,
|
||||
LoadOptionNumberUnassigned,
|
||||
LoadOptionTypeBoot,
|
||||
IsBootCategory ? LOAD_OPTION_ACTIVE : LOAD_OPTION_CATEGORY_APP,
|
||||
Description,
|
||||
DevicePath,
|
||||
NULL,
|
||||
0
|
||||
);
|
||||
Status = EfiBootManagerInitializeLoadOption (
|
||||
&NewOption,
|
||||
LoadOptionNumberUnassigned,
|
||||
LoadOptionTypeBoot,
|
||||
IsBootCategory ? LOAD_OPTION_ACTIVE : LOAD_OPTION_CATEGORY_APP,
|
||||
Description,
|
||||
DevicePath,
|
||||
NULL,
|
||||
0
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
FreePool (DevicePath);
|
||||
|
||||
@@ -136,16 +135,16 @@ RegisterBootManagerMenuAppBootOption (
|
||||
**/
|
||||
BOOLEAN
|
||||
IsBootManagerMenuAppFilePath (
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
EFI_HANDLE FvHandle;
|
||||
VOID *NameGuid;
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE FvHandle;
|
||||
VOID *NameGuid;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &DevicePath, &FvHandle);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
NameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) DevicePath);
|
||||
NameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)DevicePath);
|
||||
if (NameGuid != NULL) {
|
||||
return CompareGuid (NameGuid, &mBootMenuFile);
|
||||
}
|
||||
@@ -167,10 +166,10 @@ GetBootManagerMenuAppOption (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINTN BootOptionCount;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
|
||||
UINTN Index;
|
||||
UINTN OptionNumber;
|
||||
UINTN BootOptionCount;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
|
||||
UINTN Index;
|
||||
UINTN OptionNumber;
|
||||
|
||||
OptionNumber = 0;
|
||||
|
||||
@@ -189,7 +188,7 @@ GetBootManagerMenuAppOption (
|
||||
//
|
||||
// If not found the BootManagerMenuApp, create it.
|
||||
//
|
||||
OptionNumber = (UINT16) RegisterBootManagerMenuAppBootOption (&mBootMenuFile, L"UEFI BootManagerMenuApp", (UINTN) -1, FALSE);
|
||||
OptionNumber = (UINT16)RegisterBootManagerMenuAppBootOption (&mBootMenuFile, L"UEFI BootManagerMenuApp", (UINTN)-1, FALSE);
|
||||
}
|
||||
|
||||
return OptionNumber;
|
||||
@@ -205,13 +204,13 @@ PlatformBootManagerBeforeConsole (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
UINTN Index;
|
||||
|
||||
SetupVariableInit ();
|
||||
|
||||
EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);
|
||||
|
||||
Index = 0;
|
||||
Index = 0;
|
||||
while (gPlatformConsole[Index].DevicePath != NULL) {
|
||||
//
|
||||
// Update the console variable with the connect type
|
||||
@@ -256,8 +255,8 @@ PlatformBdsConnectSequence (
|
||||
**/
|
||||
VOID
|
||||
PlatformBdsDiagnostics (
|
||||
IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,
|
||||
IN BOOLEAN QuietBoot
|
||||
IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,
|
||||
IN BOOLEAN QuietBoot
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
@@ -317,14 +316,14 @@ PlatformBdsRegisterStaticBootOptions (
|
||||
F2.ScanCode = SCAN_F2;
|
||||
F2.UnicodeChar = CHAR_NULL;
|
||||
EfiBootManagerGetBootManagerMenu (&BootOption);
|
||||
EfiBootManagerAddKeyOptionVariable (NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL);
|
||||
EfiBootManagerAddKeyOptionVariable (NULL, (UINT16)BootOption.OptionNumber, 0, &F2, NULL);
|
||||
|
||||
//
|
||||
// 3. Boot Device List menu
|
||||
//
|
||||
F7.ScanCode = SCAN_F7;
|
||||
F7.UnicodeChar = CHAR_NULL;
|
||||
OptionNumber = GetBootManagerMenuAppOption ();
|
||||
F7.ScanCode = SCAN_F7;
|
||||
F7.UnicodeChar = CHAR_NULL;
|
||||
OptionNumber = GetBootManagerMenuAppOption ();
|
||||
EfiBootManagerAddKeyOptionVariable (NULL, (UINT16)OptionNumber, 0, &F7, NULL);
|
||||
|
||||
PrintXY (10, 10, &White, &Black, L"F2 to enter Setup. ");
|
||||
@@ -339,7 +338,7 @@ PlatformBdsRegisterStaticBootOptions (
|
||||
**/
|
||||
UINTN
|
||||
BootOptionPriority (
|
||||
CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
|
||||
CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -348,6 +347,7 @@ BootOptionPriority (
|
||||
if (StrCmp (BootOption->Description, L"UEFI Shell") == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 100;
|
||||
}
|
||||
|
||||
@@ -377,37 +377,35 @@ PlatformBootManagerAfterConsole (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
|
||||
//
|
||||
// Go the different platform policy with different boot mode
|
||||
// Notes: this part code can be change with the table policy
|
||||
//
|
||||
switch (GetBootModeHob ()) {
|
||||
case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:
|
||||
case BOOT_WITH_MINIMAL_CONFIGURATION:
|
||||
PlatformBdsDiagnostics (IGNORE, TRUE);
|
||||
|
||||
case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:
|
||||
case BOOT_WITH_MINIMAL_CONFIGURATION:
|
||||
PlatformBdsDiagnostics (IGNORE, TRUE);
|
||||
//
|
||||
// Perform some platform specific connect sequence
|
||||
//
|
||||
PlatformBdsConnectSequence ();
|
||||
break;
|
||||
|
||||
//
|
||||
// Perform some platform specific connect sequence
|
||||
//
|
||||
PlatformBdsConnectSequence ();
|
||||
break;
|
||||
case BOOT_IN_RECOVERY_MODE:
|
||||
PlatformBdsDiagnostics (EXTENSIVE, FALSE);
|
||||
break;
|
||||
|
||||
case BOOT_IN_RECOVERY_MODE:
|
||||
PlatformBdsDiagnostics (EXTENSIVE, FALSE);
|
||||
break;
|
||||
|
||||
case BOOT_WITH_FULL_CONFIGURATION:
|
||||
case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:
|
||||
case BOOT_WITH_DEFAULT_SETTINGS:
|
||||
default:
|
||||
PlatformBdsDiagnostics (IGNORE, TRUE);
|
||||
PlatformBdsRegisterStaticBootOptions ();
|
||||
PlatformBdsConnectSequence ();
|
||||
EfiBootManagerRefreshAllBootOption ();
|
||||
EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot, (SORT_COMPARE)CompareBootOption);
|
||||
break;
|
||||
case BOOT_WITH_FULL_CONFIGURATION:
|
||||
case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:
|
||||
case BOOT_WITH_DEFAULT_SETTINGS:
|
||||
default:
|
||||
PlatformBdsDiagnostics (IGNORE, TRUE);
|
||||
PlatformBdsRegisterStaticBootOptions ();
|
||||
PlatformBdsConnectSequence ();
|
||||
EfiBootManagerRefreshAllBootOption ();
|
||||
EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot, (SORT_COMPARE)CompareBootOption);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,12 +417,12 @@ PlatformBootManagerAfterConsole (
|
||||
VOID
|
||||
EFIAPI
|
||||
PlatformBootManagerWaitCallback (
|
||||
UINT16 TimeoutRemain
|
||||
UINT16 TimeoutRemain
|
||||
)
|
||||
{
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White;
|
||||
UINT16 Timeout;
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White;
|
||||
UINT16 Timeout;
|
||||
|
||||
Timeout = PcdGet16 (PcdPlatformBootTimeOut);
|
||||
|
||||
@@ -456,4 +454,3 @@ PlatformBootManagerUnableToBoot (
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -34,14 +34,14 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#include <Library/HobLib.h>
|
||||
#include <Library/HiiLib.h>
|
||||
|
||||
#define CONSOLE_OUT 0x00000001
|
||||
#define STD_ERROR 0x00000002
|
||||
#define CONSOLE_IN 0x00000004
|
||||
#define CONSOLE_ALL (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
|
||||
#define CONSOLE_OUT 0x00000001
|
||||
#define STD_ERROR 0x00000002
|
||||
#define CONSOLE_IN 0x00000004
|
||||
#define CONSOLE_ALL (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
|
||||
|
||||
typedef struct {
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
UINTN ConnectType;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
UINTN ConnectType;
|
||||
} BDS_CONSOLE_CONNECT_ENTRY;
|
||||
|
||||
extern BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[];
|
||||
@@ -56,14 +56,12 @@ extern BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[];
|
||||
}\
|
||||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
EMU_VENDOR_DEVICE_PATH_NODE EmuBus;
|
||||
EMU_VENDOR_DEVICE_PATH_NODE EmuGraphicsWindow;
|
||||
EFI_DEVICE_PATH_PROTOCOL End;
|
||||
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
|
||||
//
|
||||
@@ -80,10 +78,9 @@ typedef struct {
|
||||
**/
|
||||
EFI_STATUS
|
||||
PlatformBootManagerMemoryTest (
|
||||
IN EXTENDMEM_COVERAGE_LEVEL Level
|
||||
IN EXTENDMEM_COVERAGE_LEVEL Level
|
||||
);
|
||||
|
||||
|
||||
VOID
|
||||
PlatformBdsConnectSequence (
|
||||
VOID
|
||||
|
@@ -8,17 +8,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include "PlatformBm.h"
|
||||
|
||||
|
||||
|
||||
EMU_PLATFORM_UGA_DEVICE_PATH gGopDevicePath = {
|
||||
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)
|
||||
(UINT8)(sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),
|
||||
(UINT8)((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)
|
||||
}
|
||||
},
|
||||
EMU_THUNK_PROTOCOL_GUID
|
||||
@@ -31,8 +29,8 @@ 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)
|
||||
(UINT8)(sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),
|
||||
(UINT8)((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)
|
||||
},
|
||||
},
|
||||
EMU_GRAPHICS_WINDOW_PROTOCOL_GUID,
|
||||
@@ -42,15 +40,15 @@ EMU_PLATFORM_UGA_DEVICE_PATH gGopDevicePath = {
|
||||
gEndEntire
|
||||
};
|
||||
|
||||
EMU_PLATFORM_UGA_DEVICE_PATH gGopDevicePath2 = {
|
||||
EMU_PLATFORM_UGA_DEVICE_PATH gGopDevicePath2 = {
|
||||
{
|
||||
{
|
||||
{
|
||||
HARDWARE_DEVICE_PATH,
|
||||
HW_VENDOR_DP,
|
||||
{
|
||||
(UINT8) (sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),
|
||||
(UINT8) ((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)
|
||||
(UINT8)(sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),
|
||||
(UINT8)((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)
|
||||
}
|
||||
},
|
||||
EMU_THUNK_PROTOCOL_GUID
|
||||
@@ -63,8 +61,8 @@ EMU_PLATFORM_UGA_DEVICE_PATH gGopDevicePath2 = {
|
||||
HARDWARE_DEVICE_PATH,
|
||||
HW_VENDOR_DP,
|
||||
{
|
||||
(UINT8) (sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),
|
||||
(UINT8) ((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)
|
||||
(UINT8)(sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),
|
||||
(UINT8)((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)
|
||||
},
|
||||
},
|
||||
EMU_GRAPHICS_WINDOW_PROTOCOL_GUID,
|
||||
@@ -77,13 +75,13 @@ EMU_PLATFORM_UGA_DEVICE_PATH gGopDevicePath2 = {
|
||||
//
|
||||
// Predefined platform default console device path
|
||||
//
|
||||
BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = {
|
||||
BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = {
|
||||
{
|
||||
(EFI_DEVICE_PATH_PROTOCOL *) &gGopDevicePath,
|
||||
(EFI_DEVICE_PATH_PROTOCOL *)&gGopDevicePath,
|
||||
(CONSOLE_OUT | CONSOLE_IN)
|
||||
},
|
||||
{
|
||||
(EFI_DEVICE_PATH_PROTOCOL *) &gGopDevicePath2,
|
||||
(EFI_DEVICE_PATH_PROTOCOL *)&gGopDevicePath2,
|
||||
(CONSOLE_OUT | CONSOLE_IN)
|
||||
},
|
||||
{
|
||||
@@ -91,4 +89,3 @@ BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = {
|
||||
0
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -24,7 +24,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
**/
|
||||
EFI_STATUS
|
||||
PlatformBootManagerMemoryTest (
|
||||
IN EXTENDMEM_COVERAGE_LEVEL Level
|
||||
IN EXTENDMEM_COVERAGE_LEVEL Level
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
@@ -42,17 +42,17 @@ PlatformBootManagerMemoryTest (
|
||||
ReturnStatus = EFI_SUCCESS;
|
||||
ZeroMem (&Key, sizeof (EFI_INPUT_KEY));
|
||||
|
||||
TestedMemorySize = 0;
|
||||
TotalMemorySize = 0;
|
||||
ErrorOut = FALSE;
|
||||
TestAbort = FALSE;
|
||||
TestedMemorySize = 0;
|
||||
TotalMemorySize = 0;
|
||||
ErrorOut = FALSE;
|
||||
TestAbort = FALSE;
|
||||
|
||||
RequireSoftECCInit = FALSE;
|
||||
|
||||
Status = gBS->LocateProtocol (
|
||||
&gEfiGenericMemTestProtocolGuid,
|
||||
NULL,
|
||||
(VOID **) &GenMemoryTest
|
||||
(VOID **)&GenMemoryTest
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_SUCCESS;
|
||||
@@ -88,11 +88,10 @@ PlatformBootManagerMemoryTest (
|
||||
ASSERT (0);
|
||||
}
|
||||
|
||||
|
||||
DEBUG ((DEBUG_INFO, "Perform memory test (ESC to skip).\n"));
|
||||
|
||||
if (!PcdGetBool (PcdConInConnectOnDemand)) {
|
||||
KeyStatus = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
|
||||
KeyStatus = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
|
||||
if (!EFI_ERROR (KeyStatus) && (Key.ScanCode == SCAN_ESC)) {
|
||||
if (!RequireSoftECCInit) {
|
||||
Status = GenMemoryTest->Finished (GenMemoryTest);
|
||||
|
@@ -18,15 +18,15 @@
|
||||
#include <Guid/GlobalVariable.h>
|
||||
#include <Guid/ImageAuthentication.h>
|
||||
|
||||
BOOLEAN mSecureBootDisabled = FALSE;
|
||||
BOOLEAN mStopRedfishService = FALSE;
|
||||
BOOLEAN mSecureBootDisabled = FALSE;
|
||||
BOOLEAN mStopRedfishService = FALSE;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
LibStopRedfishService (
|
||||
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This,
|
||||
IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType
|
||||
);
|
||||
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This,
|
||||
IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType
|
||||
);
|
||||
|
||||
/**
|
||||
Return the credential for accessing to Redfish servcice.
|
||||
@@ -41,10 +41,10 @@ LibStopRedfishService (
|
||||
**/
|
||||
EFI_STATUS
|
||||
GetRedfishCredential (
|
||||
OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod,
|
||||
OUT CHAR8 **UserId,
|
||||
OUT CHAR8 **Password
|
||||
)
|
||||
OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod,
|
||||
OUT CHAR8 **UserId,
|
||||
OUT CHAR8 **Password
|
||||
)
|
||||
{
|
||||
UINTN UserIdSize;
|
||||
UINTN PasswordSize;
|
||||
@@ -59,14 +59,16 @@ GetRedfishCredential (
|
||||
//
|
||||
UserIdSize = AsciiStrSize ((CHAR8 *)PcdGetPtr (PcdRedfishServieUserId));
|
||||
PasswordSize = AsciiStrSize ((CHAR8 *)PcdGetPtr (PcdRedfishServiePassword));
|
||||
if (UserIdSize == 0 || PasswordSize == 0) {
|
||||
if ((UserIdSize == 0) || (PasswordSize == 0)) {
|
||||
DEBUG ((DEBUG_ERROR, "Incorrect string of UserID or Password for REdfish service.\n"));
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
*UserId = AllocateZeroPool (UserIdSize);
|
||||
if (*UserId == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
CopyMem (*UserId, (CHAR8 *)PcdGetPtr (PcdRedfishServieUserId), UserIdSize);
|
||||
|
||||
*Password = AllocateZeroPool (PasswordSize);
|
||||
@@ -110,11 +112,11 @@ LibCredentialGetAuthInfo (
|
||||
OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod,
|
||||
OUT CHAR8 **UserId,
|
||||
OUT CHAR8 **Password
|
||||
)
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (This == NULL || AuthMethod == NULL || UserId == NULL || Password == NULL) {
|
||||
if ((This == NULL) || (AuthMethod == NULL) || (UserId == NULL) || (Password == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -124,7 +126,7 @@ LibCredentialGetAuthInfo (
|
||||
|
||||
if (mSecureBootDisabled) {
|
||||
Status = LibStopRedfishService (This, ServiceStopTypeSecureBootDisabled);
|
||||
if (EFI_ERROR (Status) && Status != EFI_UNSUPPORTED) {
|
||||
if (EFI_ERROR (Status) && (Status != EFI_UNSUPPORTED)) {
|
||||
DEBUG ((DEBUG_ERROR, "SecureBoot has been disabled, but failed to stop RedfishService - %r\n", Status));
|
||||
return Status;
|
||||
}
|
||||
@@ -159,9 +161,9 @@ LibCredentialGetAuthInfo (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
LibStopRedfishService (
|
||||
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This,
|
||||
IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType
|
||||
)
|
||||
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This,
|
||||
IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType
|
||||
)
|
||||
{
|
||||
if (ServiceStopType >= ServiceStopTypeMax) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
@@ -193,8 +195,10 @@ LibStopRedfishService (
|
||||
mStopRedfishService = TRUE;
|
||||
DEBUG ((DEBUG_INFO, "EFI Redfish service is stopped without Redfish service stop type!!\n"));
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Notification of Exit Boot Service.
|
||||
|
||||
@@ -204,7 +208,7 @@ VOID
|
||||
EFIAPI
|
||||
LibCredentialExitBootServicesNotify (
|
||||
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This
|
||||
)
|
||||
)
|
||||
{
|
||||
LibStopRedfishService (This, ServiceStopTypeExitBootService);
|
||||
}
|
||||
@@ -218,15 +222,15 @@ VOID
|
||||
EFIAPI
|
||||
LibCredentialEndOfDxeNotify (
|
||||
IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This
|
||||
)
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT8 *SecureBootVar;
|
||||
UINT8 *SecureBootVar;
|
||||
|
||||
//
|
||||
// Check Secure Boot status and lock Redfish service if Secure Boot is disabled.
|
||||
//
|
||||
Status = GetVariable2 (EFI_SECURE_BOOT_MODE_NAME, &gEfiGlobalVariableGuid, (VOID**)&SecureBootVar, NULL);
|
||||
Status = GetVariable2 (EFI_SECURE_BOOT_MODE_NAME, &gEfiGlobalVariableGuid, (VOID **)&SecureBootVar, NULL);
|
||||
if (EFI_ERROR (Status) || (*SecureBootVar != SECURE_BOOT_MODE_ENABLE)) {
|
||||
//
|
||||
// Secure Boot is disabled
|
||||
|
@@ -26,7 +26,7 @@
|
||||
#define VERBOSE_COLUME_SIZE (16)
|
||||
|
||||
REDFISH_OVER_IP_PROTOCOL_DATA *mRedfishOverIpProtocolData;
|
||||
UINT8 mRedfishProtocolDataSize;
|
||||
UINT8 mRedfishProtocolDataSize;
|
||||
|
||||
/**
|
||||
Get the MAC address of NIC.
|
||||
@@ -38,22 +38,23 @@ UINT8 mRedfishProtocolDataSize;
|
||||
**/
|
||||
EFI_STATUS
|
||||
GetMacAddressInformation (
|
||||
OUT EFI_MAC_ADDRESS *MacAddress
|
||||
OUT EFI_MAC_ADDRESS *MacAddress
|
||||
)
|
||||
{
|
||||
MAC_ADDR_DEVICE_PATH *Mac;
|
||||
REST_EX_SERVICE_DEVICE_PATH_DATA *RestExServiceDevicePathData;
|
||||
EFI_DEVICE_PATH_PROTOCOL *RestExServiceDevicePath;
|
||||
MAC_ADDR_DEVICE_PATH *MacAddressDevicePath;
|
||||
MAC_ADDR_DEVICE_PATH *Mac;
|
||||
REST_EX_SERVICE_DEVICE_PATH_DATA *RestExServiceDevicePathData;
|
||||
EFI_DEVICE_PATH_PROTOCOL *RestExServiceDevicePath;
|
||||
MAC_ADDR_DEVICE_PATH *MacAddressDevicePath;
|
||||
|
||||
Mac = NULL;
|
||||
RestExServiceDevicePathData = NULL;
|
||||
RestExServiceDevicePath = NULL;
|
||||
Mac = NULL;
|
||||
RestExServiceDevicePathData = NULL;
|
||||
RestExServiceDevicePath = NULL;
|
||||
|
||||
RestExServiceDevicePathData = (REST_EX_SERVICE_DEVICE_PATH_DATA *)PcdGetPtr(PcdRedfishRestExServiceDevicePath);
|
||||
if (RestExServiceDevicePathData == NULL ||
|
||||
RestExServiceDevicePathData->DevicePathNum == 0 ||
|
||||
!IsDevicePathValid (RestExServiceDevicePathData->DevicePath, 0)) {
|
||||
RestExServiceDevicePathData = (REST_EX_SERVICE_DEVICE_PATH_DATA *)PcdGetPtr (PcdRedfishRestExServiceDevicePath);
|
||||
if ((RestExServiceDevicePathData == NULL) ||
|
||||
(RestExServiceDevicePathData->DevicePathNum == 0) ||
|
||||
!IsDevicePathValid (RestExServiceDevicePathData->DevicePath, 0))
|
||||
{
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
@@ -67,7 +68,8 @@ GetMacAddressInformation (
|
||||
//
|
||||
while (!IsDevicePathEnd (RestExServiceDevicePath) &&
|
||||
((DevicePathType (RestExServiceDevicePath) != MESSAGING_DEVICE_PATH) ||
|
||||
(DevicePathSubType (RestExServiceDevicePath) != MSG_MAC_ADDR_DP))) {
|
||||
(DevicePathSubType (RestExServiceDevicePath) != MSG_MAC_ADDR_DP)))
|
||||
{
|
||||
RestExServiceDevicePath = NextDevicePathNode (RestExServiceDevicePath);
|
||||
}
|
||||
|
||||
@@ -76,6 +78,7 @@ GetMacAddressInformation (
|
||||
CopyMem ((VOID *)MacAddress, (VOID *)&MacAddressDevicePath->MacAddress, sizeof (EFI_MAC_ADDRESS));
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
@@ -91,35 +94,38 @@ GetMacAddressInformation (
|
||||
**/
|
||||
EFI_STATUS
|
||||
RedfishPlatformHostInterfaceDeviceDescriptor (
|
||||
OUT UINT8 *DeviceType,
|
||||
OUT UINT8 *DeviceType,
|
||||
OUT REDFISH_INTERFACE_DATA **DeviceDescriptor
|
||||
)
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_MAC_ADDRESS MacAddress;
|
||||
REDFISH_INTERFACE_DATA *RedfishInterfaceData;
|
||||
PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2 *ThisDeviceDescriptor;
|
||||
EFI_STATUS Status;
|
||||
EFI_MAC_ADDRESS MacAddress;
|
||||
REDFISH_INTERFACE_DATA *RedfishInterfaceData;
|
||||
PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2 *ThisDeviceDescriptor;
|
||||
|
||||
RedfishInterfaceData = AllocateZeroPool (sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1);
|
||||
if (RedfishInterfaceData == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
RedfishInterfaceData->DeviceType = REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2;
|
||||
//
|
||||
// Fill up device type information.
|
||||
//
|
||||
ThisDeviceDescriptor = (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2 *)((UINT8 *)RedfishInterfaceData + 1);
|
||||
ThisDeviceDescriptor = (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2 *)((UINT8 *)RedfishInterfaceData + 1);
|
||||
ThisDeviceDescriptor->Length = sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1;
|
||||
Status = GetMacAddressInformation (&MacAddress);
|
||||
Status = GetMacAddressInformation (&MacAddress);
|
||||
if (EFI_ERROR (Status)) {
|
||||
FreePool (RedfishInterfaceData);
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
CopyMem ((VOID *)&ThisDeviceDescriptor->MacAddress, (VOID *)&MacAddress, sizeof (ThisDeviceDescriptor->MacAddress));
|
||||
*DeviceType = REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2;
|
||||
*DeviceType = REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2;
|
||||
*DeviceDescriptor = RedfishInterfaceData;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Get platform Redfish host interface protocol data.
|
||||
Caller should pass NULL in ProtocolRecord to retrive the first protocol record.
|
||||
@@ -136,29 +142,32 @@ RedfishPlatformHostInterfaceDeviceDescriptor (
|
||||
**/
|
||||
EFI_STATUS
|
||||
RedfishPlatformHostInterfaceProtocolData (
|
||||
OUT MC_HOST_INTERFACE_PROTOCOL_RECORD **ProtocolRecord,
|
||||
IN UINT8 IndexOfProtocolData
|
||||
)
|
||||
OUT MC_HOST_INTERFACE_PROTOCOL_RECORD **ProtocolRecord,
|
||||
IN UINT8 IndexOfProtocolData
|
||||
)
|
||||
{
|
||||
MC_HOST_INTERFACE_PROTOCOL_RECORD *ThisProtocolRecord;
|
||||
MC_HOST_INTERFACE_PROTOCOL_RECORD *ThisProtocolRecord;
|
||||
|
||||
if (mRedfishOverIpProtocolData == 0) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (IndexOfProtocolData == 0) {
|
||||
//
|
||||
// Return the first Redfish protocol data to caller. We only have
|
||||
// one protocol data in this case.
|
||||
//
|
||||
ThisProtocolRecord = (MC_HOST_INTERFACE_PROTOCOL_RECORD *) AllocatePool (mRedfishProtocolDataSize + sizeof (MC_HOST_INTERFACE_PROTOCOL_RECORD) - 1);
|
||||
ThisProtocolRecord->ProtocolType = MCHostInterfaceProtocolTypeRedfishOverIP;
|
||||
ThisProtocolRecord = (MC_HOST_INTERFACE_PROTOCOL_RECORD *)AllocatePool (mRedfishProtocolDataSize + sizeof (MC_HOST_INTERFACE_PROTOCOL_RECORD) - 1);
|
||||
ThisProtocolRecord->ProtocolType = MCHostInterfaceProtocolTypeRedfishOverIP;
|
||||
ThisProtocolRecord->ProtocolTypeDataLen = mRedfishProtocolDataSize;
|
||||
CopyMem ((VOID *)&ThisProtocolRecord->ProtocolTypeData, (VOID *)mRedfishOverIpProtocolData, mRedfishProtocolDataSize);
|
||||
*ProtocolRecord = ThisProtocolRecord;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
/**
|
||||
Dump IPv4 address.
|
||||
|
||||
@@ -166,10 +175,10 @@ RedfishPlatformHostInterfaceProtocolData (
|
||||
**/
|
||||
VOID
|
||||
InternalDumpIp4Addr (
|
||||
IN EFI_IPv4_ADDRESS *Ip
|
||||
IN EFI_IPv4_ADDRESS *Ip
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
UINTN Index;
|
||||
|
||||
for (Index = 0; Index < 4; Index++) {
|
||||
DEBUG ((DEBUG_VERBOSE, "%d", Ip->Addr[Index]));
|
||||
@@ -180,6 +189,7 @@ InternalDumpIp4Addr (
|
||||
|
||||
DEBUG ((DEBUG_VERBOSE, "\n"));
|
||||
}
|
||||
|
||||
/**
|
||||
Dump IPv6 address.
|
||||
|
||||
@@ -187,15 +197,16 @@ InternalDumpIp4Addr (
|
||||
**/
|
||||
VOID
|
||||
InternalDumpIp6Addr (
|
||||
IN EFI_IPv6_ADDRESS *Ip
|
||||
IN EFI_IPv6_ADDRESS *Ip
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
UINTN Index;
|
||||
|
||||
for (Index = 0; Index < 16; Index++) {
|
||||
if (Ip->Addr[Index] != 0) {
|
||||
DEBUG ((DEBUG_VERBOSE, "%x", Ip->Addr[Index]));
|
||||
}
|
||||
|
||||
Index++;
|
||||
|
||||
if (Index > 15) {
|
||||
@@ -205,14 +216,17 @@ InternalDumpIp6Addr (
|
||||
if (((Ip->Addr[Index] & 0xf0) == 0) && (Ip->Addr[Index - 1] != 0)) {
|
||||
DEBUG ((DEBUG_VERBOSE, "0"));
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_VERBOSE, "%x", Ip->Addr[Index]));
|
||||
|
||||
if (Index < 15) {
|
||||
DEBUG ((DEBUG_VERBOSE, ":"));
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_VERBOSE, "\n"));
|
||||
}
|
||||
|
||||
/**
|
||||
Dump data
|
||||
|
||||
@@ -226,10 +240,12 @@ InternalDumpData (
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
|
||||
for (Index = 0; Index < Size; Index++) {
|
||||
DEBUG ((DEBUG_VERBOSE, "%02x ", (UINTN)Data[Index]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Dump hex data
|
||||
|
||||
@@ -242,9 +258,9 @@ InternalDumpHex (
|
||||
IN UINTN Size
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
UINTN Count;
|
||||
UINTN Left;
|
||||
UINTN Index;
|
||||
UINTN Count;
|
||||
UINTN Left;
|
||||
|
||||
Count = Size / VERBOSE_COLUME_SIZE;
|
||||
Left = Size % VERBOSE_COLUME_SIZE;
|
||||
@@ -260,6 +276,7 @@ InternalDumpHex (
|
||||
|
||||
DEBUG ((DEBUG_VERBOSE, "\n"));
|
||||
}
|
||||
|
||||
/**
|
||||
Dump Redfish over IP protocol data
|
||||
|
||||
@@ -268,14 +285,14 @@ InternalDumpHex (
|
||||
**/
|
||||
VOID
|
||||
DumpRedfishIpProtocolData (
|
||||
IN REDFISH_OVER_IP_PROTOCOL_DATA *RedfishProtocolData,
|
||||
IN UINT8 RedfishProtocolDataSize
|
||||
IN REDFISH_OVER_IP_PROTOCOL_DATA *RedfishProtocolData,
|
||||
IN UINT8 RedfishProtocolDataSize
|
||||
)
|
||||
{
|
||||
CHAR16 Hostname[16];
|
||||
CHAR16 Hostname[16];
|
||||
|
||||
DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData: \n"));
|
||||
InternalDumpHex ((UINT8 *) RedfishProtocolData, RedfishProtocolDataSize);
|
||||
InternalDumpHex ((UINT8 *)RedfishProtocolData, RedfishProtocolDataSize);
|
||||
|
||||
DEBUG ((DEBUG_VERBOSE, "Parsing as below: \n"));
|
||||
|
||||
@@ -287,16 +304,16 @@ DumpRedfishIpProtocolData (
|
||||
|
||||
DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->HostIpAddress: \n"));
|
||||
if (RedfishProtocolData->HostIpAddressFormat == 0x01) {
|
||||
InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *) (RedfishProtocolData->HostIpAddress));
|
||||
InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *)(RedfishProtocolData->HostIpAddress));
|
||||
} else {
|
||||
InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *) (RedfishProtocolData->HostIpAddress));
|
||||
InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *)(RedfishProtocolData->HostIpAddress));
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->HostIpMask: \n"));
|
||||
if (RedfishProtocolData->HostIpAddressFormat == 0x01) {
|
||||
InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *) (RedfishProtocolData->HostIpMask));
|
||||
InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *)(RedfishProtocolData->HostIpMask));
|
||||
} else {
|
||||
InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *) (RedfishProtocolData->HostIpMask));
|
||||
InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *)(RedfishProtocolData->HostIpMask));
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpDiscoveryType - %d\n", RedfishProtocolData->RedfishServiceIpDiscoveryType));
|
||||
@@ -305,16 +322,16 @@ DumpRedfishIpProtocolData (
|
||||
|
||||
DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpAddress: \n"));
|
||||
if (RedfishProtocolData->RedfishServiceIpAddressFormat == 0x01) {
|
||||
InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *) (RedfishProtocolData->RedfishServiceIpAddress));
|
||||
InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *)(RedfishProtocolData->RedfishServiceIpAddress));
|
||||
} else {
|
||||
InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *) (RedfishProtocolData->RedfishServiceIpAddress));
|
||||
InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *)(RedfishProtocolData->RedfishServiceIpAddress));
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpMask: \n"));
|
||||
if (RedfishProtocolData->RedfishServiceIpAddressFormat == 0x01) {
|
||||
InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *) (RedfishProtocolData->RedfishServiceIpMask));
|
||||
InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *)(RedfishProtocolData->RedfishServiceIpMask));
|
||||
} else {
|
||||
InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *) (RedfishProtocolData->RedfishServiceIpMask));
|
||||
InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *)(RedfishProtocolData->RedfishServiceIpMask));
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpPort - %d\n", RedfishProtocolData->RedfishServiceIpPort));
|
||||
@@ -323,7 +340,7 @@ DumpRedfishIpProtocolData (
|
||||
|
||||
DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceHostnameLength - %d\n", RedfishProtocolData->RedfishServiceHostnameLength));
|
||||
|
||||
AsciiStrToUnicodeStrS((CHAR8 *) RedfishProtocolData->RedfishServiceHostname, Hostname, sizeof (Hostname) / sizeof (Hostname[0]));
|
||||
AsciiStrToUnicodeStrS ((CHAR8 *)RedfishProtocolData->RedfishServiceHostname, Hostname, sizeof (Hostname) / sizeof (Hostname[0]));
|
||||
DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceHostname - %s\n", Hostname));
|
||||
}
|
||||
|
||||
@@ -337,24 +354,24 @@ DumpRedfishIpProtocolData (
|
||||
**/
|
||||
EFI_STATUS
|
||||
GetRedfishRecordFromVariable (
|
||||
OUT REDFISH_OVER_IP_PROTOCOL_DATA **RedfishProtocolData,
|
||||
OUT UINT8 *RedfishProtocolDataSize
|
||||
OUT REDFISH_OVER_IP_PROTOCOL_DATA **RedfishProtocolData,
|
||||
OUT UINT8 *RedfishProtocolDataSize
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT8 HostIpAssignmentType;
|
||||
UINTN HostIpAssignmentTypeSize;
|
||||
EFI_IPv4_ADDRESS HostIpAddress;
|
||||
UINTN IPv4DataSize;
|
||||
EFI_IPv4_ADDRESS HostIpMask;
|
||||
EFI_IPv4_ADDRESS RedfishServiceIpAddress;
|
||||
EFI_IPv4_ADDRESS RedfishServiceIpMask;
|
||||
UINT16 RedfishServiceIpPort;
|
||||
UINTN IpPortDataSize;
|
||||
UINT8 HostNameSize;
|
||||
CHAR8 RedfishHostName[20];
|
||||
EFI_STATUS Status;
|
||||
UINT8 HostIpAssignmentType;
|
||||
UINTN HostIpAssignmentTypeSize;
|
||||
EFI_IPv4_ADDRESS HostIpAddress;
|
||||
UINTN IPv4DataSize;
|
||||
EFI_IPv4_ADDRESS HostIpMask;
|
||||
EFI_IPv4_ADDRESS RedfishServiceIpAddress;
|
||||
EFI_IPv4_ADDRESS RedfishServiceIpMask;
|
||||
UINT16 RedfishServiceIpPort;
|
||||
UINTN IpPortDataSize;
|
||||
UINT8 HostNameSize;
|
||||
CHAR8 RedfishHostName[20];
|
||||
|
||||
if (RedfishProtocolData == NULL || RedfishProtocolDataSize == NULL) {
|
||||
if ((RedfishProtocolData == NULL) || (RedfishProtocolDataSize == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -446,7 +463,7 @@ GetRedfishRecordFromVariable (
|
||||
RedfishServiceIpAddress.Addr[3]
|
||||
);
|
||||
|
||||
HostNameSize = (UINT8) AsciiStrLen (RedfishHostName) + 1;
|
||||
HostNameSize = (UINT8)AsciiStrLen (RedfishHostName) + 1;
|
||||
|
||||
//
|
||||
// 2. Protocol Data Size.
|
||||
@@ -456,7 +473,7 @@ GetRedfishRecordFromVariable (
|
||||
//
|
||||
// 3. Protocol Data.
|
||||
//
|
||||
*RedfishProtocolData = (REDFISH_OVER_IP_PROTOCOL_DATA *) AllocateZeroPool (*RedfishProtocolDataSize);
|
||||
*RedfishProtocolData = (REDFISH_OVER_IP_PROTOCOL_DATA *)AllocateZeroPool (*RedfishProtocolDataSize);
|
||||
if (*RedfishProtocolData == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@@ -464,7 +481,7 @@ GetRedfishRecordFromVariable (
|
||||
CopyGuid (&(*RedfishProtocolData)->ServiceUuid, &gEmuRedfishServiceGuid);
|
||||
|
||||
(*RedfishProtocolData)->HostIpAssignmentType = HostIpAssignmentType;
|
||||
(*RedfishProtocolData)->HostIpAddressFormat = 1; // Only support IPv4
|
||||
(*RedfishProtocolData)->HostIpAddressFormat = 1; // Only support IPv4
|
||||
|
||||
if (HostIpAssignmentType == 1 ) {
|
||||
(*RedfishProtocolData)->HostIpAddress[0] = HostIpAddress.Addr[0];
|
||||
@@ -495,7 +512,7 @@ GetRedfishRecordFromVariable (
|
||||
(*RedfishProtocolData)->RedfishServiceVlanId = 0xffffffff;
|
||||
|
||||
(*RedfishProtocolData)->RedfishServiceHostnameLength = HostNameSize;
|
||||
AsciiStrCpyS ((CHAR8 *) ((*RedfishProtocolData)->RedfishServiceHostname), HostNameSize, RedfishHostName);
|
||||
AsciiStrCpyS ((CHAR8 *)((*RedfishProtocolData)->RedfishServiceHostname), HostNameSize, RedfishHostName);
|
||||
|
||||
return Status;
|
||||
}
|
||||
@@ -513,16 +530,17 @@ GetRedfishRecordFromVariable (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
RedfishPlatformHostInterfaceConstructor (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = GetRedfishRecordFromVariable (&mRedfishOverIpProtocolData, &mRedfishProtocolDataSize);
|
||||
DEBUG ((DEBUG_INFO, "%a: GetRedfishRecordFromVariable() - %r\n", __FUNCTION__, Status));
|
||||
if (!EFI_ERROR (Status)) {
|
||||
DumpRedfishIpProtocolData (mRedfishOverIpProtocolData, mRedfishProtocolDataSize);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
@@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include <PiPei.h>
|
||||
|
||||
|
||||
#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \
|
||||
(ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1))
|
||||
|
||||
@@ -18,6 +17,7 @@ GetFileState (
|
||||
IN UINT8 ErasePolarity,
|
||||
IN EFI_FFS_FILE_HEADER *FfsHeader
|
||||
)
|
||||
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@@ -39,7 +39,7 @@ Returns:
|
||||
FileState = FfsHeader->State;
|
||||
|
||||
if (ErasePolarity != 0) {
|
||||
FileState = (EFI_FFS_FILE_STATE)~FileState;
|
||||
FileState = (EFI_FFS_FILE_STATE) ~FileState;
|
||||
}
|
||||
|
||||
HighestBit = 0x80;
|
||||
@@ -54,6 +54,7 @@ UINT8
|
||||
CalculateHeaderChecksum (
|
||||
IN EFI_FFS_FILE_HEADER *FileHeader
|
||||
)
|
||||
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@@ -67,41 +68,43 @@ Returns:
|
||||
|
||||
**/
|
||||
{
|
||||
UINT8 *ptr;
|
||||
UINTN Index;
|
||||
UINT8 Sum;
|
||||
UINT8 *ptr;
|
||||
UINTN Index;
|
||||
UINT8 Sum;
|
||||
|
||||
Sum = 0;
|
||||
ptr = (UINT8 *) FileHeader;
|
||||
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]);
|
||||
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]);
|
||||
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);
|
||||
Sum = (UINT8)(Sum - FileHeader->State);
|
||||
//
|
||||
// Checksum field of the file is not part of the header checksum.
|
||||
//
|
||||
Sum = (UINT8) (Sum - FileHeader->IntegrityCheck.Checksum.File);
|
||||
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
|
||||
IN EFI_FV_FILETYPE SearchType,
|
||||
IN EFI_PEI_FV_HANDLE FvHandle,
|
||||
IN OUT EFI_PEI_FILE_HANDLE *FileHandle
|
||||
)
|
||||
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@@ -124,20 +127,20 @@ Returns:
|
||||
|
||||
**/
|
||||
{
|
||||
EFI_FFS_FILE_HEADER *FfsFileHeader;
|
||||
UINT32 FileLength;
|
||||
UINT32 FileOccupiedSize;
|
||||
UINT32 FileOffset;
|
||||
UINT64 FvLength;
|
||||
UINT8 ErasePolarity;
|
||||
UINT8 FileState;
|
||||
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;
|
||||
FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)FvHandle;
|
||||
FileHeader = (EFI_FFS_FILE_HEADER **)FileHandle;
|
||||
|
||||
FvLength = FwVolHeader->FvLength;
|
||||
@@ -146,23 +149,24 @@ Returns:
|
||||
} 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);
|
||||
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);
|
||||
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);
|
||||
FileOffset = (UINT32)((UINT8 *)FfsFileHeader - (UINT8 *)FwVolHeader);
|
||||
|
||||
while (FileOffset < (FvLength - sizeof (EFI_FFS_FILE_HEADER))) {
|
||||
//
|
||||
@@ -171,42 +175,40 @@ Returns:
|
||||
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_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);
|
||||
|
||||
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;
|
||||
|
||||
if ((SearchType == FfsFileHeader->Type) || (SearchType == EFI_FV_FILETYPE_ALL)) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
*FileHeader = FfsFileHeader;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
FileOffset += FileOccupiedSize;
|
||||
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + FileOccupiedSize);
|
||||
} else {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
FileOffset += FileOccupiedSize;
|
||||
FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + FileOccupiedSize);
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
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;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,10 +217,11 @@ Returns:
|
||||
|
||||
EFI_STATUS
|
||||
SecFfsFindSectionData (
|
||||
IN EFI_SECTION_TYPE SectionType,
|
||||
IN EFI_FFS_FILE_HEADER *FfsFileHeader,
|
||||
IN OUT VOID **SectionData
|
||||
IN EFI_SECTION_TYPE SectionType,
|
||||
IN EFI_FFS_FILE_HEADER *FfsFileHeader,
|
||||
IN OUT VOID **SectionData
|
||||
)
|
||||
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@@ -237,39 +240,39 @@ Returns:
|
||||
|
||||
**/
|
||||
{
|
||||
UINT32 FileSize;
|
||||
EFI_COMMON_SECTION_HEADER *Section;
|
||||
UINT32 SectionLength;
|
||||
UINT32 ParsedLength;
|
||||
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;
|
||||
Section = (EFI_COMMON_SECTION_HEADER *)(FfsFileHeader + 1);
|
||||
FileSize = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
|
||||
FileSize -= sizeof (EFI_FFS_FILE_HEADER);
|
||||
|
||||
*SectionData = NULL;
|
||||
ParsedLength = 0;
|
||||
*SectionData = NULL;
|
||||
ParsedLength = 0;
|
||||
while (ParsedLength < FileSize) {
|
||||
if (Section->Type == SectionType) {
|
||||
*SectionData = (VOID *) (Section + 1);
|
||||
*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 = *(UINT32 *)Section->Size & 0x00FFFFFF;
|
||||
SectionLength = GET_OCCUPIED_SIZE (SectionLength, 4);
|
||||
|
||||
ParsedLength += SectionLength;
|
||||
Section = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) Section + SectionLength);
|
||||
Section = (EFI_COMMON_SECTION_HEADER *)((UINT8 *)Section + SectionLength);
|
||||
}
|
||||
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
@@ -6,30 +6,26 @@
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#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
|
||||
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
|
||||
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.
|
||||
|
||||
@@ -45,7 +41,7 @@ SecFfsFindSectionData (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesInstallPpi (
|
||||
IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList
|
||||
IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
@@ -70,8 +66,8 @@ PeiServicesInstallPpi (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesReInstallPpi (
|
||||
IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi,
|
||||
IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi
|
||||
IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi,
|
||||
IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
@@ -97,26 +93,28 @@ PeiServicesReInstallPpi (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesLocatePpi (
|
||||
IN CONST EFI_GUID *Guid,
|
||||
IN UINTN Instance,
|
||||
IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,
|
||||
IN OUT VOID **Ppi
|
||||
IN CONST EFI_GUID *Guid,
|
||||
IN UINTN Instance,
|
||||
IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,
|
||||
IN OUT VOID **Ppi
|
||||
)
|
||||
{
|
||||
EFI_PEI_PPI_DESCRIPTOR *PpiList;
|
||||
EFI_PEI_PPI_DESCRIPTOR *PpiList;
|
||||
|
||||
if (Instance != 0) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
for (PpiList = EMU_MAGIC_PAGE()->PpiList; ; PpiList++) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -125,7 +123,6 @@ PeiServicesLocatePpi (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
@@ -166,7 +163,7 @@ PeiServicesNotifyPpi (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesGetBootMode (
|
||||
OUT EFI_BOOT_MODE *BootMode
|
||||
OUT EFI_BOOT_MODE *BootMode
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
@@ -184,7 +181,7 @@ PeiServicesGetBootMode (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesSetBootMode (
|
||||
IN EFI_BOOT_MODE BootMode
|
||||
IN EFI_BOOT_MODE BootMode
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
@@ -204,7 +201,7 @@ PeiServicesSetBootMode (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesGetHobList (
|
||||
OUT VOID **HobList
|
||||
OUT VOID **HobList
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
@@ -226,9 +223,9 @@ PeiServicesGetHobList (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesCreateHob (
|
||||
IN UINT16 Type,
|
||||
IN UINT16 Length,
|
||||
OUT VOID **Hob
|
||||
IN UINT16 Type,
|
||||
IN UINT16 Length,
|
||||
OUT VOID **Hob
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
@@ -251,8 +248,8 @@ PeiServicesCreateHob (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesFfsFindNextVolume (
|
||||
IN UINTN Instance,
|
||||
IN OUT EFI_PEI_FV_HANDLE *VolumeHandle
|
||||
IN UINTN Instance,
|
||||
IN OUT EFI_PEI_FV_HANDLE *VolumeHandle
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
@@ -276,9 +273,9 @@ PeiServicesFfsFindNextVolume (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesFfsFindNextFile (
|
||||
IN EFI_FV_FILETYPE SearchType,
|
||||
IN EFI_PEI_FV_HANDLE VolumeHandle,
|
||||
IN OUT EFI_PEI_FILE_HANDLE *FileHandle
|
||||
IN EFI_FV_FILETYPE SearchType,
|
||||
IN EFI_PEI_FV_HANDLE VolumeHandle,
|
||||
IN OUT EFI_PEI_FILE_HANDLE *FileHandle
|
||||
)
|
||||
{
|
||||
return SecFfsFindNextFile (SearchType, VolumeHandle, FileHandle);
|
||||
@@ -299,9 +296,9 @@ PeiServicesFfsFindNextFile (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesFfsFindSectionData (
|
||||
IN EFI_SECTION_TYPE SectionType,
|
||||
IN EFI_PEI_FILE_HANDLE FileHandle,
|
||||
OUT VOID **SectionData
|
||||
IN EFI_SECTION_TYPE SectionType,
|
||||
IN EFI_PEI_FILE_HANDLE FileHandle,
|
||||
OUT VOID **SectionData
|
||||
)
|
||||
{
|
||||
return SecFfsFindSectionData (SectionType, FileHandle, SectionData);
|
||||
@@ -322,8 +319,8 @@ PeiServicesFfsFindSectionData (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesInstallPeiMemory (
|
||||
IN EFI_PHYSICAL_ADDRESS MemoryBegin,
|
||||
IN UINT64 MemoryLength
|
||||
IN EFI_PHYSICAL_ADDRESS MemoryBegin,
|
||||
IN UINT64 MemoryLength
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
@@ -347,9 +344,9 @@ PeiServicesInstallPeiMemory (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesAllocatePages (
|
||||
IN EFI_MEMORY_TYPE MemoryType,
|
||||
IN UINTN Pages,
|
||||
OUT EFI_PHYSICAL_ADDRESS *Memory
|
||||
IN EFI_MEMORY_TYPE MemoryType,
|
||||
IN UINTN Pages,
|
||||
OUT EFI_PHYSICAL_ADDRESS *Memory
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
@@ -370,8 +367,8 @@ PeiServicesAllocatePages (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesAllocatePool (
|
||||
IN UINTN Size,
|
||||
OUT VOID **Buffer
|
||||
IN UINTN Size,
|
||||
OUT VOID **Buffer
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
@@ -415,7 +412,7 @@ PeiServicesResetSystem (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesRegisterForShadow (
|
||||
IN EFI_PEI_FILE_HANDLE FileHandle
|
||||
IN EFI_PEI_FILE_HANDLE FileHandle
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
@@ -443,15 +440,14 @@ PeiServicesRegisterForShadow (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesFfsGetFileInfo (
|
||||
IN CONST EFI_PEI_FILE_HANDLE FileHandle,
|
||||
OUT EFI_FV_FILE_INFO *FileInfo
|
||||
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
|
||||
@@ -476,16 +472,15 @@ PeiServicesFfsGetFileInfo (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesFfsFindFileByName (
|
||||
IN CONST EFI_GUID *FileName,
|
||||
IN CONST EFI_PEI_FV_HANDLE VolumeHandle,
|
||||
OUT EFI_PEI_FILE_HANDLE *FileHandle
|
||||
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
|
||||
@@ -507,8 +502,8 @@ PeiServicesFfsFindFileByName (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PeiServicesFfsGetVolumeInfo (
|
||||
IN EFI_PEI_FV_HANDLE VolumeHandle,
|
||||
OUT EFI_FV_INFO *VolumeInfo
|
||||
IN EFI_PEI_FV_HANDLE VolumeHandle,
|
||||
OUT EFI_FV_INFO *VolumeInfo
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
@@ -548,11 +543,11 @@ PeiServicesFfsGetVolumeInfo (
|
||||
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
|
||||
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);
|
||||
|
@@ -8,4 +8,3 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#include <PiPei.h>
|
||||
|
||||
CONST EFI_PEI_PPI_DESCRIPTOR *gPpiList = NULL;
|
||||
|
||||
|
@@ -18,9 +18,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/SmbiosLib.h>
|
||||
|
||||
|
||||
EFI_SMBIOS_PROTOCOL *gSmbios = NULL;
|
||||
|
||||
EFI_SMBIOS_PROTOCOL *gSmbios = NULL;
|
||||
|
||||
/**
|
||||
Create an initial SMBIOS Table from an array of SMBIOS_TEMPLATE_ENTRY
|
||||
@@ -34,11 +32,11 @@ EFI_SMBIOS_PROTOCOL *gSmbios = NULL;
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmbiosLibInitializeFromTemplate (
|
||||
IN SMBIOS_TEMPLATE_ENTRY *Template
|
||||
IN SMBIOS_TEMPLATE_ENTRY *Template
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN Index;
|
||||
EFI_STATUS Status;
|
||||
UINTN Index;
|
||||
|
||||
if (Template == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
@@ -53,8 +51,6 @@ SmbiosLibInitializeFromTemplate (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Create SMBIOS record.
|
||||
|
||||
@@ -85,17 +81,17 @@ SmbiosLibInitializeFromTemplate (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmbiosLibCreateEntry (
|
||||
IN SMBIOS_STRUCTURE *SmbiosEntry,
|
||||
IN CHAR8 **StringArray
|
||||
IN SMBIOS_STRUCTURE *SmbiosEntry,
|
||||
IN CHAR8 **StringArray
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_SMBIOS_HANDLE SmbiosHandle;
|
||||
EFI_SMBIOS_TABLE_HEADER *Record;
|
||||
UINTN Index;
|
||||
UINTN StringSize;
|
||||
UINTN Size;
|
||||
CHAR8 *Str;
|
||||
EFI_STATUS Status;
|
||||
EFI_SMBIOS_HANDLE SmbiosHandle;
|
||||
EFI_SMBIOS_TABLE_HEADER *Record;
|
||||
UINTN Index;
|
||||
UINTN StringSize;
|
||||
UINTN Size;
|
||||
CHAR8 *Str;
|
||||
|
||||
// Calculate the size of the fixed record and optional string pack
|
||||
Size = SmbiosEntry->Length;
|
||||
@@ -106,8 +102,9 @@ SmbiosLibCreateEntry (
|
||||
} else {
|
||||
for (Index = 0; StringArray[Index] != NULL; Index++) {
|
||||
StringSize = AsciiStrSize (StringArray[Index]);
|
||||
Size += StringSize;
|
||||
Size += StringSize;
|
||||
}
|
||||
|
||||
// Don't forget the terminating double null
|
||||
Size += 1;
|
||||
}
|
||||
@@ -117,6 +114,7 @@ SmbiosLibCreateEntry (
|
||||
if (Record == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
CopyMem (Record, SmbiosEntry, SmbiosEntry->Length);
|
||||
|
||||
if (StringArray != NULL) {
|
||||
@@ -127,23 +125,22 @@ SmbiosLibCreateEntry (
|
||||
CopyMem (Str, StringArray[Index], StringSize);
|
||||
Str += StringSize;
|
||||
}
|
||||
|
||||
*Str = 0;
|
||||
}
|
||||
|
||||
SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
|
||||
Status = gSmbios->Add (
|
||||
gSmbios,
|
||||
gImageHandle,
|
||||
&SmbiosHandle,
|
||||
Record
|
||||
);
|
||||
Status = gSmbios->Add (
|
||||
gSmbios,
|
||||
gImageHandle,
|
||||
&SmbiosHandle,
|
||||
Record
|
||||
);
|
||||
|
||||
FreePool (Record);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Update the string associated with an existing SMBIOS record.
|
||||
|
||||
@@ -162,12 +159,12 @@ SmbiosLibCreateEntry (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmbiosLibUpdateString (
|
||||
IN EFI_SMBIOS_HANDLE SmbiosHandle,
|
||||
IN SMBIOS_TABLE_STRING StringNumber,
|
||||
IN CHAR8 *String
|
||||
IN EFI_SMBIOS_HANDLE SmbiosHandle,
|
||||
IN SMBIOS_TABLE_STRING StringNumber,
|
||||
IN CHAR8 *String
|
||||
)
|
||||
{
|
||||
UINTN StringIndex;
|
||||
UINTN StringIndex;
|
||||
|
||||
if (String == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
@@ -182,7 +179,6 @@ SmbiosLibUpdateString (
|
||||
return gSmbios->UpdateString (gSmbios, &SmbiosHandle, &StringIndex, String);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Update the string associated with an existing SMBIOS record.
|
||||
|
||||
@@ -201,9 +197,9 @@ SmbiosLibUpdateString (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmbiosLibUpdateUnicodeString (
|
||||
IN EFI_SMBIOS_HANDLE SmbiosHandle,
|
||||
IN SMBIOS_TABLE_STRING StringNumber,
|
||||
IN CHAR16 *String
|
||||
IN EFI_SMBIOS_HANDLE SmbiosHandle,
|
||||
IN SMBIOS_TABLE_STRING StringNumber,
|
||||
IN CHAR16 *String
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
@@ -223,16 +219,16 @@ SmbiosLibUpdateUnicodeString (
|
||||
if (Ascii == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
UnicodeStrToAsciiStrS (String, Ascii, StrSize (String));
|
||||
|
||||
StringIndex = StringNumber;
|
||||
Status = gSmbios->UpdateString (gSmbios, &SmbiosHandle, &StringIndex, Ascii);
|
||||
Status = gSmbios->UpdateString (gSmbios, &SmbiosHandle, &StringIndex, Ascii);
|
||||
|
||||
FreePool (Ascii);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Allow caller to read a specific SMBIOS string
|
||||
|
||||
@@ -249,14 +245,15 @@ SmbiosLibReadString (
|
||||
IN EFI_SMBIOS_STRING StringNumber
|
||||
)
|
||||
{
|
||||
CHAR8 *Data;
|
||||
UINTN Match;
|
||||
CHAR8 *Data;
|
||||
UINTN Match;
|
||||
|
||||
Data = (CHAR8 *)Header + Header->Length;
|
||||
for (Match = 1;!(*Data == 0 && *(Data+1) == 0); ) {
|
||||
for (Match = 1; !(*Data == 0 && *(Data+1) == 0); ) {
|
||||
if (StringNumber == Match) {
|
||||
return Data;
|
||||
}
|
||||
|
||||
Data++;
|
||||
if (*(Data - 1) == '\0') {
|
||||
Match++;
|
||||
@@ -266,7 +263,6 @@ SmbiosLibReadString (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Allow the caller to discover a specific SMBIOS entry, and patch it if necissary.
|
||||
|
||||
@@ -280,14 +276,14 @@ SmbiosLibReadString (
|
||||
SMBIOS_STRUCTURE *
|
||||
EFIAPI
|
||||
SmbiosLibGetRecord (
|
||||
IN EFI_SMBIOS_TYPE Type,
|
||||
IN UINTN Instance,
|
||||
OUT EFI_SMBIOS_HANDLE *SmbiosHandle
|
||||
IN EFI_SMBIOS_TYPE Type,
|
||||
IN UINTN Instance,
|
||||
OUT EFI_SMBIOS_HANDLE *SmbiosHandle
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_SMBIOS_TABLE_HEADER *Record;
|
||||
UINTN Match;
|
||||
EFI_STATUS Status;
|
||||
EFI_SMBIOS_TABLE_HEADER *Record;
|
||||
UINTN Match;
|
||||
|
||||
Match = 0;
|
||||
*SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
|
||||
@@ -297,6 +293,7 @@ SmbiosLibGetRecord (
|
||||
if (Match == Instance) {
|
||||
return (SMBIOS_STRUCTURE *)Record;
|
||||
}
|
||||
|
||||
Match++;
|
||||
}
|
||||
} while (!EFI_ERROR (Status));
|
||||
@@ -304,7 +301,6 @@ SmbiosLibGetRecord (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Remove an SMBIOS record.
|
||||
|
||||
@@ -318,14 +314,12 @@ SmbiosLibGetRecord (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SmbiosLibRemove (
|
||||
OUT EFI_SMBIOS_HANDLE SmbiosHandle
|
||||
OUT EFI_SMBIOS_HANDLE SmbiosHandle
|
||||
)
|
||||
{
|
||||
return gSmbios->Remove (gSmbios, SmbiosHandle);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@param ImageHandle ImageHandle of the loaded driver.
|
||||
@@ -343,4 +337,3 @@ SmbiosLibConstructor (
|
||||
{
|
||||
return gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&gSmbios);
|
||||
}
|
||||
|
||||
|
@@ -12,30 +12,26 @@
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
|
||||
|
||||
UINTN gThunkPpiListSize = 0;
|
||||
EFI_PEI_PPI_DESCRIPTOR *gThunkPpiList = NULL;
|
||||
|
||||
|
||||
EFI_PEI_PPI_DESCRIPTOR *gThunkPpiList = NULL;
|
||||
|
||||
EFI_PEI_PPI_DESCRIPTOR *
|
||||
GetThunkPpiList (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
UINTN Index;
|
||||
|
||||
if (gThunkPpiList == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Index = (gThunkPpiListSize/sizeof (EFI_PEI_PPI_DESCRIPTOR)) - 1;
|
||||
Index = (gThunkPpiListSize/sizeof (EFI_PEI_PPI_DESCRIPTOR)) - 1;
|
||||
gThunkPpiList[Index].Flags |= EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
|
||||
|
||||
return gThunkPpiList;
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
AddThunkPpi (
|
||||
@@ -44,7 +40,7 @@ AddThunkPpi (
|
||||
IN VOID *Ppi
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
UINTN Index;
|
||||
|
||||
gThunkPpiList = ReallocatePool (
|
||||
gThunkPpiListSize,
|
||||
@@ -55,16 +51,11 @@ AddThunkPpi (
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Index = (gThunkPpiListSize/sizeof (EFI_PEI_PPI_DESCRIPTOR));
|
||||
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);
|
||||
gThunkPpiListSize += sizeof (EFI_PEI_PPI_DESCRIPTOR);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -16,25 +16,23 @@
|
||||
|
||||
#include <Protocol/EmuIoThunk.h>
|
||||
|
||||
|
||||
#define EMU_IO_THUNK_PROTOCOL_DATA_SIGNATURE SIGNATURE_32('E','m','u','T')
|
||||
#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;
|
||||
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
|
||||
IN EMU_IO_THUNK_PROTOCOL *ThunkIo,
|
||||
IN CHAR16 *ConfigString,
|
||||
IN BOOLEAN EmuBusDriver
|
||||
)
|
||||
{
|
||||
UINTN Size;
|
||||
@@ -47,15 +45,15 @@ AddThunkProtocol (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Instance = 0;
|
||||
Size = StrSize (ConfigString);
|
||||
Instance = 0;
|
||||
Size = StrSize (ConfigString);
|
||||
StartString = AllocatePool (Size);
|
||||
if (StartString == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
StrCpyS (StartString, Size / sizeof (CHAR16), ConfigString);
|
||||
while (*StartString != '\0') {
|
||||
|
||||
//
|
||||
// Find the end of the sub string
|
||||
//
|
||||
@@ -77,12 +75,13 @@ AddThunkProtocol (
|
||||
if (Private == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
Private->Signature = EMU_IO_THUNK_PROTOCOL_DATA_SIGNATURE;
|
||||
Private->EmuBusDriver = EmuBusDriver;
|
||||
|
||||
Private->Signature = EMU_IO_THUNK_PROTOCOL_DATA_SIGNATURE;
|
||||
Private->EmuBusDriver = EmuBusDriver;
|
||||
|
||||
CopyMem (&Private->Data, ThunkIo, sizeof (EMU_IO_THUNK_PROTOCOL));
|
||||
Private->Data.Instance = (UINT16)Instance++;
|
||||
Private->Data.ConfigString = StartString;
|
||||
Private->Data.Instance = (UINT16)Instance++;
|
||||
Private->Data.ConfigString = StartString;
|
||||
|
||||
InsertTailList (&mThunkList, &Private->Link);
|
||||
|
||||
@@ -95,16 +94,15 @@ AddThunkProtocol (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
GetNextThunkProtocol (
|
||||
IN BOOLEAN EmuBusDriver,
|
||||
OUT EMU_IO_THUNK_PROTOCOL **Instance OPTIONAL
|
||||
IN BOOLEAN EmuBusDriver,
|
||||
OUT EMU_IO_THUNK_PROTOCOL **Instance OPTIONAL
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Link;
|
||||
EMU_IO_THUNK_PROTOCOL_DATA *Private;
|
||||
LIST_ENTRY *Link;
|
||||
EMU_IO_THUNK_PROTOCOL_DATA *Private;
|
||||
|
||||
if (mThunkList.ForwardLink == &mThunkList) {
|
||||
// Skip parsing an empty list
|
||||
@@ -125,13 +123,12 @@ GetNextThunkProtocol (
|
||||
if (Link == &mThunkList) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
Private = CR (Link, EMU_IO_THUNK_PROTOCOL_DATA, Link, EMU_IO_THUNK_PROTOCOL_DATA_SIGNATURE);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user