public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2] IntelSiliconPkg/BaseConfigBlockLib: Add function to iterate over Config Blocks
@ 2022-03-03 11:43 Fedorowicz, Jakub
  0 siblings, 0 replies; 3+ messages in thread
From: Fedorowicz, Jakub @ 2022-03-03 11:43 UTC (permalink / raw)
  To: devel@edk2.groups.io; +Cc: Ni, Ray, Chaganty, Rangasai V

[-- Attachment #1: Type: text/plain, Size: 6344 bytes --]

In BaseConfigBlockLib add function to get next config block from config blocks table in order to iterate over blocks of the same GUID.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3700
Cc: Ray Ni ray.ni@intel.com<mailto:ray.ni@intel.com>
Cc: Rangasai V Chaganty rangasai.v.chaganty@intel.com<mailto:rangasai.v.chaganty@intel.com>
Signed-off-by: Jakub Fedorowicz jakub.fedorowicz@intel.com<mailto:jakub.fedorowicz@intel.com>
---
.../Include/Library/ConfigBlockLib.h          | 20 +++++++
.../BaseConfigBlockLib/BaseConfigBlockLib.c   | 54 ++++++++++++++++---
2 files changed, 68 insertions(+), 6 deletions(-)

diff --git a/Silicon/Intel/IntelSiliconPkg/Include/Library/ConfigBlockLib.h b/Silicon/Intel/IntelSiliconPkg/Include/Library/ConfigBlockLib.h
index 37a396816..64a13bca9 100644
--- a/Silicon/Intel/IntelSiliconPkg/Include/Library/ConfigBlockLib.h
+++ b/Silicon/Intel/IntelSiliconPkg/Include/Library/ConfigBlockLib.h
@@ -9,6 +9,8 @@
#ifndef _CONFIG_BLOCK_LIB_H_
#define _CONFIG_BLOCK_LIB_H_
+#include <ConfigBlock.h>
+
/**
   Create config block table.
@@ -61,4 +63,22 @@ GetConfigBlock (
   OUT    VOID      **ConfigBlockAddress
   );
+/**
+  Search through ConfigBlockTable blocks to find following Config Block of given GUID.
+  If there is no such following Config Block found until the end of the table, return EFI_NOT_FOUND.
+
+  @param[in]    ConfigBlockTable  A pointer to the beginning of Config Block Table
+  @param[in]    ConfigBlock       A pointer to the Config Block, against which the search begins
+  @param[in]    TargetGuid        A pointer to the Guid of Config Block to find
+
+  @return                         Pointer to config block, or NULL if config block of given guid was not found
+**/
+CONFIG_BLOCK*
+EFIAPI
+GetNextConfigBlock (
+  IN CONFIG_BLOCK_TABLE_HEADER    *ConfigBlockTable,
+  IN CONFIG_BLOCK                 *ConfigBlock,
+  IN EFI_GUID                     *TargetGuid
+  );
+
#endif // _CONFIG_BLOCK_LIB_H_
diff --git a/Silicon/Intel/IntelSiliconPkg/Library/BaseConfigBlockLib/BaseConfigBlockLib.c b/Silicon/Intel/IntelSiliconPkg/Library/BaseConfigBlockLib/BaseConfigBlockLib.c
index c89699ea4..30847d561 100644
--- a/Silicon/Intel/IntelSiliconPkg/Library/BaseConfigBlockLib/BaseConfigBlockLib.c
+++ b/Silicon/Intel/IntelSiliconPkg/Library/BaseConfigBlockLib/BaseConfigBlockLib.c
@@ -5,7 +5,6 @@ Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
-#include <ConfigBlock.h>
#include <Library/ConfigBlockLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
@@ -14,12 +13,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
/**
   Create config block table.
-  @param[in]     TotalSize                    - Max size to be allocated for the Config Block Table
-  @param[out]    ConfigBlockTableAddress      - On return, points to a pointer to the beginning of Config Block Table Address
+  @param[in]     TotalSize                Max size to be allocated for the Config Block Table
+  @param[out]    ConfigBlockTableAddress  On return, points to a pointer to the beginning of Config Block Table Address
-  @retval EFI_INVALID_PARAMETER - Invalid Parameter
-  @retval EFI_OUT_OF_RESOURCES  - Out of resources
-  @retval EFI_SUCCESS           - Successfully created Config Block Table at ConfigBlockTableAddress
+  @retval EFI_INVALID_PARAMETER           Invalid Parameter
+  @retval EFI_OUT_OF_RESOURCES            Out of resources
+  @retval EFI_SUCCESS                     Successfully created Config Block Table at ConfigBlockTableAddress
**/
EFI_STATUS
EFIAPI
@@ -137,3 +136,46 @@ GetConfigBlock (
   return EFI_NOT_FOUND;
}
+
+
+/**
+  Search through ConfigBlockTable blocks to find following Config Block of given GUID.
+  If there is no such following Config Block found until the end of the table, return EFI_NOT_FOUND.
+
+  @param[in]    ConfigBlockTable  A pointer to the beginning of Config Block Table
+  @param[in]    ConfigBlock       A pointer to the Config Block, against which the search begins
+  @param[in]    TargetGuid        A pointer to the Guid of Config Block to find
+
+  @return                         Pointer to config block, or NULL if config block of given guid was not found
+**/
+CONFIG_BLOCK*
+EFIAPI
+GetNextConfigBlock (
+  IN CONFIG_BLOCK_TABLE_HEADER    *ConfigBlockTable,
+  IN CONFIG_BLOCK                 *ConfigBlock,
+  IN EFI_GUID                     *TargetGuid
+  )
+{
+  CONFIG_BLOCK_TABLE_HEADER    *ConfigBlkTblHdrPtr;
+  UINTN                         ConfigBlkTblEndAddr;
+  UINTN                         ConfigBlkOffset;
+  CONFIG_BLOCK                 *TempConfigBlk;
+
+  ConfigBlkTblHdrPtr = ConfigBlockTable;
+  ConfigBlkTblEndAddr = (UINTN) ConfigBlockTable + (UINTN) ConfigBlkTblHdrPtr->Header.GuidHob.Header.HobLength;
+  TempConfigBlk = (CONFIG_BLOCK *) ConfigBlock;
+  ConfigBlkOffset = (UINTN) ConfigBlock + (UINTN) TempConfigBlk->Header.GuidHob.Header.HobLength;
+
+  //
+  // Loop until exceeding ConfigBlockTable range
+  //
+  while (ConfigBlkOffset < ConfigBlkTblEndAddr) {
+    TempConfigBlk = (CONFIG_BLOCK *) ConfigBlkOffset;
+    if (CompareGuid (TargetGuid, &(TempConfigBlk->Header.GuidHob.Name))) {
+      return TempConfigBlk;
+    }
+    ConfigBlkOffset += (UINTN) TempConfigBlk->Header.GuidHob.Header.HobLength;
+  }
+
+  return NULL;
+}
--
2.30.0.windows.2

---------------------------------------------------------------------
Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN.
Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited.

[-- Attachment #2: Type: text/html, Size: 15507 bytes --]

^ permalink raw reply related	[flat|nested] 3+ messages in thread
* [PATCH v2] IntelSiliconPkg/BaseConfigBlockLib: Add function to iterate over Config Blocks
@ 2022-02-22 17:34 Fedorowicz, Jakub
  0 siblings, 0 replies; 3+ messages in thread
From: Fedorowicz, Jakub @ 2022-02-22 17:34 UTC (permalink / raw)
  To: devel@edk2.groups.io

In BaseConfigBlockLib add function to get next config block from config blocks table in order to iterate over blocks of the same GUID.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3700
Cc: Ray Ni <mailto:ray.ni@intel.com>
Cc: Rangasai V Chaganty <mailto:rangasai.v.chaganty@intel.com>
Signed-off-by: Jakub Fedorowicz <mailto:jakub.fedorowicz@intel.com>
---
 .../Include/Library/ConfigBlockLib.h          | 20 +++++++
 .../BaseConfigBlockLib/BaseConfigBlockLib.c   | 54 ++++++++++++++++---
 2 files changed, 68 insertions(+), 6 deletions(-)

diff --git a/Silicon/Intel/IntelSiliconPkg/Include/Library/ConfigBlockLib.h b/Silicon/Intel/IntelSiliconPkg/Include/Library/ConfigBlockLib.h
index 37a396816..64a13bca9 100644
--- a/Silicon/Intel/IntelSiliconPkg/Include/Library/ConfigBlockLib.h
+++ b/Silicon/Intel/IntelSiliconPkg/Include/Library/ConfigBlockLib.h
@@ -9,6 +9,8 @@
 #ifndef _CONFIG_BLOCK_LIB_H_
 #define _CONFIG_BLOCK_LIB_H_
 
+#include <ConfigBlock.h>
+
 /**
   Create config block table.
 
@@ -61,4 +63,22 @@ GetConfigBlock (
   OUT    VOID      **ConfigBlockAddress
   );
 
+/**
+  Search through ConfigBlockTable blocks to find following Config Block of given GUID.
+  If there is no such following Config Block found until the end of the table, return EFI_NOT_FOUND.
+
+  @param[in]    ConfigBlockTable  A pointer to the beginning of Config Block Table
+  @param[in]    ConfigBlock       A pointer to the Config Block, against which the search begins
+  @param[in]    TargetGuid        A pointer to the Guid of Config Block to find
+
+  @return                         Pointer to config block, or NULL if config block of given guid was not found
+**/
+CONFIG_BLOCK*
+EFIAPI
+GetNextConfigBlock (
+  IN CONFIG_BLOCK_TABLE_HEADER    *ConfigBlockTable,
+  IN CONFIG_BLOCK                 *ConfigBlock,
+  IN EFI_GUID                     *TargetGuid
+  );
+
 #endif // _CONFIG_BLOCK_LIB_H_
diff --git a/Silicon/Intel/IntelSiliconPkg/Library/BaseConfigBlockLib/BaseConfigBlockLib.c b/Silicon/Intel/IntelSiliconPkg/Library/BaseConfigBlockLib/BaseConfigBlockLib.c
index c89699ea4..30847d561 100644
--- a/Silicon/Intel/IntelSiliconPkg/Library/BaseConfigBlockLib/BaseConfigBlockLib.c
+++ b/Silicon/Intel/IntelSiliconPkg/Library/BaseConfigBlockLib/BaseConfi
+++ gBlockLib.c
@@ -5,7 +5,6 @@ Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
-#include <ConfigBlock.h>
 #include <Library/ConfigBlockLib.h>
 #include <Library/BaseMemoryLib.h>
 #include <Library/MemoryAllocationLib.h> @@ -14,12 +13,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 /**
   Create config block table.
 
-  @param[in]     TotalSize                    - Max size to be allocated for the Config Block Table
-  @param[out]    ConfigBlockTableAddress      - On return, points to a pointer to the beginning of Config Block Table Address
+  @param[in]     TotalSize                Max size to be allocated for the Config Block Table
+  @param[out]    ConfigBlockTableAddress  On return, points to a pointer to the beginning of Config Block Table Address
 
-  @retval EFI_INVALID_PARAMETER - Invalid Parameter
-  @retval EFI_OUT_OF_RESOURCES  - Out of resources
-  @retval EFI_SUCCESS           - Successfully created Config Block Table at ConfigBlockTableAddress
+  @retval EFI_INVALID_PARAMETER           Invalid Parameter
+  @retval EFI_OUT_OF_RESOURCES            Out of resources
+  @retval EFI_SUCCESS                     Successfully created Config Block Table at ConfigBlockTableAddress
 **/
 EFI_STATUS
 EFIAPI
@@ -137,3 +136,46 @@ GetConfigBlock (
 
   return EFI_NOT_FOUND;
 }
+
+
+/**
+  Search through ConfigBlockTable blocks to find following Config Block of given GUID.
+  If there is no such following Config Block found until the end of the table, return EFI_NOT_FOUND.
+
+  @param[in]    ConfigBlockTable  A pointer to the beginning of Config Block Table
+  @param[in]    ConfigBlock       A pointer to the Config Block, against which the search begins
+  @param[in]    TargetGuid        A pointer to the Guid of Config Block to find
+
+  @return                         Pointer to config block, or NULL if config block of given guid was not found
+**/
+CONFIG_BLOCK*
+EFIAPI
+GetNextConfigBlock (
+  IN CONFIG_BLOCK_TABLE_HEADER    *ConfigBlockTable,
+  IN CONFIG_BLOCK                 *ConfigBlock,
+  IN EFI_GUID                     *TargetGuid
+  )
+{
+  CONFIG_BLOCK_TABLE_HEADER    *ConfigBlkTblHdrPtr;
+  UINTN                         ConfigBlkTblEndAddr;
+  UINTN                         ConfigBlkOffset;
+  CONFIG_BLOCK                 *TempConfigBlk;
+
+  ConfigBlkTblHdrPtr = ConfigBlockTable;  ConfigBlkTblEndAddr = (UINTN) 
+ ConfigBlockTable + (UINTN) 
+ ConfigBlkTblHdrPtr->Header.GuidHob.Header.HobLength;
+  TempConfigBlk = (CONFIG_BLOCK *) ConfigBlock;  ConfigBlkOffset = 
+ (UINTN) ConfigBlock + (UINTN) 
+ TempConfigBlk->Header.GuidHob.Header.HobLength;
+
+  //
+  // Loop until exceeding ConfigBlockTable range  //  while 
+ (ConfigBlkOffset < ConfigBlkTblEndAddr) {
+    TempConfigBlk = (CONFIG_BLOCK *) ConfigBlkOffset;
+    if (CompareGuid (TargetGuid, &(TempConfigBlk->Header.GuidHob.Name))) {
+      return TempConfigBlk;
+    }
+    ConfigBlkOffset += (UINTN) 
+ TempConfigBlk->Header.GuidHob.Header.HobLength;
+  }
+
+  return NULL;
+}
--
2.30.0.windows.2


---------------------------------------------------------------------
Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN.
Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited.


^ permalink raw reply related	[flat|nested] 3+ messages in thread
* [PATCH v2] IntelSiliconPkg/BaseConfigBlockLib: Add function to iterate over Config Blocks
@ 2021-11-09  8:12 Fedorowicz, Jakub
  0 siblings, 0 replies; 3+ messages in thread
From: Fedorowicz, Jakub @ 2021-11-09  8:12 UTC (permalink / raw)
  To: devel@edk2.groups.io; +Cc: Chaganty, Rangasai V, Ni, Ray

In BaseConfigBlockLib add function to get next config block from config blocks table in order to iterate over blocks of the same type.

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

Signed-off-by: Jakub Fedorowicz mailto:jakub.fedorowicz@intel.com

Cc: Ray Ni mailto:ray.ni@intel.com
Cc: Rangasai V Chaganty mailto:rangasai.v.chaganty@intel.com
---
 .../Include/Library/ConfigBlockLib.h          | 20 ++++++++
 .../BaseConfigBlockLib/BaseConfigBlockLib.c   | 50 +++++++++++++++++++
 2 files changed, 70 insertions(+)

diff --git a/Silicon/Intel/IntelSiliconPkg/Include/Library/ConfigBlockLib.h b/Silicon/Intel/IntelSiliconPkg/Include/Library/ConfigBlockLib.h
index 37a39681..77eff21b 100644
--- a/Silicon/Intel/IntelSiliconPkg/Include/Library/ConfigBlockLib.h
+++ b/Silicon/Intel/IntelSiliconPkg/Include/Library/ConfigBlockLib.h
@@ -45,6 +45,7 @@ AddConfigBlock (
 
 /**
   Retrieve a specific Config Block data by GUID.
+  If there is more than one Config Block with given GUID, return the first found with given GUID.
 
   @param[in]      ConfigBlockTableAddress      - A pointer to the beginning of Config Block Table Address
   @param[in]      ConfigBlockGuid              - A pointer to the GUID uses to search specific Config Block
@@ -61,4 +62,23 @@ GetConfigBlock (
   OUT    VOID      **ConfigBlockAddress
   );
 
+/**
+  Search through ConfigBlockTable blocks to find following Config Block of the same GUID.
+  If there is no following Config Block found until the end of the table, return EFI_NOT_FOUND.
+
+  @param[in]      ConfigBlockTableAddress   - A pointer to the beginning of Config Block Table
+  @param[in]      ConfigBlockAddress        - A pointer to the Config Block, in relation to which we start the search
+  @param[out]     NextConfigBlockAddress    - On return, points to a pointer to the found Config Block
+
+  @retval EFI_NOT_FOUND         - Could not find the following Config Block
+  @retval EFI_SUCCESS           - Config Block found and return
+**/
+EFI_STATUS
+EFIAPI
+GetNextConfigBlock (
+  IN     VOID      *ConfigBlockTableAddress,
+  IN     VOID      *ConfigBlockAddress,
+  OUT    VOID      **NextConfigBlockAddress
+  );
+
 #endif // _CONFIG_BLOCK_LIB_H_
diff --git a/Silicon/Intel/IntelSiliconPkg/Library/BaseConfigBlockLib/BaseConfigBlockLib.c b/Silicon/Intel/IntelSiliconPkg/Library/BaseConfigBlockLib/BaseConfigBlockLib.c
index c89699ea..f026ac0b 100644
--- a/Silicon/Intel/IntelSiliconPkg/Library/BaseConfigBlockLib/BaseConfigBlockLib.c
+++ b/Silicon/Intel/IntelSiliconPkg/Library/BaseConfigBlockLib/BaseConfigBlockLib.c
@@ -95,6 +95,7 @@ AddConfigBlock (
 
 /**
   Retrieve a specific Config Block data by GUID.
+  If there is more than one Config Block with given GUID, return the first found with given GUID.
 
   @param[in]      ConfigBlockTableAddress      - A pointer to the beginning of Config Block Table Address
   @param[in]      ConfigBlockGuid              - A pointer to the GUID uses to search specific Config Block
@@ -137,3 +138,52 @@ GetConfigBlock (
 
   return EFI_NOT_FOUND;
 }
+
+/**
+  Search through ConfigBlockTable blocks to find following Config Block of the same GUID.
+  If there is no following Config Block found until the end of the table, return EFI_NOT_FOUND.
+
+  @param[in]      ConfigBlockTableAddress   - A pointer to the beginning of Config Block Table
+  @param[in]      ConfigBlockAddress        - A pointer to the Config Block, in relation to which we start the search
+  @param[out]     NextConfigBlockAddress    - On return, points to a pointer to the found Config Block
+
+  @retval EFI_NOT_FOUND         - Could not find the following Config Block
+  @retval EFI_SUCCESS           - Config Block found and return
+**/
+EFI_STATUS
+EFIAPI
+GetNextConfigBlock (
+  IN     VOID      *ConfigBlockTableAddress,
+  IN     VOID      *ConfigBlockAddress,
+  OUT    VOID      **NextConfigBlockAddress
+  )
+{
+  CONFIG_BLOCK_TABLE_HEADER    *ConfigBlkTblHdrPtr;
+  UINTN                         ConfigBlkTblEndAddr;
+  UINTN                         ConfigBlkOffset;
+  CONFIG_BLOCK                 *TempConfigBlk;
+  EFI_GUID                     *TargetGuid;
+
+  ConfigBlkTblHdrPtr = (CONFIG_BLOCK_TABLE_HEADER *) ConfigBlockTableAddress;
+  ConfigBlkTblEndAddr = (UINTN) ConfigBlockTableAddress + (UINTN) ConfigBlkTblHdrPtr->Header.GuidHob.Header.HobLength;
+
+  TempConfigBlk = (CONFIG_BLOCK *) ConfigBlockAddress;
+  TargetGuid = &(TempConfigBlk->Header.GuidHob.Name);
+  ConfigBlkOffset = (UINTN) ConfigBlockAddress + (UINTN) TempConfigBlk->Header.GuidHob.Header.HobLength;
+
+  //
+  // Loop until exceeding ConfigBlockTable range
+  //
+  while (ConfigBlkOffset < ConfigBlkTblEndAddr) {
+    TempConfigBlk = (CONFIG_BLOCK *) ConfigBlkOffset;
+
+    if (CompareGuid (TargetGuid, &(TempConfigBlk->Header.GuidHob.Name))) {
+      *NextConfigBlockAddress = (VOID *) TempConfigBlk;
+      return EFI_SUCCESS;
+    }
+
+    ConfigBlkOffset += (UINTN) TempConfigBlk->Header.GuidHob.Header.HobLength;
+  }
+
+  return EFI_NOT_FOUND;
+}
-- 
2.30.0.windows.2
---------------------------------------------------------------------
Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN.
Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited.


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

end of thread, other threads:[~2022-03-03 11:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-03 11:43 [PATCH v2] IntelSiliconPkg/BaseConfigBlockLib: Add function to iterate over Config Blocks Fedorowicz, Jakub
  -- strict thread matches above, loose matches on Subject: below --
2022-02-22 17:34 Fedorowicz, Jakub
2021-11-09  8:12 Fedorowicz, Jakub

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