[edk2-devel] [PATCH v1 1/1] BoardModulePkg\Library\BiosIdLib: Support Standalone MM

2023-12-25 Thread Huang, Li-Xia
Add Standalone Mm BiosIdLib and format code with Uncrustify.

Cc: Eric Dong 
Cc: Nate DeSimone 

Signed-off-by: Lixia Huang 
---
 Platform/Intel/BoardModulePkg/Library/BiosIdLib/BiosIdCommon.c|  
96 
 Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.c| 
111 +++---
 Platform/Intel/BoardModulePkg/Library/BiosIdLib/PeiBiosIdLib.c| 
118 +++-
 Platform/Intel/BoardModulePkg/Library/BiosIdLib/StandaloneMmBiosIdLib.c   |  
65 +++
 Platform/Intel/BoardModulePkg/BoardModulePkg.dsc  |   
1 +
 Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.inf  |   
1 +
 Platform/Intel/BoardModulePkg/Library/BiosIdLib/PeiBiosIdLib.inf  |   
6 +-
 Platform/Intel/BoardModulePkg/Library/BiosIdLib/StandaloneMmBiosIdLib.inf |  
42 +++
 8 files changed, 241 insertions(+), 199 deletions(-)

diff --git a/Platform/Intel/BoardModulePkg/Library/BiosIdLib/BiosIdCommon.c 
b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/BiosIdCommon.c
new file mode 100644
index ..5735566bfe3a
--- /dev/null
+++ b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/BiosIdCommon.c
@@ -0,0 +1,96 @@
+/** @file
+  Boot service common BIOS ID library implementation.
+
+  These functions in this file can be called during DXE and cannot be called 
during runtime
+  or in SMM which should use a RT or SMM library.
+
+
+Copyright (c) 2023, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+
+/**
+  This function returns the BIOS Version & Release Date and Time by getting 
and converting BIOS ID.
+
+  @param[out] BiosVersion   The Bios Version out of the conversion.
+  @param[out] BiosReleaseDate   The Bios Release Date out of the conversion.
+  @param[out] BiosReleaseTime   The Bios Release Time out of the conversion.
+
+  @retval EFI_SUCCESS   BIOS Version & Release Date and Time have 
been got successfully.
+  @retval EFI_NOT_FOUND BIOS ID image is not found, and no 
parameter will be modified.
+  @retval EFI_INVALID_PARAMETER All the parameters are NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+GetBiosVersionDateTime (
+  OUT CHAR16  *BiosVersion OPTIONAL,
+  OUT CHAR16  *BiosReleaseDate OPTIONAL,
+  OUT CHAR16  *BiosReleaseTime OPTIONAL
+  )
+{
+  EFI_STATUS Status;
+  BIOS_ID_IMAGE  BiosIdImage;
+
+  if ((BiosVersion == NULL) && (BiosReleaseDate == NULL) && (BiosReleaseTime 
== NULL)) {
+return EFI_INVALID_PARAMETER;
+  }
+
+  Status = GetBiosId ();
+  if (EFI_ERROR (Status)) {
+return EFI_NOT_FOUND;
+  }
+
+  if (BiosVersion != NULL) {
+//
+// Fill the BiosVersion data from the BIOS ID.
+//
+CopyMem (BiosVersion, &(BiosIdImage.BiosIdString), sizeof 
(BIOS_ID_STRING));
+  }
+
+  if (BiosReleaseDate != NULL) {
+//
+// Fill the build timestamp date from the BIOS ID in the "MM/DD/YY" format.
+//
+BiosReleaseDate[0] = BiosIdImage.BiosIdString.TimeStamp[2];
+BiosReleaseDate[1] = BiosIdImage.BiosIdString.TimeStamp[3];
+BiosReleaseDate[2] = (CHAR16)((UINT8)('/'));
+
+BiosReleaseDate[3] = BiosIdImage.BiosIdString.TimeStamp[4];
+BiosReleaseDate[4] = BiosIdImage.BiosIdString.TimeStamp[5];
+BiosReleaseDate[5] = (CHAR16)((UINT8)('/'));
+
+//
+// Add 20 for SMBIOS table
+// Current Linux kernel will misjudge 09 as year 0, so using 2009 for 
SMBIOS table
+//
+BiosReleaseDate[6] = '2';
+BiosReleaseDate[7] = '0';
+BiosReleaseDate[8] = BiosIdImage.BiosIdString.TimeStamp[0];
+BiosReleaseDate[9] = BiosIdImage.BiosIdString.TimeStamp[1];
+
+BiosReleaseDate[10] = (CHAR16)((UINT8)('\0'));
+  }
+
+  if (BiosReleaseTime != NULL) {
+//
+// Fill the build timestamp time from the BIOS ID in the "HH:MM" format.
+//
+BiosReleaseTime[0] = BiosIdImage.BiosIdString.TimeStamp[6];
+BiosReleaseTime[1] = BiosIdImage.BiosIdString.TimeStamp[7];
+BiosReleaseTime[2] = (CHAR16)((UINT8)(':'));
+
+BiosReleaseTime[3] = BiosIdImage.BiosIdString.TimeStamp[8];
+BiosReleaseTime[4] = BiosIdImage.BiosIdString.TimeStamp[9];
+
+BiosReleaseTime[5] = (CHAR16)((UINT8)('\0'));
+  }
+
+  return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.c 
b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.c
index 3e614d9efc3e..6535bb36f6c9 100644
--- a/Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.c
+++ b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.c
@@ -5,7 +5,7 @@
   or in SMM which should use a RT or SMM library.
 
 
-Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2023, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -15,7 +15,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ 

[edk2-devel] [PATCH v1 2/2] IpmiFeaturePkg/GenericIpmi: Fix GCC compiler error

2023-12-18 Thread Huang, Li-Xia
Fix GCC compiler error in StandaloneMmGenericIpmi.

Cc: Abner Chang 
Cc: Nate DeSimone 

Signed-off-by: Lixia Huang 
---
 
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
 | 2 --
 1 file changed, 2 deletions(-)

diff --git 
a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
 
b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
index 1b9841e4b745..edc9eec9395a 100644
--- 
a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
+++ 
b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
@@ -185,12 +185,10 @@ Returns:
 **/
 {
   EFI_STATUSStatus;
-  UINT8 ErrorCount;
   IPMI_INTERFACE_STATE  InterfaceState;
   UINT8 Index;
 
   DEBUG ((DEBUG_INFO, "SmmInitializeIpmiKcsPhysicalLayer entry \n"));
-  ErrorCount = 0;
   InterfaceState = IpmiInterfaceNotReady;
 
   Status = gMmst->MmAllocatePool (
-- 
2.26.2.windows.1



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




[edk2-devel] [PATCH v1 1/1] IpmiFeaturePkg/GenericIpmi: Sync change from SMM

2023-12-05 Thread Huang, Li-Xia
Sync change from SMM to StandaloneMm GenericIpmi driver.
Update SmmIpmbInterface and SmmSsifInterface Lib to support
MM_STANDALONE. And Format code with uncrustify.

Cc: Abner Chang 
Cc: Nate DeSimone 

Signed-off-by: Lixia Huang 
---
 
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
| 315 +---
 
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/IpmbInterfaceLib/SmmIpmbInterfaceLib.c
   |   4 +-
 
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/SsifInterfaceLib/SmmSsifInterfaceLib.c
   |  64 ++--
 
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.inf
  |  10 +
 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/IpmiFeature.dsc  
 |   2 +-
 
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/IpmbInterfaceLib/SmmIpmbInterfaceLib.inf
 |   4 +-
 
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/SsifInterfaceLib/SmmSsifInterfaceLib.inf
 |   4 +-
 7 files changed, 326 insertions(+), 77 deletions(-)

diff --git 
a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
 
b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
index d808e2517c99..1b9841e4b745 100644
--- 
a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
+++ 
b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
@@ -19,17 +19,157 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include "IpmiHooks.h"
 #include "IpmiBmcCommon.h"
 #include "IpmiBmc.h"
 
-IPMI_BMC_INSTANCE_DATA *mIpmiInstance;
-EFI_HANDLE mHandle;
+IPMI_BMC_INSTANCE_DATA  *mIpmiInstance;
+EFI_HANDLE  mIpmiTransportHandle;
+EFI_HANDLE  mIpmiTransport2Handle;
 
 /**
+
+Routine Description:
+  Initialize the API and parameters for IPMI Transport2 Instance
+
+Arguments:
+  IpmiInstance- Pointer to IPMI Instance.
+
+Returns:
+  VOID- Nothing.
+
+**/
+VOID
+InitIpmiTransport2 (
+  IN  IPMI_BMC_INSTANCE_DATA  *IpmiInstance
+  )
+{
+  IpmiInstance->IpmiTransport2.InterfaceType   = FixedPcdGet8 
(PcdDefaultSystemInterface);
+  IpmiInstance->IpmiTransport2.IpmiTransport2BmcStatus = BmcStatusOk;
+  IpmiInstance->IpmiTransport2.IpmiSubmitCommand2  = IpmiSendCommand2;
+  IpmiInstance->IpmiTransport2.IpmiSubmitCommand2Ex= IpmiSendCommand2Ex;
+
+  if (FixedPcdGet8 (PcdBtInterfaceSupport) == 1) {
+InitBtInterfaceData (>IpmiTransport2);
+  }
+
+  if (FixedPcdGet8 (PcdSsifInterfaceSupport) == 1) {
+InitSsifInterfaceData (>IpmiTransport2);
+  }
+
+  if (FixedPcdGet8 (PcdIpmbInterfaceSupport) == 1) {
+InitIpmbInterfaceData (>IpmiTransport2);
+  }
+}
+
+/**
+
+Routine Description:
+  Notify call back to initialize the interfaces and install SMM IPMI
+  protocol.
+
+Arguments:
+  Protocol- Pointer to the protocol guid.
+  Interface   - Pointer to the protocol instance.
+  Handle  - Handle on which the protocol is installed.
+
+Returns:
+  Status of Notify call back.
+
+**/
+EFI_STATUS
+EFIAPI
+SmmNotifyCallback (
+  IN CONST  EFI_GUID*Protocol,
+  INVOID*Interface,
+  INEFI_HANDLE  Handle
+  )
+{
+  EFI_STATUSStatus;
+  IPMI_INTERFACE_STATE  InterfaceState;
+
+  InterfaceState = IpmiInterfaceNotReady;
+
+  if (FixedPcdGet8 (PcdSsifInterfaceSupport) == 1) {
+InitSsifInterfaceData (>IpmiTransport2);
+
+if (mIpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState == 
IpmiInterfaceInitialized) {
+  InterfaceState = IpmiInterfaceInitialized;
+}
+  }
+
+  if (FixedPcdGet8 (PcdIpmbInterfaceSupport) == 1) {
+InitIpmbInterfaceData (>IpmiTransport2);
+  }
+
+  if (mIpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState == 
IpmiInterfaceInitialized) {
+InterfaceState = IpmiInterfaceInitialized;
+  }
+
+  if (InterfaceState != IpmiInterfaceInitialized) {
+return EFI_SUCCESS;
+  }
+
+  // Default Interface data should be initialized to install Ipmi Transport2 
Protocol.
+  if (InterfaceState == IpmiInterfaceInitialized) {
+mIpmiTransport2Handle = NULL;
+Status= gMmst->MmInstallProtocolInterface (
+ ,
+ ,
+ EFI_NATIVE_INTERFACE,
+ >IpmiTransport2
+ );
+  }
+
+  ASSERT_EFI_ERROR (Status);
+  return EFI_SUCCESS;
+}
+
+/**
+
+Routine Description:
+  Registers Protocol call back.
+
+Arguments:
+  ProtocolGuid- Pointer to Protocol GUID to register call back.
+
+Returns:
+  Status.
+
+**/

[edk2-devel] [PATCH v1 1/1] BoardModulePkg\Library\BiosIdLib: Support Standalone MM

2023-11-20 Thread Huang, Li-Xia
Add Standalone Mm BiosIdLib.
Also fix some EDKII Coding Style issue with uncrustify.

Cc: Eric Dong 
Cc: Nate DeSimone 

Signed-off-by: Lixia Huang 
---
 Platform/Intel/BoardModulePkg/Library/BiosIdLib/BiosIdCommon.c|  
96 
 Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.c| 
111 +++---
 Platform/Intel/BoardModulePkg/Library/BiosIdLib/PeiBiosIdLib.c| 
118 +++-
 Platform/Intel/BoardModulePkg/Library/BiosIdLib/StandaloneMmBiosIdLib.c   |  
65 +++
 Platform/Intel/BoardModulePkg/BoardModulePkg.dsc  |   
1 +
 Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.inf  |   
6 +-
 Platform/Intel/BoardModulePkg/Library/BiosIdLib/PeiBiosIdLib.inf  |   
6 +-
 Platform/Intel/BoardModulePkg/Library/BiosIdLib/StandaloneMmBiosIdLib.inf |  
42 +++
 8 files changed, 244 insertions(+), 201 deletions(-)

diff --git a/Platform/Intel/BoardModulePkg/Library/BiosIdLib/BiosIdCommon.c 
b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/BiosIdCommon.c
new file mode 100644
index ..5735566bfe3a
--- /dev/null
+++ b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/BiosIdCommon.c
@@ -0,0 +1,96 @@
+/** @file
+  Boot service common BIOS ID library implementation.
+
+  These functions in this file can be called during DXE and cannot be called 
during runtime
+  or in SMM which should use a RT or SMM library.
+
+
+Copyright (c) 2023, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+
+/**
+  This function returns the BIOS Version & Release Date and Time by getting 
and converting BIOS ID.
+
+  @param[out] BiosVersion   The Bios Version out of the conversion.
+  @param[out] BiosReleaseDate   The Bios Release Date out of the conversion.
+  @param[out] BiosReleaseTime   The Bios Release Time out of the conversion.
+
+  @retval EFI_SUCCESS   BIOS Version & Release Date and Time have 
been got successfully.
+  @retval EFI_NOT_FOUND BIOS ID image is not found, and no 
parameter will be modified.
+  @retval EFI_INVALID_PARAMETER All the parameters are NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+GetBiosVersionDateTime (
+  OUT CHAR16  *BiosVersion OPTIONAL,
+  OUT CHAR16  *BiosReleaseDate OPTIONAL,
+  OUT CHAR16  *BiosReleaseTime OPTIONAL
+  )
+{
+  EFI_STATUS Status;
+  BIOS_ID_IMAGE  BiosIdImage;
+
+  if ((BiosVersion == NULL) && (BiosReleaseDate == NULL) && (BiosReleaseTime 
== NULL)) {
+return EFI_INVALID_PARAMETER;
+  }
+
+  Status = GetBiosId ();
+  if (EFI_ERROR (Status)) {
+return EFI_NOT_FOUND;
+  }
+
+  if (BiosVersion != NULL) {
+//
+// Fill the BiosVersion data from the BIOS ID.
+//
+CopyMem (BiosVersion, &(BiosIdImage.BiosIdString), sizeof 
(BIOS_ID_STRING));
+  }
+
+  if (BiosReleaseDate != NULL) {
+//
+// Fill the build timestamp date from the BIOS ID in the "MM/DD/YY" format.
+//
+BiosReleaseDate[0] = BiosIdImage.BiosIdString.TimeStamp[2];
+BiosReleaseDate[1] = BiosIdImage.BiosIdString.TimeStamp[3];
+BiosReleaseDate[2] = (CHAR16)((UINT8)('/'));
+
+BiosReleaseDate[3] = BiosIdImage.BiosIdString.TimeStamp[4];
+BiosReleaseDate[4] = BiosIdImage.BiosIdString.TimeStamp[5];
+BiosReleaseDate[5] = (CHAR16)((UINT8)('/'));
+
+//
+// Add 20 for SMBIOS table
+// Current Linux kernel will misjudge 09 as year 0, so using 2009 for 
SMBIOS table
+//
+BiosReleaseDate[6] = '2';
+BiosReleaseDate[7] = '0';
+BiosReleaseDate[8] = BiosIdImage.BiosIdString.TimeStamp[0];
+BiosReleaseDate[9] = BiosIdImage.BiosIdString.TimeStamp[1];
+
+BiosReleaseDate[10] = (CHAR16)((UINT8)('\0'));
+  }
+
+  if (BiosReleaseTime != NULL) {
+//
+// Fill the build timestamp time from the BIOS ID in the "HH:MM" format.
+//
+BiosReleaseTime[0] = BiosIdImage.BiosIdString.TimeStamp[6];
+BiosReleaseTime[1] = BiosIdImage.BiosIdString.TimeStamp[7];
+BiosReleaseTime[2] = (CHAR16)((UINT8)(':'));
+
+BiosReleaseTime[3] = BiosIdImage.BiosIdString.TimeStamp[8];
+BiosReleaseTime[4] = BiosIdImage.BiosIdString.TimeStamp[9];
+
+BiosReleaseTime[5] = (CHAR16)((UINT8)('\0'));
+  }
+
+  return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.c 
b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.c
index 3e614d9efc3e..6535bb36f6c9 100644
--- a/Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.c
+++ b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.c
@@ -5,7 +5,7 @@
   or in SMM which should use a RT or SMM library.
 
 
-Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2023, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -15,7 +15,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
-#include 
 #include 
 

[edk2-devel] [PATCH v4 1/1] IpmiFeaturePkg/GenericIpmi: Support Standalone MM

2023-10-31 Thread Huang, Li-Xia
Add Standalone Mm Generic Impi driver. And add type 'PcdsFixedAtBuild'
for PcdIpmiSmmIoBaseAddress to access in StandaloneMm driver

Cc: Abner Chang 
Cc: Nate DeSimone 
Signed-off-by: Lixia Huang 
---
 
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
   | 146 
 
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.inf
 |  51 +++
 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec   
|   2 +
 3 files changed, 199 insertions(+)

diff --git 
a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
 
b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
new file mode 100644
index ..d808e2517c99
--- /dev/null
+++ 
b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
@@ -0,0 +1,146 @@
+/** @file
+  Generic StandaloneMm IPMI stack driver
+
+  Copyright 2023 Intel Corporation. 
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+//
+// Statements that include other files
+//
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "IpmiHooks.h"
+#include "IpmiBmcCommon.h"
+#include "IpmiBmc.h"
+
+IPMI_BMC_INSTANCE_DATA *mIpmiInstance;
+EFI_HANDLE mHandle;
+
+/**
+Routine Description:
+  Setup and initialize the BMC for the SMM 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
+SmmInitializeIpmiKcsPhysicalLayer (
+  VOID
+  )
+{
+  EFI_STATUS   Status;
+
+  DEBUG ((DEBUG_INFO,"SmmInitializeIpmiKcsPhysicalLayer entry \n"));
+
+  Status = gMmst->MmAllocatePool (
+EfiRuntimeServicesData,
+sizeof (IPMI_BMC_INSTANCE_DATA),
+(VOID **));
+
+  if (EFI_ERROR (Status)) {
+DEBUG ((DEBUG_ERROR, "mIpmiInstance mem alloc failed - 0x%x\n", Status));
+return Status;
+  } 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   = FixedPcdGet16 
(PcdIpmiSmmIoBaseAddress);
+mIpmiInstance->Signature= SM_IPMI_BMC_SIGNATURE;
+mIpmiInstance->SlaveAddress = BMC_SLAVE_ADDRESS;
+mIpmiInstance->BmcStatus= BMC_NOTREADY;
+mIpmiInstance->IpmiTransport.IpmiSubmitCommand  = IpmiSendCommand;
+mIpmiInstance->IpmiTransport.GetBmcStatus   = IpmiGetBmcStatus;
+
+mHandle = NULL;
+Status = gMmst->MmInstallProtocolInterface (
+  ,
+  ,
+  EFI_NATIVE_INTERFACE,
+  >IpmiTransport
+  );
+ASSERT_EFI_ERROR (Status);
+
+DEBUG ((DEBUG_INFO,"SmmInitializeIpmiKcsPhysicalLayer exit \n"));
+
+return EFI_SUCCESS;
+  }
+}
+
+/**
+  The module Entry Point of driver.
+
+  @param[in]  ImageHandleThe firmware allocated handle for the EFI image.
+  @param[in]  SystemTableA pointer to the MM System Table.
+
+  @retval EFI_SUCCESSThe entry point is executed successfully.
+  @retval Other  Some error occurs when executing this entry point.
+
+**/
+EFI_STATUS
+InitializeGenericIpmiStandaloneMm (
+  IN EFI_HANDLE ImageHandle,
+  IN EFI_MM_SYSTEM_TABLE*SystemTable
+  )
+{
+  SmmInitializeIpmiKcsPhysicalLayer ();
+  return EFI_SUCCESS;
+}
+
+/**
+  Unloads an image.
+
+  @param[in] ImageHandleHandle that identifies the image to be 
unloaded.
+
+  @retval EFI_SUCCESS   The image has been unloaded.
+  @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle.
+
+**/
+EFI_STATUS
+EFIAPI
+GenericIpmiStandaloneMmUnload (
+  IN EFI_HANDLE ImageHandle
+  )
+{
+  EFI_STATUSStatus;
+
+  Status = EFI_SUCCESS;
+  if (mIpmiInstance != NULL) {
+if (mHandle != NULL) {
+  Status = gMmst->MmUninstallProtocolInterface (
+mHandle,
+,
+>IpmiTransport

[edk2-devel] [PATCH v3 1/1] IpmiFeaturePkg/GenericIpmi: Support Standalone MM

2023-10-31 Thread Huang, Li-Xia
Add Standalone Mm Generic Impi driver. And add type 'PcdsFixedAtBuild'
for PcdIpmiSmmIoBaseAddress to access in StandaloneMm driver

Cc: Abner Chang 
Cc: Nate DeSimone 
Signed-off-by: Lixia Huang 
---
 
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
   | 148 
 
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.inf
 |  51 +++
 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec   
|   2 +
 3 files changed, 201 insertions(+)

diff --git 
a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
 
b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
new file mode 100644
index ..8c07845917be
--- /dev/null
+++ 
b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
@@ -0,0 +1,148 @@
+/** @file
+  Generic StandaloneMm IPMI stack driver
+
+  Copyright 2023 Intel Corporation. 
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+//
+// Statements that include other files
+//
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "IpmiHooks.h"
+#include "IpmiBmcCommon.h"
+#include "IpmiBmc.h"
+
+IPMI_BMC_INSTANCE_DATA *mIpmiInstance;
+EFI_HANDLE mHandle;
+
+/*++
+
+Routine Description:
+  Setup and initialize the BMC for the SMM 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
+SmmInitializeIpmiKcsPhysicalLayer (
+  VOID
+  )
+
+{
+  EFI_STATUS   Status;
+
+  DEBUG ((DEBUG_INFO,"SmmInitializeIpmiKcsPhysicalLayer entry \n"));
+
+  Status = gMmst->MmAllocatePool (
+EfiRuntimeServicesData,
+sizeof (IPMI_BMC_INSTANCE_DATA),
+(VOID **));
+
+  if (EFI_ERROR (Status)) {
+DEBUG ((DEBUG_ERROR, "mIpmiInstance mem alloc failed - 0x%x\n", Status));
+return Status;
+  } 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   = FixedPcdGet16 
(PcdIpmiSmmIoBaseAddress);
+mIpmiInstance->Signature= SM_IPMI_BMC_SIGNATURE;
+mIpmiInstance->SlaveAddress = BMC_SLAVE_ADDRESS;
+mIpmiInstance->BmcStatus= BMC_NOTREADY;
+mIpmiInstance->IpmiTransport.IpmiSubmitCommand  = IpmiSendCommand;
+mIpmiInstance->IpmiTransport.GetBmcStatus   = IpmiGetBmcStatus;
+
+mHandle = NULL;
+Status = gMmst->MmInstallProtocolInterface (
+  ,
+  ,
+  EFI_NATIVE_INTERFACE,
+  >IpmiTransport
+  );
+ASSERT_EFI_ERROR (Status);
+
+DEBUG ((DEBUG_INFO,"SmmInitializeIpmiKcsPhysicalLayer exit \n"));
+
+return EFI_SUCCESS;
+  }
+}
+
+/**
+  The module Entry Point of driver.
+
+  @param[in]  ImageHandleThe firmware allocated handle for the EFI image.
+  @param[in]  SystemTableA pointer to the MM System Table.
+
+  @retval EFI_SUCCESSThe entry point is executed successfully.
+  @retval Other  Some error occurs when executing this entry point.
+
+**/
+EFI_STATUS
+InitializeGenericIpmiStandaloneMm (
+  IN EFI_HANDLE ImageHandle,
+  IN EFI_MM_SYSTEM_TABLE*SystemTable
+  )
+{
+  SmmInitializeIpmiKcsPhysicalLayer ();
+  return EFI_SUCCESS;
+}
+
+/**
+  Unloads an image.
+
+  @param[in] ImageHandleHandle that identifies the image to be 
unloaded.
+
+  @retval EFI_SUCCESS   The image has been unloaded.
+  @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle.
+
+**/
+EFI_STATUS
+EFIAPI
+GenericIpmiStandaloneMmUnload (
+  IN EFI_HANDLE ImageHandle
+  )
+{
+  EFI_STATUSStatus;
+
+  Status = EFI_SUCCESS;
+  if (mIpmiInstance != NULL) {
+if (mHandle != NULL) {
+  Status = gMmst->MmUninstallProtocolInterface (
+mHandle,
+,
+

[edk2-devel] [PATCH v2 1/1] IpmiFeaturePkg/GenericIpmi: Support Standalone MM

2023-10-29 Thread Huang, Li-Xia
Add Standalone Mm Generic Impi driver. And add type 'PcdsFixedAtBuild'
for PcdIpmiSmmIoBaseAddress to access in StandaloneMm driver

Cc: Abner Chang 
Cc: Nate DeSimone 
Signed-off-by: Lixia Huang 
---
 
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
   | 148 
 
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.inf
 |  52 +++
 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec   
|   2 +
 3 files changed, 202 insertions(+)

diff --git 
a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
 
b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
new file mode 100644
index ..a8751f5b1a1d
--- /dev/null
+++ 
b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
@@ -0,0 +1,148 @@
+/** @file
+  Generic StandaloneMm IPMI stack driver
+
+  @copyright
+  Copyright 2023 Intel Corporation. 
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+//
+// Statements that include other files
+//
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "IpmiHooks.h"
+#include "IpmiBmcCommon.h"
+#include "IpmiBmc.h"
+#include 
+
+IPMI_BMC_INSTANCE_DATA *mIpmiInstance;
+EFI_HANDLE mHandle;
+
+EFI_STATUS
+SmmInitializeIpmiKcsPhysicalLayer (
+  VOID
+  )
+/*++
+
+Routine Description:
+  Setup and initialize the BMC for the SMM 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;
+
+  DEBUG ((DEBUG_INFO,"SmmInitializeIpmiKcsPhysicalLayer entry \n"));
+
+  Status = gMmst->MmAllocatePool (
+EfiRuntimeServicesData,
+sizeof (IPMI_BMC_INSTANCE_DATA),
+(VOID **));
+
+  if (EFI_ERROR (Status)) {
+DEBUG ((DEBUG_ERROR, "mIpmiInstance mem alloc failed - 0x%x\n", Status));
+return Status;
+  } 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   = FixedPcdGet16 
(PcdIpmiSmmIoBaseAddress);
+mIpmiInstance->Signature= SM_IPMI_BMC_SIGNATURE;
+mIpmiInstance->SlaveAddress = BMC_SLAVE_ADDRESS;
+mIpmiInstance->BmcStatus= BMC_NOTREADY;
+mIpmiInstance->IpmiTransport.IpmiSubmitCommand  = IpmiSendCommand;
+mIpmiInstance->IpmiTransport.GetBmcStatus   = IpmiGetBmcStatus;
+
+mHandle = NULL;
+Status = gMmst->MmInstallProtocolInterface (
+  ,
+  ,
+  EFI_NATIVE_INTERFACE,
+  >IpmiTransport
+  );
+ASSERT_EFI_ERROR (Status);
+
+DEBUG ((DEBUG_INFO,"SmmInitializeIpmiKcsPhysicalLayer exit \n"));
+
+return EFI_SUCCESS;
+  }
+}
+
+/**
+  The module Entry Point of driver.
+
+  @param  ImageHandleThe firmware allocated handle for the EFI image.
+  @param  SystemTableA pointer to the MM System Table.
+
+  @retval EFI_SUCCESSThe entry point is executed successfully.
+  @retval Other  Some error occurs when executing this entry point.
+
+**/
+EFI_STATUS
+InitializeGenericIpmiStandaloneMm (
+  IN EFI_HANDLE ImageHandle,
+  IN EFI_MM_SYSTEM_TABLE*SystemTable
+  )
+{
+  SmmInitializeIpmiKcsPhysicalLayer ();
+  return EFI_SUCCESS;
+}
+
+/**
+  Unloads an image.
+
+  @param[in] ImageHandleHandle that identifies the image to be 
unloaded.
+
+  @retval EFI_SUCCESS   The image has been unloaded.
+  @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle.
+
+**/
+EFI_STATUS
+EFIAPI
+GenericIpmiStandaloneMmUnload (
+  IN EFI_HANDLE ImageHandle
+  )
+{
+  EFI_STATUSStatus;
+
+  Status = EFI_SUCCESS;
+  if (mIpmiInstance != NULL) {
+if (mHandle != NULL) {
+  Status = gMmst->MmUninstallProtocolInterface (
+mHandle,
+,
+

Re: [edk2-devel] [PATCH v1 1/1] IpmiFeaturePkg/GenericIpmi: Support Standalone MM

2023-10-25 Thread Huang, Li-Xia
Hi Abner,

FAST_VIDEO_SUPPORT exists in GenericIPMI Dxe driver, my patch focuses on 
StandaloneMm support, and will not touch other drivers.
BTW, the patch format is also updated and pass all check.
Could you help to review again? Thanks.

Regards,
Lisa

-Original Message-
From: Chang, Abner  
Sent: Tuesday, October 24, 2023 6:43 PM
To: Huang, Li-Xia ; devel@edk2.groups.io
Cc: Isaac Oram ; Desimone, Nathaniel L 
; Wu, Yidong ; Xu, Wei6 

Subject: RE: [edk2-devel] [PATCH v1 1/1] IpmiFeaturePkg/GenericIpmi: Support 
Standalone MM

[AMD Official Use Only - General]

BTW Lisa,
As Issac told me the implementation which Intel upstream to IpmiFeaturePkg was 
from a pretty old intel code base. Also, something like FAST_VIDEO_SUPPORT, 
BmcSlaveAddress and GetBmcStatus seems not used. I think those code should be 
removed as well.

Abner

> -Original Message-
> From: Huang, Li-Xia 
> Sent: Monday, October 23, 2023 1:48 PM
> To: Chang, Abner ; devel@edk2.groups.io
> Cc: Isaac Oram ; Desimone, Nathaniel L 
> ; Wu, Yidong ; 
> Xu,
> Wei6 
> Subject: RE: [edk2-devel] [PATCH v1 1/1] IpmiFeaturePkg/GenericIpmi:
> Support Standalone MM
>
> [AMD Official Use Only - General]
>
> Caution: This message originated from an External Source. Use proper 
> caution when opening attachments, clicking links, or responding.
>
>
> Hi Abner,
>
> Thanks for your feedback.
> Since the IPMI implementation in these two packages are diverging now, 
> and my patch has some dependency with common code in IpmiFeaturePkg , 
> it will be better to resend this patch after the diverging is done.
>
> Our target schedule is  '23 WW51', could you let me know what's the 
> schedule for these two packages'(IpmiFeaturePkg and ManageabilityPkg) 
> diverging?
> Thanks.
>
> Regards,
> Lisa
>
> -Original Message-
> From: Chang, Abner 
> Sent: Saturday, October 21, 2023 10:15 PM
> To: devel@edk2.groups.io; Huang, Li-Xia 
> Cc: Isaac Oram ; Desimone, Nathaniel L 
> 
> Subject: RE: [edk2-devel] [PATCH v1 1/1] IpmiFeaturePkg/GenericIpmi:
> Support Standalone MM
>
> [AMD Official Use Only - General]
>
> Hi Lisa,
> Issac was no longer the maintainer of IpmiFeaturePkg as he was 
> retired. Nate had sent the maintainers update for review.
> As the conversation I had with Issac, we all agreed IpmiFeaturePkg 
> should be deprecated as the IPMI related drivers are now located under 
> ManageabilityPkg in edk2-platforms. The IPMI implementation in these 
> two packages are diverging now, which is not good.
> Could you please send this patch against ManageabilityPkg? I can help 
> to review it, so does Nate as he also proposed himself as the 
> maintainers of ManageabilityPkg.
>
> Thanks
> Abner
>
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of 
> > Huang, Li-Xia via groups.io
> > Sent: Friday, October 20, 2023 2:46 PM
> > To: devel@edk2.groups.io
> > Cc: Isaac Oram ; Nate DeSimone 
> > 
> > Subject: [edk2-devel] [PATCH v1 1/1] IpmiFeaturePkg/GenericIpmi:
> > Support Standalone MM
> >
> > Caution: This message originated from an External Source. Use proper 
> > caution when opening attachments, clicking links, or responding.
> >
> >
> > Add Standalone Mm Generic Impi driver. And add type 'PcdsFixedAtBuild'
> > for PcdIpmiSmmIoBaseAddress to access in StandaloneMm driver
> >
> > Cc: Isaac Oram 
> > Cc: Nate DeSimone 
> > Signed-off-by: Lixia Huang 
> > ---
> >
> >
> Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Standa
> > loneMm/StandaloneMmGenericIpmi.c   | 148 
> >
> >
> Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Standa
> > loneMm/StandaloneMmGenericIpmi.inf |  52 +++
> >
> >
> Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec
> > |   2 +
> >  3 files changed, 202 insertions(+)
> >
> > diff --git
> >
> a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Stan
> > daloneMm/StandaloneMmGenericIpmi.c
> >
> b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Stan
> > daloneMm/StandaloneMmGenericIpmi.c
> > new file mode 100644
> > index ..52d8d2abdd0d
> > --- /dev/null
> > +++
> >
> b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Stan
> > daloneMm/StandaloneMmGenericIpmi.c
> > @@ -0,0 +1,148 @@
> > +/** @file
> >
> > +  Generic StandaloneMm IPMI stack driver
> >
> > +
> >
> > +  @copyright
> >
> > +  Copyright 2023 Intel Corporation. 
> >
> > +  SPDX-License-Identifier: BSD-2-Claus

[edk2-devel] [PATCH v2 1/1] IpmiFeaturePkg/GenericIpmi: Support Standalone MM

2023-10-25 Thread Huang, Li-Xia
Add Standalone Mm Generic Impi driver. And add type 'PcdsFixedAtBuild'
for PcdIpmiSmmIoBaseAddress to access in StandaloneMm driver

Cc: Abner Chang 
Cc: Nate DeSimone 
Signed-off-by: Lixia Huang 
---
 
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
   | 148 
 
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.inf
 |  52 +++
 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec   
|   2 +
 3 files changed, 202 insertions(+)

diff --git 
a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
 
b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
new file mode 100644
index ..a8751f5b1a1d
--- /dev/null
+++ 
b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
@@ -0,0 +1,148 @@
+/** @file
+  Generic StandaloneMm IPMI stack driver
+
+  @copyright
+  Copyright 2023 Intel Corporation. 
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+//
+// Statements that include other files
+//
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "IpmiHooks.h"
+#include "IpmiBmcCommon.h"
+#include "IpmiBmc.h"
+#include 
+
+IPMI_BMC_INSTANCE_DATA *mIpmiInstance;
+EFI_HANDLE mHandle;
+
+EFI_STATUS
+SmmInitializeIpmiKcsPhysicalLayer (
+  VOID
+  )
+/*++
+
+Routine Description:
+  Setup and initialize the BMC for the SMM 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;
+
+  DEBUG ((DEBUG_INFO,"SmmInitializeIpmiKcsPhysicalLayer entry \n"));
+
+  Status = gMmst->MmAllocatePool (
+EfiRuntimeServicesData,
+sizeof (IPMI_BMC_INSTANCE_DATA),
+(VOID **));
+
+  if (EFI_ERROR (Status)) {
+DEBUG ((DEBUG_ERROR, "mIpmiInstance mem alloc failed - 0x%x\n", Status));
+return Status;
+  } 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   = FixedPcdGet16 
(PcdIpmiSmmIoBaseAddress);
+mIpmiInstance->Signature= SM_IPMI_BMC_SIGNATURE;
+mIpmiInstance->SlaveAddress = BMC_SLAVE_ADDRESS;
+mIpmiInstance->BmcStatus= BMC_NOTREADY;
+mIpmiInstance->IpmiTransport.IpmiSubmitCommand  = IpmiSendCommand;
+mIpmiInstance->IpmiTransport.GetBmcStatus   = IpmiGetBmcStatus;
+
+mHandle = NULL;
+Status = gMmst->MmInstallProtocolInterface (
+  ,
+  ,
+  EFI_NATIVE_INTERFACE,
+  >IpmiTransport
+  );
+ASSERT_EFI_ERROR (Status);
+
+DEBUG ((DEBUG_INFO,"SmmInitializeIpmiKcsPhysicalLayer exit \n"));
+
+return EFI_SUCCESS;
+  }
+}
+
+/**
+  The module Entry Point of driver.
+
+  @param  ImageHandleThe firmware allocated handle for the EFI image.
+  @param  SystemTableA pointer to the MM System Table.
+
+  @retval EFI_SUCCESSThe entry point is executed successfully.
+  @retval Other  Some error occurs when executing this entry point.
+
+**/
+EFI_STATUS
+InitializeGenericIpmiStandaloneMm (
+  IN EFI_HANDLE ImageHandle,
+  IN EFI_MM_SYSTEM_TABLE*SystemTable
+  )
+{
+  SmmInitializeIpmiKcsPhysicalLayer ();
+  return EFI_SUCCESS;
+}
+
+/**
+  Unloads an image.
+
+  @param[in] ImageHandleHandle that identifies the image to be 
unloaded.
+
+  @retval EFI_SUCCESS   The image has been unloaded.
+  @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle.
+
+**/
+EFI_STATUS
+EFIAPI
+GenericIpmiStandaloneMmUnload (
+  IN EFI_HANDLE ImageHandle
+  )
+{
+  EFI_STATUSStatus;
+
+  Status = EFI_SUCCESS;
+  if (mIpmiInstance != NULL) {
+if (mHandle != NULL) {
+  Status = gMmst->MmUninstallProtocolInterface (
+mHandle,
+,
+

Re: [edk2-devel] [PATCH v1 1/1] IpmiFeaturePkg/GenericIpmi: Support Standalone MM

2023-10-22 Thread Huang, Li-Xia
Hi Abner,

Thanks for your feedback.
Since the IPMI implementation in these two packages are diverging now, and my 
patch has some dependency with common code in IpmiFeaturePkg , it will be 
better to resend this patch after the diverging is done.

Our target schedule is  '23 WW51', could you let me know what's the schedule 
for these two packages'(IpmiFeaturePkg and ManageabilityPkg) diverging? Thanks.

Regards,
Lisa

-Original Message-
From: Chang, Abner  
Sent: Saturday, October 21, 2023 10:15 PM
To: devel@edk2.groups.io; Huang, Li-Xia 
Cc: Isaac Oram ; Desimone, Nathaniel L 

Subject: RE: [edk2-devel] [PATCH v1 1/1] IpmiFeaturePkg/GenericIpmi: Support 
Standalone MM

[AMD Official Use Only - General]

Hi Lisa,
Issac was no longer the maintainer of IpmiFeaturePkg as he was retired. Nate 
had sent the maintainers update for review.
As the conversation I had with Issac, we all agreed IpmiFeaturePkg should be 
deprecated as the IPMI related drivers are now located under ManageabilityPkg 
in edk2-platforms. The IPMI implementation in these two packages are diverging 
now, which is not good.
Could you please send this patch against ManageabilityPkg? I can help to review 
it, so does Nate as he also proposed himself as the maintainers of 
ManageabilityPkg.

Thanks
Abner

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Huang, 
> Li-Xia via groups.io
> Sent: Friday, October 20, 2023 2:46 PM
> To: devel@edk2.groups.io
> Cc: Isaac Oram ; Nate DeSimone 
> 
> Subject: [edk2-devel] [PATCH v1 1/1] IpmiFeaturePkg/GenericIpmi: 
> Support Standalone MM
>
> Caution: This message originated from an External Source. Use proper 
> caution when opening attachments, clicking links, or responding.
>
>
> Add Standalone Mm Generic Impi driver. And add type 'PcdsFixedAtBuild'
> for PcdIpmiSmmIoBaseAddress to access in StandaloneMm driver
>
> Cc: Isaac Oram 
> Cc: Nate DeSimone 
> Signed-off-by: Lixia Huang 
> ---
>
> Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Standa
> loneMm/StandaloneMmGenericIpmi.c   | 148 
>
> Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Standa
> loneMm/StandaloneMmGenericIpmi.inf |  52 +++
>
> Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec
> |   2 +
>  3 files changed, 202 insertions(+)
>
> diff --git
> a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Stan
> daloneMm/StandaloneMmGenericIpmi.c
> b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Stan
> daloneMm/StandaloneMmGenericIpmi.c
> new file mode 100644
> index ..52d8d2abdd0d
> --- /dev/null
> +++
> b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Stan
> daloneMm/StandaloneMmGenericIpmi.c
> @@ -0,0 +1,148 @@
> +/** @file
>
> +  Generic StandaloneMm IPMI stack driver
>
> +
>
> +  @copyright
>
> +  Copyright 2023 Intel Corporation. 
>
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
>
> +**/
>
> +
>
> +//
>
> +// Statements that include other files
>
> +//
>
> +#include 
>
> +#include 
>
> +#include 
>
> +#include 
>
> +#include 
>
> +#include 
>
> +#include 
>
> +#include 
>
> +#include 
>
> +#include 
>
> +#include 
>
> +#include "IpmiHooks.h"
>
> +#include "IpmiBmcCommon.h"
>
> +#include "IpmiBmc.h"
>
> +#include 
>
> +
>
> +IPMI_BMC_INSTANCE_DATA *mIpmiInstance;
>
> +EFI_HANDLE mHandle;
>
> +
>
> +EFI_STATUS
>
> +SmmInitializeIpmiKcsPhysicalLayer (
>
> +  VOID
>
> +  )
>
> +/*++
>
> +
>
> +Routine Description:
>
> +  Setup and initialize the BMC for the SMM 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;
>
> +
>
> +  DEBUG ((DEBUG_INFO,"SmmInitializeIpmiKcsPhysicalLayer entry \n"));
>
> +
>
> +  Status = gMmst->MmAllocatePool (
>
> +EfiRuntimeServicesData,
>
> + 

[edk2-devel] [PATCH v1 1/1] IpmiFeaturePkg/GenericIpmi: Support Standalone MM

2023-10-20 Thread Huang, Li-Xia
Add Standalone Mm Generic Impi driver. And add type 'PcdsFixedAtBuild'
for PcdIpmiSmmIoBaseAddress to access in StandaloneMm driver

Cc: Isaac Oram 
Cc: Nate DeSimone 
Signed-off-by: Lixia Huang 
---
 
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
   | 148 
 
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.inf
 |  52 +++
 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec   
|   2 +
 3 files changed, 202 insertions(+)

diff --git 
a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
 
b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
new file mode 100644
index ..52d8d2abdd0d
--- /dev/null
+++ 
b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
@@ -0,0 +1,148 @@
+/** @file
+  Generic StandaloneMm IPMI stack driver
+
+  @copyright
+  Copyright 2023 Intel Corporation. 
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+//
+// Statements that include other files
+//
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "IpmiHooks.h"
+#include "IpmiBmcCommon.h"
+#include "IpmiBmc.h"
+#include 
+
+IPMI_BMC_INSTANCE_DATA *mIpmiInstance;
+EFI_HANDLE mHandle;
+
+EFI_STATUS
+SmmInitializeIpmiKcsPhysicalLayer (
+  VOID
+  )
+/*++
+
+Routine Description:
+  Setup and initialize the BMC for the SMM 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;
+
+  DEBUG ((DEBUG_INFO,"SmmInitializeIpmiKcsPhysicalLayer entry \n"));
+
+  Status = gMmst->MmAllocatePool (
+EfiRuntimeServicesData,
+sizeof (IPMI_BMC_INSTANCE_DATA),
+(VOID **));
+
+  if (EFI_ERROR (Status)) {
+DEBUG ((DEBUG_ERROR, "mIpmiInstance mem alloc failed - 0x%x\n", Status));
+return Status;
+  } 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   = FixedPcdGet16 
(PcdIpmiSmmIoBaseAddress);
+mIpmiInstance->Signature= SM_IPMI_BMC_SIGNATURE;
+mIpmiInstance->SlaveAddress = BMC_SLAVE_ADDRESS;
+mIpmiInstance->BmcStatus= BMC_NOTREADY;
+mIpmiInstance->IpmiTransport.IpmiSubmitCommand  = IpmiSendCommand;
+mIpmiInstance->IpmiTransport.GetBmcStatus   = IpmiGetBmcStatus;
+
+mHandle = NULL;
+Status = gMmst->MmInstallProtocolInterface (
+  ,
+  ,
+  EFI_NATIVE_INTERFACE,
+  >IpmiTransport
+  );
+ASSERT_EFI_ERROR (Status);
+
+DEBUG ((DEBUG_INFO,"SmmInitializeIpmiKcsPhysicalLayer exit \n"));
+
+return EFI_SUCCESS;
+  }
+}
+
+/**
+  The module Entry Point of driver.
+
+  @param  ImageHandleThe firmware allocated handle for the EFI image.
+  @param  SystemTableA pointer to the MM System Table.
+
+  @retval EFI_SUCCESSThe entry point is executed successfully.
+  @retval Other  Some error occurs when executing this entry point.
+
+**/
+EFI_STATUS
+InitializeGenericIpmiStandaloneMm (
+  IN EFI_HANDLE ImageHandle,
+  IN EFI_MM_SYSTEM_TABLE*SystemTable
+  )
+{
+  SmmInitializeIpmiKcsPhysicalLayer ();
+  return EFI_SUCCESS;
+}
+
+/**
+  Unloads an image.
+
+  @param[in] ImageHandleHandle that identifies the image to be 
unloaded.
+
+  @retval EFI_SUCCESS   The image has been unloaded.
+  @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle.
+
+**/
+EFI_STATUS
+EFIAPI
+GenericIpmiStandaloneMmUnload (
+  IN EFI_HANDLE ImageHandle
+  )
+{
+  EFI_STATUSStatus;
+
+  Status = EFI_SUCCESS;
+  if (mIpmiInstance != NULL) {
+if (mHandle != NULL) {
+  Status = gMmst->MmUninstallProtocolInterface (
+mHandle,
+,
+

[edk2-devel] [PATCH v2] BaseTools/GenFw: Enhance GenFw to support PRM GCC build

2022-03-13 Thread Huang, Li-Xia
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3802

Since PRM module needs to support export table in PE-COFF, we'll
enhance GenFw tool to support this.

Add one export flag in GenFw tool. If export flag is set:
Step1: Scan ELF symbol table based on PRM module descriptor to get
descriptor offset address;
Step2: Find PRM handlers number and name in COFF file based on the
address from step1;
Step3: Write PRM info such as handler name and export RVA into COFF
export table.

PRM option currently only supports DXE RUNTIME driver and X64 arch.

Cc: Liming Gao 
Cc: Bob Feng 
Cc: Yuwei Chen 
Signed-off-by: Lixia Huang 
---
 BaseTools/Source/C/GenFw/Elf64Convert.c   | 242 +-
 BaseTools/Source/C/GenFw/ElfConvert.c |   8 +
 BaseTools/Source/C/GenFw/ElfConvert.h |  43 +++-
 BaseTools/Source/C/GenFw/GenFw.c  |  20 +-
 .../C/Include/IndustryStandard/PeImage.h  |   7 +
 5 files changed, 315 insertions(+), 5 deletions(-)

diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c 
b/BaseTools/Source/C/GenFw/Elf64Convert.c
index 0bb3ead228..2aa9bfcc94 100644
--- a/BaseTools/Source/C/GenFw/Elf64Convert.c
+++ b/BaseTools/Source/C/GenFw/Elf64Convert.c
@@ -56,6 +56,12 @@ WriteDebug64 (
   VOID
   );
 
+STATIC
+VOID
+WriteExport64 (
+  VOID
+  );
+
 STATIC
 VOID
 SetImageSize64 (
@@ -106,7 +112,7 @@ STATIC UINT32 mCoffAlignment = 0x20;
 //
 // PE section alignment.
 //
-STATIC const UINT16 mCoffNbrSections = 4;
+STATIC UINT16 mCoffNbrSections = 4;
 
 //
 // ELF sections to offset in Coff file.
@@ -122,7 +128,7 @@ STATIC UINT32 mDataOffset;
 STATIC UINT32 mHiiRsrcOffset;
 STATIC UINT32 mRelocOffset;
 STATIC UINT32 mDebugOffset;
-
+STATIC UINT32 mExportOffset;
 //
 // Used for RISC-V relocations.
 //
@@ -132,6 +138,14 @@ STATIC Elf64_Half  mRiscVPass1SymSecIndex = 0;
 STATIC INT32   mRiscVPass1Offset;
 STATIC INT32   mRiscVPass1GotFixup;
 
+//
+// Used for Export section.
+//
+STATIC UINT32  mExportSize;
+STATIC UINT32  mExportRVA[PRM_MODULE_EXPORT_SYMBOL_NUM];
+STATIC UINT32  mExportSymNum;
+STATIC CHAR8   
mExportSymName[PRM_MODULE_EXPORT_SYMBOL_NUM][PRM_HANDLER_NAME_MAXIMUM_LENGTH];
+
 //
 // Initialization Function
 //
@@ -171,6 +185,13 @@ InitializeElf64 (
 return FALSE;
   }
 
+  if (mExportFlag) {
+if (mEhdr->e_machine != EM_X86_64) {
+  Error (NULL, 0, 3000, "Unsupported", "--prm option currently only 
supports X64 arch.");
+  return FALSE;
+}
+  }
+
   //
   // Update section header pointers
   //
@@ -200,6 +221,11 @@ InitializeElf64 (
   ElfFunctions->SetImageSize = SetImageSize64;
   ElfFunctions->CleanUp = CleanUp64;
 
+  if (mExportFlag) {
+mCoffNbrSections ++;
+ElfFunctions->WriteExport = WriteExport64;
+  }
+
   return TRUE;
 }
 
@@ -263,6 +289,17 @@ IsHiiRsrcShdr (
   return (BOOLEAN) (strcmp((CHAR8*)mEhdr + Namedr->sh_offset + Shdr->sh_name, 
ELF_HII_SECTION_NAME) == 0);
 }
 
+STATIC
+BOOLEAN
+IsSymbolShdr (
+  Elf_Shdr *Shdr
+  )
+{
+  Elf_Shdr *Namehdr = GetShdrByIndex(mEhdr->e_shstrndx);
+
+  return (BOOLEAN) (strcmp((CHAR8*)mEhdr + Namehdr->sh_offset + Shdr->sh_name, 
ELF_SYMBOL_SECTION_NAME) == 0);
+}
+
 STATIC
 BOOLEAN
 IsDataShdr (
@@ -335,6 +372,37 @@ GetSymName (
   return StrtabContents + Sym->st_name;
 }
 
+//
+// Get Prm Handler number and name
+//
+STATIC
+VOID
+FindPrmHandler (
+  UINT64 Offset
+  )
+{
+  PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_HEADER *PrmExport;
+  PRM_HANDLER_EXPORT_DESCRIPTOR_STRUCT   *PrmHandler;
+  UINT32   HandlerNum;
+
+  PrmExport = (PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_HEADER*)((UINT8*)mEhdr + 
Offset);
+  PrmHandler = (PRM_HANDLER_EXPORT_DESCRIPTOR_STRUCT *)(PrmExport + 1);
+
+  for (HandlerNum = 0; HandlerNum < PrmExport->NumberPrmHandlers; 
HandlerNum++) {
+strcpy(mExportSymName[mExportSymNum], PrmHandler->PrmHandlerName);
+mExportSymNum ++;
+PrmHandler += 1;
+
+//
+// Check if PRM handler number is larger than 
(PRM_MODULE_EXPORT_SYMBOL_NUM - 1)
+//
+if (mExportSymNum >= (PRM_MODULE_EXPORT_SYMBOL_NUM - 1)) {
+  Error (NULL, 0, 3000, "Invalid", "FindPrmHandler: Number %u is too 
high.", mExportSymNum);
+  exit(EXIT_FAILURE);
+}
+  }
+}
+
 //
 // Find the ELF section hosting the GOT from an ELF Rva
 //   of a single GOT entry.  Normally, GOT is placed in
@@ -717,6 +785,7 @@ ScanSections64 (
   UINT32  CoffEntry;
   UINT32  SectionCount;
   BOOLEAN FoundSection;
+  UINT32  Offset;
 
   CoffEntry = 0;
   mCoffOffset = 0;
@@ -880,6 +949,82 @@ ScanSections64 (
 Warning (NULL, 0, 0, NULL, "Multiple sections in %s are merged into 1 data 
section. Source level debug might not work correctly.", mInImageName);
   }
 
+  //
+  //  The Symbol sections.
+  //
+  if (mExportFlag) {
+UINT32  SymIndex;
+Elf_Sym *Sym;
+UINT64  SymNum;
+const UINT8 *SymName;
+
+mExportOffset = mCoffOffset;
+mExportSize = 

Re: [edk2-devel] [PATCH v2] BaseTools/GenFw: Enhance GenFw to support PRM GCC build

2022-03-13 Thread Huang, Li-Xia
Hi Liming,

BZ link is added.
PRM option currently only supports DXE RUNTIME driver and X64 arch,   GenFw 
will report error message if PRM option is specified for other arch or other 
module type.
Thanks.

Regards,
Lisa

-Original Message-
From: devel@edk2.groups.io  On Behalf Of gaoliming
Sent: 2022年3月1日 9:52
To: devel@edk2.groups.io; Huang, Li-Xia 
Cc: Feng, Bob C ; Chen, Christine 
Subject: 回复: [edk2-devel] [PATCH v2] BaseTools/GenFw: Enhance GenFw to support 
PRM GCC build

Lisa:
  Please add BZ link for this patch. 

  And, if PRM option currently only supports DXE RUNTIME driver and X64 arch,
  does GenFw report error message if PRM option is specified for other arch or 
other module type?

Thanks
Liming
> -邮件原件-
> 发件人: devel@edk2.groups.io  代表 Huang, Li-Xia
> 发送时间: 2022年2月28日 9:14
> 收件人: devel@edk2.groups.io
> 抄送: Lixia Huang ; Liming Gao 
> ; Bob Feng ; Yuwei 
> Chen 
> 主题: [edk2-devel] [PATCH v2] BaseTools/GenFw: Enhance GenFw to support 
> PRM GCC build
> 
> Since PRM module needs to support export table in PE-COFF, we'll 
> enhance GenFw tool to support this.
> 
> Add one export flag in GenFw tool. If export flag is set:
> Step1: Scan ELF symbol table based on PRM module descriptor to get 
> descriptor offset address;
> Step2: Find PRM handlers number and name in COFF file based on the 
> address from step1;
> Step3: Write PRM info such as handler name and export RVA into COFF 
> export table.
> 
> PRM option currently only supports DXE RUNTIME driver and X64 arch.
> 
> Change-Id: I479b7c8b23beea12b5c567677688aef6f7af2085
> Cc: Liming Gao 
> Cc: Bob Feng 
> Cc: Yuwei Chen 
> Signed-off-by: Lixia Huang 
> ---
>  BaseTools/Source/C/GenFw/Elf64Convert.c   | 242
> +-
>  BaseTools/Source/C/GenFw/ElfConvert.c |   8 +
>  BaseTools/Source/C/GenFw/ElfConvert.h |  43 +++-
>  BaseTools/Source/C/GenFw/GenFw.c  |  20 +-
>  .../C/Include/IndustryStandard/PeImage.h  |   7 +
>  5 files changed, 315 insertions(+), 5 deletions(-)
> 
> diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c
> b/BaseTools/Source/C/GenFw/Elf64Convert.c
> index 0bb3ead228..2aa9bfcc94 100644
> --- a/BaseTools/Source/C/GenFw/Elf64Convert.c
> +++ b/BaseTools/Source/C/GenFw/Elf64Convert.c
> @@ -56,6 +56,12 @@ WriteDebug64 (
>VOID
> 
>);
> 
> 
> 
> +STATIC
> 
> +VOID
> 
> +WriteExport64 (
> 
> +  VOID
> 
> +  );
> 
> +
> 
>  STATIC
> 
>  VOID
> 
>  SetImageSize64 (
> 
> @@ -106,7 +112,7 @@ STATIC UINT32 mCoffAlignment = 0x20;  //
> 
>  // PE section alignment.
> 
>  //
> 
> -STATIC const UINT16 mCoffNbrSections = 4;
> 
> +STATIC UINT16 mCoffNbrSections = 4;
> 
> 
> 
>  //
> 
>  // ELF sections to offset in Coff file.
> 
> @@ -122,7 +128,7 @@ STATIC UINT32 mDataOffset;  STATIC UINT32 
> mHiiRsrcOffset;
> 
>  STATIC UINT32 mRelocOffset;
> 
>  STATIC UINT32 mDebugOffset;
> 
> -
> 
> +STATIC UINT32 mExportOffset;
> 
>  //
> 
>  // Used for RISC-V relocations.
> 
>  //
> 
> @@ -132,6 +138,14 @@ STATIC Elf64_Half  mRiscVPass1SymSecIndex = 0;
>  STATIC INT32   mRiscVPass1Offset;
> 
>  STATIC INT32   mRiscVPass1GotFixup;
> 
> 
> 
> +//
> 
> +// Used for Export section.
> 
> +//
> 
> +STATIC UINT32  mExportSize;
> 
> +STATIC UINT32
> mExportRVA[PRM_MODULE_EXPORT_SYMBOL_NUM];
> 
> +STATIC UINT32  mExportSymNum;
> 
> +STATIC CHAR8
> mExportSymName[PRM_MODULE_EXPORT_SYMBOL_NUM][PRM_HANDLE
> R_NAME_MAXIMUM_LENGTH];
> 
> +
> 
>  //
> 
>  // Initialization Function
> 
>  //
> 
> @@ -171,6 +185,13 @@ InitializeElf64 (
>  return FALSE;
> 
>}
> 
> 
> 
> +  if (mExportFlag) {
> 
> +if (mEhdr->e_machine != EM_X86_64) {
> 
> +  Error (NULL, 0, 3000, "Unsupported", "--prm option currently 
> + only
> supports X64 arch.");
> 
> +  return FALSE;
> 
> +}
> 
> +  }
> 
> +
> 
>//
> 
>// Update section header pointers
> 
>//
> 
> @@ -200,6 +221,11 @@ InitializeElf64 (
>ElfFunctions->SetImageSize = SetImageSize64;
> 
>ElfFunctions->CleanUp = CleanUp64;
> 
> 
> 
> +  if (mExportFlag) {
> 
> +mCoffNbrSections ++;
> 
> +ElfFunctions->WriteExport = WriteExport64;
> 
> +  }
> 
> +
> 
>return TRUE;
> 
>  }
> 
> 
> 
> @@ -263,6 +289,17 @@ IsHiiRsrcShdr (
>return (BOOLEAN) (strcmp((CHAR8*)mEhdr + Namedr->sh_offset +
> Shdr->sh_name, ELF_HII_SECTION_NAME) == 0);
> 
>  }
> 
> 
> 
> +STATIC
> 
> +

[edk2-devel] [PATCH] REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3802

2022-03-06 Thread Huang, Li-Xia
Since PRM module needs to support export table in PE-COFF, we'll
enhance GenFw tool to support this.

Add one export flag in GenFw tool. If export flag is set:
Step1: Scan ELF symbol table based on PRM module descriptor to get
descriptor offset address;
Step2: Find PRM handlers number and name in COFF file based on the
address from step1;
Step3: Write PRM info such as handler name and export RVA into COFF
export table.

PRM option currently only supports DXE RUNTIME driver and X64 arch.

Change-Id: I479b7c8b23beea12b5c567677688aef6f7af2085
Cc: Liming Gao 
Cc: Bob Feng 
Cc: Yuwei Chen 
Signed-off-by: Lixia Huang 
---
 BaseTools/Source/C/GenFw/Elf64Convert.c   | 242 +-
 BaseTools/Source/C/GenFw/ElfConvert.c |   8 +
 BaseTools/Source/C/GenFw/ElfConvert.h |  43 +++-
 BaseTools/Source/C/GenFw/GenFw.c  |  20 +-
 .../C/Include/IndustryStandard/PeImage.h  |   7 +
 5 files changed, 315 insertions(+), 5 deletions(-)

diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c 
b/BaseTools/Source/C/GenFw/Elf64Convert.c
index 0bb3ead228..2aa9bfcc94 100644
--- a/BaseTools/Source/C/GenFw/Elf64Convert.c
+++ b/BaseTools/Source/C/GenFw/Elf64Convert.c
@@ -56,6 +56,12 @@ WriteDebug64 (
   VOID
   );
 
+STATIC
+VOID
+WriteExport64 (
+  VOID
+  );
+
 STATIC
 VOID
 SetImageSize64 (
@@ -106,7 +112,7 @@ STATIC UINT32 mCoffAlignment = 0x20;
 //
 // PE section alignment.
 //
-STATIC const UINT16 mCoffNbrSections = 4;
+STATIC UINT16 mCoffNbrSections = 4;
 
 //
 // ELF sections to offset in Coff file.
@@ -122,7 +128,7 @@ STATIC UINT32 mDataOffset;
 STATIC UINT32 mHiiRsrcOffset;
 STATIC UINT32 mRelocOffset;
 STATIC UINT32 mDebugOffset;
-
+STATIC UINT32 mExportOffset;
 //
 // Used for RISC-V relocations.
 //
@@ -132,6 +138,14 @@ STATIC Elf64_Half  mRiscVPass1SymSecIndex = 0;
 STATIC INT32   mRiscVPass1Offset;
 STATIC INT32   mRiscVPass1GotFixup;
 
+//
+// Used for Export section.
+//
+STATIC UINT32  mExportSize;
+STATIC UINT32  mExportRVA[PRM_MODULE_EXPORT_SYMBOL_NUM];
+STATIC UINT32  mExportSymNum;
+STATIC CHAR8   
mExportSymName[PRM_MODULE_EXPORT_SYMBOL_NUM][PRM_HANDLER_NAME_MAXIMUM_LENGTH];
+
 //
 // Initialization Function
 //
@@ -171,6 +185,13 @@ InitializeElf64 (
 return FALSE;
   }
 
+  if (mExportFlag) {
+if (mEhdr->e_machine != EM_X86_64) {
+  Error (NULL, 0, 3000, "Unsupported", "--prm option currently only 
supports X64 arch.");
+  return FALSE;
+}
+  }
+
   //
   // Update section header pointers
   //
@@ -200,6 +221,11 @@ InitializeElf64 (
   ElfFunctions->SetImageSize = SetImageSize64;
   ElfFunctions->CleanUp = CleanUp64;
 
+  if (mExportFlag) {
+mCoffNbrSections ++;
+ElfFunctions->WriteExport = WriteExport64;
+  }
+
   return TRUE;
 }
 
@@ -263,6 +289,17 @@ IsHiiRsrcShdr (
   return (BOOLEAN) (strcmp((CHAR8*)mEhdr + Namedr->sh_offset + Shdr->sh_name, 
ELF_HII_SECTION_NAME) == 0);
 }
 
+STATIC
+BOOLEAN
+IsSymbolShdr (
+  Elf_Shdr *Shdr
+  )
+{
+  Elf_Shdr *Namehdr = GetShdrByIndex(mEhdr->e_shstrndx);
+
+  return (BOOLEAN) (strcmp((CHAR8*)mEhdr + Namehdr->sh_offset + Shdr->sh_name, 
ELF_SYMBOL_SECTION_NAME) == 0);
+}
+
 STATIC
 BOOLEAN
 IsDataShdr (
@@ -335,6 +372,37 @@ GetSymName (
   return StrtabContents + Sym->st_name;
 }
 
+//
+// Get Prm Handler number and name
+//
+STATIC
+VOID
+FindPrmHandler (
+  UINT64 Offset
+  )
+{
+  PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_HEADER *PrmExport;
+  PRM_HANDLER_EXPORT_DESCRIPTOR_STRUCT   *PrmHandler;
+  UINT32   HandlerNum;
+
+  PrmExport = (PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_HEADER*)((UINT8*)mEhdr + 
Offset);
+  PrmHandler = (PRM_HANDLER_EXPORT_DESCRIPTOR_STRUCT *)(PrmExport + 1);
+
+  for (HandlerNum = 0; HandlerNum < PrmExport->NumberPrmHandlers; 
HandlerNum++) {
+strcpy(mExportSymName[mExportSymNum], PrmHandler->PrmHandlerName);
+mExportSymNum ++;
+PrmHandler += 1;
+
+//
+// Check if PRM handler number is larger than 
(PRM_MODULE_EXPORT_SYMBOL_NUM - 1)
+//
+if (mExportSymNum >= (PRM_MODULE_EXPORT_SYMBOL_NUM - 1)) {
+  Error (NULL, 0, 3000, "Invalid", "FindPrmHandler: Number %u is too 
high.", mExportSymNum);
+  exit(EXIT_FAILURE);
+}
+  }
+}
+
 //
 // Find the ELF section hosting the GOT from an ELF Rva
 //   of a single GOT entry.  Normally, GOT is placed in
@@ -717,6 +785,7 @@ ScanSections64 (
   UINT32  CoffEntry;
   UINT32  SectionCount;
   BOOLEAN FoundSection;
+  UINT32  Offset;
 
   CoffEntry = 0;
   mCoffOffset = 0;
@@ -880,6 +949,82 @@ ScanSections64 (
 Warning (NULL, 0, 0, NULL, "Multiple sections in %s are merged into 1 data 
section. Source level debug might not work correctly.", mInImageName);
   }
 
+  //
+  //  The Symbol sections.
+  //
+  if (mExportFlag) {
+UINT32  SymIndex;
+Elf_Sym *Sym;
+UINT64  SymNum;
+const UINT8 *SymName;
+
+mExportOffset = mCoffOffset;
+mExportSize = 

[edk2-devel] [PATCH v2] BaseTools/GenFw: Enhance GenFw to support PRM GCC build

2022-02-27 Thread Huang, Li-Xia
Since PRM module needs to support export table in PE-COFF, we'll
enhance GenFw tool to support this.

Add one export flag in GenFw tool. If export flag is set:
Step1: Scan ELF symbol table based on PRM module descriptor to get
descriptor offset address;
Step2: Find PRM handlers number and name in COFF file based on the
address from step1;
Step3: Write PRM info such as handler name and export RVA into COFF
export table.

PRM option currently only supports DXE RUNTIME driver and X64 arch.

Change-Id: I479b7c8b23beea12b5c567677688aef6f7af2085
Cc: Liming Gao 
Cc: Bob Feng 
Cc: Yuwei Chen 
Signed-off-by: Lixia Huang 
---
 BaseTools/Source/C/GenFw/Elf64Convert.c   | 242 +-
 BaseTools/Source/C/GenFw/ElfConvert.c |   8 +
 BaseTools/Source/C/GenFw/ElfConvert.h |  43 +++-
 BaseTools/Source/C/GenFw/GenFw.c  |  20 +-
 .../C/Include/IndustryStandard/PeImage.h  |   7 +
 5 files changed, 315 insertions(+), 5 deletions(-)

diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c 
b/BaseTools/Source/C/GenFw/Elf64Convert.c
index 0bb3ead228..2aa9bfcc94 100644
--- a/BaseTools/Source/C/GenFw/Elf64Convert.c
+++ b/BaseTools/Source/C/GenFw/Elf64Convert.c
@@ -56,6 +56,12 @@ WriteDebug64 (
   VOID
   );
 
+STATIC
+VOID
+WriteExport64 (
+  VOID
+  );
+
 STATIC
 VOID
 SetImageSize64 (
@@ -106,7 +112,7 @@ STATIC UINT32 mCoffAlignment = 0x20;
 //
 // PE section alignment.
 //
-STATIC const UINT16 mCoffNbrSections = 4;
+STATIC UINT16 mCoffNbrSections = 4;
 
 //
 // ELF sections to offset in Coff file.
@@ -122,7 +128,7 @@ STATIC UINT32 mDataOffset;
 STATIC UINT32 mHiiRsrcOffset;
 STATIC UINT32 mRelocOffset;
 STATIC UINT32 mDebugOffset;
-
+STATIC UINT32 mExportOffset;
 //
 // Used for RISC-V relocations.
 //
@@ -132,6 +138,14 @@ STATIC Elf64_Half  mRiscVPass1SymSecIndex = 0;
 STATIC INT32   mRiscVPass1Offset;
 STATIC INT32   mRiscVPass1GotFixup;
 
+//
+// Used for Export section.
+//
+STATIC UINT32  mExportSize;
+STATIC UINT32  mExportRVA[PRM_MODULE_EXPORT_SYMBOL_NUM];
+STATIC UINT32  mExportSymNum;
+STATIC CHAR8   
mExportSymName[PRM_MODULE_EXPORT_SYMBOL_NUM][PRM_HANDLER_NAME_MAXIMUM_LENGTH];
+
 //
 // Initialization Function
 //
@@ -171,6 +185,13 @@ InitializeElf64 (
 return FALSE;
   }
 
+  if (mExportFlag) {
+if (mEhdr->e_machine != EM_X86_64) {
+  Error (NULL, 0, 3000, "Unsupported", "--prm option currently only 
supports X64 arch.");
+  return FALSE;
+}
+  }
+
   //
   // Update section header pointers
   //
@@ -200,6 +221,11 @@ InitializeElf64 (
   ElfFunctions->SetImageSize = SetImageSize64;
   ElfFunctions->CleanUp = CleanUp64;
 
+  if (mExportFlag) {
+mCoffNbrSections ++;
+ElfFunctions->WriteExport = WriteExport64;
+  }
+
   return TRUE;
 }
 
@@ -263,6 +289,17 @@ IsHiiRsrcShdr (
   return (BOOLEAN) (strcmp((CHAR8*)mEhdr + Namedr->sh_offset + Shdr->sh_name, 
ELF_HII_SECTION_NAME) == 0);
 }
 
+STATIC
+BOOLEAN
+IsSymbolShdr (
+  Elf_Shdr *Shdr
+  )
+{
+  Elf_Shdr *Namehdr = GetShdrByIndex(mEhdr->e_shstrndx);
+
+  return (BOOLEAN) (strcmp((CHAR8*)mEhdr + Namehdr->sh_offset + Shdr->sh_name, 
ELF_SYMBOL_SECTION_NAME) == 0);
+}
+
 STATIC
 BOOLEAN
 IsDataShdr (
@@ -335,6 +372,37 @@ GetSymName (
   return StrtabContents + Sym->st_name;
 }
 
+//
+// Get Prm Handler number and name
+//
+STATIC
+VOID
+FindPrmHandler (
+  UINT64 Offset
+  )
+{
+  PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_HEADER *PrmExport;
+  PRM_HANDLER_EXPORT_DESCRIPTOR_STRUCT   *PrmHandler;
+  UINT32   HandlerNum;
+
+  PrmExport = (PRM_MODULE_EXPORT_DESCRIPTOR_STRUCT_HEADER*)((UINT8*)mEhdr + 
Offset);
+  PrmHandler = (PRM_HANDLER_EXPORT_DESCRIPTOR_STRUCT *)(PrmExport + 1);
+
+  for (HandlerNum = 0; HandlerNum < PrmExport->NumberPrmHandlers; 
HandlerNum++) {
+strcpy(mExportSymName[mExportSymNum], PrmHandler->PrmHandlerName);
+mExportSymNum ++;
+PrmHandler += 1;
+
+//
+// Check if PRM handler number is larger than 
(PRM_MODULE_EXPORT_SYMBOL_NUM - 1)
+//
+if (mExportSymNum >= (PRM_MODULE_EXPORT_SYMBOL_NUM - 1)) {
+  Error (NULL, 0, 3000, "Invalid", "FindPrmHandler: Number %u is too 
high.", mExportSymNum);
+  exit(EXIT_FAILURE);
+}
+  }
+}
+
 //
 // Find the ELF section hosting the GOT from an ELF Rva
 //   of a single GOT entry.  Normally, GOT is placed in
@@ -717,6 +785,7 @@ ScanSections64 (
   UINT32  CoffEntry;
   UINT32  SectionCount;
   BOOLEAN FoundSection;
+  UINT32  Offset;
 
   CoffEntry = 0;
   mCoffOffset = 0;
@@ -880,6 +949,82 @@ ScanSections64 (
 Warning (NULL, 0, 0, NULL, "Multiple sections in %s are merged into 1 data 
section. Source level debug might not work correctly.", mInImageName);
   }
 
+  //
+  //  The Symbol sections.
+  //
+  if (mExportFlag) {
+UINT32  SymIndex;
+Elf_Sym *Sym;
+UINT64  SymNum;
+const UINT8 *SymName;
+
+mExportOffset = mCoffOffset;
+mExportSize = 

Re: [edk2-devel][PATCH] BaseTools/GenFw: Enhance to add export table in PE-COFF

2022-01-26 Thread Huang, Li-Xia
Hi Michael,

Thanks for your response.

Sorry I didn't give enough context for my question, I mean the ' 
SizeOfInitializedData' in Optional header of PE-COFF file.
SizeOfInitializedData
The size of the initialized data section, or the sum of all such sections if 
there are multiple data sections.

I had an experiment,  compare the .efi files generated by MSVC tool  - one with 
PRM exports and the other without,  the size of InitializedData in optional 
header becomes larger with PRM exports. So it shows that export table will be 
included in initialized data.
#if defined(_MSC_VER)
  #define PRM_EXPORT_API  __declspec(dllexport)
#else
  #define PRM_EXPORT_API
#endif

Regards,
Lisa

-Original Message-
From: Michael Kubacki  
Sent: 2022年1月27日 4:19
To: Huang, Li-Xia ; Michael Kubacki 
; devel@edk2.groups.io; Gao, Liming 
; Feng, Bob C 
Cc: Chen, Christine ; Wu, Yidong ; 
Xu, Wei6 ; You, Benjamin 
Subject: Re: [edk2-devel][PATCH] BaseTools/GenFw: Enhance to add export table 
in PE-COFF

Are you referring to "static data"? If so, no. That is allocated at boot time 
and placed into the appropriate handler information structures.

The items in the export table for a given PRM Module are:
1. PRM handler count
2. Platform GUID (automatically applied from the DSC
EDKII_DSC_PLATFORM_GUID)
(https://bugzilla.tianocore.org/show_bug.cgi?id=2969)
3. The PRM Module GUID
4. A list of PRM handler GUID<->PRM handler names
(used by FW discovery to map handler in export to GUID entry in the PRMT it 
produces)

https://github.com/tianocore/edk2-staging/blob/PlatformRuntimeMechanism/PrmPkg/Include/PrmExportDescriptor.h

Thanks,
Michael

On 1/26/2022 3:16 AM, Huang, Li-Xia wrote:
> Hi Michael,
> 
> Sure, I will include you if any update on PRM functionality.
> 
> BTW, I have a question about InitializedData, does it include export section 
> or not? Thanks.
> 
> Regards,
> Lisa
> 
> -Original Message-
> From: Michael Kubacki 
> Sent: 2022年1月22日 10:50
> To: devel@edk2.groups.io; Huang, Li-Xia ; Gao, 
> Liming ; Feng, Bob C 
> Cc: Chen, Christine ; Wu, Yidong 
> ; Xu, Wei6 ; You, Benjamin 
> ; mikub...@linux.microsoft.com
> Subject: Re: [edk2-devel][PATCH] BaseTools/GenFw: Enhance to add 
> export table in PE-COFF
> 
> Hi Lisa,
> 
> Thank you for contributing this. Please include me on functionality related 
> to PRM.
> 
> I was using the PRM_EXPORT_API macro
> (https://github.com/tianocore/edk2-staging/blob/9da8abf66505d8ff636aae
> cc429a5237ce226650/PrmPkg/Include/Prm.h#L17)
> to support this on MS toolchain.
> 
> It looks like this is to add similar functionality for ELF binaries using 
> GenFw?
> 
> Thanks,
> Michael
> 
> On 1/18/2022 1:19 AM, Huang, Li-Xia wrote:
>> Hi Liming,
>>
>> Thanks for your feedback.
>>
>> I have added some detail in BZ. 
>>
>> https://bugzilla.tianocore.org/show_bug.cgi?id=3802#add_comment
>> <https://bugzilla.tianocore.org/show_bug.cgi?id=3802#add_comment>
>>
>> Regards,
>>
>> Lisa
>>
>> *From:*gaoliming 
>> *Sent:* 2022年1月18日13:20
>> *To:* devel@edk2.groups.io; Huang, Li-Xia ; 
>> Feng, Bob C 
>> *Cc:* Chen, Christine ; Wu, Yidong 
>> ; Xu, Wei6 ; You, Benjamin 
>> 
>> *Subject:* 回复: [edk2-devel][PATCH] BaseTools/GenFw: Enhance to add 
>> export table in PE-COFF
>>
>> Lisa:
>>
>>    Can you give more background about PRM usage? What new usage 
>> requires RPM? Can you add the detail in BZ?
>>
>> Thanks
>>
>> Liming
>>
>> *发件人**:*devel@edk2.groups.io
>> <mailto:devel@edk2.groups.io>> <mailto:devel@edk2.groups.io>> *代表 *Huang, Li-Xia
>> *发送时间:* 2022年1月17日 11:09
>> *收件人:* Feng, Bob C > <mailto:bob.c.f...@intel.com>>; devel@edk2.groups.io 
>> <mailto:devel@edk2.groups.io>
>> *抄送:* Gao, Liming > <mailto:gaolim...@byosoft.com.cn>>; Chen, Christine 
>> mailto:yuwei.c...@intel.com>>; Wu, Yidong 
>> mailto:yidong...@intel.com>>; Xu, Wei6 
>> mailto:wei6...@intel.com>>; You, Benjamin 
>> mailto:benjamin@intel.com>>
>> *主题:* Re: [edk2-devel][PATCH] BaseTools/GenFw: Enhance to add export 
>> table in PE-COFF
>>
>> Hi Bob,
>>
>> Thanks for your comments.
>>
>> 1.  I will add the help information for "--PRM";
>>
>> 2.
>>
>> @@ -750,7 +818,7 @@ ScanSections64 (
>>
>>    if (shdr->sh_addralign <= mCoffAlignment) {
>>
>>      continue;
>>
>>    }
>>
>> -    if (IsTextShdr(shdr) || IsDataShdr(shdr) || IsHiiRsrcShdr(shdr)) 
>> {
>>
>> +    if (I

Re: [edk2-devel][PATCH] BaseTools/GenFw: Enhance to add export table in PE-COFF

2022-01-26 Thread Huang, Li-Xia
Hi Michael,

Sure, I will include you if any update on PRM functionality. 

BTW, I have a question about InitializedData, does it include export section or 
not? Thanks.

Regards,
Lisa

-Original Message-
From: Michael Kubacki  
Sent: 2022年1月22日 10:50
To: devel@edk2.groups.io; Huang, Li-Xia ; Gao, Liming 
; Feng, Bob C 
Cc: Chen, Christine ; Wu, Yidong ; 
Xu, Wei6 ; You, Benjamin ; 
mikub...@linux.microsoft.com
Subject: Re: [edk2-devel][PATCH] BaseTools/GenFw: Enhance to add export table 
in PE-COFF

Hi Lisa,

Thank you for contributing this. Please include me on functionality related to 
PRM.

I was using the PRM_EXPORT_API macro
(https://github.com/tianocore/edk2-staging/blob/9da8abf66505d8ff636aaecc429a5237ce226650/PrmPkg/Include/Prm.h#L17)
to support this on MS toolchain.

It looks like this is to add similar functionality for ELF binaries using GenFw?

Thanks,
Michael

On 1/18/2022 1:19 AM, Huang, Li-Xia wrote:
> Hi Liming,
> 
> Thanks for your feedback.
> 
> I have added some detail in BZ. 
> 
> https://bugzilla.tianocore.org/show_bug.cgi?id=3802#add_comment
> <https://bugzilla.tianocore.org/show_bug.cgi?id=3802#add_comment>
> 
> Regards,
> 
> Lisa
> 
> *From:*gaoliming 
> *Sent:* 2022年1月18日13:20
> *To:* devel@edk2.groups.io; Huang, Li-Xia ; 
> Feng, Bob C 
> *Cc:* Chen, Christine ; Wu, Yidong 
> ; Xu, Wei6 ; You, Benjamin 
> 
> *Subject:* 回复: [edk2-devel][PATCH] BaseTools/GenFw: Enhance to add 
> export table in PE-COFF
> 
> Lisa:
> 
>   Can you give more background about PRM usage? What new usage 
> requires RPM? Can you add the detail in BZ?
> 
> Thanks
> 
> Liming
> 
> *发件人**:*devel@edk2.groups.io
> <mailto:devel@edk2.groups.io> <mailto:devel@edk2.groups.io>> *代表 *Huang, Li-Xia
> *发送时间:* 2022年1月17日 11:09
> *收件人:* Feng, Bob C  <mailto:bob.c.f...@intel.com>>; devel@edk2.groups.io 
> <mailto:devel@edk2.groups.io>
> *抄送:* Gao, Liming  <mailto:gaolim...@byosoft.com.cn>>; Chen, Christine 
> mailto:yuwei.c...@intel.com>>; Wu, Yidong 
> mailto:yidong...@intel.com>>; Xu, Wei6 
> mailto:wei6...@intel.com>>; You, Benjamin 
> mailto:benjamin@intel.com>>
> *主题:* Re: [edk2-devel][PATCH] BaseTools/GenFw: Enhance to add export 
> table in PE-COFF
> 
> Hi Bob,
> 
> Thanks for your comments.
> 
> 1.  I will add the help information for "--PRM";
> 
> 2.
> 
> @@ -750,7 +818,7 @@ ScanSections64 (
> 
>   if (shdr->sh_addralign <= mCoffAlignment) {
> 
>     continue;
> 
>   }
> 
> -    if (IsTextShdr(shdr) || IsDataShdr(shdr) || IsHiiRsrcShdr(shdr)) 
> {
> 
> +    if (IsTextShdr(shdr) || IsDataShdr(shdr) || IsHiiRsrcShdr(shdr) 
> +||
> IsSymbolShdr(shdr)) {
> 
>     mCoffAlignment = (UINT32)shdr->sh_addralign;
> 
>   }
> 
>     }
> 
> 1) Above change is to Set mCoffAlignment to the maximum alignment of 
> the input sections including symbol section.
> 
>  The symbol section will only exist with below change, so it 
> should have no effect to other drivers.
> 
> build_rule.template:
> 
>      
> 
>      $(CP) ${src} $(DEBUG_DIR)(+)$(MODULE_NAME).debug
> 
>      #$(OBJCOPY) --strip-unneeded -R .eh_frame ${src}
> 
>      $(OBJCOPY) $(OBJCOPY_STRIPFLAG) ${src}
> 
> tools_def.template:
> 
> *_*_*_OBJCOPY_STRIPFLAG    = --strip-unneeded -R .eh_frame
> 
> PrmAddrTransDsm.inf:
> 
> [BuildOptions.common]
> 
> ...
> 
>    GCC: *_*_*_OBJCOPY_STRIPFLAG == -R .eh_frame
> 
> 2) For PRM driver, sh_addralign of symbol section is 8, and less than 
> other sections such as Text and Data (sh_addralign is 4096).
> 
> Regards,
> 
> Lisa
> 
> -Original Message-
> From: Feng, Bob C mailto:bob.c.f...@intel.com>>
> Sent: 2022年1月14日 14:12
> To: Huang, Li-Xia  <mailto:lisa.hu...@intel.com>>; devel@edk2.groups.io 
> <mailto:devel@edk2.groups.io>
> Cc: Gao, Liming  <mailto:gaolim...@byosoft.com.cn>>; Chen, Christine 
> mailto:yuwei.c...@intel.com>>
> Subject: RE: [edk2-devel][PATCH] BaseTools/GenFw: Enhance to add 
> export table in PE-COFF
> 
> Hi Lixia,
> 
> This patch introduce a new command line option --PRM. Could you add 
> the help information about --PRM?
> 
> Could you provide more information about the below change? Would there 
> be side-effect?
> 
> @@ -750,7 +818,7 @@ ScanSections64 (
> 
>   if (shdr->sh_addralign <= mCoffAlignment) {
> 
>         continue;
> 
>   }
> 
> -    if (IsTextShdr(shdr) || IsDataShdr(shdr) || IsHiiRsrcShdr(shdr)) 
> {
> 
> +    if (IsTextShdr(shdr) || IsDataShdr(shdr) || IsHiiRsrcShdr(shdr) 
> +