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:
Michael Kubacki 2022-03-15 14:46:34 -04:00 committed by mergify[bot]
parent f3c11224b5
commit a298a84478
40 changed files with 1501 additions and 1431 deletions

View File

@ -47,10 +47,10 @@ STATIC EFI_HII_HANDLE mPrmInfoHiiHandle;
STATIC LIST_ENTRY mPrmHandlerList;
STATIC CONST SHELL_PARAM_ITEM mParamList[] = {
{L"-l", TypeFlag},
{L"-t", TypeValue},
{NULL, TypeMax}
};
{ L"-l", TypeFlag },
{ L"-t", TypeValue },
{ NULL, TypeMax }
};
/**
Frees all of the nodes in a linked list.
@ -102,6 +102,7 @@ CreateNewPrmHandlerListEntry (
if (PrmHandlerContextListEntry == NULL) {
return NULL;
}
PrmHandlerContextListEntry->Signature = PRM_HANDLER_CONTEXT_LIST_ENTRY_SIGNATURE;
return PrmHandlerContextListEntry;
@ -125,7 +126,7 @@ PrintMmioRuntimeRangeInfo (
return;
}
RuntimeMmioRangeCount = (UINTN) RuntimeMmioRanges->Count;
RuntimeMmioRangeCount = (UINTN)RuntimeMmioRanges->Count;
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_RUNTIME_MMIO_COUNT), mPrmInfoHiiHandle, RuntimeMmioRangeCount);
for (RuntimeMmioRangeIndex = 0; RuntimeMmioRangeIndex < RuntimeMmioRangeCount; RuntimeMmioRangeIndex++) {
@ -184,8 +185,8 @@ GatherPrmHandlerInfo (
for (
CurrentPrmModuleImageContext = NULL, Status = GetNextPrmModuleEntry (&CurrentPrmModuleImageContext);
!EFI_ERROR (Status);
Status = GetNextPrmModuleEntry (&CurrentPrmModuleImageContext)) {
Status = GetNextPrmModuleEntry (&CurrentPrmModuleImageContext))
{
CurrentImageAddress = CurrentPrmModuleImageContext->PeCoffImageContext.ImageAddress;
CurrentImageExportDirectory = CurrentPrmModuleImageContext->ExportDirectory;
CurrentExportDescriptorStruct = CurrentPrmModuleImageContext->ExportDescriptor;
@ -196,7 +197,7 @@ GatherPrmHandlerInfo (
MajorVersion = 0;
MinorVersion = 0;
Status = GetImageVersionInPeCoffImage (
(VOID *) (UINTN) CurrentImageAddress,
(VOID *)(UINTN)CurrentImageAddress,
&CurrentPrmModuleImageContext->PeCoffImageContext,
&MajorVersion,
&MinorVersion
@ -210,7 +211,7 @@ GatherPrmHandlerInfo (
NULL,
STRING_TOKEN (STR_PRMINFO_MODULE_NAME),
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_VERSION), mPrmInfoHiiHandle, MajorVersion, MinorVersion);
@ -221,10 +222,10 @@ GatherPrmHandlerInfo (
Status = GetModuleContextBuffers (
ByModuleGuid,
CurrentModuleGuid,
(CONST PRM_MODULE_CONTEXT_BUFFERS **) &CurrentModuleContextBuffers
(CONST PRM_MODULE_CONTEXT_BUFFERS **)&CurrentModuleContextBuffers
);
ASSERT (!EFI_ERROR (Status) || Status == EFI_NOT_FOUND);
if (!EFI_ERROR (Status) && CurrentModuleContextBuffers != NULL) {
if (!EFI_ERROR (Status) && (CurrentModuleContextBuffers != NULL)) {
CurrentPrmModuleRuntimeMmioRanges = CurrentModuleContextBuffers->RuntimeMmioRanges;
}
@ -234,6 +235,7 @@ GatherPrmHandlerInfo (
} else {
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_HANDLER_COUNT), mPrmInfoHiiHandle, HandlerCount);
}
@ -241,9 +243,9 @@ GatherPrmHandlerInfo (
for (HandlerIndex = 0; HandlerIndex < HandlerCount; HandlerIndex++) {
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.Name = (CHAR8 *) CurrentExportDescriptorStruct->PrmHandlerExportDescriptors[HandlerIndex].PrmHandlerName;
CurrentHandlerContext.Name = (CHAR8 *)CurrentExportDescriptorStruct->PrmHandlerExportDescriptors[HandlerIndex].PrmHandlerName;
if (PrintInformation) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_HANDLER_NAME), mPrmInfoHiiHandle, CurrentHandlerContext.Name);
@ -258,7 +260,7 @@ GatherPrmHandlerInfo (
);
ASSERT_EFI_ERROR (Status);
if (!EFI_ERROR (Status)) {
CurrentHandlerContext.Handler = (PRM_HANDLER *) (UINTN) CurrentHandlerPhysicalAddress;
CurrentHandlerContext.Handler = (PRM_HANDLER *)(UINTN)CurrentHandlerPhysicalAddress;
if (PrintInformation) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_HANDLER_PA), mPrmInfoHiiHandle, CurrentHandlerPhysicalAddress);
@ -272,7 +274,7 @@ GatherPrmHandlerInfo (
Status = GetContextBuffer (
CurrentHandlerContext.Guid,
CurrentModuleContextBuffers,
(CONST PRM_CONTEXT_BUFFER **) &CurrentContextBuffer
(CONST PRM_CONTEXT_BUFFER **)&CurrentContextBuffer
);
if (!EFI_ERROR (Status)) {
CurrentHandlerContext.StaticDataBuffer = CurrentContextBuffer->StaticDataBuffer;
@ -286,7 +288,7 @@ GatherPrmHandlerInfo (
NULL,
STRING_TOKEN (STR_PRMINFO_STATIC_DATA_BUFFER),
mPrmInfoHiiHandle,
(UINTN) CurrentHandlerContext.StaticDataBuffer
(UINTN)CurrentHandlerContext.StaticDataBuffer
);
} else {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PRMINFO_LINE_BREAK), mPrmInfoHiiHandle);
@ -329,7 +331,7 @@ PopulateContextBuffer (
IN PRM_CONTEXT_BUFFER *ContextBuffer
)
{
if (HandlerGuid == NULL || ContextBuffer == NULL) {
if ((HandlerGuid == NULL) || (ContextBuffer == NULL)) {
return EFI_INVALID_PARAMETER;
}
@ -465,6 +467,7 @@ ExecutePrmHandlerByGuid (
if (PcdGetBool (PcdPrmInfoPrintHandlerExecutionTime)) {
StartTime = GetPerformanceCounter ();
}
Status = HandlerContext->Handler (NULL, &CurrentContextBuffer);
if (PcdGetBool (PcdPrmInfoPrintHandlerExecutionTime)) {
EndTime = GetPerformanceCounter ();
@ -477,11 +480,12 @@ ExecutePrmHandlerByGuid (
}
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);
} else {
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);
} else {
@ -541,7 +545,7 @@ ParseParameterList (
//
Status = ShellCommandLineParseEx (mParamList, &Package, &ProblemParam, FALSE, FALSE);
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);
ReturnStatus = EFI_INVALID_PARAMETER;
FreePool (ProblemParam);
@ -564,7 +568,9 @@ ParseParameterList (
ArgumentCount = 0, TempNode = Package;
GetNextNode (Package, TempNode) != Package;
ArgumentCount++, TempNode = GetNextNode (Package, TempNode)
);
)
{
}
if (ArgumentCount == 1) {
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_LINE_BREAK), mPrmInfoHiiHandle);
}
GatherPrmHandlerInfo (PrintHandlerInfo);
if (HandlerGuidStr != NULL) {
@ -680,7 +687,7 @@ UefiMain (
Status = gBS->OpenProtocol (
ImageHandle,
&gEfiHiiPackageListProtocolGuid,
(VOID **) &PackageList,
(VOID **)&PackageList,
ImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL

View File

@ -13,10 +13,10 @@
#include <Uefi.h>
#include <PrmContextBuffer.h>
#if defined(_MSC_VER)
#define PRM_EXPORT_API __declspec(dllexport)
#if defined (_MSC_VER)
#define PRM_EXPORT_API __declspec(dllexport)
#else
#define PRM_EXPORT_API
#define PRM_EXPORT_API
#endif
#define PRM_HANDLER_NAME_MAXIMUM_LENGTH 128
@ -38,7 +38,7 @@
**/
typedef
EFI_STATUS
(EFIAPI PRM_HANDLER) (
(EFIAPI PRM_HANDLER)(
IN VOID *ParameterBuffer OPTIONAL,
IN PRM_CONTEXT_BUFFER *ContextBuffer OPTIONAL
);

View File

@ -98,8 +98,7 @@ typedef struct {
// A firmware internal data structure used to track context buffer and
// runtime MMIO range usage across a PRM module.
//
typedef struct
{
typedef struct {
///
/// The GUID of the PRM module.
///

View File

@ -41,11 +41,11 @@ typedef struct {
#pragma pack(pop)
#if defined(_MSC_VER)
#define PRM_PACKED_STRUCT(definition) \
#if defined (_MSC_VER)
#define PRM_PACKED_STRUCT(definition) \
__pragma(pack(push, 1)) typedef struct definition __pragma(pack(pop))
#elif defined (__GNUC__) || defined (__clang__)
#define PRM_PACKED_STRUCT(definition) \
#define PRM_PACKED_STRUCT(definition) \
typedef struct __attribute__((packed)) definition
#endif
@ -67,6 +67,7 @@ typedef struct {
PRM_STRING_(Name) \
} \
/**
A macro that returns the count of the number of variable-length arguments given.

View File

@ -26,7 +26,7 @@
#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."); \
\
/** \
/** \
A Platform Runtime Mechanism (PRM) handler. \
\
@param[in] ParameterBuffer A pointer to the PRM handler parameter buffer \
@ -35,7 +35,7 @@
@retval EFI_STATUS The PRM handler executed successfully. \
@retval Others An error occurred in the PRM handler. \
\
**/ \
**/ \
EFI_STATUS \
PRM_EXPORT_API \
EFIAPI \

View File

@ -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_VERSION 1
struct _PRM_CONFIG_PROTOCOL
{
struct _PRM_CONFIG_PROTOCOL {
PRM_MODULE_CONTEXT_BUFFERS ModuleContextBuffers;
};

View File

@ -42,7 +42,7 @@ FindContextBufferInModuleBuffers (
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;
}
@ -91,9 +91,10 @@ GetModuleContextBuffers (
DEBUG ((DEBUG_INFO, " %a %a - Entry.\n", _DBGMSGID_, __FUNCTION__));
if (Guid == NULL || PrmModuleContextBuffers == NULL) {
if ((Guid == NULL) || (PrmModuleContextBuffers == NULL)) {
return EFI_INVALID_PARAMETER;
}
*PrmModuleContextBuffers = NULL;
Status = gBS->LocateHandleBuffer (
@ -108,10 +109,10 @@ GetModuleContextBuffers (
Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gPrmConfigProtocolGuid,
(VOID **) &PrmConfigProtocol
(VOID **)&PrmConfigProtocol
);
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status) || PrmConfigProtocol == NULL) {
if (EFI_ERROR (Status) || (PrmConfigProtocol == NULL)) {
continue;
}
@ -177,9 +178,10 @@ GetContextBuffer (
DEBUG ((DEBUG_INFO, " %a %a - Entry.\n", _DBGMSGID_, __FUNCTION__));
if (PrmHandlerGuid == NULL || PrmContextBuffer == NULL) {
if ((PrmHandlerGuid == NULL) || (PrmContextBuffer == NULL)) {
return EFI_INVALID_PARAMETER;
}
*PrmContextBuffer = NULL;
if (PrmModuleContextBuffers == NULL) {
@ -190,6 +192,7 @@ GetContextBuffer (
} else {
ContextBuffers = PrmModuleContextBuffers;
}
Status = FindContextBufferInModuleBuffers (PrmHandlerGuid, ContextBuffers, PrmContextBuffer);
return Status;

View File

@ -30,13 +30,13 @@
#define UNIT_TEST_NAME "PRM Context Buffer Library Unit Test"
#define UNIT_TEST_VERSION "0.1"
///=== TEST DATA ==================================================================================
/// === TEST DATA ==================================================================================
EFI_HANDLE mTestProtocolHandle;
//*----------------------------------------------------------------------------------*
//* Context Structures *
//*----------------------------------------------------------------------------------*
// *----------------------------------------------------------------------------------*
// * Context Structures *
// *----------------------------------------------------------------------------------*
typedef struct {
PRM_MODULE_CONTEXT_BUFFERS *InstallationStructure;
EFI_HANDLE Handle;
@ -53,9 +53,9 @@ typedef struct {
EFI_STATUS ExpectedStatus;
} PRM_CONTEXT_BUFFER_TEST_CONTEXT;
//*----------------------------------------------------------------------------------*
//* Test GUIDs *
//*----------------------------------------------------------------------------------*
// *----------------------------------------------------------------------------------*
// * Test GUIDs *
// *----------------------------------------------------------------------------------*
// {52960b90-2f3a-4917-b91a-ed5f599a8809}
#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 }}
EFI_GUID mNegativeTestGuid = NEGATIVE_TEST_GUID;
//*----------------------------------------------------------------------------------*
//* PRM Static Test Structures *
//*----------------------------------------------------------------------------------*
// *----------------------------------------------------------------------------------*
// * PRM Static Test Structures *
// *----------------------------------------------------------------------------------*
PRM_DATA_BUFFER mTestStaticDataBuffer1 = {
{
@ -145,12 +145,11 @@ PRM_MODULE_CONTEXT_BUFFERS mTestPrmModuleContextBuffers3 = {
NULL
};
// *----------------------------------------------------------------------------------*
// * Test Contexts *
// *----------------------------------------------------------------------------------*
//*----------------------------------------------------------------------------------*
//* Test Contexts *
//*----------------------------------------------------------------------------------*
//* Searches by module GUID *
// * Searches by module GUID *
// +--------------------------------+--------+----------------+--------------------+--------------------+--------------------+
// + 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 mContextBuffers04 = { &mTestPrmModuleContextBuffers1, NULL, ByModuleGuid, &gZeroGuid, &gZeroGuid, EFI_NOT_FOUND };
//* Searches by handler GUID *
// * Searches by handler GUID *
// +--------------------------------+--------+----------------+--------------------+--------------------+--------------------+
// + InstallationStructure | Handle | GuidSearchType | Guid | ExpectedModuleGuid | ExpectedStatus |
// +--------------------------------+--------+----------------+--------------------+--------------------+--------------------+
@ -208,13 +207,13 @@ PRM_CONTEXT_BUFFER_TEST_CONTEXT *mContextBufferArray[] = {
&mContextBuffer05
};
///=== HELPER FUNCTIONS ===========================================================================
/// === HELPER FUNCTIONS ===========================================================================
// None
///=== TEST CASES =================================================================================
/// === TEST CASES =================================================================================
///===== BASIC SUITE ==================================================
/// ===== BASIC SUITE ==================================================
/**
Verifies that passing NULL arguments to all library functions fails with EFI_INVALID_PARAMETER.
@ -254,7 +253,7 @@ NullPointerArgumentsShouldFailGracefully (
return UNIT_TEST_PASSED;
}
///===== FUNCTIONAL CORRECTNESS SUITE ==================================================
/// ===== FUNCTIONAL CORRECTNESS SUITE ==================================================
/**
Functional Correctness pre-requisite function.
@ -284,7 +283,7 @@ InitializeFunctionalCorrectness (
PRM_CONTEXT_BUFFERS_TEST_CONTEXT *TestContext;
UT_ASSERT_NOT_NULL (Context);
TestContext = (PRM_CONTEXT_BUFFERS_TEST_CONTEXT *) Context;
TestContext = (PRM_CONTEXT_BUFFERS_TEST_CONTEXT *)Context;
ModuleContextBuffers = TestContext->InstallationStructure;
PrmConfigProtocol = AllocateZeroPool (sizeof (*PrmConfigProtocol));
@ -300,7 +299,7 @@ InitializeFunctionalCorrectness (
&TestContext->Handle,
&gPrmConfigProtocolGuid,
EFI_NATIVE_INTERFACE,
(VOID *) PrmConfigProtocol
(VOID *)PrmConfigProtocol
);
UT_ASSERT_NOT_EFI_ERROR (Status);
@ -334,12 +333,12 @@ DeInitializeFunctionalCorrectness (
PRM_CONTEXT_BUFFERS_TEST_CONTEXT *TestContext;
UT_ASSERT_NOT_NULL (Context);
TestContext = (PRM_CONTEXT_BUFFERS_TEST_CONTEXT *) Context;
TestContext = (PRM_CONTEXT_BUFFERS_TEST_CONTEXT *)Context;
Status = gBS->HandleProtocol (
TestContext->Handle,
&gPrmConfigProtocolGuid,
(VOID **) &PrmConfigProtocol
(VOID **)&PrmConfigProtocol
);
UT_ASSERT_NOT_EFI_ERROR (Status);
@ -381,7 +380,7 @@ VerifyGetModuleContextBuffers (
PRM_CONTEXT_BUFFERS_TEST_CONTEXT *TestContext;
ContextBuffers = NULL;
TestContext = (PRM_CONTEXT_BUFFERS_TEST_CONTEXT *) Context;
TestContext = (PRM_CONTEXT_BUFFERS_TEST_CONTEXT *)Context;
Status = GetModuleContextBuffers (TestContext->GuidSearchType, TestContext->Guid, &ContextBuffers);
UT_ASSERT_STATUS_EQUAL (Status, TestContext->ExpectedStatus);
@ -393,7 +392,7 @@ VerifyGetModuleContextBuffers (
__FUNCTION__,
((TestContext->GuidSearchType == ByModuleGuid) ? "module" : "handler"),
TestContext->Guid,
(UINTN) ContextBuffers
(UINTN)ContextBuffers
);
}
@ -425,7 +424,7 @@ VerifyFindContextBufferInModuleBuffers (
ContextBuffers = NULL;
FoundContextBuffer = NULL;
TestContext = (PRM_CONTEXT_BUFFER_TEST_CONTEXT *) Context;
TestContext = (PRM_CONTEXT_BUFFER_TEST_CONTEXT *)Context;
Status = FindContextBufferInModuleBuffers (TestContext->HandlerGuid, TestContext->ContextBuffers, &FoundContextBuffer);
UT_ASSERT_STATUS_EQUAL (Status, TestContext->ExpectedStatus);
@ -471,7 +470,7 @@ VerifyGetContextBuffer (
ContextBuffers = NULL;
FoundContextBuffer = NULL;
TestContext = (PRM_CONTEXT_BUFFER_TEST_CONTEXT *) Context;
TestContext = (PRM_CONTEXT_BUFFER_TEST_CONTEXT *)Context;
Status = GetContextBuffer (TestContext->HandlerGuid, TestContext->ContextBuffers, &FoundContextBuffer);
UT_ASSERT_STATUS_EQUAL (Status, TestContext->ExpectedStatus);
@ -484,7 +483,7 @@ VerifyGetContextBuffer (
return UNIT_TEST_PASSED;
}
///=== TEST ENGINE ================================================================================
/// === TEST ENGINE ================================================================================
/**
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.
**/
int main ()
int
main (
)
{
EFI_STATUS Status;
UINTN Index;
@ -640,8 +641,7 @@ int main ()
Status = RunAllTestSuites (Framework);
EXIT:
if (Framework)
{
if (Framework) {
FreeUnitTestFramework (Framework);
}

View File

@ -59,7 +59,7 @@ GetNextPrmModuleEntry (
} else {
CurrentListEntry = NULL;
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;
}
@ -100,12 +100,13 @@ CreateNewPrmModuleImageContextListEntry (
if (PrmModuleImageContextListEntry == NULL) {
return NULL;
}
DEBUG ((
DEBUG_INFO,
" %a %a: Allocated PrmModuleImageContextListEntry at 0x%x of size 0x%x bytes.\n",
_DBGMSGID_,
__FUNCTION__,
(UINTN) PrmModuleImageContextListEntry,
(UINTN)PrmModuleImageContextListEntry,
sizeof (*PrmModuleImageContextListEntry)
));
@ -234,7 +235,7 @@ DiscoverPrmModules (
Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiLoadedImageProtocolGuid,
(VOID **) &LoadedImageProtocol
(VOID **)&LoadedImageProtocol
);
if (EFI_ERROR (Status)) {
continue;
@ -249,16 +250,17 @@ DiscoverPrmModules (
TempPrmModuleImageContext.PeCoffImageContext.ImageRead = PeCoffLoaderImageReadFromMemory;
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_WARN,
"%a %a: ImageHandle 0x%016lx is not a valid PE/COFF image. It cannot be considered a PRM module.\n",
_DBGMSGID_,
__FUNCTION__,
(EFI_PHYSICAL_ADDRESS) (UINTN) LoadedImageProtocol->ImageBase
(EFI_PHYSICAL_ADDRESS)(UINTN)LoadedImageProtocol->ImageBase
));
continue;
}
if (TempPrmModuleImageContext.PeCoffImageContext.IsTeImage) {
// A PRM Module is not allowed to be a TE image
continue;
@ -280,9 +282,10 @@ DiscoverPrmModules (
&TempPrmModuleImageContext.PeCoffImageContext,
&TempPrmModuleImageContext.ExportDescriptor
);
if (EFI_ERROR (Status) || TempPrmModuleImageContext.ExportDescriptor == NULL) {
if (EFI_ERROR (Status) || (TempPrmModuleImageContext.ExportDescriptor == NULL)) {
continue;
}
// A PRM Module Export Descriptor was successfully found, this is considered a PRM Module.
//
@ -292,6 +295,7 @@ DiscoverPrmModules (
if (PrmModuleImageContextListEntry == NULL) {
return EFI_OUT_OF_RESOURCES;
}
CopyMem (
&PrmModuleImageContextListEntry->Context,
&TempPrmModuleImageContext,
@ -306,6 +310,7 @@ DiscoverPrmModules (
if (HandlerCount != NULL) {
*HandlerCount = PrmHandlerCount;
}
if (ModuleCount != NULL) {
*ModuleCount = PrmModuleCount;
}

View File

@ -27,9 +27,9 @@
#define UNIT_TEST_NAME "PRM Module Discovery Library Unit Test"
#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.
@ -119,7 +119,7 @@ PrmModuleImageContextListEntryImageContextShouldBeZeroed (
return UNIT_TEST_PASSED;
}
///=== TEST ENGINE ================================================================================
/// === TEST ENGINE ================================================================================
/**
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.
**/
int main ()
int
main (
)
{
EFI_STATUS Status;
UNIT_TEST_FRAMEWORK_HANDLE Framework;
@ -200,8 +202,7 @@ int main ()
Status = RunAllTestSuites (Framework);
EXIT:
if (Framework)
{
if (Framework) {
FreeUnitTestFramework (Framework);
}

View File

@ -53,10 +53,11 @@ GetPrmModuleExportDescriptorTable (
DEBUG ((DEBUG_INFO, "%a %a - Entry.\n", _DBGMSGID_, __FUNCTION__));
if (ImageExportDirectory == NULL ||
PeCoffLoaderImageContext == NULL ||
PeCoffLoaderImageContext->ImageAddress == 0 ||
ExportDescriptor == NULL) {
if ((ImageExportDirectory == NULL) ||
(PeCoffLoaderImageContext == NULL) ||
(PeCoffLoaderImageContext->ImageAddress == 0) ||
(ExportDescriptor == NULL))
{
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.
//
CurrentImageAddress = PeCoffLoaderImageContext->ImageAddress;
ExportAddressTable = (UINT32 *) ((UINTN) CurrentImageAddress + ImageExportDirectory->AddressOfFunctions);
ExportNamePointerTable = (UINT32 *) ((UINTN) CurrentImageAddress + ImageExportDirectory->AddressOfNames);
OrdinalTable = (UINT16 *) ((UINTN) CurrentImageAddress + ImageExportDirectory->AddressOfNameOrdinals);
ExportAddressTable = (UINT32 *)((UINTN)CurrentImageAddress + ImageExportDirectory->AddressOfFunctions);
ExportNamePointerTable = (UINT32 *)((UINTN)CurrentImageAddress + ImageExportDirectory->AddressOfNames);
OrdinalTable = (UINT16 *)((UINTN)CurrentImageAddress + ImageExportDirectory->AddressOfNameOrdinals);
for (Index = 0; Index < ImageExportDirectory->NumberOfNames; Index++) {
CurrentExportName = (CONST CHAR8 *) ((UINTN) CurrentImageAddress + ExportNamePointerTable[Index]);
CurrentExportName = (CONST CHAR8 *)((UINTN)CurrentImageAddress + ExportNamePointerTable[Index]);
DEBUG ((
DEBUG_INFO,
" %a %a: Export Name[0x%x] - %a.\n",
@ -90,10 +91,11 @@ GetPrmModuleExportDescriptorTable (
));
if (
AsciiStrnCmp (
PRM_STRING(PRM_MODULE_EXPORT_DESCRIPTOR_NAME),
PRM_STRING (PRM_MODULE_EXPORT_DESCRIPTOR_NAME),
CurrentExportName,
AsciiStrLen (PRM_STRING(PRM_MODULE_EXPORT_DESCRIPTOR_NAME))
) == 0) {
AsciiStrLen (PRM_STRING (PRM_MODULE_EXPORT_DESCRIPTOR_NAME))
) == 0)
{
PrmModuleExportDescriptorOrdinal = OrdinalTable[Index];
DEBUG ((
DEBUG_INFO,
@ -106,19 +108,21 @@ GetPrmModuleExportDescriptorTable (
DEBUG ((DEBUG_ERROR, "%a %a: The PRM Module Export Descriptor ordinal value is invalid.\n", _DBGMSGID_, __FUNCTION__));
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) {
*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 {
DEBUG ((
DEBUG_INFO,
" %a %a: PRM Module Export Descriptor found at 0x%x but signature check failed.\n",
_DBGMSGID_,
__FUNCTION__,
(UINTN) TempExportDescriptor
(UINTN)TempExportDescriptor
));
}
DEBUG ((DEBUG_INFO, " %a %a: Exiting export iteration since export descriptor found.\n", _DBGMSGID_, __FUNCTION__));
return EFI_SUCCESS;
}
@ -156,7 +160,7 @@ GetExportDirectoryInPeCoffImage (
EFI_IMAGE_DATA_DIRECTORY *DirectoryEntry;
EFI_IMAGE_EXPORT_DIRECTORY *ExportDirectory;
if (Image == NULL || PeCoffLoaderImageContext == NULL || ImageExportDirectory == NULL) {
if ((Image == NULL) || (PeCoffLoaderImageContext == NULL) || (ImageExportDirectory == NULL)) {
return EFI_INVALID_PARAMETER;
}
@ -195,8 +199,8 @@ GetExportDirectoryInPeCoffImage (
return EFI_UNSUPPORTED;
}
OptionalHeaderPtrUnion.Pe32 = (EFI_IMAGE_NT_HEADERS32 *) (
(UINTN) Image +
OptionalHeaderPtrUnion.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)(
(UINTN)Image +
PeCoffLoaderImageContext->PeCoffHeaderOffset
);
@ -213,43 +217,44 @@ GetExportDirectoryInPeCoffImage (
// Use the PE32 offset to get the Export Directory Entry
//
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) {
//
// Use the PE32+ offset get the Export Directory Entry
//
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 {
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
//
return EFI_NOT_FOUND;
} else if (((UINT32) (~0) - DirectoryEntry->VirtualAddress) < DirectoryEntry->Size) {
} else if (((UINT32)(~0) - DirectoryEntry->VirtualAddress) < DirectoryEntry->Size) {
//
// The directory address overflows
//
DEBUG ((DEBUG_ERROR, "%a %a: The export directory entry in this image results in overflow.\n", _DBGMSGID_, __FUNCTION__));
return EFI_UNSUPPORTED;
} 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));
ExportDirectory = (EFI_IMAGE_EXPORT_DIRECTORY *) ((UINTN) Image + DirectoryEntry->VirtualAddress);
ExportDirectory = (EFI_IMAGE_EXPORT_DIRECTORY *)((UINTN)Image + DirectoryEntry->VirtualAddress);
DEBUG ((
DEBUG_INFO,
" %a %a: Export Directory Table found successfully at 0x%x. Name address = 0x%x. Name = %a.\n",
_DBGMSGID_,
__FUNCTION__,
(UINTN) ExportDirectory,
((UINTN) Image + ExportDirectory->Name),
(CHAR8 *) ((UINTN) Image + ExportDirectory->Name)
(UINTN)ExportDirectory,
((UINTN)Image + ExportDirectory->Name),
(CHAR8 *)((UINTN)Image + ExportDirectory->Name)
));
}
*ImageExportDirectory = ExportDirectory;
return EFI_SUCCESS;
@ -284,7 +289,7 @@ GetImageVersionInPeCoffImage (
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;
}
@ -320,8 +325,8 @@ GetImageVersionInPeCoffImage (
return EFI_UNSUPPORTED;
}
OptionalHeaderPtrUnion.Pe32 = (EFI_IMAGE_NT_HEADERS32 *) (
(UINTN) Image +
OptionalHeaderPtrUnion.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)(
(UINTN)Image +
PeCoffLoaderImageContext->PeCoffHeaderOffset
);
//
@ -381,17 +386,18 @@ GetExportEntryAddress (
UINT16 *OrdinalTable;
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;
}
*ExportPhysicalAddress = 0;
ExportAddressTable = (UINT32 *) ((UINTN) ImageBaseAddress + ImageExportDirectory->AddressOfFunctions);
ExportNamePointerTable = (UINT32 *) ((UINTN) ImageBaseAddress + ImageExportDirectory->AddressOfNames);
OrdinalTable = (UINT16 *) ((UINTN) ImageBaseAddress + ImageExportDirectory->AddressOfNameOrdinals);
ExportAddressTable = (UINT32 *)((UINTN)ImageBaseAddress + ImageExportDirectory->AddressOfFunctions);
ExportNamePointerTable = (UINT32 *)((UINTN)ImageBaseAddress + ImageExportDirectory->AddressOfNames);
OrdinalTable = (UINT16 *)((UINTN)ImageBaseAddress + ImageExportDirectory->AddressOfNameOrdinals);
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) {
CurrentExportOrdinal = OrdinalTable[ExportNameIndex];
@ -402,7 +408,7 @@ GetExportEntryAddress (
break;
}
*ExportPhysicalAddress = (EFI_PHYSICAL_ADDRESS) ((UINTN) ImageBaseAddress + ExportAddressTable[CurrentExportOrdinal]);
*ExportPhysicalAddress = (EFI_PHYSICAL_ADDRESS)((UINTN)ImageBaseAddress + ExportAddressTable[CurrentExportOrdinal]);
return EFI_SUCCESS;
}
}

View File

@ -42,13 +42,13 @@ ConvertRuntimeMemoryRangeAddresses (
{
UINTN Index;
if (RuntimeMmioRanges == NULL || RuntimeMmioRanges->Count == 0) {
if ((RuntimeMmioRanges == NULL) || (RuntimeMmioRanges->Count == 0)) {
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;
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__));
if (RuntimeMmioRanges == NULL || RuntimeMmioRanges->Count == 0) {
if ((RuntimeMmioRanges == NULL) || (RuntimeMmioRanges->Count == 0)) {
return;
}
for (Index = 0; Index < (UINTN) RuntimeMmioRanges->Count; Index++) {
for (Index = 0; Index < (UINTN)RuntimeMmioRanges->Count; Index++) {
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_INFO,
" %a %a: Physical address = 0x%016x. Length = 0x%x.\n",
@ -97,21 +102,22 @@ SetRuntimeMemoryRangeAttributes (
Status = gDS->GetMemorySpaceDescriptor (RuntimeMmioRanges->Range[Index].PhysicalBaseAddress, &Descriptor);
if (!EFI_ERROR (Status) &&
(
(Descriptor.GcdMemoryType != EfiGcdMemoryTypeMemoryMappedIo && Descriptor.GcdMemoryType != EfiGcdMemoryTypeReserved) ||
((Descriptor.GcdMemoryType != EfiGcdMemoryTypeMemoryMappedIo) && (Descriptor.GcdMemoryType != EfiGcdMemoryTypeReserved)) ||
((Descriptor.Length & EFI_PAGE_MASK) != 0)
)
) {
)
{
Status2 = gDS->RemoveMemorySpace (
RuntimeMmioRanges->Range[Index].PhysicalBaseAddress,
Descriptor.Length
);
}
if (Status == EFI_NOT_FOUND || !EFI_ERROR (Status2)) {
if ((Status == EFI_NOT_FOUND) || !EFI_ERROR (Status2)) {
Status = gDS->AddMemorySpace (
EfiGcdMemoryTypeMemoryMappedIo,
RuntimeMmioRanges->Range[Index].PhysicalBaseAddress,
(UINT64) RuntimeMmioRanges->Range[Index].Length,
(UINT64)RuntimeMmioRanges->Range[Index].Length,
EFI_MEMORY_UC | EFI_MEMORY_RUNTIME
);
ASSERT_EFI_ERROR (Status);
@ -120,7 +126,7 @@ SetRuntimeMemoryRangeAttributes (
EfiGcdAllocateAddress,
EfiGcdMemoryTypeMemoryMappedIo,
0,
(UINT64) RuntimeMmioRanges->Range[Index].Length,
(UINT64)RuntimeMmioRanges->Range[Index].Length,
&RuntimeMmioRanges->Range[Index].PhysicalBaseAddress,
gImageHandle,
NULL
@ -141,13 +147,14 @@ SetRuntimeMemoryRangeAttributes (
));
continue;
}
if ((Descriptor.Attributes & EFI_MEMORY_RUNTIME) != 0) {
continue;
}
Status = gDS->SetMemorySpaceAttributes (
RuntimeMmioRanges->Range[Index].PhysicalBaseAddress,
(UINT64) RuntimeMmioRanges->Range[Index].Length,
(UINT64)RuntimeMmioRanges->Range[Index].Length,
Descriptor.Attributes | EFI_MEMORY_RUNTIME
);
ASSERT_EFI_ERROR (Status);
@ -187,7 +194,7 @@ StoreVirtualMemoryAddressChangePointers (
RangeIndex = 0;
mRuntimeMmioRanges = AllocateRuntimeZeroPool (sizeof (*mRuntimeMmioRanges) * mMaxRuntimeMmioRangeCount);
if (mRuntimeMmioRanges == NULL && mMaxRuntimeMmioRangeCount > 0) {
if ((mRuntimeMmioRanges == NULL) && (mMaxRuntimeMmioRangeCount > 0)) {
DEBUG ((
DEBUG_ERROR,
" %a %a: Memory allocation for runtime MMIO pointer array failed.\n",
@ -211,10 +218,10 @@ StoreVirtualMemoryAddressChangePointers (
Status = gBS->HandleProtocol (
HandleBuffer[HandleIndex],
&gPrmConfigProtocolGuid,
(VOID **) &PrmConfigProtocol
(VOID **)&PrmConfigProtocol
);
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status) || PrmConfigProtocol == NULL) {
if (EFI_ERROR (Status) || (PrmConfigProtocol == NULL)) {
continue;
}
@ -232,9 +239,11 @@ StoreVirtualMemoryAddressChangePointers (
ASSERT_EFI_ERROR (Status);
return;
}
mRuntimeMmioRanges[RangeIndex++] = PrmConfigProtocol->ModuleContextBuffers.RuntimeMmioRanges;
}
}
DEBUG ((
DEBUG_INFO,
" %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__));
return EFI_NOT_FOUND;
}
if (PrmDataBuffer->Header.Length < sizeof (PRM_DATA_BUFFER_HEADER)) {
DEBUG ((DEBUG_ERROR, " %a %a: The PRM data buffer length is invalid.\n", _DBGMSGID_, __FUNCTION__));
return EFI_BUFFER_TOO_SMALL;
@ -310,7 +320,7 @@ ValidatePrmContextBuffer (
return EFI_NOT_FOUND;
}
if (PrmContextBuffer->StaticDataBuffer != NULL && EFI_ERROR (ValidatePrmDataBuffer (PrmContextBuffer->StaticDataBuffer))) {
if ((PrmContextBuffer->StaticDataBuffer != NULL) && EFI_ERROR (ValidatePrmDataBuffer (PrmContextBuffer->StaticDataBuffer))) {
DEBUG ((
DEBUG_ERROR,
" %a %a: Error in static buffer for PRM handler %g.\n",
@ -392,10 +402,10 @@ PrmConfigEndOfDxeNotification (
Status = gBS->HandleProtocol (
HandleBuffer[HandleIndex],
&gPrmConfigProtocolGuid,
(VOID **) &PrmConfigProtocol
(VOID **)&PrmConfigProtocol
);
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status) || PrmConfigProtocol == NULL) {
if (EFI_ERROR (Status) || (PrmConfigProtocol == NULL)) {
continue;
}
@ -422,6 +432,7 @@ PrmConfigEndOfDxeNotification (
));
}
}
DEBUG ((DEBUG_INFO, " %a %a: Module context buffer validation complete.\n", _DBGMSGID_, __FUNCTION__));
if (PrmConfigProtocol->ModuleContextBuffers.RuntimeMmioRanges != NULL) {
@ -443,7 +454,8 @@ PrmConfigEndOfDxeNotification (
if (HandleBuffer != NULL) {
gBS->FreePool (HandleBuffer);
}
gBS->CloseEvent(Event);
gBS->CloseEvent (Event);
}
/**

View File

@ -78,6 +78,7 @@ ProcessPrmModules (
if (PrmAcpiDescriptionTable == NULL) {
return EFI_INVALID_PARAMETER;
}
*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 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) +
(sizeof (PRM_HANDLER_INFORMATION_STRUCT) * mPrmHandlerCount)
);
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) {
return EFI_OUT_OF_RESOURCES;
}
@ -118,7 +119,7 @@ ProcessPrmModules (
PrmAcpiTable->Header.CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision);
CopyGuid (&PrmAcpiTable->PrmPlatformGuid, &gEdkiiDscPlatformGuid);
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
@ -127,8 +128,8 @@ ProcessPrmModules (
for (
CurrentPrmModuleImageContext = NULL, Status = GetNextPrmModuleEntry (&CurrentPrmModuleImageContext);
!EFI_ERROR (Status);
Status = GetNextPrmModuleEntry (&CurrentPrmModuleImageContext)) {
Status = GetNextPrmModuleEntry (&CurrentPrmModuleImageContext))
{
CurrentImageAddress = CurrentPrmModuleImageContext->PeCoffImageContext.ImageAddress;
CurrentImageExportDirectory = CurrentPrmModuleImageContext->ExportDirectory;
CurrentExportDescriptorStruct = CurrentPrmModuleImageContext->ExportDescriptor;
@ -139,7 +140,7 @@ ProcessPrmModules (
" %a %a: PRM Module - %a with %d handlers.\n",
_DBGMSGID_,
__FUNCTION__,
(CHAR8 *) ((UINTN) CurrentImageAddress + CurrentImageExportDirectory->Name),
(CHAR8 *)((UINTN)CurrentImageAddress + CurrentImageExportDirectory->Name),
CurrentExportDescriptorStruct->Header.NumberPrmHandlers
));
@ -149,13 +150,13 @@ ProcessPrmModules (
(CurrentExportDescriptorStruct->Header.NumberPrmHandlers * sizeof (PRM_HANDLER_INFORMATION_STRUCT))
);
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->MajorRevision = 0;
CurrentModuleInfoStruct->MinorRevision = 0;
Status = GetImageVersionInPeCoffImage (
(VOID *) (UINTN) CurrentImageAddress,
(VOID *)(UINTN)CurrentImageAddress,
&CurrentPrmModuleImageContext->PeCoffImageContext,
&CurrentModuleInfoStruct->MajorRevision,
&CurrentModuleInfoStruct->MinorRevision
@ -166,11 +167,11 @@ ProcessPrmModules (
Status = GetModuleContextBuffers (
ByModuleGuid,
&CurrentModuleInfoStruct->Identifier,
(CONST PRM_MODULE_CONTEXT_BUFFERS **) &CurrentModuleContextBuffers
(CONST PRM_MODULE_CONTEXT_BUFFERS **)&CurrentModuleContextBuffers
);
ASSERT (!EFI_ERROR (Status) || Status == EFI_NOT_FOUND);
if (!EFI_ERROR (Status) && CurrentModuleContextBuffers != NULL) {
CurrentModuleInfoStruct->RuntimeMmioRanges = (UINT64) (UINTN) CurrentModuleContextBuffers->RuntimeMmioRanges;
if (!EFI_ERROR (Status) && (CurrentModuleContextBuffers != NULL)) {
CurrentModuleInfoStruct->RuntimeMmioRanges = (UINT64)(UINTN)CurrentModuleContextBuffers->RuntimeMmioRanges;
CurrentModuleAcpiParamDescriptors = CurrentModuleContextBuffers->AcpiParameterBufferDescriptors;
}
@ -187,15 +188,15 @@ ProcessPrmModules (
&CurrentExportDescriptorStruct->PrmHandlerExportDescriptors[HandlerIndex].PrmHandlerGuid
);
CurrentExportDescriptorHandlerName = (CONST CHAR8 *) CurrentExportDescriptorStruct->PrmHandlerExportDescriptors[HandlerIndex].PrmHandlerName;
CurrentExportDescriptorHandlerName = (CONST CHAR8 *)CurrentExportDescriptorStruct->PrmHandlerExportDescriptors[HandlerIndex].PrmHandlerName;
Status = GetContextBuffer (
&CurrentHandlerInfoStruct->Identifier,
CurrentModuleContextBuffers,
(CONST PRM_CONTEXT_BUFFER **) &CurrentContextBuffer
(CONST PRM_CONTEXT_BUFFER **)&CurrentContextBuffer
);
if (!EFI_ERROR (Status)) {
CurrentHandlerInfoStruct->StaticDataBuffer = (UINT64) (UINTN) CurrentContextBuffer->StaticDataBuffer;
CurrentHandlerInfoStruct->StaticDataBuffer = (UINT64)(UINTN)CurrentContextBuffer->StaticDataBuffer;
}
Status = GetExportEntryAddress (
@ -223,15 +224,17 @@ ProcessPrmModules (
if (CurrentModuleAcpiParamDescriptors != NULL) {
for (AcpiParamIndex = 0; AcpiParamIndex < CurrentModuleContextBuffers->AcpiParameterBufferDescriptorCount; AcpiParamIndex++) {
if (CompareGuid (&CurrentModuleAcpiParamDescriptors[AcpiParamIndex].HandlerGuid, &CurrentHandlerInfoStruct->Identifier)) {
CurrentHandlerInfoStruct->AcpiParameterBuffer = (UINT64) (UINTN) (
CurrentHandlerInfoStruct->AcpiParameterBuffer = (UINT64)(UINTN)(
CurrentModuleAcpiParamDescriptors[AcpiParamIndex].AcpiParameterBufferAddress
);
}
}
}
}
CurrentModuleInfoStruct = (PRM_MODULE_INFORMATION_STRUCT *) ((UINTN) CurrentModuleInfoStruct + CurrentModuleInfoStruct->StructureLength);
CurrentModuleInfoStruct = (PRM_MODULE_INFORMATION_STRUCT *)((UINTN)CurrentModuleInfoStruct + CurrentModuleInfoStruct->StructureLength);
}
*PrmAcpiDescriptionTable = PrmAcpiTable;
return EFI_SUCCESS;
@ -259,11 +262,11 @@ PublishPrmAcpiTable (
EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtocol;
UINTN TableKey;
if (PrmAcpiDescriptionTable == NULL || PrmAcpiDescriptionTable->Header.Signature != PRM_TABLE_SIGNATURE) {
if ((PrmAcpiDescriptionTable == NULL) || (PrmAcpiDescriptionTable->Header.Signature != PRM_TABLE_SIGNATURE)) {
return EFI_INVALID_PARAMETER;
}
Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **) &AcpiTableProtocol);
Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **)&AcpiTableProtocol);
if (!EFI_ERROR (Status)) {
TableKey = 0;
//
@ -279,6 +282,7 @@ PublishPrmAcpiTable (
DEBUG ((DEBUG_INFO, "%a %a: The PRMT ACPI table was installed successfully.\n", _DBGMSGID_, __FUNCTION__));
}
}
ASSERT_EFI_ERROR (Status);
return Status;
@ -326,6 +330,7 @@ PrmLoaderEndOfDxeNotification (
if (PrmAcpiDescriptionTable != NULL) {
FreePool (PrmAcpiDescriptionTable);
}
gBS->CloseEvent (Event);
}
@ -355,7 +360,7 @@ PrmLoaderEntryPoint (
// Discover and process installed PRM modules at the End of DXE
// The PRM ACPI table is published if one or PRM modules are discovered
//
Status = gBS->CreateEventEx(
Status = gBS->CreateEventEx (
EVT_NOTIFY_SIGNAL,
TPL_CALLBACK,
PrmLoaderEndOfDxeNotification,

View File

@ -48,7 +48,7 @@ InstallPrmSsdt (
return EFI_INVALID_PARAMETER;
}
Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **) &AcpiTableProtocol);
Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **)&AcpiTableProtocol);
if (!EFI_ERROR (Status)) {
//
// Discover the SSDT
@ -57,7 +57,7 @@ InstallPrmSsdt (
&gEfiCallerIdGuid,
EFI_SECTION_RAW,
0,
(VOID **) &Ssdt,
(VOID **)&Ssdt,
&SsdtSize
);
ASSERT_EFI_ERROR (Status);
@ -103,7 +103,7 @@ PrmSsdtInstallEntryPoint (
{
EFI_STATUS Status;
Status = InstallPrmSsdt ((UINT8 *) PcdGetPtr (PcdAcpiDefaultOemId));
Status = InstallPrmSsdt ((UINT8 *)PcdGetPtr (PcdAcpiDefaultOemId));
ASSERT_EFI_ERROR (Status);
return Status;

View File

@ -17,10 +17,14 @@
STATIC EFI_HANDLE mPrmConfigProtocolHandle;
// {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}
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.
@ -82,11 +86,12 @@ AcpiParameterBufferModuleConfigLibConstructor (
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
CopyGuid (&PrmConfigProtocol->ModuleContextBuffers.ModuleGuid, &mPrmModuleGuid);
// Populate the ACPI Parameter Buffer Descriptor structure
CopyGuid (&AcpiParamBufferDescriptor->HandlerGuid, &mCheckParamBufferPrmHandlerGuid);
AcpiParamBufferDescriptor->AcpiParameterBufferAddress = (UINT64) (UINTN) AcpiParameterBuffer;
AcpiParamBufferDescriptor->AcpiParameterBufferAddress = (UINT64)(UINTN)AcpiParameterBuffer;
// Populate the PRM Module Context Buffers structure
PrmConfigProtocol->ModuleContextBuffers.AcpiParameterBufferDescriptorCount = 1;
@ -100,7 +105,7 @@ AcpiParameterBufferModuleConfigLibConstructor (
&mPrmConfigProtocolHandle,
&gPrmConfigProtocolGuid,
EFI_NATIVE_INTERFACE,
(VOID *) PrmConfigProtocol
(VOID *)PrmConfigProtocol
);
Done:
@ -108,9 +113,11 @@ Done:
if (AcpiParameterBuffer != NULL) {
FreePool (AcpiParameterBuffer);
}
if (AcpiParamBufferDescriptor != NULL) {
FreePool (AcpiParamBufferDescriptor);
}
if (PrmConfigProtocol != NULL) {
FreePool (PrmConfigProtocol);
}

View File

@ -39,13 +39,12 @@
@retval Others An error occurred in the PRM handler.
**/
PRM_HANDLER_EXPORT (CheckParamBufferPrmHandler)
{
PRM_HANDLER_EXPORT (CheckParamBufferPrmHandler) {
if (ParameterBuffer == NULL) {
return EFI_INVALID_PARAMETER;
}
if (*((UINT32 *) ParameterBuffer) == PARAM_BUFFER_TEST_SIGNATURE) {
if (*((UINT32 *)ParameterBuffer) == PARAM_BUFFER_TEST_SIGNATURE) {
return EFI_SUCCESS;
}

View File

@ -21,10 +21,14 @@
STATIC EFI_HANDLE mPrmConfigProtocolHandle;
// {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}
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.
@ -80,6 +84,7 @@ GetStaticDataBuffer (
if (StaticDataBuffer == NULL) {
return EFI_INVALID_PARAMETER;
}
*StaticDataBuffer = NULL;
//
@ -96,9 +101,9 @@ GetStaticDataBuffer (
// Initialize the data buffer header
//
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);
*StaticDataBuffer = DataBuffer;
@ -144,7 +149,7 @@ ContextBufferModuleConfigLibConstructor (
//
Status = GetStaticDataBuffer (&StaticDataBuffer);
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status) || StaticDataBuffer == NULL) {
if (EFI_ERROR (Status) || (StaticDataBuffer == NULL)) {
goto Done;
}
@ -166,6 +171,7 @@ ContextBufferModuleConfigLibConstructor (
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
CopyGuid (&PrmContextBuffer->HandlerGuid, &mCheckStaticDataBufferPrmHandlerGuid);
PrmContextBuffer->Signature = PRM_CONTEXT_BUFFER_SIGNATURE;
PrmContextBuffer->Version = PRM_CONTEXT_BUFFER_INTERFACE_VERSION;
@ -177,6 +183,7 @@ ContextBufferModuleConfigLibConstructor (
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
CopyGuid (&PrmConfigProtocol->ModuleContextBuffers.ModuleGuid, &mPrmModuleGuid);
PrmConfigProtocol->ModuleContextBuffers.BufferCount = 1;
PrmConfigProtocol->ModuleContextBuffers.Buffer = PrmContextBuffer;
@ -189,7 +196,7 @@ ContextBufferModuleConfigLibConstructor (
&mPrmConfigProtocolHandle,
&gPrmConfigProtocolGuid,
EFI_NATIVE_INTERFACE,
(VOID *) PrmConfigProtocol
(VOID *)PrmConfigProtocol
);
Done:
@ -197,9 +204,11 @@ Done:
if (StaticDataBuffer != NULL) {
FreePool (StaticDataBuffer);
}
if (PrmContextBuffer != NULL) {
FreePool (PrmContextBuffer);
}
if (PrmConfigProtocol != NULL) {
FreePool (PrmConfigProtocol);
}

View File

@ -35,8 +35,7 @@
@retval Others An error occurred in the PRM handler.
**/
PRM_HANDLER_EXPORT (CheckStaticDataBufferPrmHandler)
{
PRM_HANDLER_EXPORT (CheckStaticDataBufferPrmHandler) {
if (ContextBuffer == NULL) {
return EFI_INVALID_PARAMETER;
}
@ -49,8 +48,9 @@ PRM_HANDLER_EXPORT (CheckStaticDataBufferPrmHandler)
// Verify PRM data buffer signature is valid
//
if (
ContextBuffer->Signature != PRM_CONTEXT_BUFFER_SIGNATURE ||
ContextBuffer->StaticDataBuffer->Header.Signature != PRM_DATA_BUFFER_HEADER_SIGNATURE) {
(ContextBuffer->Signature != PRM_CONTEXT_BUFFER_SIGNATURE) ||
(ContextBuffer->StaticDataBuffer->Header.Signature != PRM_DATA_BUFFER_HEADER_SIGNATURE))
{
return EFI_NOT_FOUND;
}

View File

@ -45,13 +45,13 @@
///
typedef union {
struct {
UINT32 Revision:8;
UINT32 NumberOfTimers:5;
UINT32 CounterSize:1;
UINT32 Reserved0:1;
UINT32 LegacyRoute:1;
UINT32 VendorId:16;
UINT32 CounterClockPeriod:32;
UINT32 Revision : 8;
UINT32 NumberOfTimers : 5;
UINT32 CounterSize : 1;
UINT32 Reserved0 : 1;
UINT32 LegacyRoute : 1;
UINT32 VendorId : 16;
UINT32 CounterClockPeriod : 32;
} Bits;
UINT64 Uint64;
} HPET_GENERAL_CAPABILITIES_ID_REGISTER;
@ -61,10 +61,10 @@ typedef union {
///
typedef union {
struct {
UINT32 MainCounterEnable:1;
UINT32 LegacyRouteEnable:1;
UINT32 Reserved0:30;
UINT32 Reserved1:32;
UINT32 MainCounterEnable : 1;
UINT32 LegacyRouteEnable : 1;
UINT32 Reserved0 : 30;
UINT32 Reserved1 : 32;
} Bits;
UINT64 Uint64;
} HPET_GENERAL_CONFIGURATION_REGISTER;
@ -74,19 +74,19 @@ typedef union {
///
typedef union {
struct {
UINT32 Reserved0:1;
UINT32 LevelTriggeredInterrupt:1;
UINT32 InterruptEnable:1;
UINT32 PeriodicInterruptEnable:1;
UINT32 PeriodicInterruptCapability:1;
UINT32 CounterSizeCapability:1;
UINT32 ValueSetEnable:1;
UINT32 Reserved1:1;
UINT32 CounterSizeEnable:1;
UINT32 InterruptRoute:5;
UINT32 MsiInterruptEnable:1;
UINT32 MsiInterruptCapability:1;
UINT32 Reserved2:16;
UINT32 Reserved0 : 1;
UINT32 LevelTriggeredInterrupt : 1;
UINT32 InterruptEnable : 1;
UINT32 PeriodicInterruptEnable : 1;
UINT32 PeriodicInterruptCapability : 1;
UINT32 CounterSizeCapability : 1;
UINT32 ValueSetEnable : 1;
UINT32 Reserved1 : 1;
UINT32 CounterSizeEnable : 1;
UINT32 InterruptRoute : 5;
UINT32 MsiInterruptEnable : 1;
UINT32 MsiInterruptCapability : 1;
UINT32 Reserved2 : 16;
UINT32 InterruptRouteCapability;
} Bits;
UINT64 Uint64;
@ -97,8 +97,8 @@ typedef union {
///
typedef union {
struct {
UINT32 Value:32;
UINT32 Address:32;
UINT32 Value : 32;
UINT32 Address : 32;
} Bits;
UINT64 Uint64;
} HPET_TIMER_MSI_ROUTE_REGISTER;

View File

@ -18,7 +18,9 @@
STATIC EFI_HANDLE mPrmConfigProtocolHandle;
// {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.
@ -70,6 +72,7 @@ HardwareAccessModuleConfigLibConstructor (
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
CopyGuid (&PrmConfigProtocol->ModuleContextBuffers.ModuleGuid, &mPrmModuleGuid);
// Populate the Runtime MMIO Ranges structure
@ -87,7 +90,7 @@ HardwareAccessModuleConfigLibConstructor (
&mPrmConfigProtocolHandle,
&gPrmConfigProtocolGuid,
EFI_NATIVE_INTERFACE,
(VOID *) PrmConfigProtocol
(VOID *)PrmConfigProtocol
);
Done:
@ -95,6 +98,7 @@ Done:
if (RuntimeMmioRanges != NULL) {
FreePool (RuntimeMmioRanges);
}
if (PrmConfigProtocol != NULL) {
FreePool (PrmConfigProtocol);
}

View File

@ -158,12 +158,18 @@ AccessAllMtrrs (
RangeCount = 1;
MtrrLibGetRawVariableRanges (
&Mtrrs->Variables, VariableMtrrCount,
MtrrValidBitsMask, MtrrValidAddressMask, RawVariableRanges
&Mtrrs->Variables,
VariableMtrrCount,
MtrrValidBitsMask,
MtrrValidAddressMask,
RawVariableRanges
);
MtrrLibApplyVariableMtrrs (
RawVariableRanges, VariableMtrrCount,
Ranges, ARRAY_SIZE (Ranges), &RangeCount
RawVariableRanges,
VariableMtrrCount,
Ranges,
ARRAY_SIZE (Ranges),
&RangeCount
);
MtrrLibApplyFixedMtrrs (&Mtrrs->Fixed, Ranges, ARRAY_SIZE (Ranges), &RangeCount);
@ -200,7 +206,7 @@ HpetRead (
}
MemoryFence ();
Value = *(volatile UINT64*)Address;
Value = *(volatile UINT64 *)Address;
MemoryFence ();
return Value;
@ -251,8 +257,7 @@ GetMicrocodeSignature (
@retval Others An error occurred in the PRM handler.
**/
PRM_HANDLER_EXPORT (MsrAccessMicrocodeSignaturePrmHandler)
{
PRM_HANDLER_EXPORT (MsrAccessMicrocodeSignaturePrmHandler) {
UINT32 MicrocodeSignature;
MicrocodeSignature = 0;
@ -277,8 +282,7 @@ PRM_HANDLER_EXPORT (MsrAccessMicrocodeSignaturePrmHandler)
@retval Others An error occurred in the PRM handler.
**/
PRM_HANDLER_EXPORT (MsrAccessMtrrDumpPrmHandler)
{
PRM_HANDLER_EXPORT (MsrAccessMtrrDumpPrmHandler) {
AccessAllMtrrs ();
return EFI_SUCCESS;
@ -296,8 +300,7 @@ PRM_HANDLER_EXPORT (MsrAccessMtrrDumpPrmHandler)
@retval Others An error occurred in the PRM handler.
**/
PRM_HANDLER_EXPORT (MmioAccessHpetPrmHandler)
{
PRM_HANDLER_EXPORT (MmioAccessHpetPrmHandler) {
AccessHpetConfiguration ();
return EFI_SUCCESS;

View File

@ -27,50 +27,50 @@ STATIC EFI_BOOT_SERVICES mBootServices = {
0, // CRC32
0 // Reserved
},
(EFI_RAISE_TPL) UnitTestRaiseTpl, // RaiseTPL
(EFI_RESTORE_TPL) UnitTestRestoreTpl, // RestoreTPL
(EFI_ALLOCATE_PAGES) UnitTestAllocatePages, // AllocatePages
(EFI_FREE_PAGES) UnitTestFreePages, // FreePages
(EFI_GET_MEMORY_MAP) UnitTestGetMemoryMap, // GetMemoryMap
(EFI_ALLOCATE_POOL) UnitTestAllocatePool, // AllocatePool
(EFI_FREE_POOL) UnitTestFreePool, // FreePool
(EFI_CREATE_EVENT) UnitTestCreateEvent, // CreateEvent
(EFI_SET_TIMER) UnitTestSetTimer, // SetTimer
(EFI_WAIT_FOR_EVENT) UnitTestWaitForEvent, // WaitForEvent
(EFI_SIGNAL_EVENT) UnitTestSignalEvent, // SignalEvent
(EFI_CLOSE_EVENT) UnitTestCloseEvent, // CloseEvent
(EFI_CHECK_EVENT) UnitTestCheckEvent, // CheckEvent
(EFI_INSTALL_PROTOCOL_INTERFACE) UnitTestInstallProtocolInterface, // InstallProtocolInterface
(EFI_REINSTALL_PROTOCOL_INTERFACE) UnitTestReinstallProtocolInterface, // ReinstallProtocolInterface
(EFI_UNINSTALL_PROTOCOL_INTERFACE) UnitTestUninstallProtocolInterface, // UninstallProtocolInterface
(EFI_HANDLE_PROTOCOL) UnitTestHandleProtocol, // HandleProtocol
(VOID *) NULL, // Reserved
(EFI_REGISTER_PROTOCOL_NOTIFY) UnitTestRegisterProtocolNotify, // RegisterProtocolNotify
(EFI_LOCATE_HANDLE) UnitTestLocateHandle, // LocateHandle
(EFI_LOCATE_DEVICE_PATH) UnitTestLocateDevicePath, // LocateDevicePath
(EFI_INSTALL_CONFIGURATION_TABLE) UnitTestInstallConfigurationTable, // InstallConfigurationTable
(EFI_IMAGE_LOAD) UnitTestLoadImage, // LoadImage
(EFI_IMAGE_START) UnitTestStartImage, // StartImage
(EFI_EXIT) UnitTestExit, // Exit
(EFI_IMAGE_UNLOAD) UnitTestUnloadImage, // UnloadImage
(EFI_EXIT_BOOT_SERVICES) UnitTestExitBootServices, // ExitBootServices
(EFI_GET_NEXT_MONOTONIC_COUNT) UnitTestGetNextMonotonicCount, // GetNextMonotonicCount
(EFI_STALL) UnitTestStall, // Stall
(EFI_SET_WATCHDOG_TIMER) UnitTestSetWatchdogTimer, // SetWatchdogTimer
(EFI_CONNECT_CONTROLLER) UnitTestConnectController, // ConnectController
(EFI_DISCONNECT_CONTROLLER) UnitTestDisconnectController, // DisconnectController
(EFI_OPEN_PROTOCOL) UnitTestOpenProtocol, // OpenProtocol
(EFI_CLOSE_PROTOCOL) UnitTestCloseProtocol, // CloseProtocol
(EFI_OPEN_PROTOCOL_INFORMATION) UnitTestOpenProtocolInformation, // OpenProtocolInformation
(EFI_PROTOCOLS_PER_HANDLE) UnitTestProtocolsPerHandle, // ProtocolsPerHandle
(EFI_LOCATE_HANDLE_BUFFER) UnitTestLocateHandleBuffer, // LocateHandleBuffer
(EFI_LOCATE_PROTOCOL) UnitTestLocateProtocol, // LocateProtocol
(EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) UnitTestInstallMultipleProtocolInterfaces, // InstallMultipleProtocolInterfaces
(EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) UnitTestUninstallMultipleProtocolInterfaces, // UninstallMultipleProtocolInterfaces
(EFI_CALCULATE_CRC32) UnitTestCalculateCrc32, // CalculateCrc32
(EFI_COPY_MEM) CopyMem, // CopyMem
(EFI_SET_MEM) SetMem, // SetMem
(EFI_CREATE_EVENT_EX) UnitTestCreateEventEx // CreateEventEx
(EFI_RAISE_TPL)UnitTestRaiseTpl, // RaiseTPL
(EFI_RESTORE_TPL)UnitTestRestoreTpl, // RestoreTPL
(EFI_ALLOCATE_PAGES)UnitTestAllocatePages, // AllocatePages
(EFI_FREE_PAGES)UnitTestFreePages, // FreePages
(EFI_GET_MEMORY_MAP)UnitTestGetMemoryMap, // GetMemoryMap
(EFI_ALLOCATE_POOL)UnitTestAllocatePool, // AllocatePool
(EFI_FREE_POOL)UnitTestFreePool, // FreePool
(EFI_CREATE_EVENT)UnitTestCreateEvent, // CreateEvent
(EFI_SET_TIMER)UnitTestSetTimer, // SetTimer
(EFI_WAIT_FOR_EVENT)UnitTestWaitForEvent, // WaitForEvent
(EFI_SIGNAL_EVENT)UnitTestSignalEvent, // SignalEvent
(EFI_CLOSE_EVENT)UnitTestCloseEvent, // CloseEvent
(EFI_CHECK_EVENT)UnitTestCheckEvent, // CheckEvent
(EFI_INSTALL_PROTOCOL_INTERFACE)UnitTestInstallProtocolInterface, // InstallProtocolInterface
(EFI_REINSTALL_PROTOCOL_INTERFACE)UnitTestReinstallProtocolInterface, // ReinstallProtocolInterface
(EFI_UNINSTALL_PROTOCOL_INTERFACE)UnitTestUninstallProtocolInterface, // UninstallProtocolInterface
(EFI_HANDLE_PROTOCOL)UnitTestHandleProtocol, // HandleProtocol
(VOID *)NULL, // Reserved
(EFI_REGISTER_PROTOCOL_NOTIFY)UnitTestRegisterProtocolNotify, // RegisterProtocolNotify
(EFI_LOCATE_HANDLE)UnitTestLocateHandle, // LocateHandle
(EFI_LOCATE_DEVICE_PATH)UnitTestLocateDevicePath, // LocateDevicePath
(EFI_INSTALL_CONFIGURATION_TABLE)UnitTestInstallConfigurationTable, // InstallConfigurationTable
(EFI_IMAGE_LOAD)UnitTestLoadImage, // LoadImage
(EFI_IMAGE_START)UnitTestStartImage, // StartImage
(EFI_EXIT)UnitTestExit, // Exit
(EFI_IMAGE_UNLOAD)UnitTestUnloadImage, // UnloadImage
(EFI_EXIT_BOOT_SERVICES)UnitTestExitBootServices, // ExitBootServices
(EFI_GET_NEXT_MONOTONIC_COUNT)UnitTestGetNextMonotonicCount, // GetNextMonotonicCount
(EFI_STALL)UnitTestStall, // Stall
(EFI_SET_WATCHDOG_TIMER)UnitTestSetWatchdogTimer, // SetWatchdogTimer
(EFI_CONNECT_CONTROLLER)UnitTestConnectController, // ConnectController
(EFI_DISCONNECT_CONTROLLER)UnitTestDisconnectController, // DisconnectController
(EFI_OPEN_PROTOCOL)UnitTestOpenProtocol, // OpenProtocol
(EFI_CLOSE_PROTOCOL)UnitTestCloseProtocol, // CloseProtocol
(EFI_OPEN_PROTOCOL_INFORMATION)UnitTestOpenProtocolInformation, // OpenProtocolInformation
(EFI_PROTOCOLS_PER_HANDLE)UnitTestProtocolsPerHandle, // ProtocolsPerHandle
(EFI_LOCATE_HANDLE_BUFFER)UnitTestLocateHandleBuffer, // LocateHandleBuffer
(EFI_LOCATE_PROTOCOL)UnitTestLocateProtocol, // LocateProtocol
(EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES)UnitTestInstallMultipleProtocolInterfaces, // InstallMultipleProtocolInterfaces
(EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES)UnitTestUninstallMultipleProtocolInterfaces, // UninstallMultipleProtocolInterfaces
(EFI_CALCULATE_CRC32)UnitTestCalculateCrc32, // CalculateCrc32
(EFI_COPY_MEM)CopyMem, // CopyMem
(EFI_SET_MEM)SetMem, // SetMem
(EFI_CREATE_EVENT_EX)UnitTestCreateEventEx // CreateEventEx
};
EFI_BOOT_SERVICES *gBS = &mBootServices;

View File

@ -37,8 +37,6 @@ UnitTestRaiseTpl (
IN EFI_TPL NewTpl
);
/**
Lowers the task priority to the previous value. If the new
priority unmasks events at a higher priority, they are dispatched.
@ -137,8 +135,6 @@ UnitTestGetMemoryMap (
OUT UINT32 *DescriptorVersion
);
/**
Allocate pool of a particular type.

View File

@ -188,7 +188,7 @@ UnitTestCalculateCrc32 (
OUT UINT32 *Crc32
)
{
if (Data == NULL || Crc32 == NULL || DataSize == 0) {
if ((Data == NULL) || (Crc32 == NULL) || (DataSize == 0)) {
return EFI_INVALID_PARAMETER;
}

View File

@ -27,7 +27,7 @@ STATIC UINTN mEfiLocateHandleRequest = 0;
**/
EFI_STATUS
UnitTestValidateHandle (
UnitTestValidateHandle (
IN EFI_HANDLE UserHandle
)
{
@ -40,7 +40,7 @@ EFI_STATUS
for (Link = gHandleList.BackLink; Link != &gHandleList; Link = Link->BackLink) {
Handle = CR (Link, IHANDLE, AllHandles, EFI_HANDLE_SIGNATURE);
if (Handle == (IHANDLE *) UserHandle) {
if (Handle == (IHANDLE *)UserHandle) {
return EFI_SUCCESS;
}
}
@ -74,11 +74,10 @@ UnitTestFindProtocolEntry (
ProtEntry = NULL;
for (Link = mProtocolDatabase.ForwardLink;
Link != &mProtocolDatabase;
Link = Link->ForwardLink) {
Link = Link->ForwardLink)
{
Item = CR (Link, PROTOCOL_ENTRY, AllEntries, PROTOCOL_ENTRY_SIGNATURE);
if (CompareGuid (&Item->ProtocolID, Protocol)) {
//
// This is the protocol entry
//
@ -100,7 +99,7 @@ UnitTestFindProtocolEntry (
// Initialize new protocol entry structure
//
ProtEntry->Signature = PROTOCOL_ENTRY_SIGNATURE;
CopyGuid ((VOID *) &ProtEntry->ProtocolID, Protocol);
CopyGuid ((VOID *)&ProtEntry->ProtocolID, Protocol);
InitializeListHead (&ProtEntry->Protocols);
InitializeListHead (&ProtEntry->Notify);
@ -145,17 +144,15 @@ UnitTestFindProtocolInterface (
ProtEntry = UnitTestFindProtocolEntry (Protocol, FALSE);
if (ProtEntry != NULL) {
//
// 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
//
Prot = CR(Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
if (Prot->Interface == Interface && Prot->Protocol == ProtEntry) {
Prot = CR (Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
if ((Prot->Interface == Interface) && (Prot->Protocol == ProtEntry)) {
break;
}
@ -180,8 +177,8 @@ UnitTestNotifyProtocolEntry (
PROTOCOL_NOTIFY *ProtNotify;
LIST_ENTRY *Link;
for (Link=ProtEntry->Notify.ForwardLink; Link != &ProtEntry->Notify; Link=Link->ForwardLink) {
ProtNotify = CR(Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
for (Link = ProtEntry->Notify.ForwardLink; Link != &ProtEntry->Notify; Link = Link->ForwardLink) {
ProtNotify = CR (Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
UnitTestSignalEvent (ProtNotify->Event);
}
}
@ -270,7 +267,6 @@ UnitTestGetNextLocateByRegisterNotify (
return Handle;
}
/**
Routine to get the next Handle, when you are searching for a given protocol.
@ -294,7 +290,7 @@ UnitTestGetNextLocateByProtocol (
Handle = NULL;
*Interface = NULL;
for (; ;) {
for ( ; ;) {
//
// Next entry
//
@ -368,6 +364,7 @@ UnitTestDisconnectControllersUsingProtocolInterface (
if (!EFI_ERROR (Status)) {
ItemFound = TRUE;
}
break;
}
}
@ -380,7 +377,8 @@ UnitTestDisconnectControllersUsingProtocolInterface (
for (Link = Prot->OpenList.ForwardLink; Link != &Prot->OpenList;) {
OpenData = CR (Link, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE);
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);
Prot->OpenListCount--;
FreePool (OpenData);
@ -425,14 +423,13 @@ UnitTestRemoveInterfaceFromProtocol (
Prot = UnitTestFindProtocolInterface (Handle, Protocol, Interface);
if (Prot != NULL) {
ProtEntry = Prot->Protocol;
//
// 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) {
ProtNotify = CR(Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
for (Link = ProtEntry->Notify.ForwardLink; Link != &ProtEntry->Notify; Link = Link->ForwardLink) {
ProtNotify = CR (Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
if (ProtNotify->Position == &Prot->ByProtocol) {
ProtNotify->Position = Prot->ByProtocol.BackLink;
@ -478,18 +475,19 @@ UnitTestGetProtocolInterface (
return NULL;
}
Handle = (IHANDLE *) UserHandle;
Handle = (IHANDLE *)UserHandle;
//
// Look at each protocol interface for a match
//
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;
if (CompareGuid (&ProtEntry->ProtocolID, Protocol)) {
return Prot;
}
}
return NULL;
}
@ -529,7 +527,7 @@ UnitTestInstallProtocolInterfaceNotify (
// returns EFI_INVALID_PARAMETER if InterfaceType is invalid.
// Also added check for invalid UserHandle and Protocol pointers.
//
if (UserHandle == NULL || Protocol == NULL) {
if ((UserHandle == NULL) || (Protocol == NULL)) {
return EFI_INVALID_PARAMETER;
}
@ -547,7 +545,7 @@ UnitTestInstallProtocolInterfaceNotify (
Handle = NULL;
if (*UserHandle != NULL) {
Status = UnitTestHandleProtocol (*UserHandle, Protocol, (VOID **) &ExistingInterface);
Status = UnitTestHandleProtocol (*UserHandle, Protocol, (VOID **)&ExistingInterface);
if (!EFI_ERROR (Status)) {
return EFI_INVALID_PARAMETER;
}
@ -573,7 +571,7 @@ UnitTestInstallProtocolInterfaceNotify (
//
// If caller didn't supply a handle, allocate a new one
//
Handle = (IHANDLE *) *UserHandle;
Handle = (IHANDLE *)*UserHandle;
if (Handle == NULL) {
Handle = AllocateZeroPool (sizeof (IHANDLE));
if (Handle == NULL) {
@ -601,7 +599,7 @@ UnitTestInstallProtocolInterfaceNotify (
} else {
Status = UnitTestValidateHandle (Handle);
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;
}
}
@ -643,6 +641,7 @@ UnitTestInstallProtocolInterfaceNotify (
if (Notify) {
UnitTestNotifyProtocolEntry (ProtEntry);
}
Status = EFI_SUCCESS;
Done:
@ -658,6 +657,7 @@ Done:
if (Prot != NULL) {
UnitTestFreePool (Prot);
}
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
//
Status = EFI_NOT_FOUND;
Handle = (IHANDLE *) UserHandle;
Handle = (IHANDLE *)UserHandle;
Prot = UnitTestRemoveInterfaceFromProtocol (Handle, Protocol, Interface);
if (Prot != NULL) {
@ -933,7 +933,7 @@ UnitTestLocateHandle (
Position.Position = &gHandleList;
ResultSize = 0;
ResultBuffer = (IHANDLE **) Buffer;
ResultBuffer = (IHANDLE **)Buffer;
Status = EFI_SUCCESS;
//
@ -952,6 +952,7 @@ UnitTestLocateHandle (
Status = EFI_INVALID_PARAMETER;
break;
}
GetNext = UnitTestGetNextLocateByRegisterNotify;
break;
@ -961,6 +962,7 @@ UnitTestLocateHandle (
Status = EFI_INVALID_PARAMETER;
break;
}
//
// Look up the protocol entry and set the head pointer
//
@ -969,6 +971,7 @@ UnitTestLocateHandle (
Status = EFI_NOT_FOUND;
break;
}
Position.Position = &Position.ProtEntry->Protocols;
break;
@ -986,7 +989,7 @@ UnitTestLocateHandle (
// Enumerate out the matching handles
//
mEfiLocateHandleRequest += 1;
for (; ;) {
for ( ; ;) {
//
// Get the next handle. If no more handles, stop
//
@ -1023,7 +1026,7 @@ UnitTestLocateHandle (
*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
// returned, update the register notification position
@ -1154,39 +1157,45 @@ UnitTestOpenProtocol (
// Check for invalid Attributes
//
switch (Attributes) {
case EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER :
case EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER:
Status = UnitTestValidateHandle (ImageHandle);
if (EFI_ERROR (Status)) {
return Status;
}
Status = UnitTestValidateHandle (ControllerHandle);
if (EFI_ERROR (Status)) {
return Status;
}
if (UserHandle == ControllerHandle) {
return EFI_INVALID_PARAMETER;
}
break;
case EFI_OPEN_PROTOCOL_BY_DRIVER :
case EFI_OPEN_PROTOCOL_BY_DRIVER | EFI_OPEN_PROTOCOL_EXCLUSIVE :
case EFI_OPEN_PROTOCOL_BY_DRIVER:
case EFI_OPEN_PROTOCOL_BY_DRIVER | EFI_OPEN_PROTOCOL_EXCLUSIVE:
Status = UnitTestValidateHandle (ImageHandle);
if (EFI_ERROR (Status)) {
return Status;
}
Status = UnitTestValidateHandle (ControllerHandle);
if (EFI_ERROR (Status)) {
return Status;
}
break;
case EFI_OPEN_PROTOCOL_EXCLUSIVE :
case EFI_OPEN_PROTOCOL_EXCLUSIVE:
Status = UnitTestValidateHandle (ImageHandle);
if (EFI_ERROR (Status)) {
return Status;
}
break;
case EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL :
case EFI_OPEN_PROTOCOL_GET_PROTOCOL :
case EFI_OPEN_PROTOCOL_TEST_PROTOCOL :
case EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL:
case EFI_OPEN_PROTOCOL_GET_PROTOCOL:
case EFI_OPEN_PROTOCOL_TEST_PROTOCOL:
break;
default:
return EFI_INVALID_PARAMETER;
@ -1217,6 +1226,7 @@ UnitTestOpenProtocol (
goto Done;
}
}
if ((OpenData->Attributes & EFI_OPEN_PROTOCOL_EXCLUSIVE) != 0) {
Exclusive = TRUE;
} else if (ExactMatch) {
@ -1234,18 +1244,20 @@ UnitTestOpenProtocol (
//
switch (Attributes) {
case EFI_OPEN_PROTOCOL_BY_DRIVER :
case EFI_OPEN_PROTOCOL_BY_DRIVER:
if (Exclusive || ByDriver) {
Status = EFI_ACCESS_DENIED;
goto Done;
}
break;
case EFI_OPEN_PROTOCOL_BY_DRIVER | EFI_OPEN_PROTOCOL_EXCLUSIVE :
case EFI_OPEN_PROTOCOL_EXCLUSIVE :
case EFI_OPEN_PROTOCOL_BY_DRIVER | EFI_OPEN_PROTOCOL_EXCLUSIVE:
case EFI_OPEN_PROTOCOL_EXCLUSIVE:
if (Exclusive) {
Status = EFI_ACCESS_DENIED;
goto Done;
}
if (ByDriver) {
do {
Disconnect = FALSE;
@ -1264,11 +1276,12 @@ UnitTestOpenProtocol (
}
} while (Disconnect);
}
break;
case EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER :
case EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL :
case EFI_OPEN_PROTOCOL_GET_PROTOCOL :
case EFI_OPEN_PROTOCOL_TEST_PROTOCOL :
case EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER:
case EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL:
case EFI_OPEN_PROTOCOL_GET_PROTOCOL:
case EFI_OPEN_PROTOCOL_TEST_PROTOCOL:
break;
}
@ -1276,10 +1289,11 @@ UnitTestOpenProtocol (
Status = EFI_SUCCESS;
goto Done;
}
//
// Create new entry
//
OpenData = AllocatePool (sizeof(OPEN_PROTOCOL_DATA));
OpenData = AllocatePool (sizeof (OPEN_PROTOCOL_DATA));
if (OpenData == NULL) {
Status = EFI_OUT_OF_RESOURCES;
} else {
@ -1300,7 +1314,7 @@ Done:
// Keep Interface unmodified in case of any Error
// 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
// 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().
//
if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) {
if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
if (Status != EFI_INVALID_PARAMETER) {
Status = EFI_NOT_FOUND;
}
return Status;
}
@ -1609,6 +1624,7 @@ UnitTestUninstallMultipleProtocolInterfaces (
//
Status = UnitTestUninstallProtocolInterface (Handle, Protocol, Interface);
}
VA_END (Args);
//
@ -1620,11 +1636,12 @@ UnitTestUninstallMultipleProtocolInterfaces (
// Reset the va_arg back to the first argument.
//
VA_START (Args, Handle);
for (; Index > 1; Index--) {
Protocol = VA_ARG(Args, EFI_GUID *);
Interface = VA_ARG(Args, VOID *);
for ( ; Index > 1; Index--) {
Protocol = VA_ARG (Args, EFI_GUID *);
Interface = VA_ARG (Args, VOID *);
UnitTestInstallProtocolInterface (&Handle, Protocol, EFI_NATIVE_INTERFACE, Interface);
}
VA_END (Args);
Status = EFI_INVALID_PARAMETER;
}

View File

@ -51,7 +51,6 @@ typedef struct {
LIST_ENTRY Notify;
} PROTOCOL_ENTRY;
#define PROTOCOL_INTERFACE_SIGNATURE SIGNATURE_32('p','i','f','c')
///
@ -73,14 +72,13 @@ typedef struct {
/// OPEN_PROTOCOL_DATA list
LIST_ENTRY OpenList;
UINTN OpenListCount;
} PROTOCOL_INTERFACE;
#define OPEN_PROTOCOL_DATA_SIGNATURE SIGNATURE_32('p','o','d','l')
typedef struct {
UINTN Signature;
///Link on PROTOCOL_INTERFACE.OpenList
/// Link on PROTOCOL_INTERFACE.OpenList
LIST_ENTRY Link;
EFI_HANDLE AgentHandle;
@ -89,7 +87,6 @@ typedef struct {
UINT32 OpenCount;
} OPEN_PROTOCOL_DATA;
#define PROTOCOL_NOTIFY_SIGNATURE SIGNATURE_32('p','r','t','n')
///
@ -115,7 +112,7 @@ typedef struct {
typedef
IHANDLE *
(* UNIT_TEST_GET_NEXT) (
(*UNIT_TEST_GET_NEXT) (
IN OUT LOCATE_POSITION *Position,
OUT VOID **Interface
);