PrmPkg: Apply uncrustify changes
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in PrmPkg. Cc: Andrew Fish <afish@apple.com> Cc: Kang Gao <kang.gao@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Michael Kubacki <michael.kubacki@microsoft.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Benjamin You <benjamin.you@intel.com> Cc: Liu Yun <yun.y.liu@intel.com> Cc: Ankit Sinha <ankit.sinha@intel.com> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Acked-by: Michael D Kinney <michael.d.kinney@intel.com> Acked-by: Liming Gao <gaoliming@byosoft.com.cn> Acked-by: Leif Lindholm <quic_llindhol@quicinc.com> Reviewed-by: Ankit Sinha <ankit.sinha@intel.com>
This commit is contained in:
committed by
mergify[bot]
parent
f3c11224b5
commit
a298a84478
@ -47,10 +47,10 @@ STATIC EFI_HII_HANDLE mPrmInfoHiiHandle;
|
|||||||
STATIC LIST_ENTRY mPrmHandlerList;
|
STATIC LIST_ENTRY mPrmHandlerList;
|
||||||
|
|
||||||
STATIC CONST SHELL_PARAM_ITEM mParamList[] = {
|
STATIC CONST SHELL_PARAM_ITEM mParamList[] = {
|
||||||
{L"-l", TypeFlag},
|
{ L"-l", TypeFlag },
|
||||||
{L"-t", TypeValue},
|
{ L"-t", TypeValue },
|
||||||
{NULL, TypeMax}
|
{ NULL, TypeMax }
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Frees all of the nodes in a linked list.
|
Frees all of the nodes in a linked list.
|
||||||
@ -102,6 +102,7 @@ CreateNewPrmHandlerListEntry (
|
|||||||
if (PrmHandlerContextListEntry == NULL) {
|
if (PrmHandlerContextListEntry == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrmHandlerContextListEntry->Signature = PRM_HANDLER_CONTEXT_LIST_ENTRY_SIGNATURE;
|
PrmHandlerContextListEntry->Signature = PRM_HANDLER_CONTEXT_LIST_ENTRY_SIGNATURE;
|
||||||
|
|
||||||
return PrmHandlerContextListEntry;
|
return PrmHandlerContextListEntry;
|
||||||
@ -125,7 +126,7 @@ PrintMmioRuntimeRangeInfo (
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RuntimeMmioRangeCount = (UINTN) RuntimeMmioRanges->Count;
|
RuntimeMmioRangeCount = (UINTN)RuntimeMmioRanges->Count;
|
||||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_RUNTIME_MMIO_COUNT), mPrmInfoHiiHandle, RuntimeMmioRangeCount);
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_RUNTIME_MMIO_COUNT), mPrmInfoHiiHandle, RuntimeMmioRangeCount);
|
||||||
|
|
||||||
for (RuntimeMmioRangeIndex = 0; RuntimeMmioRangeIndex < RuntimeMmioRangeCount; RuntimeMmioRangeIndex++) {
|
for (RuntimeMmioRangeIndex = 0; RuntimeMmioRangeIndex < RuntimeMmioRangeCount; RuntimeMmioRangeIndex++) {
|
||||||
@ -184,8 +185,8 @@ GatherPrmHandlerInfo (
|
|||||||
for (
|
for (
|
||||||
CurrentPrmModuleImageContext = NULL, Status = GetNextPrmModuleEntry (&CurrentPrmModuleImageContext);
|
CurrentPrmModuleImageContext = NULL, Status = GetNextPrmModuleEntry (&CurrentPrmModuleImageContext);
|
||||||
!EFI_ERROR (Status);
|
!EFI_ERROR (Status);
|
||||||
Status = GetNextPrmModuleEntry (&CurrentPrmModuleImageContext)) {
|
Status = GetNextPrmModuleEntry (&CurrentPrmModuleImageContext))
|
||||||
|
{
|
||||||
CurrentImageAddress = CurrentPrmModuleImageContext->PeCoffImageContext.ImageAddress;
|
CurrentImageAddress = CurrentPrmModuleImageContext->PeCoffImageContext.ImageAddress;
|
||||||
CurrentImageExportDirectory = CurrentPrmModuleImageContext->ExportDirectory;
|
CurrentImageExportDirectory = CurrentPrmModuleImageContext->ExportDirectory;
|
||||||
CurrentExportDescriptorStruct = CurrentPrmModuleImageContext->ExportDescriptor;
|
CurrentExportDescriptorStruct = CurrentPrmModuleImageContext->ExportDescriptor;
|
||||||
@ -196,7 +197,7 @@ GatherPrmHandlerInfo (
|
|||||||
MajorVersion = 0;
|
MajorVersion = 0;
|
||||||
MinorVersion = 0;
|
MinorVersion = 0;
|
||||||
Status = GetImageVersionInPeCoffImage (
|
Status = GetImageVersionInPeCoffImage (
|
||||||
(VOID *) (UINTN) CurrentImageAddress,
|
(VOID *)(UINTN)CurrentImageAddress,
|
||||||
&CurrentPrmModuleImageContext->PeCoffImageContext,
|
&CurrentPrmModuleImageContext->PeCoffImageContext,
|
||||||
&MajorVersion,
|
&MajorVersion,
|
||||||
&MinorVersion
|
&MinorVersion
|
||||||
@ -210,7 +211,7 @@ GatherPrmHandlerInfo (
|
|||||||
NULL,
|
NULL,
|
||||||
STRING_TOKEN (STR_PRMINFO_MODULE_NAME),
|
STRING_TOKEN (STR_PRMINFO_MODULE_NAME),
|
||||||
mPrmInfoHiiHandle,
|
mPrmInfoHiiHandle,
|
||||||
(CHAR8 *) ((UINTN) CurrentImageAddress + CurrentImageExportDirectory->Name)
|
(CHAR8 *)((UINTN)CurrentImageAddress + CurrentImageExportDirectory->Name)
|
||||||
);
|
);
|
||||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_MODULE_GUID), mPrmInfoHiiHandle, CurrentModuleGuid);
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_MODULE_GUID), mPrmInfoHiiHandle, CurrentModuleGuid);
|
||||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_MODULE_VERSION), mPrmInfoHiiHandle, MajorVersion, MinorVersion);
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_MODULE_VERSION), mPrmInfoHiiHandle, MajorVersion, MinorVersion);
|
||||||
@ -221,10 +222,10 @@ GatherPrmHandlerInfo (
|
|||||||
Status = GetModuleContextBuffers (
|
Status = GetModuleContextBuffers (
|
||||||
ByModuleGuid,
|
ByModuleGuid,
|
||||||
CurrentModuleGuid,
|
CurrentModuleGuid,
|
||||||
(CONST PRM_MODULE_CONTEXT_BUFFERS **) &CurrentModuleContextBuffers
|
(CONST PRM_MODULE_CONTEXT_BUFFERS **)&CurrentModuleContextBuffers
|
||||||
);
|
);
|
||||||
ASSERT (!EFI_ERROR (Status) || Status == EFI_NOT_FOUND);
|
ASSERT (!EFI_ERROR (Status) || Status == EFI_NOT_FOUND);
|
||||||
if (!EFI_ERROR (Status) && CurrentModuleContextBuffers != NULL) {
|
if (!EFI_ERROR (Status) && (CurrentModuleContextBuffers != NULL)) {
|
||||||
CurrentPrmModuleRuntimeMmioRanges = CurrentModuleContextBuffers->RuntimeMmioRanges;
|
CurrentPrmModuleRuntimeMmioRanges = CurrentModuleContextBuffers->RuntimeMmioRanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,6 +235,7 @@ GatherPrmHandlerInfo (
|
|||||||
} else {
|
} else {
|
||||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_NO_MMIO_RANGES), mPrmInfoHiiHandle);
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_NO_MMIO_RANGES), mPrmInfoHiiHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_LINE_BREAK), mPrmInfoHiiHandle);
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_LINE_BREAK), mPrmInfoHiiHandle);
|
||||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_HANDLER_COUNT), mPrmInfoHiiHandle, HandlerCount);
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_HANDLER_COUNT), mPrmInfoHiiHandle, HandlerCount);
|
||||||
}
|
}
|
||||||
@ -241,9 +243,9 @@ GatherPrmHandlerInfo (
|
|||||||
for (HandlerIndex = 0; HandlerIndex < HandlerCount; HandlerIndex++) {
|
for (HandlerIndex = 0; HandlerIndex < HandlerCount; HandlerIndex++) {
|
||||||
ZeroMem (&CurrentHandlerContext, sizeof (CurrentHandlerContext));
|
ZeroMem (&CurrentHandlerContext, sizeof (CurrentHandlerContext));
|
||||||
|
|
||||||
CurrentHandlerContext.ModuleName = (CHAR8 *) ((UINTN) CurrentImageAddress + CurrentImageExportDirectory->Name);
|
CurrentHandlerContext.ModuleName = (CHAR8 *)((UINTN)CurrentImageAddress + CurrentImageExportDirectory->Name);
|
||||||
CurrentHandlerContext.Guid = &CurrentExportDescriptorStruct->PrmHandlerExportDescriptors[HandlerIndex].PrmHandlerGuid;
|
CurrentHandlerContext.Guid = &CurrentExportDescriptorStruct->PrmHandlerExportDescriptors[HandlerIndex].PrmHandlerGuid;
|
||||||
CurrentHandlerContext.Name = (CHAR8 *) CurrentExportDescriptorStruct->PrmHandlerExportDescriptors[HandlerIndex].PrmHandlerName;
|
CurrentHandlerContext.Name = (CHAR8 *)CurrentExportDescriptorStruct->PrmHandlerExportDescriptors[HandlerIndex].PrmHandlerName;
|
||||||
|
|
||||||
if (PrintInformation) {
|
if (PrintInformation) {
|
||||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_HANDLER_NAME), mPrmInfoHiiHandle, CurrentHandlerContext.Name);
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_HANDLER_NAME), mPrmInfoHiiHandle, CurrentHandlerContext.Name);
|
||||||
@ -258,7 +260,7 @@ GatherPrmHandlerInfo (
|
|||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
CurrentHandlerContext.Handler = (PRM_HANDLER *) (UINTN) CurrentHandlerPhysicalAddress;
|
CurrentHandlerContext.Handler = (PRM_HANDLER *)(UINTN)CurrentHandlerPhysicalAddress;
|
||||||
|
|
||||||
if (PrintInformation) {
|
if (PrintInformation) {
|
||||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_HANDLER_PA), mPrmInfoHiiHandle, CurrentHandlerPhysicalAddress);
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_HANDLER_PA), mPrmInfoHiiHandle, CurrentHandlerPhysicalAddress);
|
||||||
@ -272,7 +274,7 @@ GatherPrmHandlerInfo (
|
|||||||
Status = GetContextBuffer (
|
Status = GetContextBuffer (
|
||||||
CurrentHandlerContext.Guid,
|
CurrentHandlerContext.Guid,
|
||||||
CurrentModuleContextBuffers,
|
CurrentModuleContextBuffers,
|
||||||
(CONST PRM_CONTEXT_BUFFER **) &CurrentContextBuffer
|
(CONST PRM_CONTEXT_BUFFER **)&CurrentContextBuffer
|
||||||
);
|
);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
CurrentHandlerContext.StaticDataBuffer = CurrentContextBuffer->StaticDataBuffer;
|
CurrentHandlerContext.StaticDataBuffer = CurrentContextBuffer->StaticDataBuffer;
|
||||||
@ -286,7 +288,7 @@ GatherPrmHandlerInfo (
|
|||||||
NULL,
|
NULL,
|
||||||
STRING_TOKEN (STR_PRMINFO_STATIC_DATA_BUFFER),
|
STRING_TOKEN (STR_PRMINFO_STATIC_DATA_BUFFER),
|
||||||
mPrmInfoHiiHandle,
|
mPrmInfoHiiHandle,
|
||||||
(UINTN) CurrentHandlerContext.StaticDataBuffer
|
(UINTN)CurrentHandlerContext.StaticDataBuffer
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_LINE_BREAK), mPrmInfoHiiHandle);
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_LINE_BREAK), mPrmInfoHiiHandle);
|
||||||
@ -329,7 +331,7 @@ PopulateContextBuffer (
|
|||||||
IN PRM_CONTEXT_BUFFER *ContextBuffer
|
IN PRM_CONTEXT_BUFFER *ContextBuffer
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (HandlerGuid == NULL || ContextBuffer == NULL) {
|
if ((HandlerGuid == NULL) || (ContextBuffer == NULL)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -465,6 +467,7 @@ ExecutePrmHandlerByGuid (
|
|||||||
if (PcdGetBool (PcdPrmInfoPrintHandlerExecutionTime)) {
|
if (PcdGetBool (PcdPrmInfoPrintHandlerExecutionTime)) {
|
||||||
StartTime = GetPerformanceCounter ();
|
StartTime = GetPerformanceCounter ();
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = HandlerContext->Handler (NULL, &CurrentContextBuffer);
|
Status = HandlerContext->Handler (NULL, &CurrentContextBuffer);
|
||||||
if (PcdGetBool (PcdPrmInfoPrintHandlerExecutionTime)) {
|
if (PcdGetBool (PcdPrmInfoPrintHandlerExecutionTime)) {
|
||||||
EndTime = GetPerformanceCounter ();
|
EndTime = GetPerformanceCounter ();
|
||||||
@ -477,11 +480,12 @@ ExecutePrmHandlerByGuid (
|
|||||||
}
|
}
|
||||||
|
|
||||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_HANDLER_EXEC_TIME), mPrmInfoHiiHandle);
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_HANDLER_EXEC_TIME), mPrmInfoHiiHandle);
|
||||||
if (StartTime == 0 && EndTime == 0) {
|
if ((StartTime == 0) && (EndTime == 0)) {
|
||||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_UNKNOWN), mPrmInfoHiiHandle);
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_UNKNOWN), mPrmInfoHiiHandle);
|
||||||
} else {
|
} else {
|
||||||
PrintExecutionTime (GetTimeInNanoSecond (EndTime - StartTime));
|
PrintExecutionTime (GetTimeInNanoSecond (EndTime - StartTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_LINE_BREAK), mPrmInfoHiiHandle);
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_LINE_BREAK), mPrmInfoHiiHandle);
|
||||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_LINE_BREAK), mPrmInfoHiiHandle);
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_LINE_BREAK), mPrmInfoHiiHandle);
|
||||||
} else {
|
} else {
|
||||||
@ -541,7 +545,7 @@ ParseParameterList (
|
|||||||
//
|
//
|
||||||
Status = ShellCommandLineParseEx (mParamList, &Package, &ProblemParam, FALSE, FALSE);
|
Status = ShellCommandLineParseEx (mParamList, &Package, &ProblemParam, FALSE, FALSE);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
|
if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
|
||||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_GEN_PROBLEM), mPrmInfoHiiHandle, APPLICATION_NAME, ProblemParam);
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_GEN_PROBLEM), mPrmInfoHiiHandle, APPLICATION_NAME, ProblemParam);
|
||||||
ReturnStatus = EFI_INVALID_PARAMETER;
|
ReturnStatus = EFI_INVALID_PARAMETER;
|
||||||
FreePool (ProblemParam);
|
FreePool (ProblemParam);
|
||||||
@ -564,7 +568,9 @@ ParseParameterList (
|
|||||||
ArgumentCount = 0, TempNode = Package;
|
ArgumentCount = 0, TempNode = Package;
|
||||||
GetNextNode (Package, TempNode) != Package;
|
GetNextNode (Package, TempNode) != Package;
|
||||||
ArgumentCount++, TempNode = GetNextNode (Package, TempNode)
|
ArgumentCount++, TempNode = GetNextNode (Package, TempNode)
|
||||||
);
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
if (ArgumentCount == 1) {
|
if (ArgumentCount == 1) {
|
||||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_NO_ARG), mPrmInfoHiiHandle, APPLICATION_NAME);
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_NO_ARG), mPrmInfoHiiHandle, APPLICATION_NAME);
|
||||||
@ -635,6 +641,7 @@ ParseParameterList (
|
|||||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_HANDLERS_FOUND), mPrmInfoHiiHandle, mPrmHandlerCount);
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_HANDLERS_FOUND), mPrmInfoHiiHandle, mPrmHandlerCount);
|
||||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_LINE_BREAK), mPrmInfoHiiHandle);
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_LINE_BREAK), mPrmInfoHiiHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
GatherPrmHandlerInfo (PrintHandlerInfo);
|
GatherPrmHandlerInfo (PrintHandlerInfo);
|
||||||
|
|
||||||
if (HandlerGuidStr != NULL) {
|
if (HandlerGuidStr != NULL) {
|
||||||
@ -680,7 +687,7 @@ UefiMain (
|
|||||||
Status = gBS->OpenProtocol (
|
Status = gBS->OpenProtocol (
|
||||||
ImageHandle,
|
ImageHandle,
|
||||||
&gEfiHiiPackageListProtocolGuid,
|
&gEfiHiiPackageListProtocolGuid,
|
||||||
(VOID **) &PackageList,
|
(VOID **)&PackageList,
|
||||||
ImageHandle,
|
ImageHandle,
|
||||||
NULL,
|
NULL,
|
||||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||||
|
@ -13,10 +13,10 @@
|
|||||||
#include <Uefi.h>
|
#include <Uefi.h>
|
||||||
#include <PrmContextBuffer.h>
|
#include <PrmContextBuffer.h>
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined (_MSC_VER)
|
||||||
#define PRM_EXPORT_API __declspec(dllexport)
|
#define PRM_EXPORT_API __declspec(dllexport)
|
||||||
#else
|
#else
|
||||||
#define PRM_EXPORT_API
|
#define PRM_EXPORT_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PRM_HANDLER_NAME_MAXIMUM_LENGTH 128
|
#define PRM_HANDLER_NAME_MAXIMUM_LENGTH 128
|
||||||
@ -38,7 +38,7 @@
|
|||||||
**/
|
**/
|
||||||
typedef
|
typedef
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
(EFIAPI PRM_HANDLER) (
|
(EFIAPI PRM_HANDLER)(
|
||||||
IN VOID *ParameterBuffer OPTIONAL,
|
IN VOID *ParameterBuffer OPTIONAL,
|
||||||
IN PRM_CONTEXT_BUFFER *ContextBuffer OPTIONAL
|
IN PRM_CONTEXT_BUFFER *ContextBuffer OPTIONAL
|
||||||
);
|
);
|
||||||
|
@ -98,8 +98,7 @@ typedef struct {
|
|||||||
// A firmware internal data structure used to track context buffer and
|
// A firmware internal data structure used to track context buffer and
|
||||||
// runtime MMIO range usage across a PRM module.
|
// runtime MMIO range usage across a PRM module.
|
||||||
//
|
//
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
///
|
///
|
||||||
/// The GUID of the PRM module.
|
/// The GUID of the PRM module.
|
||||||
///
|
///
|
||||||
|
@ -41,11 +41,11 @@ typedef struct {
|
|||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined (_MSC_VER)
|
||||||
#define PRM_PACKED_STRUCT(definition) \
|
#define PRM_PACKED_STRUCT(definition) \
|
||||||
__pragma(pack(push, 1)) typedef struct definition __pragma(pack(pop))
|
__pragma(pack(push, 1)) typedef struct definition __pragma(pack(pop))
|
||||||
#elif defined (__GNUC__) || defined (__clang__)
|
#elif defined (__GNUC__) || defined (__clang__)
|
||||||
#define PRM_PACKED_STRUCT(definition) \
|
#define PRM_PACKED_STRUCT(definition) \
|
||||||
typedef struct __attribute__((packed)) definition
|
typedef struct __attribute__((packed)) definition
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -67,6 +67,7 @@ typedef struct {
|
|||||||
PRM_STRING_(Name) \
|
PRM_STRING_(Name) \
|
||||||
} \
|
} \
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
A macro that returns the count of the number of variable-length arguments given.
|
A macro that returns the count of the number of variable-length arguments given.
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#define PRM_HANDLER_EXPORT(Name) \
|
#define PRM_HANDLER_EXPORT(Name) \
|
||||||
STATIC_ASSERT (sizeof (PRM_STRING_(Name)) <= PRM_HANDLER_NAME_MAXIMUM_LENGTH, "The PRM handler exceeds the maximum allowed size of 128."); \
|
STATIC_ASSERT (sizeof (PRM_STRING_(Name)) <= PRM_HANDLER_NAME_MAXIMUM_LENGTH, "The PRM handler exceeds the maximum allowed size of 128."); \
|
||||||
\
|
\
|
||||||
/** \
|
/** \
|
||||||
A Platform Runtime Mechanism (PRM) handler. \
|
A Platform Runtime Mechanism (PRM) handler. \
|
||||||
\
|
\
|
||||||
@param[in] ParameterBuffer A pointer to the PRM handler parameter buffer \
|
@param[in] ParameterBuffer A pointer to the PRM handler parameter buffer \
|
||||||
@ -35,7 +35,7 @@
|
|||||||
@retval EFI_STATUS The PRM handler executed successfully. \
|
@retval EFI_STATUS The PRM handler executed successfully. \
|
||||||
@retval Others An error occurred in the PRM handler. \
|
@retval Others An error occurred in the PRM handler. \
|
||||||
\
|
\
|
||||||
**/ \
|
**/ \
|
||||||
EFI_STATUS \
|
EFI_STATUS \
|
||||||
PRM_EXPORT_API \
|
PRM_EXPORT_API \
|
||||||
EFIAPI \
|
EFIAPI \
|
||||||
|
@ -22,8 +22,7 @@ typedef struct _PRM_CONFIG_PROTOCOL PRM_CONFIG_PROTOCOL;
|
|||||||
#define PRM_CONFIG_PROTOCOL_SIGNATURE SIGNATURE_32('P','M','C','P')
|
#define PRM_CONFIG_PROTOCOL_SIGNATURE SIGNATURE_32('P','M','C','P')
|
||||||
#define PRM_CONFIG_PROTOCOL_VERSION 1
|
#define PRM_CONFIG_PROTOCOL_VERSION 1
|
||||||
|
|
||||||
struct _PRM_CONFIG_PROTOCOL
|
struct _PRM_CONFIG_PROTOCOL {
|
||||||
{
|
|
||||||
PRM_MODULE_CONTEXT_BUFFERS ModuleContextBuffers;
|
PRM_MODULE_CONTEXT_BUFFERS ModuleContextBuffers;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ FindContextBufferInModuleBuffers (
|
|||||||
|
|
||||||
DEBUG ((DEBUG_INFO, " %a %a - Entry.\n", _DBGMSGID_, __FUNCTION__));
|
DEBUG ((DEBUG_INFO, " %a %a - Entry.\n", _DBGMSGID_, __FUNCTION__));
|
||||||
|
|
||||||
if (HandlerGuid == NULL || ModuleContextBuffers == NULL || ContextBuffer == NULL) {
|
if ((HandlerGuid == NULL) || (ModuleContextBuffers == NULL) || (ContextBuffer == NULL)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,9 +91,10 @@ GetModuleContextBuffers (
|
|||||||
|
|
||||||
DEBUG ((DEBUG_INFO, " %a %a - Entry.\n", _DBGMSGID_, __FUNCTION__));
|
DEBUG ((DEBUG_INFO, " %a %a - Entry.\n", _DBGMSGID_, __FUNCTION__));
|
||||||
|
|
||||||
if (Guid == NULL || PrmModuleContextBuffers == NULL) {
|
if ((Guid == NULL) || (PrmModuleContextBuffers == NULL)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
*PrmModuleContextBuffers = NULL;
|
*PrmModuleContextBuffers = NULL;
|
||||||
|
|
||||||
Status = gBS->LocateHandleBuffer (
|
Status = gBS->LocateHandleBuffer (
|
||||||
@ -108,10 +109,10 @@ GetModuleContextBuffers (
|
|||||||
Status = gBS->HandleProtocol (
|
Status = gBS->HandleProtocol (
|
||||||
HandleBuffer[Index],
|
HandleBuffer[Index],
|
||||||
&gPrmConfigProtocolGuid,
|
&gPrmConfigProtocolGuid,
|
||||||
(VOID **) &PrmConfigProtocol
|
(VOID **)&PrmConfigProtocol
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
if (EFI_ERROR (Status) || PrmConfigProtocol == NULL) {
|
if (EFI_ERROR (Status) || (PrmConfigProtocol == NULL)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,9 +178,10 @@ GetContextBuffer (
|
|||||||
|
|
||||||
DEBUG ((DEBUG_INFO, " %a %a - Entry.\n", _DBGMSGID_, __FUNCTION__));
|
DEBUG ((DEBUG_INFO, " %a %a - Entry.\n", _DBGMSGID_, __FUNCTION__));
|
||||||
|
|
||||||
if (PrmHandlerGuid == NULL || PrmContextBuffer == NULL) {
|
if ((PrmHandlerGuid == NULL) || (PrmContextBuffer == NULL)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
*PrmContextBuffer = NULL;
|
*PrmContextBuffer = NULL;
|
||||||
|
|
||||||
if (PrmModuleContextBuffers == NULL) {
|
if (PrmModuleContextBuffers == NULL) {
|
||||||
@ -190,6 +192,7 @@ GetContextBuffer (
|
|||||||
} else {
|
} else {
|
||||||
ContextBuffers = PrmModuleContextBuffers;
|
ContextBuffers = PrmModuleContextBuffers;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = FindContextBufferInModuleBuffers (PrmHandlerGuid, ContextBuffers, PrmContextBuffer);
|
Status = FindContextBufferInModuleBuffers (PrmHandlerGuid, ContextBuffers, PrmContextBuffer);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -30,13 +30,13 @@
|
|||||||
#define UNIT_TEST_NAME "PRM Context Buffer Library Unit Test"
|
#define UNIT_TEST_NAME "PRM Context Buffer Library Unit Test"
|
||||||
#define UNIT_TEST_VERSION "0.1"
|
#define UNIT_TEST_VERSION "0.1"
|
||||||
|
|
||||||
///=== TEST DATA ==================================================================================
|
/// === TEST DATA ==================================================================================
|
||||||
|
|
||||||
EFI_HANDLE mTestProtocolHandle;
|
EFI_HANDLE mTestProtocolHandle;
|
||||||
|
|
||||||
//*----------------------------------------------------------------------------------*
|
// *----------------------------------------------------------------------------------*
|
||||||
//* Context Structures *
|
// * Context Structures *
|
||||||
//*----------------------------------------------------------------------------------*
|
// *----------------------------------------------------------------------------------*
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PRM_MODULE_CONTEXT_BUFFERS *InstallationStructure;
|
PRM_MODULE_CONTEXT_BUFFERS *InstallationStructure;
|
||||||
EFI_HANDLE Handle;
|
EFI_HANDLE Handle;
|
||||||
@ -53,9 +53,9 @@ typedef struct {
|
|||||||
EFI_STATUS ExpectedStatus;
|
EFI_STATUS ExpectedStatus;
|
||||||
} PRM_CONTEXT_BUFFER_TEST_CONTEXT;
|
} PRM_CONTEXT_BUFFER_TEST_CONTEXT;
|
||||||
|
|
||||||
//*----------------------------------------------------------------------------------*
|
// *----------------------------------------------------------------------------------*
|
||||||
//* Test GUIDs *
|
// * Test GUIDs *
|
||||||
//*----------------------------------------------------------------------------------*
|
// *----------------------------------------------------------------------------------*
|
||||||
|
|
||||||
// {52960b90-2f3a-4917-b91a-ed5f599a8809}
|
// {52960b90-2f3a-4917-b91a-ed5f599a8809}
|
||||||
#define HANDLER_TEST_GUID_1 {0x52960b90, 0x2f3a, 0x4917, { 0xb9, 0x1a, 0xed, 0x5f, 0x59, 0x9a, 0x88, 0x09 }}
|
#define HANDLER_TEST_GUID_1 {0x52960b90, 0x2f3a, 0x4917, { 0xb9, 0x1a, 0xed, 0x5f, 0x59, 0x9a, 0x88, 0x09 }}
|
||||||
@ -85,9 +85,9 @@ EFI_GUID mModuleTestGuid3 = MODULE_TEST_GUID_3;
|
|||||||
#define NEGATIVE_TEST_GUID {0x4a941a9c, 0x9dcf, 0x471b, {0x94, 0xb5, 0xd9, 0xe2, 0xd8, 0xc6, 0x4a, 0x1b }}
|
#define NEGATIVE_TEST_GUID {0x4a941a9c, 0x9dcf, 0x471b, {0x94, 0xb5, 0xd9, 0xe2, 0xd8, 0xc6, 0x4a, 0x1b }}
|
||||||
EFI_GUID mNegativeTestGuid = NEGATIVE_TEST_GUID;
|
EFI_GUID mNegativeTestGuid = NEGATIVE_TEST_GUID;
|
||||||
|
|
||||||
//*----------------------------------------------------------------------------------*
|
// *----------------------------------------------------------------------------------*
|
||||||
//* PRM Static Test Structures *
|
// * PRM Static Test Structures *
|
||||||
//*----------------------------------------------------------------------------------*
|
// *----------------------------------------------------------------------------------*
|
||||||
|
|
||||||
PRM_DATA_BUFFER mTestStaticDataBuffer1 = {
|
PRM_DATA_BUFFER mTestStaticDataBuffer1 = {
|
||||||
{
|
{
|
||||||
@ -145,12 +145,11 @@ PRM_MODULE_CONTEXT_BUFFERS mTestPrmModuleContextBuffers3 = {
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// *----------------------------------------------------------------------------------*
|
||||||
|
// * Test Contexts *
|
||||||
|
// *----------------------------------------------------------------------------------*
|
||||||
|
|
||||||
//*----------------------------------------------------------------------------------*
|
// * Searches by module GUID *
|
||||||
//* Test Contexts *
|
|
||||||
//*----------------------------------------------------------------------------------*
|
|
||||||
|
|
||||||
//* Searches by module GUID *
|
|
||||||
// +--------------------------------+--------+----------------+--------------------+--------------------+--------------------+
|
// +--------------------------------+--------+----------------+--------------------+--------------------+--------------------+
|
||||||
// + InstallationStructure | Handle | GuidSearchType | Guid | ExpectedModuleGuid | ExpectedStatus |
|
// + InstallationStructure | Handle | GuidSearchType | Guid | ExpectedModuleGuid | ExpectedStatus |
|
||||||
// +--------------------------------+--------+----------------+--------------------+--------------------+--------------------+
|
// +--------------------------------+--------+----------------+--------------------+--------------------+--------------------+
|
||||||
@ -160,7 +159,7 @@ PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers02 = { &mTestPrmModuleContextBuf
|
|||||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers03 = { &mTestPrmModuleContextBuffers3, NULL, ByModuleGuid, &mNegativeTestGuid, &gZeroGuid, EFI_NOT_FOUND };
|
PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers03 = { &mTestPrmModuleContextBuffers3, NULL, ByModuleGuid, &mNegativeTestGuid, &gZeroGuid, EFI_NOT_FOUND };
|
||||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers04 = { &mTestPrmModuleContextBuffers1, NULL, ByModuleGuid, &gZeroGuid, &gZeroGuid, EFI_NOT_FOUND };
|
PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers04 = { &mTestPrmModuleContextBuffers1, NULL, ByModuleGuid, &gZeroGuid, &gZeroGuid, EFI_NOT_FOUND };
|
||||||
|
|
||||||
//* Searches by handler GUID *
|
// * Searches by handler GUID *
|
||||||
// +--------------------------------+--------+----------------+--------------------+--------------------+--------------------+
|
// +--------------------------------+--------+----------------+--------------------+--------------------+--------------------+
|
||||||
// + InstallationStructure | Handle | GuidSearchType | Guid | ExpectedModuleGuid | ExpectedStatus |
|
// + InstallationStructure | Handle | GuidSearchType | Guid | ExpectedModuleGuid | ExpectedStatus |
|
||||||
// +--------------------------------+--------+----------------+--------------------+--------------------+--------------------+
|
// +--------------------------------+--------+----------------+--------------------+--------------------+--------------------+
|
||||||
@ -208,13 +207,13 @@ PRM_CONTEXT_BUFFER_TEST_CONTEXT *mContextBufferArray[] = {
|
|||||||
&mContextBuffer05
|
&mContextBuffer05
|
||||||
};
|
};
|
||||||
|
|
||||||
///=== HELPER FUNCTIONS ===========================================================================
|
/// === HELPER FUNCTIONS ===========================================================================
|
||||||
|
|
||||||
// None
|
// None
|
||||||
|
|
||||||
///=== TEST CASES =================================================================================
|
/// === TEST CASES =================================================================================
|
||||||
|
|
||||||
///===== BASIC SUITE ==================================================
|
/// ===== BASIC SUITE ==================================================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Verifies that passing NULL arguments to all library functions fails with EFI_INVALID_PARAMETER.
|
Verifies that passing NULL arguments to all library functions fails with EFI_INVALID_PARAMETER.
|
||||||
@ -254,7 +253,7 @@ NullPointerArgumentsShouldFailGracefully (
|
|||||||
return UNIT_TEST_PASSED;
|
return UNIT_TEST_PASSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
///===== FUNCTIONAL CORRECTNESS SUITE ==================================================
|
/// ===== FUNCTIONAL CORRECTNESS SUITE ==================================================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Functional Correctness pre-requisite function.
|
Functional Correctness pre-requisite function.
|
||||||
@ -284,7 +283,7 @@ InitializeFunctionalCorrectness (
|
|||||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT *TestContext;
|
PRM_CONTEXT_BUFFERS_TEST_CONTEXT *TestContext;
|
||||||
|
|
||||||
UT_ASSERT_NOT_NULL (Context);
|
UT_ASSERT_NOT_NULL (Context);
|
||||||
TestContext = (PRM_CONTEXT_BUFFERS_TEST_CONTEXT *) Context;
|
TestContext = (PRM_CONTEXT_BUFFERS_TEST_CONTEXT *)Context;
|
||||||
ModuleContextBuffers = TestContext->InstallationStructure;
|
ModuleContextBuffers = TestContext->InstallationStructure;
|
||||||
|
|
||||||
PrmConfigProtocol = AllocateZeroPool (sizeof (*PrmConfigProtocol));
|
PrmConfigProtocol = AllocateZeroPool (sizeof (*PrmConfigProtocol));
|
||||||
@ -300,7 +299,7 @@ InitializeFunctionalCorrectness (
|
|||||||
&TestContext->Handle,
|
&TestContext->Handle,
|
||||||
&gPrmConfigProtocolGuid,
|
&gPrmConfigProtocolGuid,
|
||||||
EFI_NATIVE_INTERFACE,
|
EFI_NATIVE_INTERFACE,
|
||||||
(VOID *) PrmConfigProtocol
|
(VOID *)PrmConfigProtocol
|
||||||
);
|
);
|
||||||
UT_ASSERT_NOT_EFI_ERROR (Status);
|
UT_ASSERT_NOT_EFI_ERROR (Status);
|
||||||
|
|
||||||
@ -334,12 +333,12 @@ DeInitializeFunctionalCorrectness (
|
|||||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT *TestContext;
|
PRM_CONTEXT_BUFFERS_TEST_CONTEXT *TestContext;
|
||||||
|
|
||||||
UT_ASSERT_NOT_NULL (Context);
|
UT_ASSERT_NOT_NULL (Context);
|
||||||
TestContext = (PRM_CONTEXT_BUFFERS_TEST_CONTEXT *) Context;
|
TestContext = (PRM_CONTEXT_BUFFERS_TEST_CONTEXT *)Context;
|
||||||
|
|
||||||
Status = gBS->HandleProtocol (
|
Status = gBS->HandleProtocol (
|
||||||
TestContext->Handle,
|
TestContext->Handle,
|
||||||
&gPrmConfigProtocolGuid,
|
&gPrmConfigProtocolGuid,
|
||||||
(VOID **) &PrmConfigProtocol
|
(VOID **)&PrmConfigProtocol
|
||||||
);
|
);
|
||||||
UT_ASSERT_NOT_EFI_ERROR (Status);
|
UT_ASSERT_NOT_EFI_ERROR (Status);
|
||||||
|
|
||||||
@ -381,7 +380,7 @@ VerifyGetModuleContextBuffers (
|
|||||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT *TestContext;
|
PRM_CONTEXT_BUFFERS_TEST_CONTEXT *TestContext;
|
||||||
|
|
||||||
ContextBuffers = NULL;
|
ContextBuffers = NULL;
|
||||||
TestContext = (PRM_CONTEXT_BUFFERS_TEST_CONTEXT *) Context;
|
TestContext = (PRM_CONTEXT_BUFFERS_TEST_CONTEXT *)Context;
|
||||||
|
|
||||||
Status = GetModuleContextBuffers (TestContext->GuidSearchType, TestContext->Guid, &ContextBuffers);
|
Status = GetModuleContextBuffers (TestContext->GuidSearchType, TestContext->Guid, &ContextBuffers);
|
||||||
UT_ASSERT_STATUS_EQUAL (Status, TestContext->ExpectedStatus);
|
UT_ASSERT_STATUS_EQUAL (Status, TestContext->ExpectedStatus);
|
||||||
@ -393,7 +392,7 @@ VerifyGetModuleContextBuffers (
|
|||||||
__FUNCTION__,
|
__FUNCTION__,
|
||||||
((TestContext->GuidSearchType == ByModuleGuid) ? "module" : "handler"),
|
((TestContext->GuidSearchType == ByModuleGuid) ? "module" : "handler"),
|
||||||
TestContext->Guid,
|
TestContext->Guid,
|
||||||
(UINTN) ContextBuffers
|
(UINTN)ContextBuffers
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -425,7 +424,7 @@ VerifyFindContextBufferInModuleBuffers (
|
|||||||
|
|
||||||
ContextBuffers = NULL;
|
ContextBuffers = NULL;
|
||||||
FoundContextBuffer = NULL;
|
FoundContextBuffer = NULL;
|
||||||
TestContext = (PRM_CONTEXT_BUFFER_TEST_CONTEXT *) Context;
|
TestContext = (PRM_CONTEXT_BUFFER_TEST_CONTEXT *)Context;
|
||||||
|
|
||||||
Status = FindContextBufferInModuleBuffers (TestContext->HandlerGuid, TestContext->ContextBuffers, &FoundContextBuffer);
|
Status = FindContextBufferInModuleBuffers (TestContext->HandlerGuid, TestContext->ContextBuffers, &FoundContextBuffer);
|
||||||
UT_ASSERT_STATUS_EQUAL (Status, TestContext->ExpectedStatus);
|
UT_ASSERT_STATUS_EQUAL (Status, TestContext->ExpectedStatus);
|
||||||
@ -471,7 +470,7 @@ VerifyGetContextBuffer (
|
|||||||
|
|
||||||
ContextBuffers = NULL;
|
ContextBuffers = NULL;
|
||||||
FoundContextBuffer = NULL;
|
FoundContextBuffer = NULL;
|
||||||
TestContext = (PRM_CONTEXT_BUFFER_TEST_CONTEXT *) Context;
|
TestContext = (PRM_CONTEXT_BUFFER_TEST_CONTEXT *)Context;
|
||||||
|
|
||||||
Status = GetContextBuffer (TestContext->HandlerGuid, TestContext->ContextBuffers, &FoundContextBuffer);
|
Status = GetContextBuffer (TestContext->HandlerGuid, TestContext->ContextBuffers, &FoundContextBuffer);
|
||||||
UT_ASSERT_STATUS_EQUAL (Status, TestContext->ExpectedStatus);
|
UT_ASSERT_STATUS_EQUAL (Status, TestContext->ExpectedStatus);
|
||||||
@ -484,7 +483,7 @@ VerifyGetContextBuffer (
|
|||||||
return UNIT_TEST_PASSED;
|
return UNIT_TEST_PASSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
///=== TEST ENGINE ================================================================================
|
/// === TEST ENGINE ================================================================================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Entry point for the PRM Context Buffer Library unit tests.
|
Entry point for the PRM Context Buffer Library unit tests.
|
||||||
@ -496,7 +495,9 @@ VerifyGetContextBuffer (
|
|||||||
@retval other Some error occurred when executing this entry point.
|
@retval other Some error occurred when executing this entry point.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
int main ()
|
int
|
||||||
|
main (
|
||||||
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
@ -640,8 +641,7 @@ int main ()
|
|||||||
Status = RunAllTestSuites (Framework);
|
Status = RunAllTestSuites (Framework);
|
||||||
|
|
||||||
EXIT:
|
EXIT:
|
||||||
if (Framework)
|
if (Framework) {
|
||||||
{
|
|
||||||
FreeUnitTestFramework (Framework);
|
FreeUnitTestFramework (Framework);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ GetNextPrmModuleEntry (
|
|||||||
} else {
|
} else {
|
||||||
CurrentListEntry = NULL;
|
CurrentListEntry = NULL;
|
||||||
CurrentListEntry = CR (*ModuleImageContext, PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY, Context, PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY_SIGNATURE);
|
CurrentListEntry = CR (*ModuleImageContext, PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY, Context, PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY_SIGNATURE);
|
||||||
if (CurrentListEntry == NULL || CurrentListEntry->Signature != PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY_SIGNATURE) {
|
if ((CurrentListEntry == NULL) || (CurrentListEntry->Signature != PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY_SIGNATURE)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,12 +100,13 @@ CreateNewPrmModuleImageContextListEntry (
|
|||||||
if (PrmModuleImageContextListEntry == NULL) {
|
if (PrmModuleImageContextListEntry == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_INFO,
|
DEBUG_INFO,
|
||||||
" %a %a: Allocated PrmModuleImageContextListEntry at 0x%x of size 0x%x bytes.\n",
|
" %a %a: Allocated PrmModuleImageContextListEntry at 0x%x of size 0x%x bytes.\n",
|
||||||
_DBGMSGID_,
|
_DBGMSGID_,
|
||||||
__FUNCTION__,
|
__FUNCTION__,
|
||||||
(UINTN) PrmModuleImageContextListEntry,
|
(UINTN)PrmModuleImageContextListEntry,
|
||||||
sizeof (*PrmModuleImageContextListEntry)
|
sizeof (*PrmModuleImageContextListEntry)
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -234,7 +235,7 @@ DiscoverPrmModules (
|
|||||||
Status = gBS->HandleProtocol (
|
Status = gBS->HandleProtocol (
|
||||||
HandleBuffer[Index],
|
HandleBuffer[Index],
|
||||||
&gEfiLoadedImageProtocolGuid,
|
&gEfiLoadedImageProtocolGuid,
|
||||||
(VOID **) &LoadedImageProtocol
|
(VOID **)&LoadedImageProtocol
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
continue;
|
continue;
|
||||||
@ -249,16 +250,17 @@ DiscoverPrmModules (
|
|||||||
TempPrmModuleImageContext.PeCoffImageContext.ImageRead = PeCoffLoaderImageReadFromMemory;
|
TempPrmModuleImageContext.PeCoffImageContext.ImageRead = PeCoffLoaderImageReadFromMemory;
|
||||||
|
|
||||||
Status = PeCoffLoaderGetImageInfo (&TempPrmModuleImageContext.PeCoffImageContext);
|
Status = PeCoffLoaderGetImageInfo (&TempPrmModuleImageContext.PeCoffImageContext);
|
||||||
if (EFI_ERROR (Status) || TempPrmModuleImageContext.PeCoffImageContext.ImageError != IMAGE_ERROR_SUCCESS) {
|
if (EFI_ERROR (Status) || (TempPrmModuleImageContext.PeCoffImageContext.ImageError != IMAGE_ERROR_SUCCESS)) {
|
||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_WARN,
|
DEBUG_WARN,
|
||||||
"%a %a: ImageHandle 0x%016lx is not a valid PE/COFF image. It cannot be considered a PRM module.\n",
|
"%a %a: ImageHandle 0x%016lx is not a valid PE/COFF image. It cannot be considered a PRM module.\n",
|
||||||
_DBGMSGID_,
|
_DBGMSGID_,
|
||||||
__FUNCTION__,
|
__FUNCTION__,
|
||||||
(EFI_PHYSICAL_ADDRESS) (UINTN) LoadedImageProtocol->ImageBase
|
(EFI_PHYSICAL_ADDRESS)(UINTN)LoadedImageProtocol->ImageBase
|
||||||
));
|
));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TempPrmModuleImageContext.PeCoffImageContext.IsTeImage) {
|
if (TempPrmModuleImageContext.PeCoffImageContext.IsTeImage) {
|
||||||
// A PRM Module is not allowed to be a TE image
|
// A PRM Module is not allowed to be a TE image
|
||||||
continue;
|
continue;
|
||||||
@ -280,9 +282,10 @@ DiscoverPrmModules (
|
|||||||
&TempPrmModuleImageContext.PeCoffImageContext,
|
&TempPrmModuleImageContext.PeCoffImageContext,
|
||||||
&TempPrmModuleImageContext.ExportDescriptor
|
&TempPrmModuleImageContext.ExportDescriptor
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status) || TempPrmModuleImageContext.ExportDescriptor == NULL) {
|
if (EFI_ERROR (Status) || (TempPrmModuleImageContext.ExportDescriptor == NULL)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// A PRM Module Export Descriptor was successfully found, this is considered a PRM Module.
|
// A PRM Module Export Descriptor was successfully found, this is considered a PRM Module.
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -292,6 +295,7 @@ DiscoverPrmModules (
|
|||||||
if (PrmModuleImageContextListEntry == NULL) {
|
if (PrmModuleImageContextListEntry == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyMem (
|
CopyMem (
|
||||||
&PrmModuleImageContextListEntry->Context,
|
&PrmModuleImageContextListEntry->Context,
|
||||||
&TempPrmModuleImageContext,
|
&TempPrmModuleImageContext,
|
||||||
@ -306,6 +310,7 @@ DiscoverPrmModules (
|
|||||||
if (HandlerCount != NULL) {
|
if (HandlerCount != NULL) {
|
||||||
*HandlerCount = PrmHandlerCount;
|
*HandlerCount = PrmHandlerCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ModuleCount != NULL) {
|
if (ModuleCount != NULL) {
|
||||||
*ModuleCount = PrmModuleCount;
|
*ModuleCount = PrmModuleCount;
|
||||||
}
|
}
|
||||||
|
@ -27,9 +27,9 @@
|
|||||||
#define UNIT_TEST_NAME "PRM Module Discovery Library Unit Test"
|
#define UNIT_TEST_NAME "PRM Module Discovery Library Unit Test"
|
||||||
#define UNIT_TEST_VERSION "0.1"
|
#define UNIT_TEST_VERSION "0.1"
|
||||||
|
|
||||||
///=== TEST CASES =================================================================================
|
/// === TEST CASES =================================================================================
|
||||||
|
|
||||||
///===== CREATE NEW PRM MODULE IMAGE CONTEXT LIST ENTRY TESTS SUITE ==================================================
|
/// ===== CREATE NEW PRM MODULE IMAGE CONTEXT LIST ENTRY TESTS SUITE ==================================================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Verifies that the buffer returned can be deallocated.
|
Verifies that the buffer returned can be deallocated.
|
||||||
@ -119,7 +119,7 @@ PrmModuleImageContextListEntryImageContextShouldBeZeroed (
|
|||||||
return UNIT_TEST_PASSED;
|
return UNIT_TEST_PASSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
///=== TEST ENGINE ================================================================================
|
/// === TEST ENGINE ================================================================================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Entry point for the PRM Context Buffer Library unit tests.
|
Entry point for the PRM Context Buffer Library unit tests.
|
||||||
@ -131,7 +131,9 @@ PrmModuleImageContextListEntryImageContextShouldBeZeroed (
|
|||||||
@retval other Some error occurred when executing this entry point.
|
@retval other Some error occurred when executing this entry point.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
int main ()
|
int
|
||||||
|
main (
|
||||||
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UNIT_TEST_FRAMEWORK_HANDLE Framework;
|
UNIT_TEST_FRAMEWORK_HANDLE Framework;
|
||||||
@ -200,8 +202,7 @@ int main ()
|
|||||||
Status = RunAllTestSuites (Framework);
|
Status = RunAllTestSuites (Framework);
|
||||||
|
|
||||||
EXIT:
|
EXIT:
|
||||||
if (Framework)
|
if (Framework) {
|
||||||
{
|
|
||||||
FreeUnitTestFramework (Framework);
|
FreeUnitTestFramework (Framework);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,10 +53,11 @@ GetPrmModuleExportDescriptorTable (
|
|||||||
|
|
||||||
DEBUG ((DEBUG_INFO, "%a %a - Entry.\n", _DBGMSGID_, __FUNCTION__));
|
DEBUG ((DEBUG_INFO, "%a %a - Entry.\n", _DBGMSGID_, __FUNCTION__));
|
||||||
|
|
||||||
if (ImageExportDirectory == NULL ||
|
if ((ImageExportDirectory == NULL) ||
|
||||||
PeCoffLoaderImageContext == NULL ||
|
(PeCoffLoaderImageContext == NULL) ||
|
||||||
PeCoffLoaderImageContext->ImageAddress == 0 ||
|
(PeCoffLoaderImageContext->ImageAddress == 0) ||
|
||||||
ExportDescriptor == NULL) {
|
(ExportDescriptor == NULL))
|
||||||
|
{
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,12 +75,12 @@ GetPrmModuleExportDescriptorTable (
|
|||||||
// The export name pointer table and export ordinal table form two parallel arrays associated by index.
|
// The export name pointer table and export ordinal table form two parallel arrays associated by index.
|
||||||
//
|
//
|
||||||
CurrentImageAddress = PeCoffLoaderImageContext->ImageAddress;
|
CurrentImageAddress = PeCoffLoaderImageContext->ImageAddress;
|
||||||
ExportAddressTable = (UINT32 *) ((UINTN) CurrentImageAddress + ImageExportDirectory->AddressOfFunctions);
|
ExportAddressTable = (UINT32 *)((UINTN)CurrentImageAddress + ImageExportDirectory->AddressOfFunctions);
|
||||||
ExportNamePointerTable = (UINT32 *) ((UINTN) CurrentImageAddress + ImageExportDirectory->AddressOfNames);
|
ExportNamePointerTable = (UINT32 *)((UINTN)CurrentImageAddress + ImageExportDirectory->AddressOfNames);
|
||||||
OrdinalTable = (UINT16 *) ((UINTN) CurrentImageAddress + ImageExportDirectory->AddressOfNameOrdinals);
|
OrdinalTable = (UINT16 *)((UINTN)CurrentImageAddress + ImageExportDirectory->AddressOfNameOrdinals);
|
||||||
|
|
||||||
for (Index = 0; Index < ImageExportDirectory->NumberOfNames; Index++) {
|
for (Index = 0; Index < ImageExportDirectory->NumberOfNames; Index++) {
|
||||||
CurrentExportName = (CONST CHAR8 *) ((UINTN) CurrentImageAddress + ExportNamePointerTable[Index]);
|
CurrentExportName = (CONST CHAR8 *)((UINTN)CurrentImageAddress + ExportNamePointerTable[Index]);
|
||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_INFO,
|
DEBUG_INFO,
|
||||||
" %a %a: Export Name[0x%x] - %a.\n",
|
" %a %a: Export Name[0x%x] - %a.\n",
|
||||||
@ -90,10 +91,11 @@ GetPrmModuleExportDescriptorTable (
|
|||||||
));
|
));
|
||||||
if (
|
if (
|
||||||
AsciiStrnCmp (
|
AsciiStrnCmp (
|
||||||
PRM_STRING(PRM_MODULE_EXPORT_DESCRIPTOR_NAME),
|
PRM_STRING (PRM_MODULE_EXPORT_DESCRIPTOR_NAME),
|
||||||
CurrentExportName,
|
CurrentExportName,
|
||||||
AsciiStrLen (PRM_STRING(PRM_MODULE_EXPORT_DESCRIPTOR_NAME))
|
AsciiStrLen (PRM_STRING (PRM_MODULE_EXPORT_DESCRIPTOR_NAME))
|
||||||
) == 0) {
|
) == 0)
|
||||||
|
{
|
||||||
PrmModuleExportDescriptorOrdinal = OrdinalTable[Index];
|
PrmModuleExportDescriptorOrdinal = OrdinalTable[Index];
|
||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_INFO,
|
DEBUG_INFO,
|
||||||
@ -106,19 +108,21 @@ GetPrmModuleExportDescriptorTable (
|
|||||||
DEBUG ((DEBUG_ERROR, "%a %a: The PRM Module Export Descriptor ordinal value is invalid.\n", _DBGMSGID_, __FUNCTION__));
|
DEBUG ((DEBUG_ERROR, "%a %a: The PRM Module Export Descriptor ordinal value is invalid.\n", _DBGMSGID_, __FUNCTION__));
|
||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
TempExportDescriptor = (PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT *) ((UINTN) CurrentImageAddress + ExportAddressTable[PrmModuleExportDescriptorOrdinal]);
|
|
||||||
|
TempExportDescriptor = (PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT *)((UINTN)CurrentImageAddress + ExportAddressTable[PrmModuleExportDescriptorOrdinal]);
|
||||||
if (TempExportDescriptor->Header.Signature == PRM_MODULE_EXPORT_DESCRIPTOR_SIGNATURE) {
|
if (TempExportDescriptor->Header.Signature == PRM_MODULE_EXPORT_DESCRIPTOR_SIGNATURE) {
|
||||||
*ExportDescriptor = TempExportDescriptor;
|
*ExportDescriptor = TempExportDescriptor;
|
||||||
DEBUG ((DEBUG_INFO, " %a %a: PRM Module Export Descriptor found at 0x%x.\n", _DBGMSGID_, __FUNCTION__, (UINTN) ExportDescriptor));
|
DEBUG ((DEBUG_INFO, " %a %a: PRM Module Export Descriptor found at 0x%x.\n", _DBGMSGID_, __FUNCTION__, (UINTN)ExportDescriptor));
|
||||||
} else {
|
} else {
|
||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_INFO,
|
DEBUG_INFO,
|
||||||
" %a %a: PRM Module Export Descriptor found at 0x%x but signature check failed.\n",
|
" %a %a: PRM Module Export Descriptor found at 0x%x but signature check failed.\n",
|
||||||
_DBGMSGID_,
|
_DBGMSGID_,
|
||||||
__FUNCTION__,
|
__FUNCTION__,
|
||||||
(UINTN) TempExportDescriptor
|
(UINTN)TempExportDescriptor
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG ((DEBUG_INFO, " %a %a: Exiting export iteration since export descriptor found.\n", _DBGMSGID_, __FUNCTION__));
|
DEBUG ((DEBUG_INFO, " %a %a: Exiting export iteration since export descriptor found.\n", _DBGMSGID_, __FUNCTION__));
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -156,7 +160,7 @@ GetExportDirectoryInPeCoffImage (
|
|||||||
EFI_IMAGE_DATA_DIRECTORY *DirectoryEntry;
|
EFI_IMAGE_DATA_DIRECTORY *DirectoryEntry;
|
||||||
EFI_IMAGE_EXPORT_DIRECTORY *ExportDirectory;
|
EFI_IMAGE_EXPORT_DIRECTORY *ExportDirectory;
|
||||||
|
|
||||||
if (Image == NULL || PeCoffLoaderImageContext == NULL || ImageExportDirectory == NULL) {
|
if ((Image == NULL) || (PeCoffLoaderImageContext == NULL) || (ImageExportDirectory == NULL)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,8 +199,8 @@ GetExportDirectoryInPeCoffImage (
|
|||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
OptionalHeaderPtrUnion.Pe32 = (EFI_IMAGE_NT_HEADERS32 *) (
|
OptionalHeaderPtrUnion.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)(
|
||||||
(UINTN) Image +
|
(UINTN)Image +
|
||||||
PeCoffLoaderImageContext->PeCoffHeaderOffset
|
PeCoffLoaderImageContext->PeCoffHeaderOffset
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -213,43 +217,44 @@ GetExportDirectoryInPeCoffImage (
|
|||||||
// Use the PE32 offset to get the Export Directory Entry
|
// Use the PE32 offset to get the Export Directory Entry
|
||||||
//
|
//
|
||||||
NumberOfRvaAndSizes = OptionalHeaderPtrUnion.Pe32->OptionalHeader.NumberOfRvaAndSizes;
|
NumberOfRvaAndSizes = OptionalHeaderPtrUnion.Pe32->OptionalHeader.NumberOfRvaAndSizes;
|
||||||
DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *) &(OptionalHeaderPtrUnion.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_EXPORT]);
|
DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(OptionalHeaderPtrUnion.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_EXPORT]);
|
||||||
} else if (OptionalHeaderPtrUnion.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {
|
} else if (OptionalHeaderPtrUnion.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {
|
||||||
//
|
//
|
||||||
// Use the PE32+ offset get the Export Directory Entry
|
// Use the PE32+ offset get the Export Directory Entry
|
||||||
//
|
//
|
||||||
NumberOfRvaAndSizes = OptionalHeaderPtrUnion.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;
|
NumberOfRvaAndSizes = OptionalHeaderPtrUnion.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;
|
||||||
DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *) &(OptionalHeaderPtrUnion.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_EXPORT]);
|
DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(OptionalHeaderPtrUnion.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_EXPORT]);
|
||||||
} else {
|
} else {
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_EXPORT || DirectoryEntry->VirtualAddress == 0) {
|
if ((NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_EXPORT) || (DirectoryEntry->VirtualAddress == 0)) {
|
||||||
//
|
//
|
||||||
// The export directory is not present
|
// The export directory is not present
|
||||||
//
|
//
|
||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
} else if (((UINT32) (~0) - DirectoryEntry->VirtualAddress) < DirectoryEntry->Size) {
|
} else if (((UINT32)(~0) - DirectoryEntry->VirtualAddress) < DirectoryEntry->Size) {
|
||||||
//
|
//
|
||||||
// The directory address overflows
|
// The directory address overflows
|
||||||
//
|
//
|
||||||
DEBUG ((DEBUG_ERROR, "%a %a: The export directory entry in this image results in overflow.\n", _DBGMSGID_, __FUNCTION__));
|
DEBUG ((DEBUG_ERROR, "%a %a: The export directory entry in this image results in overflow.\n", _DBGMSGID_, __FUNCTION__));
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
} else {
|
} else {
|
||||||
DEBUG ((DEBUG_INFO, "%a %a: Export Directory Entry found in the image at 0x%x.\n", _DBGMSGID_, __FUNCTION__, (UINTN) OptionalHeaderPtrUnion.Pe32));
|
DEBUG ((DEBUG_INFO, "%a %a: Export Directory Entry found in the image at 0x%x.\n", _DBGMSGID_, __FUNCTION__, (UINTN)OptionalHeaderPtrUnion.Pe32));
|
||||||
DEBUG ((DEBUG_INFO, " %a %a: Directory Entry Virtual Address = 0x%x.\n", _DBGMSGID_, __FUNCTION__, DirectoryEntry->VirtualAddress));
|
DEBUG ((DEBUG_INFO, " %a %a: Directory Entry Virtual Address = 0x%x.\n", _DBGMSGID_, __FUNCTION__, DirectoryEntry->VirtualAddress));
|
||||||
|
|
||||||
ExportDirectory = (EFI_IMAGE_EXPORT_DIRECTORY *) ((UINTN) Image + DirectoryEntry->VirtualAddress);
|
ExportDirectory = (EFI_IMAGE_EXPORT_DIRECTORY *)((UINTN)Image + DirectoryEntry->VirtualAddress);
|
||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_INFO,
|
DEBUG_INFO,
|
||||||
" %a %a: Export Directory Table found successfully at 0x%x. Name address = 0x%x. Name = %a.\n",
|
" %a %a: Export Directory Table found successfully at 0x%x. Name address = 0x%x. Name = %a.\n",
|
||||||
_DBGMSGID_,
|
_DBGMSGID_,
|
||||||
__FUNCTION__,
|
__FUNCTION__,
|
||||||
(UINTN) ExportDirectory,
|
(UINTN)ExportDirectory,
|
||||||
((UINTN) Image + ExportDirectory->Name),
|
((UINTN)Image + ExportDirectory->Name),
|
||||||
(CHAR8 *) ((UINTN) Image + ExportDirectory->Name)
|
(CHAR8 *)((UINTN)Image + ExportDirectory->Name)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
*ImageExportDirectory = ExportDirectory;
|
*ImageExportDirectory = ExportDirectory;
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
@ -284,7 +289,7 @@ GetImageVersionInPeCoffImage (
|
|||||||
|
|
||||||
DEBUG ((DEBUG_INFO, " %a %a - Entry.\n", _DBGMSGID_, __FUNCTION__));
|
DEBUG ((DEBUG_INFO, " %a %a - Entry.\n", _DBGMSGID_, __FUNCTION__));
|
||||||
|
|
||||||
if (Image == NULL || PeCoffLoaderImageContext == NULL || ImageMajorVersion == NULL || ImageMinorVersion == NULL) {
|
if ((Image == NULL) || (PeCoffLoaderImageContext == NULL) || (ImageMajorVersion == NULL) || (ImageMinorVersion == NULL)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,8 +325,8 @@ GetImageVersionInPeCoffImage (
|
|||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
OptionalHeaderPtrUnion.Pe32 = (EFI_IMAGE_NT_HEADERS32 *) (
|
OptionalHeaderPtrUnion.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)(
|
||||||
(UINTN) Image +
|
(UINTN)Image +
|
||||||
PeCoffLoaderImageContext->PeCoffHeaderOffset
|
PeCoffLoaderImageContext->PeCoffHeaderOffset
|
||||||
);
|
);
|
||||||
//
|
//
|
||||||
@ -381,17 +386,18 @@ GetExportEntryAddress (
|
|||||||
UINT16 *OrdinalTable;
|
UINT16 *OrdinalTable;
|
||||||
CONST CHAR8 *ExportNameTablePointerName;
|
CONST CHAR8 *ExportNameTablePointerName;
|
||||||
|
|
||||||
if (ExportName == NULL || ImageBaseAddress == 0 || ImageExportDirectory == NULL || ExportPhysicalAddress == NULL) {
|
if ((ExportName == NULL) || (ImageBaseAddress == 0) || (ImageExportDirectory == NULL) || (ExportPhysicalAddress == NULL)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
*ExportPhysicalAddress = 0;
|
*ExportPhysicalAddress = 0;
|
||||||
|
|
||||||
ExportAddressTable = (UINT32 *) ((UINTN) ImageBaseAddress + ImageExportDirectory->AddressOfFunctions);
|
ExportAddressTable = (UINT32 *)((UINTN)ImageBaseAddress + ImageExportDirectory->AddressOfFunctions);
|
||||||
ExportNamePointerTable = (UINT32 *) ((UINTN) ImageBaseAddress + ImageExportDirectory->AddressOfNames);
|
ExportNamePointerTable = (UINT32 *)((UINTN)ImageBaseAddress + ImageExportDirectory->AddressOfNames);
|
||||||
OrdinalTable = (UINT16 *) ((UINTN) ImageBaseAddress + ImageExportDirectory->AddressOfNameOrdinals);
|
OrdinalTable = (UINT16 *)((UINTN)ImageBaseAddress + ImageExportDirectory->AddressOfNameOrdinals);
|
||||||
|
|
||||||
for (ExportNameIndex = 0; ExportNameIndex < ImageExportDirectory->NumberOfNames; ExportNameIndex++) {
|
for (ExportNameIndex = 0; ExportNameIndex < ImageExportDirectory->NumberOfNames; ExportNameIndex++) {
|
||||||
ExportNameTablePointerName = (CONST CHAR8 *) ((UINTN) ImageBaseAddress + ExportNamePointerTable[ExportNameIndex]);
|
ExportNameTablePointerName = (CONST CHAR8 *)((UINTN)ImageBaseAddress + ExportNamePointerTable[ExportNameIndex]);
|
||||||
|
|
||||||
if (AsciiStrnCmp (ExportName, ExportNameTablePointerName, PRM_HANDLER_NAME_MAXIMUM_LENGTH) == 0) {
|
if (AsciiStrnCmp (ExportName, ExportNameTablePointerName, PRM_HANDLER_NAME_MAXIMUM_LENGTH) == 0) {
|
||||||
CurrentExportOrdinal = OrdinalTable[ExportNameIndex];
|
CurrentExportOrdinal = OrdinalTable[ExportNameIndex];
|
||||||
@ -402,7 +408,7 @@ GetExportEntryAddress (
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
*ExportPhysicalAddress = (EFI_PHYSICAL_ADDRESS) ((UINTN) ImageBaseAddress + ExportAddressTable[CurrentExportOrdinal]);
|
*ExportPhysicalAddress = (EFI_PHYSICAL_ADDRESS)((UINTN)ImageBaseAddress + ExportAddressTable[CurrentExportOrdinal]);
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,13 +42,13 @@ ConvertRuntimeMemoryRangeAddresses (
|
|||||||
{
|
{
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
|
|
||||||
if (RuntimeMmioRanges == NULL || RuntimeMmioRanges->Count == 0) {
|
if ((RuntimeMmioRanges == NULL) || (RuntimeMmioRanges->Count == 0)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Index = 0; Index < (UINTN) RuntimeMmioRanges->Count; Index++) {
|
for (Index = 0; Index < (UINTN)RuntimeMmioRanges->Count; Index++) {
|
||||||
RuntimeMmioRanges->Range[Index].VirtualBaseAddress = RuntimeMmioRanges->Range[Index].PhysicalBaseAddress;
|
RuntimeMmioRanges->Range[Index].VirtualBaseAddress = RuntimeMmioRanges->Range[Index].PhysicalBaseAddress;
|
||||||
gRT->ConvertPointer (0x0, (VOID **) &(RuntimeMmioRanges->Range[Index].VirtualBaseAddress));
|
gRT->ConvertPointer (0x0, (VOID **)&(RuntimeMmioRanges->Range[Index].VirtualBaseAddress));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,13 +73,18 @@ SetRuntimeMemoryRangeAttributes (
|
|||||||
|
|
||||||
DEBUG ((DEBUG_INFO, "%a %a - Entry.\n", _DBGMSGID_, __FUNCTION__));
|
DEBUG ((DEBUG_INFO, "%a %a - Entry.\n", _DBGMSGID_, __FUNCTION__));
|
||||||
|
|
||||||
if (RuntimeMmioRanges == NULL || RuntimeMmioRanges->Count == 0) {
|
if ((RuntimeMmioRanges == NULL) || (RuntimeMmioRanges->Count == 0)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Index = 0; Index < (UINTN) RuntimeMmioRanges->Count; Index++) {
|
for (Index = 0; Index < (UINTN)RuntimeMmioRanges->Count; Index++) {
|
||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_INFO, " %a %a: Runtime MMIO Range [%d].\n", _DBGMSGID_, __FUNCTION__, Index));
|
DEBUG_INFO,
|
||||||
|
" %a %a: Runtime MMIO Range [%d].\n",
|
||||||
|
_DBGMSGID_,
|
||||||
|
__FUNCTION__,
|
||||||
|
Index
|
||||||
|
));
|
||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_INFO,
|
DEBUG_INFO,
|
||||||
" %a %a: Physical address = 0x%016x. Length = 0x%x.\n",
|
" %a %a: Physical address = 0x%016x. Length = 0x%x.\n",
|
||||||
@ -97,21 +102,22 @@ SetRuntimeMemoryRangeAttributes (
|
|||||||
Status = gDS->GetMemorySpaceDescriptor (RuntimeMmioRanges->Range[Index].PhysicalBaseAddress, &Descriptor);
|
Status = gDS->GetMemorySpaceDescriptor (RuntimeMmioRanges->Range[Index].PhysicalBaseAddress, &Descriptor);
|
||||||
if (!EFI_ERROR (Status) &&
|
if (!EFI_ERROR (Status) &&
|
||||||
(
|
(
|
||||||
(Descriptor.GcdMemoryType != EfiGcdMemoryTypeMemoryMappedIo && Descriptor.GcdMemoryType != EfiGcdMemoryTypeReserved) ||
|
((Descriptor.GcdMemoryType != EfiGcdMemoryTypeMemoryMappedIo) && (Descriptor.GcdMemoryType != EfiGcdMemoryTypeReserved)) ||
|
||||||
((Descriptor.Length & EFI_PAGE_MASK) != 0)
|
((Descriptor.Length & EFI_PAGE_MASK) != 0)
|
||||||
)
|
)
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
Status2 = gDS->RemoveMemorySpace (
|
Status2 = gDS->RemoveMemorySpace (
|
||||||
RuntimeMmioRanges->Range[Index].PhysicalBaseAddress,
|
RuntimeMmioRanges->Range[Index].PhysicalBaseAddress,
|
||||||
Descriptor.Length
|
Descriptor.Length
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Status == EFI_NOT_FOUND || !EFI_ERROR (Status2)) {
|
if ((Status == EFI_NOT_FOUND) || !EFI_ERROR (Status2)) {
|
||||||
Status = gDS->AddMemorySpace (
|
Status = gDS->AddMemorySpace (
|
||||||
EfiGcdMemoryTypeMemoryMappedIo,
|
EfiGcdMemoryTypeMemoryMappedIo,
|
||||||
RuntimeMmioRanges->Range[Index].PhysicalBaseAddress,
|
RuntimeMmioRanges->Range[Index].PhysicalBaseAddress,
|
||||||
(UINT64) RuntimeMmioRanges->Range[Index].Length,
|
(UINT64)RuntimeMmioRanges->Range[Index].Length,
|
||||||
EFI_MEMORY_UC | EFI_MEMORY_RUNTIME
|
EFI_MEMORY_UC | EFI_MEMORY_RUNTIME
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
@ -120,7 +126,7 @@ SetRuntimeMemoryRangeAttributes (
|
|||||||
EfiGcdAllocateAddress,
|
EfiGcdAllocateAddress,
|
||||||
EfiGcdMemoryTypeMemoryMappedIo,
|
EfiGcdMemoryTypeMemoryMappedIo,
|
||||||
0,
|
0,
|
||||||
(UINT64) RuntimeMmioRanges->Range[Index].Length,
|
(UINT64)RuntimeMmioRanges->Range[Index].Length,
|
||||||
&RuntimeMmioRanges->Range[Index].PhysicalBaseAddress,
|
&RuntimeMmioRanges->Range[Index].PhysicalBaseAddress,
|
||||||
gImageHandle,
|
gImageHandle,
|
||||||
NULL
|
NULL
|
||||||
@ -141,13 +147,14 @@ SetRuntimeMemoryRangeAttributes (
|
|||||||
));
|
));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((Descriptor.Attributes & EFI_MEMORY_RUNTIME) != 0) {
|
if ((Descriptor.Attributes & EFI_MEMORY_RUNTIME) != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = gDS->SetMemorySpaceAttributes (
|
Status = gDS->SetMemorySpaceAttributes (
|
||||||
RuntimeMmioRanges->Range[Index].PhysicalBaseAddress,
|
RuntimeMmioRanges->Range[Index].PhysicalBaseAddress,
|
||||||
(UINT64) RuntimeMmioRanges->Range[Index].Length,
|
(UINT64)RuntimeMmioRanges->Range[Index].Length,
|
||||||
Descriptor.Attributes | EFI_MEMORY_RUNTIME
|
Descriptor.Attributes | EFI_MEMORY_RUNTIME
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
@ -187,7 +194,7 @@ StoreVirtualMemoryAddressChangePointers (
|
|||||||
RangeIndex = 0;
|
RangeIndex = 0;
|
||||||
|
|
||||||
mRuntimeMmioRanges = AllocateRuntimeZeroPool (sizeof (*mRuntimeMmioRanges) * mMaxRuntimeMmioRangeCount);
|
mRuntimeMmioRanges = AllocateRuntimeZeroPool (sizeof (*mRuntimeMmioRanges) * mMaxRuntimeMmioRangeCount);
|
||||||
if (mRuntimeMmioRanges == NULL && mMaxRuntimeMmioRangeCount > 0) {
|
if ((mRuntimeMmioRanges == NULL) && (mMaxRuntimeMmioRangeCount > 0)) {
|
||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_ERROR,
|
DEBUG_ERROR,
|
||||||
" %a %a: Memory allocation for runtime MMIO pointer array failed.\n",
|
" %a %a: Memory allocation for runtime MMIO pointer array failed.\n",
|
||||||
@ -211,10 +218,10 @@ StoreVirtualMemoryAddressChangePointers (
|
|||||||
Status = gBS->HandleProtocol (
|
Status = gBS->HandleProtocol (
|
||||||
HandleBuffer[HandleIndex],
|
HandleBuffer[HandleIndex],
|
||||||
&gPrmConfigProtocolGuid,
|
&gPrmConfigProtocolGuid,
|
||||||
(VOID **) &PrmConfigProtocol
|
(VOID **)&PrmConfigProtocol
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
if (EFI_ERROR (Status) || PrmConfigProtocol == NULL) {
|
if (EFI_ERROR (Status) || (PrmConfigProtocol == NULL)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,9 +239,11 @@ StoreVirtualMemoryAddressChangePointers (
|
|||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mRuntimeMmioRanges[RangeIndex++] = PrmConfigProtocol->ModuleContextBuffers.RuntimeMmioRanges;
|
mRuntimeMmioRanges[RangeIndex++] = PrmConfigProtocol->ModuleContextBuffers.RuntimeMmioRanges;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_INFO,
|
DEBUG_INFO,
|
||||||
" %a %a: %d MMIO ranges buffers saved for future virtual memory conversion.\n",
|
" %a %a: %d MMIO ranges buffers saved for future virtual memory conversion.\n",
|
||||||
@ -271,6 +280,7 @@ ValidatePrmDataBuffer (
|
|||||||
DEBUG ((DEBUG_ERROR, " %a %a: The PRM data buffer signature is invalid. PRM module.\n", _DBGMSGID_, __FUNCTION__));
|
DEBUG ((DEBUG_ERROR, " %a %a: The PRM data buffer signature is invalid. PRM module.\n", _DBGMSGID_, __FUNCTION__));
|
||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PrmDataBuffer->Header.Length < sizeof (PRM_DATA_BUFFER_HEADER)) {
|
if (PrmDataBuffer->Header.Length < sizeof (PRM_DATA_BUFFER_HEADER)) {
|
||||||
DEBUG ((DEBUG_ERROR, " %a %a: The PRM data buffer length is invalid.\n", _DBGMSGID_, __FUNCTION__));
|
DEBUG ((DEBUG_ERROR, " %a %a: The PRM data buffer length is invalid.\n", _DBGMSGID_, __FUNCTION__));
|
||||||
return EFI_BUFFER_TOO_SMALL;
|
return EFI_BUFFER_TOO_SMALL;
|
||||||
@ -310,7 +320,7 @@ ValidatePrmContextBuffer (
|
|||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PrmContextBuffer->StaticDataBuffer != NULL && EFI_ERROR (ValidatePrmDataBuffer (PrmContextBuffer->StaticDataBuffer))) {
|
if ((PrmContextBuffer->StaticDataBuffer != NULL) && EFI_ERROR (ValidatePrmDataBuffer (PrmContextBuffer->StaticDataBuffer))) {
|
||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_ERROR,
|
DEBUG_ERROR,
|
||||||
" %a %a: Error in static buffer for PRM handler %g.\n",
|
" %a %a: Error in static buffer for PRM handler %g.\n",
|
||||||
@ -392,10 +402,10 @@ PrmConfigEndOfDxeNotification (
|
|||||||
Status = gBS->HandleProtocol (
|
Status = gBS->HandleProtocol (
|
||||||
HandleBuffer[HandleIndex],
|
HandleBuffer[HandleIndex],
|
||||||
&gPrmConfigProtocolGuid,
|
&gPrmConfigProtocolGuid,
|
||||||
(VOID **) &PrmConfigProtocol
|
(VOID **)&PrmConfigProtocol
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
if (EFI_ERROR (Status) || PrmConfigProtocol == NULL) {
|
if (EFI_ERROR (Status) || (PrmConfigProtocol == NULL)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -422,6 +432,7 @@ PrmConfigEndOfDxeNotification (
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG ((DEBUG_INFO, " %a %a: Module context buffer validation complete.\n", _DBGMSGID_, __FUNCTION__));
|
DEBUG ((DEBUG_INFO, " %a %a: Module context buffer validation complete.\n", _DBGMSGID_, __FUNCTION__));
|
||||||
|
|
||||||
if (PrmConfigProtocol->ModuleContextBuffers.RuntimeMmioRanges != NULL) {
|
if (PrmConfigProtocol->ModuleContextBuffers.RuntimeMmioRanges != NULL) {
|
||||||
@ -443,7 +454,8 @@ PrmConfigEndOfDxeNotification (
|
|||||||
if (HandleBuffer != NULL) {
|
if (HandleBuffer != NULL) {
|
||||||
gBS->FreePool (HandleBuffer);
|
gBS->FreePool (HandleBuffer);
|
||||||
}
|
}
|
||||||
gBS->CloseEvent(Event);
|
|
||||||
|
gBS->CloseEvent (Event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,6 +78,7 @@ ProcessPrmModules (
|
|||||||
if (PrmAcpiDescriptionTable == NULL) {
|
if (PrmAcpiDescriptionTable == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
*PrmAcpiDescriptionTable = NULL;
|
*PrmAcpiDescriptionTable = NULL;
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -96,13 +97,13 @@ ProcessPrmModules (
|
|||||||
DEBUG ((DEBUG_INFO, " %a %a: %d total PRM modules to process.\n", _DBGMSGID_, __FUNCTION__, mPrmModuleCount));
|
DEBUG ((DEBUG_INFO, " %a %a: %d total PRM modules to process.\n", _DBGMSGID_, __FUNCTION__, mPrmModuleCount));
|
||||||
DEBUG ((DEBUG_INFO, " %a %a: %d total PRM handlers to process.\n", _DBGMSGID_, __FUNCTION__, mPrmHandlerCount));
|
DEBUG ((DEBUG_INFO, " %a %a: %d total PRM handlers to process.\n", _DBGMSGID_, __FUNCTION__, mPrmHandlerCount));
|
||||||
|
|
||||||
PrmAcpiDescriptionTableBufferSize = (UINT32) (OFFSET_OF (PRM_ACPI_DESCRIPTION_TABLE, PrmModuleInfoStructure) +
|
PrmAcpiDescriptionTableBufferSize = (UINT32)(OFFSET_OF (PRM_ACPI_DESCRIPTION_TABLE, PrmModuleInfoStructure) +
|
||||||
(OFFSET_OF (PRM_MODULE_INFORMATION_STRUCT, HandlerInfoStructure) * mPrmModuleCount) +
|
(OFFSET_OF (PRM_MODULE_INFORMATION_STRUCT, HandlerInfoStructure) * mPrmModuleCount) +
|
||||||
(sizeof (PRM_HANDLER_INFORMATION_STRUCT) * mPrmHandlerCount)
|
(sizeof (PRM_HANDLER_INFORMATION_STRUCT) * mPrmHandlerCount)
|
||||||
);
|
);
|
||||||
DEBUG ((DEBUG_INFO, " %a %a: Total PRM ACPI table size: 0x%x.\n", _DBGMSGID_, __FUNCTION__, PrmAcpiDescriptionTableBufferSize));
|
DEBUG ((DEBUG_INFO, " %a %a: Total PRM ACPI table size: 0x%x.\n", _DBGMSGID_, __FUNCTION__, PrmAcpiDescriptionTableBufferSize));
|
||||||
|
|
||||||
PrmAcpiTable = AllocateZeroPool ((UINTN) PrmAcpiDescriptionTableBufferSize);
|
PrmAcpiTable = AllocateZeroPool ((UINTN)PrmAcpiDescriptionTableBufferSize);
|
||||||
if (PrmAcpiTable == NULL) {
|
if (PrmAcpiTable == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
@ -118,7 +119,7 @@ ProcessPrmModules (
|
|||||||
PrmAcpiTable->Header.CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision);
|
PrmAcpiTable->Header.CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision);
|
||||||
CopyGuid (&PrmAcpiTable->PrmPlatformGuid, &gEdkiiDscPlatformGuid);
|
CopyGuid (&PrmAcpiTable->PrmPlatformGuid, &gEdkiiDscPlatformGuid);
|
||||||
PrmAcpiTable->PrmModuleInfoOffset = OFFSET_OF (PRM_ACPI_DESCRIPTION_TABLE, PrmModuleInfoStructure);
|
PrmAcpiTable->PrmModuleInfoOffset = OFFSET_OF (PRM_ACPI_DESCRIPTION_TABLE, PrmModuleInfoStructure);
|
||||||
PrmAcpiTable->PrmModuleInfoCount = (UINT32) mPrmModuleCount;
|
PrmAcpiTable->PrmModuleInfoCount = (UINT32)mPrmModuleCount;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Iterate across all PRM Modules on the list
|
// Iterate across all PRM Modules on the list
|
||||||
@ -127,8 +128,8 @@ ProcessPrmModules (
|
|||||||
for (
|
for (
|
||||||
CurrentPrmModuleImageContext = NULL, Status = GetNextPrmModuleEntry (&CurrentPrmModuleImageContext);
|
CurrentPrmModuleImageContext = NULL, Status = GetNextPrmModuleEntry (&CurrentPrmModuleImageContext);
|
||||||
!EFI_ERROR (Status);
|
!EFI_ERROR (Status);
|
||||||
Status = GetNextPrmModuleEntry (&CurrentPrmModuleImageContext)) {
|
Status = GetNextPrmModuleEntry (&CurrentPrmModuleImageContext))
|
||||||
|
{
|
||||||
CurrentImageAddress = CurrentPrmModuleImageContext->PeCoffImageContext.ImageAddress;
|
CurrentImageAddress = CurrentPrmModuleImageContext->PeCoffImageContext.ImageAddress;
|
||||||
CurrentImageExportDirectory = CurrentPrmModuleImageContext->ExportDirectory;
|
CurrentImageExportDirectory = CurrentPrmModuleImageContext->ExportDirectory;
|
||||||
CurrentExportDescriptorStruct = CurrentPrmModuleImageContext->ExportDescriptor;
|
CurrentExportDescriptorStruct = CurrentPrmModuleImageContext->ExportDescriptor;
|
||||||
@ -139,7 +140,7 @@ ProcessPrmModules (
|
|||||||
" %a %a: PRM Module - %a with %d handlers.\n",
|
" %a %a: PRM Module - %a with %d handlers.\n",
|
||||||
_DBGMSGID_,
|
_DBGMSGID_,
|
||||||
__FUNCTION__,
|
__FUNCTION__,
|
||||||
(CHAR8 *) ((UINTN) CurrentImageAddress + CurrentImageExportDirectory->Name),
|
(CHAR8 *)((UINTN)CurrentImageAddress + CurrentImageExportDirectory->Name),
|
||||||
CurrentExportDescriptorStruct->Header.NumberPrmHandlers
|
CurrentExportDescriptorStruct->Header.NumberPrmHandlers
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -149,13 +150,13 @@ ProcessPrmModules (
|
|||||||
(CurrentExportDescriptorStruct->Header.NumberPrmHandlers * sizeof (PRM_HANDLER_INFORMATION_STRUCT))
|
(CurrentExportDescriptorStruct->Header.NumberPrmHandlers * sizeof (PRM_HANDLER_INFORMATION_STRUCT))
|
||||||
);
|
);
|
||||||
CopyGuid (&CurrentModuleInfoStruct->Identifier, &CurrentExportDescriptorStruct->Header.ModuleGuid);
|
CopyGuid (&CurrentModuleInfoStruct->Identifier, &CurrentExportDescriptorStruct->Header.ModuleGuid);
|
||||||
CurrentModuleInfoStruct->HandlerCount = (UINT32) CurrentExportDescriptorStruct->Header.NumberPrmHandlers;
|
CurrentModuleInfoStruct->HandlerCount = (UINT32)CurrentExportDescriptorStruct->Header.NumberPrmHandlers;
|
||||||
CurrentModuleInfoStruct->HandlerInfoOffset = OFFSET_OF (PRM_MODULE_INFORMATION_STRUCT, HandlerInfoStructure);
|
CurrentModuleInfoStruct->HandlerInfoOffset = OFFSET_OF (PRM_MODULE_INFORMATION_STRUCT, HandlerInfoStructure);
|
||||||
|
|
||||||
CurrentModuleInfoStruct->MajorRevision = 0;
|
CurrentModuleInfoStruct->MajorRevision = 0;
|
||||||
CurrentModuleInfoStruct->MinorRevision = 0;
|
CurrentModuleInfoStruct->MinorRevision = 0;
|
||||||
Status = GetImageVersionInPeCoffImage (
|
Status = GetImageVersionInPeCoffImage (
|
||||||
(VOID *) (UINTN) CurrentImageAddress,
|
(VOID *)(UINTN)CurrentImageAddress,
|
||||||
&CurrentPrmModuleImageContext->PeCoffImageContext,
|
&CurrentPrmModuleImageContext->PeCoffImageContext,
|
||||||
&CurrentModuleInfoStruct->MajorRevision,
|
&CurrentModuleInfoStruct->MajorRevision,
|
||||||
&CurrentModuleInfoStruct->MinorRevision
|
&CurrentModuleInfoStruct->MinorRevision
|
||||||
@ -166,11 +167,11 @@ ProcessPrmModules (
|
|||||||
Status = GetModuleContextBuffers (
|
Status = GetModuleContextBuffers (
|
||||||
ByModuleGuid,
|
ByModuleGuid,
|
||||||
&CurrentModuleInfoStruct->Identifier,
|
&CurrentModuleInfoStruct->Identifier,
|
||||||
(CONST PRM_MODULE_CONTEXT_BUFFERS **) &CurrentModuleContextBuffers
|
(CONST PRM_MODULE_CONTEXT_BUFFERS **)&CurrentModuleContextBuffers
|
||||||
);
|
);
|
||||||
ASSERT (!EFI_ERROR (Status) || Status == EFI_NOT_FOUND);
|
ASSERT (!EFI_ERROR (Status) || Status == EFI_NOT_FOUND);
|
||||||
if (!EFI_ERROR (Status) && CurrentModuleContextBuffers != NULL) {
|
if (!EFI_ERROR (Status) && (CurrentModuleContextBuffers != NULL)) {
|
||||||
CurrentModuleInfoStruct->RuntimeMmioRanges = (UINT64) (UINTN) CurrentModuleContextBuffers->RuntimeMmioRanges;
|
CurrentModuleInfoStruct->RuntimeMmioRanges = (UINT64)(UINTN)CurrentModuleContextBuffers->RuntimeMmioRanges;
|
||||||
CurrentModuleAcpiParamDescriptors = CurrentModuleContextBuffers->AcpiParameterBufferDescriptors;
|
CurrentModuleAcpiParamDescriptors = CurrentModuleContextBuffers->AcpiParameterBufferDescriptors;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,15 +188,15 @@ ProcessPrmModules (
|
|||||||
&CurrentExportDescriptorStruct->PrmHandlerExportDescriptors[HandlerIndex].PrmHandlerGuid
|
&CurrentExportDescriptorStruct->PrmHandlerExportDescriptors[HandlerIndex].PrmHandlerGuid
|
||||||
);
|
);
|
||||||
|
|
||||||
CurrentExportDescriptorHandlerName = (CONST CHAR8 *) CurrentExportDescriptorStruct->PrmHandlerExportDescriptors[HandlerIndex].PrmHandlerName;
|
CurrentExportDescriptorHandlerName = (CONST CHAR8 *)CurrentExportDescriptorStruct->PrmHandlerExportDescriptors[HandlerIndex].PrmHandlerName;
|
||||||
|
|
||||||
Status = GetContextBuffer (
|
Status = GetContextBuffer (
|
||||||
&CurrentHandlerInfoStruct->Identifier,
|
&CurrentHandlerInfoStruct->Identifier,
|
||||||
CurrentModuleContextBuffers,
|
CurrentModuleContextBuffers,
|
||||||
(CONST PRM_CONTEXT_BUFFER **) &CurrentContextBuffer
|
(CONST PRM_CONTEXT_BUFFER **)&CurrentContextBuffer
|
||||||
);
|
);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
CurrentHandlerInfoStruct->StaticDataBuffer = (UINT64) (UINTN) CurrentContextBuffer->StaticDataBuffer;
|
CurrentHandlerInfoStruct->StaticDataBuffer = (UINT64)(UINTN)CurrentContextBuffer->StaticDataBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = GetExportEntryAddress (
|
Status = GetExportEntryAddress (
|
||||||
@ -223,15 +224,17 @@ ProcessPrmModules (
|
|||||||
if (CurrentModuleAcpiParamDescriptors != NULL) {
|
if (CurrentModuleAcpiParamDescriptors != NULL) {
|
||||||
for (AcpiParamIndex = 0; AcpiParamIndex < CurrentModuleContextBuffers->AcpiParameterBufferDescriptorCount; AcpiParamIndex++) {
|
for (AcpiParamIndex = 0; AcpiParamIndex < CurrentModuleContextBuffers->AcpiParameterBufferDescriptorCount; AcpiParamIndex++) {
|
||||||
if (CompareGuid (&CurrentModuleAcpiParamDescriptors[AcpiParamIndex].HandlerGuid, &CurrentHandlerInfoStruct->Identifier)) {
|
if (CompareGuid (&CurrentModuleAcpiParamDescriptors[AcpiParamIndex].HandlerGuid, &CurrentHandlerInfoStruct->Identifier)) {
|
||||||
CurrentHandlerInfoStruct->AcpiParameterBuffer = (UINT64) (UINTN) (
|
CurrentHandlerInfoStruct->AcpiParameterBuffer = (UINT64)(UINTN)(
|
||||||
CurrentModuleAcpiParamDescriptors[AcpiParamIndex].AcpiParameterBufferAddress
|
CurrentModuleAcpiParamDescriptors[AcpiParamIndex].AcpiParameterBufferAddress
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CurrentModuleInfoStruct = (PRM_MODULE_INFORMATION_STRUCT *) ((UINTN) CurrentModuleInfoStruct + CurrentModuleInfoStruct->StructureLength);
|
|
||||||
|
CurrentModuleInfoStruct = (PRM_MODULE_INFORMATION_STRUCT *)((UINTN)CurrentModuleInfoStruct + CurrentModuleInfoStruct->StructureLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
*PrmAcpiDescriptionTable = PrmAcpiTable;
|
*PrmAcpiDescriptionTable = PrmAcpiTable;
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
@ -259,11 +262,11 @@ PublishPrmAcpiTable (
|
|||||||
EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtocol;
|
EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtocol;
|
||||||
UINTN TableKey;
|
UINTN TableKey;
|
||||||
|
|
||||||
if (PrmAcpiDescriptionTable == NULL || PrmAcpiDescriptionTable->Header.Signature != PRM_TABLE_SIGNATURE) {
|
if ((PrmAcpiDescriptionTable == NULL) || (PrmAcpiDescriptionTable->Header.Signature != PRM_TABLE_SIGNATURE)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **) &AcpiTableProtocol);
|
Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **)&AcpiTableProtocol);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
TableKey = 0;
|
TableKey = 0;
|
||||||
//
|
//
|
||||||
@ -279,6 +282,7 @@ PublishPrmAcpiTable (
|
|||||||
DEBUG ((DEBUG_INFO, "%a %a: The PRMT ACPI table was installed successfully.\n", _DBGMSGID_, __FUNCTION__));
|
DEBUG ((DEBUG_INFO, "%a %a: The PRMT ACPI table was installed successfully.\n", _DBGMSGID_, __FUNCTION__));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
@ -326,6 +330,7 @@ PrmLoaderEndOfDxeNotification (
|
|||||||
if (PrmAcpiDescriptionTable != NULL) {
|
if (PrmAcpiDescriptionTable != NULL) {
|
||||||
FreePool (PrmAcpiDescriptionTable);
|
FreePool (PrmAcpiDescriptionTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
gBS->CloseEvent (Event);
|
gBS->CloseEvent (Event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,7 +360,7 @@ PrmLoaderEntryPoint (
|
|||||||
// Discover and process installed PRM modules at the End of DXE
|
// Discover and process installed PRM modules at the End of DXE
|
||||||
// The PRM ACPI table is published if one or PRM modules are discovered
|
// The PRM ACPI table is published if one or PRM modules are discovered
|
||||||
//
|
//
|
||||||
Status = gBS->CreateEventEx(
|
Status = gBS->CreateEventEx (
|
||||||
EVT_NOTIFY_SIGNAL,
|
EVT_NOTIFY_SIGNAL,
|
||||||
TPL_CALLBACK,
|
TPL_CALLBACK,
|
||||||
PrmLoaderEndOfDxeNotification,
|
PrmLoaderEndOfDxeNotification,
|
||||||
|
@ -48,7 +48,7 @@ InstallPrmSsdt (
|
|||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **) &AcpiTableProtocol);
|
Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **)&AcpiTableProtocol);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
//
|
//
|
||||||
// Discover the SSDT
|
// Discover the SSDT
|
||||||
@ -57,7 +57,7 @@ InstallPrmSsdt (
|
|||||||
&gEfiCallerIdGuid,
|
&gEfiCallerIdGuid,
|
||||||
EFI_SECTION_RAW,
|
EFI_SECTION_RAW,
|
||||||
0,
|
0,
|
||||||
(VOID **) &Ssdt,
|
(VOID **)&Ssdt,
|
||||||
&SsdtSize
|
&SsdtSize
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
@ -103,7 +103,7 @@ PrmSsdtInstallEntryPoint (
|
|||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
Status = InstallPrmSsdt ((UINT8 *) PcdGetPtr (PcdAcpiDefaultOemId));
|
Status = InstallPrmSsdt ((UINT8 *)PcdGetPtr (PcdAcpiDefaultOemId));
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -17,10 +17,14 @@
|
|||||||
STATIC EFI_HANDLE mPrmConfigProtocolHandle;
|
STATIC EFI_HANDLE mPrmConfigProtocolHandle;
|
||||||
|
|
||||||
// {dc2a58a6-5927-4776-b995-d118a27335a2}
|
// {dc2a58a6-5927-4776-b995-d118a27335a2}
|
||||||
STATIC CONST EFI_GUID mPrmModuleGuid = {0xdc2a58a6, 0x5927, 0x4776, {0xb9, 0x95, 0xd1, 0x18, 0xa2, 0x73, 0x35, 0xa2}};
|
STATIC CONST EFI_GUID mPrmModuleGuid = {
|
||||||
|
0xdc2a58a6, 0x5927, 0x4776, { 0xb9, 0x95, 0xd1, 0x18, 0xa2, 0x73, 0x35, 0xa2 }
|
||||||
|
};
|
||||||
|
|
||||||
// {2e4f2d13-6240-4ed0-a401-c723fbdc34e8}
|
// {2e4f2d13-6240-4ed0-a401-c723fbdc34e8}
|
||||||
STATIC CONST EFI_GUID mCheckParamBufferPrmHandlerGuid = {0x2e4f2d13, 0x6240, 0x4ed0, {0xa4, 0x01, 0xc7, 0x23, 0xfb, 0xdc, 0x34, 0xe8}};
|
STATIC CONST EFI_GUID mCheckParamBufferPrmHandlerGuid = {
|
||||||
|
0x2e4f2d13, 0x6240, 0x4ed0, { 0xa4, 0x01, 0xc7, 0x23, 0xfb, 0xdc, 0x34, 0xe8 }
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructor of the PRM configuration library.
|
Constructor of the PRM configuration library.
|
||||||
@ -82,11 +86,12 @@ AcpiParameterBufferModuleConfigLibConstructor (
|
|||||||
Status = EFI_OUT_OF_RESOURCES;
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
goto Done;
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyGuid (&PrmConfigProtocol->ModuleContextBuffers.ModuleGuid, &mPrmModuleGuid);
|
CopyGuid (&PrmConfigProtocol->ModuleContextBuffers.ModuleGuid, &mPrmModuleGuid);
|
||||||
|
|
||||||
// Populate the ACPI Parameter Buffer Descriptor structure
|
// Populate the ACPI Parameter Buffer Descriptor structure
|
||||||
CopyGuid (&AcpiParamBufferDescriptor->HandlerGuid, &mCheckParamBufferPrmHandlerGuid);
|
CopyGuid (&AcpiParamBufferDescriptor->HandlerGuid, &mCheckParamBufferPrmHandlerGuid);
|
||||||
AcpiParamBufferDescriptor->AcpiParameterBufferAddress = (UINT64) (UINTN) AcpiParameterBuffer;
|
AcpiParamBufferDescriptor->AcpiParameterBufferAddress = (UINT64)(UINTN)AcpiParameterBuffer;
|
||||||
|
|
||||||
// Populate the PRM Module Context Buffers structure
|
// Populate the PRM Module Context Buffers structure
|
||||||
PrmConfigProtocol->ModuleContextBuffers.AcpiParameterBufferDescriptorCount = 1;
|
PrmConfigProtocol->ModuleContextBuffers.AcpiParameterBufferDescriptorCount = 1;
|
||||||
@ -100,7 +105,7 @@ AcpiParameterBufferModuleConfigLibConstructor (
|
|||||||
&mPrmConfigProtocolHandle,
|
&mPrmConfigProtocolHandle,
|
||||||
&gPrmConfigProtocolGuid,
|
&gPrmConfigProtocolGuid,
|
||||||
EFI_NATIVE_INTERFACE,
|
EFI_NATIVE_INTERFACE,
|
||||||
(VOID *) PrmConfigProtocol
|
(VOID *)PrmConfigProtocol
|
||||||
);
|
);
|
||||||
|
|
||||||
Done:
|
Done:
|
||||||
@ -108,9 +113,11 @@ Done:
|
|||||||
if (AcpiParameterBuffer != NULL) {
|
if (AcpiParameterBuffer != NULL) {
|
||||||
FreePool (AcpiParameterBuffer);
|
FreePool (AcpiParameterBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AcpiParamBufferDescriptor != NULL) {
|
if (AcpiParamBufferDescriptor != NULL) {
|
||||||
FreePool (AcpiParamBufferDescriptor);
|
FreePool (AcpiParamBufferDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PrmConfigProtocol != NULL) {
|
if (PrmConfigProtocol != NULL) {
|
||||||
FreePool (PrmConfigProtocol);
|
FreePool (PrmConfigProtocol);
|
||||||
}
|
}
|
||||||
|
@ -39,13 +39,12 @@
|
|||||||
@retval Others An error occurred in the PRM handler.
|
@retval Others An error occurred in the PRM handler.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
PRM_HANDLER_EXPORT (CheckParamBufferPrmHandler)
|
PRM_HANDLER_EXPORT (CheckParamBufferPrmHandler) {
|
||||||
{
|
|
||||||
if (ParameterBuffer == NULL) {
|
if (ParameterBuffer == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*((UINT32 *) ParameterBuffer) == PARAM_BUFFER_TEST_SIGNATURE) {
|
if (*((UINT32 *)ParameterBuffer) == PARAM_BUFFER_TEST_SIGNATURE) {
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,10 +21,14 @@
|
|||||||
STATIC EFI_HANDLE mPrmConfigProtocolHandle;
|
STATIC EFI_HANDLE mPrmConfigProtocolHandle;
|
||||||
|
|
||||||
// {5a6cf42b-8bb4-472c-a233-5c4dc4033dc7}
|
// {5a6cf42b-8bb4-472c-a233-5c4dc4033dc7}
|
||||||
STATIC CONST EFI_GUID mPrmModuleGuid = {0x5a6cf42b, 0x8bb4, 0x472c, {0xa2, 0x33, 0x5c, 0x4d, 0xc4, 0x03, 0x3d, 0xc7}};
|
STATIC CONST EFI_GUID mPrmModuleGuid = {
|
||||||
|
0x5a6cf42b, 0x8bb4, 0x472c, { 0xa2, 0x33, 0x5c, 0x4d, 0xc4, 0x03, 0x3d, 0xc7 }
|
||||||
|
};
|
||||||
|
|
||||||
// {e1466081-7562-430f-896b-b0e523dc335a}
|
// {e1466081-7562-430f-896b-b0e523dc335a}
|
||||||
STATIC CONST EFI_GUID mCheckStaticDataBufferPrmHandlerGuid = {0xe1466081, 0x7562, 0x430f, {0x89, 0x6b, 0xb0, 0xe5, 0x23, 0xdc, 0x33, 0x5a}};
|
STATIC CONST EFI_GUID mCheckStaticDataBufferPrmHandlerGuid = {
|
||||||
|
0xe1466081, 0x7562, 0x430f, { 0x89, 0x6b, 0xb0, 0xe5, 0x23, 0xdc, 0x33, 0x5a }
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Populates the static data buffer for this PRM module.
|
Populates the static data buffer for this PRM module.
|
||||||
@ -80,6 +84,7 @@ GetStaticDataBuffer (
|
|||||||
if (StaticDataBuffer == NULL) {
|
if (StaticDataBuffer == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
*StaticDataBuffer = NULL;
|
*StaticDataBuffer = NULL;
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -96,9 +101,9 @@ GetStaticDataBuffer (
|
|||||||
// Initialize the data buffer header
|
// Initialize the data buffer header
|
||||||
//
|
//
|
||||||
DataBuffer->Header.Signature = PRM_DATA_BUFFER_HEADER_SIGNATURE;
|
DataBuffer->Header.Signature = PRM_DATA_BUFFER_HEADER_SIGNATURE;
|
||||||
DataBuffer->Header.Length = (UINT32) DataBufferLength;
|
DataBuffer->Header.Length = (UINT32)DataBufferLength;
|
||||||
|
|
||||||
Status = PopulateStaticDataBuffer ((STATIC_DATA_SAMPLE_CONTEXT_BUFFER_MODULE *) &DataBuffer->Data[0]);
|
Status = PopulateStaticDataBuffer ((STATIC_DATA_SAMPLE_CONTEXT_BUFFER_MODULE *)&DataBuffer->Data[0]);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
*StaticDataBuffer = DataBuffer;
|
*StaticDataBuffer = DataBuffer;
|
||||||
@ -144,7 +149,7 @@ ContextBufferModuleConfigLibConstructor (
|
|||||||
//
|
//
|
||||||
Status = GetStaticDataBuffer (&StaticDataBuffer);
|
Status = GetStaticDataBuffer (&StaticDataBuffer);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
if (EFI_ERROR (Status) || StaticDataBuffer == NULL) {
|
if (EFI_ERROR (Status) || (StaticDataBuffer == NULL)) {
|
||||||
goto Done;
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,6 +171,7 @@ ContextBufferModuleConfigLibConstructor (
|
|||||||
Status = EFI_OUT_OF_RESOURCES;
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
goto Done;
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyGuid (&PrmContextBuffer->HandlerGuid, &mCheckStaticDataBufferPrmHandlerGuid);
|
CopyGuid (&PrmContextBuffer->HandlerGuid, &mCheckStaticDataBufferPrmHandlerGuid);
|
||||||
PrmContextBuffer->Signature = PRM_CONTEXT_BUFFER_SIGNATURE;
|
PrmContextBuffer->Signature = PRM_CONTEXT_BUFFER_SIGNATURE;
|
||||||
PrmContextBuffer->Version = PRM_CONTEXT_BUFFER_INTERFACE_VERSION;
|
PrmContextBuffer->Version = PRM_CONTEXT_BUFFER_INTERFACE_VERSION;
|
||||||
@ -177,6 +183,7 @@ ContextBufferModuleConfigLibConstructor (
|
|||||||
Status = EFI_OUT_OF_RESOURCES;
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
goto Done;
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyGuid (&PrmConfigProtocol->ModuleContextBuffers.ModuleGuid, &mPrmModuleGuid);
|
CopyGuid (&PrmConfigProtocol->ModuleContextBuffers.ModuleGuid, &mPrmModuleGuid);
|
||||||
PrmConfigProtocol->ModuleContextBuffers.BufferCount = 1;
|
PrmConfigProtocol->ModuleContextBuffers.BufferCount = 1;
|
||||||
PrmConfigProtocol->ModuleContextBuffers.Buffer = PrmContextBuffer;
|
PrmConfigProtocol->ModuleContextBuffers.Buffer = PrmContextBuffer;
|
||||||
@ -189,7 +196,7 @@ ContextBufferModuleConfigLibConstructor (
|
|||||||
&mPrmConfigProtocolHandle,
|
&mPrmConfigProtocolHandle,
|
||||||
&gPrmConfigProtocolGuid,
|
&gPrmConfigProtocolGuid,
|
||||||
EFI_NATIVE_INTERFACE,
|
EFI_NATIVE_INTERFACE,
|
||||||
(VOID *) PrmConfigProtocol
|
(VOID *)PrmConfigProtocol
|
||||||
);
|
);
|
||||||
|
|
||||||
Done:
|
Done:
|
||||||
@ -197,9 +204,11 @@ Done:
|
|||||||
if (StaticDataBuffer != NULL) {
|
if (StaticDataBuffer != NULL) {
|
||||||
FreePool (StaticDataBuffer);
|
FreePool (StaticDataBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PrmContextBuffer != NULL) {
|
if (PrmContextBuffer != NULL) {
|
||||||
FreePool (PrmContextBuffer);
|
FreePool (PrmContextBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PrmConfigProtocol != NULL) {
|
if (PrmConfigProtocol != NULL) {
|
||||||
FreePool (PrmConfigProtocol);
|
FreePool (PrmConfigProtocol);
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,7 @@
|
|||||||
@retval Others An error occurred in the PRM handler.
|
@retval Others An error occurred in the PRM handler.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
PRM_HANDLER_EXPORT (CheckStaticDataBufferPrmHandler)
|
PRM_HANDLER_EXPORT (CheckStaticDataBufferPrmHandler) {
|
||||||
{
|
|
||||||
if (ContextBuffer == NULL) {
|
if (ContextBuffer == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
@ -49,8 +48,9 @@ PRM_HANDLER_EXPORT (CheckStaticDataBufferPrmHandler)
|
|||||||
// Verify PRM data buffer signature is valid
|
// Verify PRM data buffer signature is valid
|
||||||
//
|
//
|
||||||
if (
|
if (
|
||||||
ContextBuffer->Signature != PRM_CONTEXT_BUFFER_SIGNATURE ||
|
(ContextBuffer->Signature != PRM_CONTEXT_BUFFER_SIGNATURE) ||
|
||||||
ContextBuffer->StaticDataBuffer->Header.Signature != PRM_DATA_BUFFER_HEADER_SIGNATURE) {
|
(ContextBuffer->StaticDataBuffer->Header.Signature != PRM_DATA_BUFFER_HEADER_SIGNATURE))
|
||||||
|
{
|
||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,13 +45,13 @@
|
|||||||
///
|
///
|
||||||
typedef union {
|
typedef union {
|
||||||
struct {
|
struct {
|
||||||
UINT32 Revision:8;
|
UINT32 Revision : 8;
|
||||||
UINT32 NumberOfTimers:5;
|
UINT32 NumberOfTimers : 5;
|
||||||
UINT32 CounterSize:1;
|
UINT32 CounterSize : 1;
|
||||||
UINT32 Reserved0:1;
|
UINT32 Reserved0 : 1;
|
||||||
UINT32 LegacyRoute:1;
|
UINT32 LegacyRoute : 1;
|
||||||
UINT32 VendorId:16;
|
UINT32 VendorId : 16;
|
||||||
UINT32 CounterClockPeriod:32;
|
UINT32 CounterClockPeriod : 32;
|
||||||
} Bits;
|
} Bits;
|
||||||
UINT64 Uint64;
|
UINT64 Uint64;
|
||||||
} HPET_GENERAL_CAPABILITIES_ID_REGISTER;
|
} HPET_GENERAL_CAPABILITIES_ID_REGISTER;
|
||||||
@ -61,10 +61,10 @@ typedef union {
|
|||||||
///
|
///
|
||||||
typedef union {
|
typedef union {
|
||||||
struct {
|
struct {
|
||||||
UINT32 MainCounterEnable:1;
|
UINT32 MainCounterEnable : 1;
|
||||||
UINT32 LegacyRouteEnable:1;
|
UINT32 LegacyRouteEnable : 1;
|
||||||
UINT32 Reserved0:30;
|
UINT32 Reserved0 : 30;
|
||||||
UINT32 Reserved1:32;
|
UINT32 Reserved1 : 32;
|
||||||
} Bits;
|
} Bits;
|
||||||
UINT64 Uint64;
|
UINT64 Uint64;
|
||||||
} HPET_GENERAL_CONFIGURATION_REGISTER;
|
} HPET_GENERAL_CONFIGURATION_REGISTER;
|
||||||
@ -74,19 +74,19 @@ typedef union {
|
|||||||
///
|
///
|
||||||
typedef union {
|
typedef union {
|
||||||
struct {
|
struct {
|
||||||
UINT32 Reserved0:1;
|
UINT32 Reserved0 : 1;
|
||||||
UINT32 LevelTriggeredInterrupt:1;
|
UINT32 LevelTriggeredInterrupt : 1;
|
||||||
UINT32 InterruptEnable:1;
|
UINT32 InterruptEnable : 1;
|
||||||
UINT32 PeriodicInterruptEnable:1;
|
UINT32 PeriodicInterruptEnable : 1;
|
||||||
UINT32 PeriodicInterruptCapability:1;
|
UINT32 PeriodicInterruptCapability : 1;
|
||||||
UINT32 CounterSizeCapability:1;
|
UINT32 CounterSizeCapability : 1;
|
||||||
UINT32 ValueSetEnable:1;
|
UINT32 ValueSetEnable : 1;
|
||||||
UINT32 Reserved1:1;
|
UINT32 Reserved1 : 1;
|
||||||
UINT32 CounterSizeEnable:1;
|
UINT32 CounterSizeEnable : 1;
|
||||||
UINT32 InterruptRoute:5;
|
UINT32 InterruptRoute : 5;
|
||||||
UINT32 MsiInterruptEnable:1;
|
UINT32 MsiInterruptEnable : 1;
|
||||||
UINT32 MsiInterruptCapability:1;
|
UINT32 MsiInterruptCapability : 1;
|
||||||
UINT32 Reserved2:16;
|
UINT32 Reserved2 : 16;
|
||||||
UINT32 InterruptRouteCapability;
|
UINT32 InterruptRouteCapability;
|
||||||
} Bits;
|
} Bits;
|
||||||
UINT64 Uint64;
|
UINT64 Uint64;
|
||||||
@ -97,8 +97,8 @@ typedef union {
|
|||||||
///
|
///
|
||||||
typedef union {
|
typedef union {
|
||||||
struct {
|
struct {
|
||||||
UINT32 Value:32;
|
UINT32 Value : 32;
|
||||||
UINT32 Address:32;
|
UINT32 Address : 32;
|
||||||
} Bits;
|
} Bits;
|
||||||
UINT64 Uint64;
|
UINT64 Uint64;
|
||||||
} HPET_TIMER_MSI_ROUTE_REGISTER;
|
} HPET_TIMER_MSI_ROUTE_REGISTER;
|
||||||
|
@ -18,7 +18,9 @@
|
|||||||
STATIC EFI_HANDLE mPrmConfigProtocolHandle;
|
STATIC EFI_HANDLE mPrmConfigProtocolHandle;
|
||||||
|
|
||||||
// {0ef93ed7-14ae-425b-928f-b85a6213b57e}
|
// {0ef93ed7-14ae-425b-928f-b85a6213b57e}
|
||||||
STATIC CONST EFI_GUID mPrmModuleGuid = {0x0ef93ed7, 0x14ae, 0x425b, {0x92, 0x8f, 0xb8, 0x5a, 0x62, 0x13, 0xb5, 0x7e}};
|
STATIC CONST EFI_GUID mPrmModuleGuid = {
|
||||||
|
0x0ef93ed7, 0x14ae, 0x425b, { 0x92, 0x8f, 0xb8, 0x5a, 0x62, 0x13, 0xb5, 0x7e }
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructor of the PRM configuration library.
|
Constructor of the PRM configuration library.
|
||||||
@ -70,6 +72,7 @@ HardwareAccessModuleConfigLibConstructor (
|
|||||||
Status = EFI_OUT_OF_RESOURCES;
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
goto Done;
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyGuid (&PrmConfigProtocol->ModuleContextBuffers.ModuleGuid, &mPrmModuleGuid);
|
CopyGuid (&PrmConfigProtocol->ModuleContextBuffers.ModuleGuid, &mPrmModuleGuid);
|
||||||
|
|
||||||
// Populate the Runtime MMIO Ranges structure
|
// Populate the Runtime MMIO Ranges structure
|
||||||
@ -87,7 +90,7 @@ HardwareAccessModuleConfigLibConstructor (
|
|||||||
&mPrmConfigProtocolHandle,
|
&mPrmConfigProtocolHandle,
|
||||||
&gPrmConfigProtocolGuid,
|
&gPrmConfigProtocolGuid,
|
||||||
EFI_NATIVE_INTERFACE,
|
EFI_NATIVE_INTERFACE,
|
||||||
(VOID *) PrmConfigProtocol
|
(VOID *)PrmConfigProtocol
|
||||||
);
|
);
|
||||||
|
|
||||||
Done:
|
Done:
|
||||||
@ -95,6 +98,7 @@ Done:
|
|||||||
if (RuntimeMmioRanges != NULL) {
|
if (RuntimeMmioRanges != NULL) {
|
||||||
FreePool (RuntimeMmioRanges);
|
FreePool (RuntimeMmioRanges);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PrmConfigProtocol != NULL) {
|
if (PrmConfigProtocol != NULL) {
|
||||||
FreePool (PrmConfigProtocol);
|
FreePool (PrmConfigProtocol);
|
||||||
}
|
}
|
||||||
|
@ -158,12 +158,18 @@ AccessAllMtrrs (
|
|||||||
RangeCount = 1;
|
RangeCount = 1;
|
||||||
|
|
||||||
MtrrLibGetRawVariableRanges (
|
MtrrLibGetRawVariableRanges (
|
||||||
&Mtrrs->Variables, VariableMtrrCount,
|
&Mtrrs->Variables,
|
||||||
MtrrValidBitsMask, MtrrValidAddressMask, RawVariableRanges
|
VariableMtrrCount,
|
||||||
|
MtrrValidBitsMask,
|
||||||
|
MtrrValidAddressMask,
|
||||||
|
RawVariableRanges
|
||||||
);
|
);
|
||||||
MtrrLibApplyVariableMtrrs (
|
MtrrLibApplyVariableMtrrs (
|
||||||
RawVariableRanges, VariableMtrrCount,
|
RawVariableRanges,
|
||||||
Ranges, ARRAY_SIZE (Ranges), &RangeCount
|
VariableMtrrCount,
|
||||||
|
Ranges,
|
||||||
|
ARRAY_SIZE (Ranges),
|
||||||
|
&RangeCount
|
||||||
);
|
);
|
||||||
|
|
||||||
MtrrLibApplyFixedMtrrs (&Mtrrs->Fixed, Ranges, ARRAY_SIZE (Ranges), &RangeCount);
|
MtrrLibApplyFixedMtrrs (&Mtrrs->Fixed, Ranges, ARRAY_SIZE (Ranges), &RangeCount);
|
||||||
@ -200,7 +206,7 @@ HpetRead (
|
|||||||
}
|
}
|
||||||
|
|
||||||
MemoryFence ();
|
MemoryFence ();
|
||||||
Value = *(volatile UINT64*)Address;
|
Value = *(volatile UINT64 *)Address;
|
||||||
MemoryFence ();
|
MemoryFence ();
|
||||||
|
|
||||||
return Value;
|
return Value;
|
||||||
@ -251,8 +257,7 @@ GetMicrocodeSignature (
|
|||||||
@retval Others An error occurred in the PRM handler.
|
@retval Others An error occurred in the PRM handler.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
PRM_HANDLER_EXPORT (MsrAccessMicrocodeSignaturePrmHandler)
|
PRM_HANDLER_EXPORT (MsrAccessMicrocodeSignaturePrmHandler) {
|
||||||
{
|
|
||||||
UINT32 MicrocodeSignature;
|
UINT32 MicrocodeSignature;
|
||||||
|
|
||||||
MicrocodeSignature = 0;
|
MicrocodeSignature = 0;
|
||||||
@ -277,8 +282,7 @@ PRM_HANDLER_EXPORT (MsrAccessMicrocodeSignaturePrmHandler)
|
|||||||
@retval Others An error occurred in the PRM handler.
|
@retval Others An error occurred in the PRM handler.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
PRM_HANDLER_EXPORT (MsrAccessMtrrDumpPrmHandler)
|
PRM_HANDLER_EXPORT (MsrAccessMtrrDumpPrmHandler) {
|
||||||
{
|
|
||||||
AccessAllMtrrs ();
|
AccessAllMtrrs ();
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
@ -296,8 +300,7 @@ PRM_HANDLER_EXPORT (MsrAccessMtrrDumpPrmHandler)
|
|||||||
@retval Others An error occurred in the PRM handler.
|
@retval Others An error occurred in the PRM handler.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
PRM_HANDLER_EXPORT (MmioAccessHpetPrmHandler)
|
PRM_HANDLER_EXPORT (MmioAccessHpetPrmHandler) {
|
||||||
{
|
|
||||||
AccessHpetConfiguration ();
|
AccessHpetConfiguration ();
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
@ -27,50 +27,50 @@ STATIC EFI_BOOT_SERVICES mBootServices = {
|
|||||||
0, // CRC32
|
0, // CRC32
|
||||||
0 // Reserved
|
0 // Reserved
|
||||||
},
|
},
|
||||||
(EFI_RAISE_TPL) UnitTestRaiseTpl, // RaiseTPL
|
(EFI_RAISE_TPL)UnitTestRaiseTpl, // RaiseTPL
|
||||||
(EFI_RESTORE_TPL) UnitTestRestoreTpl, // RestoreTPL
|
(EFI_RESTORE_TPL)UnitTestRestoreTpl, // RestoreTPL
|
||||||
(EFI_ALLOCATE_PAGES) UnitTestAllocatePages, // AllocatePages
|
(EFI_ALLOCATE_PAGES)UnitTestAllocatePages, // AllocatePages
|
||||||
(EFI_FREE_PAGES) UnitTestFreePages, // FreePages
|
(EFI_FREE_PAGES)UnitTestFreePages, // FreePages
|
||||||
(EFI_GET_MEMORY_MAP) UnitTestGetMemoryMap, // GetMemoryMap
|
(EFI_GET_MEMORY_MAP)UnitTestGetMemoryMap, // GetMemoryMap
|
||||||
(EFI_ALLOCATE_POOL) UnitTestAllocatePool, // AllocatePool
|
(EFI_ALLOCATE_POOL)UnitTestAllocatePool, // AllocatePool
|
||||||
(EFI_FREE_POOL) UnitTestFreePool, // FreePool
|
(EFI_FREE_POOL)UnitTestFreePool, // FreePool
|
||||||
(EFI_CREATE_EVENT) UnitTestCreateEvent, // CreateEvent
|
(EFI_CREATE_EVENT)UnitTestCreateEvent, // CreateEvent
|
||||||
(EFI_SET_TIMER) UnitTestSetTimer, // SetTimer
|
(EFI_SET_TIMER)UnitTestSetTimer, // SetTimer
|
||||||
(EFI_WAIT_FOR_EVENT) UnitTestWaitForEvent, // WaitForEvent
|
(EFI_WAIT_FOR_EVENT)UnitTestWaitForEvent, // WaitForEvent
|
||||||
(EFI_SIGNAL_EVENT) UnitTestSignalEvent, // SignalEvent
|
(EFI_SIGNAL_EVENT)UnitTestSignalEvent, // SignalEvent
|
||||||
(EFI_CLOSE_EVENT) UnitTestCloseEvent, // CloseEvent
|
(EFI_CLOSE_EVENT)UnitTestCloseEvent, // CloseEvent
|
||||||
(EFI_CHECK_EVENT) UnitTestCheckEvent, // CheckEvent
|
(EFI_CHECK_EVENT)UnitTestCheckEvent, // CheckEvent
|
||||||
(EFI_INSTALL_PROTOCOL_INTERFACE) UnitTestInstallProtocolInterface, // InstallProtocolInterface
|
(EFI_INSTALL_PROTOCOL_INTERFACE)UnitTestInstallProtocolInterface, // InstallProtocolInterface
|
||||||
(EFI_REINSTALL_PROTOCOL_INTERFACE) UnitTestReinstallProtocolInterface, // ReinstallProtocolInterface
|
(EFI_REINSTALL_PROTOCOL_INTERFACE)UnitTestReinstallProtocolInterface, // ReinstallProtocolInterface
|
||||||
(EFI_UNINSTALL_PROTOCOL_INTERFACE) UnitTestUninstallProtocolInterface, // UninstallProtocolInterface
|
(EFI_UNINSTALL_PROTOCOL_INTERFACE)UnitTestUninstallProtocolInterface, // UninstallProtocolInterface
|
||||||
(EFI_HANDLE_PROTOCOL) UnitTestHandleProtocol, // HandleProtocol
|
(EFI_HANDLE_PROTOCOL)UnitTestHandleProtocol, // HandleProtocol
|
||||||
(VOID *) NULL, // Reserved
|
(VOID *)NULL, // Reserved
|
||||||
(EFI_REGISTER_PROTOCOL_NOTIFY) UnitTestRegisterProtocolNotify, // RegisterProtocolNotify
|
(EFI_REGISTER_PROTOCOL_NOTIFY)UnitTestRegisterProtocolNotify, // RegisterProtocolNotify
|
||||||
(EFI_LOCATE_HANDLE) UnitTestLocateHandle, // LocateHandle
|
(EFI_LOCATE_HANDLE)UnitTestLocateHandle, // LocateHandle
|
||||||
(EFI_LOCATE_DEVICE_PATH) UnitTestLocateDevicePath, // LocateDevicePath
|
(EFI_LOCATE_DEVICE_PATH)UnitTestLocateDevicePath, // LocateDevicePath
|
||||||
(EFI_INSTALL_CONFIGURATION_TABLE) UnitTestInstallConfigurationTable, // InstallConfigurationTable
|
(EFI_INSTALL_CONFIGURATION_TABLE)UnitTestInstallConfigurationTable, // InstallConfigurationTable
|
||||||
(EFI_IMAGE_LOAD) UnitTestLoadImage, // LoadImage
|
(EFI_IMAGE_LOAD)UnitTestLoadImage, // LoadImage
|
||||||
(EFI_IMAGE_START) UnitTestStartImage, // StartImage
|
(EFI_IMAGE_START)UnitTestStartImage, // StartImage
|
||||||
(EFI_EXIT) UnitTestExit, // Exit
|
(EFI_EXIT)UnitTestExit, // Exit
|
||||||
(EFI_IMAGE_UNLOAD) UnitTestUnloadImage, // UnloadImage
|
(EFI_IMAGE_UNLOAD)UnitTestUnloadImage, // UnloadImage
|
||||||
(EFI_EXIT_BOOT_SERVICES) UnitTestExitBootServices, // ExitBootServices
|
(EFI_EXIT_BOOT_SERVICES)UnitTestExitBootServices, // ExitBootServices
|
||||||
(EFI_GET_NEXT_MONOTONIC_COUNT) UnitTestGetNextMonotonicCount, // GetNextMonotonicCount
|
(EFI_GET_NEXT_MONOTONIC_COUNT)UnitTestGetNextMonotonicCount, // GetNextMonotonicCount
|
||||||
(EFI_STALL) UnitTestStall, // Stall
|
(EFI_STALL)UnitTestStall, // Stall
|
||||||
(EFI_SET_WATCHDOG_TIMER) UnitTestSetWatchdogTimer, // SetWatchdogTimer
|
(EFI_SET_WATCHDOG_TIMER)UnitTestSetWatchdogTimer, // SetWatchdogTimer
|
||||||
(EFI_CONNECT_CONTROLLER) UnitTestConnectController, // ConnectController
|
(EFI_CONNECT_CONTROLLER)UnitTestConnectController, // ConnectController
|
||||||
(EFI_DISCONNECT_CONTROLLER) UnitTestDisconnectController, // DisconnectController
|
(EFI_DISCONNECT_CONTROLLER)UnitTestDisconnectController, // DisconnectController
|
||||||
(EFI_OPEN_PROTOCOL) UnitTestOpenProtocol, // OpenProtocol
|
(EFI_OPEN_PROTOCOL)UnitTestOpenProtocol, // OpenProtocol
|
||||||
(EFI_CLOSE_PROTOCOL) UnitTestCloseProtocol, // CloseProtocol
|
(EFI_CLOSE_PROTOCOL)UnitTestCloseProtocol, // CloseProtocol
|
||||||
(EFI_OPEN_PROTOCOL_INFORMATION) UnitTestOpenProtocolInformation, // OpenProtocolInformation
|
(EFI_OPEN_PROTOCOL_INFORMATION)UnitTestOpenProtocolInformation, // OpenProtocolInformation
|
||||||
(EFI_PROTOCOLS_PER_HANDLE) UnitTestProtocolsPerHandle, // ProtocolsPerHandle
|
(EFI_PROTOCOLS_PER_HANDLE)UnitTestProtocolsPerHandle, // ProtocolsPerHandle
|
||||||
(EFI_LOCATE_HANDLE_BUFFER) UnitTestLocateHandleBuffer, // LocateHandleBuffer
|
(EFI_LOCATE_HANDLE_BUFFER)UnitTestLocateHandleBuffer, // LocateHandleBuffer
|
||||||
(EFI_LOCATE_PROTOCOL) UnitTestLocateProtocol, // LocateProtocol
|
(EFI_LOCATE_PROTOCOL)UnitTestLocateProtocol, // LocateProtocol
|
||||||
(EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) UnitTestInstallMultipleProtocolInterfaces, // InstallMultipleProtocolInterfaces
|
(EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES)UnitTestInstallMultipleProtocolInterfaces, // InstallMultipleProtocolInterfaces
|
||||||
(EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) UnitTestUninstallMultipleProtocolInterfaces, // UninstallMultipleProtocolInterfaces
|
(EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES)UnitTestUninstallMultipleProtocolInterfaces, // UninstallMultipleProtocolInterfaces
|
||||||
(EFI_CALCULATE_CRC32) UnitTestCalculateCrc32, // CalculateCrc32
|
(EFI_CALCULATE_CRC32)UnitTestCalculateCrc32, // CalculateCrc32
|
||||||
(EFI_COPY_MEM) CopyMem, // CopyMem
|
(EFI_COPY_MEM)CopyMem, // CopyMem
|
||||||
(EFI_SET_MEM) SetMem, // SetMem
|
(EFI_SET_MEM)SetMem, // SetMem
|
||||||
(EFI_CREATE_EVENT_EX) UnitTestCreateEventEx // CreateEventEx
|
(EFI_CREATE_EVENT_EX)UnitTestCreateEventEx // CreateEventEx
|
||||||
};
|
};
|
||||||
|
|
||||||
EFI_BOOT_SERVICES *gBS = &mBootServices;
|
EFI_BOOT_SERVICES *gBS = &mBootServices;
|
||||||
|
@ -37,8 +37,6 @@ UnitTestRaiseTpl (
|
|||||||
IN EFI_TPL NewTpl
|
IN EFI_TPL NewTpl
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Lowers the task priority to the previous value. If the new
|
Lowers the task priority to the previous value. If the new
|
||||||
priority unmasks events at a higher priority, they are dispatched.
|
priority unmasks events at a higher priority, they are dispatched.
|
||||||
@ -137,8 +135,6 @@ UnitTestGetMemoryMap (
|
|||||||
OUT UINT32 *DescriptorVersion
|
OUT UINT32 *DescriptorVersion
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Allocate pool of a particular type.
|
Allocate pool of a particular type.
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ UnitTestCalculateCrc32 (
|
|||||||
OUT UINT32 *Crc32
|
OUT UINT32 *Crc32
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (Data == NULL || Crc32 == NULL || DataSize == 0) {
|
if ((Data == NULL) || (Crc32 == NULL) || (DataSize == 0)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ STATIC UINTN mEfiLocateHandleRequest = 0;
|
|||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
UnitTestValidateHandle (
|
UnitTestValidateHandle (
|
||||||
IN EFI_HANDLE UserHandle
|
IN EFI_HANDLE UserHandle
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -40,7 +40,7 @@ EFI_STATUS
|
|||||||
|
|
||||||
for (Link = gHandleList.BackLink; Link != &gHandleList; Link = Link->BackLink) {
|
for (Link = gHandleList.BackLink; Link != &gHandleList; Link = Link->BackLink) {
|
||||||
Handle = CR (Link, IHANDLE, AllHandles, EFI_HANDLE_SIGNATURE);
|
Handle = CR (Link, IHANDLE, AllHandles, EFI_HANDLE_SIGNATURE);
|
||||||
if (Handle == (IHANDLE *) UserHandle) {
|
if (Handle == (IHANDLE *)UserHandle) {
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,11 +74,10 @@ UnitTestFindProtocolEntry (
|
|||||||
ProtEntry = NULL;
|
ProtEntry = NULL;
|
||||||
for (Link = mProtocolDatabase.ForwardLink;
|
for (Link = mProtocolDatabase.ForwardLink;
|
||||||
Link != &mProtocolDatabase;
|
Link != &mProtocolDatabase;
|
||||||
Link = Link->ForwardLink) {
|
Link = Link->ForwardLink)
|
||||||
|
{
|
||||||
Item = CR (Link, PROTOCOL_ENTRY, AllEntries, PROTOCOL_ENTRY_SIGNATURE);
|
Item = CR (Link, PROTOCOL_ENTRY, AllEntries, PROTOCOL_ENTRY_SIGNATURE);
|
||||||
if (CompareGuid (&Item->ProtocolID, Protocol)) {
|
if (CompareGuid (&Item->ProtocolID, Protocol)) {
|
||||||
|
|
||||||
//
|
//
|
||||||
// This is the protocol entry
|
// This is the protocol entry
|
||||||
//
|
//
|
||||||
@ -100,7 +99,7 @@ UnitTestFindProtocolEntry (
|
|||||||
// Initialize new protocol entry structure
|
// Initialize new protocol entry structure
|
||||||
//
|
//
|
||||||
ProtEntry->Signature = PROTOCOL_ENTRY_SIGNATURE;
|
ProtEntry->Signature = PROTOCOL_ENTRY_SIGNATURE;
|
||||||
CopyGuid ((VOID *) &ProtEntry->ProtocolID, Protocol);
|
CopyGuid ((VOID *)&ProtEntry->ProtocolID, Protocol);
|
||||||
InitializeListHead (&ProtEntry->Protocols);
|
InitializeListHead (&ProtEntry->Protocols);
|
||||||
InitializeListHead (&ProtEntry->Notify);
|
InitializeListHead (&ProtEntry->Notify);
|
||||||
|
|
||||||
@ -145,17 +144,15 @@ UnitTestFindProtocolInterface (
|
|||||||
|
|
||||||
ProtEntry = UnitTestFindProtocolEntry (Protocol, FALSE);
|
ProtEntry = UnitTestFindProtocolEntry (Protocol, FALSE);
|
||||||
if (ProtEntry != NULL) {
|
if (ProtEntry != NULL) {
|
||||||
|
|
||||||
//
|
//
|
||||||
// Look at each protocol interface for any matches
|
// Look at each protocol interface for any matches
|
||||||
//
|
//
|
||||||
for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link=Link->ForwardLink) {
|
for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) {
|
||||||
|
|
||||||
//
|
//
|
||||||
// If this protocol interface matches, remove it
|
// If this protocol interface matches, remove it
|
||||||
//
|
//
|
||||||
Prot = CR(Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
|
Prot = CR (Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
|
||||||
if (Prot->Interface == Interface && Prot->Protocol == ProtEntry) {
|
if ((Prot->Interface == Interface) && (Prot->Protocol == ProtEntry)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,8 +177,8 @@ UnitTestNotifyProtocolEntry (
|
|||||||
PROTOCOL_NOTIFY *ProtNotify;
|
PROTOCOL_NOTIFY *ProtNotify;
|
||||||
LIST_ENTRY *Link;
|
LIST_ENTRY *Link;
|
||||||
|
|
||||||
for (Link=ProtEntry->Notify.ForwardLink; Link != &ProtEntry->Notify; Link=Link->ForwardLink) {
|
for (Link = ProtEntry->Notify.ForwardLink; Link != &ProtEntry->Notify; Link = Link->ForwardLink) {
|
||||||
ProtNotify = CR(Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
|
ProtNotify = CR (Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
|
||||||
UnitTestSignalEvent (ProtNotify->Event);
|
UnitTestSignalEvent (ProtNotify->Event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -270,7 +267,6 @@ UnitTestGetNextLocateByRegisterNotify (
|
|||||||
return Handle;
|
return Handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Routine to get the next Handle, when you are searching for a given protocol.
|
Routine to get the next Handle, when you are searching for a given protocol.
|
||||||
|
|
||||||
@ -294,7 +290,7 @@ UnitTestGetNextLocateByProtocol (
|
|||||||
|
|
||||||
Handle = NULL;
|
Handle = NULL;
|
||||||
*Interface = NULL;
|
*Interface = NULL;
|
||||||
for (; ;) {
|
for ( ; ;) {
|
||||||
//
|
//
|
||||||
// Next entry
|
// Next entry
|
||||||
//
|
//
|
||||||
@ -368,6 +364,7 @@ UnitTestDisconnectControllersUsingProtocolInterface (
|
|||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
ItemFound = TRUE;
|
ItemFound = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -380,7 +377,8 @@ UnitTestDisconnectControllersUsingProtocolInterface (
|
|||||||
for (Link = Prot->OpenList.ForwardLink; Link != &Prot->OpenList;) {
|
for (Link = Prot->OpenList.ForwardLink; Link != &Prot->OpenList;) {
|
||||||
OpenData = CR (Link, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE);
|
OpenData = CR (Link, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE);
|
||||||
if ((OpenData->Attributes &
|
if ((OpenData->Attributes &
|
||||||
(EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL | EFI_OPEN_PROTOCOL_GET_PROTOCOL | EFI_OPEN_PROTOCOL_TEST_PROTOCOL)) != 0) {
|
(EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL | EFI_OPEN_PROTOCOL_GET_PROTOCOL | EFI_OPEN_PROTOCOL_TEST_PROTOCOL)) != 0)
|
||||||
|
{
|
||||||
Link = RemoveEntryList (&OpenData->Link);
|
Link = RemoveEntryList (&OpenData->Link);
|
||||||
Prot->OpenListCount--;
|
Prot->OpenListCount--;
|
||||||
FreePool (OpenData);
|
FreePool (OpenData);
|
||||||
@ -425,14 +423,13 @@ UnitTestRemoveInterfaceFromProtocol (
|
|||||||
|
|
||||||
Prot = UnitTestFindProtocolInterface (Handle, Protocol, Interface);
|
Prot = UnitTestFindProtocolInterface (Handle, Protocol, Interface);
|
||||||
if (Prot != NULL) {
|
if (Prot != NULL) {
|
||||||
|
|
||||||
ProtEntry = Prot->Protocol;
|
ProtEntry = Prot->Protocol;
|
||||||
|
|
||||||
//
|
//
|
||||||
// If there's a protocol notify location pointing to this entry, back it up one
|
// If there's a protocol notify location pointing to this entry, back it up one
|
||||||
//
|
//
|
||||||
for(Link = ProtEntry->Notify.ForwardLink; Link != &ProtEntry->Notify; Link=Link->ForwardLink) {
|
for (Link = ProtEntry->Notify.ForwardLink; Link != &ProtEntry->Notify; Link = Link->ForwardLink) {
|
||||||
ProtNotify = CR(Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
|
ProtNotify = CR (Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
|
||||||
|
|
||||||
if (ProtNotify->Position == &Prot->ByProtocol) {
|
if (ProtNotify->Position == &Prot->ByProtocol) {
|
||||||
ProtNotify->Position = Prot->ByProtocol.BackLink;
|
ProtNotify->Position = Prot->ByProtocol.BackLink;
|
||||||
@ -478,18 +475,19 @@ UnitTestGetProtocolInterface (
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle = (IHANDLE *) UserHandle;
|
Handle = (IHANDLE *)UserHandle;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Look at each protocol interface for a match
|
// Look at each protocol interface for a match
|
||||||
//
|
//
|
||||||
for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) {
|
for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) {
|
||||||
Prot = CR(Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
|
Prot = CR (Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
|
||||||
ProtEntry = Prot->Protocol;
|
ProtEntry = Prot->Protocol;
|
||||||
if (CompareGuid (&ProtEntry->ProtocolID, Protocol)) {
|
if (CompareGuid (&ProtEntry->ProtocolID, Protocol)) {
|
||||||
return Prot;
|
return Prot;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -529,7 +527,7 @@ UnitTestInstallProtocolInterfaceNotify (
|
|||||||
// returns EFI_INVALID_PARAMETER if InterfaceType is invalid.
|
// returns EFI_INVALID_PARAMETER if InterfaceType is invalid.
|
||||||
// Also added check for invalid UserHandle and Protocol pointers.
|
// Also added check for invalid UserHandle and Protocol pointers.
|
||||||
//
|
//
|
||||||
if (UserHandle == NULL || Protocol == NULL) {
|
if ((UserHandle == NULL) || (Protocol == NULL)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -547,7 +545,7 @@ UnitTestInstallProtocolInterfaceNotify (
|
|||||||
Handle = NULL;
|
Handle = NULL;
|
||||||
|
|
||||||
if (*UserHandle != NULL) {
|
if (*UserHandle != NULL) {
|
||||||
Status = UnitTestHandleProtocol (*UserHandle, Protocol, (VOID **) &ExistingInterface);
|
Status = UnitTestHandleProtocol (*UserHandle, Protocol, (VOID **)&ExistingInterface);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
@ -573,7 +571,7 @@ UnitTestInstallProtocolInterfaceNotify (
|
|||||||
//
|
//
|
||||||
// If caller didn't supply a handle, allocate a new one
|
// If caller didn't supply a handle, allocate a new one
|
||||||
//
|
//
|
||||||
Handle = (IHANDLE *) *UserHandle;
|
Handle = (IHANDLE *)*UserHandle;
|
||||||
if (Handle == NULL) {
|
if (Handle == NULL) {
|
||||||
Handle = AllocateZeroPool (sizeof (IHANDLE));
|
Handle = AllocateZeroPool (sizeof (IHANDLE));
|
||||||
if (Handle == NULL) {
|
if (Handle == NULL) {
|
||||||
@ -601,7 +599,7 @@ UnitTestInstallProtocolInterfaceNotify (
|
|||||||
} else {
|
} else {
|
||||||
Status = UnitTestValidateHandle (Handle);
|
Status = UnitTestValidateHandle (Handle);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG((DEBUG_ERROR, "InstallProtocolInterface: input handle at 0x%x is invalid\n", Handle));
|
DEBUG ((DEBUG_ERROR, "InstallProtocolInterface: input handle at 0x%x is invalid\n", Handle));
|
||||||
goto Done;
|
goto Done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -643,6 +641,7 @@ UnitTestInstallProtocolInterfaceNotify (
|
|||||||
if (Notify) {
|
if (Notify) {
|
||||||
UnitTestNotifyProtocolEntry (ProtEntry);
|
UnitTestNotifyProtocolEntry (ProtEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
|
|
||||||
Done:
|
Done:
|
||||||
@ -658,6 +657,7 @@ Done:
|
|||||||
if (Prot != NULL) {
|
if (Prot != NULL) {
|
||||||
UnitTestFreePool (Prot);
|
UnitTestFreePool (Prot);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG ((DEBUG_ERROR, "InstallProtocolInterface: %g %p failed with %r\n", Protocol, Interface, Status));
|
DEBUG ((DEBUG_ERROR, "InstallProtocolInterface: %g %p failed with %r\n", Protocol, Interface, Status));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -789,7 +789,7 @@ UnitTestUninstallProtocolInterface (
|
|||||||
// Remove the protocol interface from the protocol
|
// Remove the protocol interface from the protocol
|
||||||
//
|
//
|
||||||
Status = EFI_NOT_FOUND;
|
Status = EFI_NOT_FOUND;
|
||||||
Handle = (IHANDLE *) UserHandle;
|
Handle = (IHANDLE *)UserHandle;
|
||||||
Prot = UnitTestRemoveInterfaceFromProtocol (Handle, Protocol, Interface);
|
Prot = UnitTestRemoveInterfaceFromProtocol (Handle, Protocol, Interface);
|
||||||
|
|
||||||
if (Prot != NULL) {
|
if (Prot != NULL) {
|
||||||
@ -933,7 +933,7 @@ UnitTestLocateHandle (
|
|||||||
Position.Position = &gHandleList;
|
Position.Position = &gHandleList;
|
||||||
|
|
||||||
ResultSize = 0;
|
ResultSize = 0;
|
||||||
ResultBuffer = (IHANDLE **) Buffer;
|
ResultBuffer = (IHANDLE **)Buffer;
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -952,6 +952,7 @@ UnitTestLocateHandle (
|
|||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetNext = UnitTestGetNextLocateByRegisterNotify;
|
GetNext = UnitTestGetNextLocateByRegisterNotify;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -961,6 +962,7 @@ UnitTestLocateHandle (
|
|||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Look up the protocol entry and set the head pointer
|
// Look up the protocol entry and set the head pointer
|
||||||
//
|
//
|
||||||
@ -969,6 +971,7 @@ UnitTestLocateHandle (
|
|||||||
Status = EFI_NOT_FOUND;
|
Status = EFI_NOT_FOUND;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Position.Position = &Position.ProtEntry->Protocols;
|
Position.Position = &Position.ProtEntry->Protocols;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -986,7 +989,7 @@ UnitTestLocateHandle (
|
|||||||
// Enumerate out the matching handles
|
// Enumerate out the matching handles
|
||||||
//
|
//
|
||||||
mEfiLocateHandleRequest += 1;
|
mEfiLocateHandleRequest += 1;
|
||||||
for (; ;) {
|
for ( ; ;) {
|
||||||
//
|
//
|
||||||
// Get the next handle. If no more handles, stop
|
// Get the next handle. If no more handles, stop
|
||||||
//
|
//
|
||||||
@ -1023,7 +1026,7 @@ UnitTestLocateHandle (
|
|||||||
|
|
||||||
*BufferSize = ResultSize;
|
*BufferSize = ResultSize;
|
||||||
|
|
||||||
if (SearchType == ByRegisterNotify && !EFI_ERROR(Status)) {
|
if ((SearchType == ByRegisterNotify) && !EFI_ERROR (Status)) {
|
||||||
//
|
//
|
||||||
// If this is a search by register notify and a handle was
|
// If this is a search by register notify and a handle was
|
||||||
// returned, update the register notification position
|
// returned, update the register notification position
|
||||||
@ -1154,39 +1157,45 @@ UnitTestOpenProtocol (
|
|||||||
// Check for invalid Attributes
|
// Check for invalid Attributes
|
||||||
//
|
//
|
||||||
switch (Attributes) {
|
switch (Attributes) {
|
||||||
case EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER :
|
case EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER:
|
||||||
Status = UnitTestValidateHandle (ImageHandle);
|
Status = UnitTestValidateHandle (ImageHandle);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = UnitTestValidateHandle (ControllerHandle);
|
Status = UnitTestValidateHandle (ControllerHandle);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UserHandle == ControllerHandle) {
|
if (UserHandle == ControllerHandle) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case EFI_OPEN_PROTOCOL_BY_DRIVER :
|
case EFI_OPEN_PROTOCOL_BY_DRIVER:
|
||||||
case EFI_OPEN_PROTOCOL_BY_DRIVER | EFI_OPEN_PROTOCOL_EXCLUSIVE :
|
case EFI_OPEN_PROTOCOL_BY_DRIVER | EFI_OPEN_PROTOCOL_EXCLUSIVE:
|
||||||
Status = UnitTestValidateHandle (ImageHandle);
|
Status = UnitTestValidateHandle (ImageHandle);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = UnitTestValidateHandle (ControllerHandle);
|
Status = UnitTestValidateHandle (ControllerHandle);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case EFI_OPEN_PROTOCOL_EXCLUSIVE :
|
case EFI_OPEN_PROTOCOL_EXCLUSIVE:
|
||||||
Status = UnitTestValidateHandle (ImageHandle);
|
Status = UnitTestValidateHandle (ImageHandle);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL :
|
case EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL:
|
||||||
case EFI_OPEN_PROTOCOL_GET_PROTOCOL :
|
case EFI_OPEN_PROTOCOL_GET_PROTOCOL:
|
||||||
case EFI_OPEN_PROTOCOL_TEST_PROTOCOL :
|
case EFI_OPEN_PROTOCOL_TEST_PROTOCOL:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
@ -1217,6 +1226,7 @@ UnitTestOpenProtocol (
|
|||||||
goto Done;
|
goto Done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((OpenData->Attributes & EFI_OPEN_PROTOCOL_EXCLUSIVE) != 0) {
|
if ((OpenData->Attributes & EFI_OPEN_PROTOCOL_EXCLUSIVE) != 0) {
|
||||||
Exclusive = TRUE;
|
Exclusive = TRUE;
|
||||||
} else if (ExactMatch) {
|
} else if (ExactMatch) {
|
||||||
@ -1234,18 +1244,20 @@ UnitTestOpenProtocol (
|
|||||||
//
|
//
|
||||||
|
|
||||||
switch (Attributes) {
|
switch (Attributes) {
|
||||||
case EFI_OPEN_PROTOCOL_BY_DRIVER :
|
case EFI_OPEN_PROTOCOL_BY_DRIVER:
|
||||||
if (Exclusive || ByDriver) {
|
if (Exclusive || ByDriver) {
|
||||||
Status = EFI_ACCESS_DENIED;
|
Status = EFI_ACCESS_DENIED;
|
||||||
goto Done;
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case EFI_OPEN_PROTOCOL_BY_DRIVER | EFI_OPEN_PROTOCOL_EXCLUSIVE :
|
case EFI_OPEN_PROTOCOL_BY_DRIVER | EFI_OPEN_PROTOCOL_EXCLUSIVE:
|
||||||
case EFI_OPEN_PROTOCOL_EXCLUSIVE :
|
case EFI_OPEN_PROTOCOL_EXCLUSIVE:
|
||||||
if (Exclusive) {
|
if (Exclusive) {
|
||||||
Status = EFI_ACCESS_DENIED;
|
Status = EFI_ACCESS_DENIED;
|
||||||
goto Done;
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ByDriver) {
|
if (ByDriver) {
|
||||||
do {
|
do {
|
||||||
Disconnect = FALSE;
|
Disconnect = FALSE;
|
||||||
@ -1264,11 +1276,12 @@ UnitTestOpenProtocol (
|
|||||||
}
|
}
|
||||||
} while (Disconnect);
|
} while (Disconnect);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER :
|
case EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER:
|
||||||
case EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL :
|
case EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL:
|
||||||
case EFI_OPEN_PROTOCOL_GET_PROTOCOL :
|
case EFI_OPEN_PROTOCOL_GET_PROTOCOL:
|
||||||
case EFI_OPEN_PROTOCOL_TEST_PROTOCOL :
|
case EFI_OPEN_PROTOCOL_TEST_PROTOCOL:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1276,10 +1289,11 @@ UnitTestOpenProtocol (
|
|||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
goto Done;
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create new entry
|
// Create new entry
|
||||||
//
|
//
|
||||||
OpenData = AllocatePool (sizeof(OPEN_PROTOCOL_DATA));
|
OpenData = AllocatePool (sizeof (OPEN_PROTOCOL_DATA));
|
||||||
if (OpenData == NULL) {
|
if (OpenData == NULL) {
|
||||||
Status = EFI_OUT_OF_RESOURCES;
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
} else {
|
} else {
|
||||||
@ -1300,7 +1314,7 @@ Done:
|
|||||||
// Keep Interface unmodified in case of any Error
|
// Keep Interface unmodified in case of any Error
|
||||||
// except EFI_ALREADY_STARTED and EFI_UNSUPPORTED.
|
// except EFI_ALREADY_STARTED and EFI_UNSUPPORTED.
|
||||||
//
|
//
|
||||||
if (!EFI_ERROR (Status) || Status == EFI_ALREADY_STARTED) {
|
if (!EFI_ERROR (Status) || (Status == EFI_ALREADY_STARTED)) {
|
||||||
//
|
//
|
||||||
// According to above logic, if 'Prot' is NULL, then the 'Status' must be
|
// According to above logic, if 'Prot' is NULL, then the 'Status' must be
|
||||||
// EFI_UNSUPPORTED. Here the 'Status' is not EFI_UNSUPPORTED, so 'Prot'
|
// EFI_UNSUPPORTED. Here the 'Status' is not EFI_UNSUPPORTED, so 'Prot'
|
||||||
@ -1479,10 +1493,11 @@ UnitTestLocateHandleBuffer (
|
|||||||
//
|
//
|
||||||
// Add code to correctly handle expected errors from UnitTestLocateHandle().
|
// Add code to correctly handle expected errors from UnitTestLocateHandle().
|
||||||
//
|
//
|
||||||
if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) {
|
if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
|
||||||
if (Status != EFI_INVALID_PARAMETER) {
|
if (Status != EFI_INVALID_PARAMETER) {
|
||||||
Status = EFI_NOT_FOUND;
|
Status = EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1609,6 +1624,7 @@ UnitTestUninstallMultipleProtocolInterfaces (
|
|||||||
//
|
//
|
||||||
Status = UnitTestUninstallProtocolInterface (Handle, Protocol, Interface);
|
Status = UnitTestUninstallProtocolInterface (Handle, Protocol, Interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
VA_END (Args);
|
VA_END (Args);
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -1620,11 +1636,12 @@ UnitTestUninstallMultipleProtocolInterfaces (
|
|||||||
// Reset the va_arg back to the first argument.
|
// Reset the va_arg back to the first argument.
|
||||||
//
|
//
|
||||||
VA_START (Args, Handle);
|
VA_START (Args, Handle);
|
||||||
for (; Index > 1; Index--) {
|
for ( ; Index > 1; Index--) {
|
||||||
Protocol = VA_ARG(Args, EFI_GUID *);
|
Protocol = VA_ARG (Args, EFI_GUID *);
|
||||||
Interface = VA_ARG(Args, VOID *);
|
Interface = VA_ARG (Args, VOID *);
|
||||||
UnitTestInstallProtocolInterface (&Handle, Protocol, EFI_NATIVE_INTERFACE, Interface);
|
UnitTestInstallProtocolInterface (&Handle, Protocol, EFI_NATIVE_INTERFACE, Interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
VA_END (Args);
|
VA_END (Args);
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,6 @@ typedef struct {
|
|||||||
LIST_ENTRY Notify;
|
LIST_ENTRY Notify;
|
||||||
} PROTOCOL_ENTRY;
|
} PROTOCOL_ENTRY;
|
||||||
|
|
||||||
|
|
||||||
#define PROTOCOL_INTERFACE_SIGNATURE SIGNATURE_32('p','i','f','c')
|
#define PROTOCOL_INTERFACE_SIGNATURE SIGNATURE_32('p','i','f','c')
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -73,14 +72,13 @@ typedef struct {
|
|||||||
/// OPEN_PROTOCOL_DATA list
|
/// OPEN_PROTOCOL_DATA list
|
||||||
LIST_ENTRY OpenList;
|
LIST_ENTRY OpenList;
|
||||||
UINTN OpenListCount;
|
UINTN OpenListCount;
|
||||||
|
|
||||||
} PROTOCOL_INTERFACE;
|
} PROTOCOL_INTERFACE;
|
||||||
|
|
||||||
#define OPEN_PROTOCOL_DATA_SIGNATURE SIGNATURE_32('p','o','d','l')
|
#define OPEN_PROTOCOL_DATA_SIGNATURE SIGNATURE_32('p','o','d','l')
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
UINTN Signature;
|
UINTN Signature;
|
||||||
///Link on PROTOCOL_INTERFACE.OpenList
|
/// Link on PROTOCOL_INTERFACE.OpenList
|
||||||
LIST_ENTRY Link;
|
LIST_ENTRY Link;
|
||||||
|
|
||||||
EFI_HANDLE AgentHandle;
|
EFI_HANDLE AgentHandle;
|
||||||
@ -89,7 +87,6 @@ typedef struct {
|
|||||||
UINT32 OpenCount;
|
UINT32 OpenCount;
|
||||||
} OPEN_PROTOCOL_DATA;
|
} OPEN_PROTOCOL_DATA;
|
||||||
|
|
||||||
|
|
||||||
#define PROTOCOL_NOTIFY_SIGNATURE SIGNATURE_32('p','r','t','n')
|
#define PROTOCOL_NOTIFY_SIGNATURE SIGNATURE_32('p','r','t','n')
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -115,7 +112,7 @@ typedef struct {
|
|||||||
|
|
||||||
typedef
|
typedef
|
||||||
IHANDLE *
|
IHANDLE *
|
||||||
(* UNIT_TEST_GET_NEXT) (
|
(*UNIT_TEST_GET_NEXT) (
|
||||||
IN OUT LOCATE_POSITION *Position,
|
IN OUT LOCATE_POSITION *Position,
|
||||||
OUT VOID **Interface
|
OUT VOID **Interface
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user