From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.107.237.67]) by mx.groups.io with SMTP id smtpd.web10.72946.1680534323958508392 for ; Mon, 03 Apr 2023 08:05:24 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=Cva5ppK7; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.237.67, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bGLucupwK5JI4duQiWhDnRkbEarnsfDLMZFYF6YzM32LekfCUHNZwBNNEUAQGZunzgnpy6iAvNNuUOTUar4arDwxuYckgsyxTp0eGzeQIov1lukxt1Fz3aEZf2aC9+njcv+pXt6bnbamZcDwq6Leir6nxkBTYNp8q3nGrjVwsmH1A1XvR+w3UkyREK0/gmdGvnrcnMjvM5PwZqTPmOWIEp1O4V1SBoJKItBRbkeqnY/4OOTBamjX1KKxLrVv6I2PIX1xBOYHaSVXVG3U2EeBUCbHvnNyDC3eeVu6bOR2Fn4c0r46E2Loz4s6dtuYLhtX2MqJoP4U6G6Pa3cX23p4KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=f/Wjf6SIsgez718gP3loflURD8OZyKzCHNGgjg6B5us=; b=JJfq8Df+t0MS86HTBf6dfAk19dPUvnROyOlO2+A0Gwzz1t7D1ZI81agHKCJh8D2CJsvtxDHoA8HRuH2qNyEQAeBQESKuD/g/7BigsjukPT0qLyQsBkX4Oa8LwIi/7DnPtEnA78nnY8NdL/vl+QRt80Ff0LdgTPof4eMXHdGZNFKQ9FyMzTVakt1wRuMNEz7pw/GLoWRcHEh8GLC+mShah28mfW68iVGpjX09kgVQaTjEr0x1MJ0TZL4aE/HWViOsXr1G/fjXnXdpP0RAATS5NtBkNEvyKWhp3H8BWU6ZLx6fHWK3CZFqYgapFLv7r4aPJAHNywerVd8A0cG/NTmIDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=f/Wjf6SIsgez718gP3loflURD8OZyKzCHNGgjg6B5us=; b=Cva5ppK7F3zqrFISyL5j3n5DYRfsgBHoFPiv/7G0rNaJkUTB4b9xeKmgTitgZT3jMEPxdHX0zMKETDdVZNp1c76Q9tvoBi4b9AEd1nws4MCrlDhE4EgiAe7Uu1YBQCK8lJZ38j9yV+Z4ENs+xRZFec5jO5uysMaVtEsLUqS84lk= Received: from DM6PR13CA0044.namprd13.prod.outlook.com (2603:10b6:5:134::21) by IA1PR12MB6530.namprd12.prod.outlook.com (2603:10b6:208:3a5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.30; Mon, 3 Apr 2023 15:05:21 +0000 Received: from DM6NAM11FT033.eop-nam11.prod.protection.outlook.com (2603:10b6:5:134:cafe::a) by DM6PR13CA0044.outlook.office365.com (2603:10b6:5:134::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.26 via Frontend Transport; Mon, 3 Apr 2023 15:05:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT033.mail.protection.outlook.com (10.13.172.221) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6277.18 via Frontend Transport; Mon, 3 Apr 2023 15:05:20 +0000 Received: from TPE-L1-ABNCHANG.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 3 Apr 2023 10:05:18 -0500 From: "Chang, Abner" To: CC: Isaac Oram , Abdul Lateef Attar , Nickle Wang , Igor Kulchytskyy Subject: [edk2-platforms][PATCH 01/14] ManageabilityPkg: Add more helper functions Date: Mon, 3 Apr 2023 23:04:46 +0800 Message-ID: <20230403150459.925-2-abner.chang@amd.com> X-Mailer: git-send-email 2.37.1.windows.1 In-Reply-To: <20230403150459.925-1-abner.chang@amd.com> References: <20230403150459.925-1-abner.chang@amd.com> MIME-Version: 1.0 Return-Path: Abner.Chang@amd.com X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT033:EE_|IA1PR12MB6530:EE_ X-MS-Office365-Filtering-Correlation-Id: 378b11bb-be29-47e7-66fc-08db3454d7ee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: alpfnAPcDYnNm/3WfdYgEx3K0YEv0XgsR4Az1izLsDTA/0tq4qJY72wMghdgE3ht0J/7ogRhSLP67sKxwMHzUdX8oTEpxvV7bzxo+It+3ev9ddz7IDx/t4SmohlpQJUNd1y/8VkiEct/8no+HprCwujRW9jE7wC5sBKCi9hK6pTziGnS663zp1u5qxs5UvRvyQ/85wTLsQs5oo7A6x+dD6CzplM7zFhvh6r/77j3/L4nrzu6z9j/W23zHfphU7eFk/ruCMlx9K0KKu31gOnU5ld8HkzBXkOlK4xetgkHAhyQ6+sp5F7n38tn4ZEiWOq54/i94miCyvVGPqdY0lDoqDDvrtUAlLor/HBTX5OY9NzkJ3tYnrb61MWj2GakCo4o0OHMJHMxJcUwn6G3SJm/Uk8nTPUkcnKjFPKrb9RxBZM05buwcvL39G25monGdowsYaFo1UM/YN8xQl8W2siS4yml+O3HV1DKsT4Q9FCIjiTS37ev6VHQKB4qYmvDz2qHVFg/264JjA62xulF6Gn+AP0dxuiDMkY8fAmFmYGyFjuy52SQ+dh5tRqf/tlh4oKrzU+TcCpQBSozC4L45lgGKlWvGsxPAX6D9bWsz9CjS78C+y9F65rRdYO0SD/YKwSkPW/rhQ9EofuLrRaO+9Qo+Hxb81vMfyF90TxPz3YwrekFMBtjAHNH88j85QNxE3U3AGeJiX936eAhw8jQs3QDICYjvoJk18fDOjcEoq6JSZA= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(136003)(346002)(39860400002)(376002)(451199021)(40470700004)(36840700001)(46966006)(40480700001)(40460700003)(6916009)(8676002)(4326008)(36860700001)(70206006)(70586007)(478600001)(316002)(54906003)(8936002)(30864003)(356005)(41300700001)(81166007)(82740400003)(5660300002)(186003)(47076005)(16526019)(426003)(83380400001)(2616005)(336012)(26005)(6666004)(1076003)(86362001)(36756003)(2906002)(2876002)(82310400005)(7696005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2023 15:05:20.6898 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 378b11bb-be29-47e7-66fc-08db3454d7ee X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT033.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6530 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain From: Abner Chang 1. Add a helper function to output payload binary to debug output device. 2. Add a helper function to split payload into packages according to maximum transfer unit of transport interface. 3. Add a helper function to generate CRC8. Signed-off-by: Abner Chang Cc: Isaac Oram Cc: Abdul Lateef Attar Cc: Nickle Wang Cc: Igor Kulchytskyy --- .../BaseManageabilityTransportHelper.inf | 1 + .../Library/ManageabilityTransportHelperLib.h | 98 ++++++++ .../BaseManageabilityTransportHelper.c | 218 +++++++++++++++++- 3 files changed, 310 insertions(+), 7 deletions(-) diff --git a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHe= lperLib/BaseManageabilityTransportHelper.inf b/Features/ManageabilityPkg/Li= brary/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.= inf index 95c3362ddb..c31a89aa49 100644 --- a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib= /BaseManageabilityTransportHelper.inf +++ b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib= /BaseManageabilityTransportHelper.inf @@ -25,6 +25,7 @@ [LibraryClasses] BaseMemoryLib DebugLib + MemoryAllocationLib =20 [Packages] ManageabilityPkg/ManageabilityPkg.dec diff --git a/Features/ManageabilityPkg/Include/Library/ManageabilityTranspo= rtHelperLib.h b/Features/ManageabilityPkg/Include/Library/ManageabilityTran= sportHelperLib.h index 718ac34a1f..0dbf5ccb3c 100644 --- a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportHelpe= rLib.h +++ b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportHelpe= rLib.h @@ -11,8 +11,24 @@ =20 #include =20 +#define DEBUG_MANAGEABILITY_INFO DEBUG_INFO + typedef struct _MANAGEABILITY_PROTOCOL_NAME MANAGEABILITY_PROTOCOL_NAME; =20 +typedef struct { + UINT8 *PayloadPointer; + UINT32 PayloadSize; +} MANAGEABILITY_TRANSMISSION_PACKAGE_ATTR; + +// +// The information of multi portions of payload it is +// splitted according to transport interface Maximum +// Transfer Unit. +typedef struct { + UINT16 NumberOfPackages; ///< Number= of packages in MultiPackages. + MANAGEABILITY_TRANSMISSION_PACKAGE_ATTR MultiPackages[]; +} MANAGEABILITY_TRANSMISSION_MULTI_PACKAGES; + /** Helper function returns the human readable name of Manageability specifi= cation. =20 @@ -90,4 +106,86 @@ HelperInitManageabilityTransport ( OUT MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS *TransportAdditionalSt= atus OPTIONAL ); =20 +/** + This function splits payload into multiple packages according to + the given transport interface Maximum Transfer Unit (MTU). + + @param[in] PreambleSize The additional data size precedes + each package. + @param[in] PostambleSize The additional data size succeeds + each package. + @param[in] Payload Pointer to payload. + @param[in] PayloadSize Payload size in byte. + @param[in] MaximumTransferUnit MTU of transport interface. + @param[out] MultiplePackages Pointer to receive + MANAGEABILITY_TRANSMISSION_MULTI_PACKAG= ES + structure. Caller has to free the memor= y + allocated for MANAGEABILITY_TRANSMISSIO= N_MULTI_PACKAGES. + + @retval EFI_SUCCESS MANAGEABILITY_TRANSMISSION_MULTI_PACKAGES= structure + is returned successfully. + @retval EFI_OUT_OF_RESOURCE Not enough resource to create + MANAGEABILITY_TRANSMISSION_MULTI_PACKAGES= structure. +**/ +EFI_STATUS +HelperManageabilitySplitPayload ( + IN UINT16 PreambleSize, + IN UINT16 PostambleSize, + IN UINT8 *Payload, + IN UINT32 PayloadSize, + IN UINT32 MaximumTransferUnit, + OUT MANAGEABILITY_TRANSMISSION_MULTI_PACKAGES **MultiplePackages + ); + +/** + This function generates CRC8 with given polynomial. + + @param[in] Polynomial Polynomial in 8-bit. + @param[in] CrcInitialValue CRC initial value. + @param[in] BufferStart Pointer to buffer starts the CRC calculatio= n. + @param[in] BufferSize Size of buffer. + + @retval UINT8 CRC value. +**/ +UINT8 +HelperManageabilityGenerateCrc8 ( + IN UINT8 Polynomial, + IN UINT8 CrcInitialValue, + IN UINT8 *BufferStart, + IN UINT32 BufferSize + ); + +/** + Print out manageability transmit payload to the debug output device. + + @param[in] Payload Payload to print. + @param[in] PayloadSize Payload size. + +**/ +VOID +EFIAPI +HelperManageabilityPayLoadDebugPrint ( + IN VOID *Payload, + IN UINT32 PayloadSize + ); + +/** + Prints a debug message and manageability payload to the debug output dev= ice. + + @param[in] Payload Payload to print. + @param[in] PayloadSize Payload size. + @param[in] Format The format string for the debug message to prin= t. + @param[in] ... The variable argument list whose contents are a= ccessed + based on the format string specified by Format. + +**/ +VOID +EFIAPI +HelperManageabilityDebugPrint ( + IN VOID *Payload, + IN UINT32 PayloadSize, + IN CONST CHAR8 *Format, + ... + ); + #endif diff --git a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHe= lperLib/BaseManageabilityTransportHelper.c b/Features/ManageabilityPkg/Libr= ary/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.c index 81da209764..9d20ed49ff 100644 --- a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib= /BaseManageabilityTransportHelper.c +++ b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib= /BaseManageabilityTransportHelper.c @@ -8,11 +8,12 @@ #include #include #include +#include #include =20 // // BaseManageabilityTransportHelper is used by PEI, DXE and SMM. -// Make sure the global variables added here should be unchangable. +// Make sure the global variables added here should be unchangeable. // MANAGEABILITY_SPECIFICATION_NAME ManageabilitySpecNameTable[] =3D { { &gManageabilityTransportKcsGuid, L"KCS" }, @@ -47,8 +48,8 @@ HelperManageabilitySpecName ( return NULL; } =20 - if (SpecificationGuid =3D=3D NULL || IsZeroGuid (SpecificationGuid)) { - DEBUG((DEBUG_ERROR, "%a: Improper input GUIDs, could be NULL or zero G= UID.\n", __FUNCTION__)); + if ((SpecificationGuid =3D=3D NULL) || IsZeroGuid (SpecificationGuid)) { + DEBUG ((DEBUG_ERROR, "%a: Improper input GUIDs, could be NULL or zero = GUID.\n", __FUNCTION__)); return NULL; } =20 @@ -99,12 +100,13 @@ HelperManageabilityCheckSupportedSpec ( return EFI_INVALID_PARAMETER; } =20 - if (TransportGuid =3D=3D NULL || + if ((TransportGuid =3D=3D NULL) || IsZeroGuid (TransportGuid) || - ManageabilityProtocolToCheck =3D=3D NULL || + (ManageabilityProtocolToCheck =3D=3D NULL) || IsZeroGuid (ManageabilityProtocolToCheck) - ) { - DEBUG((DEBUG_ERROR, "%a: Improper input GUIDs, could be NULL or zero= GUID.\n", __FUNCTION__)); + ) + { + DEBUG ((DEBUG_ERROR, "%a: Improper input GUIDs, could be NULL or zero = GUID.\n", __FUNCTION__)); return EFI_INVALID_PARAMETER; } =20 @@ -259,3 +261,205 @@ HelperInitManageabilityTransport ( =20 return Status; } + +/** + This function generates CRC8 with given polynomial. + + @param[in] Polynomial Polynomial in 8-bit. + @param[in] CrcInitialValue CRC initial value. + @param[in] BufferStart Pointer to buffer starts the CRC calculatio= n. + @param[in] BufferSize Size of buffer. + + @retval UINT8 CRC value. +**/ +UINT8 +HelperManageabilityGenerateCrc8 ( + IN UINT8 Polynomial, + IN UINT8 CrcInitialValue, + IN UINT8 *BufferStart, + IN UINT32 BufferSize + ) +{ + UINT8 BitIndex; + UINT32 BufferIndex; + + BufferIndex =3D 0; + while (BufferIndex < BufferSize) { + CrcInitialValue =3D CrcInitialValue ^ *(BufferStart + BufferIndex); + BufferIndex++; + + for (BitIndex =3D 0; BitIndex < 8; BitIndex++) { + if ((CrcInitialValue & 0x80) !=3D 0) { + CrcInitialValue =3D (CrcInitialValue << 1) ^ Polynomial; + } else { + CrcInitialValue <<=3D 1; + } + } + } + + return CrcInitialValue; +} + +/** + This function splits payload into multiple packages according to + the given transport interface Maximum Transfer Unit (MTU). + + + @param[in] PreambleSize The additional data size precedes + each package. + @param[in] PostambleSize The additional data size succeeds + each package. + @param[in] Payload Pointer to payload. + @param[in] PayloadSize Payload size in byte. + @param[in] MaximumTransferUnit MTU of transport interface. + @param[out] MultiplePackages Pointer to receive + MANAGEABILITY_TRANSMISSION_MULTI_PACKAG= ES + structure. Caller has to free the memor= y + allocated for MANAGEABILITY_TRANSMISSIO= N_MULTI_PACKAGES. + + @retval EFI_SUCCESS MANAGEABILITY_TRANSMISSION_MULTI_PACKAGES= structure + is returned successfully. + @retval EFI_OUT_OF_RESOURCE Not enough resource to create + MANAGEABILITY_TRANSMISSION_MULTI_PACKAGES= structure. +**/ +EFI_STATUS +HelperManageabilitySplitPayload ( + IN UINT16 PreambleSize, + IN UINT16 PostambleSize, + IN UINT8 *Payload, + IN UINT32 PayloadSize, + IN UINT32 MaximumTransferUnit, + OUT MANAGEABILITY_TRANSMISSION_MULTI_PACKAGES **MultiplePackages + ) +{ + UINT16 NumberOfPackages; + UINT16 IndexOfPackage; + UINT32 PackagePayloadSize; + UINT32 TotalPayloadRemaining; + MANAGEABILITY_TRANSMISSION_MULTI_PACKAGES *ThisMultiplePackages; + MANAGEABILITY_TRANSMISSION_PACKAGE_ATTR *ThisPackage; + + if ((INT16)(MaximumTransferUnit - PreambleSize - PostambleSize) < 0) { + DEBUG (( + DEBUG_ERROR, + "%a: (Preamble 0x%x + PostambleSize 0x%x) is greater than MaximumTra= nsferUnit 0x%x.\n", + __FUNCTION__, + PreambleSize, + PostambleSize, + MaximumTransferUnit + )); + return EFI_INVALID_PARAMETER; + } + + PackagePayloadSize =3D MaximumTransferUnit -PreambleSize - PostambleSi= ze; + NumberOfPackages =3D (UINT16)((PayloadSize + (PackagePayloadSize - 1= )) / PackagePayloadSize); + ThisMultiplePackages =3D (MANAGEABILITY_TRANSMISSION_MULTI_PACKAGES *)Al= locateZeroPool ( + si= zeof (MANAGEABILITY_TRANSMISSION_MULTI_PACKAGES) + + si= zeof (MANAGEABILITY_TRANSMISSION_PACKAGE_ATTR) * NumberOfPackages + ); + if (ThisMultiplePackages =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: Not enough memory for MANAGEABILITY_TRANSMIS= SION_MULTI_PACKAGES\n")); + return EFI_INVALID_PARAMETER; + } + + ThisMultiplePackages->NumberOfPackages =3D NumberOfPackages; + ThisPackage =3D (MANAGEABILITY_TRANSMISSION_P= ACKAGE_ATTR *)(ThisMultiplePackages + 1); + TotalPayloadRemaining =3D PayloadSize; + for (IndexOfPackage =3D 0; IndexOfPackage < NumberOfPackages; IndexOfPac= kage++) { + ThisPackage->PayloadPointer =3D Payload + (IndexOfPackage * PackagePay= loadSize); + ThisPackage->PayloadSize =3D MIN (TotalPayloadRemaining, PackagePay= loadSize); + TotalPayloadRemaining -=3D ThisPackage->PayloadSize; + ThisPackage++; + } + + if (TotalPayloadRemaining !=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: Error processing multiple packages (TotalPay= loadRemaining !=3D 0)\n", __FUNCTION__)); + return EFI_INVALID_PARAMETER; + } + + *MultiplePackages =3D ThisMultiplePackages; + return EFI_SUCCESS; +} + +/** + Print out manageability transmit payload to the debug output device. + + @param[in] Payload Payload to print. + @param[in] PayloadSize Payload size. + +**/ +VOID +EFIAPI +HelperManageabilityPayLoadDebugPrint ( + IN VOID *Payload, + IN UINT32 PayloadSize + ) +{ + UINT16 Page256; + UINT16 Row16; + UINT16 Column16; + UINT32 RemainingBytes; + UINT32 TotalBytePrinted; + + RemainingBytes =3D PayloadSize; + TotalBytePrinted =3D 0; + while (TRUE) { + if (TotalBytePrinted % 256 =3D=3D 0) { + Page256 =3D (UINT16)TotalBytePrinted / 256; + DEBUG ((DEBUG_MANAGEABILITY_INFO, "=3D=3D=3D=3D=3D=3D=3D=3D Manageab= ility Payload %04xH - %04xH =3D=3D=3D=3D=3D=3D=3D=3D=3D\n", Page256 * 256, = Page256 * 256 + MIN (RemainingBytes, 256) - 1)); + DEBUG ((DEBUG_MANAGEABILITY_INFO, " ")); + for (Column16 =3D 0; Column16 < 16; Column16++) { + DEBUG ((DEBUG_MANAGEABILITY_INFO, "%02x ", Column16)); + } + + DEBUG ((DEBUG_MANAGEABILITY_INFO, "\n ------------------------= -----------------------\n")); + } + + for (Row16 =3D 0; Row16 < 16; Row16++) { + DEBUG ((DEBUG_MANAGEABILITY_INFO, "%04x | ", Page256 * 256 + Row16 *= 16)); + for (Column16 =3D 0; Column16 < MIN (RemainingBytes, 16); Column16++= ) { + DEBUG ((DEBUG_MANAGEABILITY_INFO, "%02x ", *((UINT8 *)Payload + Pa= ge256 * 256 + Row16 * 16 + Column16))); + } + + RemainingBytes -=3D Column16; + TotalBytePrinted +=3D Column16; + if (RemainingBytes =3D=3D 0) { + DEBUG ((DEBUG_MANAGEABILITY_INFO, "\n\n")); + return; + } + DEBUG((DEBUG_MANAGEABILITY_INFO, "\n")); + } + + DEBUG ((DEBUG_MANAGEABILITY_INFO, "\n")); + } + + DEBUG ((DEBUG_MANAGEABILITY_INFO, "\n\n")); +} + +/** + Prints a debug message and manageability payload to the debug output dev= ice. + + @param[in] Payload Payload to print. + @param[in] PayloadSize Payload size. + @param[in] Format The format string for the debug message to prin= t. + @param[in] ... The variable argument list whose contents are a= ccessed + based on the format string specified by Format. + +**/ +VOID +EFIAPI +HelperManageabilityDebugPrint ( + IN VOID *Payload, + IN UINT32 PayloadSize, + IN CONST CHAR8 *Format, + ... + ) +{ + VA_LIST Marker; + + VA_START (Marker, Format); + DEBUG ((DEBUG_MANAGEABILITY_INFO, "Manageability Transmission: ")); + DebugVPrint ((UINTN)DEBUG_MANAGEABILITY_INFO, Format, Marker); + HelperManageabilityPayLoadDebugPrint (Payload, PayloadSize); + VA_END (Marker); +} --=20 2.37.1.windows.1