]> git.proxmox.com Git - mirror_edk2.git/blobdiff - DuetPkg/FSVariable/FSVariable.c
Remove unnecessary use of FixedPcdxxx() functions and [FixedPcd] INF sections. These...
[mirror_edk2.git] / DuetPkg / FSVariable / FSVariable.c
index 49e92076e1806907e43a2500926247ff0f55804f..2298e4e474304adae320ddfa0ffebc1c80942acb 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006 - 2007, Intel Corporation\r
+Copyright (c) 2006 - 2010, Intel Corporation\r
 All rights reserved. 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
@@ -47,7 +47,7 @@ VARIABLE_GLOBAL  *mGlobal;
 \r
   @param[in] DataSize           Size of data. 0 means delete\r
 \r
-  @param[in] Attributes              Attribues of the variable\r
+  @param[in] Attributes         Attribues of the variable\r
 \r
   @param[in] Variable           The variable information which is used to keep track of variable usage.\r
 \r
@@ -553,9 +553,9 @@ Returns:
   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
@@ -570,7 +570,7 @@ Returns:
 \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
@@ -604,7 +604,7 @@ GetIndexFromSupportedLangCodes(
     return 0;\r
   } else {\r
     //\r
-    // Compare RFC3066 language code\r
+    // Compare RFC4646 language code\r
     //\r
     while (*Supported != '\0') {\r
       //\r
@@ -630,9 +630,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
@@ -647,7 +647,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
@@ -755,7 +755,7 @@ AutoUpdateLangVariable(
     // Therefore, in variable driver, only store the original value for other use.\r
     //\r
     AsciiStrnCpy (mGlobal->LangCodes, Data, DataSize);\r
-  } else if (StrCmp (VariableName, L"PlatformLang") == 0) {\r
+  } else if ((StrCmp (VariableName, L"PlatformLang") == 0) && (DataSize != 0)) {\r
     ASSERT (AsciiStrLen (mGlobal->PlatformLangCodes) != 0);\r
 \r
     //\r
@@ -769,7 +769,7 @@ AutoUpdateLangVariable(
     Index = GetIndexFromSupportedLangCodes(mGlobal->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(mGlobal->LangCodes, Index, TRUE);\r
 \r
@@ -785,7 +785,7 @@ AutoUpdateLangVariable(
 \r
     ASSERT_EFI_ERROR(Status);\r
     \r
-  } else if (StrCmp (VariableName, L"Lang") == 0) {\r
+  } else if ((StrCmp (VariableName, L"Lang") == 0) && (DataSize != 0)) {\r
     ASSERT (AsciiStrLen (mGlobal->LangCodes) != 0);\r
 \r
     //\r
@@ -799,7 +799,7 @@ AutoUpdateLangVariable(
     Index = GetIndexFromSupportedLangCodes(mGlobal->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(mGlobal->PlatformLangCodes, Index, FALSE);\r
 \r
@@ -809,7 +809,7 @@ AutoUpdateLangVariable(
     FindVariable(L"PlatformLang", &gEfiGlobalVariableGuid, &Variable);\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
@@ -829,7 +829,7 @@ AutoUpdateLangVariable(
 \r
   @param[in] DataSize           Size of data. 0 means delete\r
 \r
-  @param[in] Attributes              Attribues of the variable\r
+  @param[in] Attributes         Attribues of the variable\r
 \r
   @param[in] Variable           The variable information which is used to keep track of variable usage.\r
 \r
@@ -1288,6 +1288,10 @@ Returns:
     return EFI_INVALID_PARAMETER;\r
   }\r
   \r
+  if (DataSize != 0 && Data == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   //\r
   //  Make sure if runtime bit is set, boot service bit is set also\r
   //\r
@@ -1297,12 +1301,12 @@ Returns:
   \r
   //\r
   //  The size of the VariableName, including the Unicode Null in bytes plus\r
-  //  the DataSize is limited to maximum size of FixedPcdGet32(PcdMaxHardwareErrorVariableSize)\r
-  //  bytes for HwErrRec, and FixedPcdGet32(PcdMaxVariableSize) bytes for the others.\r
+  //  the DataSize is limited to maximum size of PcdGet32 (PcdMaxHardwareErrorVariableSize)\r
+  //  bytes for HwErrRec, and PcdGet32 (PcdMaxVariableSize) bytes for the others.\r
   //\r
   if ((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == EFI_VARIABLE_HARDWARE_ERROR_RECORD) {\r
-    if ((DataSize > FixedPcdGet32(PcdMaxHardwareErrorVariableSize)) ||                                                       \r
-        (sizeof (VARIABLE_HEADER) + StrSize (VariableName) + DataSize > FixedPcdGet32(PcdMaxHardwareErrorVariableSize))) {\r
+    if ((DataSize > PcdGet32(PcdMaxHardwareErrorVariableSize)) ||                                                       \r
+        (sizeof (VARIABLE_HEADER) + StrSize (VariableName) + DataSize > PcdGet32(PcdMaxHardwareErrorVariableSize))) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
     //\r
@@ -1312,8 +1316,8 @@ Returns:
       return EFI_INVALID_PARAMETER;\r
     }\r
   } else {\r
-    if ((DataSize > FixedPcdGet32(PcdMaxVariableSize)) ||\r
-        (sizeof (VARIABLE_HEADER) + StrSize (VariableName) + DataSize > FixedPcdGet32(PcdMaxVariableSize))) {\r
+    if ((DataSize > PcdGet32(PcdMaxVariableSize)) ||\r
+        (sizeof (VARIABLE_HEADER) + StrSize (VariableName) + DataSize > PcdGet32(PcdMaxVariableSize))) {\r
       return EFI_INVALID_PARAMETER;\r
     }  \r
   }  \r
@@ -1417,18 +1421,18 @@ Returns:
   // Harware error record variable needs larger size.\r
   //\r
   if ((Attributes & (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_HARDWARE_ERROR_RECORD)) == (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_HARDWARE_ERROR_RECORD)) {\r
-    *MaximumVariableStorageSize = FixedPcdGet32(PcdHwErrStorageSize);\r
-    *MaximumVariableSize = FixedPcdGet32(PcdMaxHardwareErrorVariableSize) - sizeof (VARIABLE_HEADER);\r
+    *MaximumVariableStorageSize = PcdGet32(PcdHwErrStorageSize);\r
+    *MaximumVariableSize = PcdGet32(PcdMaxHardwareErrorVariableSize) - sizeof (VARIABLE_HEADER);\r
   } else {\r
     if ((Attributes & EFI_VARIABLE_NON_VOLATILE) != 0) {\r
-      ASSERT (FixedPcdGet32(PcdHwErrStorageSize) < VariableStoreHeader->Size);\r
-      *MaximumVariableStorageSize = VariableStoreHeader->Size - sizeof (VARIABLE_STORE_HEADER) - FixedPcdGet32(PcdHwErrStorageSize);\r
+      ASSERT (PcdGet32(PcdHwErrStorageSize) < VariableStoreHeader->Size);\r
+      *MaximumVariableStorageSize = VariableStoreHeader->Size - sizeof (VARIABLE_STORE_HEADER) - PcdGet32(PcdHwErrStorageSize);\r
     }\r
 \r
     //\r
-    // Let *MaximumVariableSize be FixedPcdGet32(PcdMaxVariableSize) with the exception of the variable header size.\r
+    // Let *MaximumVariableSize be PcdGet32(PcdMaxVariableSize) with the exception of the variable header size.\r
     //\r
-    *MaximumVariableSize = FixedPcdGet32(PcdMaxVariableSize) - sizeof (VARIABLE_HEADER);\r
+    *MaximumVariableSize = PcdGet32(PcdMaxVariableSize) - sizeof (VARIABLE_HEADER);\r
   }\r
   \r
   //\r