[PATCH v3] IntelSiliconPkg/BaseConfigBlockLib: Add function to iterate over Config Blocks


Fedorowicz, Jakub <jakub.fedorowicz@...>
 

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@...

 

Cc: Ray Ni mailto:ray.ni@...

Cc: Rangasai V Chaganty mailto:rangasai.v.chaganty@...

---

.../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, against which the search begins

+  @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/BaseConfi

+++ gBlockLib.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, against which the search begins

+  @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. Słowackiego 173 | 80-298 Gdańsk | Sąd Rejonowy Gdańsk Północ | VII Wydział Gospodarczy Krajowego Rejestru Sądowego - KRS 101882 | NIP 957-07-52-316 | Kapitał zakładowy 200.000 PLN.

Ta wiadomość wraz z załącznikami jest przeznaczona dla określonego adresata i może zawierać informacje poufne. W razie przypadkowego otrzymania tej wiadomości, prosimy o powiadomienie nadawcy oraz trwałe jej usunięcie; jakiekolwiek przeglądanie 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.


Ni, Ray
 

+EFI_STATUS

+EFIAPI

+GetNextConfigBlock (

+  IN     VOID      *ConfigBlockTableAddress,

+  IN     VOID      *ConfigBlockAddress,

+  OUT    VOID      **NextConfigBlockAddress

+  )

 

How about using following prototype?

 

CONFIG_BLOCK *

GetNextConfigBlock (

  IN CONFIG_BLOCK_TABLE_HEADER *ConfigBlockTable

  IN CONFIG_BLOCK                                *ConfigBlock,

  IN GUID                                                   *Guid

  );

 

The API searches within ConfigBlockTable from ConfigBlock to find the next one whose GUID matches to Guid.

The new API is more flexible than yours because it allows caller to supply a different GUID.

 

 

By the way, do you have a plan to change existing library APIs to replace “VOID *” with “CONFIG_BLOCK_TABLE_HEADER *” or “CONFIG_BLOCK *”?

 

Thanks,

Ray