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
Cc: Ray Ni mailto:[email protected]
Cc: Rangasai V Chaganty mailto:[email protected]
Signed-off-by: Jakub Fedorowicz mailto:[email protected]
---
 .../Include/Library/ConfigBlockLib.h          | 19 ++++++++
 .../BaseConfigBlockLib/BaseConfigBlockLib.c   | 43 +++++++++++++++++++
 2 files changed, 62 insertions(+)

diff --git a/Silicon/Intel/IntelSiliconPkg/Include/Library/ConfigBlockLib.h 
b/Silicon/Intel/IntelSiliconPkg/Include/Library/ConfigBlockLib.h
index 37a39681..7f2e8d58 100644
--- a/Silicon/Intel/IntelSiliconPkg/Include/Library/ConfigBlockLib.h
+++ b/Silicon/Intel/IntelSiliconPkg/Include/Library/ConfigBlockLib.h
@@ -61,4 +61,23 @@ 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
+
+  @retval CONFIG_BLOCK*         - Found Config Block
+  @retval NULL          - Config Block of given guid not found
+**/
+CONFIG_BLOCK*
+EFIAPI
+GetNextConfigBlock (
+  IN CONFIG_BLOCK                 *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 c89699ea..552caa57 100644
--- 
a/Silicon/Intel/IntelSiliconPkg/Library/BaseConfigBlockLib/BaseConfigBlockLib.c
+++ 
b/Silicon/Intel/IntelSiliconPkg/Library/BaseConfigBlockLib/BaseConfigBlockLib.c
@@ -137,3 +137,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
+
+  @retval CONFIG_BLOCK*         - Found Config Block
+  @retval NULL          - Config Block of given guid not found
+**/
+CONFIG_BLOCK*
+EFIAPI
+GetNextConfigBlock (
+  IN CONFIG_BLOCK                 *ConfigBlockTable,
+  IN CONFIG_BLOCK                 *ConfigBlock,
+  IN EFI_GUID                     *TargetGuid
+  )
+{
+  CONFIG_BLOCK_TABLE_HEADER    *ConfigBlkTblHdrPtr;
+  UINTN                         ConfigBlkTblEndAddr;
+  UINTN                         ConfigBlkOffset;
+  CONFIG_BLOCK                 *TempConfigBlk;
+
+  ConfigBlkTblHdrPtr = (CONFIG_BLOCK_TABLE_HEADER *) 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.



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#84646): https://edk2.groups.io/g/devel/message/84646
Mute This Topic: https://groups.io/mt/87640147/21656
Group Owner: [email protected]
Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to