[edk2-devel] [edk2-platforms][PATCH 1/2] ManageabilityPkg/IpmiOsWdt: IPMI OS Watchdog timer Driver

Isaac Oram isaac.w.oram at intel.com
Fri May 19 03:12:11 UTC 2023


Reviewed-by: Isaac Oram <isaac.w.oram at intel.com>

-----Original Message-----
From: devel at edk2.groups.io <devel at edk2.groups.io> On Behalf Of Chang, Abner via groups.io
Sent: Thursday, May 11, 2023 9:07 PM
To: devel at edk2.groups.io
Cc: Oram, Isaac W <isaac.w.oram at intel.com>; Abdul Lateef Attar <abdattar at amd.com>; Nickle Wang <nicklew at nvidia.com>; Tinh Nguyen <tinhnguyen at os.amperecomputing.com>
Subject: [edk2-devel] [edk2-platforms][PATCH 1/2] ManageabilityPkg/IpmiOsWdt: IPMI OS Watchdog timer Driver

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

IpmiOsWdt is cloned from
edk2-platforms/Features/Intel/OutOfBandManagement/
IpmiFeaturePkg/OsWdt 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/OsWdt 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/IpmiOsWdt/OsWdt.inf             |  33 ++++++
 .../Universal/IpmiOsWdt/OsWdt.c               | 112 ++++++++++++++++++
 2 files changed, 145 insertions(+)
 create mode 100644 Features/ManageabilityPkg/Universal/IpmiOsWdt/OsWdt.inf
 create mode 100644 Features/ManageabilityPkg/Universal/IpmiOsWdt/OsWdt.c

diff --git a/Features/ManageabilityPkg/Universal/IpmiOsWdt/OsWdt.inf b/Features/ManageabilityPkg/Universal/IpmiOsWdt/OsWdt.inf
new file mode 100644
index 0000000000..b5af3b25e1
--- /dev/null
+++ b/Features/ManageabilityPkg/Universal/IpmiOsWdt/OsWdt.inf
@@ -0,0 +1,33 @@
+### @file
+# Component description file for IPMI OS watch dog timer driver.
+#
+# Copyright (c) 2018 - 2019, Intel Corporation. All rights 
+reserved.<BR> # # SPDX-License-Identifier: BSD-2-Clause-Patent # ###
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = OsWdt
+  FILE_GUID                      = BA4FD21F-8443-4017-8D13-70EC92F4BD4C
+  MODULE_TYPE                    = DXE_DRIVER
+  VERSION_STRING                 = 1.0
+  ENTRY_POINT                    = DriverInit
+
+[Sources]
+  OsWdt.c
+
+[Packages]
+  ManageabilityPkg/ManageabilityPkg.dec
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  DebugLib
+  IpmiCommandLib
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
+  UefiLib
+
+[Depex]
+  TRUE
diff --git a/Features/ManageabilityPkg/Universal/IpmiOsWdt/OsWdt.c b/Features/ManageabilityPkg/Universal/IpmiOsWdt/OsWdt.c
new file mode 100644
index 0000000000..e2bbd95b83
--- /dev/null
+++ b/Features/ManageabilityPkg/Universal/IpmiOsWdt/OsWdt.c
@@ -0,0 +1,112 @@
+/** @file
+  IPMI Os watchdog timer Driver.
+
+Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/IpmiCommandLib.h>
+#include <IndustryStandard/Ipmi.h>
+
+BOOLEAN  mOsWdtFlag = FALSE;
+
+EFI_EVENT  mExitBootServicesEvent;
+
+/*++
+
+Routine Description:
+  Enable the OS Boot Watchdog Timer.
+  Is called only on legacy or EFI OS boot.
+
+Arguments:
+  Event    - Event type
+  *Context - Context for the event
+
+Returns:
+  None
+
+--*/
+VOID
+EFIAPI
+EnableEfiOsBootWdtHandler (
+  IN EFI_EVENT  Event,
+  IN VOID       *Context
+  )
+{
+  EFI_STATUS                        Status;
+  IPMI_SET_WATCHDOG_TIMER_REQUEST   SetWatchdogTimer;
+  UINT8                             CompletionCode;
+  IPMI_GET_WATCHDOG_TIMER_RESPONSE  GetWatchdogTimer;
+  static BOOLEAN                    OsWdtEventHandled = FALSE;
+
+  DEBUG ((DEBUG_ERROR, "!!! EnableEfiOsBootWdtHandler()!!!\n"));
+
+  //
+  // Make sure it processes once only. And proceess it only if 
+ OsWdtFlag==TRUE;  //  if (OsWdtEventHandled || !mOsWdtFlag) {
+    return;
+  }
+
+  OsWdtEventHandled = TRUE;
+
+  Status = IpmiGetWatchdogTimer (&GetWatchdogTimer);  if (EFI_ERROR 
+ (Status)) {
+    return;
+  }
+
+  ZeroMem (&SetWatchdogTimer, sizeof (SetWatchdogTimer));  //  // Just 
+ flip the Timer Use bit. This should release the timer.
+  //
+  SetWatchdogTimer.TimerUse.Bits.TimerRunning    = 1;
+  SetWatchdogTimer.TimerUse.Bits.TimerUse        = IPMI_WATCHDOG_TIMER_OS_LOADER;
+  SetWatchdogTimer.TimerActions.Uint8            = IPMI_WATCHDOG_TIMER_ACTION_HARD_RESET;
+  SetWatchdogTimer.TimerUseExpirationFlagsClear &= ~BIT4;  
+ SetWatchdogTimer.TimerUseExpirationFlagsClear |= BIT1 | BIT2;
+  SetWatchdogTimer.InitialCountdownValue         = 600; // 100ms / count
+
+  Status = IpmiSetWatchdogTimer (&SetWatchdogTimer, &CompletionCode);
+  return;
+}
+
+/*++
+
+Routine Description:
+  This is the standard EFI driver point. This function intitializes
+  the private data required for creating ASRR Driver.
+
+Arguments:
+  As required for DXE driver enrty routine.
+  ImageHandle - ImageHandle of the loaded driver
+  SystemTable - Pointer to the System Table
+
+Returns:
+  @retval EFI_SUCCESS           Protocol successfully started and installed.
+  @retval EFI_OUT_OF_RESOURCES  The event could not be allocated.
+
+--*/
+EFI_STATUS
+EFIAPI
+DriverInit (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+{
+  EFI_STATUS  Status;
+
+  Status = gBS->CreateEvent (
+                  EVT_SIGNAL_EXIT_BOOT_SERVICES,
+                  TPL_NOTIFY,
+                  EnableEfiOsBootWdtHandler,
+                  NULL,
+                  &mExitBootServicesEvent
+                  );
+
+  return Status;
+}
--
2.37.1.windows.1








-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#105059): https://edk2.groups.io/g/devel/message/105059
Mute This Topic: https://groups.io/mt/98843095/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