From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com [40.107.236.40]) by mx.groups.io with SMTP id smtpd.web10.11821.1682005525615401623 for ; Thu, 20 Apr 2023 08:45:25 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=cFDTPSBO; 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.236.40, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e1EJC+6Wg3nCHJu82QNMcfoYQpKFMoMG5Kn7OAVLh+HljDAipiRV7RcDlkxI8SltGharyN/cnZNs33x9DGG+PmMkNO00kpNUdj1R4h8uZw44Btqn4OD8b8zCU/Iy86Y4KTWUL7EKh92fNCYtvxSpQ/b7LDy5nvKaBrhCxFsrSWI09qDUB+ddfXyfCi6RXxfS+0FpLALkELNCMWJBayt/7iPLNdm7a/ufU1UwXVrUYAqDfpzYw/WZ8S6K4YlRder0Rfkn95XkJQ/W53omRp6B/5JhIt9ZKNm/wHI0o0MkjW5oQM0G/aq5UY9nrl3rjSc5CXJdeu66VJ8BbJ8gnUKxxQ== 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=vbXpacIttvLRu6Ucvaev3vjLxDvNQ7MBOYo3GunbKss=; b=GnwYPQtRGvxKs1G3dA23S5s/Wizug7C5jGkUkfDc8j2DcRtmpT8eW+I5x+CEhrU4nRAlawsQzximq8Efk3rKJHHnraO9AFiuLsC1X4zcMg14YETwH6WDPvlGxaixrTBFYsCWVRoKCg+J+GcSsqn7TUYIsjQgcF5apsb2HnK9R0tRdhar9rpcM4BZnuZrVc1Bt1QWB40zpIn2UA2KbPImpYYZ00uDxJEMlqHiXhYj8o5znK45Olj+8oTnb9U2X4KGjrWjTMXKkaiYC4fnhZsn+AZ9VtbHDQF2UwIvtHAboDY7ZByWN7wQAxdklRKMUlR2gW0xHGJkSfmupJzry/TlWQ== 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=vbXpacIttvLRu6Ucvaev3vjLxDvNQ7MBOYo3GunbKss=; b=cFDTPSBOWFxuECIBZ4gHq2389nZXgMKJ7lU8ZHuWO8CJJjEMHd7vbgxJCHw6Zuwo5fClhEzs8br6HRyt6WSSOb421D9gEksvlEBNDzF2+BOYR3Fp48XMhO7dpcFZTc0Q6m6JJXDCB1hfuB9xfA4ltP22jNikd09AOfNa4Reoeqc= Received: from MN2PR12MB3966.namprd12.prod.outlook.com (2603:10b6:208:165::18) by DM4PR12MB6399.namprd12.prod.outlook.com (2603:10b6:8:b7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.22; Thu, 20 Apr 2023 15:45:22 +0000 Received: from MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::46f1:bdce:a4bc:29e3]) by MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::46f1:bdce:a4bc:29e3%3]) with mapi id 15.20.6319.022; Thu, 20 Apr 2023 15:45:22 +0000 From: "Chang, Abner" To: Nickle Wang , "devel@edk2.groups.io" CC: Isaac Oram , "Attar, AbdulLateef (Abdul Lateef)" , 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: AQHZc1M1hC8l+w9yq0G+b9xWqfivEa80V4Cw Date: Thu, 20 Apr 2023 15:45:22 +0000 Message-ID: References: <20230418071543.1951-1-abner.chang@amd.com> <20230418071543.1951-2-abner.chang@amd.com> In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2023-04-20T15:45:19Z; 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_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=26deaa99-f7b2-4878-a490-5d3771dac21b; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=1 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: MN2PR12MB3966:EE_|DM4PR12MB6399:EE_ x-ms-office365-filtering-correlation-id: a50ff6dd-1207-4677-9ad4-08db41b6409b x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: +rEVgfHTMjkarxp3hydWn+859rqp4mpk9HT5qIxagJNpGBoOF+/LMiXZJCZ4AGorpweFwjcQlAY3GuIJzrDBqSNA/VoXFHKIabF8GYtJVJovn0/6VCIbOPNDfSODsr4mNfu/Fir455mQ+X1i0H1whEJfGX6CM/HDVeL1CRXqwFdLjNYzlrvNsJXYiYO3s3dftXcowk3pHq/JL8WF5AAi0QcV3c/LlmLZqP5/+qS43mBQSE6VIigOr6ALdpDKoSLuPiCg0RBWiFLQ9NIy5fnn9YvNQyQvU5fNlxcbpOobCqI95mfKsxJCeHP14aYn26f18fFc40AHInkjh1sUKso1J+MgjYJjnC3F1zA3sSQwaUFZAooAMU5SUWnZYMWBtD2IBRn0EdbwvBqzR7Y4nKJpEL9cBiEw5sFOQlFghDtSEWFhBEnoKKduH2PnRuwTJaI52Yuzzo4fxc9quYmQGy5yrnEZQQg1x3+v7+7dqAAO5CUBt0mvH9xrz66+Qimm/EKXqfYwBdwbL0pem1gP5PlgQOzKZocc0xAxbt7RwreQ3vmd4VsqFe828Hc/SMHDsIHHuxYszdHsSOqHqRTJBYL+2fOrly29/65mRA4yekPuX0vnbvvPWJlcY4XbqOLBIoBQ x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB3966.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(136003)(366004)(39860400002)(396003)(376002)(346002)(451199021)(30864003)(2906002)(38070700005)(38100700002)(8936002)(8676002)(52536014)(5660300002)(55016003)(86362001)(33656002)(7696005)(71200400001)(6506007)(26005)(110136005)(54906003)(478600001)(9686003)(83380400001)(53546011)(186003)(66476007)(66946007)(316002)(66556008)(41300700001)(66446008)(122000001)(4326008)(76116006)(64756008)(579004);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?RCY243LBQGZcz9lBcMN4w/nZK7Aqfj43AGXMJvksMdukAqWiT5/MyTqhqAEi?= =?us-ascii?Q?H8jU1z4GGPHis6IC2A7h6bGX5Bjyvf3nFZDrQjmPo8ISfjnKfJDVj3mLUm4r?= =?us-ascii?Q?alO0rn927mQiHCy6aRnQW7dbnpOncXz61o5h6aTvDG8D6Cm8q04RDfHcTCUd?= =?us-ascii?Q?Wru3poqcqhG4SBM0+51oqCucZ67G9LI1dU13x9R4HBP+TfER7NMb4D5r9Chr?= =?us-ascii?Q?dIaFE71GZuXt4uJBN01AYo+nTc5zVWMM+AaOVqDXiUmSLUit6+aFRb9kWV3c?= =?us-ascii?Q?m9CcLN4BKvYnObF9uVxBVoSDKPUka3ey7aUtEj2tEDwxWN6LIGx3+HsQI12u?= =?us-ascii?Q?52I60/PbP9C3RR4u/nMPeqvW1JSSwI7kbdLOLNxxBSd+s1Vsfh5rl+4SKuW8?= =?us-ascii?Q?4eXyPOIXg0hRxV0O3RfIzhissvQqprVkMwz4UBnw9WRiYF1/kJjGEJ2ZjYQ8?= =?us-ascii?Q?xgE+TJiUkLkmSCGyyxPCdGaz6wZl744oMaFeeJb5455ARfUcCaDoU/uhGcJC?= =?us-ascii?Q?sm5uZoqDvGdAwqK6cyDlP0QH5UJ87kdlsgNuH6RFb7GDK+vrvZgPUvXPZ/ug?= =?us-ascii?Q?s0Uni8WeZOfchr7+z8d/ZsmArg8xakQ2lGLYY7YSTMls8aCKgISgCiix1WTW?= =?us-ascii?Q?Adz5BN9QM2QTfg/0RUrv8s7luu9gX8AJibPT5UeWkdMH8cijrmCGbJoDEWr5?= =?us-ascii?Q?zeH0cLLFYZNDbVcfaKS749g/CXQ60FSjtzx/+m+q3A3t4In2E+pPpBDrlEN6?= =?us-ascii?Q?LunxF41mcFfYwYi5heHog7MB5p0xIP70xhmP65ZMAV3fDRcOlvC03ykP6b/6?= =?us-ascii?Q?whVrum701GYYKg/JxN1Y1z3lMWNYHm9voGalcDHRTsYC71mmglFMt2EglqJd?= =?us-ascii?Q?Xv2HF00JsxndI1fPRFuk8g04aKITvBDLu4r2vlGBW5TiyjH8JDPoMucxXLrA?= =?us-ascii?Q?/VewcyPyG/Iz8bit3ytJz2IrPG9Nc6f6GKQmeODQrWUvcG8/0u7jXllSPre8?= =?us-ascii?Q?NiapVLAdAnmpwvHmvCesr4lT3CuYTokiZNaaluW1tszA28nJvgU+X/ICF0tx?= =?us-ascii?Q?hsCik/saoc+xazMoty75LVjUnAdSC/nEmzSzcImt64qo3GlOeqvf8G8EXVyD?= =?us-ascii?Q?lrxpRUuMYQWsw2KFPwlkcdzsQzKDfuJtA0/i/cGydlxlXax7sI27NqYCcado?= =?us-ascii?Q?BbiFYhZAoge4bpMVZMcMB4WQKZfLLMgXrRDU6ie7xmjfYIrRNK+n6eSHpq3o?= =?us-ascii?Q?khbM3pRWLBP6jTLRFgmWWdCWbyUGh6WhHif2YGY2hllwVFCnUYAw673L32KW?= =?us-ascii?Q?N8tiKwIbPMIBfP6HWNhVsTBCUg1r1duT4oc+4iZbm6Cl7jKRth5BElEEhd4k?= =?us-ascii?Q?tU2+Ma+prpb744Ckpg7cqVPqI5JUFP2MxPcS6tAKvWssDRiId3nKgiBRcJei?= =?us-ascii?Q?kAYke9BY5G59+xFy5Q+RjOG3cQORHYzP1xpAk41U/NDqPe92G4rHlQd4vWnu?= =?us-ascii?Q?BDFEQVlPEVcfBocuCLfJOv0RLkRjdDbdKaZa27ushjG6ad77APrrR8OvgVfU?= =?us-ascii?Q?bgLf4ncKDfgw8hOSGF/+xiMWwHrTdB9KSQ5Iy1Vr?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB3966.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a50ff6dd-1207-4677-9ad4-08db41b6409b X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Apr 2023 15:45:22.6668 (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-CrossTenant-userprincipalname: XtcO++GqiReV6PJ23M3wtqQBeasLZN8xCNowrUF0SUGdh3INv/AQqPS0x3eD699Y7A5gbp5iOclJ003S22LDww== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6399 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only - General] Hi Nickle, I will fix them in the next version. Thanks Abner > -----Original Message----- > From: Nickle Wang > Sent: Thursday, April 20, 2023 2:42 PM > To: Chang, Abner ; devel@edk2.groups.io > Cc: Isaac Oram ; Attar, AbdulLateef (Abdul Lateef= ) > ; Igor Kulchytskyy > Subject: RE: [edk2-platforms][PATCH V2 01/14] ManageabilityPkg: Add more > helper functions >=20 > Caution: This message originated from an External Source. Use proper > caution when opening attachments, clicking links, or responding. >=20 >=20 > Hi Abner, >=20 > Please find my comments below. >=20 > Thanks, > Nickle >=20 > > -----Original Message----- > > From: abner.chang@amd.com > > Sent: Tuesday, April 18, 2023 3:16 PM > > To: devel@edk2.groups.io > > Cc: Isaac Oram ; Abdul Lateef Attar > > ; Nickle Wang ; Igor > Kulchytskyy > > > > Subject: [edk2-platforms][PATCH V2 01/14] ManageabilityPkg: Add more > > helper functions > > > > External email: Use caution opening links or attachments > > > > > > 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/BaseManageabilityTransportHelperLi > > b/Ba > > seManageabilityTransportHelper.inf > > b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLi > > b/Ba > > seManageabilityTransportHelper.inf > > index 5447954144..c9e5eaef60 100644 > > --- > > a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLi > > b/Ba > > seManageabilityTransportHelper.inf > > +++ > b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelp > > +++ er Lib/BaseManageabilityTransportHelper.inf > > @@ -25,6 +25,7 @@ > > [LibraryClasses] > > BaseMemoryLib > > DebugLib > > + MemoryAllocationLib > > > > [Packages] > > ManageabilityPkg/ManageabilityPkg.dec > > diff --git > > a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportHelp > > erLib > > .h > > b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportHelp > > erLib > > .h > > index 718ac34a1f..0dbf5ccb3c 100644 > > --- > > a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportHelp > > erLib > > .h > > +++ b/Features/ManageabilityPkg/Include/Library/ManageabilityTransport > > +++ He > > +++ 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; ///< Nu= mber of packages > in > > MultiPackages. > > + MANAGEABILITY_TRANSMISSION_PACKAGE_ATTR MultiPackages[]; > > +} MANAGEABILITY_TRANSMISSION_MULTI_PACKAGES; > > + > > /** > > Helper function returns the human readable name of Manageability > > specification. > > > > @@ -90,4 +106,86 @@ HelperInitManageabilityTransport ( > > OUT MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS > > *TransportAdditionalStatus 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_PA= CKAGES > > + structure. Caller has to free the m= emory > > + allocated for > > MANAGEABILITY_TRANSMISSION_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 calcul= ation. > > + @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 > > device. > > + > > + @param[in] Payload Payload to print. > > + @param[in] PayloadSize Payload size. > > + @param[in] Format The format string for the debug message to = print. > > + @param[in] ... The variable argument list whose contents a= re > accessed > > + based on the format string specified by For= mat. > > + > > +**/ > > +VOID > > +EFIAPI > > +HelperManageabilityDebugPrint ( > > + IN VOID *Payload, > > + IN UINT32 PayloadSize, > > + IN CONST CHAR8 *Format, > > + ... > > + ); > > + > > #endif > > diff --git > > a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLi > > b/Ba > > seManageabilityTransportHelper.c > > b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLi > > b/Ba > > seManageabilityTransportHelper.c > > index c3f35b7beb..0e241ca3fd 100644 > > --- > > a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLi > > b/Ba > > seManageabilityTransportHelper.c > > +++ > b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelp > > +++ er 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 > > GUID.\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 > specification.\n", > > __FUNCTION__, > > HelperManageabilitySpecName (TransportGuid), @@ -174,7 +176,7 > > @@ HelperAcquireManageabilityTransport ( > > return EFI_UNSUPPORTED; > > } > > > > - DEBUG ((DEBUG_INFO, " Manageability protocol %s is going to > > acquire transport interface token...\n", ManageabilityProtocolName)); > > + DEBUG ((DEBUG_MANAGEABILITY_INFO, " Manageability protocol %s is > > + going to acquire transport interface token...\n", > > + ManageabilityProtocolName)); > > > > Status =3D AcquireTransportSession (ManageabilityProtocolSpec, > > TransportToken); > > 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 calcul= ation. > > + @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_PA= CKAGES > > + structure. Caller has to free the m= emory > > + allocated for > > MANAGEABILITY_TRANSMISSION_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 > > MaximumTransferUnit 0x%x.\n", > > + __FUNCTION__, > > + PreambleSize, > > + PostambleSize, > > + MaximumTransferUnit > > + )); > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + PackagePayloadSize =3D MaximumTransferUnit -PreambleSize - > PostambleSize; > > + NumberOfPackages =3D (UINT16)((PayloadSize + (PackagePayloadSize= - > 1)) / > > PackagePayloadSize); > > + ThisMultiplePackages =3D > (MANAGEABILITY_TRANSMISSION_MULTI_PACKAGES > > *)AllocateZeroPool ( > > + > > + sizeof > > (MANAGEABILITY_TRANSMISSION_MULTI_PACKAGES) + > > + > > + sizeof > > (MANAGEABILITY_TRANSMISSION_PACKAGE_ATTR) * NumberOfPackages > > + > > + ); if (ThisMultiplePackages =3D=3D NULL) { > > + DEBUG ((DEBUG_ERROR, "%a: Not enough memory for > > MANAGEABILITY_TRANSMISSION_MULTI_PACKAGES\n")); > > + return EFI_INVALID_PARAMETER; >=20 > Since there is no memory to allocate, the return value should be > EFI_OUT_OF_RESOURCE. >=20 >=20 >=20 > > + } > > + > > + ThisMultiplePackages->NumberOfPackages =3D NumberOfPackages; > > + ThisPackage =3D > > (MANAGEABILITY_TRANSMISSION_PACKAGE_ATTR > *)(ThisMultiplePackages + 1); > > + TotalPayloadRemaining =3D PayloadSize; > > + for (IndexOfPackage =3D 0; IndexOfPackage < NumberOfPackages; > > IndexOfPackage++) { > > + ThisPackage->PayloadPointer =3D Payload + (IndexOfPackage * > > PackagePayloadSize); > > + ThisPackage->PayloadSize =3D MIN (TotalPayloadRemaining, > > PackagePayloadSize); > > + TotalPayloadRemaining -=3D ThisPackage->PayloadSize; > > + ThisPackage++; > > + } > > + > > + if (TotalPayloadRemaining !=3D 0) { > > + DEBUG ((DEBUG_ERROR, "%a: Error processing multiple packages > > (TotalPayloadRemaining !=3D 0)\n", __FUNCTION__)); >=20 > Before this error return, shall we release ThisMultiplePackages buffer? >=20 >=20 >=20 > > + 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 Mana= geability > > Payload %04xH - %04xH =3D=3D=3D=3D=3D=3D=3D=3D=3D\n", Page256 * 256, Pa= ge256 * 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); Column= 16++) > { > > + DEBUG ((DEBUG_MANAGEABILITY_INFO, "%02x ", *((UINT8 > *)Payload > > + + > > Page256 * 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 > > device. > > + > > + @param[in] Payload Payload to print. > > + @param[in] PayloadSize Payload size. > > + @param[in] Format The format string for the debug message to = print. > > + @param[in] ... The variable argument list whose contents a= re > accessed > > + based on the format string specified by For= mat. > > + > > +**/ > > +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