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 A9773941E7B for ; Fri, 27 Oct 2023 22:38:04 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=pYTrQoxsbUPq1awz60HZEDXK9L1Qv9cQgMhKj9Onsx0=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: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=1698446283; v=1; b=m70BFpYkTCg53/AIQdlXruU/6VCh1ldG+K06eGj9iZY8J3wI/haDPVlaJz5Vnn1rY6bV+RyY Os0q668ONwB7NOY1zux0I7G2NAzUAMKs6K6Tj/ZYfqi2nHwSCyMg7IN9fNASaPTg/5JbNBlAeVL M4sSAYuGO6twZLz/OhX+lwjM= X-Received: by 127.0.0.2 with SMTP id JnuoYY7687511xbpvcjv0s8e; Fri, 27 Oct 2023 15:38:03 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web10.16429.1698437520175802004 for ; Fri, 27 Oct 2023 13:12:04 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10876"; a="372897524" X-IronPort-AV: E=Sophos;i="6.03,257,1694761200"; d="scan'208";a="372897524" X-Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2023 13:12:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.03,257,1694761200"; d="scan'208";a="948627" X-Received: from scsrds0181.amr.corp.intel.com ([10.116.50.7]) by fmviesa002.fm.intel.com with ESMTP; 27 Oct 2023 13:11:52 -0700 From: Zhen Gong To: devel@edk2.groups.io Cc: Zhen Gong Subject: [edk2-devel] [PATCH edk2-platforms 3/4] IpmiFeaturePkg: Add ACPI power state drivers Date: Fri, 27 Oct 2023 13:11:15 -0700 Message-Id: <5518582e9e3665c3a474b1e65980ed0c12123243.1698437221.git.zhen.gong@intel.com> In-Reply-To: References: 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,zhen.gong@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: dOMJ6WXuzxKJXfdTrptZWBBIx7686176AA= 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=m70BFpYk; 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 DXE and SMM drivers that send "Set ACPI Power State" command to BMC. Signed-off-by: Zhen Gong --- .../IpmiFeaturePkg/IpmiFeaturePkg.dec | 1 + .../IpmiFeaturePkg/Include/IpmiFeature.dsc | 2 + .../IpmiFeaturePkg/Include/PostMemory.fdf | 2 + .../BmcAcpiState/BmcAcpiState.inf | 40 ++++ .../BmcAcpiSwChild/BmcAcpiSwChild.inf | 39 ++++ .../BmcAcpiState/BmcAcpiState.h | 26 +++ .../BmcAcpiSwChild/BmcAcpiSwChild.h | 82 ++++++++ .../Include/Protocol/BmcAcpiSwChildPolicy.h | 31 +++ .../BmcAcpiState/BmcAcpiState.c | 93 +++++++++ .../BmcAcpiSwChild/BmcAcpiSwChild.c | 189 ++++++++++++++++++ 10 files changed, 505 insertions(+) create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/BmcAcpiState/BmcAcpiState.inf create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/BmcAcpiSwChild/BmcAcpiSwChild.inf create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/BmcAcpiState/BmcAcpiState.h create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/BmcAcpiSwChild/BmcAcpiSwChild.h create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Protocol/BmcAcpiSwChildPolicy.h create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/BmcAcpiState/BmcAcpiState.c create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/BmcAcpiSwChild/BmcAcpiSwChild.c diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec index 22bc4e69be8a..be0a11e2adb1 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec @@ -75,6 +75,7 @@ [Protocols] gEfiVideoPrintProtocolGuid = {0x3dbf3e06, 0x9d0c, 0x40d3, {0xb2, 0x17, 0x45, 0x5f, 0x33, 0x9e, 0x29, 0x09}} gIpmiTransport2ProtocolGuid = { 0x4A1D0E66, 0x5271, 0x4E22, { 0x83, 0xFE, 0x90, 0x92, 0x1B, 0x74, 0x82, 0x13 }} gSmmIpmiTransport2ProtocolGuid = { 0x1DBD1503, 0x0A60, 0x4230, { 0xAA, 0xA3, 0x80, 0x16, 0xD8, 0xC3, 0xDE, 0x2F }} + gEfiBmcAcpiSwChildPolicyProtocolGuid = { 0x89843c0b, 0x5701, 0x4ff6, { 0xa4, 0x73, 0x65, 0x75, 0x99, 0x04, 0xf7, 0x35 } } gEfiGenericElogProtocolGuid = { 0x59d02fcd, 0x9233, 0x4d34, { 0xbc, 0xfe, 0x87, 0xca, 0x81, 0xd3, 0xdd, 0xa7 } } gSmmGenericElogProtocolGuid = { 0x664ef1f6, 0x19bf, 0x4498, { 0xab, 0x6a, 0xfc, 0x05, 0x72, 0xfb, 0x98, 0x51 } } gEfiRedirElogProtocolGuid = { 0x16d11030, 0x71ba, 0x4e5e, { 0xa9, 0xf9, 0xb4, 0x75, 0xa5, 0x49, 0x4, 0x8a } } diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/IpmiFeature.dsc b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/IpmiFeature.dsc index fc9001e98473..7e663236d9a1 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/IpmiFeature.dsc +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/IpmiFeature.dsc @@ -122,6 +122,8 @@ [Components.X64] IpmiFeaturePkg/GenericIpmi/Dxe/GenericIpmi.inf IpmiFeaturePkg/Library/SmmIpmiBaseLib/SmmIpmiBaseLib.inf IpmiFeaturePkg/BmcAcpi/BmcAcpi.inf + IpmiFeaturePkg/BmcAcpiState/BmcAcpiState.inf + IpmiFeaturePkg/BmcAcpiSwChild/BmcAcpiSwChild.inf IpmiFeaturePkg/BmcElog/DxeBmcElog.inf IpmiFeaturePkg/BmcElog/SmmBmcElog.inf IpmiFeaturePkg/GenericElog/Dxe/GenericElog.inf diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/PostMemory.fdf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/PostMemory.fdf index f29810bc0b34..9b692f07dcd8 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/PostMemory.fdf +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/PostMemory.fdf @@ -10,6 +10,8 @@ INF IpmiFeaturePkg/GenericIpmi/Dxe/GenericIpmi.inf INF IpmiFeaturePkg/IpmiInit/DxeIpmiInit.inf INF RuleOverride = DRIVER_ACPITABLE IpmiFeaturePkg/BmcAcpi/BmcAcpi.inf +INF IpmiFeaturePkg/BmcAcpiState/BmcAcpiState.inf +INF IpmiFeaturePkg/BmcAcpiSwChild/BmcAcpiSwChild.inf INF IpmiFeaturePkg/BmcElog/DxeBmcElog.inf INF IpmiFeaturePkg/BmcElog/SmmBmcElog.inf INF IpmiFeaturePkg/Frb/FrbDxe.inf diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/BmcAcpiState/BmcAcpiState.inf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/BmcAcpiState/BmcAcpiState.inf new file mode 100644 index 000000000000..f1b750d6a20a --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/BmcAcpiState/BmcAcpiState.inf @@ -0,0 +1,40 @@ +### @file +# +# Copyright (c) 2023, Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +### + + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = BmcAcpiState + FILE_GUID = 04103e59-48cc-417a-baec-9929c69c20f6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = BmcAcpiStateEntryPoint + +[Sources] + BmcAcpiState.c + BmcAcpiState.h + +[Packages] + IpmiFeaturePkg/IpmiFeaturePkg.dec + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + DebugLib + UefiDriverEntryPoint + UefiBootServicesTableLib + IpmiBaseLib + +[Protocols] + gIpmiTransportProtocolGuid + +[Guids] + gEfiEventExitBootServicesGuid ## CONSUMES ## Event + +[Depex] + gIpmiTransportProtocolGuid diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/BmcAcpiSwChild/BmcAcpiSwChild.inf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/BmcAcpiSwChild/BmcAcpiSwChild.inf new file mode 100644 index 000000000000..59a9f77d9f10 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/BmcAcpiSwChild/BmcAcpiSwChild.inf @@ -0,0 +1,39 @@ +### @file +# +# Copyright (c) 2023, Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +### + + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = BmcAcpiSwChild + FILE_GUID = BB5BEBD1-CE71-4cd0-9E2F-C07886502661 + MODULE_TYPE = DXE_SMM_DRIVER + PI_SPECIFICATION_VERSION = 0x0001000A + VERSION_STRING = 1.0 + ENTRY_POINT = InitializeBmcAcpiSwChild + +[Sources] + BmcAcpiSwChild.c + BmcAcpiSwChild.h + +[Packages] + IpmiFeaturePkg/IpmiFeaturePkg.dec + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + UefiDriverEntryPoint + DebugLib + SmmServicesTableLib + ServerManagementLib + IpmiBaseLib + +[Protocols] + gEfiBmcAcpiSwChildPolicyProtocolGuid # PROTOCOL ALWAYS_PRODUCED + +[Depex] + gSmmIpmiTransportProtocolGuid diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/BmcAcpiState/BmcAcpiState.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/BmcAcpiState/BmcAcpiState.h new file mode 100644 index 000000000000..4352652a2bda --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/BmcAcpiState/BmcAcpiState.h @@ -0,0 +1,26 @@ +/** @file + +Copyright (c) 2023, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef _ACPI_BMC_STATE_H_ +#define _ACPI_BMC_STATE_H_ + +// +// Statements that include other header files +// +#include +#include +#include +#include +#include +#include +#include +#include +#include + +EFI_EVENT mExitBootServicesEvent = NULL; + +#endif diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/BmcAcpiSwChild/BmcAcpiSwChild.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/BmcAcpiSwChild/BmcAcpiSwChild.h new file mode 100644 index 000000000000..10d687ed2b84 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/BmcAcpiSwChild/BmcAcpiSwChild.h @@ -0,0 +1,82 @@ +/** @file + This driver produces the ACPI enable and disable SMI handlers. + +Copyright (c) 2023, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef _BMC_ACPI_SW_CHILD_H_ +#define _BMC_ACPI_SW_CHILD_H_ + +// +// Statements that include other files +// +#include +#include +#include +#include +#include +#include +#include + +#include "ServerManagement.h" + +#include +#include +#include +#include +#include + +// +// Module prototypes +// + +/** + This is the standard EFI driver entrypoint. This function initializes + the BMC ACPI SW Child protocol. + + @param ImageHandle - ImageHandle of the loaded driver + @param SystemTable - Pointer to the System Table + + @retval EFI_SUCCESS - If all services discovered. + @retval Other - Failure in constructor. + +**/ +EFI_STATUS +EFIAPI +InitializeBmcAcpiSwChild ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +/** + Send the time to the BMC, in the UNIX 32 bit format. + + @retval Status - result of sending the time stamp + +**/ +EFI_STATUS +SyncTimeStamp ( + VOID + ); + +/** + Send a command to BMC to set the present power state. + + @param This + @param PowerState + @param DeviceState + + @retval EFI_SUCCESS if successful + @retval Other than EFI_SUCCESS if not successful + +**/ +EFI_STATUS +SetACPIPowerStateInBMC ( + IN EFI_BMC_ACPI_SW_CHILD_POLICY_PROTOCOL *This, + IN UINT8 PowerState, + IN UINT8 DeviceState + ); + +#endif diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Protocol/BmcAcpiSwChildPolicy.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Protocol/BmcAcpiSwChildPolicy.h new file mode 100644 index 000000000000..7958f8c63899 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Protocol/BmcAcpiSwChildPolicy.h @@ -0,0 +1,31 @@ +/** @file + This protocol produces BmcAcpiSwChildPolicy Protocol. + +Copyright (c) 2023, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef _BMC_ACPI_SW_CHILD_POLICY_H_ +#define _BMC_ACPI_SW_CHILD_POLICY_H_ + +typedef struct _EFI_BMC_ACPI_SW_CHILD_POLICY_PROTOCOL EFI_BMC_ACPI_SW_CHILD_POLICY_PROTOCOL; + +#define EFI_BMC_ACPI_SW_CHILD_POLICY_PROTOCOL_GUID \ + { 0x89843c0b, 0x5701, 0x4ff6, 0xa4, 0x73, 0x65, 0x75, 0x99, 0x04, 0xf7, 0x35 } + +typedef +EFI_STATUS +(EFIAPI *EFI_SET_ACPI_POWER_STATE_IN_BMC)( + IN EFI_BMC_ACPI_SW_CHILD_POLICY_PROTOCOL *This, + IN UINT8 PowerState, + IN UINT8 DeviceState + ); + +struct _EFI_BMC_ACPI_SW_CHILD_POLICY_PROTOCOL { + EFI_SET_ACPI_POWER_STATE_IN_BMC SetACPIPowerStateInBMC; +}; + +extern EFI_GUID gEfiBmcAcpiSwChildPolicyProtocolGuid; + +#endif diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/BmcAcpiState/BmcAcpiState.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/BmcAcpiState/BmcAcpiState.c new file mode 100644 index 000000000000..04fe2d80307e --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/BmcAcpiState/BmcAcpiState.c @@ -0,0 +1,93 @@ +/** @file + +Copyright (c) 2023, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +/** + Notification function of Exit Boot Services event group. + + Send a command to BMC to set power state to S0. + + @param Event Event whose notification function is being invoked. + @param Context Pointer to the notification function's context. + +**/ +VOID +EFIAPI +BmcAcpiPowerStateS0Notify ( + EFI_EVENT Event, + VOID *Context + ) +{ + EFI_STATUS Status = EFI_SUCCESS; + IPMI_SET_ACPI_POWER_STATE_REQUEST AcpiPowerStateRequest; + UINT8 AcpiPowerStateResponse; + UINT32 ResponseDataSize = 0; + + AcpiPowerStateRequest.SystemPowerState.Bits.PowerState = IPMI_SYSTEM_POWER_STATE_S0_G0; // System Power State S0 + AcpiPowerStateRequest.SystemPowerState.Bits.StateChange = 1; + AcpiPowerStateRequest.DevicePowerState.Bits.PowerState = IPMI_DEVICE_POWER_STATE_D0; // Device State State S0 + AcpiPowerStateRequest.DevicePowerState.Bits.StateChange = 1; + + ResponseDataSize = sizeof (AcpiPowerStateResponse); + + // + // Send a command to BMC to set power state to S0. + // + Status = IpmiSubmitCommand ( + IPMI_NETFN_APP, + IPMI_APP_SET_ACPI_POWERSTATE, + (UINT8 *)&AcpiPowerStateRequest, + sizeof (IPMI_SET_ACPI_POWER_STATE_REQUEST), + (UINT8 *)&AcpiPowerStateResponse, + &ResponseDataSize + ); + + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "IpmiSubmitCommand App Set Acpi Power State Failed %r\n", Status)); + } +} + +/** + + Entry point for the Bmc Acpi State Dxe driver. + Use this function to replace previous ACPI Enable SMM handler to set BMC ACPI power state. + + @param ImageHandle - Image Handle. + @param SystemTable - EFI System Table. + + @retval EFI_SUCCESS - Function has completed successfully. + +**/ +EFI_STATUS +EFIAPI +BmcAcpiStateEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + // + // Create an Exit Boot Service to Send a command to BMC to set the present power state + // + Status = gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_NOTIFY, + BmcAcpiPowerStateS0Notify, + NULL, + &gEfiEventExitBootServicesGuid, + &mExitBootServicesEvent + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Create Exit Boot Services Event Failed\n")); + } else { + return EFI_SUCCESS; + } + + return EFI_UNSUPPORTED; +} diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/BmcAcpiSwChild/BmcAcpiSwChild.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/BmcAcpiSwChild/BmcAcpiSwChild.c new file mode 100644 index 000000000000..ba134db8d50d --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/BmcAcpiSwChild/BmcAcpiSwChild.c @@ -0,0 +1,189 @@ +/** @file + This driver publishes a protocol that is used by the ACPI SMM Platform + driver to notify the BMC of Power State transitions. + +Copyright (c) 2023, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "BmcAcpiSwChild.h" + +// +// Global variables +// +EFI_BMC_ACPI_SW_CHILD_POLICY_PROTOCOL mBmcAcpiSwChild; + +/** + This is the standard EFI driver entrypoint. This function initializes + the BMC ACPI SW Child protocol. + + @param ImageHandle - ImageHandle of the loaded driver + @param SystemTable - Pointer to the System Table + + @retval EFI_SUCCESS - If all services discovered. + @retval Other - Failure in constructor. + +**/ +EFI_STATUS +EFIAPI +InitializeBmcAcpiSwChild ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_HANDLE Handle; + + Status = EFI_SUCCESS; + + mBmcAcpiSwChild.SetACPIPowerStateInBMC = (EFI_SET_ACPI_POWER_STATE_IN_BMC)SetACPIPowerStateInBMC; + + // + // Install protocol + // + Handle = NULL; + Status = gSmst->SmmInstallProtocolInterface ( + &Handle, + &gEfiBmcAcpiSwChildPolicyProtocolGuid, + EFI_NATIVE_INTERFACE, + &mBmcAcpiSwChild + ); + + return Status; +} + +/** + Send the time to the BMC, in the UNIX 32 bit format. + + @retval Status - result of sending the time stamp + +**/ +EFI_STATUS +SyncTimeStamp ( + VOID + ) +{ + EFI_STATUS Status; + UINT32 ResponseDataSize; + IPMI_ADD_SEL_ENTRY_REQUEST TimeStampEvtRecord; + IPMI_ADD_SEL_ENTRY_RESPONSE AddSelEntryResponse; + IPMI_SET_SEL_TIME_REQUEST SelTimeReq; + UINT8 SelTimeResponse; + + TimeStampEvtRecord.RecordData.RecordId = 0; // Record Id + TimeStampEvtRecord.RecordData.RecordType = IPMI_SEL_SYSTEM_RECORD; // Record Type + TimeStampEvtRecord.RecordData.TimeStamp = 0; // Time stamp + TimeStampEvtRecord.RecordData.GeneratorId = 0x0003; // GenID:BIOS + TimeStampEvtRecord.RecordData.EvMRevision = IPMI_EVM_REVISION; // EVM REV + TimeStampEvtRecord.RecordData.SensorType = 0x12; // Sensor Type + TimeStampEvtRecord.RecordData.SensorNumber = 0x83; // Sensor No + TimeStampEvtRecord.RecordData.EventDirType = IPMI_SENSOR_TYPE_EVENT_CODE_DISCRETE; // Event Dir + TimeStampEvtRecord.RecordData.OEMEvData1 = 05; // Sensor specific Offset for Timestamp Clock Synch Event. + TimeStampEvtRecord.RecordData.OEMEvData2 = 00; // ED2 + TimeStampEvtRecord.RecordData.OEMEvData3 = 0xFF; // ED3 + + // + // Log Timestamp Clock Synch Event 1st pair. + // + ResponseDataSize = sizeof (AddSelEntryResponse); + Status = IpmiSubmitCommand ( + IPMI_NETFN_STORAGE, + IPMI_STORAGE_ADD_SEL_ENTRY, + (UINT8 *)&TimeStampEvtRecord, + sizeof (TimeStampEvtRecord), + (UINT8 *)&AddSelEntryResponse, + &ResponseDataSize + ); + + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "IpmiSubmitCommand Storage Add SEL Entry Failed %r\n", Status)); + return Status; + } + + Status = EfiSmGetTimeStamp (&SelTimeReq.Timestamp); + if (EFI_ERROR (Status)) { + return Status; + } + + ResponseDataSize = sizeof (SelTimeResponse); + Status = IpmiSubmitCommand ( + IPMI_NETFN_STORAGE, + IPMI_STORAGE_SET_SEL_TIME, + (UINT8 *)&SelTimeReq, + sizeof (SelTimeReq), + (UINT8 *)&SelTimeResponse, + &ResponseDataSize + ); + + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "IpmiSubmitCommand Storage Set SEL Time Failed %r\n", Status)); + return Status; + } + + // + // Log Timestamp Clock Sync Event 2nd pair. + // + TimeStampEvtRecord.RecordData.OEMEvData2 = 0x80; + ResponseDataSize = sizeof (AddSelEntryResponse); + Status = IpmiSubmitCommand ( + IPMI_NETFN_STORAGE, + IPMI_STORAGE_ADD_SEL_ENTRY, + (UINT8 *)&TimeStampEvtRecord, + sizeof (TimeStampEvtRecord), + (UINT8 *)&AddSelEntryResponse, + &ResponseDataSize + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "IpmiSubmitCommand Storage Add SEL Entry Failed %r\n", Status)); + return Status; + } + + return EFI_SUCCESS; +} + +/** + Send a command to BMC to set the present power state. + + @param This + @param PowerState + @param DeviceState + + @retval EFI_SUCCESS if successful + @retval Other than EFI_SUCCESS if not successful + +**/ +EFI_STATUS +SetACPIPowerStateInBMC ( + IN EFI_BMC_ACPI_SW_CHILD_POLICY_PROTOCOL *This, + IN UINT8 PowerState, + IN UINT8 DeviceState + ) +{ + EFI_STATUS Status; + IPMI_SET_ACPI_POWER_STATE_REQUEST AcpiPowerStateRequest; + UINT8 AcpiPowerStateResponse; + UINT32 ResponseDataSize; + + AcpiPowerStateRequest.SystemPowerState.Bits.PowerState = PowerState; + AcpiPowerStateRequest.SystemPowerState.Bits.StateChange = 1; + AcpiPowerStateRequest.DevicePowerState.Bits.PowerState = DeviceState; + AcpiPowerStateRequest.DevicePowerState.Bits.StateChange = 1; + + ResponseDataSize = sizeof (AcpiPowerStateResponse); + + Status = IpmiSubmitCommand ( + IPMI_NETFN_APP, + IPMI_APP_SET_ACPI_POWERSTATE, + (UINT8 *)&AcpiPowerStateRequest, + sizeof (AcpiPowerStateRequest), + (UINT8 *)&AcpiPowerStateResponse, + &ResponseDataSize + ); + + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "IpmiSubmitCommand App Set Acpi Power State Failed %r\n", Status)); + } + + return Status; +} -- 2.39.2.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#110231): https://edk2.groups.io/g/devel/message/110231 Mute This Topic: https://groups.io/mt/102231768/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-