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.41]) by mx.groups.io with SMTP id smtpd.web11.8271.1678285048612898019 for ; Wed, 08 Mar 2023 06:17:29 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=gPpEQiHA; 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.41, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gRFfnmsXV/KlbgAem/ySc4+aj6RSbFoSEggqmGWuuscD0B6jw95wqv10xnP6A8ACTBMUnTWatsIBPcnX8BlaJWeLcWWXOY51faRmQE6ndQMIMFz5Ib5reyErtvaIm+0JMGEEfeaqDdmmrJBJryAyYDjeYQMororpmEf2Fdug6yfe1yqmKDbnzAXtOB/5drr5qe40W9WVaGiXww1jwO7dGrqmbLhfU2lNR0LPl0vTR532X+PcZ+0xKSUJR/7DVGMHzKYiygDTTvcCsnkSkuLXsgvH8iLYEIJA8ZGXuB1p0LMZNLmVSGULuvAfLJTqM+1/mIQfbWTDf5nbUz1X1sNLwg== 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=Cx3TvwQjG591f5o+dGiXnLtRyGhusIZyhouYNe5Wwdk=; b=inMbdP2c66vUDHyyqfyYEAEIuemm2/TGixtHsUqkz2oC5lL0teUoBT4ehu8Wu/QkJSsXNZQqrUU/DwYsTpPojXk9bczItD7IwAbPWmZT1P2nf/Lw/l6kfx+Pbu+hAZpEB8UZ++ws4cDDB9KDR8mFntnr9U1myR8wvJa8EoaMbOkDmGfi9MNf1BwmapNXmgA0SJd4OdSh3oj4qJqMPe4aPq7bkPbrbV6onVBk4A58v0g0iM3xoAvoao6jxCYyfWsVzlPE4aed5mzapsxnoqCFb19TfbSB23EN+7owNYqJ8boQah0x6wLl1G4kmvUITlfEQ7NEnA/pUo8UQ210XjonwA== 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=Cx3TvwQjG591f5o+dGiXnLtRyGhusIZyhouYNe5Wwdk=; b=gPpEQiHAjlM3xJjS5nlPE7eTQ1PzlVQUJ3WPPdBTZ5sVUENAyRVIjgmzAUck7RlrT6MepGXYj3u5hcxrYjZhgpkYGsIwKHZpqLwflxddRkjko9EgJ0y2mtB2IVtB5tjpUU01WMDxva/UqVw+Pb9Y8/lZXaLwa4m4PjgqIKxjOio= Received: from CY5PR04CA0004.namprd04.prod.outlook.com (2603:10b6:930:1e::26) by CY8PR12MB7587.namprd12.prod.outlook.com (2603:10b6:930:9a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.16; Wed, 8 Mar 2023 14:17:24 +0000 Received: from CY4PEPF0000C97F.namprd02.prod.outlook.com (2603:10b6:930:1e:cafe::9) by CY5PR04CA0004.outlook.office365.com (2603:10b6:930:1e::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.18 via Frontend Transport; Wed, 8 Mar 2023 14:17:24 +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 CY4PEPF0000C97F.mail.protection.outlook.com (10.167.241.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.13 via Frontend Transport; Wed, 8 Mar 2023 14:17:24 +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; Wed, 8 Mar 2023 08:17:21 -0600 From: "Chang, Abner" To: CC: Liming Gao , Isaac Oram , Nate DeSimone , Abdul Lateef Attar , Nickle Wang , "Igor Kulchytskyy" Subject: [edk2-platforms][PATCH V2 6/8] ManageabilityPkg: Implement Ipmi Protocol/Ppi Date: Wed, 8 Mar 2023 22:16:45 +0800 Message-ID: <20230308141647.1318-7-abner.chang@amd.com> X-Mailer: git-send-email 2.37.1.windows.1 In-Reply-To: <20230308141647.1318-1-abner.chang@amd.com> References: <20230308141647.1318-1-abner.chang@amd.com> MIME-Version: 1.0 Return-Path: Abner.Chang@amd.com X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000C97F:EE_|CY8PR12MB7587:EE_ X-MS-Office365-Filtering-Correlation-Id: 2fe02042-a1d7-4fe9-e04c-08db1fdfd6b4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B0mMHbOz4gAa+AqatDg9wlp2rLAhWEsVd98/6Npaijl3Ky9Kupj/h3F7s7NOxyyQTwXjKN09l627+YPkLOE0jFfZtR4ypNmNYzOfitOcq5I19SP6deYQfGXZxrbb3JePf2FIfob2Uf7D4fkI7SNvueh6jfeqrngTRLQlA+NmX17SowsFX3M84yLqeTQdekYLbA+HM/mNvRwry9thHssfk3VEit90utNKOU0BpuD0e9gj7ZMBcuBqZ2Ir9RMcOvUX+Nuu0VxoJ9rzCKP+SRZyO/1wqJDEt+HjWY8D69Ty3TLwSGYPuHCxv9/F0J9qKFhXIn6lFqXl8jQOupDowXFhyHGhZhBPUExGSGNcXpFlSbLX+6xJBKzhSOd8iqRSbHhFT4UyYfOg86Dp/HRvoNqRP4O2gtcwi7lUOyiORpHlTaaZZxXYldRTLKfpIe41VbN9Ot4ZzL4iP+Ico5wBgt1WjQCD7HjNQuw7bZhPd3T3Sg5eYITDkhMxXkByFo3Cowf+wImimhBkdSiXSCg3yMSb2+HDor82P8cSNlvOPVjx35pRhO0tr9O09dBo/t59tyaouRfSnQoU/jOGVryDI1UfOjhE2WyPE1pc5RhRV0rAne2veZNA2qU+yT2QHtk8zWVef2dbrBsHvRszJpUch1FQ345GV/0eu27gDadcbd0YNZGuSeQx/pjGk7xkm+caEnsLlpDtzUkWystRatC7MTpNuxVW3dFGuQgkT9/uWl97inln5UsDrHTNeSot+Ld+7IO5hNyqKLwPlBwosq3pQpNKBg== 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:(13230025)(4636009)(39860400002)(376002)(396003)(136003)(346002)(451199018)(46966006)(36840700001)(40470700004)(356005)(8936002)(426003)(7696005)(40460700003)(30864003)(83380400001)(16526019)(5660300002)(186003)(26005)(478600001)(1076003)(6666004)(81166007)(36756003)(336012)(36860700001)(2876002)(82740400003)(2616005)(54906003)(316002)(86362001)(41300700001)(47076005)(82310400005)(8676002)(70586007)(70206006)(6916009)(4326008)(2906002)(40480700001)(36900700001)(579004)(44824005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 14:17:24.2308 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2fe02042-a1d7-4fe9-e04c-08db1fdfd6b4 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: CY4PEPF0000C97F.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7587 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain From: Abner Chang Add Ipmi Protocol/Ppi/SMM implementations. The underlying implementation of transport interface depends on the binded ManageabilityTransportLib. Signed-off-by: Abner Chang Cc: Liming Gao Cc: Isaac Oram Cc: Nate DeSimone Cc: Abdul Lateef Attar Cc: Nickle Wang Cc: Igor Kulchytskyy --- .../IpmiProtocol/Dxe/IpmiProtocolDxe.inf | 50 ++++ .../Universal/IpmiProtocol/Pei/IpmiPpiPei.inf | 51 ++++ .../IpmiProtocol/Smm/IpmiProtocolSmm.inf | 52 ++++ .../IpmiProtocol/Common/IpmiProtocolCommon.h | 108 ++++++++ .../IpmiProtocol/Common/IpmiProtocolCommon.c | 247 ++++++++++++++++++ .../Universal/IpmiProtocol/Dxe/IpmiProtocol.c | 177 +++++++++++++ .../Universal/IpmiProtocol/Pei/IpmiPpi.c | 151 +++++++++++ .../Universal/IpmiProtocol/Smm/IpmiProtocol.c | 147 +++++++++++ 8 files changed, 983 insertions(+) create mode 100644 Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/Ip= miProtocolDxe.inf create mode 100644 Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/Ip= miPpiPei.inf create mode 100644 Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/Ip= miProtocolSmm.inf create mode 100644 Features/ManageabilityPkg/Universal/IpmiProtocol/Common= /IpmiProtocolCommon.h create mode 100644 Features/ManageabilityPkg/Universal/IpmiProtocol/Common= /IpmiProtocolCommon.c create mode 100644 Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/Ip= miProtocol.c create mode 100644 Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/Ip= miPpi.c create mode 100644 Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/Ip= miProtocol.c diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProto= colDxe.inf b/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProto= colDxe.inf new file mode 100644 index 0000000000..ff5ec56c73 --- /dev/null +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocolDxe.= inf @@ -0,0 +1,50 @@ +## @file +# IPMI Protocol DXE Driver. +# +# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x0001001d + BASE_NAME =3D IpmiDxe + FILE_GUID =3D BC41B0C2-9D8A-42B5-A28F-02CE0D4A6C28 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D DxeIpmiEntry + UNLOAD_IMAGE =3D IpmiUnloadImage + +# +# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 +# + +[Sources] + IpmiProtocol.c + ../Common/IpmiProtocolCommon.c + ../Common/IpmiProtocolCommon.h + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + ManageabilityPkg/ManageabilityPkg.dec + +[LibraryClasses] + BaseMemoryLib + DebugLib + ManageabilityTransportHelperLib + ManageabilityTransportLib + UefiDriverEntryPoint + UefiBootServicesTableLib + +[Protocols] + gIpmiProtocolGuid # PROTOCOL ALWAYS_PRODUCED + +[Guids] + gManageabilityProtocolIpmiGuid + gManageabilityTransportKcsGuid + +[FixedPcd] + gEfiMdePkgTokenSpaceGuid.PcdIpmiKcsBaseAddress + +[Depex] + TRUE diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpiPe= i.inf b/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpiPei.inf new file mode 100644 index 0000000000..058bfb63cb --- /dev/null +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpiPei.inf @@ -0,0 +1,51 @@ +## @file +# IPMI Protocol PEI Driver. +# +# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x0001001d + BASE_NAME =3D IpmiPei + FILE_GUID =3D 7832F989-CB72-4715-ADCA-35C0B031856C + MODULE_TYPE =3D PEIM + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D PeiIpmiEntry + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 +# + +[Sources] + IpmiPpi.c + ../Common/IpmiProtocolCommon.c + ../Common/IpmiProtocolCommon.h + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + ManageabilityPkg/ManageabilityPkg.dec + +[LibraryClasses] + BaseMemoryLib + DebugLib + ManageabilityTransportHelperLib + ManageabilityTransportLib + PeimEntryPoint + ManageabilityTransportLib + +[Ppis] + gPeiIpmiPpiGuid # PPI ALWAYS PRODUCED + +[Guids] + gManageabilityProtocolIpmiGuid + gManageabilityTransportKcsGuid + +[FixedPcd] + gEfiMdePkgTokenSpaceGuid.PcdIpmiKcsBaseAddress + +[Depex] + TRUE diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProto= colSmm.inf b/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProto= colSmm.inf new file mode 100644 index 0000000000..cae1462f4f --- /dev/null +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocolSmm.= inf @@ -0,0 +1,52 @@ +## @file +# IPMI Protocol SMM Driver. +# +# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 +# +[Defines] + INF_VERSION =3D 0x0001001d + BASE_NAME =3D IpmiSmm + FILE_GUID =3D CDD5D1DE-E3D3-4B1F-8689-DCC66156= 1BB4 + MODULE_TYPE =3D DXE_SMM_DRIVER + PI_SPECIFICATION_VERSION =3D 0x0001000A + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D SmmIpmiEntry + +[Sources] + IpmiProtocol.c + ../Common/IpmiProtocolCommon.c + ../Common/IpmiProtocolCommon.h + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + ManageabilityPkg/ManageabilityPkg.dec + +[LibraryClasses] + BaseMemoryLib + DebugLib + ManageabilityTransportHelperLib + ManageabilityTransportLib + SmmServicesTableLib + UefiDriverEntryPoint + UefiBootServicesTableLib + +[Protocols] + gSmmIpmiProtocolGuid # PROTOCOL ALWAYS_PRODUCED + +[Guids] + gManageabilityProtocolIpmiGuid + gManageabilityTransportKcsGuid + +[FixedPcd] + gEfiMdePkgTokenSpaceGuid.PcdIpmiKcsBaseAddress + +[Depex] + TRUE diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/IpmiPr= otocolCommon.h b/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/Ip= miProtocolCommon.h new file mode 100644 index 0000000000..39684d0617 --- /dev/null +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/IpmiProtocolC= ommon.h @@ -0,0 +1,108 @@ +/** @file + + IPMI Manageability Protocol common header file. + + Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef MANAGEABILITY_IPMI_COMMON_H_ +#define MANAGEABILITY_IPMI_COMMON_H_ + +#include +#include + +/// +/// IPMI KCS hardware information. +/// +#define IPMI_KCS_BASE_ADDRESS PcdGet16 (PcdIpmiKcsBaseAddress) +#define IPMI_KCS_REG_DATA_IN IPMI_KCS_BASE_ADDRESS + IPMI_KCS_DATA_IN_RE= GISTER_OFFSET +#define IPMI_KCS_REG_DATA_OUT IPMI_KCS_BASE_ADDRESS + IPMI_KCS_DATA_OUT_R= EGISTER_OFFSET +#define IPMI_KCS_REG_COMMAND IPMI_KCS_BASE_ADDRESS + IPMI_KCS_COMMAND_RE= GISTER_OFFSET +#define IPMI_KCS_REG_STATUS IPMI_KCS_BASE_ADDRESS + IPMI_KCS_STATUS_REG= ISTER_OFFSET + +/** + This functions setup the IPMI transport hardware information according + to the specification of transport token acquired from transport library. + + @param[in] TransportToken The transport interface. + @param[out] HardwareInformation Pointer to receive the hardware = information. + + @retval EFI_SUCCESS Hardware information is returned in Hardw= areInformation. + Caller must free the memory allocated for= HardwareInformation + once it doesn't need it. + @retval EFI_UNSUPPORTED No hardware information for the specifica= tion specified + in the transport token. +**/ +EFI_STATUS +SetupIpmiTransportHardwareInformation ( + IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken, + OUT MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION *HardwareInformation + ); + +/** + This functions setup the final header/body/trailer packets for + the acquired transport interface. + + @param[in] TransportToken The transport interface. + @param[in] NetFunction IPMI function. + @param[in] Command IPMI command. + @param[out] PacketHeader The pointer to receive header of requ= est. + @param[in, out] PacketBody The request body. + When IN, it is the caller's request b= ody. + When OUT and NULL, the request body i= s not + changed. + Whee out and non-NULL, the request bo= dy is + changed to comfort the transport inte= rface. + @param[in, out] PacketBodySize The request body size. + When IN and non-zero, it is the new d= ata + length of request body. + When IN and zero, the request body is= unchanged. + @param[out] PacketTrailer The pointer to receive trailer of req= uest. + + @retval EFI_SUCCESS Request packet is returned. + @retval EFI_UNSUPPORTED Request packet is not returned because + the unsupported transport interface. +**/ +EFI_STATUS +SetupIpmiRequestTransportPacket ( + IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken, + IN UINT8 NetFunction, + IN UINT8 Command, + OUT MANAGEABILITY_TRANSPORT_HEADER *PacketHeader, + IN OUT UINT8 **PacketBody, + IN OUT UINT32 *PacketBodySize, + OUT MANAGEABILITY_TRANSPORT_TRAILER *PacketTrailer + ); + +/** + Common code to submit IPMI commands + + @param[in] TransportToken TRansport token. + @param[in] NetFunction Net function of the command. + @param[in] Command IPMI Command. + @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 Ipmi Device is not ready for Ipmi command= access. + @retval EFI_DEVICE_ERROR Ipmi 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 allocation is out of resourc= e or data size error. +**/ +EFI_STATUS +CommonIpmiSubmitCommand ( + IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken, + IN UINT8 NetFunction, + IN UINT8 Command, + IN UINT8 *RequestData, + IN UINT32 RequestDataSize, + OUT UINT8 *ResponseData, + IN OUT UINT32 *ResponseDataSize + ); + +#endif diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/IpmiPr= otocolCommon.c b/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/Ip= miProtocolCommon.c new file mode 100644 index 0000000000..8e9dd7bf9d --- /dev/null +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/IpmiProtocolC= ommon.c @@ -0,0 +1,247 @@ +/** @file + + IPMI Manageability Protocol common file. + + Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +#include +#include +#include +#include +#include +#include + +#include "IpmiProtocolCommon.h" + +extern CHAR16 *mTransportName; + +MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION mHardwareInformation; + +/** + This functions setup the IPMI transport hardware information according + to the specification of transport token acquired from transport library. + + @param[in] TransportToken The transport interface. + @param[out] HardwareInformation Pointer to receive the hardware = information. + + @retval EFI_SUCCESS Hardware information is returned in Hardw= areInformation. + Caller must free the memory allocated for= HardwareInformation + once it doesn't need it. + @retval EFI_UNSUPPORTED No hardware information for the specifica= tion specified + in the transport token. + #retval EFI_OUT_OF_RESOURCES Not enough memory for MANAGEABILITY_TRANS= PORT_KCS_HARDWARE_INFO. +**/ +EFI_STATUS +SetupIpmiTransportHardwareInformation ( + IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken, + OUT MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION *HardwareInformation + ) +{ + MANAGEABILITY_TRANSPORT_KCS_HARDWARE_INFO *KcsHardwareInfo; + + KcsHardwareInfo =3D AllocatePool (sizeof (MANAGEABILITY_TRANSPORT_KCS_HA= RDWARE_INFO)); + if (KcsHardwareInfo =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: Not enough memory for MANAGEABILITY_TRANSPOR= T_KCS_HARDWARE_INFO.\n", __FUNCTION__)); + return EFI_OUT_OF_RESOURCES; + } + + if (CompareGuid (&gManageabilityTransportKcsGuid, TransportToken->Transp= ort->ManageabilityTransportSpecification)) { + // This is KCS transport interface. + KcsHardwareInfo->MemoryMap =3D MANAGEABILITY_TRANSP= ORT_KCS_IO_MAP_IO; + KcsHardwareInfo->IoBaseAddress.IoAddress16 =3D IPMI_KCS_BASE_ADDRES= S; + KcsHardwareInfo->IoDataInAddress.IoAddress16 =3D IPMI_KCS_REG_DATA_IN= ; + KcsHardwareInfo->IoDataOutAddress.IoAddress16 =3D IPMI_KCS_REG_DATA_OU= T; + KcsHardwareInfo->IoCommandAddress.IoAddress16 =3D IPMI_KCS_REG_COMMAND= ; + KcsHardwareInfo->IoStatusAddress.IoAddress16 =3D IPMI_KCS_REG_STATUS; + *HardwareInformation =3D + (MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION)KcsHardwareInfo; + return EFI_SUCCESS; + } else { + DEBUG ((DEBUG_ERROR, "%a: No implementation of setting hardware inform= ation.", __FUNCTION__)); + ASSERT (FALSE); + } + + return EFI_UNSUPPORTED; +} + +/** + This functions setup the final header/body/trailer packets for + the acquired transport interface. + + @param[in] TransportToken The transport interface. + @param[in] NetFunction IPMI function. + @param[in] Command IPMI command. + @param[out] PacketHeader The pointer to receive header of requ= est. + @param[in, out] PacketBody The request body. + When IN, it is the caller's request b= ody. + When OUT and NULL, the request body i= s not + changed. + When OUT and non-NULL, the request bo= dy is + changed to conform the transport inte= rface. + @param[in, out] PacketBodySize The request body size. + When OUT and non-zero, it is the new = data + length of request body. + When OUT and zero, the request body i= s unchanged. + @param[out] PacketTrailer The pointer to receive trailer of req= uest. + + @retval EFI_SUCCESS Request packet is returned. + @retval EFI_UNSUPPORTED Request packet is not returned because + the unsupported transport interface. +**/ +EFI_STATUS +SetupIpmiRequestTransportPacket ( + IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken, + IN UINT8 NetFunction, + IN UINT8 Command, + OUT MANAGEABILITY_TRANSPORT_HEADER *PacketHeader, + IN OUT UINT8 **PacketBody, + IN OUT UINT32 *PacketBodySize, + OUT MANAGEABILITY_TRANSPORT_TRAILER *PacketTrailer + ) +{ + MANAGEABILITY_IPMI_TRANSPORT_HEADER *IpmiHeader; + + if (CompareGuid (&gManageabilityTransportKcsGuid, TransportToken->Transp= ort->ManageabilityTransportSpecification)) { + // This is KCS transport interface. + IpmiHeader =3D AllocateZeroPool (sizeof (MANAGEABILITY_IPMI_TRANSPORT_= HEADER)); + if (IpmiHeader =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + IpmiHeader->Command =3D Command; + IpmiHeader->Lun =3D 0; + IpmiHeader->NetFn =3D NetFunction; + *PacketHeader =3D (MANAGEABILITY_TRANSPORT_HEADER *)IpmiHeader; + *PacketTrailer =3D NULL; + *PacketBody =3D NULL; + *PacketBodySize =3D 0; + } else { + DEBUG ((DEBUG_ERROR, "%a: No implementation of building up packet.", _= _FUNCTION__)); + ASSERT (FALSE); + } + + return EFI_SUCCESS; +} + +/** + Common code to submit IPMI commands + + @param[in] TransportToken TRansport token. + @param[in] NetFunction Net function of the command. + @param[in] Command IPMI Command. + @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 Ipmi Device is not ready for Ipmi command= access. + @retval EFI_DEVICE_ERROR Ipmi 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 allocation is out of resourc= e or data size error. +**/ +EFI_STATUS +CommonIpmiSubmitCommand ( + IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken, + IN UINT8 NetFunction, + IN UINT8 Command, + IN UINT8 *RequestData, + IN UINT32 RequestDataSize, + OUT UINT8 *ResponseData, + IN OUT UINT32 *ResponseDataSize + ) +{ + EFI_STATUS Status; + UINT8 *ThisRequestData; + UINT32 ThisRequestDataSize; + MANAGEABILITY_TRANSFER_TOKEN TransferToken; + MANAGEABILITY_TRANSPORT_HEADER IpmiTransportHeader; + MANAGEABILITY_TRANSPORT_TRAILER IpmiTransportTrailer; + MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS TransportAdditionalStatus; + + if (TransportToken =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: No transport toke for IPMI\n", __FUNCTION__)= ); + return EFI_UNSUPPORTED; + } + + Status =3D TransportToken->Transport->Function.Version1_0->TransportStat= us ( + TransportToke= n, + &TransportAdd= itionalStatus + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Transport %s for IPMI has problem - (%r)\n",= __FUNCTION__, mTransportName, Status)); + return Status; + } + + ThisRequestData =3D RequestData; + ThisRequestDataSize =3D RequestDataSize; + IpmiTransportHeader =3D NULL; + IpmiTransportTrailer =3D NULL; + Status =3D SetupIpmiRequestTransportPacket ( + TransportToken, + NetFunction, + Command, + &IpmiTransportHeader, + &ThisRequestData, + &ThisRequestDataSize, + &IpmiTransportTrailer + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Fail to build packets - (%r)\n", __FUNCTION_= _, Status)); + return Status; + } + + ZeroMem (&TransferToken, sizeof (MANAGEABILITY_TRANSFER_TOKEN)); + TransferToken.TransmitHeader =3D IpmiTransportHeader; + TransferToken.TransmitTrailer =3D IpmiTransportTrailer; + + // Transmit packet. + if ((ThisRequestData =3D=3D NULL) || (ThisRequestDataSize =3D=3D 0)) { + + // Transmit parameter were not changed by SetupIpmiRequestTransportPac= ket(). + TransferToken.TransmitPackage.TransmitPayload =3D RequestData; + TransferToken.TransmitPackage.TransmitSizeInByte =3D RequestDataSize; + } else { + TransferToken.TransmitPackage.TransmitPayload =3D ThisRequestData; + TransferToken.TransmitPackage.TransmitSizeInByte =3D ThisRequestDataSi= ze; + } + + TransferToken.TransmitPackage.TransmitTimeoutInMillisecond =3D MANAGEABI= LITY_TRANSPORT_NO_TIMEOUT; + + // Receive packet. + TransferToken.ReceivePackage.ReceiveBuffer =3D ResponseDa= ta; + TransferToken.ReceivePackage.ReceiveSizeInByte =3D *ResponseD= ataSize; + TransferToken.ReceivePackage.TransmitTimeoutInMillisecond =3D MANAGEABIL= ITY_TRANSPORT_NO_TIMEOUT; + TransportToken->Transport->Function.Version1_0->TransportTransmitReceive= ( + TransportToken, + &TransferToken + ); + + if (IpmiTransportHeader !=3D NULL) { + FreePool ((VOID *)IpmiTransportHeader); + } + + if (IpmiTransportTrailer !=3D NULL) { + FreePool ((VOID *)IpmiTransportTrailer); + } + + if (ThisRequestData !=3D NULL) { + FreePool ((VOID *)ThisRequestData); + } + + // Return transfer status. + // + Status =3D TransferToken.TransferStatus; + TransportAdditionalStatus =3D TransferToken.TransportAdditionalStatus; + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Failed to send IPMI command over %s\n", __FU= NCTION__, mTransportName)); + return Status; + } + + *ResponseDataSize =3D TransferToken.ReceivePackage.ReceiveSizeInByte; + return Status; +} diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProto= col.c b/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocol.c new file mode 100644 index 0000000000..6d3720581c --- /dev/null +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocol.c @@ -0,0 +1,177 @@ +/** @file + This file provides IPMI Protocol implementation. + + Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "IpmiProtocolCommon.h" + +MANAGEABILITY_TRANSPORT_TOKEN *mTransportToken =3D NULL; +CHAR16 *mTransportName; + +extern MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION mHardwareInformation; + +/** + This service enables submitting commands via Ipmi. + + @param[in] This This point for IPMI_PROTOCOL struct= ure. + @param[in] NetFunction Net function of the command. + @param[in] Command IPMI Command. + @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 Ipmi Device is not ready for Ipmi command= access. + @retval EFI_DEVICE_ERROR Ipmi 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 allocation is out of resourc= e or data size error. +**/ +EFI_STATUS +EFIAPI +DxeIpmiSubmitCommand ( + IN IPMI_PROTOCOL *This, + IN UINT8 NetFunction, + IN UINT8 Command, + IN UINT8 *RequestData, + IN UINT32 RequestDataSize, + OUT UINT8 *ResponseData, + IN OUT UINT32 *ResponseDataSize + ) +{ + EFI_STATUS Status; + + Status =3D CommonIpmiSubmitCommand ( + mTransportToken, + NetFunction, + Command, + RequestData, + RequestDataSize, + ResponseData, + ResponseDataSize + ); + return Status; +} + +static IPMI_PROTOCOL mIpmiProtocol =3D { + DxeIpmiSubmitCommand +}; + +/** + The entry point of the Ipmi DXE driver. + + @param[in] ImageHandle - Handle of this driver image + @param[in] SystemTable - Table containing standard EFI services + + @retval EFI_SUCCESS - IPMI Protocol is installed successfully. + @retval Otherwise - Other errors. +**/ +EFI_STATUS +EFIAPI +DxeIpmiEntry ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_HANDLE Handle; + MANAGEABILITY_TRANSPORT_CAPABILITY TransportCapability; + MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS TransportAdditionalStatus; + + GetTransportCapability (&TransportCapability); + + Status =3D HelperAcquireManageabilityTransport ( + &gManageabilityProtocolIpmiGuid, + &mTransportToken + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Failed to acquire transport interface for IP= MI protocol - %r\n", __FUNCTION__, Status)); + return Status; + } + + mTransportName =3D HelperManageabilitySpecName (mTransportToken->Transpo= rt->ManageabilityTransportSpecification); + DEBUG ((DEBUG_ERROR, "%a: IPMI protocol over %s.\n", __FUNCTION__, mTran= sportName)); + + // + // Setup hardware information according to the transport interface. + Status =3D SetupIpmiTransportHardwareInformation ( + mTransportToken, + &mHardwareInformation + ); + if (EFI_ERROR (Status)) { + if (Status =3D=3D EFI_UNSUPPORTED) { + DEBUG ((DEBUG_ERROR, "%a: No hardware information of %s transport in= terface.\n", __FUNCTION__, mTransportName)); + } + + return Status; + } + + // + // Initial transport interface with the hardware information assigned. + Status =3D HelperInitManageabilityTransport ( + mTransportToken, + mHardwareInformation, + &TransportAdditionalStatus + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Handle =3D NULL; + Status =3D gBS->InstallProtocolInterface ( + &Handle, + &gIpmiProtocolGuid, + EFI_NATIVE_INTERFACE, + (VOID **)&mIpmiProtocol + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Failed to install IPMI protocol - %r\n", __F= UNCTION__, Status)); + } + + return Status; +} + +/** + This is the unload handler for IPMI protocol module. + + Release the MANAGEABILITY_TRANSPORT_TOKEN acquired at entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +IpmiUnloadImage ( + IN EFI_HANDLE ImageHandle + ) +{ + EFI_STATUS Status; + + Status =3D EFI_SUCCESS; + if (mTransportToken !=3D NULL) { + Status =3D ReleaseTransportSession (mTransportToken); + } + + if (mHardwareInformation.Pointer !=3D NULL) { + FreePool (mHardwareInformation.Pointer); + } + + return Status; +} diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpi.c= b/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpi.c new file mode 100644 index 0000000000..f31dbc9f4d --- /dev/null +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpi.c @@ -0,0 +1,151 @@ +/** @file + This file provides IPMI PPI implementation. + + Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "IpmiProtocolCommon.h" + +MANAGEABILITY_TRANSPORT_TOKEN *mTransportToken =3D NULL; +CHAR16 *mTransportName; + +extern MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION mHardwareInformation; + +/** + This service enables submitting commands via Ipmi. + + @param[in] This This point for PEI_IPMI_PPI structu= re. + @param[in] NetFunction Net function of the command. + @param[in] Command IPMI Command. + @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 Ipmi Device is not ready for Ipmi command= access. + @retval EFI_DEVICE_ERROR Ipmi 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 allocation is out of resourc= e or data size error. +**/ +EFI_STATUS +EFIAPI +PeiIpmiSubmitCommand ( + IN PEI_IPMI_PPI *This, + IN UINT8 NetFunction, + IN UINT8 Command, + IN UINT8 *RequestData, + IN UINT32 RequestDataSize, + OUT UINT8 *ResponseData, + IN OUT UINT32 *ResponseDataSize + ) +{ + EFI_STATUS Status; + + Status =3D CommonIpmiSubmitCommand ( + mTransportToken, + NetFunction, + Command, + RequestData, + RequestDataSize, + ResponseData, + ResponseDataSize + ); + return Status; +} + +static PEI_IPMI_PPI mPeiIpmiPpi =3D { + PeiIpmiSubmitCommand +}; + +static EFI_PEI_PPI_DESCRIPTOR mIpmiPpiList[] =3D { + { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gPeiIpmiPpiGuid, + &mPeiIpmiPpi + } +}; + +/** + The entry point of the Ipmi PPI PEIM. + + @param FileHandle Handle of the file being invoked. + @param PeiServices Describes the list of possible PEI Services. + + @retval EFI_SUCCESS Indicates that Ipmi initialization completed succe= ssfully. + @retval Others Indicates that Ipmi initialization could not compl= ete successfully. +**/ +EFI_STATUS +EFIAPI +PeiIpmiEntry ( + IN EFI_PEI_FILE_HANDLE FileHandle, + IN CONST EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_STATUS Status; + MANAGEABILITY_TRANSPORT_CAPABILITY TransportCapability; + MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS TransportAdditionalStatus; + + GetTransportCapability (&TransportCapability); + + Status =3D HelperAcquireManageabilityTransport ( + &gManageabilityProtocolIpmiGuid, + &mTransportToken + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Failed to acquire transport interface for IP= MI protocol - %r\n", __FUNCTION__, Status)); + return Status; + } + + mTransportName =3D HelperManageabilitySpecName (mTransportToken->Transpo= rt->ManageabilityTransportSpecification); + DEBUG ((DEBUG_ERROR, "%a: IPMI protocol over %s.\n", __FUNCTION__, mTran= sportName)); + + // + // Setup hardware information according to the transport interface. + Status =3D SetupIpmiTransportHardwareInformation ( + mTransportToken, + &mHardwareInformation + ); + if (EFI_ERROR (Status)) { + if (Status =3D=3D EFI_UNSUPPORTED) { + DEBUG ((DEBUG_ERROR, "%a: No hardware information of %s transport in= terface.\n", __FUNCTION__, mTransportName)); + } + + return Status; + } + + // + // Initial transport interface with the hardware information assigned. + Status =3D HelperInitManageabilityTransport ( + mTransportToken, + mHardwareInformation, + &TransportAdditionalStatus + ); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Install IPMI PPI. + // + Status =3D PeiServicesInstallPpi (&mIpmiPpiList[0]); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Failed to install IPMI PPI - %r\n", __FUNCTI= ON__, Status)); + } + + return Status; +} diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProto= col.c b/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocol.c new file mode 100644 index 0000000000..227f6f7114 --- /dev/null +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocol.c @@ -0,0 +1,147 @@ +/** @file + This file provides IPMI SMM Protocol implementation. + + Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "IpmiProtocolCommon.h" + +MANAGEABILITY_TRANSPORT_TOKEN *mTransportToken =3D NULL; +CHAR16 *mTransportName; + +extern MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION mHardwareInformation; + +/** + This service enables submitting commands via Ipmi. + + @param[in] This This point for IPMI_PROTOCOL struct= ure. + @param[in] NetFunction Net function of the command. + @param[in] Command IPMI Command. + @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 Ipmi Device is not ready for Ipmi command= access. + @retval EFI_DEVICE_ERROR Ipmi 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 allocation is out of resourc= e or data size error. +**/ +EFI_STATUS +EFIAPI +SmmIpmiSubmitCommand ( + IN IPMI_PROTOCOL *This, + IN UINT8 NetFunction, + IN UINT8 Command, + IN UINT8 *RequestData, + IN UINT32 RequestDataSize, + OUT UINT8 *ResponseData, + IN OUT UINT32 *ResponseDataSize + ) +{ + EFI_STATUS Status; + + Status =3D CommonIpmiSubmitCommand ( + mTransportToken, + NetFunction, + Command, + RequestData, + RequestDataSize, + ResponseData, + ResponseDataSize + ); + return Status; +} + +static IPMI_PROTOCOL mIpmiProtocol =3D { + SmmIpmiSubmitCommand +}; + +/** + The entry point of the Ipmi DXE driver. + + @param[in] ImageHandle - Handle of this driver image + @param[in] SystemTable - Table containing standard EFI services + + @retval EFI_SUCCESS - IPMI Protocol is installed successfully. + @retval Otherwise - Other errors. +**/ +EFI_STATUS +EFIAPI +SmmIpmiEntry ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_HANDLE Handle; + MANAGEABILITY_TRANSPORT_CAPABILITY TransportCapability; + MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS TransportAdditionalStatus; + + GetTransportCapability (&TransportCapability); + + Status =3D HelperAcquireManageabilityTransport ( + &gManageabilityProtocolIpmiGuid, + &mTransportToken + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Failed to acquire transport interface for IP= MI protocol - %r\n", __FUNCTION__, Status)); + return Status; + } + + mTransportName =3D HelperManageabilitySpecName (mTransportToken->Transpo= rt->ManageabilityTransportSpecification); + DEBUG ((DEBUG_ERROR, "%a: IPMI protocol over %s.\n", __FUNCTION__, mTran= sportName)); + + // + // Setup hardware information according to the transport interface. + Status =3D SetupIpmiTransportHardwareInformation ( + mTransportToken, + &mHardwareInformation + ); + if (EFI_ERROR (Status)) { + if (Status =3D=3D EFI_UNSUPPORTED) { + DEBUG ((DEBUG_ERROR, "%a: No hardware information of %s transport in= terface.\n", __FUNCTION__, mTransportName)); + } + + return Status; + } + + // + // Initial transport interface with the hardware information assigned. + Status =3D HelperInitManageabilityTransport ( + mTransportToken, + mHardwareInformation, + &TransportAdditionalStatus + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Handle =3D NULL; + Status =3D gSmst->SmmInstallProtocolInterface ( + &Handle, + &gSmmIpmiProtocolGuid, + EFI_NATIVE_INTERFACE, + (VOID **)&mIpmiProtocol + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Failed to install IPMI SMM protocol - %r\n",= __FUNCTION__, Status)); + } + + return Status; +} --=20 2.37.1.windows.1