public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-platforms] [PATCH v1 0/9] IpmiFeaturePkg: Add IPMI transport drivers
@ 2021-03-02  2:27 Nate DeSimone
  2021-03-02  2:27 ` [edk2-platforms] [PATCH v1 1/9] IpmiFeaturePkg: Add IPMI driver Include headers Nate DeSimone
                   ` (10 more replies)
  0 siblings, 11 replies; 14+ messages in thread
From: Nate DeSimone @ 2021-03-02  2:27 UTC (permalink / raw)
  To: devel; +Cc: Isaac Oram, Sai Chaganty, Liming Gao, Michael Kubacki

From: Isaac Oram <isaac.w.oram@intel.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3242

Implement an open source generic IPMI transport driver.
Provides the ability to communicate with a BMC over IPMI
in MinPlatform board packages.

New changes:
  1. Added GenericIpmi
  2. Added IPMI base libs
  3. Added transport PPI and protocol
  4. Updated IPMI command request and response data size from
     UINT8 to UINT32 in IPMI transport layer to be compatible
     with EDK2 industry standard IPMI commands.
  6. Added the completion code in the first byte of all IPMI
     response data to be compatible with EDK2 industry standard
     IPMI commands.

Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Michael Kubacki <michael.kubacki@microsoft.com>
Signed-off-by: Isaac Oram <isaac.w.oram@intel.com>
Co-authored-by: Nate DeSimone <nathaniel.l.desimone@intel.com>

Isaac Oram (9):
  IpmiFeaturePkg: Add IPMI driver Include headers
  IpmiFeaturePkg: Add IpmiBaseLib and IpmiCommandLib
  IpmiFeaturePkg: Add IpmiInit drivers
  IpmiFeaturePkg: Add GenericIpmi driver common code
  IpmiFeaturePkg: Add GenericIpmi PEIM
  IpmiFeaturePkg: Add GenericIpmi DXE Driver
  IpmiFeaturePkg: Add GenericIpmi SMM Driver
  IpmiFeaturePkg: Add IPMI driver build files
  Maintainers.txt: Add IpmiFeaturePkg maintainers

 .../GenericIpmi/Common/IpmiBmc.c              | 297 +++++++++++
 .../GenericIpmi/Common/IpmiBmc.h              |  44 ++
 .../GenericIpmi/Common/IpmiBmcCommon.h        | 179 +++++++
 .../GenericIpmi/Common/IpmiHooks.c            |  96 ++++
 .../GenericIpmi/Common/IpmiHooks.h            |  81 +++
 .../GenericIpmi/Common/IpmiPhysicalLayer.h    |  29 ++
 .../GenericIpmi/Common/KcsBmc.c               | 483 ++++++++++++++++++
 .../GenericIpmi/Common/KcsBmc.h               | 236 +++++++++
 .../GenericIpmi/Dxe/GenericIpmi.c             |  46 ++
 .../GenericIpmi/Dxe/GenericIpmi.inf           |  66 +++
 .../IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c | 452 ++++++++++++++++
 .../GenericIpmi/Pei/PeiGenericIpmi.c          | 362 +++++++++++++
 .../GenericIpmi/Pei/PeiGenericIpmi.h          | 138 +++++
 .../GenericIpmi/Pei/PeiGenericIpmi.inf        |  58 +++
 .../GenericIpmi/Pei/PeiIpmiBmc.c              | 277 ++++++++++
 .../GenericIpmi/Pei/PeiIpmiBmc.h              |  38 ++
 .../GenericIpmi/Pei/PeiIpmiBmcDef.h           | 156 ++++++
 .../GenericIpmi/Smm/SmmGenericIpmi.c          | 208 ++++++++
 .../GenericIpmi/Smm/SmmGenericIpmi.inf        |  53 ++
 .../IpmiFeaturePkg/Include/IpmiFeature.dsc    |   9 +-
 .../Include/Library/IpmiBaseLib.h             |  50 ++
 .../Include/Library/IpmiCommandLib.h          |  19 +-
 .../Include/Ppi/IpmiTransportPpi.h            |  68 +++
 .../Include/Protocol/IpmiTransportProtocol.h  |  75 +++
 .../IpmiFeaturePkg/Include/ServerManagement.h | 337 ++++++++++++
 .../IpmiFeaturePkg/Include/SmStatusCodes.h    |  98 ++++
 .../IpmiFeaturePkg/IpmiFeaturePkg.dec         |  22 +-
 .../IpmiFeaturePkg/IpmiInit/DxeIpmiInit.c     |   4 +-
 .../IpmiFeaturePkg/IpmiInit/DxeIpmiInit.inf   |   6 +-
 .../IpmiFeaturePkg/IpmiInit/PeiIpmiInit.c     |   4 +-
 .../IpmiFeaturePkg/IpmiInit/PeiIpmiInit.inf   |   4 +-
 .../Library/IpmiBaseLib/IpmiBaseLib.c         | 155 ++++++
 .../Library/IpmiBaseLib/IpmiBaseLib.inf       |  28 +
 .../Library/IpmiBaseLibNull/IpmiBaseLibNull.c |  76 +++
 .../IpmiBaseLibNull/IpmiBaseLibNull.inf       |  36 ++
 .../Library/IpmiCommandLib/IpmiCommandLib.inf |   4 +-
 .../IpmiCommandLib/IpmiCommandLibNetFnApp.c   |   7 +-
 .../IpmiCommandLibNetFnChassis.c              |  51 +-
 .../IpmiCommandLibNetFnStorage.c              |   7 +-
 .../IpmiCommandLibNetFnTransport.c            |   7 +-
 .../Library/PeiIpmiBaseLib/PeiIpmiBaseLib.c   | 111 ++++
 .../Library/PeiIpmiBaseLib/PeiIpmiBaseLib.inf |  30 ++
 .../Library/SmmIpmiBaseLib/SmmIpmiBaseLib.c   | 180 +++++++
 .../Library/SmmIpmiBaseLib/SmmIpmiBaseLib.inf |  29 ++
 .../IpmiFeaturePkg/Readme.md                  |   4 +-
 Maintainers.txt                               |   6 +
 46 files changed, 4694 insertions(+), 32 deletions(-)
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiBmc.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiBmc.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiBmcCommon.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiHooks.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiHooks.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiPhysicalLayer.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/KcsBmc.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/KcsBmc.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/GenericIpmi.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/GenericIpmi.inf
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.inf
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiBmc.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiBmc.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiBmcDef.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/SmmGenericIpmi.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/SmmGenericIpmi.inf
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Library/IpmiBaseLib.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Ppi/IpmiTransportPpi.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Protocol/IpmiTransportProtocol.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/ServerManagement.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/SmStatusCodes.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLib/IpmiBaseLib.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLib/IpmiBaseLib.inf
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLibNull/IpmiBaseLibNull.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLibNull/IpmiBaseLibNull.inf
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/PeiIpmiBaseLib/PeiIpmiBaseLib.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/PeiIpmiBaseLib/PeiIpmiBaseLib.inf
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/SmmIpmiBaseLib/SmmIpmiBaseLib.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/SmmIpmiBaseLib/SmmIpmiBaseLib.inf

-- 
2.27.0.windows.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [edk2-platforms] [PATCH v1 1/9] IpmiFeaturePkg: Add IPMI driver Include headers
  2021-03-02  2:27 [edk2-platforms] [PATCH v1 0/9] IpmiFeaturePkg: Add IPMI transport drivers Nate DeSimone
@ 2021-03-02  2:27 ` Nate DeSimone
  2021-03-02  2:27 ` [edk2-platforms] [PATCH v1 2/9] IpmiFeaturePkg: Add IpmiBaseLib and IpmiCommandLib Nate DeSimone
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Nate DeSimone @ 2021-03-02  2:27 UTC (permalink / raw)
  To: devel; +Cc: Isaac Oram, Sai Chaganty, Liming Gao, Michael Kubacki

From: Isaac Oram <isaac.w.oram@intel.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3242

Adds header files for the IPMI transport drivers.

Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Michael Kubacki <michael.kubacki@microsoft.com>
Signed-off-by: Isaac Oram <isaac.w.oram@intel.com>
Co-authored-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
---
 .../Include/Library/IpmiBaseLib.h             |  50 +++
 .../Include/Library/IpmiCommandLib.h          |  19 +-
 .../Include/Ppi/IpmiTransportPpi.h            |  68 ++++
 .../Include/Protocol/IpmiTransportProtocol.h  |  75 ++++
 .../IpmiFeaturePkg/Include/ServerManagement.h | 337 ++++++++++++++++++
 .../IpmiFeaturePkg/Include/SmStatusCodes.h    |  98 +++++
 6 files changed, 646 insertions(+), 1 deletion(-)
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Library/IpmiBaseLib.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Ppi/IpmiTransportPpi.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Protocol/IpmiTransportProtocol.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/ServerManagement.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/SmStatusCodes.h

diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Library/IpmiBaseLib.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Library/IpmiBaseLib.h
new file mode 100644
index 0000000000..8487ace5ba
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Library/IpmiBaseLib.h
@@ -0,0 +1,50 @@
+/** @file
+  IPMI Command Library Header File.
+
+  @copyright
+  Copyright 2011 - 2021 Intel Corporation. <BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef _IPMI_BASE_LIB_H_
+#define _IPMI_BASE_LIB_H_
+
+//
+// Prototype definitions for IPMI Library
+//
+/**
+  Initialize the global varible with the pointer of IpmiTransport Protocol.
+
+  @retval EFI_SUCCESS - Always return success
+
+**/
+EFI_STATUS
+InitializeIpmiBase (
+  VOID
+  );
+
+/**
+  Routine to send commands to BMC.
+
+  @param NetFunction       - Net function of the command
+  @param Command           - IPMI Command
+  @param CommandData       - Command Data
+  @param CommandDataSize   - Size of CommandData
+  @param ResponseData      - Response Data
+  @param ResponseDataSize  - Response Data Size
+
+  @retval EFI_NOT_AVAILABLE_YET - IpmiTransport Protocol is not installed yet
+
+**/
+EFI_STATUS
+IpmiSubmitCommand (
+  IN UINT8     NetFunction,
+  IN UINT8     Command,
+  IN UINT8     *CommandData,
+  IN UINT32    CommandDataSize,
+  OUT UINT8    *ResponseData,
+  OUT UINT32   *ResponseDataSize
+  );
+
+#endif
+
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Library/IpmiCommandLib.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Library/IpmiCommandLib.h
index 9b761717d4..18f9d123c9 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Library/IpmiCommandLib.h
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Library/IpmiCommandLib.h
@@ -1,7 +1,7 @@
 /** @file
   This library abstract how to send/receive IPMI command.
 
-Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2018-2021, Intel Corporation. All rights reserved.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -143,6 +143,23 @@ IpmiSetPowerRestorePolicy (
   OUT IPMI_SET_POWER_RESTORE_POLICY_RESPONSE *ChassisControlResponse
   );
 
+//
+// NetFnStorage
+//
+EFI_STATUS
+EFIAPI
+IpmiSetSystemBootOptions (
+  IN  IPMI_SET_BOOT_OPTIONS_REQUEST  *BootOptionsRequest,
+  OUT IPMI_SET_BOOT_OPTIONS_RESPONSE *BootOptionsResponse
+  );
+
+EFI_STATUS
+EFIAPI
+IpmiGetSystemBootOptions (
+  IN  IPMI_GET_BOOT_OPTIONS_REQUEST  *BootOptionsRequest,
+  OUT IPMI_GET_BOOT_OPTIONS_RESPONSE *BootOptionsResponse
+  );
+
 //
 // NetFnStorage
 //
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Ppi/IpmiTransportPpi.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Ppi/IpmiTransportPpi.h
new file mode 100644
index 0000000000..9ecb20f9bf
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Ppi/IpmiTransportPpi.h
@@ -0,0 +1,68 @@
+/** @file
+  IPMI Ttransport PPI Header File.
+
+  @copyright
+  Copyright 2014 - 2021 Intel Corporation. <BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef _IPMI_TRANSPORT_PPI_H_
+#define _IPMI_TRANSPORT_PPI_H_
+
+#include "ServerManagement.h"
+
+typedef struct _PEI_IPMI_TRANSPORT_PPI PEI_IPMI_TRANSPORT_PPI;
+
+#define PEI_IPMI_TRANSPORT_PPI_GUID \
+  { \
+    0x7bf5fecc, 0xc5b5, 0x4b25, 0x81, 0x1b, 0xb4, 0xb5, 0xb, 0x28, 0x79, 0xf7 \
+  }
+
+//
+// Common Defines
+//
+typedef UINT32  BMC_STATUS;
+
+#define BMC_OK        0
+#define BMC_SOFTFAIL  1
+#define BMC_HARDFAIL  2
+#define BMC_UPDATE_IN_PROGRESS  3
+#define BMC_NOTREADY  4
+
+
+//
+//  IPMI Function Prototypes
+//
+typedef
+EFI_STATUS
+(EFIAPI *PEI_IPMI_SEND_COMMAND) (
+  IN PEI_IPMI_TRANSPORT_PPI            *This,
+  IN UINT8                             NetFunction,
+  IN UINT8                             Lun,
+  IN UINT8                             Command,
+  IN UINT8                             *CommandData,
+  IN UINT32                            CommandDataSize,
+  OUT UINT8                            *ResponseData,
+  OUT UINT32                           *ResponseDataSize
+  );
+
+typedef
+EFI_STATUS
+(EFIAPI *PEI_IPMI_GET_CHANNEL_STATUS) (
+  IN PEI_IPMI_TRANSPORT_PPI       *This,
+  OUT BMC_STATUS                  *BmcStatus,
+  OUT SM_COM_ADDRESS              *ComAddress
+  );
+
+//
+// IPMI TRANSPORT PPI
+//
+struct _PEI_IPMI_TRANSPORT_PPI {
+  UINT64                      Revision;
+  PEI_IPMI_SEND_COMMAND       IpmiSubmitCommand;
+  PEI_IPMI_GET_CHANNEL_STATUS GetBmcStatus;
+};
+
+extern EFI_GUID gPeiIpmiTransportPpiGuid;
+
+#endif
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Protocol/IpmiTransportProtocol.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Protocol/IpmiTransportProtocol.h
new file mode 100644
index 0000000000..2ee6f98e07
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Protocol/IpmiTransportProtocol.h
@@ -0,0 +1,75 @@
+/** @file
+  IPMITtransport Protocol Header File.
+
+  @copyright
+  Copyright 2011 - 2021 Intel Corporation. <BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef _IPMI_TRANSPORT_PROTO_H_
+#define _IPMI_TRANSPORT_PROTO_H_
+
+#include <ServerManagement.h>
+
+typedef struct _IPMI_TRANSPORT IPMI_TRANSPORT;
+
+#define IPMI_TRANSPORT_PROTOCOL_GUID \
+  { \
+    0x6bb945e8, 0x3743, 0x433e, 0xb9, 0xe, 0x29, 0xb3, 0xd, 0x5d, 0xc6, 0x30 \
+  }
+
+#define SMM_IPMI_TRANSPORT_PROTOCOL_GUID \
+{ \
+  0x8bb070f1, 0xa8f3, 0x471d, 0x86, 0x16, 0x77, 0x4b, 0xa3, 0xf4, 0x30, 0xa0 \
+}
+
+//
+// Common Defines
+//
+typedef UINT32  BMC_STATUS;
+
+#define BMC_OK                  0
+#define BMC_SOFTFAIL            1
+#define BMC_HARDFAIL            2
+#define BMC_UPDATE_IN_PROGRESS  3
+#define BMC_NOTREADY            4
+
+//
+//  IPMI Function Prototypes
+//
+typedef
+EFI_STATUS
+(EFIAPI *IPMI_SEND_COMMAND) (
+  IN IPMI_TRANSPORT                    *This,
+  IN UINT8                             NetFunction,
+  IN UINT8                             Lun,
+  IN UINT8                             Command,
+  IN UINT8                             *CommandData,
+  IN UINT32                            CommandDataSize,
+  OUT UINT8                            *ResponseData,
+  OUT UINT32                           *ResponseDataSize
+  );
+
+typedef
+EFI_STATUS
+(EFIAPI *IPMI_GET_CHANNEL_STATUS) (
+  IN IPMI_TRANSPORT                   *This,
+  OUT BMC_STATUS                      *BmcStatus,
+  OUT SM_COM_ADDRESS                  *ComAddress
+  );
+
+//
+// IPMI TRANSPORT PROTOCOL
+//
+struct _IPMI_TRANSPORT {
+  UINT64                      Revision;
+  IPMI_SEND_COMMAND           IpmiSubmitCommand;
+  IPMI_GET_CHANNEL_STATUS     GetBmcStatus;
+  EFI_HANDLE                  IpmiHandle;
+  UINT8                       CompletionCode;
+};
+
+extern EFI_GUID gIpmiTransportProtocolGuid;
+extern EFI_GUID gSmmIpmiTransportProtocolGuid;
+
+#endif
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/ServerManagement.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/ServerManagement.h
new file mode 100644
index 0000000000..244b86e91a
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/ServerManagement.h
@@ -0,0 +1,337 @@
+/** @file
+  Generic Definations for Server Management Header File.
+
+  @copyright
+  Copyright 1999 - 2021 Intel Corporation. <BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef _SERVER_MANAGEMENT_H_
+#define _SERVER_MANAGEMENT_H_
+
+//
+// Defines
+//
+#define PRIM_IPMB_CHANNEL       0x0
+#define BMC_LUN                 0x0
+#define PRESENT_INTERFACE       0xE
+#define SYSTEM_INTERFACE        0xF
+#define COMPLETE_SEL_RECORD     0xFF
+#define IPMI_UNSPECIFIED_ERROR  0xFF
+
+//
+// Net Function Defines.
+//
+#define SM_CHASSIS      0x0
+#define SM_BRIDGE       0x2
+#define SM_SENSOR_EVENT 0x4
+#define SM_APPLICATION  0x6
+#define SM_FIRMWARE     0x8
+#define SM_STORAGE      0xA
+#define SM_TRANSPORT    0xC
+#define SM_GROUP_EXT    0x2C
+#define SM_OEM_GROUP    0x2E
+#define SM_INTEL_OEM    0x30
+#define SM_SOL_OEM      0x34
+
+//
+// IPMI Command Definations.
+//
+#define IPMI_GET_DEVICE_ID          1
+#define IPMI_COLD_RESET             2
+#define IPMI_WARM_RESET             3
+#define IPMI_GET_SELF_TEST_RESULTS  4
+#define IPMI_MFG_MODE_ON            5
+#define IPMI_SET_ACPI_POWER_STATE   6
+#define IPMI_GET_ACPI_POWER_STATE   7
+#define IPMI_GET_DEVICE_GUID        8
+
+#define IPMI_GET_MESSAGE_FLAGS      0x31
+#define IPMI_GET_MESSAGE            0x33
+#define IPMI_SEND_MESSAGE           0x34
+
+#define RESERVE_SEL_ENTRY               0x42
+#define ADD_SEL_ENTRY                   0x44
+#define GET_SEL_ENTRY                   0x43
+#define DELETE_SEL_ENTRY                0x46
+#define CLEAR_SEL_ENTRY                 0x47
+#define SET_BMC_GLOBALS                 0x2E
+#define GET_BMC_GLOBALS                 0x2F
+#define SET_SEL_TIME                    0x49
+
+#define GET_SELF_TEST_RESULTS           0x4
+
+#define NMI_ENABLE_DISABLE              0xF7
+
+//
+// Controller Attributes
+//
+#define IPMI_SENSOR_DEVICE_SUPPORT    0x1
+#define IPMB_SDR_REPOSITORY_SUPPORT   0x2
+#define IPMI_SEL_DEVICE_SUPPORT       0x4
+#define IPMI_FRU_INVENTORY_SUPPORT    0x8
+#define IPMB_EVENT_RECEIVER_SUPPORT   0x10
+#define IPMB_EVENT_GENERATOR_SUPPORT  0x20
+#define ICMB_BRIDGE_SUPPORT           0x40
+#define ICMB_CHASSIS_DEVICE_SUPPORT   0x80
+#define SM_TCP_SUPPORT                0x100
+#define SM_UDP_SUPPORT                0x200
+#define SM_IPV4_SUPPORT               0x400
+#define SM_IPV6_SUPPORT               0x800
+#define SM_RS232_SUPPORT              0x1000
+
+//
+// Sensor Type Definations
+//
+typedef enum {
+  SensorReserved,
+  SensorTemperature,
+  SensorVoltage,
+  SensorCurrent,
+  SensorFan,
+  SensorPhysicalSecurity,
+  SensorPlatformSecurityViolationAttempt,
+  SensorProcessor,
+  SensorPowerSupply,
+  SensorPowerUnit,
+  SensorCoolingDevice,
+  SensorOtherUnits,
+  SensorMemory,
+  SensorDriveSlot,
+  SensorPOSTMemoryResize,
+  SensorSystemFirmwareProgress,
+  SensorEventLoggingDisabled,
+  SensorWatchdog1,
+  SensorSystemEvent,
+  SensorCriticalInterrupt,
+  SensorButton,
+  SensorModuleBoard,
+  SensorMicrocontrollerCoprocessor,
+  SensorAddinCard,
+  SensorChassis,
+  SensorChipSet,
+  SensorOtherFRU,
+  SensorCableInterconnect,
+  SensorTerminator,
+  SensorSystemBootInitiated,
+  SensorBootError,
+  SensorOSBoot,
+  SensorOSCriticalStop,
+  SensorSlotConnector,
+  SensorSystemACPIPowerState,
+  SensorWatchdog2,
+  SensorPlatformAlert,
+  SensorEntityPresence,
+  SensorMonitorASIC,
+  SensorLAN,
+  SensorManagementSubsystemHealth
+} SM_SENSOR_TYPE;
+
+//
+// Sensor Event Type Code
+//
+#define SENSOR_THRESHOLD_EVENT_TYPE 1
+#define SENSOR_SPECIFIC_EVENT_TYPE  0x6F
+
+//
+// THRESHOLD SENSOR TYPE BIT MASK
+//
+#define LOWER_NON_CRITICAL_GOING_LOW  0x1
+#define LOWER_NON_CRITICAL_GOING_HI   0x2
+#define LOWER_CRITICAL_GOING_LOW      0x4
+#define LOWER_CRITICAL_GOING_HI       0x8
+#define LOWER_NON_RECOVER_GOING_LOW   0x10
+#define LOWER_NON_RECOVER_GOING_HI    0x20
+#define UPPER_NON_CRITICAL_GOING_LOW  0x40
+#define UPPER_NON_CRITICAL_GOING_HI   0x80
+#define UPPER_CRITICAL_GOING_LOW      0x100
+#define UPPER_CRITICAL_GOING_HI       0x200
+#define UPPER_NON_RECOVER_GOING_LOW   0x400
+#define UPPER_NON_RECOVER_GOING_HI    0x800
+
+//
+// Server Management COM Addressing types
+//
+typedef enum {
+  SmReserved,
+  SmIpmb,
+  SmIcmb1_0,
+  SmIcmb0_9,
+  Sm802_3_Lan,
+  SmRs_232,
+  SmOtherLan,
+  SmPciSmBus,
+  SmSmBus1_0,
+  SmSmBus2_0,
+  SmUsb1_x,
+  SmUsb2_x,
+  SmBmc
+} SM_CHANNEL_MEDIA_TYPE;
+
+typedef enum {
+  SmTcp,
+  SmUdp,
+  SmIcmp,
+  SmIpmi
+} SM_PROTOCOL_TYPE;
+
+typedef enum {
+  SmMessage,
+  SmRawData
+} SM_DATA_TYPE;
+
+typedef struct {
+  BOOLEAN IpAddressType;
+  UINT16  IpPort;
+  UINT8   IpAddress[16];
+} SM_IP_ADDRESS;
+
+typedef struct {
+  UINT8 SlaveAddress;
+  UINT8 LunAddress;
+  UINT8 NetFunction;
+  UINT8 ChannelAddress;
+} SM_IPMI_ADDRESS;
+
+typedef struct {
+  UINT8 SerialPortNumber;
+} SM_SERIAL_ADDRESS;
+
+typedef union {
+  SM_IP_ADDRESS     IpAddress;
+  SM_IPMI_ADDRESS   BmcAddress;
+  SM_SERIAL_ADDRESS SerialAddress;
+} SM_COM_ADDRESS_TYPE;
+
+typedef struct {
+  SM_CHANNEL_MEDIA_TYPE ChannelType;
+  SM_COM_ADDRESS_TYPE   Address;
+} SM_COM_ADDRESS;
+
+#pragma pack(1)
+//
+// Sensor Reading Data
+//
+typedef enum {
+  DataLinear,                                   // Linear
+  DataNaturalLog,                               // Ln(x)
+  DataLog10,                                    // Log10(x)
+  DataLog2,                                     // Log2(x)
+  Datae,                                        // e
+  DataExp10,                                    // Exp 10
+  DataExp2,                                     // Exp 2
+  DataInverse,                                  // 1/x
+  DataSqr,                                      // Sqr
+  DataCube,                                     // Cube
+  DataSqrt,                                     // Square Root
+  DataCubeInverse                               // Cube-1 (x)
+} LINERIZATION_TYPE;
+
+typedef union {
+  UINT8   SensorUint8Data[2];
+  UINT16  SensorUint16Data;
+} SENSOR_SPLIT_DATA;
+
+typedef struct {
+  LINERIZATION_TYPE Linearization;              // L
+  UINT8             Tolerance;                  // Tolerance
+  UINT8             AdditiveOffsetExp;          // k1
+  UINT8             AccuracyExp;                // Accuracy Exponential
+  UINT8             ResultExponent;             // k2
+  SENSOR_SPLIT_DATA IntegerConstantMultiplier;  // M
+  SENSOR_SPLIT_DATA AdditiveOffset;             // B
+  SENSOR_SPLIT_DATA Accuracy;                   // Accuracy
+} SENSOR_CONVERSION_DATA;
+
+//
+// Server Management Controller Information
+//
+typedef struct {
+  UINT8   CompletionCode;
+  UINT8   DeviceId;
+  UINT8   DeviceRevision : 4;
+  UINT8   Reserved : 3;
+  UINT8   DeviceSdr : 1;
+  UINT8   MajorFirmwareRev : 7;
+  UINT8   UpdateMode : 1;
+  UINT8   MinorFirmwareRev;
+  UINT8   SpecificationVersion;
+  UINT8   SensorDeviceSupport : 1;
+  UINT8   SdrRepositorySupport : 1;
+  UINT8   SelDeviceSupport : 1;
+  UINT8   FruInventorySupport : 1;
+  UINT8   IPMBMessageReceiver : 1;
+  UINT8   IPMBMessageGenerator : 1;
+  UINT8   BridgeSupport : 1;
+  UINT8   ChassisSupport : 1;
+  UINT8   ManufacturerId[3];
+  UINT16  ProductId;
+  UINT32  AuxFirmwareRevInfo;
+} SM_CTRL_INFO;
+
+typedef struct {
+  UINT8 Reserved1 : 1;
+  UINT8 ControllerSlaveAddress : 7;
+  UINT8 FruDeviceId;
+  UINT8 BusId : 3;
+  UINT8 Lun : 2;
+  UINT8 Reserved : 2;
+  UINT8 LogicalFruDevice : 1;
+  UINT8 Reserved3 : 4;
+  UINT8 ChannelNumber : 4;
+} FRU_DATA_INFO;
+#pragma pack()
+
+typedef enum {
+  Unicode,
+  BcdPlus,
+  Ascii6BitPacked,
+  AsciiLatin1
+} SENSOR_ID_STRING_TYPE;
+
+//
+// SENSOR Structures
+//
+typedef struct {
+  BOOLEAN                     Valid;              // Data is Valid
+  SENSOR_CONVERSION_DATA      ConversionParam;    // Conversion Parameters
+  UINT8                       UpperNonRec;        // Upper Non Recoverable
+  UINT8                       UpperCritical;      // Upper Critical
+  UINT8                       UpperNonCritical;   // Upper Non Critical
+  UINT8                       LowerNonRec;        // Lower Non Recoverable
+  UINT8                       LowerCritical;      // Lower Critical
+  UINT8                       LowerNonCritical;   // Lower Non Critical
+} SENSOR_THRESHOLD_STRUCT;
+
+typedef struct {
+  BOOLEAN                     Valid;              // Structure Valid
+  SENSOR_CONVERSION_DATA      ConversionParam;    // Conversion Parameters
+  SENSOR_ID_STRING_TYPE       SensorIdStringType; // Sensor ID String type
+  UINT8                       NominalReading;     // Nominal Reading of the Sensor
+  UINT8                       SensorId[16];       // Sensor Description
+} SENSOR_READING_STRUCT;
+
+//
+//  IPMI HOB
+//
+typedef struct {
+  UINT16  IoBasePort;
+} IPMI_HOB_DATA;
+
+//
+// COM Layer Callback
+//
+typedef
+EFI_STATUS
+(EFIAPI *SM_CALLBACK_PROC) (
+  OUT  EFI_STATUS                          Status,
+  IN  VOID                                 *UserContext
+  );
+
+typedef struct {
+  SM_CALLBACK_PROC      SmCallback;
+  VOID                  *UserContext;
+} SM_CALLBACK;
+
+#endif  // _SERVER_MANAGEMENT_H_
+
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/SmStatusCodes.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/SmStatusCodes.h
new file mode 100644
index 0000000000..08cd3b21b9
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/SmStatusCodes.h
@@ -0,0 +1,98 @@
+/** @file
+  Efi Server Management Status Code Header File.
+
+  @copyright
+  Copyright 2011 - 2021 Intel Corporation. <BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef _SM_STATUS_CODE_H_
+#define _SM_STATUS_CODE_H_
+
+//
+// Computing Unit Host Processor Subclass Error Code definitions.
+//
+#define CU_HP_EC_MISMATCH_STEPPING              (EFI_SUBCLASS_SPECIFIC | 0x0000000E)
+#define CU_HP_EC_MISMATCH_FAMILY                (EFI_SUBCLASS_SPECIFIC | 0x0000000F)
+#define CU_HP_EC_MISMATCH_MODEL                 (EFI_SUBCLASS_SPECIFIC | 0x00000010)
+#define CU_HP_EC_MISMATCH_FSB                   (EFI_SUBCLASS_SPECIFIC | 0x00000011)
+#define CU_HP_EC_MISMATCH_SPEED                 (EFI_SUBCLASS_SPECIFIC | 0x00000012)
+#define CU_HP_EC_UNSUPPORTED_PROCESSOR_FAMILY   (EFI_SUBCLASS_SPECIFIC | 0x00000013)
+#define CU_HP_EC_MISMATCH_CACHE_SIZE            (EFI_SUBCLASS_SPECIFIC | 0x00000014)
+#define CU_HP_EC_UNSUPPORTED_CHIPSET            (EFI_SUBCLASS_SPECIFIC | 0x00000015)
+#define CU_HP_EC_MISMATCH_VOLTAGE               (EFI_SUBCLASS_SPECIFIC | 0x00000016)
+
+//
+// Computing Unit Firmware Processor Subclass Error Code definitions.
+//
+#define CU_FP_EC_FRB2_WATCHDOG_TIMEOUT          (EFI_SUBCLASS_SPECIFIC | 0x00000003)
+#define CU_FP_EC_OS_WATCHDOG_TIMEOUT            (EFI_SUBCLASS_SPECIFIC | 0x00000004)
+#define CU_FP_EC_SDR_EMPTY                      (EFI_SUBCLASS_SPECIFIC | 0x00000005)
+#define CU_FP_EC_FORCE_UPDATE_MODE              (EFI_SUBCLASS_SPECIFIC | 0x00000006)
+#define CU_FP_EC_FW_MISMATCH                    (EFI_SUBCLASS_SPECIFIC | 0x00000007)
+
+//
+// Computing Unit Memory Subclass Error Code definitions.
+//
+#define CU_MEMORY_EC_FAILED                     (EFI_SUBCLASS_SPECIFIC | 0x0000000B)
+#define CU_MEMORY_EC_UNSUPPORTED                (EFI_SUBCLASS_SPECIFIC | 0x0000000C)
+#define CU_MEMORY_EC_CLTT_FAILED                (EFI_SUBCLASS_SPECIFIC | 0x0000000D)
+#define CU_MEMORY_EC_DCPMM_INV_POP              (EFI_SUBCLASS_SPECIFIC | 0x0000000E)
+
+//
+// Peripheral Class Error Code definitions.
+//
+#define P_EC_FW_CORRUPTED              0x0000000A
+#define P_EC_RESOURCE_CONSUMED_BY_BMC  0x0000000B
+
+//
+// IO Bus Subclass definitions.
+//
+#define IO_BUS_PCI_EXPRESS                      (IO_BUS | 0x000D0000)
+
+//
+// IO Bus Class PCI Subclass Error Code definitions.
+//
+#define IOB_PCI_EC_OUT_OF_RESOURCES             (EFI_SUBCLASS_SPECIFIC | 0x00000002)
+
+//
+// IO Bus Class PCI EXPRESS Subclass Error Code definitions.
+//
+#define IOB_PCI_EXP_EC_PERR                     (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define IOB_PCI_EXP_EC_SERR                     (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+#define IOB_PCI_EXP_EC_TRAINING_FAILED          (EFI_SUBCLASS_SPECIFIC | 0x00000002)
+#define IOB_PCI_EXP_EC_DEGRADED_LINK            (EFI_SUBCLASS_SPECIFIC | 0x00000003)
+#define IOB_PCI_EXP_EC_IBIST_FAILED             (EFI_SUBCLASS_SPECIFIC | 0x00000004)
+
+//
+// Software Subclass definitions.
+//
+#define SOFTWARE_SYSTEM_ERROR                   (EFI_SOFTWARE | 0x00130000)
+#define SYSTEM_FRONT_PANEL                      (EFI_SOFTWARE | 0x00140000)
+#define SOFTWARE_EFI_BMC                        (EFI_SOFTWARE | 0x00150000)
+
+//
+// Software Class DXE BS Driver Subclass Progress Code definitions.
+//
+#define SW_DXE_BS_END_OF_POST                   (EFI_SUBCLASS_SPECIFIC | 0x00000007)
+
+//
+// Software Class Error Code definitions.
+//
+#define SW_EC_PWD_CLEAR_JMPR_SET       0x00000012
+
+//
+// Software Class PEI Module Subclass Error Code definitions.
+//
+#define SW_PEIM_WATCHDOG_TIMEOUT                (EFI_SUBCLASS_SPECIFIC | 0x00000002)
+#define SW_PEIM_OS_WATCHDOG_TIMEOUT             (EFI_SUBCLASS_SPECIFIC | 0x00000003)
+
+//
+// Software Class System Subclass Error Code definitions.
+//
+#define SW_EC_CMOS_DATE_TIME_ERROR              (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define SW_EC_BACKUP_BIOS_FLASH_ERROR           (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+
+
+#endif // _SM_STATUS_CODE_H_
+
-- 
2.27.0.windows.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [edk2-platforms] [PATCH v1 2/9] IpmiFeaturePkg: Add IpmiBaseLib and IpmiCommandLib
  2021-03-02  2:27 [edk2-platforms] [PATCH v1 0/9] IpmiFeaturePkg: Add IPMI transport drivers Nate DeSimone
  2021-03-02  2:27 ` [edk2-platforms] [PATCH v1 1/9] IpmiFeaturePkg: Add IPMI driver Include headers Nate DeSimone
@ 2021-03-02  2:27 ` Nate DeSimone
  2021-03-02  2:27 ` [edk2-platforms] [PATCH v1 3/9] IpmiFeaturePkg: Add IpmiInit driver DEPEXs Nate DeSimone
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Nate DeSimone @ 2021-03-02  2:27 UTC (permalink / raw)
  To: devel; +Cc: Isaac Oram, Sai Chaganty, Liming Gao, Michael Kubacki

From: Isaac Oram <isaac.w.oram@intel.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3242

Adds IpmiBaseLib and adds new commands to IpmiCommandLib

Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Michael Kubacki <michael.kubacki@microsoft.com>
Signed-off-by: Isaac Oram <isaac.w.oram@intel.com>
Co-authored-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
---
 .../Library/IpmiBaseLib/IpmiBaseLib.c         | 155 +++++++++++++++
 .../Library/IpmiBaseLib/IpmiBaseLib.inf       |  28 +++
 .../Library/IpmiBaseLibNull/IpmiBaseLibNull.c |  76 ++++++++
 .../IpmiBaseLibNull/IpmiBaseLibNull.inf       |  36 ++++
 .../Library/IpmiCommandLib/IpmiCommandLib.inf |   4 +-
 .../IpmiCommandLib/IpmiCommandLibNetFnApp.c   |   7 +-
 .../IpmiCommandLibNetFnChassis.c              |  51 ++++-
 .../IpmiCommandLibNetFnStorage.c              |   7 +-
 .../IpmiCommandLibNetFnTransport.c            |   7 +-
 .../Library/PeiIpmiBaseLib/PeiIpmiBaseLib.c   | 111 +++++++++++
 .../Library/PeiIpmiBaseLib/PeiIpmiBaseLib.inf |  30 +++
 .../Library/SmmIpmiBaseLib/SmmIpmiBaseLib.c   | 180 ++++++++++++++++++
 .../Library/SmmIpmiBaseLib/SmmIpmiBaseLib.inf |  29 +++
 13 files changed, 703 insertions(+), 18 deletions(-)
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLib/IpmiBaseLib.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLib/IpmiBaseLib.inf
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLibNull/IpmiBaseLibNull.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLibNull/IpmiBaseLibNull.inf
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/PeiIpmiBaseLib/PeiIpmiBaseLib.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/PeiIpmiBaseLib/PeiIpmiBaseLib.inf
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/SmmIpmiBaseLib/SmmIpmiBaseLib.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/SmmIpmiBaseLib/SmmIpmiBaseLib.inf

diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLib/IpmiBaseLib.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLib/IpmiBaseLib.c
new file mode 100644
index 0000000000..6b2e0a9e1e
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLib/IpmiBaseLib.c
@@ -0,0 +1,155 @@
+/** @file
+  A Library to support all BMC access via IPMI command during Dxe Phase.
+
+  @copyright
+  Copyright 1999 - 2021 Intel Corporation. <BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <PiDxe.h>
+#include <Protocol/IpmiTransportProtocol.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/DebugLib.h>
+
+STATIC IPMI_TRANSPORT     *mIpmiTransport = NULL;
+VOID                      *mEfiIpmiProtocolNotifyReg;
+EFI_EVENT                 mEfiIpmiProtocolEvent;
+
+/**
+  Callback function for locating the IpmiTransport protocol.
+  @param[in]  Event    Event on which the callback is called.
+  @param[in]  Context  The context of the Callback.
+
+  @retval EFI_SUCCESS  Return from EfiLocateProtocolInterface function.
+  @retval Other        Failure.
+
+**/
+EFI_STATUS
+NotifyIpmiTransportCallback (
+  IN EFI_EVENT Event,
+  IN VOID      *Context
+  )
+{
+  EFI_STATUS  Status;
+
+  Status = EFI_SUCCESS;
+  if (mIpmiTransport == NULL) {
+    Status = gBS->LocateProtocol (
+                    &gIpmiTransportProtocolGuid,
+                    NULL,
+                    (VOID **) &mIpmiTransport
+                    );
+  }
+
+  return Status;
+}
+
+/**
+  Initialize the global varible with the pointer of IpmiTransport Protocol.
+
+  @retval EFI_SUCCESS  Always return success.
+
+**/
+EFI_STATUS
+InitializeIpmiBase (
+  VOID
+  )
+{
+  EFI_STATUS  Status;
+
+  if (mIpmiTransport == NULL) {
+    Status = gBS->CreateEvent (EVT_NOTIFY_SIGNAL, TPL_CALLBACK, (EFI_EVENT_NOTIFY) NotifyIpmiTransportCallback, NULL, &mEfiIpmiProtocolEvent);
+    ASSERT_EFI_ERROR (Status);
+    if (Status != EFI_SUCCESS) {
+      return Status;
+    }
+
+    Status = gBS->RegisterProtocolNotify (&gIpmiTransportProtocolGuid, mEfiIpmiProtocolEvent, &mEfiIpmiProtocolNotifyReg);
+    ASSERT_EFI_ERROR (Status);
+    if (Status != EFI_SUCCESS) {
+      return Status;
+    }
+
+    gBS->SignalEvent (mEfiIpmiProtocolEvent);
+  }
+
+  return EFI_SUCCESS;
+}
+
+/**
+  Routine to send commands to BMC.
+  @param[in]       NetFunction        Net function of the command
+  @param[in]       Command            IPMI Command
+  @param[in]       CommandData        Command Data
+  @param[in]       CommandDataSize    Size of CommandData
+  @param[out]  ResponseData       Response Data
+  @param[in, out]  ResponseDataSize   Response Data Size
+
+  @retval EFI_SUCCESS            Return Successly.
+  @retval EFI_NOT_AVAILABLE_YET  IpmiTransport Protocol is not installed yet
+  @retval Other                  Failure.
+
+**/
+EFI_STATUS
+IpmiSubmitCommand (
+  IN UINT8        NetFunction,
+  IN UINT8        Command,
+  IN UINT8        *CommandData,
+  IN UINT32       CommandDataSize,
+  OUT UINT8       *ResponseData,
+  IN OUT UINT32   *ResponseDataSize
+  )
+{
+  EFI_STATUS  Status;
+
+  Status = gBS->LocateProtocol (&gIpmiTransportProtocolGuid, NULL, (VOID **) &mIpmiTransport);
+  if (EFI_ERROR (Status)) {
+    ASSERT_EFI_ERROR (Status);
+    return Status;
+  }
+
+  Status = mIpmiTransport->IpmiSubmitCommand (
+                             mIpmiTransport,
+                             NetFunction,
+                             0,
+                             Command,
+                             CommandData,
+                             CommandDataSize,
+                             ResponseData,
+                             ResponseDataSize
+                             );
+  return Status;
+}
+
+/**
+  Routine to send commands to BMC.
+  @param[out]  BmcStatus    A pointer to the BMC_STATUS.
+  @param[out]  ComAddress   Pointer to the SM_COM_ADDRESS.
+
+  @retval EFI_SUCCESS            Restart Successly.
+  @retval EFI_NOT_AVAILABLE_YET  IpmiTransport Protocol is not installed yet.
+  @retval Other                  Failure.
+
+**/
+EFI_STATUS
+IpmiGetBmcStatus (
+  OUT BMC_STATUS                         *BmcStatus,
+  OUT SM_COM_ADDRESS                     *ComAddress
+  )
+{
+  EFI_STATUS  Status;
+
+  Status = gBS->LocateProtocol (&gIpmiTransportProtocolGuid, NULL, (VOID **) &mIpmiTransport);
+  if (EFI_ERROR (Status)) {
+    ASSERT_EFI_ERROR (Status);
+    return Status;
+  }
+
+  Status = mIpmiTransport->GetBmcStatus (
+                             mIpmiTransport,
+                             BmcStatus,
+                             ComAddress
+                             );
+  return Status;
+}
+
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLib/IpmiBaseLib.inf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLib/IpmiBaseLib.inf
new file mode 100644
index 0000000000..b429d3b7b9
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLib/IpmiBaseLib.inf
@@ -0,0 +1,28 @@
+## @file
+#
+# @copyright
+# Copyright 2010 - 2021 Intel Corporation. <BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = IpmiBaseLib
+  FILE_GUID                      = 2B5AD78E-5CF8-45d2-B2AC-749A09425911
+  MODULE_TYPE                    = UEFI_DRIVER
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = IpmiBaseLib|DXE_RUNTIME_DRIVER DXE_DRIVER UEFI_APPLICATION UEFI_DRIVER
+
+[sources]
+  IpmiBaseLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec
+
+[LibraryClasses]
+  UefiBootServicesTableLib
+  DebugLib
+
+[Protocols]
+  gIpmiTransportProtocolGuid
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLibNull/IpmiBaseLibNull.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLibNull/IpmiBaseLibNull.c
new file mode 100644
index 0000000000..7c4c67f6ac
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLibNull/IpmiBaseLibNull.c
@@ -0,0 +1,76 @@
+/** @file
+  A Null Library to support all BMC access via IPMI command.
+
+  @copyright
+  Copyright 2011 - 2021 Intel Corporation. <BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <Library/BaseLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/DxeServicesLib.h>
+#include <Library/DebugLib.h>
+#include <Library/IpmiBaseLib.h>
+#include <Ppi/IpmiTransportPpi.h>
+
+/**
+
+  Initialize the global varible with the pointer of IpmiTransport Protocol
+
+  @retval EFI_SUCCESS Always return success.
+
+**/
+EFI_STATUS
+InitializeIpmiBase (
+  VOID
+  )
+{
+  return EFI_SUCCESS;
+}
+
+/**
+  Routine to send commands to BMC.
+  @param [in]   NetFunction        Net function of the command
+  @param [in]   Command            IPMI Command
+  @param [in]   CommandData        Command Data
+  @param [in]   CommandDataSize    Size of CommandData
+  @param [out]  ResponseData       Response Data
+  @param [out]  ResponseDataSize   Response Data Size
+
+  @retval EFI_SUCCESS            Restart Successly.
+  @retval EFI_NOT_AVAILABLE_YET  IpmiTransport Protocol is not installed yet.
+  @retval Other                  Failure.
+
+**/
+EFI_STATUS
+IpmiSubmitCommand (
+  IN UINT8     NetFunction,
+  IN UINT8     Command,
+  IN UINT8     *CommandData,
+  IN UINT32    CommandDataSize,
+  OUT UINT8    *ResponseData,
+  OUT UINT32   *ResponseDataSize
+  )
+{
+  return EFI_SUCCESS;
+}
+
+/**
+  Routine to send commands to BMC.
+  @param [out] BmcStatus   A pointer to BMC_STATUS.
+  @param [out] ComAddress  A pointer to SM_COM_ADDRESS.
+
+  @retval EFI_SUCCESS  Restart Successly.
+  @retval EFI_NOT_AVAILABLE_YET - IpmiTransport Protocol is not installed yet.
+  @retval Other        Failure.
+
+**/
+EFI_STATUS
+GetBmcStatus (
+  OUT BMC_STATUS                         *BmcStatus,
+  OUT SM_COM_ADDRESS                     *ComAddress
+  )
+{
+  return EFI_SUCCESS;
+}
+
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLibNull/IpmiBaseLibNull.inf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLibNull/IpmiBaseLibNull.inf
new file mode 100644
index 0000000000..5478f9842b
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLibNull/IpmiBaseLibNull.inf
@@ -0,0 +1,36 @@
+## @file
+#
+# @copyright
+# Copyright 2011 - 2021 Intel Corporation. <BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION                   = 0x00010005
+  BASE_NAME                     = IpmiBaseLibNull
+  FILE_GUID                     = 3444CF4F-8B88-4579-9A95-2E7678C0E945
+  MODULE_TYPE                   = DXE_SMM_DRIVER
+  VERSION_STRING                = 1.0
+  LIBRARY_CLASS                 = IpmiBaseLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES          = IA32 X64
+#
+
+[Sources.common]
+  IpmiBaseLibNull.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec
+
+[LibraryClasses]
+  BaseLib
+  UefiBootServicesTableLib
+  DxeServicesLib
+  DebugLib
+
+[Guids]
+
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLib.inf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLib.inf
index 0bdace8688..f8e7ba5a8f 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLib.inf
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLib.inf
@@ -1,7 +1,7 @@
 ### @file
 # Component description file for IPMI Command Library.
 #
-# Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved.<BR>
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -29,4 +29,4 @@
 [LibraryClasses]
   BaseMemoryLib
   DebugLib
-  IpmiLib
+  IpmiBaseLib
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnApp.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnApp.c
index b57db50610..addabc554e 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnApp.c
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnApp.c
@@ -1,15 +1,14 @@
 /** @file
   IPMI Command - NetFnApp.
 
-Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
-SPDX-License-Identifier: BSD-2-Clause-Patent
-
+  Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
 #include <PiPei.h>
 #include <Library/BaseMemoryLib.h>
 #include <Library/DebugLib.h>
-#include <Library/IpmiLib.h>
+#include <Library/IpmiBaseLib.h>
 
 #include <IndustryStandard/Ipmi.h>
 
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnChassis.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnChassis.c
index 1b86aa888e..9c19f52ce4 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnChassis.c
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnChassis.c
@@ -1,15 +1,14 @@
 /** @file
   IPMI Command - NetFnChassis.
 
-Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
-SPDX-License-Identifier: BSD-2-Clause-Patent
-
+  Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
 #include <PiPei.h>
 #include <Library/BaseMemoryLib.h>
 #include <Library/DebugLib.h>
-#include <Library/IpmiLib.h>
+#include <Library/IpmiBaseLib.h>
 
 #include <IndustryStandard/Ipmi.h>
 
@@ -99,3 +98,47 @@ IpmiSetPowerRestorePolicy (
              );
   return Status;
 }
+
+EFI_STATUS
+EFIAPI
+IpmiSetSystemBootOptions (
+  IN  IPMI_SET_BOOT_OPTIONS_REQUEST   *BootOptionsRequest,
+  OUT IPMI_SET_BOOT_OPTIONS_RESPONSE  *BootOptionsResponse
+  )
+{
+  EFI_STATUS                   Status;
+  UINT32                       DataSize;
+
+  DataSize = sizeof(*BootOptionsResponse);
+  Status = IpmiSubmitCommand (
+             IPMI_NETFN_CHASSIS,
+             IPMI_CHASSIS_SET_SYSTEM_BOOT_OPTIONS,
+             (VOID *)BootOptionsRequest,
+             sizeof(*BootOptionsRequest),
+             (VOID *)BootOptionsResponse,
+             &DataSize
+             );
+  return Status;
+}
+
+EFI_STATUS
+EFIAPI
+IpmiGetSystemBootOptions (
+  IN  IPMI_GET_BOOT_OPTIONS_REQUEST  *BootOptionsRequest,
+  OUT IPMI_GET_BOOT_OPTIONS_RESPONSE *BootOptionsResponse
+  )
+{
+  EFI_STATUS                   Status;
+  UINT32                       DataSize;
+
+  DataSize = sizeof(*BootOptionsResponse);
+  Status = IpmiSubmitCommand (
+             IPMI_NETFN_CHASSIS,
+             IPMI_CHASSIS_GET_SYSTEM_BOOT_OPTIONS,
+             (VOID *)BootOptionsRequest,
+             sizeof(*BootOptionsRequest),
+             (VOID *)BootOptionsResponse,
+             &DataSize
+             );
+  return Status;
+}
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnStorage.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnStorage.c
index 8e892c5f84..2215028089 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnStorage.c
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnStorage.c
@@ -1,15 +1,14 @@
 /** @file
   IPMI Command - NetFnStorage.
 
-Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
-SPDX-License-Identifier: BSD-2-Clause-Patent
-
+  Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
 #include <PiPei.h>
 #include <Library/BaseMemoryLib.h>
 #include <Library/DebugLib.h>
-#include <Library/IpmiLib.h>
+#include <Library/IpmiBaseLib.h>
 
 #include <IndustryStandard/Ipmi.h>
 
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnTransport.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnTransport.c
index 3b9b17b909..7dfcf86126 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnTransport.c
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiCommandLib/IpmiCommandLibNetFnTransport.c
@@ -1,15 +1,14 @@
 /** @file
   IPMI Command - NetFnTransport.
 
-Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
-SPDX-License-Identifier: BSD-2-Clause-Patent
-
+  Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
 #include <PiPei.h>
 #include <Library/BaseMemoryLib.h>
 #include <Library/DebugLib.h>
-#include <Library/IpmiLib.h>
+#include <Library/IpmiBaseLib.h>
 
 #include <IndustryStandard/Ipmi.h>
 
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/PeiIpmiBaseLib/PeiIpmiBaseLib.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/PeiIpmiBaseLib/PeiIpmiBaseLib.c
new file mode 100644
index 0000000000..8679cd95db
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/PeiIpmiBaseLib/PeiIpmiBaseLib.c
@@ -0,0 +1,111 @@
+/** @file
+  A Library to support all BMC access via IPMI command during PEI Phase.
+
+  @copyright
+  Copyright 2017 - 2021 Intel Corporation. <BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <PiPei.h>
+#include <Library/IpmiBaseLib.h>
+#include <Library/PeiServicesLib.h>
+#include <Library/DebugLib.h>
+#include <Ppi/IpmiTransportPpi.h>
+
+
+/**
+  Initialize the global varible with the pointer of IpmiTransport Protocol.
+
+  @return EFI_SUCCESS - Always return success
+
+**/
+EFI_STATUS
+InitializeIpmiBase (
+  VOID
+  )
+{
+  EFI_STATUS                                Status;
+  PEI_IPMI_TRANSPORT_PPI                    *IpmiTransport;
+
+  Status = PeiServicesLocatePpi (&gPeiIpmiTransportPpiGuid, 0, NULL, (VOID **) &IpmiTransport);
+  if (EFI_ERROR (Status)) {
+    ASSERT_EFI_ERROR (Status);
+  }
+  return Status;
+}
+
+/**
+  Routine to send commands to BMC.
+
+  @param NetFunction       - Net function of the command
+  @param Command           - IPMI Command
+  @param CommandData       - Command Data
+  @param CommandDataSize   - Size of CommandData
+  @param ResponseData      - Response Data
+  @param ResponseDataSize  - Response Data Size
+
+  @return EFI_NOT_AVAILABLE_YET - IpmiTransport Protocol is not installed yet
+
+**/
+EFI_STATUS
+IpmiSubmitCommand (
+  IN UINT8        NetFunction,
+  IN UINT8        Command,
+  IN UINT8        *CommandData,
+  IN UINT32       CommandDataSize,
+  OUT UINT8       *ResponseData,
+  IN OUT UINT32   *ResponseDataSize
+  )
+{
+  EFI_STATUS                                Status;
+  PEI_IPMI_TRANSPORT_PPI                    *IpmiTransport;
+
+  Status = PeiServicesLocatePpi (&gPeiIpmiTransportPpiGuid, 0, NULL, (VOID **) &IpmiTransport);
+  if (EFI_ERROR (Status)) {
+    ASSERT_EFI_ERROR (Status);
+    return Status;
+  }
+  Status = IpmiTransport->IpmiSubmitCommand (
+                            IpmiTransport,
+                            NetFunction,
+                            0,
+                            Command,
+                            CommandData,
+                            CommandDataSize,
+                            ResponseData,
+                            ResponseDataSize
+                            );
+  return Status;
+}
+
+/**
+  Routine to send commands to BMC.
+
+  @param BmcStatus       - Ststus of Bmc
+  @param ComAddress      - IPMI Address
+
+  @return EFI_NOT_AVAILABLE_YET - IpmiTransport Protocol is not installed yet
+
+**/
+EFI_STATUS
+GetBmcStatus (
+  OUT BMC_STATUS                       *BmcStatus,
+  OUT SM_COM_ADDRESS                   *ComAddress
+  )
+{
+  EFI_STATUS                                Status;
+  PEI_IPMI_TRANSPORT_PPI                    *IpmiTransport;
+
+  Status = PeiServicesLocatePpi (&gPeiIpmiTransportPpiGuid, 0, NULL, (VOID **) &IpmiTransport);
+  if (EFI_ERROR (Status)) {
+    ASSERT_EFI_ERROR (Status);
+    return Status;
+  }
+  Status = IpmiTransport->GetBmcStatus (
+                            IpmiTransport,
+                            BmcStatus,
+                            ComAddress
+                            );
+  return Status;
+}
+
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/PeiIpmiBaseLib/PeiIpmiBaseLib.inf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/PeiIpmiBaseLib/PeiIpmiBaseLib.inf
new file mode 100644
index 0000000000..f89614adfb
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/PeiIpmiBaseLib/PeiIpmiBaseLib.inf
@@ -0,0 +1,30 @@
+## @file
+#
+# @copyright
+# Copyright 2014 - 2021 Intel Corporation. <BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = PeiIpmiBaseLib
+  FILE_GUID                      = 616A8628-9A5C-4d19-9C62-3874C5E6F4A6
+  MODULE_TYPE                    = PEIM
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = IpmiBaseLib|PEIM PEI_CORE
+
+[sources]
+  PeiIpmiBaseLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec
+
+[LibraryClasses]
+  DebugLib
+  BaseMemoryLib
+  PeiServicesLib
+
+
+[Ppis]
+  gPeiIpmiTransportPpiGuid
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/SmmIpmiBaseLib/SmmIpmiBaseLib.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/SmmIpmiBaseLib/SmmIpmiBaseLib.c
new file mode 100644
index 0000000000..6282adc269
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/SmmIpmiBaseLib/SmmIpmiBaseLib.c
@@ -0,0 +1,180 @@
+/** @file
+  A Library to support all BMC access via IPMI command during SMM Phase.
+
+  @copyright
+  Copyright 1999 - 2021 Intel Corporation. <BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <PiDxe.h>
+#include <Protocol/IpmiTransportProtocol.h>
+#include <Library/IpmiBaseLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/SmmServicesTableLib.h>
+#include <Library/DebugLib.h>
+
+STATIC IPMI_TRANSPORT     *mIpmiTransport = NULL;
+VOID                      *mEfiIpmiProtocolNotifyReg = NULL;
+EFI_EVENT                 mEfiIpmiProtocolEvent;
+
+/**
+  Callback function for locating the IpmiTransport protocol.
+
+  @param Protocol     A pointer to EFI_GUID
+  @param Interface    A pointer to Interface
+  @param Handle       Handle
+
+  @retval EFI_SUCCESS:               Callback successfully
+
+**/
+EFI_STATUS
+NotifyIpmiTransportCallback (
+  IN CONST EFI_GUID                *Protocol,
+  IN VOID                          *Interface,
+  IN EFI_HANDLE                    Handle
+  )
+{
+  EFI_STATUS  Status;
+  Status = EFI_SUCCESS;
+  if (mIpmiTransport == NULL) {
+    Status = gSmst->SmmLocateProtocol (
+                      &gSmmIpmiTransportProtocolGuid,
+                      NULL,
+                      (VOID **) &mIpmiTransport
+                      );
+  }
+
+  return Status;
+}
+
+/**
+  Routine to send commands to BMC.
+
+  @retval EFI_SUCCESS:        Always return success
+
+**/
+EFI_STATUS
+InitializeIpmiBase (
+  VOID
+  )
+{
+  EFI_STATUS  Status;
+  if (mIpmiTransport == NULL) {
+    Status = gSmst->SmmLocateProtocol (
+                      &gSmmIpmiTransportProtocolGuid,
+                      NULL,
+                      (VOID **) &mIpmiTransport
+                      );
+    if (EFI_ERROR (Status)) {
+      Status = gSmst->SmmRegisterProtocolNotify (
+                        &gSmmIpmiTransportProtocolGuid,
+                        (EFI_SMM_NOTIFY_FN) NotifyIpmiTransportCallback,
+                        &mEfiIpmiProtocolNotifyReg
+                        );
+    }
+    ASSERT_EFI_ERROR (Status);
+    if (Status != EFI_SUCCESS) {
+      return Status;
+    }
+  }
+
+  return EFI_SUCCESS;
+}
+
+/**
+  Routine to send commands to BMC.
+
+  @param NetFunction       - Net function of the command
+  @param Command           - IPMI Command
+  @param CommandData       - Command Data
+  @param CommandDataSize   - Size of CommandData
+  @param ResponseData      - Response Data
+  @param ResponseDataSize  - Response Data Size
+
+  @retval EFI_SUCCESS:               Get successfully
+  @retval EFI_NOT_AVAILABLE_YET
+
+**/
+EFI_STATUS
+IpmiSubmitCommand (
+  IN UINT8        NetFunction,
+  IN UINT8        Command,
+  IN UINT8        *CommandData,
+  IN UINT32       CommandDataSize,
+  OUT UINT8       *ResponseData,
+  IN OUT UINT32   *ResponseDataSize
+  )
+/*++
+
+Routine Description:
+
+  Routine to send commands to BMC
+
+Arguments:
+
+  NetFunction       - Net function of the command
+  Command           - IPMI Command
+  CommandData       - Command Data
+  CommandDataSize   - Size of CommandData
+  ResponseData      - Response Data
+  ResponseDataSize  - Response Data Size
+
+Returns:
+
+  EFI_NOT_AVAILABLE_YET - IpmiTransport Protocol is not installed yet
+
+--*/
+{
+  EFI_STATUS  Status;
+
+  Status = gSmst->SmmLocateProtocol (&gSmmIpmiTransportProtocolGuid, NULL, (VOID **) &mIpmiTransport);
+  if (EFI_ERROR (Status)) {
+    ASSERT_EFI_ERROR (Status);
+    return Status;
+  }
+
+  Status = mIpmiTransport->IpmiSubmitCommand (
+                             mIpmiTransport,
+                             NetFunction,
+                             0,
+                             Command,
+                             CommandData,
+                             CommandDataSize,
+                             ResponseData,
+                             ResponseDataSize
+                             );
+  return Status;
+}
+
+/**
+  Routine to send commands to BMC.
+
+  @param BmcStatus                   The ConnectAllComplete EFI Event.
+  @param ComAddress                  Event context pass to create function
+
+  @retval EFI_SUCCESS:               Get successfully
+  @retval EFI_NOT_AVAILABLE_YET
+
+**/
+EFI_STATUS
+GetBmcStatus (
+  OUT BMC_STATUS                       *BmcStatus,
+  OUT SM_COM_ADDRESS                   *ComAddress
+  )
+{
+  EFI_STATUS  Status;
+
+  Status = gSmst->SmmLocateProtocol (&gSmmIpmiTransportProtocolGuid, NULL, (VOID **) &mIpmiTransport);
+  if (EFI_ERROR (Status)) {
+    ASSERT_EFI_ERROR (Status);
+    return Status;
+  }
+
+  Status = mIpmiTransport->GetBmcStatus (
+                             mIpmiTransport,
+                             BmcStatus,
+                             ComAddress
+                             );
+  return Status;
+}
+
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/SmmIpmiBaseLib/SmmIpmiBaseLib.inf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/SmmIpmiBaseLib/SmmIpmiBaseLib.inf
new file mode 100644
index 0000000000..bb1ccf1ca2
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/SmmIpmiBaseLib/SmmIpmiBaseLib.inf
@@ -0,0 +1,29 @@
+## @file
+#
+# @copyright
+# Copyright 2010 - 2021 Intel Corporation. <BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = SmmIpmiBaseLib
+  FILE_GUID                      = 2B5AD78E-5CF8-45d2-B2AC-749A09425911
+  MODULE_TYPE                    = DXE_SMM_DRIVER
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = IpmiBaseLib|DXE_SMM_DRIVER SMM_CORE
+
+[sources]
+  SmmIpmiBaseLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec
+
+[LibraryClasses]
+  UefiBootServicesTableLib
+  DebugLib
+  SmmServicesTableLib
+
+[Protocols]
+  gSmmIpmiTransportProtocolGuid
-- 
2.27.0.windows.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [edk2-platforms] [PATCH v1 3/9] IpmiFeaturePkg: Add IpmiInit driver DEPEXs
  2021-03-02  2:27 [edk2-platforms] [PATCH v1 0/9] IpmiFeaturePkg: Add IPMI transport drivers Nate DeSimone
  2021-03-02  2:27 ` [edk2-platforms] [PATCH v1 1/9] IpmiFeaturePkg: Add IPMI driver Include headers Nate DeSimone
  2021-03-02  2:27 ` [edk2-platforms] [PATCH v1 2/9] IpmiFeaturePkg: Add IpmiBaseLib and IpmiCommandLib Nate DeSimone
@ 2021-03-02  2:27 ` Nate DeSimone
  2021-03-02  2:27 ` [edk2-platforms] [PATCH v1 4/9] IpmiFeaturePkg: Add GenericIpmi driver common code Nate DeSimone
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Nate DeSimone @ 2021-03-02  2:27 UTC (permalink / raw)
  To: devel; +Cc: Isaac Oram, Sai Chaganty, Liming Gao, Michael Kubacki

From: Isaac Oram <isaac.w.oram@intel.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3242

Adds IPMI Transport Protocol/PPI to the
IpmiInit PEIM and DXE driver's DEPEXs

Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Michael Kubacki <michael.kubacki@microsoft.com>
Signed-off-by: Isaac Oram <isaac.w.oram@intel.com>
Co-authored-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
---
 .../IpmiFeaturePkg/IpmiInit/DxeIpmiInit.c                   | 4 ++--
 .../IpmiFeaturePkg/IpmiInit/DxeIpmiInit.inf                 | 6 +++---
 .../IpmiFeaturePkg/IpmiInit/PeiIpmiInit.c                   | 4 ++--
 .../IpmiFeaturePkg/IpmiInit/PeiIpmiInit.inf                 | 4 ++--
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiInit/DxeIpmiInit.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiInit/DxeIpmiInit.c
index 0639c3b2a1..baa2f1bb9f 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiInit/DxeIpmiInit.c
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiInit/DxeIpmiInit.c
@@ -1,7 +1,7 @@
 /** @file
     IPMI stack initialization.
 
-Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -79,7 +79,7 @@ Returns:
 
   //
   // Set up a loop to retry for up to 30 seconds. Calculate retries not timeout
-  // so that in case KCS is not enabled and EfiIpmiSendCommand() returns
+  // so that in case KCS is not enabled and IpmiSendCommand() returns
   // immediately we will not wait all the 30 seconds.
   //
   Retries = BMC_TIMEOUT / BMC_KCS_TIMEOUT + 1;
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiInit/DxeIpmiInit.inf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiInit/DxeIpmiInit.inf
index 68ff70cd43..831bfb0b5e 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiInit/DxeIpmiInit.inf
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiInit/DxeIpmiInit.inf
@@ -1,7 +1,7 @@
 ### @file
 # Component description file for IPMI initialization.
 #
-# Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved.<BR>
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -10,7 +10,7 @@
 [Defines]
   INF_VERSION                    = 0x00010005
   BASE_NAME                      = DxeIpmiInit
-  FILE_GUID                      = 07A01ACF-46D5-48de-A63D-74FA92AA8450
+  FILE_GUID                      = 09D958D8-4646-886D-85F1-AA9249CC50FB
   MODULE_TYPE                    = DXE_DRIVER
   VERSION_STRING                 = 1.0
   ENTRY_POINT                    = IpmiInterfaceInit
@@ -31,4 +31,4 @@
   TimerLib
 
 [Depex]
-  TRUE
+  gIpmiTransportProtocolGuid
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiInit/PeiIpmiInit.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiInit/PeiIpmiInit.c
index 062d20c44e..e4d040c381 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiInit/PeiIpmiInit.c
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiInit/PeiIpmiInit.c
@@ -1,7 +1,7 @@
 /** @file
   IPMI stack initialization in PEI.
 
-Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -38,7 +38,7 @@ Returns:
 
   //
   // Set up a loop to retry for up to 30 seconds. Calculate retries not timeout
-  // so that in case KCS is not enabled and EfiIpmiSendCommand() returns
+  // so that in case KCS is not enabled and IpmiSendCommand() returns
   // immediately we will not wait all the 30 seconds.
   //
   Retries = BMC_TIMEOUT_PEI/ BMC_KCS_TIMEOUT + 1;
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiInit/PeiIpmiInit.inf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiInit/PeiIpmiInit.inf
index 825451ede1..607a185eb6 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiInit/PeiIpmiInit.inf
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiInit/PeiIpmiInit.inf
@@ -1,7 +1,7 @@
 ### @file
 # Component description file for IPMI initialization in PEI.
 #
-# Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved.<BR>
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -29,4 +29,4 @@
   IpmiCommandLib
 
 [Depex]
-  TRUE
+  gPeiIpmiTransportPpiGuid
-- 
2.27.0.windows.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [edk2-platforms] [PATCH v1 4/9] IpmiFeaturePkg: Add GenericIpmi driver common code
  2021-03-02  2:27 [edk2-platforms] [PATCH v1 0/9] IpmiFeaturePkg: Add IPMI transport drivers Nate DeSimone
                   ` (2 preceding siblings ...)
  2021-03-02  2:27 ` [edk2-platforms] [PATCH v1 3/9] IpmiFeaturePkg: Add IpmiInit driver DEPEXs Nate DeSimone
@ 2021-03-02  2:27 ` Nate DeSimone
  2021-03-02  2:28 ` [edk2-platforms] [PATCH v1 5/9] IpmiFeaturePkg: Add GenericIpmi PEIM Nate DeSimone
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Nate DeSimone @ 2021-03-02  2:27 UTC (permalink / raw)
  To: devel; +Cc: Isaac Oram, Sai Chaganty, Liming Gao, Michael Kubacki

From: Isaac Oram <isaac.w.oram@intel.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3242

Adds phase independent code for the generic IPMI
transport driver.

Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Michael Kubacki <michael.kubacki@microsoft.com>
Signed-off-by: Isaac Oram <isaac.w.oram@intel.com>
Co-authored-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
---
 .../GenericIpmi/Common/IpmiBmc.c              | 297 +++++++++++
 .../GenericIpmi/Common/IpmiBmc.h              |  44 ++
 .../GenericIpmi/Common/IpmiBmcCommon.h        | 179 +++++++
 .../GenericIpmi/Common/IpmiHooks.c            |  96 ++++
 .../GenericIpmi/Common/IpmiHooks.h            |  81 +++
 .../GenericIpmi/Common/IpmiPhysicalLayer.h    |  29 ++
 .../GenericIpmi/Common/KcsBmc.c               | 483 ++++++++++++++++++
 .../GenericIpmi/Common/KcsBmc.h               | 236 +++++++++
 8 files changed, 1445 insertions(+)
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiBmc.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiBmc.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiBmcCommon.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiHooks.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiHooks.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiPhysicalLayer.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/KcsBmc.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/KcsBmc.h

diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiBmc.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiBmc.c
new file mode 100644
index 0000000000..03b8174e37
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiBmc.c
@@ -0,0 +1,297 @@
+/** @file
+  IPMI Transport common layer driver
+
+  @copyright
+  Copyright 1999 - 2021 Intel Corporation. <BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include "IpmiBmc.h"
+
+EFI_STATUS
+UpdateErrorStatus (
+  IN UINT8                      BmcError,
+  IPMI_BMC_INSTANCE_DATA    *IpmiInstance
+  )
+/*++
+
+Routine Description:
+
+  Check if the completion code is a Soft Error and increment the count.  The count
+  is not updated if the BMC is in Force Update Mode.
+
+Arguments:
+
+  BmcError      - Completion code to check
+  IpmiInstance  - BMC instance data
+
+Returns:
+
+  EFI_SUCCESS   - Status
+
+--*/
+{
+  UINT8   Errors[] = COMPLETION_CODES;
+  UINT16  CodeCount;
+  UINT8   i;
+
+  CodeCount = sizeof (Errors) / sizeof (Errors[0]);
+  for (i = 0; i < CodeCount; i++) {
+    if (BmcError == Errors[i]) {
+      //
+      // Don't change Bmc Status flag if the BMC is in Force Update Mode.
+      //
+      if (IpmiInstance->BmcStatus != BMC_UPDATE_IN_PROGRESS) {
+        IpmiInstance->BmcStatus = BMC_SOFTFAIL;
+      }
+
+      IpmiInstance->SoftErrorCount++;
+      break;
+    }
+  }
+
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+IpmiSendCommandToBmc (
+  IN      IPMI_TRANSPORT            *This,
+  IN      UINT8                         NetFunction,
+  IN      UINT8                         Lun,
+  IN      UINT8                         Command,
+  IN      UINT8                         *CommandData,
+  IN      UINT8                         CommandDataSize,
+  IN OUT  UINT8                         *ResponseData,
+  IN OUT  UINT8                         *ResponseDataSize,
+  IN      VOID                          *Context
+  )
+/*++
+
+Routine Description:
+
+  Send IPMI command to BMC
+
+Arguments:
+
+  This              - Pointer to IPMI protocol instance
+  NetFunction       - Net Function of command to send
+  Lun               - LUN of command to send
+  Command           - IPMI command to send
+  CommandData       - Pointer to command data buffer, if needed
+  CommandDataSize   - Size of command data buffer
+  ResponseData      - Pointer to response data buffer
+  ResponseDataSize  - Pointer to response data buffer size
+  Context           - Context
+
+Returns:
+
+  EFI_INVALID_PARAMETER - One of the input values is bad
+  EFI_DEVICE_ERROR      - IPMI command failed
+  EFI_BUFFER_TOO_SMALL  - Response buffer is too small
+  EFI_UNSUPPORTED       - Command is not supported by BMC
+  EFI_SUCCESS           - Command completed successfully
+
+--*/
+{
+  IPMI_BMC_INSTANCE_DATA  *IpmiInstance;
+  UINT8                   DataSize;
+  EFI_STATUS              Status;
+  IPMI_COMMAND            *IpmiCommand;
+  IPMI_RESPONSE           *IpmiResponse;
+  UINT8                   RetryCnt = IPMI_SEND_COMMAND_MAX_RETRY;
+  UINT8                   Index;
+
+  IpmiInstance = INSTANCE_FROM_SM_IPMI_BMC_THIS (This);
+
+  while (RetryCnt--) {
+    //
+    // The TempData buffer is used for both sending command data and receiving
+    // response data.  Since the command format is different from the response
+    // format, the buffer is cast to both structure definitions.
+    //
+    IpmiCommand  = (IPMI_COMMAND*)  IpmiInstance->TempData;
+    IpmiResponse = (IPMI_RESPONSE*) IpmiInstance->TempData;
+
+    //
+    // Send IPMI command to BMC
+    //
+    IpmiCommand->Lun = Lun;
+    IpmiCommand->NetFunction = NetFunction;
+    IpmiCommand->Command = Command;
+
+    //
+    // Ensure that the buffer is valid before attempting to copy the command data
+    // buffer into the IpmiCommand structure.
+    //
+    if (CommandDataSize > 0) {
+      if (CommandData == NULL) {
+        return EFI_INVALID_PARAMETER;
+      }
+
+      CopyMem (
+        IpmiCommand->CommandData,
+        CommandData,
+        CommandDataSize
+        );
+    }
+
+    Status = SendDataToBmcPort (
+               IpmiInstance->KcsTimeoutPeriod,
+               IpmiInstance->IpmiIoBase,
+               Context,
+               (UINT8 *) IpmiCommand,
+               (CommandDataSize + IPMI_COMMAND_HEADER_SIZE)
+               );
+
+    if (Status != EFI_SUCCESS) {
+      IpmiInstance->BmcStatus = BMC_SOFTFAIL;
+      IpmiInstance->SoftErrorCount++;
+      return Status;
+    }
+
+    //
+    // Get Response to IPMI Command from BMC.
+    // Subtract 1 from DataSize so memory past the end of the buffer can't be written
+    //
+    DataSize = MAX_TEMP_DATA - 1;
+    Status = ReceiveBmcDataFromPort (
+               IpmiInstance->KcsTimeoutPeriod,
+               IpmiInstance->IpmiIoBase,
+               Context,
+               (UINT8 *) IpmiResponse,
+               &DataSize
+               );
+
+    if (Status != EFI_SUCCESS) {
+      IpmiInstance->BmcStatus = BMC_SOFTFAIL;
+      IpmiInstance->SoftErrorCount++;
+      return Status;
+    }
+
+    //
+    // If we got this far without any error codes, but the DataSize less than IPMI_RESPONSE_HEADER_SIZE, then the
+    // command response failed, so do not continue.
+    //
+    if (DataSize < IPMI_RESPONSE_HEADER_SIZE) {
+      return EFI_DEVICE_ERROR;
+    }
+
+    if ((IpmiResponse->CompletionCode != COMP_CODE_NORMAL) &&
+        (IpmiInstance->BmcStatus == BMC_UPDATE_IN_PROGRESS)) {
+      //
+      // If the completion code is not normal and the BMC is in Force Update
+      // mode, then update the error status and return EFI_UNSUPPORTED.
+      //
+      UpdateErrorStatus (
+        IpmiResponse->CompletionCode,
+        IpmiInstance
+        );
+      return EFI_UNSUPPORTED;
+    } else if (IpmiResponse->CompletionCode != COMP_CODE_NORMAL) {
+      //
+      // Otherwise if the BMC is in normal mode, but the completion code
+      // is not normal, then update the error status and return device error.
+      //
+      UpdateErrorStatus (
+        IpmiResponse->CompletionCode,
+        IpmiInstance
+        );
+      //
+      // Intel Server System Integrated Baseboard Management Controller (BMC) Firmware v0.62
+      // D4h C Insufficient privilege, in KCS channel this indicates KCS Policy Control Mode is Deny All.
+      // In authenticated channels this indicates invalid authentication/privilege.
+      //
+      if (IpmiResponse->CompletionCode == COMP_INSUFFICIENT_PRIVILEGE) {
+        return EFI_SECURITY_VIOLATION;
+      } else {
+        return EFI_DEVICE_ERROR;
+      }
+    }
+
+    //
+    // Verify the response data buffer passed in is big enough.
+    //
+    if ((DataSize - IPMI_RESPONSE_HEADER_SIZE) > *ResponseDataSize) {
+      //
+      //Verify the response data matched with the cmd sent.
+      //
+      if ((IpmiResponse->NetFunction != (NetFunction | 0x1)) || (IpmiResponse->Command != Command)) {
+        if (0 == RetryCnt) {
+          return EFI_DEVICE_ERROR;
+        } else {
+          continue;
+        }
+      }
+      return EFI_BUFFER_TOO_SMALL;
+    }
+
+    break;
+  }
+  //
+  // Copy data over to the response data buffer.
+  //
+  *ResponseDataSize = DataSize - IPMI_RESPONSE_HEADER_SIZE;
+  CopyMem (
+    ResponseData,
+    IpmiResponse->ResponseData,
+    *ResponseDataSize
+    );
+
+  //
+  // Add completion code in response data to meet the requirement of IPMI spec 2.0
+  //
+  *ResponseDataSize += 1; // Add one byte for Completion Code
+  for (Index = 1; Index < *ResponseDataSize; Index++) {
+    ResponseData [*ResponseDataSize - Index] = ResponseData [*ResponseDataSize - (Index + 1)];
+  }
+  ResponseData [0] = IpmiResponse->CompletionCode;
+
+  IpmiInstance->BmcStatus = BMC_OK;
+  return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+EFIAPI
+IpmiBmcStatus (
+  IN  IPMI_TRANSPORT              *This,
+  OUT BMC_STATUS                  *BmcStatus,
+  OUT SM_COM_ADDRESS              *ComAddress,
+  IN  VOID                            *Context
+  )
+/*++
+
+Routine Description:
+
+  Updates the BMC status and returns the Com Address
+
+Arguments:
+
+  This        - Pointer to IPMI protocol instance
+  BmcStatus   - BMC status
+  ComAddress  - Com Address
+  Context     - Context
+
+Returns:
+
+  EFI_SUCCESS - Success
+
+--*/
+{
+  IPMI_BMC_INSTANCE_DATA  *IpmiInstance;
+
+  IpmiInstance = INSTANCE_FROM_SM_IPMI_BMC_THIS (This);
+
+  if ((IpmiInstance->BmcStatus == BMC_SOFTFAIL) && (IpmiInstance->SoftErrorCount >= MAX_SOFT_COUNT)) {
+    IpmiInstance->BmcStatus = BMC_HARDFAIL;
+  }
+
+  *BmcStatus = IpmiInstance->BmcStatus;
+  ComAddress->ChannelType = SmBmc;
+  ComAddress->Address.BmcAddress.LunAddress = 0x0;
+  ComAddress->Address.BmcAddress.SlaveAddress = IpmiInstance->SlaveAddress;
+  ComAddress->Address.BmcAddress.ChannelAddress = 0x0;
+
+  return EFI_SUCCESS;
+}
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiBmc.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiBmc.h
new file mode 100644
index 0000000000..d306a085e5
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiBmc.h
@@ -0,0 +1,44 @@
+/** @file
+  IPMI Transport common layer driver head file
+
+  @copyright
+  Copyright 1999 - 2021 Intel Corporation. <BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef _IPMI_BMC_H_
+#define _IPMI_BMC_H_
+
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiDriverEntryPoint.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/PcdLib.h>
+#include <Library/UefiLib.h>
+#include <Library/BaseLib.h>
+#include <Library/IoLib.h>
+#include <Library/ReportStatusCodeLib.h>
+#include <Library/IpmiBaseLib.h>
+#include <Protocol/IpmiTransportProtocol.h>
+
+#include "IpmiBmcCommon.h"
+#include "KcsBmc.h"
+
+
+#define BMC_KCS_TIMEOUT  5   // [s] Single KSC request timeout
+
+//
+// IPMI Instance signature
+//
+#define SM_IPMI_BMC_SIGNATURE SIGNATURE_32 ('i', 'p', 'm', 'i')
+#define IPMI_SEND_COMMAND_MAX_RETRY  3   // Number of retries
+#define INSTANCE_FROM_SM_IPMI_BMC_THIS(a) \
+  CR ( \
+  a, \
+  IPMI_BMC_INSTANCE_DATA, \
+  IpmiTransport, \
+  SM_IPMI_BMC_SIGNATURE \
+  )
+
+#endif // _IPMI_BMC_H_
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiBmcCommon.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiBmcCommon.h
new file mode 100644
index 0000000000..1e5dfd81f1
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiBmcCommon.h
@@ -0,0 +1,179 @@
+/** @file
+  IPMI Transport common layer driver common head file
+
+  @copyright
+  Copyright 1999 - 2021 Intel Corporation. <BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef _IPMI_COMMON_BMC_H_
+#define _IPMI_COMMON_BMC_H_
+
+#define MAX_TEMP_DATA     255 // 160 Modified to increase number of bytes transfered per command
+#define BMC_SLAVE_ADDRESS 0x20
+#define MAX_SOFT_COUNT    10
+#define COMP_CODE_NORMAL  0x00
+
+//
+// IPMI command completion codes to check for in the UpdateErrorStatus routine.
+// These completion codes indicate a soft error and a running total of the occurrences
+// of these errors is maintained.
+//
+#define COMP_CODE_NODE_BUSY               0xC0
+#define COMP_CODE_TIMEOUT                 0xC3
+#define COMP_CODE_OUT_OF_SPACE            0xC4
+#define COMP_CODE_OUT_OF_RANGE            0xC9
+#define COMP_CODE_CMD_RESP_NOT_PROVIDED   0xCE
+#define COMP_CODE_FAIL_DUP_REQUEST        0xCF
+#define COMP_CODE_SDR_REP_IN_UPDATE_MODE  0xD0
+#define COMP_CODE_DEV_IN_FW_UPDATE_MODE   0xD1
+#define COMP_CODE_BMC_INIT_IN_PROGRESS    0xD2
+//
+// Intel Server System Integrated Baseboard Management Controller (BMC) Firmware v0.62
+// D4h C Insufficient privilege, in KCS channel this indicates KCS Policy Control Mode is Deny All.
+// In authenticated channels this indicates invalid authentication/privilege.
+//
+#define COMP_INSUFFICIENT_PRIVILEGE       0xD4
+#define COMP_CODE_UNSPECIFIED             0xFF
+
+#define COMPLETION_CODES \
+  { \
+    COMP_CODE_NODE_BUSY, COMP_CODE_TIMEOUT, COMP_CODE_OUT_OF_SPACE, COMP_CODE_OUT_OF_RANGE, \
+    COMP_CODE_CMD_RESP_NOT_PROVIDED, COMP_CODE_FAIL_DUP_REQUEST, COMP_CODE_SDR_REP_IN_UPDATE_MODE, \
+    COMP_CODE_DEV_IN_FW_UPDATE_MODE, COMP_CODE_BMC_INIT_IN_PROGRESS, COMP_INSUFFICIENT_PRIVILEGE, COMP_CODE_UNSPECIFIED \
+  }
+
+//
+// Dxe Ipmi instance data
+//
+typedef struct {
+  UINTN               Signature;
+  UINT64              KcsTimeoutPeriod;
+  UINT8               SlaveAddress;
+  UINT8               TempData[MAX_TEMP_DATA];
+  BMC_STATUS          BmcStatus;
+  UINT64              ErrorStatus;
+  UINT8               SoftErrorCount;
+  UINT16              IpmiIoBase;
+  IPMI_TRANSPORT      IpmiTransport;
+  EFI_HANDLE          IpmiSmmHandle;
+} IPMI_BMC_INSTANCE_DATA;
+
+//
+// Structure of IPMI Command buffer
+//
+#define IPMI_COMMAND_HEADER_SIZE  2
+
+typedef struct {
+  UINT8 Lun : 2;
+  UINT8 NetFunction : 6;
+  UINT8 Command;
+  UINT8 CommandData[MAX_TEMP_DATA - IPMI_COMMAND_HEADER_SIZE];
+} IPMI_COMMAND;
+
+//
+// Structure of IPMI Command response buffer
+//
+#define IPMI_RESPONSE_HEADER_SIZE 3
+
+typedef struct {
+  UINT8 Lun : 2;
+  UINT8 NetFunction : 6;
+  UINT8 Command;
+  UINT8 CompletionCode;
+  UINT8 ResponseData[MAX_TEMP_DATA - IPMI_RESPONSE_HEADER_SIZE];
+} IPMI_RESPONSE;
+
+EFI_STATUS
+EFIAPI
+IpmiSendCommandToBmc (
+  IN      IPMI_TRANSPORT                *This,
+  IN      UINT8                         NetFunction,
+  IN      UINT8                         Lun,
+  IN      UINT8                         Command,
+  IN      UINT8                         *CommandData,
+  IN      UINT8                         CommandDataSize,
+  IN OUT  UINT8                         *ResponseData,
+  IN OUT  UINT8                         *ResponseDataSize,
+  IN      VOID                          *Context
+  )
+/*++
+
+Routine Description:
+
+  Send IPMI command to BMC
+
+Arguments:
+
+  This              - Pointer to IPMI protocol instance
+  NetFunction       - Net Function of command to send
+  Lun               - LUN of command to send
+  Command           - IPMI command to send
+  CommandData       - Pointer to command data buffer, if needed
+  CommandDataSize   - Size of command data buffer
+  ResponseData      - Pointer to response data buffer
+  ResponseDataSize  - Pointer to response data buffer size
+  Context           - Context
+
+Returns:
+
+  EFI_INVALID_PARAMETER - One of the input values is bad
+  EFI_DEVICE_ERROR      - IPMI command failed
+  EFI_BUFFER_TOO_SMALL  - Response buffer is too small
+  EFI_SUCCESS           - Command completed successfully
+
+--*/
+;
+
+
+EFI_STATUS
+EFIAPI
+IpmiBmcStatus (
+  IN  IPMI_TRANSPORT              *This,
+  OUT BMC_STATUS                  *BmcStatus,
+  OUT SM_COM_ADDRESS              *ComAddress,
+  IN  VOID                        *Context
+  )
+/*++
+
+Routine Description:
+
+  Updates the BMC status and returns the Com Address
+
+Arguments:
+
+  This        - Pointer to IPMI protocol instance
+  BmcStatus   - BMC status
+  ComAddress  - Com Address
+  Context     - Context
+
+Returns:
+
+  EFI_SUCCESS - Success
+
+--*/
+;
+
+VOID
+GetDeviceSpecificTestResults (
+  IN      IPMI_BMC_INSTANCE_DATA  *IpmiInstance
+  )
+/*++
+
+Routine Description:
+
+  This is a BMC specific routine to check the device specific self test results as defined
+  in the Bensley BMC core specification.
+
+Arguments:
+
+  IpmiInstance  - Data structure describing BMC variables and used for sending commands
+
+Returns:
+
+  VOID
+
+--*/
+;
+
+#endif
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiHooks.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiHooks.c
new file mode 100644
index 0000000000..86ff7c0fdf
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiHooks.c
@@ -0,0 +1,96 @@
+/** @file
+  IPMI common hook functions
+
+  @copyright
+  Copyright 2014 - 2021 Intel Corporation. <BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include "IpmiHooks.h"
+
+EFI_STATUS
+IpmiSendCommand (
+  IN      IPMI_TRANSPORT               *This,
+  IN      UINT8                        NetFunction,
+  IN      UINT8                        Lun,
+  IN      UINT8                        Command,
+  IN      UINT8                        *CommandData,
+  IN      UINT32                       CommandDataSize,
+  IN OUT  UINT8                        *ResponseData,
+  IN OUT  UINT32                       *ResponseDataSize
+  )
+/*++
+
+Routine Description:
+
+  Send Ipmi Command in the right mode: HECI or KCS,  to the
+  appropiate device, ME or BMC.
+
+Arguments:
+
+  This              - Pointer to IPMI protocol instance
+  NetFunction       - Net Function of command to send
+  Lun               - LUN of command to send
+  Command           - IPMI command to send
+  CommandData       - Pointer to command data buffer, if needed
+  CommandDataSize   - Size of command data buffer
+  ResponseData      - Pointer to response data buffer
+  ResponseDataSize  - Pointer to response data buffer size
+
+Returns:
+
+  EFI_INVALID_PARAMETER - One of the input values is bad
+  EFI_DEVICE_ERROR      - IPMI command failed
+  EFI_BUFFER_TOO_SMALL  - Response buffer is too small
+  EFI_UNSUPPORTED       - Command is not supported by BMC
+  EFI_SUCCESS           - Command completed successfully
+
+--*/
+{
+  //
+  // This Will be unchanged ( BMC/KCS style )
+  //
+  return IpmiSendCommandToBmc (
+           This,
+           NetFunction,
+           Lun,
+           Command,
+           CommandData,
+           (UINT8) CommandDataSize,
+           ResponseData,
+           (UINT8*) ResponseDataSize,
+           NULL
+           );
+} // IpmiSendCommand()
+
+EFI_STATUS
+IpmiGetBmcStatus (
+  IN IPMI_TRANSPORT                *This,
+  OUT BMC_STATUS                   *BmcStatus,
+  OUT SM_COM_ADDRESS               *ComAddress
+  )
+/*++
+
+Routine Description:
+
+  Updates the BMC status and returns the Com Address
+
+Arguments:
+
+  This        - Pointer to IPMI protocol instance
+  BmcStatus   - BMC status
+  ComAddress  - Com Address
+
+Returns:
+
+  EFI_SUCCESS - Success
+
+--*/
+{
+  return IpmiBmcStatus (
+           This,
+           BmcStatus,
+           ComAddress,
+           NULL
+           );
+}
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiHooks.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiHooks.h
new file mode 100644
index 0000000000..083c9e70b0
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiHooks.h
@@ -0,0 +1,81 @@
+/** @file
+  IPMI common hook functions head file
+
+  @copyright
+  Copyright 2014 - 2021 Intel Corporation. <BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef _IPMI_HOOKS_H
+#define _IPMI_HOOKS_H
+
+#include "IpmiBmc.h"
+
+//
+// Internal(hook) function list
+//
+EFI_STATUS
+IpmiSendCommand (
+  IN      IPMI_TRANSPORT               *This,
+  IN      UINT8                        NetFunction,
+  IN      UINT8                        Lun,
+  IN      UINT8                        Command,
+  IN      UINT8                        *CommandData,
+  IN      UINT32                       CommandDataSize,
+  IN OUT  UINT8                        *ResponseData,
+  IN OUT  UINT32                       *ResponseDataSize
+  )
+/*++
+
+Routine Description:
+
+  Send IPMI command to BMC
+
+Arguments:
+
+  This              - Pointer to IPMI protocol instance
+  NetFunction       - Net Function of command to send
+  Lun               - LUN of command to send
+  Command           - IPMI command to send
+  CommandData       - Pointer to command data buffer, if needed
+  CommandDataSize   - Size of command data buffer
+  ResponseData      - Pointer to response data buffer
+  ResponseDataSize  - Pointer to response data buffer size
+
+Returns:
+
+  EFI_INVALID_PARAMETER - One of the input values is bad
+  EFI_DEVICE_ERROR      - IPMI command failed
+  EFI_BUFFER_TOO_SMALL  - Response buffer is too small
+  EFI_UNSUPPORTED       - Command is not supported by BMC
+  EFI_SUCCESS           - Command completed successfully
+
+--*/
+;
+
+EFI_STATUS
+IpmiGetBmcStatus (
+  IN IPMI_TRANSPORT                                    *This,
+  OUT BMC_STATUS                                       *BmcStatus,
+  OUT SM_COM_ADDRESS                                   *ComAddress
+  )
+/*++
+
+Routine Description:
+
+  Updates the BMC status and returns the Com Address
+
+Arguments:
+
+  This        - Pointer to IPMI protocol instance
+  BmcStatus   - BMC status
+  ComAddress  - Com Address
+
+Returns:
+
+  EFI_SUCCESS - Success
+
+--*/
+;
+
+#endif
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiPhysicalLayer.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiPhysicalLayer.h
new file mode 100644
index 0000000000..0215bd0e5a
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiPhysicalLayer.h
@@ -0,0 +1,29 @@
+/** @file
+  IPMI Common physical layer functions.
+
+  @copyright
+  Copyright 2014 - 2021 Intel Corporation. <BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef _IPMI_PHYSICAL_LAYER_H
+#define _IPMI_PHYSICAL_LAYER_H
+
+//
+// KCS physical interface layer
+//
+EFI_STATUS
+InitializeIpmiKcsPhysicalLayer (
+  IN EFI_HANDLE ImageHandle,
+  IN EFI_SYSTEM_TABLE *SystemTable
+  );
+
+
+EFI_STATUS
+SmmInitializeIpmiKcsPhysicalLayer (
+  IN EFI_HANDLE ImageHandle,
+  IN EFI_SYSTEM_TABLE *SystemTable
+  );
+
+#endif
+
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/KcsBmc.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/KcsBmc.c
new file mode 100644
index 0000000000..7243d37cc5
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/KcsBmc.c
@@ -0,0 +1,483 @@
+/** @file
+  KCS Transport Hook.
+
+  @copyright
+  Copyright 1999 - 2021 Intel Corporation. <BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include "KcsBmc.h"
+
+EFI_STATUS
+KcsErrorExit (
+  UINT64                            KcsTimeoutPeriod,
+  UINT16                            KcsPort,
+  VOID                              *Context
+  )
+/*++
+
+Routine Description:
+
+  Check the KCS error status
+
+Arguments:
+
+  IpmiInstance     - The pointer of IPMI_BMC_INSTANCE_DATA
+  KcsPort          - The base port of KCS
+  Context          - The Context for this operation
+
+Returns:
+
+  EFI_DEVICE_ERROR - The device error happened
+  EFI_SUCCESS      - Successfully check the KCS error status
+
+--*/
+{
+  EFI_STATUS      Status;
+  UINT8           KcsData;
+  KCS_STATUS      KcsStatus;
+  UINT8           BmcStatus;
+  UINT8           RetryCount;
+  UINT64          TimeOut;
+
+  TimeOut     = 0;
+  RetryCount  = 0;
+  while (RetryCount < KCS_ABORT_RETRY_COUNT) {
+
+    TimeOut = 0;
+    do {
+      MicroSecondDelay (KCS_DELAY_UNIT);
+      KcsStatus.RawData = IoRead8 (KcsPort + 1);
+      if (KcsStatus.RawData == 0xFF || (TimeOut >= KcsTimeoutPeriod)) {
+        RetryCount = KCS_ABORT_RETRY_COUNT;
+        break;
+      }
+      TimeOut++;
+    } while (KcsStatus.Status.Ibf);
+
+    if (RetryCount >= KCS_ABORT_RETRY_COUNT) {
+      break;
+    }
+
+    KcsData = KCS_ABORT;
+    IoWrite8 ((KcsPort + 1), KcsData);
+
+    TimeOut = 0;
+    do {
+      MicroSecondDelay (KCS_DELAY_UNIT);
+      KcsStatus.RawData = IoRead8 (KcsPort + 1);
+      if (KcsStatus.RawData == 0xFF || (TimeOut >= KcsTimeoutPeriod)) {
+        Status = EFI_DEVICE_ERROR;
+        goto LabelError;
+      }
+      TimeOut++;
+    } while (KcsStatus.Status.Ibf);
+
+    KcsData = IoRead8 (KcsPort);
+
+    KcsData = 0x0;
+    IoWrite8 (KcsPort, KcsData);
+
+    TimeOut = 0;
+    do {
+      MicroSecondDelay (KCS_DELAY_UNIT);
+      KcsStatus.RawData = IoRead8 (KcsPort + 1);
+      if (KcsStatus.RawData == 0xFF || (TimeOut >= KcsTimeoutPeriod)) {
+        Status = EFI_DEVICE_ERROR;
+        goto LabelError;
+      }
+      TimeOut++;
+    } while (KcsStatus.Status.Ibf);
+
+    if (KcsStatus.Status.State == KcsReadState) {
+      TimeOut = 0;
+      do {
+        MicroSecondDelay (KCS_DELAY_UNIT);
+        KcsStatus.RawData = IoRead8 (KcsPort + 1);
+        if (KcsStatus.RawData == 0xFF || (TimeOut >= KcsTimeoutPeriod)) {
+          Status = EFI_DEVICE_ERROR;
+          goto LabelError;
+        }
+        TimeOut++;
+      } while (!KcsStatus.Status.Obf);
+
+      BmcStatus = IoRead8 (KcsPort);
+
+      KcsData = KCS_READ;
+      IoWrite8 (KcsPort, KcsData);
+
+      TimeOut = 0;
+      do {
+        MicroSecondDelay (KCS_DELAY_UNIT);
+        KcsStatus.RawData = IoRead8 (KcsPort + 1);
+        if (KcsStatus.RawData == 0xFF || (TimeOut >= KcsTimeoutPeriod)) {
+          Status = EFI_DEVICE_ERROR;
+          goto LabelError;
+        }
+        TimeOut++;
+      } while (KcsStatus.Status.Ibf);
+
+      if (KcsStatus.Status.State == KcsIdleState) {
+        TimeOut = 0;
+        do {
+          MicroSecondDelay (KCS_DELAY_UNIT);
+          KcsStatus.RawData = IoRead8 (KcsPort + 1);
+          if (KcsStatus.RawData == 0xFF || (TimeOut >= KcsTimeoutPeriod)) {
+            Status = EFI_DEVICE_ERROR;
+            goto LabelError;
+          }
+          TimeOut++;
+        } while (!KcsStatus.Status.Obf);
+
+        KcsData = IoRead8 (KcsPort);
+        break;
+
+      } else {
+        RetryCount++;
+        continue;
+      }
+
+    } else {
+      RetryCount++;
+      continue;
+    }
+  }
+
+  if (RetryCount >= KCS_ABORT_RETRY_COUNT) {
+    Status = EFI_DEVICE_ERROR;
+    goto LabelError;
+  }
+
+  return EFI_SUCCESS;
+
+LabelError:
+  return Status;
+}
+
+EFI_STATUS
+KcsCheckStatus (
+  UINT64                            KcsTimeoutPeriod,
+  UINT16                            KcsPort,
+  KCS_STATE                         KcsState,
+  BOOLEAN                           *Idle,
+  VOID                              *Context
+  )
+/*++
+
+Routine Description:
+
+  Ckeck KCS status
+
+Arguments:
+
+  IpmiInstance  - The pointer of IPMI_BMC_INSTANCE_DATA
+  KcsPort       - The base port of KCS
+  KcsState      - The state of KCS to be checked
+  Idle          - If the KCS is idle
+  Context       - The context for this operation
+
+Returns:
+
+  EFI_SUCCESS   - Checked the KCS status successfully
+
+--*/
+{
+  EFI_STATUS      Status;
+  KCS_STATUS      KcsStatus;
+  UINT8           KcsData;
+  UINT64          TimeOut;
+
+  if (Idle == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  *Idle = FALSE;
+
+  TimeOut = 0;
+  do {
+    MicroSecondDelay (KCS_DELAY_UNIT);
+    KcsStatus.RawData = IoRead8 (KcsPort + 1);
+    if (KcsStatus.RawData == 0xFF || (TimeOut >= KcsTimeoutPeriod)) {
+      Status = EFI_DEVICE_ERROR;
+      goto LabelError;
+    }
+    TimeOut++;
+  } while (KcsStatus.Status.Ibf);
+
+  if (KcsState == KcsWriteState) {
+    KcsData = IoRead8 (KcsPort);
+  }
+
+  if (KcsStatus.Status.State != KcsState) {
+    if ((KcsStatus.Status.State == KcsIdleState) && (KcsState == KcsReadState)) {
+      *Idle = TRUE;
+    } else {
+      Status = KcsErrorExit (KcsTimeoutPeriod, KcsPort, Context);
+      goto LabelError;
+    }
+  }
+
+  if (KcsState == KcsReadState) {
+    TimeOut = 0;
+    do {
+      MicroSecondDelay (KCS_DELAY_UNIT);
+      KcsStatus.RawData = IoRead8 (KcsPort + 1);
+      if (KcsStatus.RawData == 0xFF || (TimeOut >= KcsTimeoutPeriod)) {
+        Status = EFI_DEVICE_ERROR;
+        goto LabelError;
+      }
+      TimeOut++;
+    } while (!KcsStatus.Status.Obf);
+  }
+
+  if (KcsState == KcsWriteState || (*Idle == TRUE)) {
+    KcsData = IoRead8 (KcsPort);
+  }
+
+  return EFI_SUCCESS;
+
+LabelError:
+  return Status;
+}
+
+EFI_STATUS
+SendDataToBmc (
+  UINT64                          KcsTimeoutPeriod,
+  UINT16                          KcsPort,
+  VOID                            *Context,
+  UINT8                           *Data,
+  UINT8                           DataSize
+  )
+/*++
+
+Routine Description:
+
+  Send data to BMC
+
+Arguments:
+
+  IpmiInstance  - The pointer of IPMI_BMC_INSTANCE_DATA
+  Context       - The context of this operation
+  Data          - The data pointer to be sent
+  DataSize      - The data size
+
+Returns:
+
+  EFI_SUCCESS   - Send out the data successfully
+
+--*/
+{
+  KCS_STATUS      KcsStatus;
+  UINT8           KcsData;
+  UINT16          KcsIoBase;
+  EFI_STATUS      Status;
+  UINT8           i;
+  BOOLEAN         Idle;
+  UINT64          TimeOut;
+
+  KcsIoBase = KcsPort;
+
+  TimeOut = 0;
+
+  do {
+    MicroSecondDelay (KCS_DELAY_UNIT);
+    KcsStatus.RawData = IoRead8 (KcsIoBase + 1);
+    if ((KcsStatus.RawData == 0xFF) || (TimeOut >= KcsTimeoutPeriod)) {
+      if ((Status = KcsErrorExit (KcsTimeoutPeriod, KcsIoBase, Context)) != EFI_SUCCESS) {
+        return Status;
+      }
+    }
+    TimeOut++;
+  } while (KcsStatus.Status.Ibf);
+
+  KcsData = KCS_WRITE_START;
+  IoWrite8 ((KcsIoBase + 1), KcsData);
+  if ((Status = KcsCheckStatus (KcsTimeoutPeriod, KcsIoBase, KcsWriteState, &Idle, Context)) != EFI_SUCCESS) {
+    return Status;
+  }
+
+  for (i = 0; i < DataSize; i++) {
+    if (i == (DataSize - 1)) {
+      if ((Status = KcsCheckStatus (KcsTimeoutPeriod, KcsIoBase, KcsWriteState, &Idle, Context)) != EFI_SUCCESS) {
+        return Status;
+      }
+
+      KcsData = KCS_WRITE_END;
+      IoWrite8 ((KcsIoBase + 1), KcsData);
+    }
+
+    Status = KcsCheckStatus (KcsTimeoutPeriod, KcsIoBase, KcsWriteState, &Idle, Context);
+    if (EFI_ERROR (Status)) {
+      return Status;
+    }
+
+    IoWrite8 (KcsIoBase, Data[i]);
+  }
+
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+ReceiveBmcData (
+  UINT64                          KcsTimeoutPeriod,
+  UINT16                          KcsPort,
+  VOID                            *Context,
+  UINT8                           *Data,
+  UINT8                           *DataSize
+  )
+/*++
+
+Routine Description:
+
+  Routine Description:
+
+  Receive data from BMC
+
+Arguments:
+
+  IpmiInstance  - The pointer of IPMI_BMC_INSTANCE_DATA
+  Context       - The context of this operation
+  Data          - The buffer pointer
+  DataSize      - The buffer size
+
+Returns:
+
+  EFI_SUCCESS   - Received data successfully
+
+--*/
+{
+  UINT8       KcsData;
+  UINT16      KcsIoBase;
+  EFI_STATUS  Status;
+  BOOLEAN     Idle;
+  UINT8       Count;
+
+  Count     = 0;
+  KcsIoBase = KcsPort;
+
+  while (TRUE) {
+
+    if ((Status = KcsCheckStatus (KcsTimeoutPeriod, KcsIoBase, KcsReadState, &Idle, Context)) != EFI_SUCCESS) {
+      return Status;
+    }
+
+    if (Idle) {
+      *DataSize = Count;
+      break;
+    }
+
+    //
+    //Need to check Data Size -1 to account for array access
+    //
+    if (Count >= *DataSize) {
+      return EFI_DEVICE_ERROR;
+    }
+
+    Data[Count] = IoRead8 (KcsIoBase);
+
+    Count++;
+
+    KcsData = KCS_READ;
+    IoWrite8 (KcsIoBase, KcsData);
+  }
+
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+ReceiveBmcDataFromPort (
+  UINT64                          KcsTimeoutPeriod,
+  UINT16                          KcsPort,
+  VOID                            *Context,
+  UINT8                           *Data,
+  UINT8                           *DataSize
+  )
+/*++
+
+Routine Description:
+
+  Receive data from BMC
+
+Arguments:
+
+  IpmiInstance  - The pointer of IPMI_BMC_INSTANCE_DATA
+  Context       - The context of this operation
+  Data          - The buffer pointer to receive data
+  DataSize      - The buffer size
+
+Returns:
+
+  EFI_SUCCESS   - Received the data successfully
+
+--*/
+{
+  EFI_STATUS  Status;
+  UINT16      KcsIoBase;
+  UINT8       i;
+  UINT8       MyDataSize;
+
+  MyDataSize  = *DataSize;
+  KcsIoBase   = KcsPort;
+
+  for (i = 0; i < KCS_ABORT_RETRY_COUNT; i++) {
+    Status = ReceiveBmcData (KcsTimeoutPeriod, KcsIoBase, Context, Data, DataSize);
+    if (EFI_ERROR (Status)) {
+      if ((Status = KcsErrorExit (KcsTimeoutPeriod, KcsIoBase, Context)) != EFI_SUCCESS) {
+        return Status;
+      }
+
+      *DataSize = MyDataSize;
+    } else {
+      return Status;
+    }
+  }
+
+  return EFI_DEVICE_ERROR;
+}
+
+EFI_STATUS
+SendDataToBmcPort (
+  UINT64                          KcsTimeoutPeriod,
+  UINT16                          KcsPort,
+  VOID                            *Context,
+  UINT8                           *Data,
+  UINT8                           DataSize
+  )
+/*++
+
+Routine Description:
+
+  Send data to BMC
+
+Arguments:
+
+  IpmiInstance  - The pointer of IPMI_BMC_INSTANCE_DATA
+  Context       - The context of this operation
+  Data          - The data pointer to be sent
+  DataSize      - The data size
+
+Returns:
+
+  EFI_SUCCESS   - Send out the data successfully
+
+--*/
+{
+  EFI_STATUS  Status;
+  UINT16      KcsIoBase;
+  UINT8       i;
+
+  KcsIoBase = KcsPort;
+
+  for (i = 0; i < KCS_ABORT_RETRY_COUNT; i++) {
+    Status = SendDataToBmc (KcsTimeoutPeriod, KcsIoBase, Context, Data, DataSize);
+    if (EFI_ERROR (Status)) {
+      if ((Status = KcsErrorExit (KcsTimeoutPeriod, KcsIoBase, Context)) != EFI_SUCCESS) {
+        return Status;
+      }
+    } else {
+      return Status;
+    }
+  }
+
+  return EFI_DEVICE_ERROR;
+}
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/KcsBmc.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/KcsBmc.h
new file mode 100644
index 0000000000..a8684cc4f6
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/KcsBmc.h
@@ -0,0 +1,236 @@
+/** @file
+  KCS Transport Hook head file.
+
+  @copyright
+  Copyright 1999 - 2021 Intel Corporation. <BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef _KCS_BMC_H
+#define _KCS_BMC_H
+
+#include <Library/BaseLib.h>
+#include <Library/IoLib.h>
+#include <Library/DebugLib.h>
+#include <Library/TimerLib.h>
+
+#define KCS_WRITE_START       0x61
+#define KCS_WRITE_END         0x62
+#define KCS_READ              0x68
+#define KCS_GET_STATUS        0x60
+#define KCS_ABORT             0x60
+#define KCS_DELAY_UNIT        50  // [s] Each KSC IO delay
+
+//
+// In OpenBMC, UpdateMode: the bit 7 of byte 4 in get device id command is used for the BMC status:
+// 0 means BMC is ready, 1 means BMC is not ready.
+// At the very beginning of BMC power on, the status is 1 means BMC is in booting process and not ready. It is not the flag for force update mode.
+//
+#define BMC_READY             0
+
+
+#define KCS_ABORT_RETRY_COUNT 1
+
+//#define TIMEOUT64(a,b)  ((INT64)((b) - (a)) < 0)
+
+typedef enum {
+  KcsIdleState,
+  KcsReadState,
+  KcsWriteState,
+  KcsErrorState
+} KCS_STATE;
+
+typedef union {
+  UINT8     RawData;
+  struct {
+    UINT8 Obf   : 1;
+    UINT8 Ibf   : 1;
+    UINT8 SmAtn : 1;
+    UINT8 CD    : 1;
+    UINT8 Oem1  : 1;
+    UINT8 Oem2  : 1;
+    UINT8 State : 2;
+  } Status;
+} KCS_STATUS;
+
+
+//
+//External Fucntion List
+//
+EFI_STATUS
+SendDataToBmcPort (
+  UINT64                                    KcsTimeoutPeriod,
+  UINT16                                    KcsPort,
+  VOID                                      *Context,
+  UINT8                                     *Data,
+  UINT8                                     DataSize
+  )
+/*++
+
+Routine Description:
+
+  Send data to BMC
+
+Arguments:
+
+  IpmiInstance  - The pointer of IPMI_BMC_INSTANCE_DATA
+  Context       - The context of this operation
+  Data          - The data pointer to be sent
+  DataSize      - The data size
+
+Returns:
+
+  EFI_SUCCESS   - Send out the data successfully
+
+--*/
+;
+
+EFI_STATUS
+ReceiveBmcDataFromPort (
+  UINT64                          KcsTimeoutPeriod,
+  UINT16                          KcsPort,
+  VOID                            *Context,
+  UINT8                           *Data,
+  UINT8                           *DataSize
+  )
+/*++
+
+Routine Description:
+
+  Routine Description:
+
+  Receive data from BMC
+
+Arguments:
+
+  IpmiInstance  - The pointer of IPMI_BMC_INSTANCE_DATA
+  Context       - The context of this operation
+  Data          - The buffer pointer
+  DataSize      - The buffer size
+
+Returns:
+
+  EFI_SUCCESS   - Received data successfully
+
+--*/
+;
+
+//
+//Internal Fucntion List
+//
+EFI_STATUS
+KcsErrorExit (
+  UINT64                            KcsTimeoutPeriod,
+  UINT16                            KcsPort,
+  VOID                              *Context
+  )
+/*++
+
+Routine Description:
+
+  Check the KCS error status
+
+Arguments:
+
+  IpmiInstance     - The pointer of IPMI_BMC_INSTANCE_DATA
+  KcsPort          - The base port of KCS
+  Context          - The Context for this operation
+
+Returns:
+
+  EFI_DEVICE_ERROR - The device error happened
+  EFI_SUCCESS      - Successfully check the KCS error status
+
+--*/
+;
+
+EFI_STATUS
+KcsCheckStatus (
+  UINT64                            KcsTimeoutPeriod,
+  UINT16                            KcsPort,
+  KCS_STATE                         KcsState,
+  BOOLEAN                           *Idle,
+  VOID                              *Context
+  )
+/*++
+
+Routine Description:
+
+  Ckeck KCS status
+
+Arguments:
+
+  IpmiInstance  - The pointer of IPMI_BMC_INSTANCE_DATA
+  KcsPort       - The base port of KCS
+  KcsState      - The state of KCS to be checked
+  Idle          - If the KCS is idle
+  Context       - The context for this operation
+
+Returns:
+
+  EFI_SUCCESS   - Checked the KCS status successfully
+
+--*/
+;
+
+
+EFI_STATUS
+SendDataToBmc (
+  UINT64                          KcsTimeoutPeriod,
+  UINT16                          KcsPort,
+  VOID                            *Context,
+  UINT8                           *Data,
+  UINT8                           DataSize
+  )
+/*++
+
+Routine Description:
+
+  Send data to BMC
+
+Arguments:
+
+  IpmiInstance  - The pointer of IPMI_BMC_INSTANCE_DATA
+  Context       - The context of this operation
+  Data          - The data pointer to be sent
+  DataSize      - The data size
+
+Returns:
+
+  EFI_SUCCESS   - Send out the data successfully
+
+--*/
+;
+
+
+EFI_STATUS
+ReceiveBmcData (
+  UINT64                          KcsTimeoutPeriod,
+  UINT16                          KcsPort,
+  VOID                            *Context,
+  UINT8                           *Data,
+  UINT8                           *DataSize
+  )
+/*++
+
+Routine Description:
+
+  Routine Description:
+
+  Receive data from BMC
+
+Arguments:
+
+  IpmiInstance  - The pointer of IPMI_BMC_INSTANCE_DATA
+  Context       - The context of this operation
+  Data          - The buffer pointer
+  DataSize      - The buffer size
+
+Returns:
+
+  EFI_SUCCESS   - Received data successfully
+
+--*/
+;
+
+#endif
-- 
2.27.0.windows.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [edk2-platforms] [PATCH v1 5/9] IpmiFeaturePkg: Add GenericIpmi PEIM
  2021-03-02  2:27 [edk2-platforms] [PATCH v1 0/9] IpmiFeaturePkg: Add IPMI transport drivers Nate DeSimone
                   ` (3 preceding siblings ...)
  2021-03-02  2:27 ` [edk2-platforms] [PATCH v1 4/9] IpmiFeaturePkg: Add GenericIpmi driver common code Nate DeSimone
@ 2021-03-02  2:28 ` Nate DeSimone
  2021-03-02  2:28 ` [edk2-platforms] [PATCH v1 6/9] IpmiFeaturePkg: Add GenericIpmi DXE Driver Nate DeSimone
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Nate DeSimone @ 2021-03-02  2:28 UTC (permalink / raw)
  To: devel; +Cc: Isaac Oram, Sai Chaganty, Liming Gao, Michael Kubacki

From: Isaac Oram <isaac.w.oram@intel.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3242

Adds the PEI version of the generic
IPMI transport driver.

Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Michael Kubacki <michael.kubacki@microsoft.com>
Signed-off-by: Isaac Oram <isaac.w.oram@intel.com>
Co-authored-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
---
 .../GenericIpmi/Pei/PeiGenericIpmi.c          | 362 ++++++++++++++++++
 .../GenericIpmi/Pei/PeiGenericIpmi.h          | 138 +++++++
 .../GenericIpmi/Pei/PeiGenericIpmi.inf        |  58 +++
 .../GenericIpmi/Pei/PeiIpmiBmc.c              | 277 ++++++++++++++
 .../GenericIpmi/Pei/PeiIpmiBmc.h              |  38 ++
 .../GenericIpmi/Pei/PeiIpmiBmcDef.h           | 156 ++++++++
 6 files changed, 1029 insertions(+)
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.inf
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiBmc.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiBmc.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiBmcDef.h

diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c
new file mode 100644
index 0000000000..31f613925d
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c
@@ -0,0 +1,362 @@
+/** @file
+  Generic IPMI stack during PEI phase
+
+  @copyright
+  Copyright 2017 - 2021 Intel Corporation. <BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <IndustryStandard/Ipmi.h>
+#include "PeiGenericIpmi.h"
+#include <Library/ReportStatusCodeLib.h>
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Function Implementations
+//
+
+/*****************************************************************************
+ @brief
+  Internal function
+
+ @param[in] PeiServices          General purpose services available to every PEIM.
+
+ @retval EFI_SUCCESS             Always return EFI_SUCCESS
+**/
+EFI_STATUS
+EFIAPI
+PeiInitializeIpmiKcsPhysicalLayer (
+  IN CONST EFI_PEI_SERVICES             **PeiServices
+  )
+{
+  EFI_STATUS                       Status;
+  PEI_IPMI_BMC_INSTANCE_DATA       *mIpmiInstance;
+
+  mIpmiInstance = NULL;
+
+  //
+  // Send Pre-Boot signal to BMC
+  //
+  if (PcdGetBool (PcdSignalPreBootToBmc)) {
+    Status = SendPreBootSignaltoBmc (PeiServices);
+    if (EFI_ERROR (Status)) {
+      return Status;
+    }
+  }
+
+  //
+  // Enable OEM specific southbridge SIO KCS I/O address range 0xCA0 to 0xCAF at here
+  // if the the I/O address range has not been enabled.
+  //
+
+  mIpmiInstance = AllocateZeroPool (sizeof (PEI_IPMI_BMC_INSTANCE_DATA));
+  if (mIpmiInstance == NULL) {
+    DEBUG ((EFI_D_ERROR,"IPMI Peim:EFI_OUT_OF_RESOURCES of memory allocation\n"));
+    return EFI_OUT_OF_RESOURCES;
+  }
+
+  //
+  // Calibrate TSC Counter.  Stall for 10ms, then multiply the resulting number of
+  // ticks in that period by 100 to get the number of ticks in a 1 second timeout
+  //
+  DEBUG ((DEBUG_INFO,"IPMI Peim:IPMI STACK Initialization\n"));
+  mIpmiInstance->KcsTimeoutPeriod = (BMC_KCS_TIMEOUT_PEI *1000*1000) / KCS_DELAY_UNIT_PEI;
+  DEBUG ((EFI_D_INFO,"IPMI Peim:KcsTimeoutPeriod = 0x%x\n", mIpmiInstance->KcsTimeoutPeriod));
+
+  //
+  // Initialize IPMI IO Base.
+  //
+  mIpmiInstance->IpmiIoBase                         = PcdGet16 (PcdIpmiIoBaseAddress);
+  DEBUG ((EFI_D_INFO,"IPMI Peim:IpmiIoBase=0x%x\n",mIpmiInstance->IpmiIoBase));
+  mIpmiInstance->Signature                          = SM_IPMI_BMC_SIGNATURE;
+  mIpmiInstance->SlaveAddress                       = BMC_SLAVE_ADDRESS;
+  mIpmiInstance->BmcStatus                          = BMC_NOTREADY;
+  mIpmiInstance->IpmiTransportPpi.IpmiSubmitCommand = PeiIpmiSendCommand;
+  mIpmiInstance->IpmiTransportPpi.GetBmcStatus      = PeiGetIpmiBmcStatus;
+
+  mIpmiInstance->PeiIpmiBmcDataDesc.Flags         = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
+  mIpmiInstance->PeiIpmiBmcDataDesc.Guid          = &gPeiIpmiTransportPpiGuid;
+  mIpmiInstance->PeiIpmiBmcDataDesc.Ppi           = &mIpmiInstance->IpmiTransportPpi;
+
+  //
+  // Get the Device ID and check if the system is in Force Update mode.
+  //
+  Status = GetDeviceId (mIpmiInstance);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((EFI_D_ERROR,"IPMI Peim:Get BMC Device Id Failed. Status=%r\n",Status));
+  }
+
+  //
+  // Do not continue initialization if the BMC is in Force Update Mode.
+  //
+  if (mIpmiInstance->BmcStatus == BMC_UPDATE_IN_PROGRESS || mIpmiInstance->BmcStatus == BMC_HARDFAIL) {
+    return EFI_UNSUPPORTED;
+  }
+
+  //
+  // Just produce PPI
+  //
+  Status = PeiServicesInstallPpi (&mIpmiInstance->PeiIpmiBmcDataDesc);
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  return EFI_SUCCESS;
+}
+
+/*****************************************************************************
+ @bref
+  PRE-BOOT signal will be sent in very early PEI phase, to enable necessary KCS access for host boot.
+
+  @param[in] PeiServices          General purpose services available to every PEIM.
+
+  @retval EFI_SUCCESS   Indicates that the signal is sent successfully.
+**/
+EFI_STATUS
+SendPreBootSignaltoBmc (
+  IN CONST EFI_PEI_SERVICES             **PeiServices
+  )
+{
+  EFI_STATUS                        Status;
+  EFI_PEI_CPU_IO_PPI                *CpuIoPpi;
+  UINT32                            ProvisionPort = 0;
+  UINT8                             PreBoot = 0;
+
+  //
+  // Locate CpuIo service
+  //
+  CpuIoPpi = (**PeiServices).CpuIo;
+  ProvisionPort = PcdGet32 (PcdSioMailboxBaseAddress) + MBXDAT_B;
+  PreBoot = 0x01;// PRE-BOOT
+
+  Status = CpuIoPpi->Io.Write (
+                          PeiServices,
+                          CpuIoPpi,
+                          EfiPeiCpuIoWidthUint8,
+                          ProvisionPort,
+                          1,
+                          &PreBoot
+                          );
+  if (EFI_ERROR (Status)) {
+    DEBUG ((EFI_D_ERROR, "SendPreBootSignaltoBmc () Write PRE-BOOT Status=%r\n", Status));
+    return Status;
+  }
+
+  return EFI_SUCCESS;
+}
+
+/*****************************************************************************
+ @bref
+  The entry point of the Ipmi PEIM. Instals Ipmi PPI interface.
+
+  @param  FileHandle  Handle of the file being invoked.
+  @param  PeiServices Describes the list of possible PEI Services.
+
+  @retval EFI_SUCCESS   Indicates that Ipmi initialization completed successfully.
+**/
+EFI_STATUS
+PeimIpmiInterfaceInit (
+  IN       EFI_PEI_FILE_HANDLE  FileHandle,
+  IN CONST EFI_PEI_SERVICES     **PeiServices
+  )
+{
+  EFI_STATUS  Status;
+
+
+  //
+  // Performing Ipmi KCS physical layer initialization
+  //
+  Status = PeiInitializeIpmiKcsPhysicalLayer (PeiServices);
+
+  return EFI_SUCCESS;
+} // PeimIpmiInterfaceInit()
+
+
+EFI_STATUS
+PeiIpmiSendCommand (
+  IN      PEI_IPMI_TRANSPORT_PPI       *This,
+  IN      UINT8                        NetFunction,
+  IN      UINT8                        Lun,
+  IN      UINT8                        Command,
+  IN      UINT8                        *CommandData,
+  IN      UINT32                       CommandDataSize,
+  IN OUT  UINT8                        *ResponseData,
+  IN OUT  UINT32                       *ResponseDataSize
+  )
+/*++
+
+Routine Description:
+
+  Send Ipmi Command in the right mode: HECI or KCS,  to the
+  appropiate device, ME or BMC.
+
+Arguments:
+
+  This              - Pointer to IPMI protocol instance
+  NetFunction       - Net Function of command to send
+  Lun               - LUN of command to send
+  Command           - IPMI command to send
+  CommandData       - Pointer to command data buffer, if needed
+  CommandDataSize   - Size of command data buffer
+  ResponseData      - Pointer to response data buffer
+  ResponseDataSize  - Pointer to response data buffer size
+
+Returns:
+
+  EFI_INVALID_PARAMETER - One of the input values is bad
+  EFI_DEVICE_ERROR      - IPMI command failed
+  EFI_BUFFER_TOO_SMALL  - Response buffer is too small
+  EFI_UNSUPPORTED       - Command is not supported by BMC
+  EFI_SUCCESS           - Command completed successfully
+
+--*/
+{
+  //
+  // This Will be unchanged ( BMC/KCS style )
+  //
+  return PeiIpmiSendCommandToBmc (
+           This,
+           NetFunction,
+           Lun,
+           Command,
+           CommandData,
+           (UINT8) CommandDataSize,
+           ResponseData,
+           (UINT8 *) ResponseDataSize,
+           NULL
+           );
+} // IpmiSendCommand()
+
+EFI_STATUS
+PeiGetIpmiBmcStatus (
+  IN      PEI_IPMI_TRANSPORT_PPI       *This,
+  OUT BMC_STATUS                       *BmcStatus,
+  OUT SM_COM_ADDRESS                   *ComAddress
+  )
+/*++
+
+Routine Description:
+
+  Updates the BMC status and returns the Com Address
+
+Arguments:
+
+  This        - Pointer to IPMI protocol instance
+  BmcStatus   - BMC status
+  ComAddress  - Com Address
+
+Returns:
+
+  EFI_SUCCESS - Success
+
+--*/
+{
+  return PeiIpmiBmcStatus (
+           This,
+           BmcStatus,
+           ComAddress,
+           NULL
+           );
+}
+
+
+EFI_STATUS
+GetDeviceId (
+  IN      PEI_IPMI_BMC_INSTANCE_DATA   *mIpmiInstance
+  )
+/*++
+
+Routine Description:
+  Execute the Get Device ID command to determine whether or not the BMC is in Force Update
+  Mode.  If it is, then report it to the error manager.
+
+Arguments:
+  mIpmiInstance   - Data structure describing BMC variables and used for sending commands
+  StatusCodeValue - An array used to accumulate error codes for later reporting.
+  ErrorCount      - Counter used to keep track of error codes in StatusCodeValue
+
+Returns:
+  Status
+
+--*/
+{
+  EFI_STATUS          Status;
+  UINT32              DataSize;
+  SM_CTRL_INFO        *pBmcInfo;
+  UINTN               Retries;
+
+  //
+  // Set up a loop to retry for up to PcdIpmiBmcReadyDelayTimer seconds. Calculate retries not timeout
+  // so that in case KCS is not enabled and IpmiSendCommand() returns
+  // immediately we will not wait all the PcdIpmiBmcReadyDelayTimer seconds.
+  //
+  Retries = PcdGet8 (PcdIpmiBmcReadyDelayTimer);
+  //
+  // Get the device ID information for the BMC.
+  //
+  DataSize = sizeof (mIpmiInstance->TempData);
+  while (EFI_ERROR (Status = PeiIpmiSendCommand (
+                               &mIpmiInstance->IpmiTransportPpi,
+                               IPMI_NETFN_APP,
+                               0,
+                               IPMI_APP_GET_DEVICE_ID,
+                               NULL,
+                               0,
+                               mIpmiInstance->TempData,
+                               &DataSize
+                               ))) {
+    DEBUG ((EFI_D_ERROR, "[IPMI] BMC does not respond (status: %r), %d retries left\n",
+            Status, Retries));
+
+    if (Retries-- == 0) {
+      ReportStatusCode (EFI_ERROR_CODE | EFI_ERROR_MAJOR, EFI_COMPUTING_UNIT_FIRMWARE_PROCESSOR | EFI_CU_FP_EC_COMM_ERROR);
+      mIpmiInstance->BmcStatus = BMC_HARDFAIL;
+      return Status;
+    }
+    //
+    // Handle the case that BMC FW still not enable KCS channel after AC cycle. just stall 1 second
+    //
+    MicroSecondDelay (1*1000*1000);
+  }
+  pBmcInfo = (SM_CTRL_INFO*) &mIpmiInstance->TempData[0];
+  DEBUG ((DEBUG_INFO, "[IPMI PEI] BMC Device ID: 0x%02X, firmware version: %d.%02X UpdateMode:%x\n",
+          pBmcInfo->DeviceId, pBmcInfo->MajorFirmwareRev, pBmcInfo->MinorFirmwareRev, pBmcInfo->UpdateMode));
+  //
+  // In OpenBMC, UpdateMode: the bit 7 of byte 4 in get device id command is used for the BMC status:
+  // 0 means BMC is ready, 1 means BMC is not ready.
+  // At the very beginning of BMC power on, the status is 1 means BMC is in booting process and not ready. It is not the flag for force update mode.
+  //
+  if (pBmcInfo->UpdateMode == BMC_READY) {
+    mIpmiInstance->BmcStatus = BMC_OK;
+    return EFI_SUCCESS;
+  } else {
+    //
+    // Updatemode = 1 mean BMC is not ready, continue waiting.
+    //
+    while (Retries-- != 0) {
+      MicroSecondDelay(1*1000*1000); //delay 1 seconds
+      DEBUG ((DEBUG_INFO, "[IPMI PEI] UpdateMode Retries:%x \n",Retries));
+      Status = PeiIpmiSendCommand (
+                 &mIpmiInstance->IpmiTransportPpi,
+                 IPMI_NETFN_APP,
+                 0,
+                 IPMI_APP_GET_DEVICE_ID,
+                 NULL,
+                 0,
+                 mIpmiInstance->TempData,
+                 &DataSize
+                 );
+      if (!EFI_ERROR (Status)) {
+        pBmcInfo = (SM_CTRL_INFO*) &mIpmiInstance->TempData[0];
+        DEBUG ((DEBUG_INFO, "[IPMI PEI] UpdateMode Retries:%x   pBmcInfo->UpdateMode:%x\n", Retries, pBmcInfo->UpdateMode));
+        if (pBmcInfo->UpdateMode == BMC_READY) {
+          mIpmiInstance->BmcStatus = BMC_OK;
+          return EFI_SUCCESS;
+        }
+      }
+    }
+  }
+
+  mIpmiInstance->BmcStatus = BMC_HARDFAIL;
+  return Status;
+} // GetDeviceId()
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.h
new file mode 100644
index 0000000000..d31af85325
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.h
@@ -0,0 +1,138 @@
+/** @file
+  Generic IPMI stack head file during PEI phase
+
+  @copyright
+  Copyright 2017 - 2021 Intel Corporation. <BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef _PEI_IPMI_INIT_H_
+#define _PEI_IPMI_INIT_H_
+
+#include <PiPei.h>
+#include <Uefi.h>
+
+#include <Ppi/IpmiTransportPpi.h>
+
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/IoLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/PcdLib.h>
+#include <Library/PeiServicesLib.h>
+#include <Library/PeiServicesTablePointerLib.h>
+#include <Library/TimerLib.h>
+#include <Library/PciLib.h>
+
+#include "PeiIpmiBmcDef.h"
+#include "PeiIpmiBmc.h"
+
+//
+// Prototypes
+//
+#define MBXDAT_B                          0x0B
+#define BMC_KCS_TIMEOUT_PEI               5     // [s] Single KSC request timeout
+#define KCS_DELAY_UNIT_PEI                1000  // [s] Each KSC IO delay
+#define IPMI_DEFAULT_IO_BASE              0xCA2
+
+//
+// Internal(hook) function list
+//
+EFI_STATUS
+SendPreBootSignaltoBmc (
+  IN CONST EFI_PEI_SERVICES             **PeiServices
+  )
+  /*++
+
+Routine Description:
+  Send Pre-Boot signal to BMC
+
+Arguments:
+  PeiServices           - General purpose services available to every PEIM.
+
+Returns:
+  EFI_SUCCESS           - Success
+--*/
+;
+
+EFI_STATUS
+PeiIpmiSendCommand (
+  IN      PEI_IPMI_TRANSPORT_PPI       *This,
+  IN      UINT8                        NetFunction,
+  IN      UINT8                        Lun,
+  IN      UINT8                        Command,
+  IN      UINT8                        *CommandData,
+  IN      UINT32                       CommandDataSize,
+  IN OUT  UINT8                        *ResponseData,
+  IN OUT  UINT32                       *ResponseDataSize
+  )
+/*++
+
+Routine Description:
+  Send IPMI command to BMC
+
+Arguments:
+  This              - Pointer to IPMI protocol instance
+  NetFunction       - Net Function of command to send
+  Lun               - LUN of command to send
+  Command           - IPMI command to send
+  CommandData       - Pointer to command data buffer, if needed
+  CommandDataSize   - Size of command data buffer
+  ResponseData      - Pointer to response data buffer
+  ResponseDataSize  - Pointer to response data buffer size
+
+Returns:
+  EFI_INVALID_PARAMETER - One of the input values is bad
+  EFI_DEVICE_ERROR      - IPMI command failed
+  EFI_BUFFER_TOO_SMALL  - Response buffer is too small
+  EFI_UNSUPPORTED       - Command is not supported by BMC
+  EFI_SUCCESS           - Command completed successfully
+--*/
+;
+
+EFI_STATUS
+PeiGetIpmiBmcStatus (
+  IN  PEI_IPMI_TRANSPORT_PPI                           *This,
+  OUT BMC_STATUS                                       *BmcStatus,
+  OUT SM_COM_ADDRESS                                   *ComAddress
+  )
+/*++
+
+Routine Description:
+  Updates the BMC status and returns the Com Address
+
+Arguments:
+  This        - Pointer to IPMI protocol instance
+  BmcStatus   - BMC status
+  ComAddress  - Com Address
+
+Returns:
+  EFI_SUCCESS - Success
+--*/
+;
+
+//
+// internal function list
+//
+EFI_STATUS
+GetDeviceId (
+  IN      PEI_IPMI_BMC_INSTANCE_DATA   *mIpmiInstance
+  )
+/*++
+
+Routine Description:
+  Execute the Get Device ID command to determine whether or not the BMC is in Force Update
+  Mode.  If it is, then report it to the error manager.
+
+Arguments:
+  mIpmiInstance   - Data structure describing BMC variables and used for sending commands
+  StatusCodeValue - An array used to accumulate error codes for later reporting.
+  ErrorCount      - Counter used to keep track of error codes in StatusCodeValue
+
+Returns:
+  Status
+
+--*/
+;
+#endif //_PEI_IPMI_INIT_H_
+
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.inf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.inf
new file mode 100644
index 0000000000..0ef2c18116
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.inf
@@ -0,0 +1,58 @@
+## @file
+# Generic IPMI during PEI phase
+#
+# @copyright
+# Copyright 2017 - 2021 Intel Corporation. <BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = PeiGenericIpmi
+  FILE_GUID                      = 0B161208-2958-460C-B97F-B912A8AD0F8D
+  MODULE_TYPE                    = PEIM
+  VERSION_STRING                 = 1.0
+  ENTRY_POINT                    = PeimIpmiInterfaceInit
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64
+#
+#  HOB Guid C Name: gEfiHtBistHobGuid Hob Type: GUID_EXTENSION
+#
+[Sources]
+  ../Common/IpmiBmcCommon.h
+  ../Common/KcsBmc.c
+  ../Common/KcsBmc.h
+  PeiIpmiBmc.c
+  PeiIpmiBmc.h
+  PeiIpmiBmcDef.h
+  PeiGenericIpmi.c
+  PeiGenericIpmi.h
+
+[Packages]
+  MdePkg/MdePkg.dec
+  OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec
+
+[LibraryClasses]
+  PeimEntryPoint
+  PciLib
+  MemoryAllocationLib
+  DebugLib
+  IoLib
+  TimerLib
+
+[Guids]
+
+[Ppis]
+  gPeiIpmiTransportPpiGuid       #ALWAYS PRODUCE
+
+[Pcd]
+  gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiIoBaseAddress
+  gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiBmcReadyDelayTimer
+  gIpmiFeaturePkgTokenSpaceGuid.PcdSioMailboxBaseAddress
+  gIpmiFeaturePkgTokenSpaceGuid.PcdSignalPreBootToBmc
+
+[Depex]
+  TRUE
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiBmc.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiBmc.c
new file mode 100644
index 0000000000..32665b3e22
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiBmc.c
@@ -0,0 +1,277 @@
+/** @file
+  Generic IPMI transport layer during PEI phase
+
+  @copyright
+  Copyright 2016 - 2021 Intel Corporation. <BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include "PeiIpmiBmc.h"
+
+EFI_STATUS
+UpdateErrorStatus (
+  IN UINT8                      BmcError,
+  PEI_IPMI_BMC_INSTANCE_DATA    *IpmiInstance
+  )
+/*++
+
+Routine Description:
+
+  Check if the completion code is a Soft Error and increment the count.  The count
+  is not updated if the BMC is in Force Update Mode.
+
+Arguments:
+
+  BmcError      - Completion code to check
+  IpmiInstance  - BMC instance data
+
+Returns:
+
+  EFI_SUCCESS   - Status
+
+--*/
+{
+  UINT8   Errors[] = COMPLETION_CODES;
+  UINT16  CodeCount;
+  UINT8   i;
+
+  CodeCount = sizeof (Errors) / sizeof (Errors[0]);
+  for (i = 0; i < CodeCount; i++) {
+    if (BmcError == Errors[i]) {
+      //
+      // Don't change Bmc Status flag if the BMC is in Force Update Mode.
+      //
+      if (IpmiInstance->BmcStatus != BMC_UPDATE_IN_PROGRESS) {
+        IpmiInstance->BmcStatus = BMC_SOFTFAIL;
+      }
+
+      IpmiInstance->SoftErrorCount++;
+      break;
+    }
+  }
+
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+PeiIpmiSendCommandToBmc (
+  IN      PEI_IPMI_TRANSPORT_PPI        *This,
+  IN      UINT8                         NetFunction,
+  IN      UINT8                         Lun,
+  IN      UINT8                         Command,
+  IN      UINT8                         *CommandData,
+  IN      UINT8                         CommandDataSize,
+  IN OUT  UINT8                         *ResponseData,
+  IN OUT  UINT8                         *ResponseDataSize,
+  IN      VOID                          *Context
+  )
+/*++
+
+Routine Description:
+
+  Send IPMI command to BMC
+
+Arguments:
+
+  This              - Pointer to IPMI protocol instance
+  NetFunction       - Net Function of command to send
+  Lun               - LUN of command to send
+  Command           - IPMI command to send
+  CommandData       - Pointer to command data buffer, if needed
+  CommandDataSize   - Size of command data buffer
+  ResponseData      - Pointer to response data buffer
+  ResponseDataSize  - Pointer to response data buffer size
+  Context           - Context
+
+Returns:
+
+  EFI_INVALID_PARAMETER - One of the input values is bad
+  EFI_DEVICE_ERROR      - IPMI command failed
+  EFI_BUFFER_TOO_SMALL  - Response buffer is too small
+  EFI_UNSUPPORTED       - Command is not supported by BMC
+  EFI_SUCCESS           - Command completed successfully
+
+--*/
+{
+  PEI_IPMI_BMC_INSTANCE_DATA  *IpmiInstance;
+  UINT8                       DataSize;
+  EFI_STATUS                  Status;
+  IPMI_COMMAND                *IpmiCommand;
+  IPMI_RESPONSE               *IpmiResponse;
+  UINT8                       Index;
+
+  IpmiInstance = INSTANCE_FROM_PEI_SM_IPMI_BMC_THIS (This);
+
+  //
+  // The TempData buffer is used for both sending command data and receiving
+  // response data.  Since the command format is different from the response
+  // format, the buffer is cast to both structure definitions.
+  //
+  IpmiCommand   = (IPMI_COMMAND*)  IpmiInstance->TempData;
+  IpmiResponse  = (IPMI_RESPONSE*) IpmiInstance->TempData;
+
+  //
+  // Send IPMI command to BMC
+  //
+  IpmiCommand->Lun          = Lun;
+  IpmiCommand->NetFunction  = NetFunction;
+  IpmiCommand->Command      = Command;
+
+  //
+  // Ensure that the buffer is valid before attempting to copy the command data
+  // buffer into the IpmiCommand structure.
+  //
+  if (CommandDataSize > 0) {
+    if (CommandData == NULL) {
+      return EFI_INVALID_PARAMETER;
+    }
+
+    CopyMem (
+      IpmiCommand->CommandData,
+      CommandData,
+      CommandDataSize
+      );
+  }
+
+  Status = SendDataToBmcPort (
+             IpmiInstance->KcsTimeoutPeriod,
+             IpmiInstance->IpmiIoBase,
+             Context,
+             (UINT8 *) IpmiCommand,
+             (CommandDataSize + IPMI_COMMAND_HEADER_SIZE)
+             );
+
+  if (Status != EFI_SUCCESS) {
+    IpmiInstance->BmcStatus = BMC_SOFTFAIL;
+    IpmiInstance->SoftErrorCount++;
+    DEBUG ((EFI_D_ERROR, "PEI Phase SendDataToBmcPort failed Status:%r\n", Status));
+    return Status;
+  }
+
+  //
+  // Get Response to IPMI Command from BMC.
+  //
+  DataSize = MAX_TEMP_DATA;
+  Status = ReceiveBmcDataFromPort (
+             IpmiInstance->KcsTimeoutPeriod,
+             IpmiInstance->IpmiIoBase,
+             Context,
+             (UINT8 *) IpmiResponse,
+             &DataSize
+             );
+
+  if (Status != EFI_SUCCESS) {
+    IpmiInstance->BmcStatus = BMC_SOFTFAIL;
+    IpmiInstance->SoftErrorCount++;
+    DEBUG ((EFI_D_ERROR, "PEI Phase ReceiveBmcDataFromPort failed Status:%r\n", Status));
+    return Status;
+  }
+
+  if ((IpmiResponse->CompletionCode != COMP_CODE_NORMAL) &&
+      (IpmiInstance->BmcStatus == BMC_UPDATE_IN_PROGRESS)) {
+    //
+    // If the completion code is not normal and the BMC is in Force Update
+    // mode, then update the error status and return EFI_UNSUPPORTED.
+    //
+    UpdateErrorStatus (
+      IpmiResponse->CompletionCode,
+      IpmiInstance
+      );
+    return EFI_UNSUPPORTED;
+  } else if (IpmiResponse->CompletionCode != COMP_CODE_NORMAL) {
+    //
+    // Otherwise if the BMC is in normal mode, but the completion code
+    // is not normal, then update the error status and return device error.
+    //
+    UpdateErrorStatus (
+      IpmiResponse->CompletionCode,
+      IpmiInstance
+      );
+    return EFI_DEVICE_ERROR;
+  }
+
+  //
+  // If we got this far without any error codes, but the DataSize is 0 then the
+  // command response failed, so do not continue.
+  //
+  //
+  // Some abnormal case, in order to avoid that BMC sent illegal data size.
+  // If we got this far without any error codes, but the DataSize less than IPMI_RESPONSE_HEADER_SIZE, then the
+  // command response failed, so do not continue.
+  if (DataSize < IPMI_RESPONSE_HEADER_SIZE) {
+    return EFI_DEVICE_ERROR;
+  }
+
+  //
+  // Verify the response data buffer passed in is big enough.
+  //
+  if ((DataSize - IPMI_RESPONSE_HEADER_SIZE) > *ResponseDataSize) {
+    return EFI_BUFFER_TOO_SMALL;
+  }
+
+  //
+  // Copy data over to the response data buffer.
+  //
+  *ResponseDataSize = DataSize - IPMI_RESPONSE_HEADER_SIZE;
+  CopyMem (
+    ResponseData,
+    IpmiResponse->ResponseData,
+    *ResponseDataSize
+    );
+
+  //
+  // Add completion code in response data to meet the requirement of IPMI spec 2.0
+  //
+  *ResponseDataSize += 1; // Add one byte for Completion Code
+  for (Index = 1; Index < *ResponseDataSize; Index++) {
+    ResponseData [*ResponseDataSize - Index] = ResponseData [*ResponseDataSize - (Index + 1)];
+  }
+  ResponseData [0] = IpmiResponse->CompletionCode;
+
+  IpmiInstance->BmcStatus = BMC_OK;
+  return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+PeiIpmiBmcStatus (
+  IN  PEI_IPMI_TRANSPORT_PPI          *This,
+  OUT BMC_STATUS                  *BmcStatus,
+  OUT SM_COM_ADDRESS              *ComAddress,
+  IN  VOID                            *Context
+  )
+/*++
+
+Routine Description:
+
+  Updates the BMC status and returns the Com Address
+
+Arguments:
+
+  This        - Pointer to IPMI protocol instance
+  BmcStatus   - BMC status
+  ComAddress  - Com Address
+  Context     - Context
+
+Returns:
+
+  EFI_SUCCESS - Success
+
+--*/
+{
+  PEI_IPMI_BMC_INSTANCE_DATA  *IpmiInstance;
+
+  IpmiInstance = INSTANCE_FROM_PEI_SM_IPMI_BMC_THIS (This);
+
+  if ((IpmiInstance->BmcStatus == BMC_SOFTFAIL) && (IpmiInstance->SoftErrorCount >= MAX_SOFT_COUNT)) {
+    IpmiInstance->BmcStatus = BMC_HARDFAIL;
+  }
+
+  *BmcStatus = IpmiInstance->BmcStatus;
+  ComAddress->ChannelType = SmBmc;
+  ComAddress->Address.BmcAddress.LunAddress = 0x0;
+  ComAddress->Address.BmcAddress.SlaveAddress = IpmiInstance->SlaveAddress;
+  ComAddress->Address.BmcAddress.ChannelAddress = 0x0;
+
+  return EFI_SUCCESS;
+}
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiBmc.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiBmc.h
new file mode 100644
index 0000000000..40b9429e84
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiBmc.h
@@ -0,0 +1,38 @@
+/** @file
+  Generic IPMI transport layer head file during PEI phase
+
+  @copyright
+  Copyright 2016 - 2021 Intel Corporation. <BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef _PEI_IPMI_BMC_H_
+#define _PEI_IPMI_BMC_H_
+
+#include <Library/MemoryAllocationLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/PcdLib.h>
+#include <Library/BaseLib.h>
+#include <Library/IoLib.h>
+#include <Library/IpmiBaseLib.h>
+
+#include <Ppi/IpmiTransportPpi.h>
+
+#include "PeiIpmiBmcDef.h"
+#include "KcsBmc.h"
+
+//
+// IPMI Instance signature
+//
+#define SM_IPMI_BMC_SIGNATURE SIGNATURE_32 ('i', 'p', 'm', 'i')
+
+#define INSTANCE_FROM_PEI_SM_IPMI_BMC_THIS(a) \
+  CR ( \
+  a, \
+  PEI_IPMI_BMC_INSTANCE_DATA, \
+  IpmiTransportPpi, \
+  SM_IPMI_BMC_SIGNATURE \
+  )
+
+#endif // _PEI_IPMI_BMC_H_
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiBmcDef.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiBmcDef.h
new file mode 100644
index 0000000000..3fbe70ce62
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiBmcDef.h
@@ -0,0 +1,156 @@
+/** @file
+  Generic IPMI transport layer common head file during PEI phase
+
+  @copyright
+  Copyright 2016 - 2021 Intel Corporation. <BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef _PEI_IPMI_COMMON_BMC_H_
+#define _PEI_IPMI_COMMON_BMC_H_
+
+#include <Ppi/IpmiTransportPpi.h>
+
+#define MAX_TEMP_DATA     160
+#define BMC_SLAVE_ADDRESS 0x20
+#define MAX_SOFT_COUNT    10
+#define COMP_CODE_NORMAL  0x00
+
+//
+// IPMI command completion codes to check for in the UpdateErrorStatus routine.
+// These completion codes indicate a soft error and a running total of the occurrences
+// of these errors is maintained.
+//
+#define COMP_CODE_NODE_BUSY               0xC0
+#define COMP_CODE_TIMEOUT                 0xC3
+#define COMP_CODE_OUT_OF_SPACE            0xC4
+#define COMP_CODE_OUT_OF_RANGE            0xC9
+#define COMP_CODE_CMD_RESP_NOT_PROVIDED   0xCE
+#define COMP_CODE_FAIL_DUP_REQUEST        0xCF
+#define COMP_CODE_SDR_REP_IN_UPDATE_MODE  0xD0
+#define COMP_CODE_DEV_IN_FW_UPDATE_MODE   0xD1
+#define COMP_CODE_BMC_INIT_IN_PROGRESS    0xD2
+#define COMP_CODE_UNSPECIFIED             0xFF
+
+#define COMPLETION_CODES \
+  { \
+    COMP_CODE_NODE_BUSY, COMP_CODE_TIMEOUT, COMP_CODE_OUT_OF_SPACE, COMP_CODE_OUT_OF_RANGE, \
+    COMP_CODE_CMD_RESP_NOT_PROVIDED, COMP_CODE_FAIL_DUP_REQUEST, COMP_CODE_SDR_REP_IN_UPDATE_MODE, \
+    COMP_CODE_DEV_IN_FW_UPDATE_MODE, COMP_CODE_BMC_INIT_IN_PROGRESS, COMP_CODE_UNSPECIFIED \
+  }
+//
+// Ensure proper structure formats
+//
+#pragma pack(1)
+//
+// Pei Ipmi instance data
+//
+typedef struct {
+  UINTN                  Signature;
+  UINT64                 KcsTimeoutPeriod;
+  UINT8                  SlaveAddress;
+  UINT8                  TempData[MAX_TEMP_DATA];
+  BMC_STATUS             BmcStatus;
+  UINT64                 ErrorStatus;
+  UINT8                  SoftErrorCount;
+  UINT16                 IpmiIoBase;
+  PEI_IPMI_TRANSPORT_PPI IpmiTransportPpi;
+  EFI_PEI_PPI_DESCRIPTOR PeiIpmiBmcDataDesc;
+} PEI_IPMI_BMC_INSTANCE_DATA;
+
+//
+// Structure of IPMI Command buffer
+//
+#define IPMI_COMMAND_HEADER_SIZE  2
+
+typedef struct {
+  UINT8 Lun : 2;
+  UINT8 NetFunction : 6;
+  UINT8 Command;
+  UINT8 CommandData[MAX_TEMP_DATA - IPMI_COMMAND_HEADER_SIZE];
+} IPMI_COMMAND;
+
+//
+// Structure of IPMI Command response buffer
+//
+#define IPMI_RESPONSE_HEADER_SIZE 3
+
+typedef struct {
+  UINT8 Lun : 2;
+  UINT8 NetFunction : 6;
+  UINT8 Command;
+  UINT8 CompletionCode;
+  UINT8 ResponseData[MAX_TEMP_DATA - IPMI_RESPONSE_HEADER_SIZE];
+} IPMI_RESPONSE;
+#pragma pack()
+
+EFI_STATUS
+PeiIpmiSendCommandToBmc (
+  IN      PEI_IPMI_TRANSPORT_PPI        *This,
+  IN      UINT8                         NetFunction,
+  IN      UINT8                         Lun,
+  IN      UINT8                         Command,
+  IN      UINT8                         *CommandData,
+  IN      UINT8                         CommandDataSize,
+  IN OUT  UINT8                         *ResponseData,
+  IN OUT  UINT8                         *ResponseDataSize,
+  IN      VOID                          *Context
+  )
+/*++
+
+Routine Description:
+
+  Send IPMI command to BMC
+
+Arguments:
+
+  This              - Pointer to IPMI protocol instance
+  NetFunction       - Net Function of command to send
+  Lun               - LUN of command to send
+  Command           - IPMI command to send
+  CommandData       - Pointer to command data buffer, if needed
+  CommandDataSize   - Size of command data buffer
+  ResponseData      - Pointer to response data buffer
+  ResponseDataSize  - Pointer to response data buffer size
+  Context           - Context
+
+Returns:
+
+  EFI_INVALID_PARAMETER - One of the input values is bad
+  EFI_DEVICE_ERROR      - IPMI command failed
+  EFI_BUFFER_TOO_SMALL  - Response buffer is too small
+  EFI_SUCCESS           - Command completed successfully
+
+--*/
+;
+
+
+EFI_STATUS
+PeiIpmiBmcStatus (
+  IN      PEI_IPMI_TRANSPORT_PPI       *This,
+  OUT BMC_STATUS                       *BmcStatus,
+  OUT SM_COM_ADDRESS                   *ComAddress,
+  IN  VOID                             *Context
+  )
+/*++
+
+Routine Description:
+
+  Updates the BMC status and returns the Com Address
+
+Arguments:
+
+  This        - Pointer to IPMI protocol instance
+  BmcStatus   - BMC status
+  ComAddress  - Com Address
+  Context     - Context
+
+Returns:
+
+  EFI_SUCCESS - Success
+
+--*/
+;
+
+
+#endif //_PEI_IPMI_COMMON_BMC_H_
-- 
2.27.0.windows.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [edk2-platforms] [PATCH v1 6/9] IpmiFeaturePkg: Add GenericIpmi DXE Driver
  2021-03-02  2:27 [edk2-platforms] [PATCH v1 0/9] IpmiFeaturePkg: Add IPMI transport drivers Nate DeSimone
                   ` (4 preceding siblings ...)
  2021-03-02  2:28 ` [edk2-platforms] [PATCH v1 5/9] IpmiFeaturePkg: Add GenericIpmi PEIM Nate DeSimone
@ 2021-03-02  2:28 ` Nate DeSimone
  2021-03-02  2:28 ` [edk2-platforms] [PATCH v1 7/9] IpmiFeaturePkg: Add GenericIpmi SMM Driver Nate DeSimone
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Nate DeSimone @ 2021-03-02  2:28 UTC (permalink / raw)
  To: devel; +Cc: Isaac Oram, Sai Chaganty, Liming Gao, Michael Kubacki

From: Isaac Oram <isaac.w.oram@intel.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3242

Adds the DXE version of the generic
IPMI transport driver.

Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Michael Kubacki <michael.kubacki@microsoft.com>
Signed-off-by: Isaac Oram <isaac.w.oram@intel.com>
Co-authored-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
---
 .../GenericIpmi/Dxe/GenericIpmi.c             |  46 ++
 .../GenericIpmi/Dxe/GenericIpmi.inf           |  66 +++
 .../IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c | 452 ++++++++++++++++++
 3 files changed, 564 insertions(+)
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/GenericIpmi.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/GenericIpmi.inf
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c

diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/GenericIpmi.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/GenericIpmi.c
new file mode 100644
index 0000000000..957a9c8e6e
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/GenericIpmi.c
@@ -0,0 +1,46 @@
+/** @file
+  Generic IPMI Transport functions..
+
+  @copyright
+  Copyright 1999 - 2021 Intel Corporation. <BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <IndustryStandard/Ipmi.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiDriverEntryPoint.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/PcdLib.h>
+#include <Library/UefiLib.h>
+#include <Library/BaseLib.h>
+#include "IpmiPhysicalLayer.h"
+
+/*****************************************************************************
+ @brief
+  This is entry point for IPMI service for BIOS POST.
+
+ @param[in] ImageHandle  a handle to driver image
+ @param[in] SystemTable  a pointer to system table
+
+ @retval EFI_SUCCESS      The function completed successfully.
+ @retval EFI_UNSUPPORTED  IPMI is not available.
+**/
+EFI_STATUS
+LocateIpmiInterface (
+  IN EFI_HANDLE             ImageHandle,
+  IN EFI_SYSTEM_TABLE       *SystemTable
+  )
+{
+  EFI_STATUS          Status;
+
+  Status = InitializeIpmiKcsPhysicalLayer (ImageHandle, SystemTable);
+
+  //
+  // keep this interface for other Physical Layer as new interface.
+  //
+
+  return Status;
+} // LocateIpmiInterface()
+
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/GenericIpmi.inf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/GenericIpmi.inf
new file mode 100644
index 0000000000..9881f9e3d0
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/GenericIpmi.inf
@@ -0,0 +1,66 @@
+## @file
+# Generic IPMI DXE Driver.
+#
+# @copyright
+# Copyright 2010 - 2021 Intel Corporation. <BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = GenericIpmi
+  FILE_GUID                      = 07A01ACF-46D5-48de-A63D-74FA92AA8450
+  MODULE_TYPE                    = DXE_DRIVER
+  VERSION_STRING                 = 1.0
+  ENTRY_POINT                    = LocateIpmiInterface
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64
+#
+#  VIRTUAL_ADDRESS_MAP_CALLBACK  = VariableAddressChangeEvent
+#
+
+[Sources]
+  ../Common/IpmiHooks.h
+  ../Common/IpmiHooks.c
+  ../Common/IpmiBmcCommon.h
+  ../Common/KcsBmc.c
+  ../Common/KcsBmc.h
+  ../Common/IpmiBmc.h
+  ../Common/IpmiBmc.c
+  GenericIpmi.c
+  IpmiInit.c
+
+
+[Packages]
+  MdePkg/MdePkg.dec
+  OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec
+
+[LibraryClasses]
+  MemoryAllocationLib
+  BaseLib
+  UefiBootServicesTableLib
+  UefiRuntimeServicesTableLib
+  DebugLib
+  DxeServicesTableLib
+  UefiDriverEntryPoint
+  IoLib
+  ReportStatusCodeLib
+  TimerLib
+
+[Protocols]
+  gIpmiTransportProtocolGuid               # PROTOCOL ALWAYS_PRODUCED
+  gEfiVideoPrintProtocolGuid
+
+[Guids]
+
+[Pcd]
+  gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiIoBaseAddress
+  gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiBmcReadyDelayTimer
+
+[Depex]
+  gEfiRuntimeArchProtocolGuid AND
+  gEfiVariableArchProtocolGuid
+
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c
new file mode 100644
index 0000000000..1e0c132508
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c
@@ -0,0 +1,452 @@
+/** @file
+  Generic IPMI stack driver
+
+  @copyright
+  Copyright 1999 - 2021 Intel Corporation. <BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <IndustryStandard/Ipmi.h>
+#include <SmStatusCodes.h>
+#include "IpmiHooks.h"
+#include "IpmiBmcCommon.h"
+#include "IpmiBmc.h"
+#include "IpmiPhysicalLayer.h"
+#include <Library/TimerLib.h>
+#ifdef FAST_VIDEO_SUPPORT
+  #include <Protocol/VideoPrint.h>
+#endif
+#include <Library/UefiRuntimeServicesTableLib.h>
+
+
+/******************************************************************************
+ * Local variables
+ */
+IPMI_BMC_INSTANCE_DATA       *mIpmiInstance = NULL;
+EFI_HANDLE                    mImageHandle;
+
+//
+// Specific test interface
+//
+VOID
+GetDeviceSpecificTestResults (
+  IN      IPMI_BMC_INSTANCE_DATA *IpmiInstance
+  )
+/*++
+
+Routine Description:
+
+  This is a BMC specific routine to check the device specific self test results as defined
+  in the Bensley BMC core specification.
+
+Arguments:
+
+  IpmiInstance  - Data structure describing BMC variables and used for sending commands
+
+Returns:
+
+  VOID
+
+--*/
+{
+  return;
+}
+
+EFI_STATUS
+GetSelfTest (
+  IN      IPMI_BMC_INSTANCE_DATA     *IpmiInstance,
+  IN      EFI_STATUS_CODE_VALUE       StatusCodeValue[],
+  IN OUT  UINT8                       *ErrorCount
+  )
+/*++
+
+Routine Description:
+
+  Execute the Get Self Test results command to determine whether or not the BMC self tests
+  have passed
+
+Arguments:
+
+  IpmiInstance    - Data structure describing BMC variables and used for sending commands
+  StatusCodeValue - An array used to accumulate error codes for later reporting.
+  ErrorCount      - Counter used to keep track of error codes in StatusCodeValue
+
+Returns:
+
+  EFI_SUCCESS       - BMC Self test results are retrieved and saved into BmcStatus
+  EFI_DEVICE_ERROR  - BMC failed to return self test results.
+
+--*/
+{
+  EFI_STATUS  Status;
+  UINT32      DataSize;
+  UINT8       Index;
+  UINT8       *TempPtr;
+  UINT32      Retries;
+  BOOLEAN     bResultFlag = FALSE;
+
+  //
+  // Get the SELF TEST Results.
+  //
+  //
+  //Note: If BMC PcdIpmiBmcReadyDelayTimer < BMC_KCS_TIMEOUT, it need set Retries as 1. Otherwise it will make SELT failure, caused by below condition (EFI_ERROR(Status) || Retries == 0)
+  //
+  if (PcdGet8 (PcdIpmiBmcReadyDelayTimer) < BMC_KCS_TIMEOUT) {
+    Retries = 1;
+  } else {
+    Retries = PcdGet8 (PcdIpmiBmcReadyDelayTimer);
+  }
+
+  DataSize = sizeof (IpmiInstance->TempData);
+
+  IpmiInstance->TempData[1] = 0;
+
+  do {
+    Status = IpmiSendCommand (
+               &IpmiInstance->IpmiTransport,
+               IPMI_NETFN_APP,
+               0,
+               IPMI_APP_GET_SELFTEST_RESULTS,
+               NULL,
+               0,
+               IpmiInstance->TempData,
+               &DataSize
+               );
+    if (Status == EFI_SUCCESS) {
+      switch (IpmiInstance->TempData[1]) {
+        case IPMI_APP_SELFTEST_NO_ERROR:
+        case IPMI_APP_SELFTEST_NOT_IMPLEMENTED:
+        case IPMI_APP_SELFTEST_ERROR:
+        case IPMI_APP_SELFTEST_FATAL_HW_ERROR:
+          bResultFlag = TRUE;
+          break;
+
+        default:
+          break;
+      } //switch
+
+      if (bResultFlag) {
+        break;
+      }
+    }
+
+    MicroSecondDelay (500 * 1000);
+  } while (--Retries > 0);
+
+  //
+  // If Status indicates a Device error, then the BMC is not responding, so send an error.
+  //
+  if (EFI_ERROR (Status) || Retries == 0) {
+    DEBUG ((EFI_D_ERROR, "\n[IPMI]  BMC self-test does not respond (status: %r)!\n\n", Status));
+    if (*ErrorCount < MAX_SOFT_COUNT) {
+      StatusCodeValue[*ErrorCount] = EFI_COMPUTING_UNIT_FIRMWARE_PROCESSOR | EFI_CU_FP_EC_COMM_ERROR;
+      (*ErrorCount)++;
+    }
+
+    IpmiInstance->BmcStatus = BMC_HARDFAIL;
+    return Status;
+  } else {
+    DEBUG ((EFI_D_INFO, "[IPMI] BMC self-test result: %02X-%02X\n", IpmiInstance->TempData[1], IpmiInstance->TempData[2]));
+    //
+    // Copy the Self test results to Error Status.  Data will be copied as long as it
+    // does not exceed the size of the ErrorStatus variable.
+    //
+    for (Index = 0, TempPtr = (UINT8 *) &IpmiInstance->ErrorStatus;
+         (Index < DataSize) && (Index < sizeof (IpmiInstance->ErrorStatus));
+         Index++, TempPtr++
+         ) {
+      *TempPtr = IpmiInstance->TempData[Index];
+    }
+    //
+    // Check the IPMI defined self test results.
+    // Additional Cases are device specific test results.
+    //
+    switch (IpmiInstance->TempData[0]) {
+      case IPMI_APP_SELFTEST_NO_ERROR:
+      case IPMI_APP_SELFTEST_NOT_IMPLEMENTED:
+        IpmiInstance->BmcStatus = BMC_OK;
+        break;
+
+      case IPMI_APP_SELFTEST_ERROR:
+        //
+        // Three of the possible errors result in BMC hard failure; FRU Corruption,
+        // BootBlock Firmware corruption, and Operational Firmware Corruption.  All
+        // other errors are BMC soft failures.
+        //
+        if ((IpmiInstance->TempData[1] & (IPMI_APP_SELFTEST_FRU_CORRUPT | IPMI_APP_SELFTEST_FW_BOOTBLOCK_CORRUPT | IPMI_APP_SELFTEST_FW_CORRUPT)) != 0) {
+          IpmiInstance->BmcStatus = BMC_HARDFAIL;
+        } else {
+          IpmiInstance->BmcStatus = BMC_SOFTFAIL;
+        }
+        //
+        // Check if SDR repository is empty and report it if it is.
+        //
+        if ((IpmiInstance->TempData[1] & IPMI_APP_SELFTEST_SDR_REPOSITORY_EMPTY) != 0) {
+          if (*ErrorCount < MAX_SOFT_COUNT) {
+            StatusCodeValue[*ErrorCount] = EFI_COMPUTING_UNIT_FIRMWARE_PROCESSOR | CU_FP_EC_SDR_EMPTY;
+            (*ErrorCount)++;
+          }
+        }
+        break;
+
+      case IPMI_APP_SELFTEST_FATAL_HW_ERROR:
+        IpmiInstance->BmcStatus = BMC_HARDFAIL;
+        break;
+
+      default:
+        //
+        // Call routine to check device specific failures.
+        //
+        GetDeviceSpecificTestResults (IpmiInstance);
+    }
+
+    if (IpmiInstance->BmcStatus == BMC_HARDFAIL) {
+      if (*ErrorCount < MAX_SOFT_COUNT) {
+        StatusCodeValue[*ErrorCount] = EFI_COMPUTING_UNIT_FIRMWARE_PROCESSOR | EFI_CU_FP_EC_HARD_FAIL;
+        (*ErrorCount)++;
+      }
+    } else if (IpmiInstance->BmcStatus == BMC_SOFTFAIL) {
+      if (*ErrorCount < MAX_SOFT_COUNT) {
+        StatusCodeValue[*ErrorCount] = EFI_COMPUTING_UNIT_FIRMWARE_PROCESSOR | EFI_CU_FP_EC_SOFT_FAIL;
+        (*ErrorCount)++;
+      }
+    }
+  }
+
+  return EFI_SUCCESS;
+} // GetSelfTest()
+
+
+EFI_STATUS
+GetDeviceId (
+  IN      IPMI_BMC_INSTANCE_DATA       *IpmiInstance,
+  IN      EFI_STATUS_CODE_VALUE        StatusCodeValue[ ],
+  IN OUT  UINT8                        *ErrorCount
+  )
+/*++
+
+Routine Description:
+  Execute the Get Device ID command to determine whether or not the BMC is in Force Update
+  Mode.  If it is, then report it to the error manager.
+
+Arguments:
+  IpmiInstance    - Data structure describing BMC variables and used for sending commands
+  StatusCodeValue - An array used to accumulate error codes for later reporting.
+  ErrorCount      - Counter used to keep track of error codes in StatusCodeValue
+
+Returns:
+  Status
+
+--*/
+{
+  EFI_STATUS                      Status;
+  UINT32                          DataSize;
+  SM_CTRL_INFO                    *pBmcInfo;
+  EFI_IPMI_MSG_GET_BMC_EXEC_RSP   *pBmcExecContext;
+  UINT32                          Retries;
+#ifdef FAST_VIDEO_SUPPORT
+  EFI_VIDEOPRINT_PROTOCOL         *VideoPrintProtocol;
+  EFI_STATUS                      VideoPrintStatus;
+#endif
+
+#ifdef FAST_VIDEO_SUPPORT
+  VideoPrintStatus = gBS->LocateProtocol (
+                            &gEfiVideoPrintProtocolGuid,
+                            NULL,
+                            &VideoPrintProtocol
+                            );
+#endif
+
+  //
+  // Set up a loop to retry for up to PcdIpmiBmcReadyDelayTimer seconds. Calculate retries not timeout
+  // so that in case KCS is not enabled and IpmiSendCommand() returns
+  // immediately we will not wait all the PcdIpmiBmcReadyDelayTimer seconds.
+  //
+  Retries = PcdGet8 (PcdIpmiBmcReadyDelayTimer);
+  //
+  // Get the device ID information for the BMC.
+  //
+  DataSize = sizeof (IpmiInstance->TempData);
+  while (EFI_ERROR (Status = IpmiSendCommand (
+                               &IpmiInstance->IpmiTransport,
+                               IPMI_NETFN_APP, 0,
+                               IPMI_APP_GET_DEVICE_ID,
+                               NULL, 0,
+                               IpmiInstance->TempData, &DataSize))
+         ) {
+    DEBUG ((DEBUG_ERROR, "[IPMI] BMC does not respond by Get BMC DID (status: %r), %d retries left, ResponseData: 0x%lx\n",
+            Status, Retries, IpmiInstance->TempData));
+
+    if (Retries-- == 0) {
+      IpmiInstance->BmcStatus = BMC_HARDFAIL;
+      return Status;
+    }
+    //
+    //Handle the case that BMC FW still not enable KCS channel after AC cycle. just stall 1 second
+    //
+    MicroSecondDelay (1*1000*1000);
+  }
+
+  pBmcInfo = (SM_CTRL_INFO*)&IpmiInstance->TempData[0];
+  DEBUG ((EFI_D_ERROR, "[IPMI] BMC Device ID: 0x%02X, firmware version: %d.%02X UpdateMode:%x\n", pBmcInfo->DeviceId, pBmcInfo->MajorFirmwareRev, pBmcInfo->MinorFirmwareRev,pBmcInfo->UpdateMode));
+  //
+  // In OpenBMC, UpdateMode: the bit 7 of byte 4 in get device id command is used for the BMC status:
+  // 0 means BMC is ready, 1 means BMC is not ready.
+  // At the very beginning of BMC power on, the status is 1 means BMC is in booting process and not ready. It is not the flag for force update mode.
+  //
+  if (pBmcInfo->UpdateMode == BMC_READY) {
+    mIpmiInstance->BmcStatus = BMC_OK;
+    return EFI_SUCCESS;
+  } else {
+    Status = IpmiSendCommand (
+               &IpmiInstance->IpmiTransport,
+               IPMI_NETFN_FIRMWARE, 0,
+               EFI_FIRMWARE_GET_BMC_EXECUTION_CONTEXT,
+               NULL, 0,
+               IpmiInstance->TempData, &DataSize
+               );
+
+    pBmcExecContext = (EFI_IPMI_MSG_GET_BMC_EXEC_RSP*)&IpmiInstance->TempData[0];
+    DEBUG ((DEBUG_INFO, "[IPMI] Operational status of BMC: 0x%x\n", pBmcExecContext->CurrentExecutionContext));
+    if ((pBmcExecContext->CurrentExecutionContext == EFI_FIRMWARE_BMC_IN_FORCED_UPDATE_MODE) &&
+        !EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "[IPMI] BMC in Forced Update mode, skip waiting for BMC_READY.\n"));
+      IpmiInstance->BmcStatus = BMC_UPDATE_IN_PROGRESS;
+    } else {
+      //
+      // Updatemode = 1 mean BMC is not ready, continue waiting.
+      //
+      while (Retries-- != 0) {
+        MicroSecondDelay(1*1000*1000); //delay 1 seconds
+        DEBUG ((EFI_D_ERROR, "[IPMI] UpdateMode Retries: %d \n",Retries));
+        Status = IpmiSendCommand (
+                   &IpmiInstance->IpmiTransport,
+                   IPMI_NETFN_APP, 0,
+                   IPMI_APP_GET_DEVICE_ID,
+                   NULL, 0,
+                   IpmiInstance->TempData, &DataSize
+                   );
+
+        if (!EFI_ERROR (Status)) {
+          pBmcInfo = (SM_CTRL_INFO*)&IpmiInstance->TempData[0];
+          DEBUG ((EFI_D_ERROR, "[IPMI] UpdateMode Retries: %d   pBmcInfo->UpdateMode:%x, Status: %r, Response Data: 0x%lx\n",Retries, pBmcInfo->UpdateMode, Status, IpmiInstance->TempData));
+          if (pBmcInfo->UpdateMode == BMC_READY) {
+            mIpmiInstance->BmcStatus = BMC_OK;
+            return EFI_SUCCESS;
+          }
+        }
+      }
+      mIpmiInstance->BmcStatus = BMC_HARDFAIL;
+    }
+  }
+  return Status;
+} // GetDeviceId()
+
+
+/**
+  This function initializes KCS interface to BMC.
+
+  Setup and initialize the BMC for the DXE phase.  In order to verify the BMC is functioning
+  as expected, the BMC Selftest is performed.  The results are then checked and any errors are
+  reported to the error manager.  Errors are collected throughout this routine and reported
+  just prior to installing the driver.  If there are more errors than MAX_SOFT_COUNT, then they
+  will be ignored.
+
+  @param[in] ImageHandle - Handle of this driver image
+  @param[in] SystemTable - Table containing standard EFI services
+
+  @retval EFI_SUCCESS - Always success is returned even if KCS does not function
+ **/
+EFI_STATUS
+InitializeIpmiKcsPhysicalLayer (
+  IN EFI_HANDLE             ImageHandle,
+  IN EFI_SYSTEM_TABLE       *SystemTable
+  )
+{
+  EFI_STATUS             Status;
+  UINT8                  ErrorCount;
+  EFI_HANDLE             Handle;
+  UINT8                  Index;
+  EFI_STATUS_CODE_VALUE  StatusCodeValue[MAX_SOFT_COUNT];
+
+  ErrorCount = 0;
+  mImageHandle = ImageHandle;
+
+  mIpmiInstance = AllocateZeroPool (sizeof (*mIpmiInstance));
+  if (mIpmiInstance == NULL) {
+    DEBUG ((EFI_D_ERROR, "ERROR!! Null Pointer returned by AllocateZeroPool ()\n"));
+    ASSERT_EFI_ERROR (EFI_OUT_OF_RESOURCES);
+    return EFI_OUT_OF_RESOURCES;
+  } else {
+    //
+    // Calibrate TSC Counter.  Stall for 10ms, then multiply the resulting number of
+    // ticks in that period by 100 to get the number of ticks in a 1 second timeout
+    //
+
+    //
+    // Initialize the KCS transaction timeout.
+    //
+    mIpmiInstance->KcsTimeoutPeriod = (BMC_KCS_TIMEOUT * 1000*1000) / KCS_DELAY_UNIT;
+    DEBUG ((EFI_D_ERROR, "[IPMI] mIpmiInstance->KcsTimeoutPeriod: 0x%lx\n",mIpmiInstance->KcsTimeoutPeriod));
+
+    //
+    // Initialize IPMI IO Base.
+    //
+    mIpmiInstance->IpmiIoBase                       = PcdGet16 (PcdIpmiIoBaseAddress);
+    mIpmiInstance->Signature                        = SM_IPMI_BMC_SIGNATURE;
+    mIpmiInstance->SlaveAddress                     = BMC_SLAVE_ADDRESS;
+    mIpmiInstance->BmcStatus                        = BMC_NOTREADY;
+    mIpmiInstance->IpmiTransport.IpmiSubmitCommand  = IpmiSendCommand;
+    mIpmiInstance->IpmiTransport.GetBmcStatus       = IpmiGetBmcStatus;
+
+    //
+    // Get the Device ID and check if the system is in Force Update mode.
+    //
+    Status = GetDeviceId (
+               mIpmiInstance,
+               StatusCodeValue,
+               &ErrorCount
+               );
+    //
+    // Do not continue initialization if the BMC is in Force Update Mode.
+    //
+    if ((mIpmiInstance->BmcStatus != BMC_UPDATE_IN_PROGRESS) &&
+        (mIpmiInstance->BmcStatus != BMC_HARDFAIL)) {
+      //
+      // Get the SELF TEST Results.
+      //
+      Status = GetSelfTest (
+                 mIpmiInstance,
+                 StatusCodeValue,
+                 &ErrorCount
+                 );
+    }
+
+    //
+    // iterate through the errors reporting them to the error manager.
+    //
+    for (Index = 0; Index < ErrorCount; Index++) {
+      ReportStatusCode (
+        EFI_ERROR_CODE | EFI_ERROR_MAJOR,
+        StatusCodeValue[Index]
+        );
+    }
+
+    //
+    // Now install the Protocol if the BMC is not in a HardFail State and not in Force Update mode
+    //
+    if ((mIpmiInstance->BmcStatus != BMC_HARDFAIL) && (mIpmiInstance->BmcStatus != BMC_UPDATE_IN_PROGRESS)) {
+      Handle = NULL;
+      Status = gBS->InstallProtocolInterface (
+                      &Handle,
+                      &gIpmiTransportProtocolGuid,
+                      EFI_NATIVE_INTERFACE,
+                      &mIpmiInstance->IpmiTransport
+                      );
+      ASSERT_EFI_ERROR (Status);
+    }
+
+    return EFI_SUCCESS;
+  }
+} // InitializeIpmiKcsPhysicalLayer()
+
-- 
2.27.0.windows.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [edk2-platforms] [PATCH v1 7/9] IpmiFeaturePkg: Add GenericIpmi SMM Driver
  2021-03-02  2:27 [edk2-platforms] [PATCH v1 0/9] IpmiFeaturePkg: Add IPMI transport drivers Nate DeSimone
                   ` (5 preceding siblings ...)
  2021-03-02  2:28 ` [edk2-platforms] [PATCH v1 6/9] IpmiFeaturePkg: Add GenericIpmi DXE Driver Nate DeSimone
@ 2021-03-02  2:28 ` Nate DeSimone
  2021-03-02  2:28 ` [edk2-platforms] [PATCH v1 8/9] IpmiFeaturePkg: Add IPMI driver build files Nate DeSimone
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Nate DeSimone @ 2021-03-02  2:28 UTC (permalink / raw)
  To: devel; +Cc: Isaac Oram, Sai Chaganty, Liming Gao, Michael Kubacki

From: Isaac Oram <isaac.w.oram@intel.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3242

Adds the SMM version of the generic
IPMI transport driver.

Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Michael Kubacki <michael.kubacki@microsoft.com>
Signed-off-by: Isaac Oram <isaac.w.oram@intel.com>
Co-authored-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
---
 .../GenericIpmi/Smm/SmmGenericIpmi.c          | 208 ++++++++++++++++++
 .../GenericIpmi/Smm/SmmGenericIpmi.inf        |  53 +++++
 2 files changed, 261 insertions(+)
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/SmmGenericIpmi.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/SmmGenericIpmi.inf

diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/SmmGenericIpmi.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/SmmGenericIpmi.c
new file mode 100644
index 0000000000..fda215baaa
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/SmmGenericIpmi.c
@@ -0,0 +1,208 @@
+/** @file
+  Generic SMM IPMI stack driver
+
+  @copyright
+  Copyright 1999 - 2021 Intel Corporation. <BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+//
+// Statements that include other files
+//
+#include <IndustryStandard/Ipmi.h>
+#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 <Library/UefiBootServicesTableLib.h>
+#include <Library/IpmiBaseLib.h>
+#include <SmStatusCodes.h>
+#include "IpmiHooks.h"
+#include "IpmiBmcCommon.h"
+#include "IpmiBmc.h"
+#include <Library/TimerLib.h>
+
+IPMI_BMC_INSTANCE_DATA             *mIpmiInstance;
+EFI_HANDLE                         mImageHandle;
+
+
+EFI_STATUS
+GetDeviceId (
+  IN      IPMI_BMC_INSTANCE_DATA       *IpmiInstance,
+  IN      EFI_STATUS_CODE_VALUE        StatusCodeValue[ ],
+  IN OUT  UINT8                        *ErrorCount
+  )
+/*++
+
+Routine Description:
+  Execute the Get Device ID command to determine whether or not the BMC is in Force Update
+  Mode.  If it is, then report it to the error manager.
+
+Arguments:
+  IpmiInstance    - Data structure describing BMC variables and used for sending commands
+  StatusCodeValue - An array used to accumulate error codes for later reporting.
+  ErrorCount      - Counter used to keep track of error codes in StatusCodeValue
+
+Returns:
+  Status
+
+--*/
+{
+  EFI_STATUS               Status;
+  UINT32                   DataSize;
+  SM_CTRL_INFO             *ControllerInfo;
+  UINT8                    TimeOut;
+  UINT8                    Retries;
+
+  TimeOut = 0;
+  Retries = PcdGet8 (PcdIpmiBmcReadyDelayTimer);
+
+  do {
+    //
+    // Get the device ID information for the BMC.
+    //
+    DataSize = MAX_TEMP_DATA;
+    Status = IpmiSendCommand (
+               &IpmiInstance->IpmiTransport,
+               IPMI_NETFN_APP,
+               0,
+               IPMI_APP_GET_DEVICE_ID,
+               NULL,
+               0,
+               IpmiInstance->TempData,
+               &DataSize
+               );
+    if (Status == EFI_SUCCESS) {
+      DEBUG ((EFI_D_INFO, "IPMI: SendCommand success!\n"));
+      break;
+    } else {
+      //
+      // Display message and retry.
+      //
+      DEBUG (
+        (EFI_D_ERROR | EFI_D_INFO,
+         "IPMI: Waiting for BMC (KCS 0x%x)...\n",
+         IpmiInstance->IpmiIoBase)
+        );
+      MicroSecondDelay (500 * 1000);
+      TimeOut++;
+    }
+  } while (TimeOut < Retries);
+
+  //
+  // If there is no error then proceed to check the data returned by the BMC
+  //
+  if (!EFI_ERROR (Status)) {
+    ControllerInfo = (SM_CTRL_INFO *) IpmiInstance->TempData;
+    //
+    // If the controller is in Update Mode and the maximum number of errors has not been exceeded, then
+    // save the error code to the StatusCode array and increment the counter.  Set the BMC Status to indicate
+    // the BMC is in force update mode.
+    //
+    if (ControllerInfo->UpdateMode != 0) {
+      IpmiInstance->BmcStatus = BMC_UPDATE_IN_PROGRESS;
+      if (*ErrorCount < MAX_SOFT_COUNT) {
+        StatusCodeValue[*ErrorCount] = EFI_COMPUTING_UNIT_FIRMWARE_PROCESSOR | CU_FP_EC_FORCE_UPDATE_MODE;
+        (*ErrorCount)++;
+      }
+    }
+  }
+
+  return Status;
+}
+
+EFI_STATUS
+SmmInitializeIpmiKcsPhysicalLayer (
+  IN EFI_HANDLE             ImageHandle,
+  IN EFI_SYSTEM_TABLE       *SystemTable
+  )
+/*++
+
+Routine Description:
+  Setup and initialize the BMC for the DXE phase.  In order to verify the BMC is functioning
+  as expected, the BMC Selftest is performed.  The results are then checked and any errors are
+  reported to the error manager.  Errors are collected throughout this routine and reported
+  just prior to installing the driver.  If there are more errors than MAX_SOFT_COUNT, then they
+  will be ignored.
+
+Arguments:
+  ImageHandle - Handle of this driver image
+  SystemTable - Table containing standard EFI services
+
+Returns:
+  EFI_SUCCESS - Successful driver initialization
+
+--*/
+{
+  EFI_STATUS                       Status;
+  UINT8                            ErrorCount;
+  EFI_HANDLE                       Handle;
+  EFI_STATUS_CODE_VALUE            StatusCodeValue[MAX_SOFT_COUNT];
+
+  DEBUG ((DEBUG_INFO,"SmmInitializeIpmiKcsPhysicalLayer entry \n"));
+  ErrorCount = 0;
+  mImageHandle = ImageHandle;
+
+  mIpmiInstance = AllocateZeroPool (sizeof (IPMI_BMC_INSTANCE_DATA));
+  ASSERT (mIpmiInstance != NULL);
+  if (mIpmiInstance == NULL) {
+    DEBUG ((EFI_D_ERROR, "ERROR!! Null Pointer returned by AllocateZeroPool ()\n"));
+    ASSERT_EFI_ERROR (EFI_OUT_OF_RESOURCES);
+    return EFI_OUT_OF_RESOURCES;
+  } else {
+
+    //
+    // Initialize the KCS transaction timeout. Assume delay unit is 1000 us.
+    //
+    mIpmiInstance->KcsTimeoutPeriod = (BMC_KCS_TIMEOUT * 1000*1000) / KCS_DELAY_UNIT;
+
+    //
+    // Initialize IPMI IO Base, we still use SMS IO base to get device ID and Seltest result since SMM IF may have different cmds supported
+    //
+    mIpmiInstance->IpmiIoBase                       = PcdGet16 (PcdIpmiSmmIoBaseAddress);
+    mIpmiInstance->Signature                        = SM_IPMI_BMC_SIGNATURE;
+    mIpmiInstance->SlaveAddress                     = BMC_SLAVE_ADDRESS;
+    mIpmiInstance->BmcStatus                        = BMC_NOTREADY;
+    mIpmiInstance->IpmiTransport.IpmiSubmitCommand  = IpmiSendCommand;
+    mIpmiInstance->IpmiTransport.GetBmcStatus       = IpmiGetBmcStatus;
+
+    DEBUG ((DEBUG_INFO,"IPMI: Waiting for Getting BMC DID in SMM \n"));
+    //
+    // Get the Device ID and check if the system is in Force Update mode.
+    //
+    // Just obey the Spec..
+    // If we want to improve performance, we're going to comment it.
+    //
+    Status = GetDeviceId (
+               mIpmiInstance,
+               StatusCodeValue,
+               &ErrorCount
+               );
+    ASSERT_EFI_ERROR (Status);
+    Handle = NULL;
+    Status = gSmst->SmmInstallProtocolInterface (
+                      &Handle,
+                      &gSmmIpmiTransportProtocolGuid,
+                      EFI_NATIVE_INTERFACE,
+                      &mIpmiInstance->IpmiTransport
+                      );
+    ASSERT_EFI_ERROR (Status);
+
+    DEBUG ((DEBUG_INFO,"SmmInitializeIpmiKcsPhysicalLayer exit \n"));
+
+    return EFI_SUCCESS;
+  }
+}
+
+EFI_STATUS
+InitializeSmmGenericIpmi (
+  IN EFI_HANDLE             ImageHandle,
+  IN EFI_SYSTEM_TABLE       *SystemTable
+  )
+{
+  SmmInitializeIpmiKcsPhysicalLayer (ImageHandle, SystemTable);
+  return EFI_SUCCESS;
+}
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/SmmGenericIpmi.inf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/SmmGenericIpmi.inf
new file mode 100644
index 0000000000..a534f7dac8
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/SmmGenericIpmi.inf
@@ -0,0 +1,53 @@
+## @file
+# Generic IPMI SMM Driver.
+#
+# @copyright
+# Copyright 2010 - 2021 Intel Corporation. <BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION                         = 0x00010005
+  BASE_NAME                           = SmmGenericIpmi
+  FILE_GUID                           = D14443FF-3626-4bcc-8204-196D11F06BC5
+  MODULE_TYPE                         = DXE_SMM_DRIVER
+  PI_SPECIFICATION_VERSION            = 0x0001000A
+  VERSION_STRING                      = 1.0
+  ENTRY_POINT                         = InitializeSmmGenericIpmi
+
+[Sources]
+  ../Common/IpmiHooks.h
+  ../Common/IpmiHooks.c
+  ../Common/IpmiBmcCommon.h
+  ../Common/KcsBmc.c
+  ../Common/KcsBmc.h
+  ../Common/IpmiBmc.c
+  ../Common/IpmiBmc.h
+  SmmGenericIpmi.c          #GenericIpmi.c+IpmiBmcInitialize.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec
+
+[LibraryClasses]
+  MemoryAllocationLib
+  BaseLib
+  UefiBootServicesTableLib
+  SmmServicesTableLib
+  DebugLib
+  UefiDriverEntryPoint
+  IoLib
+  ReportStatusCodeLib
+  TimerLib
+
+[Protocols]
+  gSmmIpmiTransportProtocolGuid                     # PROTOCOL ALWAYS_PRODUCED
+
+[Guids]
+
+[Pcd]
+  gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiSmmIoBaseAddress
+  gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiBmcReadyDelayTimer
+
+[Depex]
+ gIpmiTransportProtocolGuid
-- 
2.27.0.windows.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [edk2-platforms] [PATCH v1 8/9] IpmiFeaturePkg: Add IPMI driver build files
  2021-03-02  2:27 [edk2-platforms] [PATCH v1 0/9] IpmiFeaturePkg: Add IPMI transport drivers Nate DeSimone
                   ` (6 preceding siblings ...)
  2021-03-02  2:28 ` [edk2-platforms] [PATCH v1 7/9] IpmiFeaturePkg: Add GenericIpmi SMM Driver Nate DeSimone
@ 2021-03-02  2:28 ` Nate DeSimone
  2021-03-02  2:28 ` [edk2-platforms] [PATCH v1 9/9] Maintainers.txt: Add IpmiFeaturePkg maintainers Nate DeSimone
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Nate DeSimone @ 2021-03-02  2:28 UTC (permalink / raw)
  To: devel; +Cc: Isaac Oram, Sai Chaganty, Liming Gao, Michael Kubacki

From: Isaac Oram <isaac.w.oram@intel.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3242

* Adds DEC/DSC build files for the generic IPMI
  transport driver.
* Updates Readme.md

Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Michael Kubacki <michael.kubacki@microsoft.com>
Signed-off-by: Isaac Oram <isaac.w.oram@intel.com>
Co-authored-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
---
 .../IpmiFeaturePkg/Include/IpmiFeature.dsc    |  9 +++++++-
 .../IpmiFeaturePkg/IpmiFeaturePkg.dec         | 22 ++++++++++++++++++-
 .../IpmiFeaturePkg/Readme.md                  |  4 ++--
 3 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/IpmiFeature.dsc b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/IpmiFeature.dsc
index a82f18a68c..226ae27bd3 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/IpmiFeature.dsc
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/IpmiFeature.dsc
@@ -6,7 +6,7 @@
 # INF files to generate AutoGen.c and AutoGen.h files
 # for the build infrastructure.
 #
-# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -99,7 +99,10 @@
 
   OutOfBandManagement/IpmiFeaturePkg/Library/IpmiPlatformHookLibNull/IpmiPlatformHookLibNull.inf
 
+  #
   # Add components here that should be included in the package build.
+  #
+  OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.inf
   OutOfBandManagement/IpmiFeaturePkg/Frb/FrbPei.inf
   OutOfBandManagement/IpmiFeaturePkg/IpmiInit/PeiIpmiInit.inf
 
@@ -119,7 +122,11 @@
 
   OutOfBandManagement/IpmiFeaturePkg/Library/IpmiPlatformHookLibNull/IpmiPlatformHookLibNull.inf
 
+  #
   # Add components here that should be included in the package build.
+  #
+  OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/GenericIpmi.inf
+  OutOfBandManagement/IpmiFeaturePkg/Library/SmmIpmiBaseLib/SmmIpmiBaseLib.inf
   OutOfBandManagement/IpmiFeaturePkg/BmcAcpi/BmcAcpi.inf
   OutOfBandManagement/IpmiFeaturePkg/BmcElog/BmcElog.inf
   OutOfBandManagement/IpmiFeaturePkg/Frb/FrbDxe.inf
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec
index 1426496d28..48f4ebf931 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec
@@ -7,7 +7,7 @@
 # INF files to generate AutoGen.c and AutoGen.h files
 # for the build infrastructure.
 #
-# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2019-2021, Intel Corporation. All rights reserved.<BR>
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -20,7 +20,14 @@
   PACKAGE_VERSION   = 0.1
 
 [Includes]
+  GenericIpmi/Common
+  GenericIpmi/Dxe
+  GenericIpmi/Pei
+  GenericIpmi/Smm
   Include
+  IpmiInit
+  Library
+  OsWdt
 
 [LibraryClasses]
   ## @libraryclass  Provides services to send IPMI commands.
@@ -34,13 +41,26 @@
 [Guids]
   gIpmiFeaturePkgTokenSpaceGuid  =  {0xc05283f6, 0xd6a8, 0x48f3, {0x9b, 0x59, 0xfb, 0xca, 0x71, 0x32, 0x0f, 0x12}}
 
+[Ppis]
+  gPeiIpmiTransportPpiGuid = {0x7bf5fecc, 0xc5b5, 0x4b25, {0x81, 0x1b, 0xb4, 0xb5, 0xb, 0x28, 0x79, 0xf7}}
+
+[Protocols]
+  gIpmiTransportProtocolGuid  = {0x6bb945e8, 0x3743, 0x433e, {0xb9, 0x0e, 0x29, 0xb3, 0x0d, 0x5d, 0xc6, 0x30}}
+  gSmmIpmiTransportProtocolGuid  = {0x8bb070f1, 0xa8f3, 0x471d, {0x86, 0x16, 0x77, 0x4b, 0xa3, 0xf4, 0x30, 0xa0}}
+  gEfiVideoPrintProtocolGuid     = {0x3dbf3e06, 0x9d0c, 0x40d3, {0xb2, 0x17, 0x45, 0x5f, 0x33, 0x9e, 0x29, 0x09}}
+
 [PcdsFeatureFlag]
   gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiFeatureEnable|FALSE|BOOLEAN|0xA0000001
 
 [PcdsFixedAtBuild]
   gIpmiFeaturePkgTokenSpaceGuid.PcdMaxSOLChannels|3|UINT8|0xF0000001
+  #When True, BIOS will send a Pre-Boot signal to BMC
+  gIpmiFeaturePkgTokenSpaceGuid.PcdSignalPreBootToBmc|FALSE|BOOLEAN|0xF0000002
 
 [PcdsDynamic, PcdsDynamicEx]
   gIpmiFeaturePkgTokenSpaceGuid.PcdFRB2EnabledFlag|TRUE|BOOLEAN|0xD0000001
   gIpmiFeaturePkgTokenSpaceGuid.PcdFRBTimeoutValue|360|UINT16|0xD0000002
   gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiIoBaseAddress|0xCA2|UINT16|0xD0000003
+  gIpmiFeaturePkgTokenSpaceGuid.PcdSioMailboxBaseAddress|0x600|UINT32|0xD0000004
+  gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiBmcReadyDelayTimer|120|UINT8|0xD0000005
+  gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiSmmIoBaseAddress|0xCA2|UINT16|0xD0000006
diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Readme.md b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Readme.md
index 1af5b0cfda..d383150e3f 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Readme.md
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Readme.md
@@ -1,7 +1,7 @@
 # Overview
 * **Feature Name:** Intelligent Platform Management Interface (IPMI)
-* **PI Phase(s) Supported:** PEI, DXE
-* **SMM Required?** No
+* **PI Phase(s) Supported:** PEI, DXE, SMM
+* **SMM Required?** Yes
 
 More Information:
 * [IPMI Specification 2nd Generation v2.0](https://www.intel.com/content/dam/www/public/us/en/documents/product-briefs/ipmi-second-gen-interface-spec-v2-rev1-1.pdf)
-- 
2.27.0.windows.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [edk2-platforms] [PATCH v1 9/9] Maintainers.txt: Add IpmiFeaturePkg maintainers
  2021-03-02  2:27 [edk2-platforms] [PATCH v1 0/9] IpmiFeaturePkg: Add IPMI transport drivers Nate DeSimone
                   ` (7 preceding siblings ...)
  2021-03-02  2:28 ` [edk2-platforms] [PATCH v1 8/9] IpmiFeaturePkg: Add IPMI driver build files Nate DeSimone
@ 2021-03-02  2:28 ` Nate DeSimone
  2021-03-03 19:22 ` [edk2-devel] [edk2-platforms] [PATCH v1 0/9] IpmiFeaturePkg: Add IPMI transport drivers Michael Kubacki
  2021-03-11 19:29 ` Chaganty, Rangasai V
  10 siblings, 0 replies; 14+ messages in thread
From: Nate DeSimone @ 2021-03-02  2:28 UTC (permalink / raw)
  To: devel; +Cc: Isaac Oram, Sai Chaganty, Liming Gao

From: Isaac Oram <isaac.w.oram@intel.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3242

Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Isaac Oram <isaac.w.oram@intel.com>
Co-authored-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
---
 Maintainers.txt | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Maintainers.txt b/Maintainers.txt
index 2e6e87bb6d..63d09749f6 100644
--- a/Maintainers.txt
+++ b/Maintainers.txt
@@ -146,6 +146,12 @@ F: Features/Intel/Debugging/
 M: Eric Dong <eric.dong@intel.com>
 R: Liming Gao <gaoliming@byosoft.com.cn>
 
+Features/Intel/OutOfBandManagement/IpmiFeaturePkg
+F: Features/Intel/OutOfBandManagement/IpmiFeaturePkg
+M: Isaac Oram <isaac.w.oram@intel.com>
+M: Nate DeSimone <nathaniel.l.desimone@intel.com>
+R: Liming Gao <gaoliming@byosoft.com.cn>
+
 Features/Intel/UserInterface
 F: Features/Intel/UserInterface/
 M: Dandan Bi <dandan.bi@intel.com>
-- 
2.27.0.windows.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [edk2-devel] [edk2-platforms] [PATCH v1 0/9] IpmiFeaturePkg: Add IPMI transport drivers
  2021-03-02  2:27 [edk2-platforms] [PATCH v1 0/9] IpmiFeaturePkg: Add IPMI transport drivers Nate DeSimone
                   ` (8 preceding siblings ...)
  2021-03-02  2:28 ` [edk2-platforms] [PATCH v1 9/9] Maintainers.txt: Add IpmiFeaturePkg maintainers Nate DeSimone
@ 2021-03-03 19:22 ` Michael Kubacki
  2021-03-04 23:33   ` Oram, Isaac W
  2021-03-11 19:29 ` Chaganty, Rangasai V
  10 siblings, 1 reply; 14+ messages in thread
From: Michael Kubacki @ 2021-03-03 19:22 UTC (permalink / raw)
  To: devel, nathaniel.l.desimone
  Cc: Isaac Oram, Sai Chaganty, Liming Gao, Michael Kubacki

Looked over the series at a high-level and the feature structure looks 
fine. For the series:
Acked-by: Michael Kubacki <michael.kubacki@microsoft.com>

I didn't look closely at implementation but there's a few things I noticed.

There's a few typos. I'd suggest running a spell check to clean those 
up. Some quick examples:

ServerManagement.h:

  "Generic Definations for Server Management Header File."

   typedef struct {
     LINERIZATION_TYPE Linearization;              // L

IpmiTransportPei.h:

   "IPMI Ttransport PPI Header File."

There was a mix of function documentation styles though that might be 
something to clean up later.

I saw some globals that did not appear necessary. For example, 
mIpmiTransport in SmmIpmiBaseLib.c seems to be located before every access.

Thanks,
Michael

On 3/1/2021 6:27 PM, Nate DeSimone wrote:
> From: Isaac Oram <isaac.w.oram@intel.com>
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3242
> 
> Implement an open source generic IPMI transport driver.
> Provides the ability to communicate with a BMC over IPMI
> in MinPlatform board packages.
> 
> New changes:
>    1. Added GenericIpmi
>    2. Added IPMI base libs
>    3. Added transport PPI and protocol
>    4. Updated IPMI command request and response data size from
>       UINT8 to UINT32 in IPMI transport layer to be compatible
>       with EDK2 industry standard IPMI commands.
>    6. Added the completion code in the first byte of all IPMI
>       response data to be compatible with EDK2 industry standard
>       IPMI commands.
> 
> Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Michael Kubacki <michael.kubacki@microsoft.com>
> Signed-off-by: Isaac Oram <isaac.w.oram@intel.com>
> Co-authored-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
> 
> Isaac Oram (9):
>    IpmiFeaturePkg: Add IPMI driver Include headers
>    IpmiFeaturePkg: Add IpmiBaseLib and IpmiCommandLib
>    IpmiFeaturePkg: Add IpmiInit drivers
>    IpmiFeaturePkg: Add GenericIpmi driver common code
>    IpmiFeaturePkg: Add GenericIpmi PEIM
>    IpmiFeaturePkg: Add GenericIpmi DXE Driver
>    IpmiFeaturePkg: Add GenericIpmi SMM Driver
>    IpmiFeaturePkg: Add IPMI driver build files
>    Maintainers.txt: Add IpmiFeaturePkg maintainers
> 
>   .../GenericIpmi/Common/IpmiBmc.c              | 297 +++++++++++
>   .../GenericIpmi/Common/IpmiBmc.h              |  44 ++
>   .../GenericIpmi/Common/IpmiBmcCommon.h        | 179 +++++++
>   .../GenericIpmi/Common/IpmiHooks.c            |  96 ++++
>   .../GenericIpmi/Common/IpmiHooks.h            |  81 +++
>   .../GenericIpmi/Common/IpmiPhysicalLayer.h    |  29 ++
>   .../GenericIpmi/Common/KcsBmc.c               | 483 ++++++++++++++++++
>   .../GenericIpmi/Common/KcsBmc.h               | 236 +++++++++
>   .../GenericIpmi/Dxe/GenericIpmi.c             |  46 ++
>   .../GenericIpmi/Dxe/GenericIpmi.inf           |  66 +++
>   .../IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c | 452 ++++++++++++++++
>   .../GenericIpmi/Pei/PeiGenericIpmi.c          | 362 +++++++++++++
>   .../GenericIpmi/Pei/PeiGenericIpmi.h          | 138 +++++
>   .../GenericIpmi/Pei/PeiGenericIpmi.inf        |  58 +++
>   .../GenericIpmi/Pei/PeiIpmiBmc.c              | 277 ++++++++++
>   .../GenericIpmi/Pei/PeiIpmiBmc.h              |  38 ++
>   .../GenericIpmi/Pei/PeiIpmiBmcDef.h           | 156 ++++++
>   .../GenericIpmi/Smm/SmmGenericIpmi.c          | 208 ++++++++
>   .../GenericIpmi/Smm/SmmGenericIpmi.inf        |  53 ++
>   .../IpmiFeaturePkg/Include/IpmiFeature.dsc    |   9 +-
>   .../Include/Library/IpmiBaseLib.h             |  50 ++
>   .../Include/Library/IpmiCommandLib.h          |  19 +-
>   .../Include/Ppi/IpmiTransportPpi.h            |  68 +++
>   .../Include/Protocol/IpmiTransportProtocol.h  |  75 +++
>   .../IpmiFeaturePkg/Include/ServerManagement.h | 337 ++++++++++++
>   .../IpmiFeaturePkg/Include/SmStatusCodes.h    |  98 ++++
>   .../IpmiFeaturePkg/IpmiFeaturePkg.dec         |  22 +-
>   .../IpmiFeaturePkg/IpmiInit/DxeIpmiInit.c     |   4 +-
>   .../IpmiFeaturePkg/IpmiInit/DxeIpmiInit.inf   |   6 +-
>   .../IpmiFeaturePkg/IpmiInit/PeiIpmiInit.c     |   4 +-
>   .../IpmiFeaturePkg/IpmiInit/PeiIpmiInit.inf   |   4 +-
>   .../Library/IpmiBaseLib/IpmiBaseLib.c         | 155 ++++++
>   .../Library/IpmiBaseLib/IpmiBaseLib.inf       |  28 +
>   .../Library/IpmiBaseLibNull/IpmiBaseLibNull.c |  76 +++
>   .../IpmiBaseLibNull/IpmiBaseLibNull.inf       |  36 ++
>   .../Library/IpmiCommandLib/IpmiCommandLib.inf |   4 +-
>   .../IpmiCommandLib/IpmiCommandLibNetFnApp.c   |   7 +-
>   .../IpmiCommandLibNetFnChassis.c              |  51 +-
>   .../IpmiCommandLibNetFnStorage.c              |   7 +-
>   .../IpmiCommandLibNetFnTransport.c            |   7 +-
>   .../Library/PeiIpmiBaseLib/PeiIpmiBaseLib.c   | 111 ++++
>   .../Library/PeiIpmiBaseLib/PeiIpmiBaseLib.inf |  30 ++
>   .../Library/SmmIpmiBaseLib/SmmIpmiBaseLib.c   | 180 +++++++
>   .../Library/SmmIpmiBaseLib/SmmIpmiBaseLib.inf |  29 ++
>   .../IpmiFeaturePkg/Readme.md                  |   4 +-
>   Maintainers.txt                               |   6 +
>   46 files changed, 4694 insertions(+), 32 deletions(-)
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiBmc.c
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiBmc.h
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiBmcCommon.h
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiHooks.c
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiHooks.h
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiPhysicalLayer.h
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/KcsBmc.c
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/KcsBmc.h
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/GenericIpmi.c
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/GenericIpmi.inf
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.h
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.inf
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiBmc.c
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiBmc.h
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiBmcDef.h
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/SmmGenericIpmi.c
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/SmmGenericIpmi.inf
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Library/IpmiBaseLib.h
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Ppi/IpmiTransportPpi.h
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Protocol/IpmiTransportProtocol.h
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/ServerManagement.h
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/SmStatusCodes.h
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLib/IpmiBaseLib.c
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLib/IpmiBaseLib.inf
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLibNull/IpmiBaseLibNull.c
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLibNull/IpmiBaseLibNull.inf
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/PeiIpmiBaseLib/PeiIpmiBaseLib.c
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/PeiIpmiBaseLib/PeiIpmiBaseLib.inf
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/SmmIpmiBaseLib/SmmIpmiBaseLib.c
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/SmmIpmiBaseLib/SmmIpmiBaseLib.inf
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [edk2-devel] [edk2-platforms] [PATCH v1 0/9] IpmiFeaturePkg: Add IPMI transport drivers
  2021-03-03 19:22 ` [edk2-devel] [edk2-platforms] [PATCH v1 0/9] IpmiFeaturePkg: Add IPMI transport drivers Michael Kubacki
@ 2021-03-04 23:33   ` Oram, Isaac W
  2021-03-05 11:06     ` Nhi Pham
  0 siblings, 1 reply; 14+ messages in thread
From: Oram, Isaac W @ 2021-03-04 23:33 UTC (permalink / raw)
  To: devel@edk2.groups.io, mikuback@linux.microsoft.com,
	Desimone, Nathaniel L
  Cc: Chaganty, Rangasai V, Liming Gao, Michael Kubacki

Michael,

Thanks for the feedback.

I was torn between aligning with the proprietary version and cleaning it up.
My concern is if we do too much cleanup, it will delay adoption.  

I did the minimum that we know is required for ECC tool to pass coding style tool and avoid EFI prefixes.  

I would like delay refactoring and cleaning up until it is in the open where people can easily follow the code evolution from proprietary to open source.  I am looking to develop some maintainers for this feature package, and the cleanup would be a good way to ramp them into active open participation and put them on the path to becoming maintainers.

Anyway, your feedback is noted and I will put those on the to do list for completing this.

Regards,
Isaac

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Michael Kubacki
Sent: Wednesday, March 3, 2021 11:23 AM
To: devel@edk2.groups.io; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>
Cc: Oram, Isaac W <isaac.w.oram@intel.com>; Chaganty, Rangasai V <rangasai.v.chaganty@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>; Michael Kubacki <michael.kubacki@microsoft.com>
Subject: Re: [edk2-devel] [edk2-platforms] [PATCH v1 0/9] IpmiFeaturePkg: Add IPMI transport drivers

Looked over the series at a high-level and the feature structure looks fine. For the series:
Acked-by: Michael Kubacki <michael.kubacki@microsoft.com>

I didn't look closely at implementation but there's a few things I noticed.

There's a few typos. I'd suggest running a spell check to clean those up. Some quick examples:

ServerManagement.h:

  "Generic Definations for Server Management Header File."

   typedef struct {
     LINERIZATION_TYPE Linearization;              // L

IpmiTransportPei.h:

   "IPMI Ttransport PPI Header File."

There was a mix of function documentation styles though that might be something to clean up later.

I saw some globals that did not appear necessary. For example, mIpmiTransport in SmmIpmiBaseLib.c seems to be located before every access.

Thanks,
Michael

On 3/1/2021 6:27 PM, Nate DeSimone wrote:
> From: Isaac Oram <isaac.w.oram@intel.com>
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3242
> 
> Implement an open source generic IPMI transport driver.
> Provides the ability to communicate with a BMC over IPMI in 
> MinPlatform board packages.
> 
> New changes:
>    1. Added GenericIpmi
>    2. Added IPMI base libs
>    3. Added transport PPI and protocol
>    4. Updated IPMI command request and response data size from
>       UINT8 to UINT32 in IPMI transport layer to be compatible
>       with EDK2 industry standard IPMI commands.
>    6. Added the completion code in the first byte of all IPMI
>       response data to be compatible with EDK2 industry standard
>       IPMI commands.
> 
> Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Michael Kubacki <michael.kubacki@microsoft.com>
> Signed-off-by: Isaac Oram <isaac.w.oram@intel.com>
> Co-authored-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
> 
> Isaac Oram (9):
>    IpmiFeaturePkg: Add IPMI driver Include headers
>    IpmiFeaturePkg: Add IpmiBaseLib and IpmiCommandLib
>    IpmiFeaturePkg: Add IpmiInit drivers
>    IpmiFeaturePkg: Add GenericIpmi driver common code
>    IpmiFeaturePkg: Add GenericIpmi PEIM
>    IpmiFeaturePkg: Add GenericIpmi DXE Driver
>    IpmiFeaturePkg: Add GenericIpmi SMM Driver
>    IpmiFeaturePkg: Add IPMI driver build files
>    Maintainers.txt: Add IpmiFeaturePkg maintainers
> 
>   .../GenericIpmi/Common/IpmiBmc.c              | 297 +++++++++++
>   .../GenericIpmi/Common/IpmiBmc.h              |  44 ++
>   .../GenericIpmi/Common/IpmiBmcCommon.h        | 179 +++++++
>   .../GenericIpmi/Common/IpmiHooks.c            |  96 ++++
>   .../GenericIpmi/Common/IpmiHooks.h            |  81 +++
>   .../GenericIpmi/Common/IpmiPhysicalLayer.h    |  29 ++
>   .../GenericIpmi/Common/KcsBmc.c               | 483 ++++++++++++++++++
>   .../GenericIpmi/Common/KcsBmc.h               | 236 +++++++++
>   .../GenericIpmi/Dxe/GenericIpmi.c             |  46 ++
>   .../GenericIpmi/Dxe/GenericIpmi.inf           |  66 +++
>   .../IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c | 452 ++++++++++++++++
>   .../GenericIpmi/Pei/PeiGenericIpmi.c          | 362 +++++++++++++
>   .../GenericIpmi/Pei/PeiGenericIpmi.h          | 138 +++++
>   .../GenericIpmi/Pei/PeiGenericIpmi.inf        |  58 +++
>   .../GenericIpmi/Pei/PeiIpmiBmc.c              | 277 ++++++++++
>   .../GenericIpmi/Pei/PeiIpmiBmc.h              |  38 ++
>   .../GenericIpmi/Pei/PeiIpmiBmcDef.h           | 156 ++++++
>   .../GenericIpmi/Smm/SmmGenericIpmi.c          | 208 ++++++++
>   .../GenericIpmi/Smm/SmmGenericIpmi.inf        |  53 ++
>   .../IpmiFeaturePkg/Include/IpmiFeature.dsc    |   9 +-
>   .../Include/Library/IpmiBaseLib.h             |  50 ++
>   .../Include/Library/IpmiCommandLib.h          |  19 +-
>   .../Include/Ppi/IpmiTransportPpi.h            |  68 +++
>   .../Include/Protocol/IpmiTransportProtocol.h  |  75 +++
>   .../IpmiFeaturePkg/Include/ServerManagement.h | 337 ++++++++++++
>   .../IpmiFeaturePkg/Include/SmStatusCodes.h    |  98 ++++
>   .../IpmiFeaturePkg/IpmiFeaturePkg.dec         |  22 +-
>   .../IpmiFeaturePkg/IpmiInit/DxeIpmiInit.c     |   4 +-
>   .../IpmiFeaturePkg/IpmiInit/DxeIpmiInit.inf   |   6 +-
>   .../IpmiFeaturePkg/IpmiInit/PeiIpmiInit.c     |   4 +-
>   .../IpmiFeaturePkg/IpmiInit/PeiIpmiInit.inf   |   4 +-
>   .../Library/IpmiBaseLib/IpmiBaseLib.c         | 155 ++++++
>   .../Library/IpmiBaseLib/IpmiBaseLib.inf       |  28 +
>   .../Library/IpmiBaseLibNull/IpmiBaseLibNull.c |  76 +++
>   .../IpmiBaseLibNull/IpmiBaseLibNull.inf       |  36 ++
>   .../Library/IpmiCommandLib/IpmiCommandLib.inf |   4 +-
>   .../IpmiCommandLib/IpmiCommandLibNetFnApp.c   |   7 +-
>   .../IpmiCommandLibNetFnChassis.c              |  51 +-
>   .../IpmiCommandLibNetFnStorage.c              |   7 +-
>   .../IpmiCommandLibNetFnTransport.c            |   7 +-
>   .../Library/PeiIpmiBaseLib/PeiIpmiBaseLib.c   | 111 ++++
>   .../Library/PeiIpmiBaseLib/PeiIpmiBaseLib.inf |  30 ++
>   .../Library/SmmIpmiBaseLib/SmmIpmiBaseLib.c   | 180 +++++++
>   .../Library/SmmIpmiBaseLib/SmmIpmiBaseLib.inf |  29 ++
>   .../IpmiFeaturePkg/Readme.md                  |   4 +-
>   Maintainers.txt                               |   6 +
>   46 files changed, 4694 insertions(+), 32 deletions(-)
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiBmc.c
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiBmc.h
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiBmcCommon.h
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiHooks.c
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiHooks.h
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiPhysicalLayer.h
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/KcsBmc.c
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/KcsBmc.h
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/GenericIpmi.c
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/GenericIpmi.inf
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.h
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.inf
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiBmc.c
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiBmc.h
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiBmcDef.h
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/SmmGenericIpmi.c
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/SmmGenericIpmi.inf
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Library/IpmiBaseLib.h
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Ppi/IpmiTransportPpi.h
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Protocol/IpmiTransportProtocol.h
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/ServerManagement.h
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/SmStatusCodes.h
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLib/IpmiBaseLib.c
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLib/IpmiBaseLib.inf
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLibNull/IpmiBaseLibNull.c
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLibNull/IpmiBaseLibNull.inf
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/PeiIpmiBaseLib/PeiIpmiBaseLib.c
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/PeiIpmiBaseLib/PeiIpmiBaseLib.inf
>   create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/SmmIpmiBaseLib/SmmIpmiBaseLib.c
>   create mode 100644 
> Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/SmmIpmiBaseL
> ib/SmmIpmiBaseLib.inf
> 






^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [edk2-devel] [edk2-platforms] [PATCH v1 0/9] IpmiFeaturePkg: Add IPMI transport drivers
  2021-03-04 23:33   ` Oram, Isaac W
@ 2021-03-05 11:06     ` Nhi Pham
  0 siblings, 0 replies; 14+ messages in thread
From: Nhi Pham @ 2021-03-05 11:06 UTC (permalink / raw)
  To: devel, isaac.w.oram, mikuback@linux.microsoft.com,
	Desimone, Nathaniel L
  Cc: Chaganty, Rangasai V, Liming Gao, Michael Kubacki, Phong Vo,
	Chuong Le Anh Tran, Vu Hoang Nguyen, Thang Nguyen

Hi Isaac,

We - Ampere Computing  are implementing IPMI over SSIF transport (per 
IPMI 2.0 spec). We also have this ready for submission, soon.
However, in light of this review, we would be interested in co-work with 
Intel so the same design can be used on non-KCS platform, instead of 
keeping each implementation proprietary.

Thanks,
Nhi

On 3/5/21 06:33, Oram, Isaac W via groups.io wrote:
> Michael,
>
> Thanks for the feedback.
>
> I was torn between aligning with the proprietary version and cleaning it up.
> My concern is if we do too much cleanup, it will delay adoption.
>
> I did the minimum that we know is required for ECC tool to pass coding style tool and avoid EFI prefixes.
>
> I would like delay refactoring and cleaning up until it is in the open where people can easily follow the code evolution from proprietary to open source.  I am looking to develop some maintainers for this feature package, and the cleanup would be a good way to ramp them into active open participation and put them on the path to becoming maintainers.
>
> Anyway, your feedback is noted and I will put those on the to do list for completing this.
>
> Regards,
> Isaac
>
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Michael Kubacki
> Sent: Wednesday, March 3, 2021 11:23 AM
> To: devel@edk2.groups.io; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>
> Cc: Oram, Isaac W <isaac.w.oram@intel.com>; Chaganty, Rangasai V <rangasai.v.chaganty@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>; Michael Kubacki <michael.kubacki@microsoft.com>
> Subject: Re: [edk2-devel] [edk2-platforms] [PATCH v1 0/9] IpmiFeaturePkg: Add IPMI transport drivers
>
> Looked over the series at a high-level and the feature structure looks fine. For the series:
> Acked-by: Michael Kubacki <michael.kubacki@microsoft.com>
>
> I didn't look closely at implementation but there's a few things I noticed.
>
> There's a few typos. I'd suggest running a spell check to clean those up. Some quick examples:
>
> ServerManagement.h:
>
>    "Generic Definations for Server Management Header File."
>
>     typedef struct {
>       LINERIZATION_TYPE Linearization;              // L
>
> IpmiTransportPei.h:
>
>     "IPMI Ttransport PPI Header File."
>
> There was a mix of function documentation styles though that might be something to clean up later.
>
> I saw some globals that did not appear necessary. For example, mIpmiTransport in SmmIpmiBaseLib.c seems to be located before every access.
>
> Thanks,
> Michael
>
> On 3/1/2021 6:27 PM, Nate DeSimone wrote:
>> From: Isaac Oram <isaac.w.oram@intel.com>
>>
>> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3242
>>
>> Implement an open source generic IPMI transport driver.
>> Provides the ability to communicate with a BMC over IPMI in
>> MinPlatform board packages.
>>
>> New changes:
>>     1. Added GenericIpmi
>>     2. Added IPMI base libs
>>     3. Added transport PPI and protocol
>>     4. Updated IPMI command request and response data size from
>>        UINT8 to UINT32 in IPMI transport layer to be compatible
>>        with EDK2 industry standard IPMI commands.
>>     6. Added the completion code in the first byte of all IPMI
>>        response data to be compatible with EDK2 industry standard
>>        IPMI commands.
>>
>> Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
>> Cc: Liming Gao <gaoliming@byosoft.com.cn>
>> Cc: Michael Kubacki <michael.kubacki@microsoft.com>
>> Signed-off-by: Isaac Oram <isaac.w.oram@intel.com>
>> Co-authored-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
>>
>> Isaac Oram (9):
>>     IpmiFeaturePkg: Add IPMI driver Include headers
>>     IpmiFeaturePkg: Add IpmiBaseLib and IpmiCommandLib
>>     IpmiFeaturePkg: Add IpmiInit drivers
>>     IpmiFeaturePkg: Add GenericIpmi driver common code
>>     IpmiFeaturePkg: Add GenericIpmi PEIM
>>     IpmiFeaturePkg: Add GenericIpmi DXE Driver
>>     IpmiFeaturePkg: Add GenericIpmi SMM Driver
>>     IpmiFeaturePkg: Add IPMI driver build files
>>     Maintainers.txt: Add IpmiFeaturePkg maintainers
>>
>>    .../GenericIpmi/Common/IpmiBmc.c              | 297 +++++++++++
>>    .../GenericIpmi/Common/IpmiBmc.h              |  44 ++
>>    .../GenericIpmi/Common/IpmiBmcCommon.h        | 179 +++++++
>>    .../GenericIpmi/Common/IpmiHooks.c            |  96 ++++
>>    .../GenericIpmi/Common/IpmiHooks.h            |  81 +++
>>    .../GenericIpmi/Common/IpmiPhysicalLayer.h    |  29 ++
>>    .../GenericIpmi/Common/KcsBmc.c               | 483 ++++++++++++++++++
>>    .../GenericIpmi/Common/KcsBmc.h               | 236 +++++++++
>>    .../GenericIpmi/Dxe/GenericIpmi.c             |  46 ++
>>    .../GenericIpmi/Dxe/GenericIpmi.inf           |  66 +++
>>    .../IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c | 452 ++++++++++++++++
>>    .../GenericIpmi/Pei/PeiGenericIpmi.c          | 362 +++++++++++++
>>    .../GenericIpmi/Pei/PeiGenericIpmi.h          | 138 +++++
>>    .../GenericIpmi/Pei/PeiGenericIpmi.inf        |  58 +++
>>    .../GenericIpmi/Pei/PeiIpmiBmc.c              | 277 ++++++++++
>>    .../GenericIpmi/Pei/PeiIpmiBmc.h              |  38 ++
>>    .../GenericIpmi/Pei/PeiIpmiBmcDef.h           | 156 ++++++
>>    .../GenericIpmi/Smm/SmmGenericIpmi.c          | 208 ++++++++
>>    .../GenericIpmi/Smm/SmmGenericIpmi.inf        |  53 ++
>>    .../IpmiFeaturePkg/Include/IpmiFeature.dsc    |   9 +-
>>    .../Include/Library/IpmiBaseLib.h             |  50 ++
>>    .../Include/Library/IpmiCommandLib.h          |  19 +-
>>    .../Include/Ppi/IpmiTransportPpi.h            |  68 +++
>>    .../Include/Protocol/IpmiTransportProtocol.h  |  75 +++
>>    .../IpmiFeaturePkg/Include/ServerManagement.h | 337 ++++++++++++
>>    .../IpmiFeaturePkg/Include/SmStatusCodes.h    |  98 ++++
>>    .../IpmiFeaturePkg/IpmiFeaturePkg.dec         |  22 +-
>>    .../IpmiFeaturePkg/IpmiInit/DxeIpmiInit.c     |   4 +-
>>    .../IpmiFeaturePkg/IpmiInit/DxeIpmiInit.inf   |   6 +-
>>    .../IpmiFeaturePkg/IpmiInit/PeiIpmiInit.c     |   4 +-
>>    .../IpmiFeaturePkg/IpmiInit/PeiIpmiInit.inf   |   4 +-
>>    .../Library/IpmiBaseLib/IpmiBaseLib.c         | 155 ++++++
>>    .../Library/IpmiBaseLib/IpmiBaseLib.inf       |  28 +
>>    .../Library/IpmiBaseLibNull/IpmiBaseLibNull.c |  76 +++
>>    .../IpmiBaseLibNull/IpmiBaseLibNull.inf       |  36 ++
>>    .../Library/IpmiCommandLib/IpmiCommandLib.inf |   4 +-
>>    .../IpmiCommandLib/IpmiCommandLibNetFnApp.c   |   7 +-
>>    .../IpmiCommandLibNetFnChassis.c              |  51 +-
>>    .../IpmiCommandLibNetFnStorage.c              |   7 +-
>>    .../IpmiCommandLibNetFnTransport.c            |   7 +-
>>    .../Library/PeiIpmiBaseLib/PeiIpmiBaseLib.c   | 111 ++++
>>    .../Library/PeiIpmiBaseLib/PeiIpmiBaseLib.inf |  30 ++
>>    .../Library/SmmIpmiBaseLib/SmmIpmiBaseLib.c   | 180 +++++++
>>    .../Library/SmmIpmiBaseLib/SmmIpmiBaseLib.inf |  29 ++
>>    .../IpmiFeaturePkg/Readme.md                  |   4 +-
>>    Maintainers.txt                               |   6 +
>>    46 files changed, 4694 insertions(+), 32 deletions(-)
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiBmc.c
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiBmc.h
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiBmcCommon.h
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiHooks.c
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiHooks.h
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiPhysicalLayer.h
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/KcsBmc.c
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/KcsBmc.h
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/GenericIpmi.c
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/GenericIpmi.inf
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.h
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.inf
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiBmc.c
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiBmc.h
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiBmcDef.h
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/SmmGenericIpmi.c
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/SmmGenericIpmi.inf
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Library/IpmiBaseLib.h
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Ppi/IpmiTransportPpi.h
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Protocol/IpmiTransportProtocol.h
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/ServerManagement.h
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/SmStatusCodes.h
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLib/IpmiBaseLib.c
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLib/IpmiBaseLib.inf
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLibNull/IpmiBaseLibNull.c
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLibNull/IpmiBaseLibNull.inf
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/PeiIpmiBaseLib/PeiIpmiBaseLib.c
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/PeiIpmiBaseLib/PeiIpmiBaseLib.inf
>>    create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/SmmIpmiBaseLib/SmmIpmiBaseLib.c
>>    create mode 100644
>> Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/SmmIpmiBaseL
>> ib/SmmIpmiBaseLib.inf
>>
>
>
>
>
>
>
> 
>
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [edk2-platforms] [PATCH v1 0/9] IpmiFeaturePkg: Add IPMI transport drivers
  2021-03-02  2:27 [edk2-platforms] [PATCH v1 0/9] IpmiFeaturePkg: Add IPMI transport drivers Nate DeSimone
                   ` (9 preceding siblings ...)
  2021-03-03 19:22 ` [edk2-devel] [edk2-platforms] [PATCH v1 0/9] IpmiFeaturePkg: Add IPMI transport drivers Michael Kubacki
@ 2021-03-11 19:29 ` Chaganty, Rangasai V
  10 siblings, 0 replies; 14+ messages in thread
From: Chaganty, Rangasai V @ 2021-03-11 19:29 UTC (permalink / raw)
  To: Desimone, Nathaniel L, devel@edk2.groups.io
  Cc: Oram, Isaac W, Liming Gao, Michael Kubacki

Overall structure looks good. For the series:
Reviewed-by: Sai Chaganty <rangasai.v.chaganty@intel.com>

There are few, rather general comments which I think can be queued up as on-going improvement after the initial check-in.
1. Copyright year for newly added files should begin with the current year // this is probably should be taken care before the first checkin
2. Ensure new GUIDs are created for newly added modules and interfaces, to avoid any potential conflicts. 
3. Null instance libraries (e.g. IpmiBaseLibNull.inf) has classes defined that are not necessarily in use (e.g DebugLib). While it may not be a functional failure, it's a good practice to declare only those classes that are being used in the implementation. 
4. ReadMe needs to be filled out completely. 
5. Function description are found to be placed after the function (e.g. UpdateErrorStatus(), IpmiSendCommandToBmc() in IpmiBmc.c). The description comment block should precede the function.
6. Found instances where return status is marked as "Status" in description. Suggest to add possible return values in the function description 
7. Found cases where we have two APIs with different names but with similar implementation - e.g. IpmiSendCommandToBmc() and PeiIpmiSendCommandToBmc(). Can these be converged?
8. Please check and address relative path issue in . inf (e.g. GenericIpmi.inf)
9. In IpmiInit.c, Please remove the following, if not applicable
	#ifdef FAST_VIDEO_SUPPORT
	  #include <Protocol/VideoPrint.h>
	#endif
10. Consider adding .fdf definition under \Include that lists the IPMI modules to be dispatched. This will simplify the integration of this feature on a platform. 
11. Need to make sure package build is working.

Regards,
Sai

-----Original Message-----
From: Desimone, Nathaniel L <nathaniel.l.desimone@intel.com> 
Sent: Monday, March 01, 2021 6:28 PM
To: devel@edk2.groups.io
Cc: Oram, Isaac W <isaac.w.oram@intel.com>; Chaganty, Rangasai V <rangasai.v.chaganty@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>; Michael Kubacki <michael.kubacki@microsoft.com>
Subject: [edk2-platforms] [PATCH v1 0/9] IpmiFeaturePkg: Add IPMI transport drivers

From: Isaac Oram <isaac.w.oram@intel.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3242

Implement an open source generic IPMI transport driver.
Provides the ability to communicate with a BMC over IPMI in MinPlatform board packages.

New changes:
  1. Added GenericIpmi
  2. Added IPMI base libs
  3. Added transport PPI and protocol
  4. Updated IPMI command request and response data size from
     UINT8 to UINT32 in IPMI transport layer to be compatible
     with EDK2 industry standard IPMI commands.
  6. Added the completion code in the first byte of all IPMI
     response data to be compatible with EDK2 industry standard
     IPMI commands.

Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Michael Kubacki <michael.kubacki@microsoft.com>
Signed-off-by: Isaac Oram <isaac.w.oram@intel.com>
Co-authored-by: Nate DeSimone <nathaniel.l.desimone@intel.com>

Isaac Oram (9):
  IpmiFeaturePkg: Add IPMI driver Include headers
  IpmiFeaturePkg: Add IpmiBaseLib and IpmiCommandLib
  IpmiFeaturePkg: Add IpmiInit drivers
  IpmiFeaturePkg: Add GenericIpmi driver common code
  IpmiFeaturePkg: Add GenericIpmi PEIM
  IpmiFeaturePkg: Add GenericIpmi DXE Driver
  IpmiFeaturePkg: Add GenericIpmi SMM Driver
  IpmiFeaturePkg: Add IPMI driver build files
  Maintainers.txt: Add IpmiFeaturePkg maintainers

 .../GenericIpmi/Common/IpmiBmc.c              | 297 +++++++++++
 .../GenericIpmi/Common/IpmiBmc.h              |  44 ++
 .../GenericIpmi/Common/IpmiBmcCommon.h        | 179 +++++++
 .../GenericIpmi/Common/IpmiHooks.c            |  96 ++++
 .../GenericIpmi/Common/IpmiHooks.h            |  81 +++
 .../GenericIpmi/Common/IpmiPhysicalLayer.h    |  29 ++
 .../GenericIpmi/Common/KcsBmc.c               | 483 ++++++++++++++++++
 .../GenericIpmi/Common/KcsBmc.h               | 236 +++++++++
 .../GenericIpmi/Dxe/GenericIpmi.c             |  46 ++
 .../GenericIpmi/Dxe/GenericIpmi.inf           |  66 +++
 .../IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c | 452 ++++++++++++++++
 .../GenericIpmi/Pei/PeiGenericIpmi.c          | 362 +++++++++++++
 .../GenericIpmi/Pei/PeiGenericIpmi.h          | 138 +++++
 .../GenericIpmi/Pei/PeiGenericIpmi.inf        |  58 +++
 .../GenericIpmi/Pei/PeiIpmiBmc.c              | 277 ++++++++++
 .../GenericIpmi/Pei/PeiIpmiBmc.h              |  38 ++
 .../GenericIpmi/Pei/PeiIpmiBmcDef.h           | 156 ++++++
 .../GenericIpmi/Smm/SmmGenericIpmi.c          | 208 ++++++++
 .../GenericIpmi/Smm/SmmGenericIpmi.inf        |  53 ++
 .../IpmiFeaturePkg/Include/IpmiFeature.dsc    |   9 +-
 .../Include/Library/IpmiBaseLib.h             |  50 ++
 .../Include/Library/IpmiCommandLib.h          |  19 +-
 .../Include/Ppi/IpmiTransportPpi.h            |  68 +++
 .../Include/Protocol/IpmiTransportProtocol.h  |  75 +++  .../IpmiFeaturePkg/Include/ServerManagement.h | 337 ++++++++++++
 .../IpmiFeaturePkg/Include/SmStatusCodes.h    |  98 ++++
 .../IpmiFeaturePkg/IpmiFeaturePkg.dec         |  22 +-
 .../IpmiFeaturePkg/IpmiInit/DxeIpmiInit.c     |   4 +-
 .../IpmiFeaturePkg/IpmiInit/DxeIpmiInit.inf   |   6 +-
 .../IpmiFeaturePkg/IpmiInit/PeiIpmiInit.c     |   4 +-
 .../IpmiFeaturePkg/IpmiInit/PeiIpmiInit.inf   |   4 +-
 .../Library/IpmiBaseLib/IpmiBaseLib.c         | 155 ++++++
 .../Library/IpmiBaseLib/IpmiBaseLib.inf       |  28 +
 .../Library/IpmiBaseLibNull/IpmiBaseLibNull.c |  76 +++
 .../IpmiBaseLibNull/IpmiBaseLibNull.inf       |  36 ++
 .../Library/IpmiCommandLib/IpmiCommandLib.inf |   4 +-
 .../IpmiCommandLib/IpmiCommandLibNetFnApp.c   |   7 +-
 .../IpmiCommandLibNetFnChassis.c              |  51 +-
 .../IpmiCommandLibNetFnStorage.c              |   7 +-
 .../IpmiCommandLibNetFnTransport.c            |   7 +-
 .../Library/PeiIpmiBaseLib/PeiIpmiBaseLib.c   | 111 ++++
 .../Library/PeiIpmiBaseLib/PeiIpmiBaseLib.inf |  30 ++
 .../Library/SmmIpmiBaseLib/SmmIpmiBaseLib.c   | 180 +++++++
 .../Library/SmmIpmiBaseLib/SmmIpmiBaseLib.inf |  29 ++
 .../IpmiFeaturePkg/Readme.md                  |   4 +-
 Maintainers.txt                               |   6 +
 46 files changed, 4694 insertions(+), 32 deletions(-)  create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiBmc.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiBmc.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiBmcCommon.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiHooks.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiHooks.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/IpmiPhysicalLayer.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/KcsBmc.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/KcsBmc.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/GenericIpmi.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/GenericIpmi.inf
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.inf
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiBmc.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiBmc.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiIpmiBmcDef.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/SmmGenericIpmi.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/SmmGenericIpmi.inf
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Library/IpmiBaseLib.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Ppi/IpmiTransportPpi.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Protocol/IpmiTransportProtocol.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/ServerManagement.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/SmStatusCodes.h
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLib/IpmiBaseLib.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLib/IpmiBaseLib.inf
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLibNull/IpmiBaseLibNull.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLibNull/IpmiBaseLibNull.inf
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/PeiIpmiBaseLib/PeiIpmiBaseLib.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/PeiIpmiBaseLib/PeiIpmiBaseLib.inf
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/SmmIpmiBaseLib/SmmIpmiBaseLib.c
 create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/SmmIpmiBaseLib/SmmIpmiBaseLib.inf

--
2.27.0.windows.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-03-11 19:29 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-02  2:27 [edk2-platforms] [PATCH v1 0/9] IpmiFeaturePkg: Add IPMI transport drivers Nate DeSimone
2021-03-02  2:27 ` [edk2-platforms] [PATCH v1 1/9] IpmiFeaturePkg: Add IPMI driver Include headers Nate DeSimone
2021-03-02  2:27 ` [edk2-platforms] [PATCH v1 2/9] IpmiFeaturePkg: Add IpmiBaseLib and IpmiCommandLib Nate DeSimone
2021-03-02  2:27 ` [edk2-platforms] [PATCH v1 3/9] IpmiFeaturePkg: Add IpmiInit driver DEPEXs Nate DeSimone
2021-03-02  2:27 ` [edk2-platforms] [PATCH v1 4/9] IpmiFeaturePkg: Add GenericIpmi driver common code Nate DeSimone
2021-03-02  2:28 ` [edk2-platforms] [PATCH v1 5/9] IpmiFeaturePkg: Add GenericIpmi PEIM Nate DeSimone
2021-03-02  2:28 ` [edk2-platforms] [PATCH v1 6/9] IpmiFeaturePkg: Add GenericIpmi DXE Driver Nate DeSimone
2021-03-02  2:28 ` [edk2-platforms] [PATCH v1 7/9] IpmiFeaturePkg: Add GenericIpmi SMM Driver Nate DeSimone
2021-03-02  2:28 ` [edk2-platforms] [PATCH v1 8/9] IpmiFeaturePkg: Add IPMI driver build files Nate DeSimone
2021-03-02  2:28 ` [edk2-platforms] [PATCH v1 9/9] Maintainers.txt: Add IpmiFeaturePkg maintainers Nate DeSimone
2021-03-03 19:22 ` [edk2-devel] [edk2-platforms] [PATCH v1 0/9] IpmiFeaturePkg: Add IPMI transport drivers Michael Kubacki
2021-03-04 23:33   ` Oram, Isaac W
2021-03-05 11:06     ` Nhi Pham
2021-03-11 19:29 ` Chaganty, Rangasai V

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox