[edk2-devel] [edk2-platforms:PATCH v2] MinPlatformPkg: Fix SetLargeVariable fail issue

2023-05-23 Thread Miki Shindo
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4454

On Server platform, when the large variable "FspNvsBuffer" is already in the 
UEFI variable store and the remaining variable storage space is less than the 
large variable size, and also not in OS runtime, then we need to add the size 
of the current data that will end up being replaced by the new data to the 
remaining space before we decide that there is not enough space to store the 
large variable.

Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Liming Gao 
Cc: Eric Dong 
Co-authored-by: Xiaoqiang Zhang 
Signed-off-by: Miki Shindo 
---
 
Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/LargeVariableWriteLib.c
   | 10 +-
 
Platform/Intel/MinPlatformPkg/Library/DxeRuntimeVariableWriteLib/DxeRuntimeVariableWriteLib.c
| 15 +++
 
Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/SmmVariableWriteCommon.c
   | 16 
 
Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/StandaloneMmVariableWriteLibConstructor.c
  | 30 ++
 
Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/TraditionalMmVariableWriteLibConstructor.c
 | 30 ++
 Platform/Intel/MinPlatformPkg/Include/Library/VariableWriteLib.h   
  | 12 
 
Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/BaseLargeVariableWriteLib.inf
 |  1 +
 
Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/StandaloneMmVariableWriteLib.inf
   |  3 ++-
 
Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/TraditionalMmVariableWriteLib.inf
  |  3 ++-
 9 files changed, 117 insertions(+), 3 deletions(-)

diff --git 
a/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/LargeVariableWriteLib.c
 
b/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/LargeVariableWriteLib.c
index de23ae6160..4bf9a6994f 100644
--- 
a/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/LargeVariableWriteLib.c
+++ 
b/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/LargeVariableWriteLib.c
@@ -22,7 +22,7 @@
 #include 
 #include 
 #include 
-
+#include 
 #include "LargeVariableCommon.h"
 
 /**
@@ -270,6 +270,7 @@ SetLargeVariable (
   UINT8 *OffsetPtr;
   UINTN BytesRemaining;
   UINTN SizeToSave;
+  UINTN BufferSize = 0;
 
   //
   // Check input parameters.
@@ -365,6 +366,13 @@ SetLargeVariable (
 // Non-Volatile storage to store the data.
 //
 RemainingVariableStorage = GetRemainingVariableStorageSpace ();
+//
+// Check if current variable already existed in NV storage variable space
+//
+Status = GetLargeVariable (VariableName, VendorGuid, , NULL);
+if ((Status == EFI_BUFFER_TOO_SMALL) && (BufferSize != 0) && 
!VarLibAtOsRuntime ()) {
+  RemainingVariableStorage = RemainingVariableStorage + BufferSize;
+}
 if (DataSize > RemainingVariableStorage) {
   DEBUG ((DEBUG_ERROR, "SetLargeVariable: Not enough NV storage space to 
store the data\n"));
   Status = EFI_OUT_OF_RESOURCES;
diff --git 
a/Platform/Intel/MinPlatformPkg/Library/DxeRuntimeVariableWriteLib/DxeRuntimeVariableWriteLib.c
 
b/Platform/Intel/MinPlatformPkg/Library/DxeRuntimeVariableWriteLib/DxeRuntimeVariableWriteLib.c
index 28730f858b..9ca4734f24 100644
--- 
a/Platform/Intel/MinPlatformPkg/Library/DxeRuntimeVariableWriteLib/DxeRuntimeVariableWriteLib.c
+++ 
b/Platform/Intel/MinPlatformPkg/Library/DxeRuntimeVariableWriteLib/DxeRuntimeVariableWriteLib.c
@@ -195,6 +195,21 @@ VarLibVariableRequestToLock (
   return Status;
 }
 
+/**
+  Indicator of whether it is runtime or not.
+
+  @retval TRUEIt is Runtime.
+  @retval FALSE   It is not Runtime.
+**/
+BOOLEAN
+EFIAPI
+VarLibAtOsRuntime (
+  VOID
+  )
+{
+  return (mVariableWriteLibVariablePolicy == NULL) ? TRUE : FALSE;
+}
+
 /**
   Close events when driver unloaded.
 
diff --git 
a/Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/SmmVariableWriteCommon.c
 
b/Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/SmmVariableWriteCommon.c
index 50ebb544b8..cd7118d1fb 100644
--- 
a/Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/SmmVariableWriteCommon.c
+++ 
b/Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/SmmVariableWriteCommon.c
@@ -18,6 +18,7 @@
 #include 
 
 EFI_SMM_VARIABLE_PROTOCOL  *mVariableWriteLibSmmVariable = NULL;
+BOOLEANmEfiAtRuntime = FALSE;
 
 /**
   Sets the value of a variable.
@@ -169,3 +170,18 @@ VarLibVariableRequestToLock (
   //
   return EFI_UNSUPPORTED;
 }
+
+/**
+  Indicator of whether it is runtime or not.
+
+  @retval TRUEIt is Runtime.
+  @retval FALSE   It is not Runtime.
+**/
+BOOLEAN
+EFIAPI
+VarLibAtOsRuntime (
+  VOID
+  )
+{
+  return mEfiAtRuntime;
+}
diff --git 
a/Platform/Intel/MinPlatformPkg/Library/SmmVariableWrite

[edk2-devel] [PATCH] EmulatorPkg/PosixFileSystem: Add NULL check on memory allocation

2022-07-19 Thread Miki Shindo
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4001

This commit adds NULL check on memory allocation of the size
for FileName in ASCII string format at PosixFileSetInfo().

Signed-off-by: Miki Shindo 
Cc: Andrew Fish 
Cc: Ray Ni 
---
 EmulatorPkg/Unix/Host/PosixFileSystem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/EmulatorPkg/Unix/Host/PosixFileSystem.c 
b/EmulatorPkg/Unix/Host/PosixFileSystem.c
index ae3fe72a05..b69d3d5520 100644
--- a/EmulatorPkg/Unix/Host/PosixFileSystem.c
+++ b/EmulatorPkg/Unix/Host/PosixFileSystem.c
@@ -1187,7 +1187,7 @@ PosixFileSetInfo (
   }
 
   OldFileName = malloc (AsciiStrSize (PrivateFile->FileName));
-  if (OldFileInfo == NULL) {
+  if (OldFileName == NULL) {
 goto Done;
   }
 
-- 
2.27.0.windows.1



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




[edk2-devel] [PATCH] MdePkg/Acpi62: Add bit definitions to NFIT Platform Capabilities Structure

2022-06-29 Thread Miki Shindo
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3915

This commit adds each capability bit definition
for NFIT Platform Capabilities Structure.
The type has been added since ACPI Specification Version 6.2A.

Signed-off-by: Miki Shindo 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Cc: Ray Ni 
Cc: Liming Gao 
---
 MdePkg/Include/IndustryStandard/Acpi62.h | 4 
 MdePkg/Include/IndustryStandard/Acpi63.h | 4 
 MdePkg/Include/IndustryStandard/Acpi64.h | 4 
 3 files changed, 12 insertions(+)

diff --git a/MdePkg/Include/IndustryStandard/Acpi62.h 
b/MdePkg/Include/IndustryStandard/Acpi62.h
index 836e986ee5..e27775a85a 100644
--- a/MdePkg/Include/IndustryStandard/Acpi62.h
+++ b/MdePkg/Include/IndustryStandard/Acpi62.h
@@ -1651,6 +1651,10 @@ typedef struct {
   UINT8 Reserved_12[4];
 } EFI_ACPI_6_2_NFIT_PLATFORM_CAPABILITIES_STRUCTURE;
 
+#define 
EFI_ACPI_6_2_NFIT_PLATFORM_CAPABILITY_CPU_CACHE_FLUSH_TO_NVDIMM_DURABILITY_ON_POWER_LOSS
  BIT0
+#define 
EFI_ACPI_6_2_NFIT_PLATFORM_CAPABILITY_MEMORY_CONTROLLER_FLUSH_TO_NVDIMM_DURABILITY_ON_POWER_LOSS
  BIT1
+#define 
EFI_ACPI_6_2_NFIT_PLATFORM_CAPABILITY_BYTE_ADDRESSABLE_PERSISTENT_MEMORY_HARDWARE_MIRRORING
   BIT2
+
 ///
 /// Secure DEVices Table (SDEV)
 ///
diff --git a/MdePkg/Include/IndustryStandard/Acpi63.h 
b/MdePkg/Include/IndustryStandard/Acpi63.h
index 15a30d8808..10bdf5fe5a 100644
--- a/MdePkg/Include/IndustryStandard/Acpi63.h
+++ b/MdePkg/Include/IndustryStandard/Acpi63.h
@@ -1615,6 +1615,10 @@ typedef struct {
   UINT8 Reserved_12[4];
 } EFI_ACPI_6_3_NFIT_PLATFORM_CAPABILITIES_STRUCTURE;
 
+#define 
EFI_ACPI_6_3_NFIT_PLATFORM_CAPABILITY_CPU_CACHE_FLUSH_TO_NVDIMM_DURABILITY_ON_POWER_LOSS
  BIT0
+#define 
EFI_ACPI_6_3_NFIT_PLATFORM_CAPABILITY_MEMORY_CONTROLLER_FLUSH_TO_NVDIMM_DURABILITY_ON_POWER_LOSS
  BIT1
+#define 
EFI_ACPI_6_3_NFIT_PLATFORM_CAPABILITY_BYTE_ADDRESSABLE_PERSISTENT_MEMORY_HARDWARE_MIRRORING
   BIT2
+
 ///
 /// Secure DEVices Table (SDEV)
 ///
diff --git a/MdePkg/Include/IndustryStandard/Acpi64.h 
b/MdePkg/Include/IndustryStandard/Acpi64.h
index c1d8b14c44..fe5ebfac2b 100644
--- a/MdePkg/Include/IndustryStandard/Acpi64.h
+++ b/MdePkg/Include/IndustryStandard/Acpi64.h
@@ -1664,6 +1664,10 @@ typedef struct {
   UINT8 Reserved_12[4];
 } EFI_ACPI_6_4_NFIT_PLATFORM_CAPABILITIES_STRUCTURE;
 
+#define 
EFI_ACPI_6_4_NFIT_PLATFORM_CAPABILITY_CPU_CACHE_FLUSH_TO_NVDIMM_DURABILITY_ON_POWER_LOSS
  BIT0
+#define 
EFI_ACPI_6_4_NFIT_PLATFORM_CAPABILITY_MEMORY_CONTROLLER_FLUSH_TO_NVDIMM_DURABILITY_ON_POWER_LOSS
  BIT1
+#define 
EFI_ACPI_6_4_NFIT_PLATFORM_CAPABILITY_BYTE_ADDRESSABLE_PERSISTENT_MEMORY_HARDWARE_MIRRORING
   BIT2
+
 ///
 /// Secure DEVices Table (SDEV)
 ///
-- 
2.27.0.windows.1



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




[edk2-devel] [edk2:PATCH v3] MdePkg/Acpi62: Add type 7 NFIT Platform Capabilities Structure support

2022-06-22 Thread Miki Shindo
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3915

This commit adds a definition type 7 Platform Capabilities Structure
and the struct definition for NFIT Table Structure Types.
The type has been added since ACPI Specification Version 6.2A.

Signed-off-by: Miki Shindo 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Cc: Ray Ni 

---
 MdePkg/Include/IndustryStandard/Acpi62.h | 13 +
 MdePkg/Include/IndustryStandard/Acpi63.h | 13 +
 MdePkg/Include/IndustryStandard/Acpi64.h | 13 +
 3 files changed, 39 insertions(+)

diff --git a/MdePkg/Include/IndustryStandard/Acpi62.h 
b/MdePkg/Include/IndustryStandard/Acpi62.h
index 313db63044..836e986ee5 100644
--- a/MdePkg/Include/IndustryStandard/Acpi62.h
+++ b/MdePkg/Include/IndustryStandard/Acpi62.h
@@ -1486,6 +1486,7 @@ typedef struct {
 #define EFI_ACPI_6_2_NFIT_NVDIMM_CONTROL_REGION_STRUCTURE_TYPE4
 #define EFI_ACPI_6_2_NFIT_NVDIMM_BLOCK_DATA_WINDOW_REGION_STRUCTURE_TYPE  5
 #define EFI_ACPI_6_2_NFIT_FLUSH_HINT_ADDRESS_STRUCTURE_TYPE   6
+#define EFI_ACPI_6_2_NFIT_PLATFORM_CAPABILITIES_STRUCTURE_TYPE7
 
 //
 // Definition for NFIT Structure Header
@@ -1638,6 +1639,18 @@ typedef struct {
   // UINT64  
FlushHintAddress[NumberOfFlushHintAddresses];
 } EFI_ACPI_6_2_NFIT_FLUSH_HINT_ADDRESS_STRUCTURE;
 
+//
+// Definition for Platform Capabilities Structure
+//
+typedef struct {
+  UINT16Type;
+  UINT16Length;
+  UINT8 HighestValidCapability;
+  UINT8 Reserved_5[3];
+  UINT32Capabilities;
+  UINT8 Reserved_12[4];
+} EFI_ACPI_6_2_NFIT_PLATFORM_CAPABILITIES_STRUCTURE;
+
 ///
 /// Secure DEVices Table (SDEV)
 ///
diff --git a/MdePkg/Include/IndustryStandard/Acpi63.h 
b/MdePkg/Include/IndustryStandard/Acpi63.h
index b1e9d5db5b..15a30d8808 100644
--- a/MdePkg/Include/IndustryStandard/Acpi63.h
+++ b/MdePkg/Include/IndustryStandard/Acpi63.h
@@ -1450,6 +1450,7 @@ typedef struct {
 #define EFI_ACPI_6_3_NFIT_NVDIMM_CONTROL_REGION_STRUCTURE_TYPE4
 #define EFI_ACPI_6_3_NFIT_NVDIMM_BLOCK_DATA_WINDOW_REGION_STRUCTURE_TYPE  5
 #define EFI_ACPI_6_3_NFIT_FLUSH_HINT_ADDRESS_STRUCTURE_TYPE   6
+#define EFI_ACPI_6_3_NFIT_PLATFORM_CAPABILITIES_STRUCTURE_TYPE7
 
 //
 // Definition for NFIT Structure Header
@@ -1602,6 +1603,18 @@ typedef struct {
   // UINT64  
FlushHintAddress[NumberOfFlushHintAddresses];
 } EFI_ACPI_6_3_NFIT_FLUSH_HINT_ADDRESS_STRUCTURE;
 
+//
+// Definition for Platform Capabilities Structure
+//
+typedef struct {
+  UINT16Type;
+  UINT16Length;
+  UINT8 HighestValidCapability;
+  UINT8 Reserved_5[3];
+  UINT32Capabilities;
+  UINT8 Reserved_12[4];
+} EFI_ACPI_6_3_NFIT_PLATFORM_CAPABILITIES_STRUCTURE;
+
 ///
 /// Secure DEVices Table (SDEV)
 ///
diff --git a/MdePkg/Include/IndustryStandard/Acpi64.h 
b/MdePkg/Include/IndustryStandard/Acpi64.h
index 232697f228..c1d8b14c44 100644
--- a/MdePkg/Include/IndustryStandard/Acpi64.h
+++ b/MdePkg/Include/IndustryStandard/Acpi64.h
@@ -1493,6 +1493,7 @@ typedef struct {
 #define EFI_ACPI_6_4_NFIT_NVDIMM_CONTROL_REGION_STRUCTURE_TYPE4
 #define EFI_ACPI_6_4_NFIT_NVDIMM_BLOCK_DATA_WINDOW_REGION_STRUCTURE_TYPE  5
 #define EFI_ACPI_6_4_NFIT_FLUSH_HINT_ADDRESS_STRUCTURE_TYPE   6
+#define EFI_ACPI_6_4_NFIT_PLATFORM_CAPABILITIES_STRUCTURE_TYPE7
 
 //
 // Definition for NFIT Structure Header
@@ -1651,6 +1652,18 @@ typedef struct {
   // UINT64  
FlushHintAddress[NumberOfFlushHintAddresses];
 } EFI_ACPI_6_4_NFIT_FLUSH_HINT_ADDRESS_STRUCTURE;
 
+//
+// Definition for Platform Capabilities Structure
+//
+typedef struct {
+  UINT16Type;
+  UINT16Length;
+  UINT8 HighestValidCapability;
+  UINT8 Reserved_5[3];
+  UINT32Capabilities;
+  UINT8 Reserved_12[4];
+} EFI_ACPI_6_4_NFIT_PLATFORM_CAPABILITIES_STRUCTURE;
+
 ///
 /// Secure DEVices Table (SDEV)
 ///
-- 
2.27.0.windows.1



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




[edk2-devel] [edk2:PATCH v2] MdePkg/Acpi62: Add type 7 NFIT Platform Capabilities Structure support

2022-05-11 Thread Miki Shindo
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3915

This commit adds a definition type 7 Platform Capabilities Structure
for NFIT Table Structure Types. The type has been added
since ACPI Specification Version 6.2A.


Signed-off-by: Miki Shindo 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Cc: Ray Ni 
Reviewed-by: Ray Ni 

---
 MdePkg/Include/IndustryStandard/Acpi62.h | 1 +
 MdePkg/Include/IndustryStandard/Acpi63.h | 1 +
 MdePkg/Include/IndustryStandard/Acpi64.h | 1 +
 3 files changed, 3 insertions(+)

diff --git a/MdePkg/Include/IndustryStandard/Acpi62.h 
b/MdePkg/Include/IndustryStandard/Acpi62.h
index 313db63044..aa115d475c 100644
--- a/MdePkg/Include/IndustryStandard/Acpi62.h
+++ b/MdePkg/Include/IndustryStandard/Acpi62.h
@@ -1486,6 +1486,7 @@ typedef struct {
 #define EFI_ACPI_6_2_NFIT_NVDIMM_CONTROL_REGION_STRUCTURE_TYPE4
 #define EFI_ACPI_6_2_NFIT_NVDIMM_BLOCK_DATA_WINDOW_REGION_STRUCTURE_TYPE  5
 #define EFI_ACPI_6_2_NFIT_FLUSH_HINT_ADDRESS_STRUCTURE_TYPE   6
+#define EFI_ACPI_6_2_NFIT_PLATFORM_CAPABILITIES_STRUCTURE_TYPE7
 
 //
 // Definition for NFIT Structure Header
diff --git a/MdePkg/Include/IndustryStandard/Acpi63.h 
b/MdePkg/Include/IndustryStandard/Acpi63.h
index b1e9d5db5b..a440bdfd48 100644
--- a/MdePkg/Include/IndustryStandard/Acpi63.h
+++ b/MdePkg/Include/IndustryStandard/Acpi63.h
@@ -1450,6 +1450,7 @@ typedef struct {
 #define EFI_ACPI_6_3_NFIT_NVDIMM_CONTROL_REGION_STRUCTURE_TYPE4
 #define EFI_ACPI_6_3_NFIT_NVDIMM_BLOCK_DATA_WINDOW_REGION_STRUCTURE_TYPE  5
 #define EFI_ACPI_6_3_NFIT_FLUSH_HINT_ADDRESS_STRUCTURE_TYPE   6
+#define EFI_ACPI_6_3_NFIT_PLATFORM_CAPABILITIES_STRUCTURE_TYPE7
 
 //
 // Definition for NFIT Structure Header
diff --git a/MdePkg/Include/IndustryStandard/Acpi64.h 
b/MdePkg/Include/IndustryStandard/Acpi64.h
index 232697f228..88d01761f1 100644
--- a/MdePkg/Include/IndustryStandard/Acpi64.h
+++ b/MdePkg/Include/IndustryStandard/Acpi64.h
@@ -1493,6 +1493,7 @@ typedef struct {
 #define EFI_ACPI_6_4_NFIT_NVDIMM_CONTROL_REGION_STRUCTURE_TYPE4
 #define EFI_ACPI_6_4_NFIT_NVDIMM_BLOCK_DATA_WINDOW_REGION_STRUCTURE_TYPE  5
 #define EFI_ACPI_6_4_NFIT_FLUSH_HINT_ADDRESS_STRUCTURE_TYPE   6
+#define EFI_ACPI_6_4_NFIT_PLATFORM_CAPABILITIES_STRUCTURE_TYPE7
 
 //
 // Definition for NFIT Structure Header
-- 
2.27.0.windows.1



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




[edk2-devel] [edk2:PATCH] MdePkg/Acpi62: Add type 7 NFIT Platform Capabilities Structure support

2022-05-10 Thread Miki Shindo
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3915

This commit adds a definition type 7 Platform Capabilities Structure
for NFIT Table Structure Types. The type has been added
since ACPI Specification Version 6.2A.


Signed-off-by: Miki Shindo 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Cc: Ray Ni 
Reviewed-by: Ray Ni 

---
 MdePkg/Include/IndustryStandard/Acpi62.h | 1 +
 MdePkg/Include/IndustryStandard/Acpi63.h | 1 +
 MdePkg/Include/IndustryStandard/Acpi64.h | 1 +
 3 files changed, 3 insertions(+)

diff --git a/MdePkg/Include/IndustryStandard/Acpi62.h 
b/MdePkg/Include/IndustryStandard/Acpi62.h
index 313db63044..aa115d475c 100644
--- a/MdePkg/Include/IndustryStandard/Acpi62.h
+++ b/MdePkg/Include/IndustryStandard/Acpi62.h
@@ -1486,6 +1486,7 @@ typedef struct {
 #define EFI_ACPI_6_2_NFIT_NVDIMM_CONTROL_REGION_STRUCTURE_TYPE4
 #define EFI_ACPI_6_2_NFIT_NVDIMM_BLOCK_DATA_WINDOW_REGION_STRUCTURE_TYPE  5
 #define EFI_ACPI_6_2_NFIT_FLUSH_HINT_ADDRESS_STRUCTURE_TYPE   6
+#define EFI_ACPI_6_2_NFIT_PLATFORM_CAPABILITIES_STRUCTURE_TYPE7
 
 //
 // Definition for NFIT Structure Header
diff --git a/MdePkg/Include/IndustryStandard/Acpi63.h 
b/MdePkg/Include/IndustryStandard/Acpi63.h
index b1e9d5db5b..d0d2438b3c 100644
--- a/MdePkg/Include/IndustryStandard/Acpi63.h
+++ b/MdePkg/Include/IndustryStandard/Acpi63.h
@@ -1450,6 +1450,7 @@ typedef struct {
 #define EFI_ACPI_6_3_NFIT_NVDIMM_CONTROL_REGION_STRUCTURE_TYPE4
 #define EFI_ACPI_6_3_NFIT_NVDIMM_BLOCK_DATA_WINDOW_REGION_STRUCTURE_TYPE  5
 #define EFI_ACPI_6_3_NFIT_FLUSH_HINT_ADDRESS_STRUCTURE_TYPE   6
+#define EFI_ACPI_6_2_NFIT_PLATFORM_CAPABILITIES_STRUCTURE_TYPE7
 
 //
 // Definition for NFIT Structure Header
diff --git a/MdePkg/Include/IndustryStandard/Acpi64.h 
b/MdePkg/Include/IndustryStandard/Acpi64.h
index 232697f228..fce77d9f01 100644
--- a/MdePkg/Include/IndustryStandard/Acpi64.h
+++ b/MdePkg/Include/IndustryStandard/Acpi64.h
@@ -1493,6 +1493,7 @@ typedef struct {
 #define EFI_ACPI_6_4_NFIT_NVDIMM_CONTROL_REGION_STRUCTURE_TYPE4
 #define EFI_ACPI_6_4_NFIT_NVDIMM_BLOCK_DATA_WINDOW_REGION_STRUCTURE_TYPE  5
 #define EFI_ACPI_6_4_NFIT_FLUSH_HINT_ADDRESS_STRUCTURE_TYPE   6
+#define EFI_ACPI_6_2_NFIT_PLATFORM_CAPABILITIES_STRUCTURE_TYPE7
 
 //
 // Definition for NFIT Structure Header
-- 
2.27.0.windows.1



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




[edk2-devel] [edk2-platforms:PATCH v5 6/7] CoffeelakeSiliconPkg/DxeAslUpdateLib: Cleans up APIs

2020-05-05 Thread Miki Shindo
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2536

Callers of DxeAslUpdateLib don't have to call InitializeAslUpdateLib()
but the library itself runs it internally. This commit deletes
the redundant calls in caller side and makes it an internal call.
LocateAcpiTableByOemTableId() is unreferenced externally
so this commit makes it an internal call.
PSS_PACKAGE_LAYOUT and AML_RESRC_TEMP_END_TAG are both unreferenced
so they are removed.
AslUpdateLib.h is cleaned up accordingly.

Signed-off-by: Miki Shindo 
Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Prince Agyeman 
Cc: Ray Ni 
Acked-by: Nate DeSimone 
Reviewed-by: Ray Ni 
Reviewed-by: Sai Chaganty 
Reviewed-by: Chasel Chiu 

---
 Silicon/Intel/CoffeelakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c   
  | 198 
--
 
Silicon/Intel/CoffeelakeSiliconPkg/Library/DxeAslUpdateLibNull/DxeAslUpdateLibNull.c
 | 100 
++--
 Silicon/Intel/CoffeelakeSiliconPkg/Pch/PchInit/Dxe/PchAcpi.c   
  |   3 ---
 Silicon/Intel/CoffeelakeSiliconPkg/Include/Library/AslUpdateLib.h  
  | 120 
++--
 4 files changed, 192 insertions(+), 229 deletions(-)

diff --git 
a/Silicon/Intel/CoffeelakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c 
b/Silicon/Intel/CoffeelakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
index 04cf66fd2f..28d20980af 100644
--- 
a/Silicon/Intel/CoffeelakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
+++ 
b/Silicon/Intel/CoffeelakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
@@ -6,7 +6,7 @@
 
   This library uses the ACPI Support protocol.
 
-  Copyright (c) 2019 Intel Corporation. All rights reserved. 
+  Copyright (c) 2019 -2020, Intel Corporation. All rights reserved. 
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
@@ -30,7 +30,7 @@ static EFI_ACPI_TABLE_PROTOCOL*mAcpiTable = NULL;
 
 /**
   Initialize the ASL update library state.
-  This must be called prior to invoking other library functions.
+  This must be called at the beggining of the function calls in this library.
 
   @retval EFI_SUCCESS  - The function completed successfully.
 **/
@@ -51,9 +51,65 @@ InitializeAslUpdateLib (
   return Status;
 }
 
+/**
+  This function uses the ACPI SDT protocol to locate an ACPI SSDT table.
+
+  @param[in] TableId   - Pointer to an ASCII string containing the OEM 
Table ID from the ACPI table header
+  @param[in] TableIdSize   - Length of the TableId to match.  Table ID are 
8 bytes long, this function
+ will consider it a match if the first 
TableIdSize bytes match
+  @param[in, out] Table- Updated with a pointer to the table
+  @param[in, out] Handle   - AcpiSupport protocol table handle for the 
table found
+
+  @retval EFI_SUCCESS  - The function completed successfully.
+  @retval EFI_NOT_FOUND- Failed to locate AcpiTable.
+  @retval EFI_NOT_READY- Not ready to locate AcpiTable.
+**/
+EFI_STATUS
+LocateAcpiTableByOemTableId (
+  IN  UINT8 *TableId,
+  IN  UINT8 TableIdSize,
+  IN OUT  EFI_ACPI_DESCRIPTION_HEADER   **Table,
+  IN OUT  UINTN *Handle
+  )
+{
+  EFI_STATUS  Status;
+  INTNIndex;
+  EFI_ACPI_TABLE_VERSION  Version;
+  EFI_ACPI_DESCRIPTION_HEADER *OrgTable;
+
+  if (mAcpiSdt == NULL) {
+InitializeAslUpdateLib ();
+if (mAcpiSdt == NULL) {
+  return EFI_NOT_READY;
+}
+  }
+  ///
+  /// Locate table with matching ID
+  ///
+  Version = 0;
+  Index = 0;
+  do {
+Status = mAcpiSdt->GetAcpiTable (Index, (EFI_ACPI_SDT_HEADER **), 
, Handle);
+if (Status == EFI_NOT_FOUND) {
+  break;
+}
+ASSERT_EFI_ERROR (Status);
+Index++;
+  } while (CompareMem (&(OrgTable->OemTableId), TableId, TableIdSize));
+
+  if (Status != EFI_NOT_FOUND) {
+*Table = AllocateCopyPool (OrgTable->Length, OrgTable);
+ASSERT (*Table);
+  }
+
+  ///
+  /// If we found the table, there will be no error.
+  ///
+  return Status;
+}
 
 /**
-  This procedure will update immediate value assigned to a Name
+  This procedure will update immediate value assigned to a Name.
 
   @param[in] AslSignature  - The signature of Operation Region that we 
want to update.
   @param[in] Buffer- source of data to be written over original aml
@@ -61,8 +117,10 @@ InitializeAslUpdateLib (
 
   @retval EFI_SUCCESS  - The function completed successfully.
   @retval EFI_NOT_FOUND- Failed to locate AcpiTabl

[edk2-devel] [edk2-platforms:PATCH v5 0/7] IntelSiliconPkg DxeAslUpdateLib support

2020-05-05 Thread Miki Shindo
Patch 7/7 of this series adds DxeAslUpdateLib support in IntelSiliconPkg 
so each project can consume it.
As the existing DxeAslUpdateLib in SiliconPkg have different header files,
this series of patches resolve the inconsistency and avoid build failure.
Also some of unreferenced contents are cleaned up.


Signed-off-by: Miki Shindo 
Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Prince Agyeman 
Cc: Ray Ni 
Acked-by: Nate DeSimone 
Reviewed-by: Ray Ni 
Reviewed-by: Sai Chaganty 
Reviewed-by: Chasel Chiu 


Miki Shindo (7):
  WhiskeylakeOpenBoardPkg/TbtDxe: Removes redundant
InitializeAslUpdateLib
  KabylakeOpenBoardPkg/TbtDxe: Removes redundant InitializeAslUpdateLib
  CometlakeOpenBoardPkg/TbtDxe: Removes redundant InitializeAslUpdateLib
  MinPlatformPkg/DxeAslUpdateLib: Cleans up APIs
  KabylakeSiliconPkg/DxeAslUpdateLib: Cleans up APIs
  CoffeelakeSiliconPkg/DxeAslUpdateLib: Cleans up APIs
  IntelSiliconPkg/DxeAslUpdateLib: Add DxeAslUpdateLib support

 Platform/Intel/CometlakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c 
  |   3 ---
 Platform/Intel/KabylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c  
  |   5 +
 Platform/Intel/MinPlatformPkg/Acpi/Library/DxeAslUpdateLib/DxeAslUpdateLib.c   
  | 215 
+++
 Platform/Intel/WhiskeylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c   
  |   5 +
 Silicon/Intel/CoffeelakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c   
  | 198 
--
 
Silicon/Intel/CoffeelakeSiliconPkg/Library/DxeAslUpdateLibNull/DxeAslUpdateLibNull.c
 | 100 
++--
 Silicon/Intel/CoffeelakeSiliconPkg/Pch/PchInit/Dxe/PchAcpi.c   
  |   3 ---
 Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
  | 520 

 Silicon/Intel/KabylakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c 
  | 213 
+
 
Silicon/Intel/KabylakeSiliconPkg/Library/DxeAslUpdateLibNull/DxeAslUpdateLibNull.c
   | 100 
+++-
 Silicon/Intel/KabylakeSiliconPkg/Pch/PchInit/Dxe/PchAcpi.c 
  |   5 +
 Platform/Intel/MinPlatformPkg/Include/Library/AslUpdateLib.h   
  | 135 
++-
 Silicon/Intel/CoffeelakeSiliconPkg/Include/Library/AslUpdateLib.h  
  | 120 
++--
 Silicon/Intel/IntelSiliconPkg/Include/Library/AslUpdateLib.h   
  | 116 

 Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec  
  |   4 
 Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.inf  
  |  42 ++
 Silicon/Intel/KabylakeSiliconPkg/Include/Library/AslUpdateLib.h
  | 134 
++
 17 files changed, 1268 insertions(+), 650 deletions(-)
 create mode 100644 
Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
 create mode 100644 Silicon/Intel/IntelSiliconPkg/Include/Library/AslUpdateLib.h
 create mode 100644 
Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.inf

-- 
2.16.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58674): https://edk2

[edk2-devel] [edk2-platforms:PATCH v5 3/7] CometlakeOpenBoardPkg/TbtDxe: Removes redundant InitializeAslUpdateLib

2020-05-05 Thread Miki Shindo
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2536

This commit removes redundant InitializeAslUpdateLib calls
as DxeAslUpdateLib itself calls it internally.

Signed-off-by: Miki Shindo 
Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Prince Agyeman 
Cc: Ray Ni 
Acked-by: Nate DeSimone 
Reviewed-by: Ray Ni 
Reviewed-by: Sai Chaganty 
Reviewed-by: Chasel Chiu 

---
 Platform/Intel/CometlakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git 
a/Platform/Intel/CometlakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c 
b/Platform/Intel/CometlakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c
index ef6201de94..e43c5c2fa1 100644
--- a/Platform/Intel/CometlakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c
+++ b/Platform/Intel/CometlakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c
@@ -125,9 +125,6 @@ TbtAcpiEndOfDxeCallback (
   UINT16Length;
   UINT32Signature;
 
-  Status = InitializeAslUpdateLib ();
-  ASSERT_EFI_ERROR (Status);
-
   Address = (UINT32) (UINTN) mTbtNvsAreaProtocol.Area;
   Length  = (UINT16) sizeof (TBT_NVS_AREA);
   DEBUG ((DEBUG_INFO, "Patch TBT NvsAreaAddress: TBT NVS Address %x Length 
%x\n", Address, Length));
-- 
2.16.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58677): https://edk2.groups.io/g/devel/message/58677
Mute This Topic: https://groups.io/mt/74013807/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-platforms:PATCH v5 2/7] KabylakeOpenBoardPkg/TbtDxe: Removes redundant InitializeAslUpdateLib

2020-05-05 Thread Miki Shindo
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2536

This commit removes redundant InitializeAslUpdateLib call
as DxeAslUpdateLib itself calls it internally.

Signed-off-by: Miki Shindo 
Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Prince Agyeman 
Cc: Ray Ni 
Acked-by: Nate DeSimone 
Reviewed-by: Ray Ni 
Reviewed-by: Sai Chaganty 
Reviewed-by: Chasel Chiu 

---
 Platform/Intel/KabylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git 
a/Platform/Intel/KabylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c 
b/Platform/Intel/KabylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c
index 13a687576c..d101f4bb75 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c
@@ -1,6 +1,6 @@
 /** @file
 
-Copyright (c) 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2018 - 2020, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -125,9 +125,6 @@ TbtAcpiEndOfDxeCallback (
   UINT16Length;
   UINT32Signature;
 
-  Status = InitializeAslUpdateLib ();
-  ASSERT_EFI_ERROR (Status);
-
   Address = (UINT32) (UINTN) mTbtNvsAreaProtocol.Area;
   Length  = (UINT16) sizeof (TBT_NVS_AREA);
   DEBUG ((DEBUG_INFO, "Patch TBT NvsAreaAddress: TBT NVS Address %x Length 
%x\n", Address, Length));
-- 
2.16.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58676): https://edk2.groups.io/g/devel/message/58676
Mute This Topic: https://groups.io/mt/74013806/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-platforms:PATCH v5 4/7] MinPlatformPkg/DxeAslUpdateLib: Cleans up APIs

2020-05-05 Thread Miki Shindo
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2536

Callers of DxeAslUpdateLib don't have to call InitializeAslUpdateLib()
but the library itself runs it internally. This commit makes it
an internal call. LocateAcpiTableByOemTableId() is unreferenced externally
so this commit makes it an internal call.
PSS_PACKAGE_LAYOUT and AML_RESRC_TEMP_END_TAG are both unreferenced
so they are removed.
AslUpdateLib.h is cleaned up accordingly.

Signed-off-by: Miki Shindo 
Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Prince Agyeman 
Cc: Ray Ni 
Acked-by: Nate DeSimone 
Reviewed-by: Ray Ni 
Reviewed-by: Sai Chaganty 
Reviewed-by: Chasel Chiu 

---
 Platform/Intel/MinPlatformPkg/Acpi/Library/DxeAslUpdateLib/DxeAslUpdateLib.c | 
215 
+++
 Platform/Intel/MinPlatformPkg/Include/Library/AslUpdateLib.h | 
135 
++-
 2 files changed, 165 insertions(+), 185 deletions(-)

diff --git 
a/Platform/Intel/MinPlatformPkg/Acpi/Library/DxeAslUpdateLib/DxeAslUpdateLib.c 
b/Platform/Intel/MinPlatformPkg/Acpi/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
index e6ab43db6d..57df18d664 100644
--- 
a/Platform/Intel/MinPlatformPkg/Acpi/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
+++ 
b/Platform/Intel/MinPlatformPkg/Acpi/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
@@ -6,7 +6,7 @@
 
   This library uses the ACPI Support protocol.
 
-Copyright (c) 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2017 - 2020, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -29,7 +29,7 @@ static EFI_ACPI_TABLE_PROTOCOL*mAcpiTable = NULL;
 
 /**
   Initialize the ASL update library state.
-  This must be called prior to invoking other library functions.
+  This must be called at the beggining of the function calls in this library.
 
   @retval EFI_SUCCESS  - The function completed successfully.
 **/
@@ -50,17 +50,76 @@ InitializeAslUpdateLib (
   return Status;
 }
 
+/**
+  This function uses the ACPI SDT protocol to locate an ACPI SSDT table.
+
+  @param[in] TableId   - Pointer to an ASCII string containing the OEM 
Table ID from the ACPI table header
+  @param[in] TableIdSize   - Length of the TableId to match.  Table ID are 
8 bytes long, this function
+ will consider it a match if the first 
TableIdSize bytes match
+  @param[in, out] Table- Updated with a pointer to the table
+  @param[in, out] Handle   - AcpiSupport protocol table handle for the 
table found
+
+  @retval EFI_SUCCESS  - The function completed successfully.
+  @retval EFI_NOT_FOUND- Failed to locate AcpiTable.
+  @retval EFI_NOT_READY- Not ready to locate AcpiTable.
+**/
+EFI_STATUS
+LocateAcpiTableByOemTableId (
+  IN  UINT8 *TableId,
+  IN  UINT8 TableIdSize,
+  IN OUT  EFI_ACPI_DESCRIPTION_HEADER   **Table,
+  IN OUT  UINTN *Handle
+  )
+{
+  EFI_STATUS  Status;
+  INTNIndex;
+  EFI_ACPI_TABLE_VERSION  Version;
+  EFI_ACPI_DESCRIPTION_HEADER *OrgTable;
+
+  if (mAcpiSdt == NULL) {
+InitializeAslUpdateLib ();
+if (mAcpiSdt == NULL) {
+  return EFI_NOT_READY;
+}
+  }
+  ///
+  /// Locate table with matching ID
+  ///
+  Version = 0;
+  Index = 0;
+  do {
+Status = mAcpiSdt->GetAcpiTable (Index, (EFI_ACPI_SDT_HEADER **), 
, Handle);
+if (Status == EFI_NOT_FOUND) {
+  break;
+}
+ASSERT_EFI_ERROR (Status);
+Index++;
+  } while (CompareMem (&(OrgTable->OemTableId), TableId, TableIdSize));
+
+  if (Status != EFI_NOT_FOUND) {
+*Table = AllocateCopyPool (OrgTable->Length, OrgTable);
+ASSERT (*Table);
+  }
+
+  ///
+  /// If we found the table, there will be no error.
+  ///
+  return Status;
+}
 
 /**
-  This procedure will update immediate value assigned to a Name
+  This procedure will update immediate value assigned to a Name.
 
   @param[in] AslSignature  - The signature of Operation Region that we 
want to update.
   @param[in] Buffer- source of data to be written over original aml
   @param[in] Length- length of data to be overwritten
 
   @retval EFI_SUCCESS  - The function completed successfully.
+  @retval EFI_NOT_FOUND- Failed to locate AcpiTable.
+  @retval EFI_NOT_READY- Not ready to locate AcpiTable.
 **/
 EFI_STATUS
+EFIAPI
 UpdateNameAslCode (
   IN UINT32AslSignature,
   IN VOID  *Buffer,
@@ -149,11 +208,57 @@ UpdateNameAslCode (
   return EFI_NOT_FOUND;
 }
 
+/**
+  This procedur

[edk2-devel] [edk2-platforms:PATCH v5 7/7] IntelSiliconPkg/DxeAslUpdateLib: Add DxeAslUpdateLib support

2020-05-05 Thread Miki Shindo
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2536

This commit adds DxeAslUpdateLib library support in IntelSiliconPkg,
which allows AML to be updated in DXE.

Signed-off-by: Miki Shindo 
Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Prince Agyeman 
Cc: Ray Ni 
Acked-by: Nate DeSimone 
Reviewed-by: Ray Ni 
Reviewed-by: Sai Chaganty 
Reviewed-by: Chasel Chiu 

---
 Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c   | 
520 

 Silicon/Intel/IntelSiliconPkg/Include/Library/AslUpdateLib.h  | 
116 

 Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec |   
4 
 Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.inf |  
42 ++
 4 files changed, 682 insertions(+)

diff --git 
a/Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c 
b/Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
new file mode 100644
index 00..6bca596b43
--- /dev/null
+++ b/Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
@@ -0,0 +1,520 @@
+/** @file
+  Boot service DXE ASL update library implementation.
+  Note that the current version of the library updates AML.
+
+  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.
+
+  This library uses the ACPI Support protocol.
+
+  Copyright (c) 2020, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+//
+// Function implemenations
+//
+static EFI_ACPI_SDT_PROTOCOL  *mAcpiSdt = NULL;
+static EFI_ACPI_TABLE_PROTOCOL*mAcpiTable = NULL;
+
+/**
+  Initialize the ASL update library state.
+  This must be called at the beggining of the function calls in this library.
+
+  @retval EFI_SUCCESS  - The function completed successfully.
+**/
+EFI_STATUS
+InitializeAslUpdateLib (
+  VOID
+  )
+{
+  EFI_STATUS  Status;
+
+  ///
+  /// Locate ACPI tables
+  ///
+  Status = gBS->LocateProtocol (, NULL, (VOID **) 
);
+  ASSERT_EFI_ERROR (Status);
+  Status = gBS->LocateProtocol (, NULL, (VOID **) 
);
+  ASSERT_EFI_ERROR (Status);
+  return Status;
+}
+
+/**
+  This function calculates and updates an UINT8 checksum.
+
+  @param  Buffer  Pointer to buffer to checksum
+  @param  SizeNumber of bytes to checksum
+  @param  ChecksumOffset  Offset to place the checksum result in
+
+  @retval EFI_SUCCESS  The function completed successfully.
+**/
+EFI_STATUS
+AcpiPlatformChecksum (
+  IN VOID   *Buffer,
+  IN UINTN  Size,
+  IN UINTN  ChecksumOffset
+  )
+{
+  UINT8 Sum;
+  UINT8 *Ptr;
+
+  Sum = 0;
+  //
+  // Initialize pointer
+  //
+  Ptr = Buffer;
+
+  //
+  // set checksum to 0 first
+  //
+  Ptr[ChecksumOffset] = 0;
+
+  //
+  // add all content of buffer
+  //
+  while ((Size--) != 0) {
+Sum = (UINT8) (Sum + (*Ptr++));
+  }
+  //
+  // set checksum
+  //
+  Ptr = Buffer;
+  Ptr[ChecksumOffset] = (UINT8) (0xff - Sum + 1);
+
+  return EFI_SUCCESS;
+}
+
+
+/**
+  This function uses the ACPI SDT protocol to locate an ACPI SSDT table.
+
+  @param[in] TableId   - Pointer to an ASCII string containing the OEM 
Table ID from the ACPI table header
+  @param[in] TableIdSize   - Length of the TableId to match.  Table ID are 
8 bytes long, this function
+ will consider it a match if the first 
TableIdSize bytes match
+  @param[in, out] Table- Updated with a pointer to the table
+  @param[in, out] Handle   - AcpiSupport protocol table handle for the 
table found
+
+  @retval EFI_SUCCESS  - The function completed successfully.
+  @retval EFI_NOT_FOUND- Failed to locate AcpiTable.
+  @retval EFI_NOT_READY- Not ready to locate AcpiTable.
+**/
+EFI_STATUS
+LocateAcpiTableByOemTableId (
+  IN  UINT8 *TableId,
+  IN  UINT8 TableIdSize,
+  IN OUT  EFI_ACPI_DESCRIPTION_HEADER   **Table,
+  IN OUT  UINTN *Handle
+  )
+{
+  EFI_STATUS  Status;
+  INTNIndex;
+  EFI_ACPI_TABLE_VERSION  V

[edk2-devel] [edk2-platforms:PATCH v5 5/7] KabylakeSiliconPkg/DxeAslUpdateLib: Cleans up APIs

2020-05-05 Thread Miki Shindo
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2536

Callers of DxeAslUpdateLib don't have to call InitializeAslUpdateLib()
but the library itself runs it internally. This commit deletes
the redundant calls in caller side and makes it an internal call.
LocateAcpiTableByOemTableId() is unreferenced externally
so this commit makes it an internal call.
PSS_PACKAGE_LAYOUT and AML_RESRC_TEMP_END_TAG are both unreferenced
so they are removed.
AslUpdateLib.h is cleaned up accordingly.

Signed-off-by: Miki Shindo 
Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Prince Agyeman 
Cc: Ray Ni 
Acked-by: Nate DeSimone 
Reviewed-by: Ray Ni 
Reviewed-by: Sai Chaganty 
Reviewed-by: Chasel Chiu 

---
 Silicon/Intel/KabylakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c 
| 213 
+
 
Silicon/Intel/KabylakeSiliconPkg/Library/DxeAslUpdateLibNull/DxeAslUpdateLibNull.c
 | 100 
+++-
 Silicon/Intel/KabylakeSiliconPkg/Pch/PchInit/Dxe/PchAcpi.c 
|   5 +
 Silicon/Intel/KabylakeSiliconPkg/Include/Library/AslUpdateLib.h
| 134 
++
 4 files changed, 227 insertions(+), 225 deletions(-)

diff --git 
a/Silicon/Intel/KabylakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c 
b/Silicon/Intel/KabylakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
index 87c6b15ed2..67507643ea 100644
--- a/Silicon/Intel/KabylakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
+++ b/Silicon/Intel/KabylakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
@@ -6,7 +6,7 @@
 
   This library uses the ACPI Support protocol.
 
-Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2017 - 2020, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -29,7 +29,7 @@ static EFI_ACPI_TABLE_PROTOCOL*mAcpiTable = NULL;
 
 /**
   Initialize the ASL update library state.
-  This must be called prior to invoking other library functions.
+  This must be called at the beggining of the function calls in this library.
 
   @retval EFI_SUCCESS  - The function completed successfully.
 **/
@@ -50,9 +50,65 @@ InitializeAslUpdateLib (
   return Status;
 }
 
+/**
+  This function uses the ACPI SDT protocol to locate an ACPI SSDT table.
+
+  @param[in] TableId   - Pointer to an ASCII string containing the OEM 
Table ID from the ACPI table header
+  @param[in] TableIdSize   - Length of the TableId to match.  Table ID are 
8 bytes long, this function
+ will consider it a match if the first 
TableIdSize bytes match
+  @param[in, out] Table- Updated with a pointer to the table
+  @param[in, out] Handle   - AcpiSupport protocol table handle for the 
table found
+
+  @retval EFI_SUCCESS  - The function completed successfully.
+  @retval EFI_NOT_FOUND- Failed to locate AcpiTable.
+  @retval EFI_NOT_READY- Not ready to locate AcpiTable.
+**/
+EFI_STATUS
+LocateAcpiTableByOemTableId (
+  IN  UINT8 *TableId,
+  IN  UINT8 TableIdSize,
+  IN OUT  EFI_ACPI_DESCRIPTION_HEADER   **Table,
+  IN OUT  UINTN *Handle
+  )
+{
+  EFI_STATUS  Status;
+  INTNIndex;
+  EFI_ACPI_TABLE_VERSION  Version;
+  EFI_ACPI_DESCRIPTION_HEADER *OrgTable;
+
+  if (mAcpiSdt == NULL) {
+InitializeAslUpdateLib ();
+if (mAcpiSdt == NULL) {
+  return EFI_NOT_READY;
+}
+  }
+  ///
+  /// Locate table with matching ID
+  ///
+  Version = 0;
+  Index = 0;
+  do {
+Status = mAcpiSdt->GetAcpiTable (Index, (EFI_ACPI_SDT_HEADER **), 
, Handle);
+if (Status == EFI_NOT_FOUND) {
+  break;
+}
+ASSERT_EFI_ERROR (Status);
+Index++;
+  } while (CompareMem (&(OrgTable->OemTableId), TableId, TableIdSize));
+
+  if (Status != EFI_NOT_FOUND) {
+*Table = AllocateCopyPool (OrgTable->Length, OrgTable);
+ASSERT (*Table);
+  }
+
+  ///
+  /// If we found the table, there will be no error.
+  ///
+  return Status;
+}
 
 /**
-  This procedure will update immediate value assigned to a Name
+  This procedure will update immediate value assigned to a Name.
 
   @param[in] AslSignature  - The signature of Operation Region that we 
want to update.
   @param[in] Buffer- source of data to be written over original aml
@@ -60,8 +116,10 @@ InitializeAslUpdateLib (
 
   @retval EFI_SUCCESS  - The function completed successfully.
   @retval EFI_NOT_FOUND- Failed to loc

[edk2-devel] [edk2-platforms:PATCH v5 1/7] WhiskeylakeOpenBoardPkg/TbtDxe: Removes redundant InitializeAslUpdateLib

2020-05-05 Thread Miki Shindo
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2536

This commit removes redundant InitializeAslUpdateLib call
as DxeAslUpdateLib itself calls it internally.

Signed-off-by: Miki Shindo 
Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Prince Agyeman 
Cc: Ray Ni 
Acked-by: Nate DeSimone 
Reviewed-by: Ray Ni 
Reviewed-by: Sai Chaganty 
Reviewed-by: Chasel Chiu 

---
 Platform/Intel/WhiskeylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c | 5 
+
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git 
a/Platform/Intel/WhiskeylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c 
b/Platform/Intel/WhiskeylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c
index c670f23320..991edfc2c6 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2019, Intel Corporation. All rights reserved.
+  Copyright (c) 2019 - 2020, Intel Corporation. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
@@ -125,9 +125,6 @@ TbtAcpiEndOfDxeCallback (
   UINT16Length;
   UINT32Signature;
 
-  Status = InitializeAslUpdateLib ();
-  ASSERT_EFI_ERROR (Status);
-
   Address = (UINT32) (UINTN) mTbtNvsAreaProtocol.Area;
   Length  = (UINT16) sizeof (TBT_NVS_AREA);
   DEBUG ((DEBUG_INFO, "Patch TBT NvsAreaAddress: TBT NVS Address %x Length 
%x\n", Address, Length));
-- 
2.16.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58675): https://edk2.groups.io/g/devel/message/58675
Mute This Topic: https://groups.io/mt/74013805/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-platforms:PATCH v4 1/7] WhiskeylakeOpenBoardPkg/TbtDxe: Removes redundant InitializeAslUpdateLib

2020-04-28 Thread Miki Shindo
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2536

This commit removes redundant InitializeAslUpdateLib call
as DxeAslUpdateLib itself calls it internally.

Signed-off-by: Miki Shindo 
Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Prince Agyeman 
Cc: Ray Ni 
---
 Platform/Intel/WhiskeylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c | 5 
+
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git 
a/Platform/Intel/WhiskeylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c 
b/Platform/Intel/WhiskeylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c
index c670f23320..991edfc2c6 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2019, Intel Corporation. All rights reserved.
+  Copyright (c) 2019 - 2020, Intel Corporation. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
@@ -125,9 +125,6 @@ TbtAcpiEndOfDxeCallback (
   UINT16Length;
   UINT32Signature;
 
-  Status = InitializeAslUpdateLib ();
-  ASSERT_EFI_ERROR (Status);
-
   Address = (UINT32) (UINTN) mTbtNvsAreaProtocol.Area;
   Length  = (UINT16) sizeof (TBT_NVS_AREA);
   DEBUG ((DEBUG_INFO, "Patch TBT NvsAreaAddress: TBT NVS Address %x Length 
%x\n", Address, Length));
-- 
2.16.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58287): https://edk2.groups.io/g/devel/message/58287
Mute This Topic: https://groups.io/mt/73345582/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-platforms:PATCH v4 7/7] IntelSiliconPkg/DxeAslUpdateLib: Add DxeAslUpdateLib support

2020-04-28 Thread Miki Shindo
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2536

This commit adds DxeAslUpdateLib library support in IntelSiliconPkg,
which allows AML to be updated in DXE.

Signed-off-by: Miki Shindo 
Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Prince Agyeman 
Cc: Ray Ni 
Acked-by: Chasel Chiu 
Acked-by: Nate DeSimone 
---
 Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c   | 
518 
++
 Silicon/Intel/IntelSiliconPkg/Include/Library/AslUpdateLib.h  | 
116 

 Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec |   
4 
 Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.inf |  
42 ++
 4 files changed, 680 insertions(+)

diff --git 
a/Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c 
b/Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
new file mode 100644
index 00..9b3117536a
--- /dev/null
+++ b/Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
@@ -0,0 +1,518 @@
+/** @file
+  Boot service DXE ASL update library implementation.
+  Note that the current version of the library updates AML.
+
+  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.
+
+  This library uses the ACPI Support protocol.
+
+  Copyright (c) 2020, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+//
+// Function implemenations
+//
+static EFI_ACPI_SDT_PROTOCOL  *mAcpiSdt = NULL;
+static EFI_ACPI_TABLE_PROTOCOL*mAcpiTable = NULL;
+
+/**
+  Initialize the ASL update library state.
+  This must be called prior to invoking other library functions.
+
+  @retval EFI_SUCCESS  - The function completed successfully.
+**/
+EFI_STATUS
+InitializeAslUpdateLib (
+  VOID
+  )
+{
+  EFI_STATUS  Status;
+
+  ///
+  /// Locate ACPI tables
+  ///
+  Status = gBS->LocateProtocol (, NULL, (VOID **) 
);
+  ASSERT_EFI_ERROR (Status);
+  Status = gBS->LocateProtocol (, NULL, (VOID **) 
);
+  ASSERT_EFI_ERROR (Status);
+  return Status;
+}
+
+/**
+  This function calculates and updates an UINT8 checksum.
+
+  @param  Buffer  Pointer to buffer to checksum
+  @param  SizeNumber of bytes to checksum
+  @param  ChecksumOffset  Offset to place the checksum result in
+
+  @retval EFI_SUCCESS  The function completed successfully.
+**/
+EFI_STATUS
+AcpiPlatformChecksum (
+  IN VOID   *Buffer,
+  IN UINTN  Size,
+  IN UINTN  ChecksumOffset
+  )
+{
+  UINT8 Sum;
+  UINT8 *Ptr;
+
+  Sum = 0;
+  //
+  // Initialize pointer
+  //
+  Ptr = Buffer;
+
+  //
+  // set checksum to 0 first
+  //
+  Ptr[ChecksumOffset] = 0;
+
+  //
+  // add all content of buffer
+  //
+  while ((Size--) != 0) {
+Sum = (UINT8) (Sum + (*Ptr++));
+  }
+  //
+  // set checksum
+  //
+  Ptr = Buffer;
+  Ptr[ChecksumOffset] = (UINT8) (0xff - Sum + 1);
+
+  return EFI_SUCCESS;
+}
+
+
+/**
+  This function uses the ACPI SDT protocol to locate an ACPI SSDT table.
+
+  @param[in] TableId   - Pointer to an ASCII string containing the OEM 
Table ID from the ACPI table header
+  @param[in] TableIdSize   - Length of the TableId to match.  Table ID are 
8 bytes long, this function
+ will consider it a match if the first 
TableIdSize bytes match
+  @param[in, out] Table- Updated with a pointer to the table
+  @param[in, out] Handle   - AcpiSupport protocol table handle for the 
table found
+
+  @retval EFI_SUCCESS  - The function completed successfully.
+  @retval EFI_NOT_FOUND- Failed to locate AcpiTable.
+  @retval EFI_NOT_READY- Not ready to locate AcpiTable.
+**/
+EFI_STATUS
+LocateAcpiTableByOemTableId (
+  IN  UINT8 *TableId,
+  IN  UINT8 TableIdSize,
+  IN OUT  EFI_ACPI_DESCRIPTION_HEADER   **Table,
+  IN OUT  UINTN *Handle
+  )
+{
+  EFI_STATUS  Status;
+  INTNIndex;
+  EFI_ACPI_TABLE_VERSION  Version;
+  EFI_ACPI_DESCRIPTION_HEADER *OrgTable;
+
+  if (mAcpiSdt =

[edk2-devel] [edk2-platforms:PATCH v4 2/7] KabylakeOpenBoardPkg/TbtDxe: Removes redundant InitializeAslUpdateLib

2020-04-28 Thread Miki Shindo
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2536

This commit removes redundant InitializeAslUpdateLib call
as DxeAslUpdateLib itself calls it internally.

Signed-off-by: Miki Shindo 
Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Prince Agyeman 
Cc: Ray Ni 
---
 Platform/Intel/KabylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git 
a/Platform/Intel/KabylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c 
b/Platform/Intel/KabylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c
index 13a687576c..d101f4bb75 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c
@@ -1,6 +1,6 @@
 /** @file
 
-Copyright (c) 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2018 - 2020, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -125,9 +125,6 @@ TbtAcpiEndOfDxeCallback (
   UINT16Length;
   UINT32Signature;
 
-  Status = InitializeAslUpdateLib ();
-  ASSERT_EFI_ERROR (Status);
-
   Address = (UINT32) (UINTN) mTbtNvsAreaProtocol.Area;
   Length  = (UINT16) sizeof (TBT_NVS_AREA);
   DEBUG ((DEBUG_INFO, "Patch TBT NvsAreaAddress: TBT NVS Address %x Length 
%x\n", Address, Length));
-- 
2.16.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58288): https://edk2.groups.io/g/devel/message/58288
Mute This Topic: https://groups.io/mt/73345583/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-platforms:PATCH v4 6/7] CoffeelakeSiliconPkg/DxeAslUpdateLib: Cleans up APIs

2020-04-28 Thread Miki Shindo
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2536

Callers of DxeAslUpdateLib don't have to call InitializeAslUpdateLib()
but the library itself runs it internally. This commit deletes
the redundant calls in caller side and makes it an internal call.
LocateAcpiTableByOemTableId() is unreferenced externally
so this commit makes it an internal call.
PSS_PACKAGE_LAYOUT and AML_RESRC_TEMP_END_TAG are both unreferenced
so they are removed.
AslUpdateLib.h is cleaned up accordingly.

Signed-off-by: Miki Shindo 
Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Prince Agyeman 
Cc: Ray Ni 
---
 Silicon/Intel/CoffeelakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c   
  | 190 
+++---
 
Silicon/Intel/CoffeelakeSiliconPkg/Library/DxeAslUpdateLibNull/DxeAslUpdateLibNull.c
 |  94 
++
 Silicon/Intel/CoffeelakeSiliconPkg/Pch/PchInit/Dxe/PchAcpi.c   
  |   3 ---
 Silicon/Intel/CoffeelakeSiliconPkg/Include/Library/AslUpdateLib.h  
  | 114 
+++---
 4 files changed, 180 insertions(+), 221 deletions(-)

diff --git 
a/Silicon/Intel/CoffeelakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c 
b/Silicon/Intel/CoffeelakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
index 04cf66fd2f..f18ca835ad 100644
--- 
a/Silicon/Intel/CoffeelakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
+++ 
b/Silicon/Intel/CoffeelakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
@@ -6,7 +6,7 @@
 
   This library uses the ACPI Support protocol.
 
-  Copyright (c) 2019 Intel Corporation. All rights reserved. 
+  Copyright (c) 2019 -2020, Intel Corporation. All rights reserved. 
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
@@ -51,6 +51,62 @@ InitializeAslUpdateLib (
   return Status;
 }
 
+/**
+  This function uses the ACPI SDT protocol to locate an ACPI SSDT table.
+
+  @param[in] TableId   - Pointer to an ASCII string containing the OEM 
Table ID from the ACPI table header
+  @param[in] TableIdSize   - Length of the TableId to match.  Table ID are 
8 bytes long, this function
+ will consider it a match if the first 
TableIdSize bytes match
+  @param[in, out] Table- Updated with a pointer to the table
+  @param[in, out] Handle   - AcpiSupport protocol table handle for the 
table found
+
+  @retval EFI_SUCCESS  - The function completed successfully.
+  @retval EFI_NOT_FOUND- Failed to locate AcpiTable.
+  @retval EFI_NOT_READY- Not ready to locate AcpiTable.
+**/
+EFI_STATUS
+LocateAcpiTableByOemTableId (
+  IN  UINT8 *TableId,
+  IN  UINT8 TableIdSize,
+  IN OUT  EFI_ACPI_DESCRIPTION_HEADER   **Table,
+  IN OUT  UINTN *Handle
+  )
+{
+  EFI_STATUS  Status;
+  INTNIndex;
+  EFI_ACPI_TABLE_VERSION  Version;
+  EFI_ACPI_DESCRIPTION_HEADER *OrgTable;
+
+  if (mAcpiSdt == NULL) {
+InitializeAslUpdateLib ();
+if (mAcpiSdt == NULL) {
+  return EFI_NOT_READY;
+}
+  }
+  ///
+  /// Locate table with matching ID
+  ///
+  Version = 0;
+  Index = 0;
+  do {
+Status = mAcpiSdt->GetAcpiTable (Index, (EFI_ACPI_SDT_HEADER **), 
, Handle);
+if (Status == EFI_NOT_FOUND) {
+  break;
+}
+ASSERT_EFI_ERROR (Status);
+Index++;
+  } while (CompareMem (&(OrgTable->OemTableId), TableId, TableIdSize));
+
+  if (Status != EFI_NOT_FOUND) {
+*Table = AllocateCopyPool (OrgTable->Length, OrgTable);
+ASSERT (*Table);
+  }
+
+  ///
+  /// If we found the table, there will be no error.
+  ///
+  return Status;
+}
 
 /**
   This procedure will update immediate value assigned to a Name
@@ -61,8 +117,10 @@ InitializeAslUpdateLib (
 
   @retval EFI_SUCCESS  - The function completed successfully.
   @retval EFI_NOT_FOUND- Failed to locate AcpiTable.
+  @retval EFI_NOT_READY- Not ready to locate AcpiTable.
 **/
 EFI_STATUS
+EFIAPI
 UpdateNameAslCode (
   IN UINT32AslSignature,
   IN VOID  *Buffer,
@@ -154,6 +212,29 @@ UpdateNameAslCode (
   return EFI_NOT_FOUND;
 }
 
+/**
+  This procedure will update immediate value assigned to a Name in SSDT table
+
+  @param[in] TableId   - Pointer to an ASCII string containing the OEM 
Table ID from the ACPI table header
+  @param[in] TableIdSize   - Length of the TableId to match.  Table ID are 
8 bytes long, this function
+  @param[in] Buffer- source of data to be written over original aml
+  @param[in] Length- l

[edk2-devel] [edk2-platforms:PATCH v4 3/7] CometlakeOpenBoardPkg/TbtDxe: Removes redundant InitializeAslUpdateLib

2020-04-28 Thread Miki Shindo
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2536

This commit removes redundant InitializeAslUpdateLib calls
as DxeAslUpdateLib itself calls it internally.

Signed-off-by: Miki Shindo 
Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Prince Agyeman 
Cc: Ray Ni 
---
 Platform/Intel/CometlakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git 
a/Platform/Intel/CometlakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c 
b/Platform/Intel/CometlakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c
index ef6201de94..e43c5c2fa1 100644
--- a/Platform/Intel/CometlakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c
+++ b/Platform/Intel/CometlakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c
@@ -125,9 +125,6 @@ TbtAcpiEndOfDxeCallback (
   UINT16Length;
   UINT32Signature;
 
-  Status = InitializeAslUpdateLib ();
-  ASSERT_EFI_ERROR (Status);
-
   Address = (UINT32) (UINTN) mTbtNvsAreaProtocol.Area;
   Length  = (UINT16) sizeof (TBT_NVS_AREA);
   DEBUG ((DEBUG_INFO, "Patch TBT NvsAreaAddress: TBT NVS Address %x Length 
%x\n", Address, Length));
-- 
2.16.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58289): https://edk2.groups.io/g/devel/message/58289
Mute This Topic: https://groups.io/mt/73345586/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-platforms:PATCH v4 4/7] MinPlatformPkg/DxeAslUpdateLib: Cleans up APIs

2020-04-28 Thread Miki Shindo
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2536

Callers of DxeAslUpdateLib don't have to call InitializeAslUpdateLib()
but the library itself runs it internally. This commit makes it
an internal call. LocateAcpiTableByOemTableId() is unreferenced externally
so this commit makes it an internal call.
PSS_PACKAGE_LAYOUT and AML_RESRC_TEMP_END_TAG are both unreferenced
so they are removed.
AslUpdateLib.h is cleaned up accordingly.

Signed-off-by: Miki Shindo 
Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Prince Agyeman 
Cc: Ray Ni 
---
 Platform/Intel/MinPlatformPkg/Acpi/Library/DxeAslUpdateLib/DxeAslUpdateLib.c | 
209 
+++--
 Platform/Intel/MinPlatformPkg/Include/Library/AslUpdateLib.h | 
131 
---
 2 files changed, 159 insertions(+), 181 deletions(-)

diff --git 
a/Platform/Intel/MinPlatformPkg/Acpi/Library/DxeAslUpdateLib/DxeAslUpdateLib.c 
b/Platform/Intel/MinPlatformPkg/Acpi/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
index e6ab43db6d..1ba51a7c55 100644
--- 
a/Platform/Intel/MinPlatformPkg/Acpi/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
+++ 
b/Platform/Intel/MinPlatformPkg/Acpi/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
@@ -6,7 +6,7 @@
 
   This library uses the ACPI Support protocol.
 
-Copyright (c) 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2017 - 2020, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -50,6 +50,62 @@ InitializeAslUpdateLib (
   return Status;
 }
 
+/**
+  This function uses the ACPI SDT protocol to locate an ACPI SSDT table.
+
+  @param[in] TableId   - Pointer to an ASCII string containing the OEM 
Table ID from the ACPI table header
+  @param[in] TableIdSize   - Length of the TableId to match.  Table ID are 
8 bytes long, this function
+ will consider it a match if the first 
TableIdSize bytes match
+  @param[in, out] Table- Updated with a pointer to the table
+  @param[in, out] Handle   - AcpiSupport protocol table handle for the 
table found
+
+  @retval EFI_SUCCESS  - The function completed successfully.
+  @retval EFI_NOT_FOUND- Failed to locate AcpiTable.
+  @retval EFI_NOT_READY- Not ready to locate AcpiTable.
+**/
+EFI_STATUS
+LocateAcpiTableByOemTableId (
+  IN  UINT8 *TableId,
+  IN  UINT8 TableIdSize,
+  IN OUT  EFI_ACPI_DESCRIPTION_HEADER   **Table,
+  IN OUT  UINTN *Handle
+  )
+{
+  EFI_STATUS  Status;
+  INTNIndex;
+  EFI_ACPI_TABLE_VERSION  Version;
+  EFI_ACPI_DESCRIPTION_HEADER *OrgTable;
+
+  if (mAcpiSdt == NULL) {
+InitializeAslUpdateLib ();
+if (mAcpiSdt == NULL) {
+  return EFI_NOT_READY;
+}
+  }
+  ///
+  /// Locate table with matching ID
+  ///
+  Version = 0;
+  Index = 0;
+  do {
+Status = mAcpiSdt->GetAcpiTable (Index, (EFI_ACPI_SDT_HEADER **), 
, Handle);
+if (Status == EFI_NOT_FOUND) {
+  break;
+}
+ASSERT_EFI_ERROR (Status);
+Index++;
+  } while (CompareMem (&(OrgTable->OemTableId), TableId, TableIdSize));
+
+  if (Status != EFI_NOT_FOUND) {
+*Table = AllocateCopyPool (OrgTable->Length, OrgTable);
+ASSERT (*Table);
+  }
+
+  ///
+  /// If we found the table, there will be no error.
+  ///
+  return Status;
+}
 
 /**
   This procedure will update immediate value assigned to a Name
@@ -59,8 +115,11 @@ InitializeAslUpdateLib (
   @param[in] Length- length of data to be overwritten
 
   @retval EFI_SUCCESS  - The function completed successfully.
+  @retval EFI_NOT_FOUND- Failed to locate AcpiTable.
+  @retval EFI_NOT_READY- Not ready to locate AcpiTable.
 **/
 EFI_STATUS
+EFIAPI
 UpdateNameAslCode (
   IN UINT32AslSignature,
   IN VOID  *Buffer,
@@ -149,6 +208,50 @@ UpdateNameAslCode (
   return EFI_NOT_FOUND;
 }
 
+/**
+  This procedure will update the name of ASL Method
+
+  @param[in] TableId   - Pointer to an ASCII string containing the OEM 
Table ID from the ACPI table header
+  @param[in] TableIdSize   - Length of the TableId to match.  Table ID are 
8 bytes long, this function
+ will consider it a match if the first 
TableIdSize bytes match
+  @param[in] AslSignature  - The signature of Operation Region that we 
want to update.
+  @param[in] Buffer- source of data to be written over original aml
+  @param[in] Length- length of data to be overwritten
+
+  @retval EFI_UNSUPPORTED  - The function is 

[edk2-devel] [edk2-platforms:PATCH v4 5/7] KabylakeSiliconPkg/DxeAslUpdateLib: Cleans up APIs

2020-04-28 Thread Miki Shindo
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2536

Callers of DxeAslUpdateLib don't have to call InitializeAslUpdateLib()
but the library itself runs it internally. This commit deletes
the redundant calls in caller side and makes it an internal call.
LocateAcpiTableByOemTableId() is unreferenced externally
so this commit makes it an internal call.
PSS_PACKAGE_LAYOUT and AML_RESRC_TEMP_END_TAG are both unreferenced
so they are removed.
AslUpdateLib.h is cleaned up accordingly.

Signed-off-by: Miki Shindo 
Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Prince Agyeman 
Cc: Ray Ni 
---
 Silicon/Intel/KabylakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c 
| 207 
+--
 
Silicon/Intel/KabylakeSiliconPkg/Library/DxeAslUpdateLibNull/DxeAslUpdateLibNull.c
 |  94 
+++---
 Silicon/Intel/KabylakeSiliconPkg/Pch/PchInit/Dxe/PchAcpi.c 
|   5 +
 Silicon/Intel/KabylakeSiliconPkg/Include/Library/AslUpdateLib.h
| 130 
--
 4 files changed, 217 insertions(+), 219 deletions(-)

diff --git 
a/Silicon/Intel/KabylakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c 
b/Silicon/Intel/KabylakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
index 87c6b15ed2..abdb85307f 100644
--- a/Silicon/Intel/KabylakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
+++ b/Silicon/Intel/KabylakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
@@ -6,7 +6,7 @@
 
   This library uses the ACPI Support protocol.
 
-Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2017 - 2020, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -50,6 +50,62 @@ InitializeAslUpdateLib (
   return Status;
 }
 
+/**
+  This function uses the ACPI SDT protocol to locate an ACPI SSDT table.
+
+  @param[in] TableId   - Pointer to an ASCII string containing the OEM 
Table ID from the ACPI table header
+  @param[in] TableIdSize   - Length of the TableId to match.  Table ID are 
8 bytes long, this function
+ will consider it a match if the first 
TableIdSize bytes match
+  @param[in, out] Table- Updated with a pointer to the table
+  @param[in, out] Handle   - AcpiSupport protocol table handle for the 
table found
+
+  @retval EFI_SUCCESS  - The function completed successfully.
+  @retval EFI_NOT_FOUND- Failed to locate AcpiTable.
+  @retval EFI_NOT_READY- Not ready to locate AcpiTable.
+**/
+EFI_STATUS
+LocateAcpiTableByOemTableId (
+  IN  UINT8 *TableId,
+  IN  UINT8 TableIdSize,
+  IN OUT  EFI_ACPI_DESCRIPTION_HEADER   **Table,
+  IN OUT  UINTN *Handle
+  )
+{
+  EFI_STATUS  Status;
+  INTNIndex;
+  EFI_ACPI_TABLE_VERSION  Version;
+  EFI_ACPI_DESCRIPTION_HEADER *OrgTable;
+
+  if (mAcpiSdt == NULL) {
+InitializeAslUpdateLib ();
+if (mAcpiSdt == NULL) {
+  return EFI_NOT_READY;
+}
+  }
+  ///
+  /// Locate table with matching ID
+  ///
+  Version = 0;
+  Index = 0;
+  do {
+Status = mAcpiSdt->GetAcpiTable (Index, (EFI_ACPI_SDT_HEADER **), 
, Handle);
+if (Status == EFI_NOT_FOUND) {
+  break;
+}
+ASSERT_EFI_ERROR (Status);
+Index++;
+  } while (CompareMem (&(OrgTable->OemTableId), TableId, TableIdSize));
+
+  if (Status != EFI_NOT_FOUND) {
+*Table = AllocateCopyPool (OrgTable->Length, OrgTable);
+ASSERT (*Table);
+  }
+
+  ///
+  /// If we found the table, there will be no error.
+  ///
+  return Status;
+}
 
 /**
   This procedure will update immediate value assigned to a Name
@@ -60,8 +116,10 @@ InitializeAslUpdateLib (
 
   @retval EFI_SUCCESS  - The function completed successfully.
   @retval EFI_NOT_FOUND- Failed to locate AcpiTable.
+  @retval EFI_NOT_READY- Not ready to locate AcpiTable.
 **/
 EFI_STATUS
+EFIAPI
 UpdateNameAslCode (
   IN UINT32AslSignature,
   IN VOID  *Buffer,
@@ -155,79 +213,67 @@ UpdateNameAslCode (
   return EFI_NOT_FOUND;
 }
 
-
 /**
-  This function uses the ACPI SDT protocol to locate an ACPI table.
-  It is really only useful for finding tables that only have a single instance,
-  e.g. FADT, FACS, MADT, etc.  It is not good for locating SSDT, etc.
+  This procedure will update the name of ASL Method
 
-  @param[in] Signature   - Pointer to an ASCII string containing the 
OEM Table ID from the ACPI table header
-  @

[edk2-devel] [edk2-platforms:PATCH v4 0/7] IntelSiliconPkg DxeAslUpdateLib support

2020-04-28 Thread Miki Shindo
Patch 7/7 of this series adds DxeAslUpdateLib support in IntelSiliconPkg 
so each project can consume it.
As the existing DxeAslUpdateLib in SiliconPkg have different header files,
this series of patches resolve the inconsistency and avoid build failure.
Also some of unreferenced contents are cleaned up.


Signed-off-by: Miki Shindo 
Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Prince Agyeman 
Cc: Ray Ni 
Acked-by: Chasel Chiu 
Acked-by: Nate DeSimone 


Miki Shindo (7):
  WhiskeylakeOpenBoardPkg/TbtDxe: Removes redundant
InitializeAslUpdateLib
  KabylakeOpenBoardPkg/TbtDxe: Removes redundant InitializeAslUpdateLib
  CometlakeOpenBoardPkg/TbtDxe: Removes redundant InitializeAslUpdateLib
  MinPlatformPkg/DxeAslUpdateLib: Cleans up APIs
  KabylakeSiliconPkg/DxeAslUpdateLib: Cleans up APIs
  CoffeelakeSiliconPkg/DxeAslUpdateLib: Cleans up APIs
  IntelSiliconPkg/DxeAslUpdateLib: Add DxeAslUpdateLib support

 Platform/Intel/CometlakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c 
  |   3 ---
 Platform/Intel/KabylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c  
  |   5 +
 Platform/Intel/MinPlatformPkg/Acpi/Library/DxeAslUpdateLib/DxeAslUpdateLib.c   
  | 209 
+++--
 Platform/Intel/WhiskeylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c   
  |   5 +
 Silicon/Intel/CoffeelakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c   
  | 190 
+++---
 
Silicon/Intel/CoffeelakeSiliconPkg/Library/DxeAslUpdateLibNull/DxeAslUpdateLibNull.c
 |  94 
++
 Silicon/Intel/CoffeelakeSiliconPkg/Pch/PchInit/Dxe/PchAcpi.c   
  |   3 ---
 Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
  | 518 
++
 Silicon/Intel/KabylakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c 
  | 207 
+--
 
Silicon/Intel/KabylakeSiliconPkg/Library/DxeAslUpdateLibNull/DxeAslUpdateLibNull.c
   |  94 
+++---
 Silicon/Intel/KabylakeSiliconPkg/Pch/PchInit/Dxe/PchAcpi.c 
  |   5 +
 Platform/Intel/MinPlatformPkg/Include/Library/AslUpdateLib.h   
  | 131 
---
 Silicon/Intel/CoffeelakeSiliconPkg/Include/Library/AslUpdateLib.h  
  | 114 
+++---
 Silicon/Intel/IntelSiliconPkg/Include/Library/AslUpdateLib.h   
  | 116 

 Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec  
  |   4 
 Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.inf  
  |  42 ++
 Silicon/Intel/KabylakeSiliconPkg/Include/Library/AslUpdateLib.h
  | 130 
--
 17 files changed, 1238 insertions(+), 632 deletions(-)
 create mode 100644 
Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
 create mode 100644 Silicon/Intel/IntelSiliconPkg/Include/Library/AslUpdateLib.h
 create mode 100644 
Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.inf

-- 
2.16.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58286): https://edk2.groups.io/g/devel/message/58286
Mute This Topic: https://groups.io/mt/73345581/21656
Group Owner: devel+ow

[edk2-devel] [edk2-platforms:PATCH v3] IntelSiliconPkg/DxeAslUpdateLib: Add DxeAslUpdateLib support

2020-04-06 Thread Miki Shindo
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2536

This commit adds DxeAslUpdateLib library support in IntelSiliconPkg,
which allows AML to be updated in DXE.

Signed-off-by: Miki Shindo 
Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Prince Agyeman 
Cc: Ray Ni 
Acked-by: Chasel Chiu 
Acked-by: Nate DeSimone 
Reviewed-by: Ray Ni 
---
 Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c   | 
512 

 Silicon/Intel/IntelSiliconPkg/Include/Library/AslUpdateLib.h  | 
106 
++
 Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec |   
4 
 Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.inf |  
42 ++
 4 files changed, 664 insertions(+)

diff --git 
a/Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c 
b/Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
new file mode 100644
index 00..4e031b0edd
--- /dev/null
+++ b/Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
@@ -0,0 +1,512 @@
+/** @file
+  Boot service DXE ASL update library implementation.
+  Note that the current version of the library updates AML.
+
+  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.
+
+  This library uses the ACPI Support protocol.
+
+  Copyright (c) 2020, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+//
+// Function implemenations
+//
+static EFI_ACPI_SDT_PROTOCOL  *mAcpiSdt = NULL;
+static EFI_ACPI_TABLE_PROTOCOL*mAcpiTable = NULL;
+
+/**
+  Initialize the ASL update library state.
+  This must be called prior to invoking other library functions.
+
+  @retval EFI_SUCCESS  - The function completed successfully.
+**/
+EFI_STATUS
+InitializeAslUpdateLib (
+  VOID
+  )
+{
+  EFI_STATUS  Status;
+
+  ///
+  /// Locate ACPI tables
+  ///
+  Status = gBS->LocateProtocol (, NULL, (VOID **) 
);
+  ASSERT_EFI_ERROR (Status);
+  Status = gBS->LocateProtocol (, NULL, (VOID **) 
);
+  ASSERT_EFI_ERROR (Status);
+  return Status;
+}
+
+/**
+  This function calculates and updates an UINT8 checksum.
+
+  @param  Buffer  Pointer to buffer to checksum
+  @param  SizeNumber of bytes to checksum
+  @param  ChecksumOffset  Offset to place the checksum result in
+
+  @return EFI_SUCCESS The function completed successfully.
+
+**/
+EFI_STATUS
+AcpiPlatformChecksum (
+  IN VOID   *Buffer,
+  IN UINTN  Size,
+  IN UINTN  ChecksumOffset
+  )
+{
+  UINT8 Sum;
+  UINT8 *Ptr;
+
+  Sum = 0;
+  //
+  // Initialize pointer
+  //
+  Ptr = Buffer;
+
+  //
+  // set checksum to 0 first
+  //
+  Ptr[ChecksumOffset] = 0;
+
+  //
+  // add all content of buffer
+  //
+  while ((Size--) != 0) {
+Sum = (UINT8) (Sum + (*Ptr++));
+  }
+  //
+  // set checksum
+  //
+  Ptr = Buffer;
+  Ptr[ChecksumOffset] = (UINT8) (0xff - Sum + 1);
+
+  return EFI_SUCCESS;
+}
+
+/**
+  This procedure will update immediate value assigned to a Name
+
+  @param[in] AslSignature  - The signature of Operation Region that we 
want to update.
+  @param[in] Buffer- source of data to be written over original aml
+  @param[in] Length- length of data to be overwritten
+
+  @retval EFI_SUCCESS  - The function completed successfully.
+  @retval EFI_NOT_FOUND- Failed to locate AcpiTable.
+**/
+EFIAPI
+EFI_STATUS
+UpdateNameAslCode (
+  IN UINT32   AslSignature,
+  IN VOID *Buffer,
+  IN UINTNLength
+  )
+{
+  EFI_STATUS  Status;
+  EFI_ACPI_DESCRIPTION_HEADER *Table;
+  UINT8   *CurrPtr;
+  UINT8   *EndPtr;
+  UINT32  *Signature;
+  UINT8   *DsdtPointer;
+  UINTN   Handle;
+  UINT8   DataSize;
+
+  if (mAcpiTable == NULL) {
+InitializeAslUpdateLib ();
+if (mAcpiTable == NULL) {
+  return EFI_NOT_READY;
+}
+  }
+
+  ///
+  /// Locate table with matching ID
+  ///
+  Handle = 0;
+  Status = LocateAcpiTableBySig

[edk2-devel] [edk2-platform:PATCH v2] IntelSiliconPkg/DxeAslUpdateLib: Add DxeAslUpdateLib support

2020-03-05 Thread Miki Shindo
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2536

This commit adds DxeAslUpdateLib library support in IntelSiliconPkg,
which allows AML to be updated in DXE.

Signed-off-by: Miki Shindo 
Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Prince Agyeman 
Cc: Ray Ni 
Reviewed-by: Chasel Chiu 
---
 Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c   | 
553 
+
 Silicon/Intel/IntelSiliconPkg/Include/Library/AslUpdateLib.h  | 
178 
++
 Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec |   
4 
 Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.inf |  
42 ++
 4 files changed, 777 insertions(+)

diff --git 
a/Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c 
b/Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
new file mode 100644
index 00..1eae8bca62
--- /dev/null
+++ b/Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
@@ -0,0 +1,553 @@
+/** @file
+  Boot service DXE ASL update library implementation.
+  Note that the current version of the library updates AML.
+
+  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.
+
+  This library uses the ACPI Support protocol.
+
+  Copyright (c) 2020, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+//
+// Function implemenations
+//
+static EFI_ACPI_SDT_PROTOCOL  *mAcpiSdt = NULL;
+static EFI_ACPI_TABLE_PROTOCOL*mAcpiTable = NULL;
+
+/**
+  Initialize the ASL update library state.
+  This must be called prior to invoking other library functions.
+
+  @retval EFI_SUCCESS  - The function completed successfully.
+**/
+EFI_STATUS
+InitializeAslUpdateLib (
+  VOID
+  )
+{
+  EFI_STATUS  Status;
+
+  ///
+  /// Locate ACPI tables
+  ///
+  Status = gBS->LocateProtocol (, NULL, (VOID **) 
);
+  ASSERT_EFI_ERROR (Status);
+  Status = gBS->LocateProtocol (, NULL, (VOID **) 
);
+  ASSERT_EFI_ERROR (Status);
+  return Status;
+}
+
+/**
+  This function calculates and updates an UINT8 checksum.
+
+  @param  Buffer  Pointer to buffer to checksum
+  @param  SizeNumber of bytes to checksum
+  @param  ChecksumOffset  Offset to place the checksum result in
+
+  @return EFI_SUCCESS The function completed successfully.
+
+**/
+EFI_STATUS
+AcpiPlatformChecksum (
+  IN VOID   *Buffer,
+  IN UINTN  Size,
+  IN UINTN  ChecksumOffset
+  )
+{
+  UINT8 Sum;
+  UINT8 *Ptr;
+
+  Sum = 0;
+  //
+  // Initialize pointer
+  //
+  Ptr = Buffer;
+
+  //
+  // set checksum to 0 first
+  //
+  Ptr[ChecksumOffset] = 0;
+
+  //
+  // add all content of buffer
+  //
+  while ((Size--) != 0) {
+Sum = (UINT8) (Sum + (*Ptr++));
+  }
+  //
+  // set checksum
+  //
+  Ptr = Buffer;
+  Ptr[ChecksumOffset] = (UINT8) (0xff - Sum + 1);
+
+  return EFI_SUCCESS;
+}
+
+/**
+  This procedure will update immediate value assigned to a Name
+
+  @param[in] AslSignature  - The signature of Operation Region that we 
want to update.
+  @param[in] Buffer- source of data to be written over original aml
+  @param[in] Length- length of data to be overwritten
+
+  @retval EFI_SUCCESS  - The function completed successfully.
+  @retval EFI_NOT_FOUND- Failed to locate AcpiTable.
+**/
+EFI_STATUS
+UpdateNameAslCode (
+  IN UINT32   AslSignature,
+  IN VOID *Buffer,
+  IN UINTNLength
+  )
+{
+  EFI_STATUS  Status;
+  EFI_ACPI_DESCRIPTION_HEADER *Table;
+  UINT8   *CurrPtr;
+  UINT8   *EndPtr;
+  UINT32  *Signature;
+  UINT8   *DsdtPointer;
+  UINTN   Handle;
+  UINT8   DataSize;
+
+  if (mAcpiTable == NULL) {
+InitializeAslUpdateLib ();
+if (mAcpiTable == NULL) {
+  return EFI_NOT_READY;
+}
+  }
+
+  ///
+  /// Locate table with matching ID
+  ///
+  

Re: [edk2-devel] [edk2-platform:PATCH v2] MinPlatformPkg/PeiReportFvLib: Remove redundant Fsp Fv installation

2020-03-02 Thread Miki Shindo
Thanks for the feedback. I will send V3 patch. 
I also make that correction in closed source. 

-Original Message-
From: Chiu, Chasel  
Sent: Monday, March 2, 2020 7:59 PM
To: Shindo, Miki ; devel@edk2.groups.io
Cc: Chaganty, Rangasai V ; Desimone, Nathaniel L 
; Agyeman, Prince 
Subject: RE: [edk2-platform:PATCH v2] MinPlatformPkg/PeiReportFvLib: Remove 
redundant Fsp Fv installation


Hi Shindo,

Please see my comments below inline.
With that updated: Reviewed-by: Chasel Chiu 

Thanks,
Chasel


> -Original Message-
> From: Shindo, Miki 
> Sent: Tuesday, March 3, 2020 9:50 AM
> To: devel@edk2.groups.io
> Cc: Chaganty, Rangasai V ; Chiu, Chasel 
> ; Desimone, Nathaniel L 
> ; Agyeman, Prince 
> 
> Subject: [edk2-platform:PATCH v2] MinPlatformPkg/PeiReportFvLib: 
> Remove redundant Fsp Fv installation
> 
> REF : https://bugzilla.tianocore.org/show_bug.cgi?id=2542
> 
> ReportPreMemFv () has redundant calls to install Fsp FVs.
> FSP-M, S, U FVs do not need to be installed when Fsp Wrapper Boot Mode 
> is disabled.
> 
> Signed-off-by: Miki Shindo 
> Cc: Sai Chaganty 
> Cc: Chasel Chiu 
> Cc: Nate DeSimone 
> Cc: Prince Agyeman 
> ---
> 
> Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReport
> FvLib.c   | 38 +++---
> 
> Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiR
> eport
> FvLib.inf |  6 --
>  2 files changed, 7 insertions(+), 37 deletions(-)
> 
> diff --git
> a/Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/Pe
> iRep
> ortFvLib.c
> b/Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/Pe
> iRep
> ortFvLib.c
> index 6158fc9412..1fad384cd6 100644
> ---
> a/Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/Pe
> iRep
> ortFvLib.c
> +++ b/Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLi
> +++ b/
> +++ PeiReportFvLib.c
> @@ -20,17 +20,9 @@ ReportPreMemFv (
>VOID
>)
>  {
> -  if (!PcdGetBool(PcdFspWrapperBootMode)) {
> -DEBUG ((DEBUG_INFO, "Install FlashFvFspM - 0x%x, 0x%x\n", PcdGet32
> (PcdFlashFvFspMBase), PcdGet32 (PcdFlashFvFspMSize)));
> -PeiServicesInstallFvInfo2Ppi (
> -  &(((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32
> (PcdFlashFvFspMBase))->FileSystemGuid),
> -  (VOID *) (UINTN) PcdGet32 (PcdFlashFvFspMBase),
> -  PcdGet32 (PcdFlashFvFspMSize),
> -  NULL,
> -  NULL,
> -  0
> -  );
> -  }
> +  ///
> +  /// Note : FSP FVs except FSP-T FV are installed in 
> + IntelFsp2Wrapper Pkg or
> FspPkg in Dispatch mode.
> +  ///


In Dispatch mode FSP FVs will be installed by IntelFsp2WrapperPkg, not FspPkg, 
please correct comments for PostMem phase too.


>if (PcdGetBool(PcdFspWrapperBootMode)) {
>  DEBUG ((DEBUG_INFO, "Install FlashFvFspT - 0x%x, 0x%x\n", 
> PcdGet32 (PcdFlashFvFspTBase), PcdGet32 (PcdFlashFvFspTSize)));
>  PeiServicesInstallFvInfo2Ppi (
> @@ -80,6 +72,10 @@ ReportPostMemFv (
>Status = PeiServicesGetBootMode ();
>ASSERT_EFI_ERROR (Status);
> 
> +  ///
> +  /// Note : FSP FVs except FSP-T FV are installed in 
> + IntelFsp2Wrapper Pkg or
> FspPkg in Dispatch mode.
> +  ///
> +
>///
>/// Build HOB for DXE
>///
> @@ -97,26 +93,6 @@ ReportPostMemFv (
>NULL,
>0
>);
> -if (!PcdGetBool(PcdFspWrapperBootMode)) {
> -  DEBUG ((DEBUG_INFO, "Install FlashFvFspS - 0x%x, 0x%x\n",
> PcdGet32 (PcdFlashFvFspSBase), PcdGet32 (PcdFlashFvFspSSize)));
> -  PeiServicesInstallFvInfo2Ppi (
> -&(((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32
> (PcdFlashFvFspSBase))->FileSystemGuid),
> -(VOID *) (UINTN) PcdGet32 (PcdFlashFvFspSBase),
> -PcdGet32 (PcdFlashFvFspSSize),
> -NULL,
> -NULL,
> -0
> -);
> -  DEBUG ((DEBUG_INFO, "Install FlashFvFspU - 0x%x, 0x%x\n",
> PcdGet32 (PcdFlashFvFspUBase), PcdGet32 (PcdFlashFvFspUSize)));
> -  PeiServicesInstallFvInfo2Ppi (
> -&(((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32
> (PcdFlashFvFspUBase))->FileSystemGuid),
> -(VOID *) (UINTN) PcdGet32 (PcdFlashFvFspUBase),
> -PcdGet32 (PcdFlashFvFspUSize),
> -NULL,
> -NULL,
> -0
> -);
> -}
>  DEBUG ((DEBUG_INFO, "Install FlashFvUefiBoot - 0x%x, 0x%x\n",
> PcdGet32 (PcdFlashFvUefiBootBase), PcdGet32 (PcdFlashFvUefiBootSize)));
>  PeiServicesInstallFvInfo2Ppi (
>&(((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 
> (PcdFlashFvUefiBootBase))->FileSystemGuid),
> diff --git
> a/Platform

[edk2-devel] [edk2-platform:PATCH v2] MinPlatformPkg/PeiReportFvLib: Remove redundant Fsp Fv installation

2020-03-02 Thread Miki Shindo
REF : https://bugzilla.tianocore.org/show_bug.cgi?id=2542

ReportPreMemFv () has redundant calls to install Fsp FVs.
FSP-M, S, U FVs do not need to be installed
when Fsp Wrapper Boot Mode is disabled.

Signed-off-by: Miki Shindo 
Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Prince Agyeman 
---
 
Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.c
   | 38 +++---
 
Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.inf
 |  6 --
 2 files changed, 7 insertions(+), 37 deletions(-)

diff --git 
a/Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.c
 
b/Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.c
index 6158fc9412..1fad384cd6 100644
--- 
a/Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.c
+++ 
b/Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.c
@@ -20,17 +20,9 @@ ReportPreMemFv (
   VOID
   )
 {
-  if (!PcdGetBool(PcdFspWrapperBootMode)) {
-DEBUG ((DEBUG_INFO, "Install FlashFvFspM - 0x%x, 0x%x\n", PcdGet32 
(PcdFlashFvFspMBase), PcdGet32 (PcdFlashFvFspMSize)));
-PeiServicesInstallFvInfo2Ppi (
-  &(((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 
(PcdFlashFvFspMBase))->FileSystemGuid),
-  (VOID *) (UINTN) PcdGet32 (PcdFlashFvFspMBase),
-  PcdGet32 (PcdFlashFvFspMSize),
-  NULL,
-  NULL,
-  0
-  );
-  }
+  ///
+  /// Note : FSP FVs except FSP-T FV are installed in IntelFsp2Wrapper Pkg or 
FspPkg in Dispatch mode.
+  ///
   if (PcdGetBool(PcdFspWrapperBootMode)) {
 DEBUG ((DEBUG_INFO, "Install FlashFvFspT - 0x%x, 0x%x\n", PcdGet32 
(PcdFlashFvFspTBase), PcdGet32 (PcdFlashFvFspTSize)));
 PeiServicesInstallFvInfo2Ppi (
@@ -80,6 +72,10 @@ ReportPostMemFv (
   Status = PeiServicesGetBootMode ();
   ASSERT_EFI_ERROR (Status);
 
+  ///
+  /// Note : FSP FVs except FSP-T FV are installed in IntelFsp2Wrapper Pkg or 
FspPkg in Dispatch mode.
+  ///
+
   ///
   /// Build HOB for DXE
   ///
@@ -97,26 +93,6 @@ ReportPostMemFv (
   NULL,
   0
   );
-if (!PcdGetBool(PcdFspWrapperBootMode)) {
-  DEBUG ((DEBUG_INFO, "Install FlashFvFspS - 0x%x, 0x%x\n", PcdGet32 
(PcdFlashFvFspSBase), PcdGet32 (PcdFlashFvFspSSize)));
-  PeiServicesInstallFvInfo2Ppi (
-&(((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 
(PcdFlashFvFspSBase))->FileSystemGuid),
-(VOID *) (UINTN) PcdGet32 (PcdFlashFvFspSBase),
-PcdGet32 (PcdFlashFvFspSSize),
-NULL,
-NULL,
-0
-);
-  DEBUG ((DEBUG_INFO, "Install FlashFvFspU - 0x%x, 0x%x\n", PcdGet32 
(PcdFlashFvFspUBase), PcdGet32 (PcdFlashFvFspUSize)));
-  PeiServicesInstallFvInfo2Ppi (
-&(((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 
(PcdFlashFvFspUBase))->FileSystemGuid),
-(VOID *) (UINTN) PcdGet32 (PcdFlashFvFspUBase),
-PcdGet32 (PcdFlashFvFspUSize),
-NULL,
-NULL,
-0
-);
-}
 DEBUG ((DEBUG_INFO, "Install FlashFvUefiBoot - 0x%x, 0x%x\n", PcdGet32 
(PcdFlashFvUefiBootBase), PcdGet32 (PcdFlashFvUefiBootSize)));
 PeiServicesInstallFvInfo2Ppi (
   &(((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 
(PcdFlashFvUefiBootBase))->FileSystemGuid),
diff --git 
a/Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.inf
 
b/Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.inf
index 79cd5ee1f7..4258d0f2e7 100644
--- 
a/Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.inf
+++ 
b/Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.inf
@@ -34,14 +34,8 @@
   gMinPlatformPkgTokenSpaceGuid.PcdFspWrapperBootMode ## CONSUMES
   gMinPlatformPkgTokenSpaceGuid.PcdFlashAreaBaseAddress   ## CONSUMES
   gMinPlatformPkgTokenSpaceGuid.PcdFlashAreaSize  ## CONSUMES
-  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspMBase## CONSUMES
-  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspMSize## CONSUMES
   gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspTBase## CONSUMES
   gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspTSize## CONSUMES
-  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspSBase## CONSUMES
-  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspSSize## CONSUMES
-  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUBase## CONSUMES
-  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUSize## CONSUMES
   gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPostMemoryBase  ## CONSUMES
   gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPostMemorySize  ## CONSUMES
   gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootBase## CONSUMES
-- 
2.16.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io 

[edk2-devel] [edk2-platforms:PATCH] MinPlatformPkg/PeiReportFvLib: Remove redundant Fsp Fv installation

2020-03-02 Thread Miki Shindo
REF : https://bugzilla.tianocore.org/show_bug.cgi?id=2542

ReportPreMemFv () has redundant calls to install Fsp FVs.
FSP-M, S, U FVs do not need to be installed
when Fsp Wrapper Boot Mode is disabled.

Signed-off-by: Miki Shindo 
Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Prince Agyeman 
---
 
Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.c
   | 38 +++---
 
Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.inf
 |  6 --
 2 files changed, 7 insertions(+), 37 deletions(-)

diff --git 
a/Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.c
 
b/Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.c
index 6158fc9412..95e3c88275 100644
--- 
a/Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.c
+++ 
b/Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.c
@@ -20,17 +20,9 @@ ReportPreMemFv (
   VOID
   )
 {
-  if (!PcdGetBool(PcdFspWrapperBootMode)) {
-DEBUG ((DEBUG_INFO, "Install FlashFvFspM - 0x%x, 0x%x\n", PcdGet32 
(PcdFlashFvFspMBase), PcdGet32 (PcdFlashFvFspMSize)));
-PeiServicesInstallFvInfo2Ppi (
-  &(((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 
(PcdFlashFvFspMBase))->FileSystemGuid),
-  (VOID *) (UINTN) PcdGet32 (PcdFlashFvFspMBase),
-  PcdGet32 (PcdFlashFvFspMSize),
-  NULL,
-  NULL,
-  0
-  );
-  }
+  /*
+Note : FSP FVs are installed in IntelFsp2Wrapper Pkg or FspPkg in Dispatch 
mode.
+  */
   if (PcdGetBool(PcdFspWrapperBootMode)) {
 DEBUG ((DEBUG_INFO, "Install FlashFvFspT - 0x%x, 0x%x\n", PcdGet32 
(PcdFlashFvFspTBase), PcdGet32 (PcdFlashFvFspTSize)));
 PeiServicesInstallFvInfo2Ppi (
@@ -80,6 +72,10 @@ ReportPostMemFv (
   Status = PeiServicesGetBootMode ();
   ASSERT_EFI_ERROR (Status);
 
+  /*
+Note : FSP FVs are installed in IntelFsp2Wrapper Pkg or FspPkg in Dispatch 
mode.
+  */
+
   ///
   /// Build HOB for DXE
   ///
@@ -97,26 +93,6 @@ ReportPostMemFv (
   NULL,
   0
   );
-if (!PcdGetBool(PcdFspWrapperBootMode)) {
-  DEBUG ((DEBUG_INFO, "Install FlashFvFspS - 0x%x, 0x%x\n", PcdGet32 
(PcdFlashFvFspSBase), PcdGet32 (PcdFlashFvFspSSize)));
-  PeiServicesInstallFvInfo2Ppi (
-&(((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 
(PcdFlashFvFspSBase))->FileSystemGuid),
-(VOID *) (UINTN) PcdGet32 (PcdFlashFvFspSBase),
-PcdGet32 (PcdFlashFvFspSSize),
-NULL,
-NULL,
-0
-);
-  DEBUG ((DEBUG_INFO, "Install FlashFvFspU - 0x%x, 0x%x\n", PcdGet32 
(PcdFlashFvFspUBase), PcdGet32 (PcdFlashFvFspUSize)));
-  PeiServicesInstallFvInfo2Ppi (
-&(((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 
(PcdFlashFvFspUBase))->FileSystemGuid),
-(VOID *) (UINTN) PcdGet32 (PcdFlashFvFspUBase),
-PcdGet32 (PcdFlashFvFspUSize),
-NULL,
-NULL,
-0
-);
-}
 DEBUG ((DEBUG_INFO, "Install FlashFvUefiBoot - 0x%x, 0x%x\n", PcdGet32 
(PcdFlashFvUefiBootBase), PcdGet32 (PcdFlashFvUefiBootSize)));
 PeiServicesInstallFvInfo2Ppi (
   &(((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 
(PcdFlashFvUefiBootBase))->FileSystemGuid),
diff --git 
a/Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.inf
 
b/Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.inf
index 79cd5ee1f7..4258d0f2e7 100644
--- 
a/Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.inf
+++ 
b/Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.inf
@@ -34,14 +34,8 @@
   gMinPlatformPkgTokenSpaceGuid.PcdFspWrapperBootMode ## CONSUMES
   gMinPlatformPkgTokenSpaceGuid.PcdFlashAreaBaseAddress   ## CONSUMES
   gMinPlatformPkgTokenSpaceGuid.PcdFlashAreaSize  ## CONSUMES
-  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspMBase## CONSUMES
-  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspMSize## CONSUMES
   gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspTBase## CONSUMES
   gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspTSize## CONSUMES
-  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspSBase## CONSUMES
-  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspSSize## CONSUMES
-  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUBase## CONSUMES
-  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUSize## CONSUMES
   gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPostMemoryBase  ## CONSUMES
   gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPostMemorySize  ## CONSUMES
   gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootBase## CONSUMES
-- 
2.16.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages s

[edk2-devel] [edk2-platforms: PATCH] MinPlatformPkg/PeiReportFvLib: Install FvFspT in PeiReportFvLib

2020-02-24 Thread Miki Shindo
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2410

TPM measurements in PEI runs on FV_INFO_PPI notification function.
Currently FvFspT is not installed so it is not measured by TPM.
This commit makes FvFspT installed by FV_INFO_PPI so the
measurement would run for FvFspT. FvFspT code actually runs,
it has to be measured.

Signed-off-by: Miki Shindo 
Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Prince Agyeman 
---
 .../Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.c  
 | 13 -
 
.../Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.inf 
|  4 +++-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git 
a/Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.c
 
b/Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.c
index 0d805d6fe7..6158fc9412 100644
--- 
a/Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.c
+++ 
b/Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.c
@@ -1,7 +1,7 @@
 /** @file
   Source code file for Report Firmware Volume (FV) library
 
-Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2018 - 2020, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -31,6 +31,17 @@ ReportPreMemFv (
   0
   );
   }
+  if (PcdGetBool(PcdFspWrapperBootMode)) {
+DEBUG ((DEBUG_INFO, "Install FlashFvFspT - 0x%x, 0x%x\n", PcdGet32 
(PcdFlashFvFspTBase), PcdGet32 (PcdFlashFvFspTSize)));
+PeiServicesInstallFvInfo2Ppi (
+  &(((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 
(PcdFlashFvFspTBase))->FileSystemGuid),
+  (VOID *) (UINTN) PcdGet32 (PcdFlashFvFspTBase),
+  PcdGet32 (PcdFlashFvFspTSize),
+  NULL,
+  NULL,
+  0
+  );
+  }
   DEBUG ((DEBUG_INFO, "Install FlashFvSecurity - 0x%x, 0x%x\n", PcdGet32 
(PcdFlashFvSecurityBase), PcdGet32 (PcdFlashFvSecuritySize)));
   PeiServicesInstallFvInfo2Ppi (
 &(((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 
(PcdFlashFvSecurityBase))->FileSystemGuid),
diff --git 
a/Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.inf
 
b/Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.inf
index ef03e110bd..79cd5ee1f7 100644
--- 
a/Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.inf
+++ 
b/Platform/Intel/MinPlatformPkg/PlatformInit/Library/PeiReportFvLib/PeiReportFvLib.inf
@@ -1,7 +1,7 @@
 ### @file
 # Component information file for the Report Firmware Volume (FV) library.
 #
-# Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2018 - 2020, Intel Corporation. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -36,6 +36,8 @@
   gMinPlatformPkgTokenSpaceGuid.PcdFlashAreaSize  ## CONSUMES
   gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspMBase## CONSUMES
   gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspMSize## CONSUMES
+  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspTBase## CONSUMES
+  gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspTSize## CONSUMES
   gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspSBase## CONSUMES
   gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspSSize## CONSUMES
   gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUBase## CONSUMES
-- 
2.16.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#54755): https://edk2.groups.io/g/devel/message/54755
Mute This Topic: https://groups.io/mt/71508030/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-