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
@@ -14,7 +14,7 @@
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Protocol/PrmConfig.h>
|
||||
|
||||
#define _DBGMSGID_ "[PRMCONTEXTBUFFERLIB]"
|
||||
#define _DBGMSGID_ "[PRMCONTEXTBUFFERLIB]"
|
||||
|
||||
/**
|
||||
Finds a PRM context buffer for the given PRM handler GUID.
|
||||
@@ -33,16 +33,16 @@
|
||||
**/
|
||||
EFI_STATUS
|
||||
FindContextBufferInModuleBuffers (
|
||||
IN CONST EFI_GUID *HandlerGuid,
|
||||
IN CONST PRM_MODULE_CONTEXT_BUFFERS *ModuleContextBuffers,
|
||||
OUT CONST PRM_CONTEXT_BUFFER **ContextBuffer
|
||||
IN CONST EFI_GUID *HandlerGuid,
|
||||
IN CONST PRM_MODULE_CONTEXT_BUFFERS *ModuleContextBuffers,
|
||||
OUT CONST PRM_CONTEXT_BUFFER **ContextBuffer
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
UINTN Index;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -77,23 +77,24 @@ FindContextBufferInModuleBuffers (
|
||||
**/
|
||||
EFI_STATUS
|
||||
GetModuleContextBuffers (
|
||||
IN PRM_GUID_SEARCH_TYPE GuidSearchType,
|
||||
IN CONST EFI_GUID *Guid,
|
||||
OUT CONST PRM_MODULE_CONTEXT_BUFFERS **PrmModuleContextBuffers
|
||||
IN PRM_GUID_SEARCH_TYPE GuidSearchType,
|
||||
IN CONST EFI_GUID *Guid,
|
||||
OUT CONST PRM_MODULE_CONTEXT_BUFFERS **PrmModuleContextBuffers
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN HandleCount;
|
||||
UINTN Index;
|
||||
EFI_HANDLE *HandleBuffer;
|
||||
PRM_CONFIG_PROTOCOL *PrmConfigProtocol;
|
||||
CONST PRM_CONTEXT_BUFFER *PrmContextBuffer;
|
||||
EFI_STATUS Status;
|
||||
UINTN HandleCount;
|
||||
UINTN Index;
|
||||
EFI_HANDLE *HandleBuffer;
|
||||
PRM_CONFIG_PROTOCOL *PrmConfigProtocol;
|
||||
CONST PRM_CONTEXT_BUFFER *PrmContextBuffer;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -167,19 +168,20 @@ GetModuleContextBuffers (
|
||||
**/
|
||||
EFI_STATUS
|
||||
GetContextBuffer (
|
||||
IN CONST EFI_GUID *PrmHandlerGuid,
|
||||
IN CONST PRM_MODULE_CONTEXT_BUFFERS *PrmModuleContextBuffers OPTIONAL,
|
||||
OUT CONST PRM_CONTEXT_BUFFER **PrmContextBuffer
|
||||
IN CONST EFI_GUID *PrmHandlerGuid,
|
||||
IN CONST PRM_MODULE_CONTEXT_BUFFERS *PrmModuleContextBuffers OPTIONAL,
|
||||
OUT CONST PRM_CONTEXT_BUFFER **PrmContextBuffer
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
CONST PRM_MODULE_CONTEXT_BUFFERS *ContextBuffers;
|
||||
EFI_STATUS Status;
|
||||
CONST PRM_MODULE_CONTEXT_BUFFERS *ContextBuffers;
|
||||
|
||||
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;
|
||||
|
@@ -27,69 +27,69 @@
|
||||
#include <Library/UnitTestLib.h>
|
||||
#include <Protocol/PrmConfig.h>
|
||||
|
||||
#define UNIT_TEST_NAME "PRM Context Buffer Library Unit Test"
|
||||
#define UNIT_TEST_VERSION "0.1"
|
||||
#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;
|
||||
PRM_GUID_SEARCH_TYPE GuidSearchType;
|
||||
EFI_GUID *Guid;
|
||||
EFI_GUID *ExpectedModuleGuid;
|
||||
EFI_STATUS ExpectedStatus;
|
||||
PRM_MODULE_CONTEXT_BUFFERS *InstallationStructure;
|
||||
EFI_HANDLE Handle;
|
||||
PRM_GUID_SEARCH_TYPE GuidSearchType;
|
||||
EFI_GUID *Guid;
|
||||
EFI_GUID *ExpectedModuleGuid;
|
||||
EFI_STATUS ExpectedStatus;
|
||||
} PRM_CONTEXT_BUFFERS_TEST_CONTEXT;
|
||||
|
||||
typedef struct {
|
||||
EFI_GUID *HandlerGuid;
|
||||
PRM_MODULE_CONTEXT_BUFFERS *ContextBuffers;
|
||||
PRM_CONTEXT_BUFFER *ExpectedContextBuffer;
|
||||
EFI_STATUS ExpectedStatus;
|
||||
EFI_GUID *HandlerGuid;
|
||||
PRM_MODULE_CONTEXT_BUFFERS *ContextBuffers;
|
||||
PRM_CONTEXT_BUFFER *ExpectedContextBuffer;
|
||||
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 }}
|
||||
EFI_GUID mHandlerTestGuid1 = HANDLER_TEST_GUID_1;
|
||||
#define HANDLER_TEST_GUID_1 {0x52960b90, 0x2f3a, 0x4917, { 0xb9, 0x1a, 0xed, 0x5f, 0x59, 0x9a, 0x88, 0x09 }}
|
||||
EFI_GUID mHandlerTestGuid1 = HANDLER_TEST_GUID_1;
|
||||
|
||||
// {9316a80d-06dc-417b-b21d-6b3c2ae4ed6f}
|
||||
#define HANDLER_TEST_GUID_2 {0x9316a80d, 0x06dc, 0x417b, { 0xb2, 0x1d, 0x6b, 0x3c, 0x2a, 0xe4, 0xed, 0x6f }}
|
||||
EFI_GUID mHandlerTestGuid2 = HANDLER_TEST_GUID_2;
|
||||
#define HANDLER_TEST_GUID_2 {0x9316a80d, 0x06dc, 0x417b, { 0xb2, 0x1d, 0x6b, 0x3c, 0x2a, 0xe4, 0xed, 0x6f }}
|
||||
EFI_GUID mHandlerTestGuid2 = HANDLER_TEST_GUID_2;
|
||||
|
||||
// {d32ac8ba-6cc6-456f-9ed9-9233fa310434}
|
||||
#define HANDLER_TEST_GUID_3 {0xd32ac8ba, 0x6cc6, 0x456f, { 0x9e, 0xd9, 0x92, 0x33, 0xfa, 0x31, 0x04, 0x34 }}
|
||||
EFI_GUID mHandlerTestGuid3 = HANDLER_TEST_GUID_3;
|
||||
#define HANDLER_TEST_GUID_3 {0xd32ac8ba, 0x6cc6, 0x456f, { 0x9e, 0xd9, 0x92, 0x33, 0xfa, 0x31, 0x04, 0x34 }}
|
||||
EFI_GUID mHandlerTestGuid3 = HANDLER_TEST_GUID_3;
|
||||
|
||||
// {faadaa95-070b-4a34-a919-18305dc07370}
|
||||
#define MODULE_TEST_GUID_1 {0xfaadaa95, 0x070b, 0x4a34, { 0xa9, 0x19, 0x18, 0x30, 0x5d, 0xc0, 0x73, 0x70 }}
|
||||
EFI_GUID mModuleTestGuid1 = MODULE_TEST_GUID_1;
|
||||
#define MODULE_TEST_GUID_1 {0xfaadaa95, 0x070b, 0x4a34, { 0xa9, 0x19, 0x18, 0x30, 0x5d, 0xc0, 0x73, 0x70 }}
|
||||
EFI_GUID mModuleTestGuid1 = MODULE_TEST_GUID_1;
|
||||
|
||||
// {0ea24584-731c-4863-9100-75780af509a7}
|
||||
#define MODULE_TEST_GUID_2 {0x0ea24584, 0x731c, 0x4863, { 0x91, 0x00, 0x75, 0x78, 0x0a, 0xf5, 0x09, 0xa7 }}
|
||||
EFI_GUID mModuleTestGuid2 = MODULE_TEST_GUID_2;
|
||||
#define MODULE_TEST_GUID_2 {0x0ea24584, 0x731c, 0x4863, { 0x91, 0x00, 0x75, 0x78, 0x0a, 0xf5, 0x09, 0xa7 }}
|
||||
EFI_GUID mModuleTestGuid2 = MODULE_TEST_GUID_2;
|
||||
|
||||
// {f456b7a1-82a6-4427-8486-87e3a602df43}
|
||||
#define MODULE_TEST_GUID_3 {0xf456b7a1, 0x82a6, 0x4427, { 0x84, 0x86, 0x87, 0xe3, 0xa6, 0x02, 0xdf, 0x43 }}
|
||||
EFI_GUID mModuleTestGuid3 = MODULE_TEST_GUID_3;
|
||||
#define MODULE_TEST_GUID_3 {0xf456b7a1, 0x82a6, 0x4427, { 0x84, 0x86, 0x87, 0xe3, 0xa6, 0x02, 0xdf, 0x43 }}
|
||||
EFI_GUID mModuleTestGuid3 = MODULE_TEST_GUID_3;
|
||||
|
||||
// {4a941a9c-9dcf-471b-94b5-d9e2d8c64a1b}
|
||||
#define NEGATIVE_TEST_GUID {0x4a941a9c, 0x9dcf, 0x471b, {0x94, 0xb5, 0xd9, 0xe2, 0xd8, 0xc6, 0x4a, 0x1b }}
|
||||
EFI_GUID mNegativeTestGuid = NEGATIVE_TEST_GUID;
|
||||
#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 = {
|
||||
PRM_DATA_BUFFER mTestStaticDataBuffer1 = {
|
||||
{
|
||||
PRM_DATA_BUFFER_HEADER_SIGNATURE,
|
||||
sizeof (PRM_DATA_BUFFER)
|
||||
@@ -97,7 +97,7 @@ PRM_DATA_BUFFER mTestStaticDataBuffer1 = {
|
||||
// No data in the buffer (only a header)
|
||||
};
|
||||
|
||||
PRM_CONTEXT_BUFFER mTestPrmContextBuffer1 = {
|
||||
PRM_CONTEXT_BUFFER mTestPrmContextBuffer1 = {
|
||||
PRM_CONTEXT_BUFFER_SIGNATURE, // Signature
|
||||
PRM_CONTEXT_BUFFER_INTERFACE_VERSION, // Version
|
||||
0, // Reserved
|
||||
@@ -105,7 +105,7 @@ PRM_CONTEXT_BUFFER mTestPrmContextBuffer1 = {
|
||||
&mTestStaticDataBuffer1 // StaticDataBuffer
|
||||
};
|
||||
|
||||
PRM_CONTEXT_BUFFER mTestPrmContextBuffer2[2] = {
|
||||
PRM_CONTEXT_BUFFER mTestPrmContextBuffer2[2] = {
|
||||
// Context buffer #1
|
||||
{
|
||||
PRM_CONTEXT_BUFFER_SIGNATURE, // Signature
|
||||
@@ -124,56 +124,55 @@ PRM_CONTEXT_BUFFER mTestPrmContextBuffer2[2] = {
|
||||
}
|
||||
};
|
||||
|
||||
PRM_MODULE_CONTEXT_BUFFERS mTestPrmModuleContextBuffers1 = {
|
||||
PRM_MODULE_CONTEXT_BUFFERS mTestPrmModuleContextBuffers1 = {
|
||||
MODULE_TEST_GUID_1,
|
||||
1,
|
||||
&mTestPrmContextBuffer1,
|
||||
NULL
|
||||
};
|
||||
|
||||
PRM_MODULE_CONTEXT_BUFFERS mTestPrmModuleContextBuffers2 = {
|
||||
PRM_MODULE_CONTEXT_BUFFERS mTestPrmModuleContextBuffers2 = {
|
||||
MODULE_TEST_GUID_2,
|
||||
1,
|
||||
&mTestPrmContextBuffer1,
|
||||
NULL
|
||||
};
|
||||
|
||||
PRM_MODULE_CONTEXT_BUFFERS mTestPrmModuleContextBuffers3 = {
|
||||
PRM_MODULE_CONTEXT_BUFFERS mTestPrmModuleContextBuffers3 = {
|
||||
MODULE_TEST_GUID_3,
|
||||
2,
|
||||
&mTestPrmContextBuffer2[0],
|
||||
NULL
|
||||
};
|
||||
|
||||
// *----------------------------------------------------------------------------------*
|
||||
// * Test Contexts *
|
||||
// *----------------------------------------------------------------------------------*
|
||||
|
||||
//*----------------------------------------------------------------------------------*
|
||||
//* Test Contexts *
|
||||
//*----------------------------------------------------------------------------------*
|
||||
|
||||
//* Searches by module GUID *
|
||||
// * Searches by module GUID *
|
||||
// +--------------------------------+--------+----------------+--------------------+--------------------+--------------------+
|
||||
// + InstallationStructure | Handle | GuidSearchType | Guid | ExpectedModuleGuid | ExpectedStatus |
|
||||
// +--------------------------------+--------+----------------+--------------------+--------------------+--------------------+
|
||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers00 = { &mTestPrmModuleContextBuffers1, NULL, ByModuleGuid, &mModuleTestGuid1, &mModuleTestGuid1, EFI_SUCCESS };
|
||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers01 = { &mTestPrmModuleContextBuffers2, NULL, ByModuleGuid, &mModuleTestGuid2, &mModuleTestGuid2, EFI_SUCCESS };
|
||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers02 = { &mTestPrmModuleContextBuffers3, NULL, ByModuleGuid, &mModuleTestGuid3, &mModuleTestGuid3, EFI_SUCCESS };
|
||||
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 mContextBuffers00 = { &mTestPrmModuleContextBuffers1, NULL, ByModuleGuid, &mModuleTestGuid1, &mModuleTestGuid1, EFI_SUCCESS };
|
||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers01 = { &mTestPrmModuleContextBuffers2, NULL, ByModuleGuid, &mModuleTestGuid2, &mModuleTestGuid2, EFI_SUCCESS };
|
||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers02 = { &mTestPrmModuleContextBuffers3, NULL, ByModuleGuid, &mModuleTestGuid3, &mModuleTestGuid3, EFI_SUCCESS };
|
||||
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 |
|
||||
// +--------------------------------+--------+----------------+--------------------+--------------------+--------------------+
|
||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers05 = { &mTestPrmModuleContextBuffers1, NULL, ByHandlerGuid, &mHandlerTestGuid1, &mModuleTestGuid1, EFI_SUCCESS };
|
||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers06 = { &mTestPrmModuleContextBuffers1, NULL, ByHandlerGuid, &gZeroGuid, &gZeroGuid, EFI_NOT_FOUND };
|
||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers07 = { &mTestPrmModuleContextBuffers2, NULL, ByHandlerGuid, &mHandlerTestGuid1, &mModuleTestGuid2, EFI_SUCCESS };
|
||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers08 = { &mTestPrmModuleContextBuffers2, NULL, ByHandlerGuid, &mNegativeTestGuid, &gZeroGuid, EFI_NOT_FOUND };
|
||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers09 = { &mTestPrmModuleContextBuffers3, NULL, ByHandlerGuid, &mHandlerTestGuid1, &gZeroGuid, EFI_NOT_FOUND };
|
||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers10 = { &mTestPrmModuleContextBuffers3, NULL, ByHandlerGuid, &mHandlerTestGuid2, &mModuleTestGuid3, EFI_SUCCESS };
|
||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers11 = { &mTestPrmModuleContextBuffers3, NULL, ByHandlerGuid, &mHandlerTestGuid3, &mModuleTestGuid3, EFI_SUCCESS };
|
||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers12 = { &mTestPrmModuleContextBuffers3, NULL, ByHandlerGuid, &gZeroGuid, &gZeroGuid, EFI_NOT_FOUND };
|
||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers05 = { &mTestPrmModuleContextBuffers1, NULL, ByHandlerGuid, &mHandlerTestGuid1, &mModuleTestGuid1, EFI_SUCCESS };
|
||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers06 = { &mTestPrmModuleContextBuffers1, NULL, ByHandlerGuid, &gZeroGuid, &gZeroGuid, EFI_NOT_FOUND };
|
||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers07 = { &mTestPrmModuleContextBuffers2, NULL, ByHandlerGuid, &mHandlerTestGuid1, &mModuleTestGuid2, EFI_SUCCESS };
|
||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers08 = { &mTestPrmModuleContextBuffers2, NULL, ByHandlerGuid, &mNegativeTestGuid, &gZeroGuid, EFI_NOT_FOUND };
|
||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers09 = { &mTestPrmModuleContextBuffers3, NULL, ByHandlerGuid, &mHandlerTestGuid1, &gZeroGuid, EFI_NOT_FOUND };
|
||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers10 = { &mTestPrmModuleContextBuffers3, NULL, ByHandlerGuid, &mHandlerTestGuid2, &mModuleTestGuid3, EFI_SUCCESS };
|
||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers11 = { &mTestPrmModuleContextBuffers3, NULL, ByHandlerGuid, &mHandlerTestGuid3, &mModuleTestGuid3, EFI_SUCCESS };
|
||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers12 = { &mTestPrmModuleContextBuffers3, NULL, ByHandlerGuid, &gZeroGuid, &gZeroGuid, EFI_NOT_FOUND };
|
||||
|
||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT *mContextBuffersArray[] = {
|
||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT *mContextBuffersArray[] = {
|
||||
&mContextBuffers00,
|
||||
&mContextBuffers01,
|
||||
&mContextBuffers02,
|
||||
@@ -192,14 +191,14 @@ PRM_CONTEXT_BUFFERS_TEST_CONTEXT *mContextBuffersArray[] = {
|
||||
// +----------------------+----------------------------------+------------------------------------------+--------------------+
|
||||
// + HandlerGuid | ContextBuffers | ExpectedContextBuffer | ExpectedStatus |
|
||||
// +----------------------+----------------------------------+------------------------------------------+--------------------+
|
||||
PRM_CONTEXT_BUFFER_TEST_CONTEXT mContextBuffer00 = { &mHandlerTestGuid1, &mTestPrmModuleContextBuffers1, &mTestPrmContextBuffer1, EFI_SUCCESS };
|
||||
PRM_CONTEXT_BUFFER_TEST_CONTEXT mContextBuffer01 = { &mHandlerTestGuid1, &mTestPrmModuleContextBuffers2, &mTestPrmContextBuffer1, EFI_SUCCESS };
|
||||
PRM_CONTEXT_BUFFER_TEST_CONTEXT mContextBuffer02 = { &mHandlerTestGuid2, &mTestPrmModuleContextBuffers3, &mTestPrmContextBuffer2[0], EFI_SUCCESS };
|
||||
PRM_CONTEXT_BUFFER_TEST_CONTEXT mContextBuffer03 = { &mHandlerTestGuid3, &mTestPrmModuleContextBuffers3, &mTestPrmContextBuffer2[1], EFI_SUCCESS };
|
||||
PRM_CONTEXT_BUFFER_TEST_CONTEXT mContextBuffer04 = { &mNegativeTestGuid, &mTestPrmModuleContextBuffers1, NULL, EFI_NOT_FOUND };
|
||||
PRM_CONTEXT_BUFFER_TEST_CONTEXT mContextBuffer05 = { &gZeroGuid, &mTestPrmModuleContextBuffers3, NULL, EFI_NOT_FOUND };
|
||||
PRM_CONTEXT_BUFFER_TEST_CONTEXT mContextBuffer00 = { &mHandlerTestGuid1, &mTestPrmModuleContextBuffers1, &mTestPrmContextBuffer1, EFI_SUCCESS };
|
||||
PRM_CONTEXT_BUFFER_TEST_CONTEXT mContextBuffer01 = { &mHandlerTestGuid1, &mTestPrmModuleContextBuffers2, &mTestPrmContextBuffer1, EFI_SUCCESS };
|
||||
PRM_CONTEXT_BUFFER_TEST_CONTEXT mContextBuffer02 = { &mHandlerTestGuid2, &mTestPrmModuleContextBuffers3, &mTestPrmContextBuffer2[0], EFI_SUCCESS };
|
||||
PRM_CONTEXT_BUFFER_TEST_CONTEXT mContextBuffer03 = { &mHandlerTestGuid3, &mTestPrmModuleContextBuffers3, &mTestPrmContextBuffer2[1], EFI_SUCCESS };
|
||||
PRM_CONTEXT_BUFFER_TEST_CONTEXT mContextBuffer04 = { &mNegativeTestGuid, &mTestPrmModuleContextBuffers1, NULL, EFI_NOT_FOUND };
|
||||
PRM_CONTEXT_BUFFER_TEST_CONTEXT mContextBuffer05 = { &gZeroGuid, &mTestPrmModuleContextBuffers3, NULL, EFI_NOT_FOUND };
|
||||
|
||||
PRM_CONTEXT_BUFFER_TEST_CONTEXT *mContextBufferArray[] = {
|
||||
PRM_CONTEXT_BUFFER_TEST_CONTEXT *mContextBufferArray[] = {
|
||||
&mContextBuffer00,
|
||||
&mContextBuffer01,
|
||||
&mContextBuffer02,
|
||||
@@ -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.
|
||||
@@ -229,13 +228,13 @@ PRM_CONTEXT_BUFFER_TEST_CONTEXT *mContextBufferArray[] = {
|
||||
UNIT_TEST_STATUS
|
||||
EFIAPI
|
||||
NullPointerArgumentsShouldFailGracefully (
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
)
|
||||
{
|
||||
EFI_GUID Guid;
|
||||
PRM_CONTEXT_BUFFER *ContextBufferPtr;
|
||||
PRM_MODULE_CONTEXT_BUFFERS ModuleContextBuffers;
|
||||
PRM_MODULE_CONTEXT_BUFFERS *ModuleContextBuffersPtr;
|
||||
EFI_GUID Guid;
|
||||
PRM_CONTEXT_BUFFER *ContextBufferPtr;
|
||||
PRM_MODULE_CONTEXT_BUFFERS ModuleContextBuffers;
|
||||
PRM_MODULE_CONTEXT_BUFFERS *ModuleContextBuffersPtr;
|
||||
|
||||
UT_ASSERT_EQUAL (FindContextBufferInModuleBuffers (NULL, NULL, NULL), EFI_INVALID_PARAMETER);
|
||||
UT_ASSERT_EQUAL (FindContextBufferInModuleBuffers (NULL, &ModuleContextBuffers, &ContextBufferPtr), EFI_INVALID_PARAMETER);
|
||||
@@ -254,7 +253,7 @@ NullPointerArgumentsShouldFailGracefully (
|
||||
return UNIT_TEST_PASSED;
|
||||
}
|
||||
|
||||
///===== FUNCTIONAL CORRECTNESS SUITE ==================================================
|
||||
/// ===== FUNCTIONAL CORRECTNESS SUITE ==================================================
|
||||
|
||||
/**
|
||||
Functional Correctness pre-requisite function.
|
||||
@@ -275,16 +274,16 @@ STATIC
|
||||
UNIT_TEST_STATUS
|
||||
EFIAPI
|
||||
InitializeFunctionalCorrectness (
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
PRM_CONFIG_PROTOCOL *PrmConfigProtocol;
|
||||
PRM_MODULE_CONTEXT_BUFFERS *ModuleContextBuffers;
|
||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT *TestContext;
|
||||
EFI_STATUS Status;
|
||||
PRM_CONFIG_PROTOCOL *PrmConfigProtocol;
|
||||
PRM_MODULE_CONTEXT_BUFFERS *ModuleContextBuffers;
|
||||
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));
|
||||
@@ -294,14 +293,14 @@ InitializeFunctionalCorrectness (
|
||||
|
||||
CopyGuid (&PrmConfigProtocol->ModuleContextBuffers.ModuleGuid, &ModuleContextBuffers->ModuleGuid);
|
||||
PrmConfigProtocol->ModuleContextBuffers.BufferCount = ModuleContextBuffers->BufferCount;
|
||||
PrmConfigProtocol->ModuleContextBuffers.Buffer = ModuleContextBuffers->Buffer;
|
||||
PrmConfigProtocol->ModuleContextBuffers.Buffer = ModuleContextBuffers->Buffer;
|
||||
|
||||
Status = gBS->InstallProtocolInterface (
|
||||
&TestContext->Handle,
|
||||
&gPrmConfigProtocolGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
(VOID *) PrmConfigProtocol
|
||||
);
|
||||
&TestContext->Handle,
|
||||
&gPrmConfigProtocolGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
(VOID *)PrmConfigProtocol
|
||||
);
|
||||
UT_ASSERT_NOT_EFI_ERROR (Status);
|
||||
|
||||
return UNIT_TEST_PASSED;
|
||||
@@ -326,20 +325,20 @@ STATIC
|
||||
UNIT_TEST_STATUS
|
||||
EFIAPI
|
||||
DeInitializeFunctionalCorrectness (
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
PRM_CONFIG_PROTOCOL *PrmConfigProtocol;
|
||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT *TestContext;
|
||||
EFI_STATUS Status;
|
||||
PRM_CONFIG_PROTOCOL *PrmConfigProtocol;
|
||||
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);
|
||||
|
||||
@@ -348,7 +347,7 @@ DeInitializeFunctionalCorrectness (
|
||||
TestContext->Handle,
|
||||
&gPrmConfigProtocolGuid,
|
||||
PrmConfigProtocol
|
||||
);
|
||||
);
|
||||
UT_ASSERT_NOT_EFI_ERROR (Status);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
FreePool (PrmConfigProtocol);
|
||||
@@ -373,15 +372,15 @@ DeInitializeFunctionalCorrectness (
|
||||
UNIT_TEST_STATUS
|
||||
EFIAPI
|
||||
VerifyGetModuleContextBuffers (
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
PRM_MODULE_CONTEXT_BUFFERS *ContextBuffers;
|
||||
PRM_CONTEXT_BUFFERS_TEST_CONTEXT *TestContext;
|
||||
EFI_STATUS Status;
|
||||
PRM_MODULE_CONTEXT_BUFFERS *ContextBuffers;
|
||||
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
|
||||
);
|
||||
}
|
||||
|
||||
@@ -415,17 +414,17 @@ VerifyGetModuleContextBuffers (
|
||||
UNIT_TEST_STATUS
|
||||
EFIAPI
|
||||
VerifyFindContextBufferInModuleBuffers (
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
PRM_CONTEXT_BUFFER *FoundContextBuffer;
|
||||
PRM_MODULE_CONTEXT_BUFFERS *ContextBuffers;
|
||||
PRM_CONTEXT_BUFFER_TEST_CONTEXT *TestContext;
|
||||
EFI_STATUS Status;
|
||||
PRM_CONTEXT_BUFFER *FoundContextBuffer;
|
||||
PRM_MODULE_CONTEXT_BUFFERS *ContextBuffers;
|
||||
PRM_CONTEXT_BUFFER_TEST_CONTEXT *TestContext;
|
||||
|
||||
ContextBuffers = NULL;
|
||||
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);
|
||||
@@ -461,17 +460,17 @@ VerifyFindContextBufferInModuleBuffers (
|
||||
UNIT_TEST_STATUS
|
||||
EFIAPI
|
||||
VerifyGetContextBuffer (
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
PRM_CONTEXT_BUFFER *FoundContextBuffer;
|
||||
PRM_MODULE_CONTEXT_BUFFERS *ContextBuffers;
|
||||
PRM_CONTEXT_BUFFER_TEST_CONTEXT *TestContext;
|
||||
EFI_STATUS Status;
|
||||
PRM_CONTEXT_BUFFER *FoundContextBuffer;
|
||||
PRM_MODULE_CONTEXT_BUFFERS *ContextBuffers;
|
||||
PRM_CONTEXT_BUFFER_TEST_CONTEXT *TestContext;
|
||||
|
||||
ContextBuffers = NULL;
|
||||
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);
|
||||
}
|
||||
|
||||
|
@@ -23,7 +23,7 @@
|
||||
|
||||
#define _DBGMSGID_ "[PRMMODULEDISCOVERYLIB]"
|
||||
|
||||
LIST_ENTRY mPrmModuleList;
|
||||
LIST_ENTRY mPrmModuleList;
|
||||
|
||||
/**
|
||||
Gets the next PRM module discovered after the given PRM module.
|
||||
@@ -40,13 +40,13 @@ LIST_ENTRY mPrmModuleList;
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
GetNextPrmModuleEntry (
|
||||
IN OUT PRM_MODULE_IMAGE_CONTEXT **ModuleImageContext
|
||||
IN OUT PRM_MODULE_IMAGE_CONTEXT **ModuleImageContext
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *CurrentLink;
|
||||
LIST_ENTRY *ForwardLink;
|
||||
PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY *CurrentListEntry;
|
||||
PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY *ForwardListEntry;
|
||||
LIST_ENTRY *CurrentLink;
|
||||
LIST_ENTRY *ForwardLink;
|
||||
PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY *CurrentListEntry;
|
||||
PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY *ForwardListEntry;
|
||||
|
||||
DEBUG ((DEBUG_INFO, "%a %a - Entry.\n", _DBGMSGID_, __FUNCTION__));
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ CreateNewPrmModuleImageContextListEntry (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY *PrmModuleImageContextListEntry;
|
||||
PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY *PrmModuleImageContextListEntry;
|
||||
|
||||
DEBUG ((DEBUG_INFO, "%a %a - Entry.\n", _DBGMSGID_, __FUNCTION__));
|
||||
|
||||
@@ -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)
|
||||
));
|
||||
|
||||
@@ -127,12 +128,12 @@ CreateNewPrmModuleImageContextListEntry (
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
IsAddressInMmram (
|
||||
IN EFI_PHYSICAL_ADDRESS Address,
|
||||
IN EFI_MMRAM_DESCRIPTOR *MmramRanges,
|
||||
IN UINTN MmramRangeCount
|
||||
IN EFI_PHYSICAL_ADDRESS Address,
|
||||
IN EFI_MMRAM_DESCRIPTOR *MmramRanges,
|
||||
IN UINTN MmramRangeCount
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
UINTN Index;
|
||||
|
||||
for (Index = 0; Index < MmramRangeCount; Index++) {
|
||||
if ((Address >= MmramRanges[Index].CpuStart) &&
|
||||
@@ -167,28 +168,28 @@ IsAddressInMmram (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
DiscoverPrmModules (
|
||||
OUT UINTN *ModuleCount OPTIONAL,
|
||||
OUT UINTN *HandlerCount OPTIONAL
|
||||
OUT UINTN *ModuleCount OPTIONAL,
|
||||
OUT UINTN *HandlerCount OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
PRM_MODULE_IMAGE_CONTEXT TempPrmModuleImageContext;
|
||||
PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY *PrmModuleImageContextListEntry;
|
||||
EFI_LOADED_IMAGE_PROTOCOL *LoadedImageProtocol;
|
||||
EFI_HANDLE *HandleBuffer;
|
||||
UINTN HandleCount;
|
||||
UINTN Index;
|
||||
UINTN PrmHandlerCount;
|
||||
UINTN PrmModuleCount;
|
||||
EFI_MM_ACCESS_PROTOCOL *MmAccess;
|
||||
UINTN Size;
|
||||
EFI_MMRAM_DESCRIPTOR *MmramRanges;
|
||||
UINTN MmramRangeCount;
|
||||
EFI_STATUS Status;
|
||||
PRM_MODULE_IMAGE_CONTEXT TempPrmModuleImageContext;
|
||||
PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY *PrmModuleImageContextListEntry;
|
||||
EFI_LOADED_IMAGE_PROTOCOL *LoadedImageProtocol;
|
||||
EFI_HANDLE *HandleBuffer;
|
||||
UINTN HandleCount;
|
||||
UINTN Index;
|
||||
UINTN PrmHandlerCount;
|
||||
UINTN PrmModuleCount;
|
||||
EFI_MM_ACCESS_PROTOCOL *MmAccess;
|
||||
UINTN Size;
|
||||
EFI_MMRAM_DESCRIPTOR *MmramRanges;
|
||||
UINTN MmramRangeCount;
|
||||
|
||||
DEBUG ((DEBUG_INFO, "%a %a - Entry.\n", _DBGMSGID_, __FUNCTION__));
|
||||
|
||||
PrmHandlerCount = 0;
|
||||
PrmModuleCount = 0;
|
||||
PrmModuleCount = 0;
|
||||
|
||||
if (!IsListEmpty (&mPrmModuleList)) {
|
||||
return EFI_ALREADY_STARTED;
|
||||
@@ -206,18 +207,18 @@ DiscoverPrmModules (
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
MmramRanges = NULL;
|
||||
MmramRanges = NULL;
|
||||
MmramRangeCount = 0;
|
||||
Status = gBS->LocateProtocol (
|
||||
&gEfiMmAccessProtocolGuid,
|
||||
NULL,
|
||||
(VOID **)&MmAccess
|
||||
);
|
||||
Status = gBS->LocateProtocol (
|
||||
&gEfiMmAccessProtocolGuid,
|
||||
NULL,
|
||||
(VOID **)&MmAccess
|
||||
);
|
||||
if (Status == EFI_SUCCESS) {
|
||||
//
|
||||
// Get MMRAM range information
|
||||
//
|
||||
Size = 0;
|
||||
Size = 0;
|
||||
Status = MmAccess->GetCapabilities (MmAccess, &Size, NULL);
|
||||
if ((Status == EFI_BUFFER_TOO_SMALL) && (Size != 0)) {
|
||||
MmramRanges = (EFI_MMRAM_DESCRIPTOR *)AllocatePool (Size);
|
||||
@@ -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;
|
||||
@@ -276,13 +278,14 @@ DiscoverPrmModules (
|
||||
|
||||
// Attempt to find the PRM Module Export Descriptor in the export table
|
||||
Status = GetPrmModuleExportDescriptorTable (
|
||||
TempPrmModuleImageContext.ExportDirectory,
|
||||
&TempPrmModuleImageContext.PeCoffImageContext,
|
||||
&TempPrmModuleImageContext.ExportDescriptor
|
||||
);
|
||||
if (EFI_ERROR (Status) || TempPrmModuleImageContext.ExportDescriptor == NULL) {
|
||||
TempPrmModuleImageContext.ExportDirectory,
|
||||
&TempPrmModuleImageContext.PeCoffImageContext,
|
||||
&TempPrmModuleImageContext.ExportDescriptor
|
||||
);
|
||||
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;
|
||||
}
|
||||
@@ -331,13 +336,13 @@ DiscoverPrmModules (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PrmModuleDiscoveryLibDestructor (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Link;
|
||||
LIST_ENTRY *NextLink;
|
||||
PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY *ListEntry;
|
||||
LIST_ENTRY *Link;
|
||||
LIST_ENTRY *NextLink;
|
||||
PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY *ListEntry;
|
||||
|
||||
if (IsListEmpty (&mPrmModuleList)) {
|
||||
return EFI_SUCCESS;
|
||||
@@ -346,7 +351,7 @@ PrmModuleDiscoveryLibDestructor (
|
||||
Link = GetFirstNode (&mPrmModuleList);
|
||||
while (!IsNull (&mPrmModuleList, Link)) {
|
||||
ListEntry = CR (Link, PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY, Link, PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY_SIGNATURE);
|
||||
NextLink = GetNextNode (&mPrmModuleList, Link);
|
||||
NextLink = GetNextNode (&mPrmModuleList, Link);
|
||||
|
||||
RemoveEntryList (Link);
|
||||
FreePool (ListEntry);
|
||||
@@ -371,8 +376,8 @@ PrmModuleDiscoveryLibDestructor (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PrmModuleDiscoveryLibConstructor (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
InitializeListHead (&mPrmModuleList);
|
||||
|
@@ -12,14 +12,14 @@
|
||||
|
||||
#include <PrmModuleImageContext.h>
|
||||
|
||||
#define PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY_SIGNATURE SIGNATURE_32('P','R','M','E')
|
||||
#define PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY_SIGNATURE SIGNATURE_32('P','R','M','E')
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
LIST_ENTRY Link;
|
||||
PRM_MODULE_IMAGE_CONTEXT Context;
|
||||
UINTN Signature;
|
||||
LIST_ENTRY Link;
|
||||
PRM_MODULE_IMAGE_CONTEXT Context;
|
||||
} PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY;
|
||||
|
||||
#pragma pack(pop)
|
||||
|
@@ -24,12 +24,12 @@
|
||||
|
||||
#include "../PrmModuleDiscovery.h"
|
||||
|
||||
#define UNIT_TEST_NAME "PRM Module Discovery Library Unit Test"
|
||||
#define UNIT_TEST_VERSION "0.1"
|
||||
#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.
|
||||
@@ -44,10 +44,10 @@
|
||||
UNIT_TEST_STATUS
|
||||
EFIAPI
|
||||
PrmModuleImageContextListEntryShouldDeallocate (
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
)
|
||||
{
|
||||
PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY *ListEntry;
|
||||
PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY *ListEntry;
|
||||
|
||||
ListEntry = CreateNewPrmModuleImageContextListEntry ();
|
||||
|
||||
@@ -72,10 +72,10 @@ PrmModuleImageContextListEntryShouldDeallocate (
|
||||
UNIT_TEST_STATUS
|
||||
EFIAPI
|
||||
PrmModuleImageContextListEntrySignatureShouldBeValid (
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
)
|
||||
{
|
||||
PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY *ListEntry;
|
||||
PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY *ListEntry;
|
||||
|
||||
ListEntry = CreateNewPrmModuleImageContextListEntry ();
|
||||
|
||||
@@ -101,11 +101,11 @@ PrmModuleImageContextListEntrySignatureShouldBeValid (
|
||||
UNIT_TEST_STATUS
|
||||
EFIAPI
|
||||
PrmModuleImageContextListEntryImageContextShouldBeZeroed (
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
IN UNIT_TEST_CONTEXT Context
|
||||
)
|
||||
{
|
||||
PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY *ListEntry;
|
||||
PRM_MODULE_IMAGE_CONTEXT ImageContext;
|
||||
PRM_MODULE_IMAGE_CONTEXT_LIST_ENTRY *ListEntry;
|
||||
PRM_MODULE_IMAGE_CONTEXT ImageContext;
|
||||
|
||||
ListEntry = CreateNewPrmModuleImageContextListEntry ();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -37,26 +37,27 @@
|
||||
**/
|
||||
EFI_STATUS
|
||||
GetPrmModuleExportDescriptorTable (
|
||||
IN EFI_IMAGE_EXPORT_DIRECTORY *ImageExportDirectory,
|
||||
IN PE_COFF_LOADER_IMAGE_CONTEXT *PeCoffLoaderImageContext,
|
||||
OUT PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT **ExportDescriptor
|
||||
IN EFI_IMAGE_EXPORT_DIRECTORY *ImageExportDirectory,
|
||||
IN PE_COFF_LOADER_IMAGE_CONTEXT *PeCoffLoaderImageContext,
|
||||
OUT PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT **ExportDescriptor
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
EFI_PHYSICAL_ADDRESS CurrentImageAddress;
|
||||
UINT16 PrmModuleExportDescriptorOrdinal;
|
||||
CONST CHAR8 *CurrentExportName;
|
||||
UINT16 *OrdinalTable;
|
||||
UINT32 *ExportNamePointerTable;
|
||||
UINT32 *ExportAddressTable;
|
||||
PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT *TempExportDescriptor;
|
||||
UINTN Index;
|
||||
EFI_PHYSICAL_ADDRESS CurrentImageAddress;
|
||||
UINT16 PrmModuleExportDescriptorOrdinal;
|
||||
CONST CHAR8 *CurrentExportName;
|
||||
UINT16 *OrdinalTable;
|
||||
UINT32 *ExportNamePointerTable;
|
||||
UINT32 *ExportAddressTable;
|
||||
PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT *TempExportDescriptor;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -73,13 +74,13 @@ 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);
|
||||
CurrentImageAddress = PeCoffLoaderImageContext->ImageAddress;
|
||||
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",
|
||||
@@ -89,11 +90,12 @@ GetPrmModuleExportDescriptorTable (
|
||||
CurrentExportName
|
||||
));
|
||||
if (
|
||||
AsciiStrnCmp (
|
||||
PRM_STRING(PRM_MODULE_EXPORT_DESCRIPTOR_NAME),
|
||||
CurrentExportName,
|
||||
AsciiStrLen (PRM_STRING(PRM_MODULE_EXPORT_DESCRIPTOR_NAME))
|
||||
) == 0) {
|
||||
AsciiStrnCmp (
|
||||
PRM_STRING (PRM_MODULE_EXPORT_DESCRIPTOR_NAME),
|
||||
CurrentExportName,
|
||||
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;
|
||||
}
|
||||
@@ -145,18 +149,18 @@ GetPrmModuleExportDescriptorTable (
|
||||
**/
|
||||
EFI_STATUS
|
||||
GetExportDirectoryInPeCoffImage (
|
||||
IN VOID *Image,
|
||||
IN PE_COFF_LOADER_IMAGE_CONTEXT *PeCoffLoaderImageContext,
|
||||
OUT EFI_IMAGE_EXPORT_DIRECTORY **ImageExportDirectory
|
||||
IN VOID *Image,
|
||||
IN PE_COFF_LOADER_IMAGE_CONTEXT *PeCoffLoaderImageContext,
|
||||
OUT EFI_IMAGE_EXPORT_DIRECTORY **ImageExportDirectory
|
||||
)
|
||||
{
|
||||
UINT16 Magic;
|
||||
UINT32 NumberOfRvaAndSizes;
|
||||
EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION OptionalHeaderPtrUnion;
|
||||
EFI_IMAGE_DATA_DIRECTORY *DirectoryEntry;
|
||||
EFI_IMAGE_EXPORT_DIRECTORY *ExportDirectory;
|
||||
UINT16 Magic;
|
||||
UINT32 NumberOfRvaAndSizes;
|
||||
EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION OptionalHeaderPtrUnion;
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -169,36 +173,36 @@ GetExportDirectoryInPeCoffImage (
|
||||
// image with PE32 magic.
|
||||
//
|
||||
switch (PeCoffLoaderImageContext->Machine) {
|
||||
case EFI_IMAGE_MACHINE_IA32:
|
||||
//
|
||||
// Assume PE32 image with IA32 Machine field.
|
||||
//
|
||||
Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
|
||||
break;
|
||||
case EFI_IMAGE_MACHINE_X64:
|
||||
case EFI_IMAGE_MACHINE_AARCH64:
|
||||
//
|
||||
// Assume PE32+ image with X64 Machine field
|
||||
//
|
||||
Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
|
||||
break;
|
||||
default:
|
||||
//
|
||||
// For unknown Machine field, use Magic in optional header
|
||||
//
|
||||
DEBUG ((
|
||||
DEBUG_WARN,
|
||||
"%a %a: The machine type for this image is not valid for a PRM module.\n",
|
||||
_DBGMSGID_,
|
||||
__FUNCTION__
|
||||
));
|
||||
return EFI_UNSUPPORTED;
|
||||
case EFI_IMAGE_MACHINE_IA32:
|
||||
//
|
||||
// Assume PE32 image with IA32 Machine field.
|
||||
//
|
||||
Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
|
||||
break;
|
||||
case EFI_IMAGE_MACHINE_X64:
|
||||
case EFI_IMAGE_MACHINE_AARCH64:
|
||||
//
|
||||
// Assume PE32+ image with X64 Machine field
|
||||
//
|
||||
Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
|
||||
break;
|
||||
default:
|
||||
//
|
||||
// For unknown Machine field, use Magic in optional header
|
||||
//
|
||||
DEBUG ((
|
||||
DEBUG_WARN,
|
||||
"%a %a: The machine type for this image is not valid for a PRM module.\n",
|
||||
_DBGMSGID_,
|
||||
__FUNCTION__
|
||||
));
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
OptionalHeaderPtrUnion.Pe32 = (EFI_IMAGE_NT_HEADERS32 *) (
|
||||
(UINTN) Image +
|
||||
PeCoffLoaderImageContext->PeCoffHeaderOffset
|
||||
);
|
||||
OptionalHeaderPtrUnion.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)(
|
||||
(UINTN)Image +
|
||||
PeCoffLoaderImageContext->PeCoffHeaderOffset
|
||||
);
|
||||
|
||||
//
|
||||
// Check the PE/COFF Header Signature. Determine if the image is valid and/or a TE image.
|
||||
@@ -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;
|
||||
@@ -273,18 +278,18 @@ GetExportDirectoryInPeCoffImage (
|
||||
**/
|
||||
EFI_STATUS
|
||||
GetImageVersionInPeCoffImage (
|
||||
IN VOID *Image,
|
||||
IN PE_COFF_LOADER_IMAGE_CONTEXT *PeCoffLoaderImageContext,
|
||||
OUT UINT16 *ImageMajorVersion,
|
||||
OUT UINT16 *ImageMinorVersion
|
||||
IN VOID *Image,
|
||||
IN PE_COFF_LOADER_IMAGE_CONTEXT *PeCoffLoaderImageContext,
|
||||
OUT UINT16 *ImageMajorVersion,
|
||||
OUT UINT16 *ImageMinorVersion
|
||||
)
|
||||
{
|
||||
EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION OptionalHeaderPtrUnion;
|
||||
UINT16 Magic;
|
||||
EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION OptionalHeaderPtrUnion;
|
||||
UINT16 Magic;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -294,36 +299,36 @@ GetImageVersionInPeCoffImage (
|
||||
// image with PE32 magic.
|
||||
//
|
||||
switch (PeCoffLoaderImageContext->Machine) {
|
||||
case EFI_IMAGE_MACHINE_IA32:
|
||||
//
|
||||
// Assume PE32 image
|
||||
//
|
||||
Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
|
||||
break;
|
||||
case EFI_IMAGE_MACHINE_X64:
|
||||
case EFI_IMAGE_MACHINE_AARCH64:
|
||||
//
|
||||
// Assume PE32+ image
|
||||
//
|
||||
Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
|
||||
break;
|
||||
default:
|
||||
//
|
||||
// For unknown Machine field, use Magic in optional header
|
||||
//
|
||||
DEBUG ((
|
||||
DEBUG_WARN,
|
||||
"%a %a: The machine type for this image is not valid for a PRM module.\n",
|
||||
_DBGMSGID_,
|
||||
__FUNCTION__
|
||||
));
|
||||
return EFI_UNSUPPORTED;
|
||||
case EFI_IMAGE_MACHINE_IA32:
|
||||
//
|
||||
// Assume PE32 image
|
||||
//
|
||||
Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
|
||||
break;
|
||||
case EFI_IMAGE_MACHINE_X64:
|
||||
case EFI_IMAGE_MACHINE_AARCH64:
|
||||
//
|
||||
// Assume PE32+ image
|
||||
//
|
||||
Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
|
||||
break;
|
||||
default:
|
||||
//
|
||||
// For unknown Machine field, use Magic in optional header
|
||||
//
|
||||
DEBUG ((
|
||||
DEBUG_WARN,
|
||||
"%a %a: The machine type for this image is not valid for a PRM module.\n",
|
||||
_DBGMSGID_,
|
||||
__FUNCTION__
|
||||
));
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
OptionalHeaderPtrUnion.Pe32 = (EFI_IMAGE_NT_HEADERS32 *) (
|
||||
(UINTN) Image +
|
||||
PeCoffLoaderImageContext->PeCoffHeaderOffset
|
||||
);
|
||||
OptionalHeaderPtrUnion.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)(
|
||||
(UINTN)Image +
|
||||
PeCoffLoaderImageContext->PeCoffHeaderOffset
|
||||
);
|
||||
//
|
||||
// Check the PE/COFF Header Signature. Determine if the image is valid and/or a TE image.
|
||||
//
|
||||
@@ -368,30 +373,31 @@ GetImageVersionInPeCoffImage (
|
||||
**/
|
||||
EFI_STATUS
|
||||
GetExportEntryAddress (
|
||||
IN CONST CHAR8 *ExportName,
|
||||
IN EFI_PHYSICAL_ADDRESS ImageBaseAddress,
|
||||
IN EFI_IMAGE_EXPORT_DIRECTORY *ImageExportDirectory,
|
||||
OUT EFI_PHYSICAL_ADDRESS *ExportPhysicalAddress
|
||||
IN CONST CHAR8 *ExportName,
|
||||
IN EFI_PHYSICAL_ADDRESS ImageBaseAddress,
|
||||
IN EFI_IMAGE_EXPORT_DIRECTORY *ImageExportDirectory,
|
||||
OUT EFI_PHYSICAL_ADDRESS *ExportPhysicalAddress
|
||||
)
|
||||
{
|
||||
UINTN ExportNameIndex;
|
||||
UINT16 CurrentExportOrdinal;
|
||||
UINT32 *ExportAddressTable;
|
||||
UINT32 *ExportNamePointerTable;
|
||||
UINT16 *OrdinalTable;
|
||||
CONST CHAR8 *ExportNameTablePointerName;
|
||||
UINTN ExportNameIndex;
|
||||
UINT16 CurrentExportOrdinal;
|
||||
UINT32 *ExportAddressTable;
|
||||
UINT32 *ExportNamePointerTable;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user