From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.107.237.41]) by mx.groups.io with SMTP id smtpd.web10.87699.1675786987368336294 for ; Tue, 07 Feb 2023 08:23:07 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=BLVK1FoS; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.237.41, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IXU7q+WRqIRk9Gru1cBL+DTOFeHOA+zex0TwQyh3kDelG2uibQ6rloUroZU+KwSiX8m5n3+Jb93t6cZ/JSCDTBQch+YrJICNAYDZW8M+NUcUJ9kCtBs1A+UanR/UDC4jGIs70t2pufmPXumyOk++peeT7o+GVrMgJoBUotaQuj7rE9fVko9NJ2rvACeQRNth/UNVapX184/7k3JHabIgIexKuKvfbwq95JzQA9+/A6Qkd4y1wZWNVmW+VMaxoo0+OHHveWYNCyMiwBT5XJxa2/g9M7Ypaw9PltXT6UjghDu9b21zNyWEXsGslovXWa8F+yxMeFqMKUWDrnjg2ru2yg== 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=lrIWwafRzq95HYtL2l5BkSMOrtDHl+yDaktl8sfvNtY=; b=B9ovOWjBF31J6TlOAlqTQ4ibbMPF13h8pFTeNvtdg8HTczFFt4KbBURNrFsflVXDGwYRFcOLbgalmZZ9AQOl6zerI89i2xilJGPphvCx4sJxHFGC0ApadOPFwzWxZQt7BfARD69NZ7lRUBQW9OuxqWRYJIrqfjsHxr1qjnuFTmlNJH6GIoZsODxrpXGsqq3WSZQIjn5yUFTDTrYQpzqY5GLrOXvj4sRdHFzejN0Wm3iBojCNMQVRgldQC7EsLA9tjX2bbsSHaRDloZs8kB/VU+W8UQL4/LHiKkTnvHQ5iL32nB1Txuapfx/AxnpXXqEQaeFpa9rwa4Yf+UxofdCFtA== 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=lrIWwafRzq95HYtL2l5BkSMOrtDHl+yDaktl8sfvNtY=; b=BLVK1FoSMytnFuGtzohmWZ3tn/SMelh2LhyiWNT+NB06NkzJhuoJ1s2fsVrev79NtOkARpjFzM0dL7pYGFQHryC0s/SQsXYHzfRs9UwTqPMpA0VZAN2NKt6bPz5SwjR3q2xySeVQzi/T9LmvCaFdkb8IL4Ojv46icK8m8Al4wi4= Received: from MW4P221CA0012.NAMP221.PROD.OUTLOOK.COM (2603:10b6:303:8b::17) by IA1PR12MB6330.namprd12.prod.outlook.com (2603:10b6:208:3e4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.25; Tue, 7 Feb 2023 16:23:04 +0000 Received: from CO1NAM11FT037.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8b:cafe::af) by MW4P221CA0012.outlook.office365.com (2603:10b6:303:8b::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.36 via Frontend Transport; Tue, 7 Feb 2023 16:23:04 +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 CO1NAM11FT037.mail.protection.outlook.com (10.13.174.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6086.16 via Frontend Transport; Tue, 7 Feb 2023 16:23:04 +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, 7 Feb 2023 10:22:59 -0600 From: "Chang, Abner" To: CC: Liming Gao , Isaac Oram , Nate DeSimone , Abdul Lateef Attar , Nickle Wang , "Igor Kulchytskyy" Subject: [edk2-platforms][PATCH 5/7] ManageabilityPkg: Implement Ipmi Protocol/Ppi Date: Wed, 8 Feb 2023 00:22:34 +0800 Message-ID: <20230207162236.1406-6-abner.chang@amd.com> X-Mailer: git-send-email 2.37.1.windows.1 In-Reply-To: <20230207162236.1406-1-abner.chang@amd.com> References: <20230207162236.1406-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: CO1NAM11FT037:EE_|IA1PR12MB6330:EE_ X-MS-Office365-Filtering-Correlation-Id: fce1c42d-63c4-4183-1494-08db092796df X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mNZLAD92FXqvFK0mi5kvwOqEEi6+TPVBk11baCj3rtIyBcsTQ3wvJFurstJvp15W6uvupocS4J952h4a/1AH5VCgN0TtbIQjQeJJvJEM3mAuOIyhGLLMD2phaG9Qpz2gsGHJH4c9TWfk5DSw4N6EdS/nM1/UFyUNzfKgzOqeQoBYjBRhGG9JABrE+OrOCFI5QIzv64SMatflKyF5HtWbRRFsbXvD7+XBaUYrewRq+dSq5piAfUkxGpQLF7MDoT+0gRQiDZvgjU3B0NUVL3a8Qoc3cx1t3z0+edQS3lvMaXFWXYQT/evJ4cz1nO8heS/DJ/44yMrNqsoT+tFVeg2tQ8fUktUzcRwrt+RE+Ho5GIgvUob+YRkOI/uZLZKuMim/7jiingu+WTInzyARI6JKOqbC/0PNKcpor6xq0BuJbtUcMEZNrtqe9oydPs5llsYjEkV+O8AKhJKq3bjLXKSRjem+6LHty990YOfCGblRTns3vyuqCrOTEZEHIDmG05CgIHAwLtNorgZtMzRmrMe2DaogVADSCSKtNSBVnFM12fEVJOyflbJ3Au8QsnGl8dUZciwUwGedGPeo8VcjsgAPe/wmqSL4GeA4cr2zyMlUPs0ofH0AoI9Muo+AQ26w7Kai848CZdTNw/D7nHLGI6YNYKgPv1QzWp22UxGPMePXGHz932r7FPxmL8K31QpQ5besNtfbewe/xLu4vDsxy1XAIzYcrmKS01jDOcnE570TgYQ= 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)(376002)(136003)(39860400002)(396003)(346002)(451199018)(46966006)(40470700004)(36840700001)(47076005)(4326008)(70206006)(16526019)(6916009)(336012)(70586007)(41300700001)(82310400005)(8936002)(2616005)(8676002)(26005)(82740400003)(186003)(81166007)(83380400001)(426003)(356005)(40460700003)(316002)(478600001)(1076003)(36860700001)(30864003)(36756003)(2876002)(7696005)(2906002)(86362001)(40480700001)(6666004)(5660300002)(54906003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2023 16:23:04.0915 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fce1c42d-63c4-4183-1494-08db092796df 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: CO1NAM11FT037.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6330 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain From: Abner Chang Add Ipmi Protocol/Ppi implementation. The underlying implementation is provided by IpmiBaseLib. 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 | 37 +++++++ .../Universal/IpmiProtocol/Pei/IpmiPpiPei.inf | 38 +++++++ .../IpmiProtocol/Smm/IpmiProtocolSmm.inf | 40 +++++++ .../Universal/IpmiProtocol/Dxe/IpmiProtocol.c | 97 +++++++++++++++++ .../Universal/IpmiProtocol/Pei/IpmiPpi.c | 102 ++++++++++++++++++ .../Universal/IpmiProtocol/Smm/IpmiProtocol.c | 98 +++++++++++++++++ 6 files changed, 412 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/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..0737a5ad8f --- /dev/null +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocolDxe.= inf @@ -0,0 +1,37 @@ +## @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 IpmiEntry + +# +# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 +# + +[Sources] + IpmiProtocol.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + IpmiFeaturePkg/IpmiFeaturePkg.dec + +[LibraryClasses] + IpmiBaseLib + UefiDriverEntryPoint + UefiBootServicesTableLib + +[Protocols] + gIpmiProtocolGuid # PROTOCOL ALWAYS_PRODUCED + +[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..7ba8584f84 --- /dev/null +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpiPei.inf @@ -0,0 +1,38 @@ +## @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 IpmiEntry + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 +# + +[Sources] + IpmiPpi.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + IpmiFeaturePkg/IpmiFeaturePkg.dec + +[LibraryClasses] + IpmiBaseLib + PeimEntryPoint + +[Ppis] + gPeiIpmiPpiGuid # PPI ALWAYS PRODUCED + +[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..25a5771cb3 --- /dev/null +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocolSmm.= inf @@ -0,0 +1,40 @@ +## @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 IpmiEntry + +[Sources] + IpmiProtocol.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + IpmiFeaturePkg/IpmiFeaturePkg.dec + +[LibraryClasses] + IpmiBaseLib + UefiDriverEntryPoint + UefiBootServicesTableLib + SmmServicesTableLib + +[Protocols] + gSmmIpmiProtocolGuid # PROTOCOL ALWAYS_PRODUCED + +[Depex] + TRUE 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..1f0b88052e --- /dev/null +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocol.c @@ -0,0 +1,97 @@ +/** @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 + +/** + 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 allcation is out of resource= or data size error. +**/ +EFI_STATUS +EFIAPI +IpmiSubmitCommand ( + 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 IpmiSendCommand ( + NetFunction, + Command, + RequestData, + RequestDataSize, + ResponseData, + ResponseDataSize + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Failed to send IPMI command in DXE - %r\n", = __FUNCTION__, Status)); + } + + return Status; +} + +static IPMI_PROTOCOL mIpmiProtocol =3D { + IpmiSubmitCommand +}; + +/** + 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 +IpmiEntry ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_HANDLE Handle; + + 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; +} diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpi.c= b/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpi.c new file mode 100644 index 0000000000..913a9b0811 --- /dev/null +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpi.c @@ -0,0 +1,102 @@ +/** @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 + +/** + 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 allcation is out of resource= or data size error. +**/ +EFI_STATUS +EFIAPI +IpmiSubmitCommand ( + 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 IpmiSendCommand ( + NetFunction, + Command, + RequestData, + RequestDataSize, + ResponseData, + ResponseDataSize + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Failed to send IPMI command in PEI- %r\n", _= _FUNCTION__, Status)); + } + + return Status; +} + +static PEI_IPMI_PPI mPeiIpmiPpi =3D { + IpmiSubmitCommand +}; + +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 +IpmiEntry ( + IN EFI_PEI_FILE_HANDLE FileHandle, + IN CONST EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_STATUS 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..ed14f9fbd1 --- /dev/null +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocol.c @@ -0,0 +1,98 @@ +/** @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 + +/** + 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 allcation is out of resource= or data size error. +**/ +EFI_STATUS +EFIAPI +IpmiSubmitCommand ( + 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 IpmiSendCommand ( + NetFunction, + Command, + RequestData, + RequestDataSize, + ResponseData, + ResponseDataSize + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Failed to send IPMI command in DXE - %r\n", = __FUNCTION__, Status)); + } + + return Status; +} + +static IPMI_PROTOCOL mIpmiProtocol =3D { + IpmiSubmitCommand +}; + +/** + 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 +IpmiEntry ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_HANDLE Handle; + + 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