From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.107.223.89]) by mx.groups.io with SMTP id smtpd.web10.30872.1681882179003975038 for ; Tue, 18 Apr 2023 22:29:39 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=rVbLvlfF; 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.223.89, mailfrom: abdullateef.attar@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Yky6VRULsDjnOcW3SPjFG8sSXb/OdMEeEeIWyxaED/al3l/vzNFIE+J+GGq8+2d1Lg19SJhkbrrBxksEIStjJTvj8hQyDeFQWlkpAUgAAKJEfp8srLnD4CYzNw7brZ50v/pEDjxEUxCTHp/0/c1DktQfrTifmgSOKrAnW6E2JNnshqzEJd29ECIQKvrE+gTeGgIFR8XmeCuLU5zl4PO14vjpdM6GAf9UeG0bvtZz57JKlsccxLtbxmDHhMjZ4wklec0L9QmgbxH0Yx/p+Yd3OPtiDHYFrq03T8qoGWKMe05Z7q3loVwzeyIDDAf9TdZ9CDt024rTuc00mLZfc1E52w== 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=XMqHaiKC68CHjFFvopR6BaaJNj9sg9uzXfa//IOsnrU=; b=H56cKEiCyXYqDa6tY8hesagqlQzyvLxiy/29xwWRmneHa9gymvkGbctdoqi6geJtqeGvekiwdcMMULt34kU2ZEQfau1BNdltXu56n1xF44v4w1UZrBnaK5nojALR5qR3rea4LqHWowh9Nfx1xSqQp+pzSzSDwpS3TDwnY3L4iSiudXzSI3+tDfB7XFr5Jww9tOMIwligcxx0AJQf5jcmo+G+TXkhpi6GtemQoAITtMbOCBbcQFWBV1HA02bHmjTHSgNbijk5duMGMRMMJFgcQZ78OA7AL1iGisKTA+9Yf15Yaxkrdcer4xM4rySj9uUF3soMvv9aSv55H6S7lx3sMA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; 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=XMqHaiKC68CHjFFvopR6BaaJNj9sg9uzXfa//IOsnrU=; b=rVbLvlfFtp+oQo86zHs4evnpBFQAPeNZixe6dw2E1JdDT3cBRkVzzb6BBAFlrdHTXa+pLMVi9UEZgm/3WqODzfgcDSIc7r8Vmw8ITx0KUC4JCGQG8mWyS53NV2tJZDRwdfaPktJ2GltR0+ZdxB+OE+J7BxLMcgAdZCscc34xxbY= Received: from IA1PR12MB6458.namprd12.prod.outlook.com (2603:10b6:208:3aa::22) by MN2PR12MB4303.namprd12.prod.outlook.com (2603:10b6:208:198::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.22; Wed, 19 Apr 2023 05:29:36 +0000 Received: from IA1PR12MB6458.namprd12.prod.outlook.com ([fe80::13d6:2b92:5ed1:361a]) by IA1PR12MB6458.namprd12.prod.outlook.com ([fe80::13d6:2b92:5ed1:361a%6]) with mapi id 15.20.6156.028; Wed, 19 Apr 2023 05:29:36 +0000 From: "Attar, AbdulLateef (Abdul Lateef)" To: "Chang, Abner" , "devel@edk2.groups.io" CC: Isaac Oram , Nickle Wang , Igor Kulchytskyy Subject: Re: [edk2-platforms][PATCH V2 01/14] ManageabilityPkg: Add more helper functions Thread-Topic: [edk2-platforms][PATCH V2 01/14] ManageabilityPkg: Add more helper functions Thread-Index: AQHZccWlhC8l+w9yq0G+b9xWqfivEa8yFZqw Date: Wed, 19 Apr 2023 05:29:35 +0000 Message-ID: References: <20230418071543.1951-1-abner.chang@amd.com> <20230418071543.1951-2-abner.chang@amd.com> In-Reply-To: <20230418071543.1951-2-abner.chang@amd.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=bdae9a92-1e9b-405a-8dc4-f32dda33887c;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=0;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Method=Standard;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Name=General;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2023-04-19T05:05:34Z;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: IA1PR12MB6458:EE_|MN2PR12MB4303:EE_ x-ms-office365-filtering-correlation-id: 7eaa81e9-e020-47ff-49f7-08db40971035 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: WWxGma3rMFNK60kxJiCVB++CSTk8/Dz7MaCxd2TozARUpmHYTMk3SHuFHstHrySdN968DmvxiRXSypSVZCwQdK6KE9TjO1CUDujYdGJR3QLoJp+Pjx2R+AthbtJgf/k0op3vm826egYxvyNUeFh4gI+ZsI3cxSC5RLZHKgEcp9MGnb7HQYgT7zrsSsAppd5KfW/0o2P5YUUghPNmGiAHXLpQZUPajShHCX/Q/4HxkU/beR3iiu4jMQjvAtXE+UlIMgUBiLMMmfn23iaUnZGwGdcxAh5t2rivLlVe9bgQoDBoq518jiKNLXOExkp+6h8mMdAZFREt8ucReeXL02WFIHgRpBd++fiuZJdqfwZvklcnUX+c8REF4vFX3g7g6B0/2j4wL9VVJNJTig1ERaK0l+Zm2xUUWpNBsUWcdK3YMEEcRqMiia3+5ap28ArBvlBytUGEZe45ZvD9jCx2zd2CcsD0T+BH3vh56gUJ7aCDhAembazYwO2F/b+ZycQUTbn5Bd01ChZSqlqZ7qEQUsQO7iQTNvvbtKaf/ZBXms6ZrGsSfFxz9f+mvLo4vRNhONwzWcrOI3HL2VtY5nyqFjD3XXRqIzpCAoiEuphS4GoLki/nuPDuYuwt/9imCARyK8i/ x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:IA1PR12MB6458.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(346002)(396003)(136003)(39860400002)(366004)(451199021)(38070700005)(2906002)(30864003)(8936002)(38100700002)(8676002)(5660300002)(52536014)(33656002)(86362001)(55016003)(7696005)(71200400001)(6506007)(26005)(9686003)(110136005)(54906003)(478600001)(83380400001)(53546011)(186003)(66476007)(66446008)(64756008)(66556008)(4326008)(76116006)(66946007)(122000001)(316002)(41300700001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?DV/xd2cFwGfoF1rCwfP+M8HgkDTVKd92RhI8wd2ogG2nVcVgXfYScBadW/vS?= =?us-ascii?Q?0SIMUdrKkVZCHk1fdC5z/cSPigoyhplE8vSoOsPBlScHQZLheiqymr9/snUR?= =?us-ascii?Q?u5Meqr6lptC2TLI1RrIKwuWuaOPzR+b7ZVkccEOIGdyZRRbB+RcCt0rnzpTb?= =?us-ascii?Q?ukNO1eYJiEZd2aozXFS4fqY0dn5j4bmgUgxQKidmYNIrS/clZDIm7MzETUQB?= =?us-ascii?Q?KBzL+/0MNd9JBDvdLxDFNXlc6Yt7w/Se3NTlN9eGFIG1fNJEdMjUbNzDPqhR?= =?us-ascii?Q?/YAHnB2uQQBi/7D/jT23Lwrm6onWc6eaxZD8H5ZMyYc8QfU6K2fRT5iCpMJM?= =?us-ascii?Q?fFB/ROBQeCCDYHYWJjr9SH1rn1QgeonOQ2aqiR3vszcwHwsgM/2tPJ0hbu9b?= =?us-ascii?Q?aQ4lUdto7Tmo+3s23kRRGxTiir6noifz2AqOZuXWHbTL3LImL4suc7wzosvM?= =?us-ascii?Q?qqNB3KVCx665H/RJ8+vD26s8A4J/KV+2FnCFE/LtGdOnUgJuti4Q+Djt2LYD?= =?us-ascii?Q?OeEk1dgzXnMLwFNSMARIN6t+i8smC267zsQb/MmgMADVyv7MMnlfSP5/MLxX?= =?us-ascii?Q?Z1j23oUTunSJd5I/FGHaLfiaqt+qBkuFnwFkFE2r83fjR4vogxd8lh8r2Az8?= =?us-ascii?Q?/+NOHmqLZCM/P0KqtSIGAdbXkmQsWtfnwgas5nN0Wi0r/Ab1N0afls21xgb5?= =?us-ascii?Q?EKnwh09B1QrNRxi3igGRXpvoXuZnmfIdOsDUOn96dHUsmpLUWxFObFcWvone?= =?us-ascii?Q?RBd3oBn0yVLip2z1STnCFfi8sIThagnoq+NiJI4HrWIqwhY7dScJTrpVFh42?= =?us-ascii?Q?LnozJAKKKYMuTSCeQlr+6QRAqKr2KahAurCzzd4kcy1Rwd2eZ2VX2u1E87p/?= =?us-ascii?Q?AzI5GXPo66WFJZYJF3xOSejN8IpWxLRMxldwEGBbwAsgiEPV0M8YAWwbLlYz?= =?us-ascii?Q?8H3Cpx1ODHpxEA4Eyd7I0dr8Kb5bNulA8S14xrQYpCgJur1Yei1BVSSFjzAH?= =?us-ascii?Q?+gd3UAKVKD3FlAlREIByPvUvHgV/xa/v0PBbzDOV+QljqzwqcBNz2FajQiap?= =?us-ascii?Q?Yte9amtRf47D0oiHPSc+SxDj3EC/p97tI3/xGXSbsdiT87bVdqMcZ2+YMNRL?= =?us-ascii?Q?dDUcPsHGBjKn7wjh7BA8q9AB2bVDJZCxaBzZcoqW7ie9Yu3C4guUKELG9nnC?= =?us-ascii?Q?XLDRz/F8WKSVrvxKbovZOilWL8tsck4mz960N/8M9L4aYQvPyaRW9hfYyzPN?= =?us-ascii?Q?rxU3Td5XpTaGev7KDIG21AklqQuZi/og5WkOeL5kqvgcyIJpnMNzOM8z1msf?= =?us-ascii?Q?hOVXb1T3sgxgeyZQXQ0VcAxKsfNiQzg9sDIGbgvTpFIPGq35TcpkFi8/WpS5?= =?us-ascii?Q?wkMLkPxHPJwHyuplQXrS+MKjlPT3RevFCH79GIhOGiRVJoXBFcVBCHiejegp?= =?us-ascii?Q?WHup5U5D7j1EJfCwBg75UUwiUdBgZ2N845OrjO3aHGPeGki06T+X4Moyu/Y9?= =?us-ascii?Q?LATcKreLlbxrV7bJwtYtt6ASPnCH3YkXvkffzUgzRpxLo5y6o6hTTukkKAjf?= =?us-ascii?Q?HhI63+92kLZF1mr7Apg=3D?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: IA1PR12MB6458.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7eaa81e9-e020-47ff-49f7-08db40971035 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Apr 2023 05:29:35.9068 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4303 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only - General] Comments inline. -----Original Message----- From: Chang, Abner Sent: 18 April 2023 12:46 To: devel@edk2.groups.io Cc: Isaac Oram ; Attar, AbdulLateef (Abdul Lateef) = ; Nickle Wang ; Igor Kulchyt= skyy Subject: [edk2-platforms][PATCH V2 01/14] ManageabilityPkg: Add more helper= functions 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 | 225 +++++++++++++++++- 3 files changed, 314 insertions(+), 10 deletions(-) diff --git a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHe= lperLib/BaseManageabilityTransportHelper.inf b/Features/ManageabilityPkg/Li= brary/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.= inf index 5447954144..c9e5eaef60 100644 --- a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib= /BaseManageabilityTransportHelper.inf +++ b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelper +++ Lib/BaseManageabilityTransportHelper.inf @@ -25,6 +25,7 @@ [LibraryClasses] BaseMemoryLib DebugLib + MemoryAllocationLib [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/ManageabilityTransportHe +++ lperLib.h @@ -11,8 +11,24 @@ #include +#define DEBUG_MANAGEABILITY_INFO DEBUG_INFO + typedef struct _MANAGEABILITY_PROTOCOL_NAME MANAGEABILITY_PROTOCOL_NAME; +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. @@ -90,4 +106,86 @@ HelperInitManageabilityTransport ( OUT MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS *TransportAdditionalSt= atus OPTIONAL ); +/** + 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 EFIAPI missing, is it intentional? +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 EFIAPI is missing, its common header file. +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 c3f35b7beb..0e241ca3fd 100644 --- a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib= /BaseManageabilityTransportHelper.c +++ b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelper +++ Lib/BaseManageabilityTransportHelper.c @@ -8,11 +8,12 @@ #include #include #include +#include #include // // 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; } - 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; } @@ -99,12 +100,13 @@ HelperManageabilityCheckSupportedSpec ( return EFI_INVALID_PARAMETER; } - 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; } @@ -116,7 +118,7 @@ HelperManageabilityCheckSupportedSpec ( )) { DEBUG (( - DEBUG_VERBOSE, + DEBUG_MANAGEABILITY_INFO, "%a: Transport interface %s supports %s manageability specificatio= n.\n", __FUNCTION__, HelperManageabilitySpecName (TransportGuid), @@ -174,7 +176,7 @@ H= elperAcquireManageabilityTransport ( return EFI_UNSUPPORTED; } - DEBUG ((DEBUG_INFO, " Manageability protocol %s is going to acquire tra= nsport interface token...\n", ManageabilityProtocolName)); + DEBUG ((DEBUG_MANAGEABILITY_INFO, " Manageability protocol %s is + going to acquire transport interface token...\n", + ManageabilityProtocolName)); Status =3D AcquireTransportSession (ManageabilityProtocolSpec, Transport= Token); if (Status =3D=3D EFI_UNSUPPORTED) { @@ -199,7 +201,7 @@ HelperAcquireManageabilityTransport ( return EFI_UNSUPPORTED; } - DEBUG ((DEBUG_INFO, "%a: This is the transfer session for %s over %s\n",= __FUNCTION__, ManageabilityProtocolName, ManageabilityTransportName)); + DEBUG ((DEBUG_MANAGEABILITY_INFO, "%a: This is the transfer session + for %s over %s\n", __FUNCTION__, ManageabilityProtocolName, + ManageabilityTransportName)); return Status; } @@ -259,3 +261,206 @@ HelperInitManageabilityTransport ( 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 EFIAPI missing, is it intentional? +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. This function also returns EFI_INVALID_PARAMETER. +**/ +EFI_STATUS EFIAPI missing, Is it intentional ? +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; return EFI_OUT_OF_RESOURCE. + } + + 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__)); Does ThisMultiplePackages requires to free the space before returning? + 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); +} -- 2.37.1.windows.1