From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web10.12281.1647966112613502311 for ; Tue, 22 Mar 2022 09:21:52 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@linux.microsoft.com header.s=default header.b=YoOQGNNt; spf=pass (domain: linux.microsoft.com, ip: 13.77.154.182, mailfrom: mikuback@linux.microsoft.com) Received: from localhost.localdomain (unknown [47.202.59.224]) by linux.microsoft.com (Postfix) with ESMTPSA id 444AE20B4783; Tue, 22 Mar 2022 09:21:51 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 444AE20B4783 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1647966112; bh=ZPIwE58mtjPFFXEeGc2vIm0IWGpgZ7wiSlJVFEXCF2A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YoOQGNNt/hzOv0pnPtrnf+H7T8tqw4Z0Rmcgpw6IqQc8vB9FR4gllSlgMfpk9oF2Q BP4e4PgwTy2os5OpkR+8XKnFuWZotmJ3x1Rlzbpq+bbzuP3GQiaLCNE+pgI5Xb8IDV WrX/TXd1u4fx8zNJVWb9eqBe01zbr2gblyFsgkmw= From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Andrew Fish , Kang Gao , Michael D Kinney , Michael Kubacki , Leif Lindholm , Benjamin You , Liu Yun , Ankit Sinha , Nate DeSimone Subject: [PATCH v1 20/41] PrmPkg/PrmSampleContextBufferModule: Remove OS debug print requirement Date: Tue, 22 Mar 2022 12:19:26 -0400 Message-Id: <20220322161947.9319-21-mikuback@linux.microsoft.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20220322161947.9319-1-mikuback@linux.microsoft.com> References: <20220322161947.9319-1-mikuback@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Kubacki Removes the expectation that the parameter buffer contain an OS debug print service at the beginning of the buffer. All supporting code related to printing is also removed. Cc: Andrew Fish Cc: Kang Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Leif Lindholm Cc: Benjamin You Cc: Liu Yun Cc: Ankit Sinha Cc: Nate DeSimone Signed-off-by: Michael Kubacki --- PrmPkg/Samples/PrmSampleContextBufferModule/Library/DxeContextBufferModu= leConfigLib/DxeContextBufferModuleConfigLib.c | 4 +- PrmPkg/Samples/PrmSampleContextBufferModule/PrmSampleContextBufferModule= .c | 128 +++----------------- 2 files changed, 17 insertions(+), 115 deletions(-) diff --git a/PrmPkg/Samples/PrmSampleContextBufferModule/Library/DxeConte= xtBufferModuleConfigLib/DxeContextBufferModuleConfigLib.c b/PrmPkg/Sample= s/PrmSampleContextBufferModule/Library/DxeContextBufferModuleConfigLib/Dx= eContextBufferModuleConfigLib.c index c222c961f23b..4c0c3348459c 100644 --- a/PrmPkg/Samples/PrmSampleContextBufferModule/Library/DxeContextBuffe= rModuleConfigLib/DxeContextBufferModuleConfigLib.c +++ b/PrmPkg/Samples/PrmSampleContextBufferModule/Library/DxeContextBuffe= rModuleConfigLib/DxeContextBufferModuleConfigLib.c @@ -24,7 +24,7 @@ STATIC EFI_HANDLE mPrmConfigProtocolHandle; STATIC CONST EFI_GUID mPrmModuleGuid =3D {0x5a6cf42b, 0x8bb4, 0x472c, {0= xa2, 0x33, 0x5c, 0x4d, 0xc4, 0x03, 0x3d, 0xc7}}; =20 // {e1466081-7562-430f-896b-b0e523dc335a} -STATIC CONST EFI_GUID mDumpStaticDataBufferPrmHandlerGuid =3D {0xe146608= 1, 0x7562, 0x430f, {0x89, 0x6b, 0xb0, 0xe5, 0x23, 0xdc, 0x33, 0x5a}}; +STATIC CONST EFI_GUID mCheckStaticDataBufferPrmHandlerGuid =3D {0xe14660= 81, 0x7562, 0x430f, {0x89, 0x6b, 0xb0, 0xe5, 0x23, 0xdc, 0x33, 0x5a}}; =20 /** Populates the static data buffer for this PRM module. @@ -166,7 +166,7 @@ ContextBufferModuleConfigLibConstructor ( Status =3D EFI_OUT_OF_RESOURCES; goto Done; } - CopyGuid (&PrmContextBuffer->HandlerGuid, &mDumpStaticDataBufferPrmHan= dlerGuid); + CopyGuid (&PrmContextBuffer->HandlerGuid, &mCheckStaticDataBufferPrmHa= ndlerGuid); PrmContextBuffer->Signature =3D PRM_CONTEXT_BUFFER_SIGNATURE; PrmContextBuffer->Version =3D PRM_CONTEXT_BUFFER_INTERFACE_VERSION; PrmContextBuffer->StaticDataBuffer =3D StaticDataBuffer; diff --git a/PrmPkg/Samples/PrmSampleContextBufferModule/PrmSampleContext= BufferModule.c b/PrmPkg/Samples/PrmSampleContextBufferModule/PrmSampleCon= textBufferModule.c index 074552d0c07e..5c4e5c7a10eb 100644 --- a/PrmPkg/Samples/PrmSampleContextBufferModule/PrmSampleContextBufferM= odule.c +++ b/PrmPkg/Samples/PrmSampleContextBufferModule/PrmSampleContextBufferM= odule.c @@ -21,146 +21,39 @@ // =20 // {e1466081-7562-430f-896b-b0e523dc335a} -#define DUMP_STATIC_DATA_BUFFER_PRM_HANDLER_GUID {0xe1466081, 0x7562, 0x= 430f, {0x89, 0x6b, 0xb0, 0xe5, 0x23, 0xdc, 0x33, 0x5a}} - -/** - Dumps the contents of a given buffer. - - @param[in] OsServiceDebugPrint A pointer to the debug print OS serv= ice. - @param[in] Buffer A pointer to the buffer that should = be dumped. - @param[in] BufferSize The size of Buffer in bytes. - -**/ -STATIC -VOID -DumpBuffer ( - IN PRM_OS_SERVICE_DEBUG_PRINT OsServiceDebugPrint, - IN CONST VOID *Buffer, - IN UINTN BufferSize - ) -{ - UINTN Count; - CONST UINT8 *Char =3D Buffer; - CHAR8 DebugMessage[16]; - - if (OsServiceDebugPrint =3D=3D NULL || Buffer =3D=3D NULL) { - return; - } - - OsServiceDebugPrint (" "); - for (Count =3D 0; Count < BufferSize; Count++) - { - if (Count && !(Count % 16)) { - OsServiceDebugPrint ("\n "); - } - AsciiSPrint ( - &DebugMessage[0], - ARRAY_SIZE (DebugMessage), - "%02X ", - Char[Count] - ); - OsServiceDebugPrint (&DebugMessage[0]); - } - OsServiceDebugPrint ("\n\n"); -} - -/** - Prints the contents of this PRM module's static data buffer. - - @param[in] OsServiceDebugPrint A pointer to the debug print OS serv= ice. - @param[in] StaticDataBuffer A pointer to the static buffer. - -**/ -VOID -EFIAPI -PrintStaticDataBuffer ( - IN PRM_OS_SERVICE_DEBUG_PRINT OsServiceDebugPrin= t, - IN CONST STATIC_DATA_SAMPLE_CONTEXT_BUFFER_MODULE *StaticDataBuffer - ) -{ - CHAR8 DebugMessage[256]; - - if (OsServiceDebugPrint =3D=3D NULL || StaticDataBuffer =3D=3D NULL) { - return; - } - - AsciiSPrint ( - &DebugMessage[0], - ARRAY_SIZE (DebugMessage), - " Policy1Enabled =3D 0x%x.\n", - StaticDataBuffer->Policy1Enabled - ); - OsServiceDebugPrint (&DebugMessage[0]); - - AsciiSPrint ( - &DebugMessage[0], - ARRAY_SIZE (DebugMessage), - " Policy2Enabled =3D 0x%x.\n", - StaticDataBuffer->Policy2Enabled - ); - OsServiceDebugPrint (&DebugMessage[0]); - - OsServiceDebugPrint (" Dumping SomeValueArray:\n"); - DumpBuffer ( - OsServiceDebugPrint, - (CONST VOID *) &StaticDataBuffer->SomeValueArray[0], - ARRAY_SIZE (StaticDataBuffer->SomeValueArray) - ); -} +#define CHECK_STATIC_DATA_BUFFER_PRM_HANDLER_GUID {0xe1466081, 0x7562, 0= x430f, {0x89, 0x6b, 0xb0, 0xe5, 0x23, 0xdc, 0x33, 0x5a}} =20 /** A sample Platform Runtime Mechanism (PRM) handler. =20 - This sample handler attempts to read the contents of the static data b= uffer that were configured - during the firmware boot environment and print those contents at OS ru= ntime. + This sample handler checks that a static data buffer can be accessed f= rom a given context buffer. =20 - @param[in] OsServices An array of pointers to OS provided se= rvices for PRM handlers - @param[in] Context Handler context info + @param[in] ParameterBuffer A pointer to the PRM handler parameter= buffer + @param[in] ContextBUffer A pointer to the PRM handler context b= uffer =20 @retval EFI_STATUS The PRM handler executed successfully. @retval Others An error occurred in the PRM handler. =20 **/ -PRM_HANDLER_EXPORT (DumpStaticDataBufferPrmHandler) +PRM_HANDLER_EXPORT (CheckStaticDataBufferPrmHandler) { - PRM_OS_SERVICE_DEBUG_PRINT OsServiceDebugPrint; - if (ContextBuffer =3D=3D NULL) { return EFI_INVALID_PARAMETER; } =20 - // In the POC, the OS debug print service is assumed to be at the begi= nning of ParameterBuffer - OsServiceDebugPrint =3D *((PRM_OS_SERVICE_DEBUG_PRINT *) ParameterBuff= er); - if (OsServiceDebugPrint =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - OsServiceDebugPrint ("Context Buffer DumpStaticDataBufferPrmHandler en= try.\n"); - if (ContextBuffer->StaticDataBuffer =3D=3D NULL) { - OsServiceDebugPrint ("The static buffer is not allocated!\n"); return EFI_INVALID_PARAMETER; } =20 - OsServiceDebugPrint (" Printing the contents of the static data buffe= r:\n"); - // // Verify PRM data buffer signature is valid // if ( ContextBuffer->Signature !=3D PRM_CONTEXT_BUFFER_SIGNATURE || ContextBuffer->StaticDataBuffer->Header.Signature !=3D PRM_DATA_BUFF= ER_HEADER_SIGNATURE) { - OsServiceDebugPrint (" A buffer signature is invalid!\n"); return EFI_NOT_FOUND; } =20 - PrintStaticDataBuffer ( - OsServiceDebugPrint, - (CONST STATIC_DATA_SAMPLE_CONTEXT_BUFFER_MODULE *) &(ContextBuffer->= StaticDataBuffer->Data[0]) - ); - - OsServiceDebugPrint ("Context Buffer DumpStaticDataBufferPrmHandler ex= it.\n"); - return EFI_SUCCESS; } =20 @@ -168,9 +61,18 @@ PRM_HANDLER_EXPORT (DumpStaticDataBufferPrmHandler) // Register the PRM export information for this PRM Module // PRM_MODULE_EXPORT ( - PRM_HANDLER_EXPORT_ENTRY (DUMP_STATIC_DATA_BUFFER_PRM_HANDLER_GUID, Du= mpStaticDataBufferPrmHandler) + PRM_HANDLER_EXPORT_ENTRY (CHECK_STATIC_DATA_BUFFER_PRM_HANDLER_GUID, C= heckStaticDataBufferPrmHandler) ); =20 +/** + Module entry point. + + @param[in] ImageHandle The image handle. + @param[in] SystemTable A pointer to the system table. + + @retval EFI_SUCCESS This function always returns success. + +**/ EFI_STATUS EFIAPI PrmSampleContextBufferModuleInit ( --=20 2.28.0.windows.1