]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
MdeModulePkg/Browser: Share default if some default value are not specified
[mirror_edk2.git] / MdeModulePkg / Universal / SetupBrowserDxe / IfrParse.c
index 11a8fdc30daaaeb01afa49dc224051b042a8c6c9..61ba0b50474daaecfe56e26c3e54b33c0fd519e8 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Parser for IFR binary encoding.\r
 \r
-Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -1311,6 +1311,9 @@ ParseOpCodes (
   INTN                    ConditionalExprCount;\r
   BOOLEAN                 InUnknownScope;\r
   UINT8                   UnknownDepth;\r
+  FORMSET_DEFAULTSTORE    *PreDefaultStore;\r
+  LIST_ENTRY              *DefaultLink;\r
+  BOOLEAN                 HaveInserted;\r
 \r
   SuppressForQuestion      = FALSE;\r
   SuppressForOption        = FALSE;\r
@@ -1875,17 +1878,31 @@ ParseOpCodes (
     // DefaultStore\r
     //\r
     case EFI_IFR_DEFAULTSTORE_OP:\r
+      HaveInserted = FALSE;\r
       DefaultStore = AllocateZeroPool (sizeof (FORMSET_DEFAULTSTORE));\r
       ASSERT (DefaultStore != NULL);\r
       DefaultStore->Signature = FORMSET_DEFAULTSTORE_SIGNATURE;\r
 \r
       CopyMem (&DefaultStore->DefaultId,   &((EFI_IFR_DEFAULTSTORE *) OpCodeData)->DefaultId,   sizeof (UINT16));\r
       CopyMem (&DefaultStore->DefaultName, &((EFI_IFR_DEFAULTSTORE *) OpCodeData)->DefaultName, sizeof (EFI_STRING_ID));\r
-\r
       //\r
-      // Insert to DefaultStore list of this Formset\r
+      // Insert it to the DefaultStore list of this Formset with ascending order.\r
       //\r
-      InsertTailList (&FormSet->DefaultStoreListHead, &DefaultStore->Link);\r
+      if (!IsListEmpty (&FormSet->DefaultStoreListHead)) {\r
+        DefaultLink = GetFirstNode (&FormSet->DefaultStoreListHead);\r
+        while (!IsNull (&FormSet->DefaultStoreListHead, DefaultLink)) {\r
+          PreDefaultStore = FORMSET_DEFAULTSTORE_FROM_LINK(DefaultLink);\r
+          DefaultLink = GetNextNode (&FormSet->DefaultStoreListHead, DefaultLink);\r
+          if (DefaultStore->DefaultId < PreDefaultStore->DefaultId) {\r
+            InsertTailList (&PreDefaultStore->Link, &DefaultStore->Link);\r
+            HaveInserted = TRUE;\r
+            break;\r
+          }\r
+        }\r
+      }\r
+      if (!HaveInserted) {\r
+        InsertTailList (&FormSet->DefaultStoreListHead, &DefaultStore->Link);\r
+      }\r
       break;\r
 \r
     //\r