From: Abner Chang <abner.ch...@amd.com>

IpmiFru is cloned from
edk2-platforms/Features/Intel/OutOfBandManagement/
IpmiFeaturePkg/IpmiFru 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/IpmiFru
until the reference to this instance are removed from
platforms.

Signed-off-by: Abner Chang <abner.ch...@amd.com>
Cc: Isaac Oram <isaac.w.o...@intel.com>
Cc: Abdul Lateef Attar <abdat...@amd.com>
Cc: Nickle Wang <nick...@nvidia.com>
Cc: Tinh Nguyen <tinhngu...@os.amperecomputing.com>
---
 .../Universal/IpmiFru/IpmiFru.inf             | 34 ++++++++++
 .../Universal/IpmiFru/IpmiFru.c               | 67 +++++++++++++++++++
 2 files changed, 101 insertions(+)
 create mode 100644 Features/ManageabilityPkg/Universal/IpmiFru/IpmiFru.inf
 create mode 100644 Features/ManageabilityPkg/Universal/IpmiFru/IpmiFru.c

diff --git a/Features/ManageabilityPkg/Universal/IpmiFru/IpmiFru.inf 
b/Features/ManageabilityPkg/Universal/IpmiFru/IpmiFru.inf
new file mode 100644
index 0000000000..ddef310309
--- /dev/null
+++ b/Features/ManageabilityPkg/Universal/IpmiFru/IpmiFru.inf
@@ -0,0 +1,34 @@
+### @file
+# Component description file for IPMI FRU.
+#
+# Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+###
+
+[Defines]
+  INF_VERSION              = 0x00010005
+  BASE_NAME                = IpmiFru
+  FILE_GUID                = CD9B99D9-E86F-48CF-A8EB-20120AC22666
+  MODULE_TYPE              = DXE_DRIVER
+  PI_SPECIFICATION_VERSION = 0x0001000A
+  VERSION_STRING           = 1.0
+  ENTRY_POINT              = InitializeFru
+
+[Sources]
+  IpmiFru.c
+
+[Packages]
+  ManageabilityPkg/ManageabilityPkg.dec
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  DebugLib
+  IpmiCommandLib
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
+  UefiLib
+
+[Depex]
+  TRUE
diff --git a/Features/ManageabilityPkg/Universal/IpmiFru/IpmiFru.c 
b/Features/ManageabilityPkg/Universal/IpmiFru/IpmiFru.c
new file mode 100644
index 0000000000..2b489410db
--- /dev/null
+++ b/Features/ManageabilityPkg/Universal/IpmiFru/IpmiFru.c
@@ -0,0 +1,67 @@
+/** @file
+  IPMI FRU Driver.
+
+Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/BaseLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/DebugLib.h>
+#include <Library/IpmiCommandLib.h>
+#include <IndustryStandard/Ipmi.h>
+
+/*++
+
+Routine Description:
+
+  Initialize SM Redirection Fru Layer
+
+Arguments:
+
+  ImageHandle - ImageHandle of the loaded driver
+  SystemTable - Pointer to the System Table
+
+Returns:
+
+  EFI_STATUS
+
+--*/
+EFI_STATUS
+EFIAPI
+InitializeFru (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+{
+  EFI_STATUS                                 Status;
+  IPMI_GET_DEVICE_ID_RESPONSE                ControllerInfo;
+  IPMI_GET_FRU_INVENTORY_AREA_INFO_REQUEST   GetFruInventoryAreaInfoRequest;
+  IPMI_GET_FRU_INVENTORY_AREA_INFO_RESPONSE  GetFruInventoryAreaInfoResponse;
+
+  //
+  //  Get all the SDR Records from BMC and retrieve the Record ID from the 
structure for future use.
+  //
+  Status = IpmiGetDeviceId (&ControllerInfo);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "!!! IpmiFru  IpmiGetDeviceId Status=%x\n", Status));
+    return Status;
+  }
+
+  DEBUG ((DEBUG_ERROR, "!!! IpmiFru  FruInventorySupport %x\n", 
ControllerInfo.DeviceSupport.Bits.FruInventorySupport));
+
+  if (ControllerInfo.DeviceSupport.Bits.FruInventorySupport) {
+    GetFruInventoryAreaInfoRequest.DeviceId = 0;
+    Status                                  = IpmiGetFruInventoryAreaInfo 
(&GetFruInventoryAreaInfoRequest, &GetFruInventoryAreaInfoResponse);
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "!!! IpmiFru  IpmiGetFruInventoryAreaInfo 
Status=%x\n", Status));
+      return Status;
+    }
+
+    DEBUG ((DEBUG_ERROR, "!!! IpmiFru  InventoryAreaSize=%x\n", 
GetFruInventoryAreaInfoResponse.InventoryAreaSize));
+  }
+
+  return EFI_SUCCESS;
+}
-- 
2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104743): https://edk2.groups.io/g/devel/message/104743
Mute This Topic: https://groups.io/mt/98842631/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to