]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c
Fix a bug that L"PlatformLang" must be a null-terminated ASCII string according to...
[mirror_edk2.git] / MdeModulePkg / Universal / Variable / EmuRuntimeDxe / EmuVariable.c
index faacd218fd24e42cb242dc724d6f86584b9be20a..cbf953dfe91522bfdf5b7939a035698e159ad7be 100644 (file)
@@ -315,9 +315,9 @@ UpdateVariableInfo (
   Get index from supported language codes according to language string.\r
 \r
   This code is used to get corresponding index in supported language codes. It can handle\r
-  RFC3066 and ISO639 language tags.\r
+  RFC4646 and ISO639 language tags.\r
   In ISO639 language tags, take 3-characters as a delimitation to find matched string and calculate the index.\r
-  In RFC3066 language tags, take semicolon as a delimitation to find matched string and calculate the index.\r
+  In RFC4646 language tags, take semicolon as a delimitation to find matched string and calculate the index.\r
 \r
   For example:\r
     SupportedLang  = "engfraengfra"\r
@@ -332,7 +332,7 @@ UpdateVariableInfo (
 \r
   @param  SupportedLang               Platform supported language codes.\r
   @param  Lang                        Configured language.\r
-  @param  Iso639Language              A bool value to signify if the handler is operated on ISO639 or RFC3066.\r
+  @param  Iso639Language              A bool value to signify if the handler is operated on ISO639 or RFC4646.\r
 \r
   @retval the index of language in the language codes.\r
 \r
@@ -366,7 +366,7 @@ GetIndexFromSupportedLangCodes(
     return 0;\r
   } else {\r
     //\r
-    // Compare RFC3066 language code\r
+    // Compare RFC4646 language code\r
     //\r
     while (*Supported != '\0') {\r
       //\r
@@ -392,9 +392,9 @@ GetIndexFromSupportedLangCodes(
   Get language string from supported language codes according to index.\r
 \r
   This code is used to get corresponding language string in supported language codes. It can handle\r
-  RFC3066 and ISO639 language tags.\r
+  RFC4646 and ISO639 language tags.\r
   In ISO639 language tags, take 3-characters as a delimitation. Find language string according to the index.\r
-  In RFC3066 language tags, take semicolon as a delimitation. Find language string according to the index.\r
+  In RFC4646 language tags, take semicolon as a delimitation. Find language string according to the index.\r
 \r
   For example:\r
     SupportedLang  = "engfraengfra"\r
@@ -409,7 +409,7 @@ GetIndexFromSupportedLangCodes(
 \r
   @param  SupportedLang               Platform supported language codes.\r
   @param  Index                       the index in supported language codes.\r
-  @param  Iso639Language              A bool value to signify if the handler is operated on ISO639 or RFC3066.\r
+  @param  Iso639Language              A bool value to signify if the handler is operated on ISO639 or RFC4646.\r
 \r
   @retval the language string in the language codes.\r
 \r
@@ -523,7 +523,7 @@ AutoUpdateLangVariable(
     //\r
     // When setting PlatformLang, firstly get most matched language string from supported language codes.\r
     //\r
-    BestPlatformLang = GetBestLanguage(mVariableModuleGlobal->PlatformLangCodes, FALSE, Data);\r
+    BestPlatformLang = GetBestLanguage(mVariableModuleGlobal->PlatformLangCodes, FALSE, Data, NULL);\r
 \r
     //\r
     // Get the corresponding index in language codes.\r
@@ -531,7 +531,7 @@ AutoUpdateLangVariable(
     Index = GetIndexFromSupportedLangCodes(mVariableModuleGlobal->PlatformLangCodes, BestPlatformLang, FALSE);\r
 \r
     //\r
-    // Get the corresponding ISO639 language tag according to RFC3066 language tag.\r
+    // Get the corresponding ISO639 language tag according to RFC4646 language tag.\r
     //\r
     BestLang = GetLangFromSupportedLangCodes(mVariableModuleGlobal->LangCodes, Index, TRUE);\r
 \r
@@ -553,7 +553,7 @@ AutoUpdateLangVariable(
     //\r
     // When setting Lang, firstly get most matched language string from supported language codes.\r
     //\r
-    BestLang = GetBestLanguage(mVariableModuleGlobal->LangCodes, TRUE, Data);\r
+    BestLang = GetBestLanguage(mVariableModuleGlobal->LangCodes, TRUE, Data, NULL);\r
 \r
     //\r
     // Get the corresponding index in language codes.\r
@@ -561,7 +561,7 @@ AutoUpdateLangVariable(
     Index = GetIndexFromSupportedLangCodes(mVariableModuleGlobal->LangCodes, BestLang, TRUE);\r
 \r
     //\r
-    // Get the corresponding RFC3066 language tag according to ISO639 language tag.\r
+    // Get the corresponding RFC4646 language tag according to ISO639 language tag.\r
     //\r
     BestPlatformLang = GetLangFromSupportedLangCodes(mVariableModuleGlobal->PlatformLangCodes, Index, FALSE);\r
 \r
@@ -571,7 +571,7 @@ AutoUpdateLangVariable(
     FindVariable(L"PlatformLang", &gEfiGlobalVariableGuid, &Variable, (VARIABLE_GLOBAL *)mVariableModuleGlobal);\r
 \r
     Status = UpdateVariable(L"PlatformLang", &gEfiGlobalVariableGuid, \r
-                    BestPlatformLang, AsciiStrLen (BestPlatformLang), Attributes, &Variable);\r
+                    BestPlatformLang, AsciiStrSize (BestPlatformLang), Attributes, &Variable);\r
 \r
     DEBUG((EFI_D_INFO, "Variable Driver Auto Update Lang, Lang:%a, PlatformLang:%a\n", BestLang, BestPlatformLang));\r
     ASSERT_EFI_ERROR(Status);\r
@@ -811,13 +811,6 @@ FindVariable (
   VARIABLE_STORE_HEADER *VariableStoreHeader[2];\r
   UINTN                 Index;\r
 \r
-  //\r
-  // We aquire the lock at the entry of FindVariable as GetVariable, GetNextVariableName\r
-  // SetVariable all call FindVariable at entry point. Please move "Aquire Lock" to\r
-  // the correct places if this assumption does not hold TRUE anymore.\r
-  //\r
-  AcquireLockOnlyAtBootTime(&Global->VariableServicesLock);\r
-\r
   //\r
   // 0: Non-Volatile, 1: Volatile\r
   //\r
@@ -906,6 +899,9 @@ EmuGetVariable (
   if (VariableName == NULL || VendorGuid == NULL || DataSize == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
+\r
+  AcquireLockOnlyAtBootTime(&Global->VariableServicesLock);\r
+\r
   //\r
   // Find existing variable\r
   //\r
@@ -979,6 +975,8 @@ EmuGetNextVariableName (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
+  AcquireLockOnlyAtBootTime(&Global->VariableServicesLock);\r
+\r
   Status = FindVariable (VariableName, VendorGuid, &Variable, Global);\r
 \r
   if (Variable.CurrPtr == NULL || EFI_ERROR (Status)) {\r
@@ -1129,6 +1127,8 @@ EmuSetVariable (
     }  \r
   }\r
 \r
+  AcquireLockOnlyAtBootTime(&Global->VariableServicesLock);\r
+\r
   //\r
   // Check whether the input variable is already existed\r
   //\r