From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 5B68174003A for ; Tue, 31 Oct 2023 06:23:56 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=y73q3Vaq+6A3l1L/Z9DxruLd3Br9BuOrXl3xTvFHBZo=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1698733434; v=1; b=sCIanehl4z+UaSG5W8TIiyDiolvyvExKgGYeDzT9BLL799HgOMbMCB/RphgA54XgHykZ0CA4 WFn4jCvOApzkxi6bQxes/N7W8hUZiz1EUE3bDoJEKIHy3q4lqQZRUg10xE9N7ATGw4MHmbnYkJ8 jiU7lxOKzLVwMGI6CrZPZY/w= X-Received: by 127.0.0.2 with SMTP id fnbgYY7687511xT5YiqT2PKU; Mon, 30 Oct 2023 23:23:54 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) by mx.groups.io with SMTP id smtpd.web11.180796.1698733434276961639 for ; Mon, 30 Oct 2023 23:23:54 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10879"; a="1071647" X-IronPort-AV: E=Sophos;i="6.03,265,1694761200"; d="scan'208";a="1071647" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2023 23:23:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10879"; a="826300307" X-IronPort-AV: E=Sophos;i="6.03,265,1694761200"; d="scan'208";a="826300307" X-Received: from lixiahua-desk2.ccr.corp.intel.com ([10.239.55.96]) by fmsmga008.fm.intel.com with ESMTP; 30 Oct 2023 23:23:39 -0700 From: "Huang, Li-Xia" To: devel@edk2.groups.io Cc: Abner Chang , Nate DeSimone Subject: [edk2-devel] [PATCH v4 1/1] IpmiFeaturePkg/GenericIpmi: Support Standalone MM Date: Tue, 31 Oct 2023 14:23:38 +0800 Message-Id: <20231031062338.1501-1-lisa.huang@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lisa.huang@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: cPOsduI66txCqoqh1WyFBgMUx7686176AA= Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=sCIanehl; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Add Standalone Mm Generic Impi driver. And add type 'PcdsFixedAtBuild' for PcdIpmiSmmIoBaseAddress to access in StandaloneMm driver Cc: Abner Chang Cc: Nate DeSimone Signed-off-by: Lixia Huang --- Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c | 146 ++++++++++++++++++++ Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.inf | 51 +++++++ Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec | 2 + 3 files changed, 199 insertions(+) diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c new file mode 100644 index 000000000000..d808e2517c99 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c @@ -0,0 +1,146 @@ +/** @file + Generic StandaloneMm IPMI stack driver + + Copyright 2023 Intel Corporation.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +// +// Statements that include other files +// +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "IpmiHooks.h" +#include "IpmiBmcCommon.h" +#include "IpmiBmc.h" + +IPMI_BMC_INSTANCE_DATA *mIpmiInstance; +EFI_HANDLE mHandle; + +/** +Routine Description: + Setup and initialize the BMC for the SMM phase. In order to verify the BMC is functioning + as expected, the BMC Selftest is performed. The results are then checked and any errors are + reported to the error manager. Errors are collected throughout this routine and reported + just prior to installing the driver. If there are more errors than MAX_SOFT_COUNT, then they + will be ignored. + +Arguments: + ImageHandle - Handle of this driver image + SystemTable - Table containing standard EFI services + +Returns: + EFI_SUCCESS - Successful driver initialization + +**/ +EFI_STATUS +SmmInitializeIpmiKcsPhysicalLayer ( + VOID + ) +{ + EFI_STATUS Status; + + DEBUG ((DEBUG_INFO,"SmmInitializeIpmiKcsPhysicalLayer entry \n")); + + Status = gMmst->MmAllocatePool ( + EfiRuntimeServicesData, + sizeof (IPMI_BMC_INSTANCE_DATA), + (VOID **)&mIpmiInstance); + + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "mIpmiInstance mem alloc failed - 0x%x\n", Status)); + return Status; + } else { + + // + // Initialize the KCS transaction timeout. Assume delay unit is 1000 us. + // + mIpmiInstance->KcsTimeoutPeriod = (BMC_KCS_TIMEOUT * 1000*1000) / KCS_DELAY_UNIT; + + // + // Initialize IPMI IO Base, we still use SMS IO base to get device ID and Seltest result since SMM IF may have different cmds supported + // + mIpmiInstance->IpmiIoBase = FixedPcdGet16 (PcdIpmiSmmIoBaseAddress); + mIpmiInstance->Signature = SM_IPMI_BMC_SIGNATURE; + mIpmiInstance->SlaveAddress = BMC_SLAVE_ADDRESS; + mIpmiInstance->BmcStatus = BMC_NOTREADY; + mIpmiInstance->IpmiTransport.IpmiSubmitCommand = IpmiSendCommand; + mIpmiInstance->IpmiTransport.GetBmcStatus = IpmiGetBmcStatus; + + mHandle = NULL; + Status = gMmst->MmInstallProtocolInterface ( + &mHandle, + &gSmmIpmiTransportProtocolGuid, + EFI_NATIVE_INTERFACE, + &mIpmiInstance->IpmiTransport + ); + ASSERT_EFI_ERROR (Status); + + DEBUG ((DEBUG_INFO,"SmmInitializeIpmiKcsPhysicalLayer exit \n")); + + return EFI_SUCCESS; + } +} + +/** + The module Entry Point of driver. + + @param[in] ImageHandle The firmware allocated handle for the EFI image. + @param[in] SystemTable A pointer to the MM System Table. + + @retval EFI_SUCCESS The entry point is executed successfully. + @retval Other Some error occurs when executing this entry point. + +**/ +EFI_STATUS +InitializeGenericIpmiStandaloneMm ( + IN EFI_HANDLE ImageHandle, + IN EFI_MM_SYSTEM_TABLE *SystemTable + ) +{ + SmmInitializeIpmiKcsPhysicalLayer (); + return EFI_SUCCESS; +} + +/** + Unloads an image. + + @param[in] ImageHandle Handle that identifies the image to be unloaded. + + @retval EFI_SUCCESS The image has been unloaded. + @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle. + +**/ +EFI_STATUS +EFIAPI +GenericIpmiStandaloneMmUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + EFI_STATUS Status; + + Status = EFI_SUCCESS; + if (mIpmiInstance != NULL) { + if (mHandle != NULL) { + Status = gMmst->MmUninstallProtocolInterface ( + mHandle, + &gSmmIpmiTransportProtocolGuid, + &mIpmiInstance->IpmiTransport + ); + ASSERT_EFI_ERROR (Status); + } + gMmst->MmFreePool (mIpmiInstance); + } + + return Status; +} diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.inf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.inf new file mode 100644 index 000000000000..170e0a8d136b --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.inf @@ -0,0 +1,51 @@ +## @file +# StandaloneMm Generic IPMI SMM Driver. +# +# Copyright 2023 Intel Corporation.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION = 0x00010017 + BASE_NAME = StandaloneMmGenericIpmi + FILE_GUID = 6899c3ea-0920-414f-9555-ad2f00f81060 + MODULE_TYPE = MM_STANDALONE + VERSION_STRING = 1.0 + PI_SPECIFICATION_VERSION = 0x00010032 + ENTRY_POINT = InitializeGenericIpmiStandaloneMm + UNLOAD_IMAGE = GenericIpmiStandaloneMmUnload + +[Sources] + ../Common/IpmiHooks.h + ../Common/IpmiHooks.c + ../Common/IpmiBmcCommon.h + ../Common/KcsBmc.c + ../Common/KcsBmc.h + ../Common/IpmiBmc.c + ../Common/IpmiBmc.h + StandaloneMmGenericIpmi.c + +[Packages] + MdePkg/MdePkg.dec + IpmiFeaturePkg/IpmiFeaturePkg.dec + +[LibraryClasses] + MemoryAllocationLib + BaseLib + MmServicesTableLib + DebugLib + StandaloneMmDriverEntryPoint + IoLib + ReportStatusCodeLib + TimerLib + +[Protocols] + gSmmIpmiTransportProtocolGuid # PROTOCOL ALWAYS_PRODUCED + +[Guids] + +[Pcd] + gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiSmmIoBaseAddress + +[Depex] + gIpmiTransportProtocolGuid diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec index 5df71300cbd1..73dca30caae9 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec @@ -129,4 +129,6 @@ gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiIoBaseAddress|0xCA2|UINT16|0xD0000003 gIpmiFeaturePkgTokenSpaceGuid.PcdSioMailboxBaseAddress|0x600|UINT32|0xD0000004 gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiBmcReadyDelayTimer|120|UINT8|0xD0000005 + +[PcdsFixedAtBuild, PcdsDynamic, PcdsDynamicEx] gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiSmmIoBaseAddress|0xCA2|UINT16|0xD0000006 -- 2.26.2.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#110371): https://edk2.groups.io/g/devel/message/110371 Mute This Topic: https://groups.io/mt/102292409/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-