Reviewed-by: Eric Dong <[email protected]>

-----Original Message-----
From: Bi, Dandan <[email protected]> 
Sent: Monday, July 31, 2023 8:46 AM
To: [email protected]
Cc: Gao, Liming <[email protected]>; Dong, Eric <[email protected]>
Subject: [PATCH v2] MdeModulePkg/SetupBrowser: Load storage via GetVariable for 
EfiVarStore

For EfiVarStore (EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER), it will call 
ExtractConfig-GetVariable-HiiBlockToConfig-ConfigToBlock when load storage 
value in LoadStorage function. It's not necessary and costs lots of time to do 
the conversion between config and block.
So now enhance it to call GetVariable directly.

Cc: Liming Gao <[email protected]>
Cc: Eric Dong <[email protected]>
Signed-off-by: Dandan Bi <[email protected]>
---
v2: Fix coding style issue.

 .../Universal/SetupBrowserDxe/Setup.c         | 54 +++++++++++--------
 1 file changed, 32 insertions(+), 22 deletions(-)

diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c 
b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
index 5158baf5bd..2f7b11b1aa 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
@@ -5634,32 +5634,42 @@ LoadStorage (
     ConfigRequest = Storage->ConfigRequest;
   }
 
-  //
-  // Request current settings from Configuration Driver
-  //
-  Status = mHiiConfigRouting->ExtractConfig (
-                                mHiiConfigRouting,
-                                ConfigRequest,
-                                &Progress,
-                                &Result
-                                );
-
-  //
-  // If get value fail, extract default from IFR binary
-  //
-  if (EFI_ERROR (Status)) {
-    ExtractDefault (FormSet, NULL, EFI_HII_DEFAULT_CLASS_STANDARD, 
FormSetLevel, GetDefaultForStorage, Storage->BrowserStorage, TRUE, TRUE);
-  } else {
+  if (Storage->BrowserStorage->Type == 
+ EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER) {
     //
-    // Convert Result from <ConfigAltResp> to <ConfigResp>
+    // Call GetVariable directly for EfiVarStore
     //
-    StrPtr = StrStr (Result, L"&GUID=");
-    if (StrPtr != NULL) {
-      *StrPtr = L'\0';
+    Status = gRT->GetVariable (Storage->BrowserStorage->Name, 
&(Storage->BrowserStorage->Guid), NULL, (UINTN 
*)(&(Storage->BrowserStorage->Size)), Storage->BrowserStorage->EditBuffer);
+    if (EFI_ERROR (Status)) {
+      ExtractDefault (FormSet, NULL, EFI_HII_DEFAULT_CLASS_STANDARD, 
+ FormSetLevel, GetDefaultForStorage, Storage->BrowserStorage, TRUE, 
+ TRUE);
     }
+  } else {
+    //
+    // Request current settings from Configuration Driver
+    //
+    Status = mHiiConfigRouting->ExtractConfig (
+                                  mHiiConfigRouting,
+                                  ConfigRequest,
+                                  &Progress,
+                                  &Result
+                                  );
 
-    Status = ConfigRespToStorage (Storage->BrowserStorage, Result);
-    FreePool (Result);
+    //
+    // If get value fail, extract default from IFR binary
+    //
+    if (EFI_ERROR (Status)) {
+      ExtractDefault (FormSet, NULL, EFI_HII_DEFAULT_CLASS_STANDARD, 
FormSetLevel, GetDefaultForStorage, Storage->BrowserStorage, TRUE, TRUE);
+    } else {
+      //
+      // Convert Result from <ConfigAltResp> to <ConfigResp>
+      //
+      StrPtr = StrStr (Result, L"&GUID=");
+      if (StrPtr != NULL) {
+        *StrPtr = L'\0';
+      }
+
+      Status = ConfigRespToStorage (Storage->BrowserStorage, Result);
+      FreePool (Result);
+    }
   }
 
   Storage->BrowserStorage->ConfigRequest = AllocateCopyPool (StrSize 
(Storage->ConfigRequest), Storage->ConfigRequest);
--
2.39.1.windows.1



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


Reply via email to