[edk2-devel] [edk2-platforms][PATCH 1/2] ManageabilityPkg/IpmiBmcElog: IPMI BMC Elog Driver

Attar, AbdulLateef (Abdul Lateef) via groups.io AbdulLateef.Attar=amd.com at groups.io
Mon May 15 03:10:02 UTC 2023


[AMD Official Use Only - General]

Reviewed-by: Abdul Lateef Attar <abdattar at amd.com>

-----Original Message-----
From: Chang, Abner <Abner.Chang at amd.com>
Sent: 12 May 2023 15:28
To: devel at edk2.groups.io
Cc: Isaac Oram <isaac.w.oram at intel.com>; Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar at amd.com>; Nickle Wang <nicklew at nvidia.com>; Tinh Nguyen <tinhnguyen at os.amperecomputing.com>
Subject: [edk2-platforms][PATCH 1/2] ManageabilityPkg/IpmiBmcElog: IPMI BMC Elog Driver

From: Abner Chang <abner.chang at amd.com>

IpmiBmcElog is cloned from
edk2-platforms/Features/Intel/OutOfBandManagement/
IpmiFeaturePkg/BmcElog in order to consolidate
edk2 system manageability support in one place.
Uncustify is applied to C files and no functionalities are changed in this patch.

We will still keep the one under IpmiFeaturePkg/BmcElog until the reference to this instance are removed from platforms.

Signed-off-by: Abner Chang <abner.chang at amd.com>
Cc: Isaac Oram <isaac.w.oram at intel.com>
Cc: Abdul Lateef Attar <abdattar at amd.com>
Cc: Nickle Wang <nicklew at nvidia.com>
Cc: Tinh Nguyen <tinhnguyen at os.amperecomputing.com>
---
 .../Universal/IpmiBmcElog/BmcElog.inf         |  33 +++
 .../Universal/IpmiBmcElog/BmcElog.c           | 192 ++++++++++++++++++
 2 files changed, 225 insertions(+)
 create mode 100644 Features/ManageabilityPkg/Universal/IpmiBmcElog/BmcElog.inf
 create mode 100644 Features/ManageabilityPkg/Universal/IpmiBmcElog/BmcElog.c

diff --git a/Features/ManageabilityPkg/Universal/IpmiBmcElog/BmcElog.inf b/Features/ManageabilityPkg/Universal/IpmiBmcElog/BmcElog.inf
new file mode 100644
index 0000000000..4c28862fe5
--- /dev/null
+++ b/Features/ManageabilityPkg/Universal/IpmiBmcElog/BmcElog.inf
@@ -0,0 +1,33 @@
+### @file
+# Component description file for BMC ELOG.
+#
+# Copyright (c) 2018 - 2019, Intel Corporation. All rights
+reserved.<BR> # # SPDX-License-Identifier: BSD-2-Clause-Patent # ###
+
+[Defines]
+  INF_VERSION              = 0x00010005
+  BASE_NAME                = BmcElog
+  FILE_GUID                = A0FF2235-B652-45E3-B3D2-B20F3E714E6F
+  MODULE_TYPE              = DXE_DRIVER
+  PI_SPECIFICATION_VERSION = 0x0001000A
+  VERSION_STRING           = 1.0
+  ENTRY_POINT              = InitializeBmcElogLayer
+
+[Sources]
+  BmcElog.c
+
+[Packages]
+  ManageabilityPkg/ManageabilityPkg.dec
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  DebugLib
+  IpmiCommandLib
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
+
+[Depex]
+  TRUE
diff --git a/Features/ManageabilityPkg/Universal/IpmiBmcElog/BmcElog.c b/Features/ManageabilityPkg/Universal/IpmiBmcElog/BmcElog.c
new file mode 100644
index 0000000000..ab179e9d49
--- /dev/null
+++ b/Features/ManageabilityPkg/Universal/IpmiBmcElog/BmcElog.c
@@ -0,0 +1,192 @@
+/** @file
+  BMC Event Log functions.
+
+Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h> #include
+<Library/UefiBootServicesTableLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Library/IpmiCommandLib.h>
+
+EFI_STATUS
+EFIAPI
+CheckIfSelIsFull (
+  VOID
+  );
+
+/**
+  This function erases event logs and waits unti complete.
+
+  @param [in]  ResvId              - Reserved ID
+
+  @retval  EFI_STATUS               EFI_SUCCESS
+                                    EFI_NO_RESPONSE
+
+**/
+EFI_STATUS
+WaitTillErased (
+  IN  UINT8  *ResvId
+  )
+{
+  INTN                     Counter;
+  IPMI_CLEAR_SEL_REQUEST   ClearSel;
+  IPMI_CLEAR_SEL_RESPONSE  ClearSelResponse;
+
+  Counter = 0x200;
+  ZeroMem (&ClearSelResponse, sizeof (ClearSelResponse));
+
+  while (TRUE) {
+    ZeroMem (&ClearSel, sizeof (ClearSel));
+    ClearSel.Reserve[0] = ResvId[0];
+    ClearSel.Reserve[1] = ResvId[1];
+    ClearSel.AscC       = 0x43;
+    ClearSel.AscL       = 0x4C;
+    ClearSel.AscR       = 0x52;
+    ClearSel.Erase      = 0x00;
+
+    IpmiClearSel (
+      &ClearSel,
+      &ClearSelResponse
+      );
+
+    if ((ClearSelResponse.ErasureProgress & 0xf) == 1) {
+      return EFI_SUCCESS;
+    }
+
+    //
+    //  If there is not a response from the BMC controller we need to return and not hang.
+    //
+    --Counter;
+    if (Counter == 0x0) {
+      return EFI_NO_RESPONSE;
+    }
+  }
+}
+
+/**
+  This function activates BMC event log.
+
+  @param [in] EnableElog  Enable/Disable event log  @param [out]
+ ElogStatus  return log status
+
+  @retval  EFI_STATUS
+
+**/
+EFI_STATUS
+EfiActivateBmcElog (
+  IN BOOLEAN   *EnableElog,
+  OUT BOOLEAN  *ElogStatus
+  )
+{
+  EFI_STATUS                            Status;
+  UINT8                                 ElogStat;
+  IPMI_SET_BMC_GLOBAL_ENABLES_REQUEST   SetBmcGlobalEnables;
+  IPMI_GET_BMC_GLOBAL_ENABLES_RESPONSE  GetBmcGlobalEnables;
+  UINT8                                 CompletionCode;
+
+  Status   = EFI_SUCCESS;
+  ElogStat = 0;
+
+  Status = IpmiGetBmcGlobalEnables (&GetBmcGlobalEnables);  if
+ (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  if (EnableElog == NULL) {
+    *ElogStatus =
+ GetBmcGlobalEnables.GetEnables.Bits.SystemEventLogging;
+  } else {
+    if (Status == EFI_SUCCESS) {
+      if (*EnableElog) {
+        ElogStat = 1;
+      }
+
+      CopyMem (&SetBmcGlobalEnables, (UINT8 *)&GetBmcGlobalEnables + 1, sizeof (UINT8));
+      SetBmcGlobalEnables.SetEnables.Bits.SystemEventLogging =
+ ElogStat;
+
+      Status = IpmiSetBmcGlobalEnables (&SetBmcGlobalEnables, &CompletionCode);
+    }
+  }
+
+  return Status;
+}
+
+/**
+
+  @retval  EFI_STATUS
+
+**/
+EFI_STATUS
+SetElogRedirInstall (
+  VOID
+  )
+{
+  BOOLEAN  EnableElog;
+  BOOLEAN  ElogStatus;
+
+  //
+  // Activate the Event Log (This should depend upon Setup).
+  //
+  EfiActivateBmcElog (&EnableElog, &ElogStatus);
+  return EFI_SUCCESS;
+}
+
+/**
+  Entry point of BmcElog DXE driver
+
+  @param [in]  ImageHandle  ImageHandle of the loaded driver  @param
+ [in]  SystemTable  Pointer to the System Table
+
+  @retval  EFI_STATUS
+
+**/
+EFI_STATUS
+EFIAPI
+InitializeBmcElogLayer (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+{
+  SetElogRedirInstall ();
+
+  CheckIfSelIsFull ();
+
+  return EFI_SUCCESS;
+}
+
+/**
+  This function verifies the BMC SEL is full and When it is
+  reports the error to the Error Manager.
+
+  @retval  EFI_STATUS
+
+**/
+EFI_STATUS
+EFIAPI
+CheckIfSelIsFull (
+  VOID
+  )
+{
+  EFI_STATUS                  Status;
+  UINT8                       SelIsFull;
+  IPMI_GET_SEL_INFO_RESPONSE  SelInfo;
+
+  Status = IpmiGetSelInfo (&SelInfo);
+  if (EFI_ERROR (Status)) {
+    return EFI_DEVICE_ERROR;
+  }
+
+  //
+  // Check the Bit7 of the OperationByte if SEL is OverFlow.
+  //
+  SelIsFull = (SelInfo.OperationSupport & 0x80);  DEBUG ((DEBUG_INFO,
+ "SelIsFull - 0x%x\n", SelIsFull));
+
+  return EFI_SUCCESS;
+}
--
2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104867): https://edk2.groups.io/g/devel/message/104867
Mute This Topic: https://groups.io/mt/98846235/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list