From: Zhen Gong <zhen.gong@intel.com>
To: devel@edk2.groups.io
Cc: Zhen Gong <zhen.gong@intel.com>
Subject: [edk2-devel] [PATCH edk2-platforms 3/4] IpmiFeaturePkg: Add ACPI power state drivers
Date: Fri, 27 Oct 2023 13:11:15 -0700 [thread overview]
Message-ID: <5518582e9e3665c3a474b1e65980ed0c12123243.1698437221.git.zhen.gong@intel.com> (raw)
In-Reply-To: <cover.1698437221.git.zhen.gong@intel.com>
Add DXE and SMM drivers that send "Set ACPI Power State" command to BMC.
Signed-off-by: Zhen Gong <zhen.gong@intel.com>
---
.../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.<BR>
+#
+# 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.<BR>
+#
+# 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.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _ACPI_BMC_STATE_H_
+#define _ACPI_BMC_STATE_H_
+
+//
+// Statements that include other header files
+//
+#include <Library/UefiDriverEntryPoint.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/DebugLib.h>
+#include <Guid/EventGroup.h>
+#include <Protocol/IpmiTransportProtocol.h>
+#include <Include/IpmiNetFnAppDefinitions.h>
+#include <IndustryStandard/Ipmi.h>
+#include <Library/IpmiBaseLib.h>
+#include <Protocol/IpmiProtocol.h>
+
+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.<BR>
+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 <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/SmmLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/SmmServicesTableLib.h>
+#include <Library/MemoryAllocationLib.h>
+
+#include "ServerManagement.h"
+
+#include <Library/ServerMgmtRtLib.h>
+#include <Protocol/IpmiTransportProtocol.h>
+#include <Protocol/BmcAcpiSwChildPolicy.h>
+#include <IndustryStandard/Ipmi.h>
+#include <Library/IpmiBaseLib.h>
+
+//
+// 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.<BR>
+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.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <BmcAcpiState.h>
+
+/**
+ 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.<BR>
+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]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2023-10-27 22:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-27 20:11 [edk2-devel] [PATCH edk2-platforms 0/4] IpmiFeaturePkg: Add server management features Zhen Gong
2023-10-27 20:11 ` [edk2-devel] [PATCH edk2-platforms 1/4] IpmiFeaturePkg: Add Elog drivers Zhen Gong
2023-10-27 20:11 ` [edk2-devel] [PATCH edk2-platforms 2/4] IpmiFeaturePkg: Add ServerManagementLib Zhen Gong
2023-10-27 20:11 ` Zhen Gong [this message]
2023-10-27 20:11 ` [edk2-devel] [PATCH edk2-platforms 4/4] IpmiFeaturePkg: Add FRU drivers Zhen Gong
2023-10-29 1:58 ` [edk2-devel] [PATCH edk2-platforms 0/4] IpmiFeaturePkg: Add server management features Chang, Abner via groups.io
2023-10-29 21:07 ` Zhen Gong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5518582e9e3665c3a474b1e65980ed0c12123243.1698437221.git.zhen.gong@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox