From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (NAM04-MW2-obe.outbound.protection.outlook.com [40.107.101.79]) by mx.groups.io with SMTP id smtpd.web11.2664.1681802178793528995 for ; Tue, 18 Apr 2023 00:16:18 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=LIKVWrqp; 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.101.79, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cKjuXQwEn6F8gRx+fCy7s/MEE/z4Pui8OK+hTLOSTgn1JMEJngCK2FHEvJfGuUA37MTV4vg3PU81vXOsfmHPRe6PxDhHDlXaIRjZMFt/PJXreR/cV72F2YOC7IkbzCyYudtM4Km08Z3SGkXm+kWMOmHZFeWvxUSiX50UvVrLd105vvIV5Ph8N4plSDwiJLU5TVOT2Ccxw2CfjK0wxr2BVMf1jI5TsH7YYWx8vB01iGtVw9CvYSCUO9AFIABJ+G36c02OGQYdBH3oO740OKFydSI9mgPFKVnI86d5FyGAGfLMtVrZcQ7Mz7Im73Gb0LPll/+vTfXZJX0gzvClqFg8Fg== 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=xY8WUNlr5KDuNoDgUWs9I4QD6yL8OA0qYHLnwVeEXuQ=; b=DfcbIt1jBxHSqV2s/nsvqWMzA1lNlVccWvuJ8oG2CR9nv5TXX1kOO3JqVWgBUJl1A4QoEC7eW5vwnZ6gax8au63Ja1II6wrgEugCm1mWEsAZ94Q0CNWM5RILWXoip/zvFm8qEyo2gZa0Z5zmxYyZUIFkn2E/UGTnmvxvQH30GzLnkjtEdivy5W8f6TlQkuRChVGtDpd84XcawTNsySpYYmhYvLrYByjASjMJEKZcRQWnQWwh3M6mHMaIa8LOmiVt0bzsWpfWR6pHF2FXiw7nhPXBnCdPgI0FqXDsAKmYmWSiSdpS3ggMlYY9Xh/TPaSL0CPjyaNACXCr8ByhCCU+VQ== 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=xY8WUNlr5KDuNoDgUWs9I4QD6yL8OA0qYHLnwVeEXuQ=; b=LIKVWrqpAHX3vejaN6OMdZZ+gjkGx+b75FN9Z+BcC6XVZA0CjhhgkQ6TKPqhxKwhJCByPftmwAwccz5QITE/stxTw9M1Hd+WFNOCWd0fsjVyKr/bDzjzwvo5br26u9qW57Unl8h1Gkm/uA1V+t96NH8xZTZAwNLxyIRY8z2TgtY= Received: from DM6PR02CA0052.namprd02.prod.outlook.com (2603:10b6:5:177::29) by CH3PR12MB8331.namprd12.prod.outlook.com (2603:10b6:610:12f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30; Tue, 18 Apr 2023 07:16:13 +0000 Received: from DM6NAM11FT063.eop-nam11.prod.protection.outlook.com (2603:10b6:5:177:cafe::5a) by DM6PR02CA0052.outlook.office365.com (2603:10b6:5:177::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.46 via Frontend Transport; Tue, 18 Apr 2023 07:16:13 +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 DM6NAM11FT063.mail.protection.outlook.com (10.13.172.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6319.20 via Frontend Transport; Tue, 18 Apr 2023 07:16:13 +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; Tue, 18 Apr 2023 02:16:10 -0500 From: "Chang, Abner" To: CC: Isaac Oram , Abdul Lateef Attar , Nickle Wang , Igor Kulchytskyy Subject: [edk2-platforms][PATCH V2 04/14] ManageabilityPkg: Add PldmProtocolLib Date: Tue, 18 Apr 2023 15:15:33 +0800 Message-ID: <20230418071543.1951-5-abner.chang@amd.com> X-Mailer: git-send-email 2.37.1.windows.1 In-Reply-To: <20230418071543.1951-1-abner.chang@amd.com> References: <20230418071543.1951-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: DM6NAM11FT063:EE_|CH3PR12MB8331:EE_ X-MS-Office365-Filtering-Correlation-Id: 8337adc5-b7dd-4309-56ed-08db3fdccb1d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uhA8bnkaOVg0cuEvpDuwnYd2/FGVpYM+uzC945GMw55VqVoGBFY5owmLEc2ndPvMU9ErdOt443D1IANbYPj65yBYZADmnB1jiBzDvsAOCRacHfIIWTjdNqHCZ6z4+YdU6fGGkFc4J4Ffqi5MJuMy48gOA4B8WDhrXw33luTEepJidf70YGkFlo+hw1TNX21j7g+nq+cK3NSGn/P8VOO6SsUoN9KTDZO7/GgqmWaeSsIncjIMcegUix4vaBoMt5wMDDfHbZTruNE1vdY/SNCdTjp2PnhfHTLUWzd7ATKrfVvL1X5nCFSBZkstjMYey3XHLfdSFtuyqDX5AgxNxRqj/A4aXoL4CR5ytGEM9HJp+HCE0sSzXT0V81etxm4nF+9PGpet2+HbIWBq9v3cxleFQF5mUdvsgC2jfhF4pSwCSixnq/vAbWFVRLuVU/ygg8dB13WHtXpjdwJA0b2Cz1EMOSK4dCY6O2mV62/hoPkJwcxJttIXe5EdrGpoXdogqsUylqDvkSn6Q9j/4I14qt4xtVbbP9klmSUnkXIlq0c2f4n5TqeHWlMwjI5Kr8GAxYOApPE0JrWyUH+yqrtVOYFPOjzjY5qAaJnEa7OJAB9aRZiZ++Pt4EGRA2htW2CeIN6odkA75RP9qLbFNsST7VMpjjXApIcjBRcwDtechUfG1WzeMxcv5N20fcBICRiUxqo8skqofBLEFzm5hJdCRCeiA/x+bETnhzHGVPz2QaxUz+RORuL/vLKOBd354KulTQH/3Yr2HIEEDe+ze5g8JVnuwQ== 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)(346002)(376002)(136003)(39860400002)(451199021)(46966006)(36840700001)(40470700004)(2906002)(30864003)(2876002)(70206006)(8936002)(5660300002)(70586007)(478600001)(8676002)(41300700001)(40460700003)(316002)(82740400003)(40480700001)(83380400001)(36756003)(426003)(54906003)(336012)(4326008)(6916009)(16526019)(86362001)(7696005)(6666004)(186003)(1076003)(26005)(81166007)(2616005)(36860700001)(356005)(47076005)(82310400005)(156123004)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2023 07:16:13.5328 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8337adc5-b7dd-4309-56ed-08db3fdccb1d 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: DM6NAM11FT063.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8331 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain From: Abner Chang PldmProtocolLib provides the library function to PLDM protocol. Signed-off-by: Abner Chang Cc: Isaac Oram Cc: Abdul Lateef Attar Cc: Nickle Wang Cc: Igor Kulchytskyy --- .../ManageabilityPkg/ManageabilityPkg.dec | 3 + .../Include/Dsc/Manageability.dsc | 3 + .../ManageabilityPkg/ManageabilityPkg.dsc | 1 + .../Dxe/PldmProtocolLib.inf | 42 +++++++++ .../Include/Library/BasePldmProtocolLib.h | 41 +++++++++ .../Include/Protocol/PldmProtocol.h | 87 +++++++++++++++++++ .../PldmProtocolLibrary/Dxe/PldmProtocolLib.c | 87 +++++++++++++++++++ .../Dxe/PldmProtocolLib.uni | 18 ++++ 8 files changed, 282 insertions(+) create mode 100644 Features/ManageabilityPkg/Library/PldmProtocolLibrary/D= xe/PldmProtocolLib.inf create mode 100644 Features/ManageabilityPkg/Include/Library/BasePldmProto= colLib.h create mode 100644 Features/ManageabilityPkg/Include/Protocol/PldmProtocol= .h create mode 100644 Features/ManageabilityPkg/Library/PldmProtocolLibrary/D= xe/PldmProtocolLib.c create mode 100644 Features/ManageabilityPkg/Library/PldmProtocolLibrary/D= xe/PldmProtocolLib.uni diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dec b/Features/Mana= geabilityPkg/ManageabilityPkg.dec index 3d279ef033..e4d147fede 100644 --- a/Features/ManageabilityPkg/ManageabilityPkg.dec +++ b/Features/ManageabilityPkg/ManageabilityPkg.dec @@ -48,3 +48,6 @@ gManageabilityProtocolMctpGuid =3D { 0x76FED8F1, 0x0BE5, 0x4269, { 0x= A3, 0x1A, 0x38, 0x0F, 0x54, 0xF1, 0xA1, 0x8A } } # Manageability Protocol PLDM gManageabilityProtocolPldmGuid =3D { 0x3958090D, 0x69DD, 0x4868, { 0x= 9C, 0x41, 0xC9, 0xAC, 0x31, 0xB5, 0x25, 0xC5 } } + +[Protocols] + gEdkiiPldmProtocolGuid =3D { 0x60997616, 0xDB70, 0x4B5F, = { 0x86, 0xA4, 0x09, 0x58, 0xA3, 0x71, 0x47, 0xB4 } } diff --git a/Features/ManageabilityPkg/Include/Dsc/Manageability.dsc b/Feat= ures/ManageabilityPkg/Include/Dsc/Manageability.dsc index 7f8d8df3f0..eda1a36bb9 100644 --- a/Features/ManageabilityPkg/Include/Dsc/Manageability.dsc +++ b/Features/ManageabilityPkg/Include/Dsc/Manageability.dsc @@ -8,6 +8,9 @@ [LibraryClasses] ManageabilityTransportHelperLib|ManageabilityPkg/Library/BaseManageabili= tyTransportHelperLib/BaseManageabilityTransportHelper.inf =20 +[LibraryClasses.common.DXE_DRIVER] + PldmProtocolLib|ManageabilityPkg/Library/PldmProtocolLibrary/Dxe/PldmPro= tocolLib.inf + [LibraryClasses.ARM, LibraryClasses.AARCH64] # # This library provides the instrinsic functions generated by a given co= mpiler. diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dsc b/Features/Mana= geabilityPkg/ManageabilityPkg.dsc index 6a083385fd..412029ef6c 100644 --- a/Features/ManageabilityPkg/ManageabilityPkg.dsc +++ b/Features/ManageabilityPkg/ManageabilityPkg.dsc @@ -37,6 +37,7 @@ =20 [Components] ManageabilityPkg/Library/ManageabilityTransportKcsLib/Dxe/DxeManageabili= tyTransportKcs.inf + ManageabilityPkg/Library/PldmProtocolLibrary/Dxe/PldmProtocolLib.inf =20 [LibraryClasses] ManageabilityTransportLib|ManageabilityPkg/Library/BaseManageabilityTran= sportNullLib/BaseManageabilityTransportNull.inf diff --git a/Features/ManageabilityPkg/Library/PldmProtocolLibrary/Dxe/Pldm= ProtocolLib.inf b/Features/ManageabilityPkg/Library/PldmProtocolLibrary/Dxe= /PldmProtocolLib.inf new file mode 100644 index 0000000000..1233d76726 --- /dev/null +++ b/Features/ManageabilityPkg/Library/PldmProtocolLibrary/Dxe/PldmProtoco= lLib.inf @@ -0,0 +1,42 @@ +## @file +# Instance of PLDM Protocol Library in DXE phase. +# +# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D PldmProtocolLib + MODULE_UNI_FILE =3D PldmProtocolLib.uni + FILE_GUID =3D 5B1173E8-6A5A-468B-BDA4-02303530C55C + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D PldmProtocolLib|DXE_RUNTIME_DRIVER DX= E_DRIVER DXE_CORE UEFI_DRIVER UEFI_APPLICATION + +# +# VALID_ARCHITECTURES =3D IA32 X64 +# + +[Sources] + PldmProtocolLib.c + +[Packages] + ManageabilityPkg/ManageabilityPkg.dec + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + DebugLib + ManageabilityTransportHelperLib + UefiBootServicesTableLib + +[Guids] + gManageabilityProtocolPldmGuid + +[Protocols] + gEdkiiPldmProtocolGuid ## ALWAYS_CONSUMES + diff --git a/Features/ManageabilityPkg/Include/Library/BasePldmProtocolLib.= h b/Features/ManageabilityPkg/Include/Library/BasePldmProtocolLib.h new file mode 100644 index 0000000000..5523ac3a4d --- /dev/null +++ b/Features/ManageabilityPkg/Include/Library/BasePldmProtocolLib.h @@ -0,0 +1,41 @@ +/** @file + + This file defines EDKII Pldm Protocol library and functions. + + Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef EDKII_PLDM_PROTOCOL_LIB_H_ +#define EDKII_PLDM_PROTOCOL_LIB_H_ + +/** + This service enables submitting commands via EDKII PLDM protocol. + + @param[in] PldmType PLDM message type. + @param[in] Command PLDM Command of PLDM message type. + @param[in] RequestData Command Request Data. + @param[in] RequestDataSize Size of Command Request Data. + @param[out] ResponseData Command Response Data. The completi= on code is the first byte of response data. + @param[in, out] ResponseDataSize Size of Command Response Data. + + @retval EFI_SUCCESS PLDM message was successfully sent to tra= nsport interface + and a response was successfully received. + @retval EFI_NOT_FOUND Transport interface is not found. + @retval EFI_NOT_READY Transport interface is not ready for PLDM= message. + @retval EFI_DEVICE_ERROR Transport interface has an hardware error= . + @retval EFI_TIMEOUT Send PLDM message got a timeout. + @retval EFI_UNSUPPORTED PLDM message is unsupported. + @retval EFI_OUT_OF_RESOURCES The resource allocation is out of resourc= e or data size error. +**/ +EFI_STATUS +PldmSubmitCommand ( + IN UINT8 PldmType, + IN UINT8 Command, + IN UINT8 *RequestData, + IN UINT32 RequestDataSize, + OUT UINT8 *ResponseData, + IN OUT UINT32 *ResponseDataSize + ); + +#endif diff --git a/Features/ManageabilityPkg/Include/Protocol/PldmProtocol.h b/Fe= atures/ManageabilityPkg/Include/Protocol/PldmProtocol.h new file mode 100644 index 0000000000..651997e1ad --- /dev/null +++ b/Features/ManageabilityPkg/Include/Protocol/PldmProtocol.h @@ -0,0 +1,87 @@ +/** @file + Protocol of EDKII PLDM Protocol. + + Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef EDKII_PLDM_PROTOCOL_H_ +#define EDKII_PLDM_PROTOCOL_H_ + +#include + +typedef struct _EDKII_PLDM_PROTOCOL EDKII_PLDM_PROTOCOL; + +#define EDKII_PLDM_PROTOCOL_GUID \ + { \ + 0x60997616, 0xDB70, 0x4B5F, 0x86, 0xA4, 0x09, 0x58, 0xA3, 0x71, 0x47, = 0xB4 \ + } + +#define EDKII_PLDM_PROTOCOL_VERSION_MAJOR 1 +#define EDKII_PLDM_PROTOCOL_VERSION_MINOR 0 +#define EDKII_PLDM_PROTOCOL_VERSION ((EDKII_PLDM_PROTOCOL_VERSION_M= AJOR << 8) |\ + EDKII_PLDM_PROTOCOL_VERSION_MINOR) + +/** + This service enables submitting commands via EDKII PLDM protocol. + + @param[in] This EDKII_PLDM_PROTOCOL instance. + @param[in] PldmType PLDM message type. + @param[in] Command PLDM Command of PLDM message type. + @param[in] RequestData Command Request Data. + @param[in] RequestDataSize Size of Command Request Data. + @param[out] ResponseData Command Response Data. The completi= on code is the first byte of response data. + @param[in, out] ResponseDataSize Size of Command Response Data. + + @retval EFI_SUCCESS The command byte stream was successfully = submit to the device and a response was successfully received. + @retval EFI_NOT_FOUND The command was not successfully sent to = the device or a response was not successfully received from the device. + @retval EFI_NOT_READY PLDM transport interface is not ready for= PLDM command access. + @retval EFI_DEVICE_ERROR PLDM transport interface Device hardware = error. + @retval EFI_TIMEOUT The command time out. + @retval EFI_UNSUPPORTED The command was not successfully sent to = the device. + @retval EFI_OUT_OF_RESOURCES The resource allcation is out of resource= or data size error. + @retval EFI_INVALID_PARAMETER Both RequestData and ResponseData are NUL= L +**/ +typedef +EFI_STATUS +(EFIAPI *PLDM_SUBMIT_COMMAND)( + IN EDKII_PLDM_PROTOCOL *This, + IN UINT8 PldmType, + IN UINT8 Command, + IN UINT8 *RequestData, + IN UINT32 RequestDataSize, + OUT UINT8 *ResponseData, + IN OUT UINT32 *ResponseDataSize + ); + +// +// EDKII_PLDM_PROTOCOL Version 1.0 +// +typedef struct { + PLDM_SUBMIT_COMMAND PldmSubmitCommand; +} EDKII_PLDM_PROTOCOL_V1_0; + +/// +/// Definitions of EDKII_PLDM_PROTOCOL. +/// This is a union that can accommodate the new functionalities defined +/// in PLDM Base specification in the future. +/// The new added function must has its own EDKII_PLDM_PROTOCOL +/// structure with the incremental version number. +/// e.g., EDKII_PLDM_PROTOCOL_V1_1. +/// +/// The new function must be added base on the last version of +/// EDKII_PLDM_PROTOCOL to keep the backward compatability. +/// +typedef union { + EDKII_PLDM_PROTOCOL_V1_0 *Version1_0; +} EDKII_PLDM_PROTOCOL_FUNCTION; + +struct _EDKII_PLDM_PROTOCOL { + UINT16 ProtocolVersion; + EDKII_PLDM_PROTOCOL_FUNCTION Functions; +}; + +extern EFI_GUID gEdkiiPldmProtocolGuid; + +#endif // EDKII_PLDM_PROTOCOL_H_ diff --git a/Features/ManageabilityPkg/Library/PldmProtocolLibrary/Dxe/Pldm= ProtocolLib.c b/Features/ManageabilityPkg/Library/PldmProtocolLibrary/Dxe/P= ldmProtocolLib.c new file mode 100644 index 0000000000..76d09696b0 --- /dev/null +++ b/Features/ManageabilityPkg/Library/PldmProtocolLibrary/Dxe/PldmProtoco= lLib.c @@ -0,0 +1,87 @@ +/** @file + Instance of EDKII PLDM Protocol Library in DXE phase + + Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include + +EDKII_PLDM_PROTOCOL *mEdkiiPldmProtocol =3D NULL; + +/** + This service enables submitting commands via EDKII PLDM protocol. + + @param[in] PldmType PLDM message type. + @param[in] Command PLDM Command of PLDM message type. + @param[in] RequestData Command Request Data. + @param[in] RequestDataSize Size of Command Request Data. + @param[out] ResponseData Command Response Data. The completi= on code is the first byte of response data. + @param[in, out] ResponseDataSize Size of Command Response Data. + + @retval EFI_SUCCESS PLDM message was successfully sent to tra= nsport interface + and a response was successfully received. + @retval EFI_NOT_FOUND Transport interface is not found. + @retval EFI_NOT_READY Transport interface is not ready for PLDM= message. + @retval EFI_DEVICE_ERROR Transport interface has an hardware error= . + @retval EFI_TIMEOUT Send PLDM message got a timeout. + @retval EFI_UNSUPPORTED PLDM message is unsupported. + @retval EFI_OUT_OF_RESOURCES The resource allocation is out of resourc= e or data size error. +**/ +EFI_STATUS +PldmSubmitCommand ( + IN UINT8 PldmType, + IN UINT8 Command, + IN UINT8 *RequestData, + IN UINT32 RequestDataSize, + OUT UINT8 *ResponseData, + IN OUT UINT32 *ResponseDataSize + ) +{ + EFI_STATUS Status; + + if (mEdkiiPldmProtocol =3D=3D NULL) { + Status =3D gBS->LocateProtocol ( + &gEdkiiPldmProtocolGuid, + NULL, + (VOID **)&mEdkiiPldmProtocol + ); + if (EFI_ERROR (Status)) { + // + // Dxe PLDM Protocol is not installed. So, PLDM device is not presen= t. + // + DEBUG ((DEBUG_ERROR, "%a: EDKII PLDM protocol is not found - %r\n", = Status)); + return EFI_NOT_FOUND; + } + } + + DEBUG ((DEBUG_MANAGEABILITY_INFO, "%a: PLDM Type: 0x%x, Command: 0x%x\n"= , __FUNCTION__, PldmType, Command)); + if ((RequestData !=3D NULL) && (RequestDataSize !=3D 0)) { + HelperManageabilityDebugPrint ((VOID *)RequestData, RequestDataSize, "= PLDM PLDM application layer Type/Command specific request payload\n"); + } + + Status =3D mEdkiiPldmProtocol->Functions.Version1_0->PldmSubmitCommand ( + mEdkiiPldmProtocol, + PldmType, + Command, + RequestData, + RequestDataSize, + ResponseData, + ResponseDataSize + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Fails to send PLDM package - %r\n", Status)); + return Status; + } + + if ((ResponseData !=3D NULL) && (*ResponseDataSize !=3D 0)) { + HelperManageabilityDebugPrint ((VOID *)ResponseData, *ResponseDataSize= , "PLDM application layer response payload\n"); + } + + return Status; +} diff --git a/Features/ManageabilityPkg/Library/PldmProtocolLibrary/Dxe/Pldm= ProtocolLib.uni b/Features/ManageabilityPkg/Library/PldmProtocolLibrary/Dxe= /PldmProtocolLib.uni new file mode 100644 index 0000000000..b58a2ac146 --- /dev/null +++ b/Features/ManageabilityPkg/Library/PldmProtocolLibrary/Dxe/PldmProtoco= lLib.uni @@ -0,0 +1,18 @@ +// /** @file +// Instance of PLDM Protocol Library in DXE phase. +// +// Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. +// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// +// **/ + +#string STR_MODULE_ABSTRACT +#language en-US +"Instance of PLDM Protocol Library in DXE phase." + +#string STR_MODULE_DESCRIPTION +#language en-US +"Instance of PLDM Protocol Library in DXE phase." + + --=20 2.37.1.windows.1