]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
IntelFrameworkModulePkg: Replace [Ascii|Unicode]ValueToString
[mirror_edk2.git] / MdeModulePkg / Universal / HiiDatabaseDxe / ConfigKeywordHandler.c
index 03f814119993f3f57a77e0906584d5a85392b61d..8e23a51533d63902d5302d4b39ff7698d81a2c2f 100644 (file)
@@ -28,7 +28,7 @@ extern HII_DATABASE_PRIVATE_DATA mPrivate;
   @param  NextString             string follow the possible PathHdr string.\r
 \r
   @retval EFI_INVALID_PARAMETER  The device path is not valid or the incoming parameter is invalid.\r
   @param  NextString             string follow the possible PathHdr string.\r
 \r
   @retval EFI_INVALID_PARAMETER  The device path is not valid or the incoming parameter is invalid.\r
-  @retval EFI_OUT_OF_RESOURCES   Lake of resources to store neccesary structures.\r
+  @retval EFI_OUT_OF_RESOURCES   Lake of resources to store necessary structures.\r
   @retval EFI_SUCCESS            The device path is retrieved and translated to binary format.\r
                                  The Input string not include PathHdr section.\r
 \r
   @retval EFI_SUCCESS            The device path is retrieved and translated to binary format.\r
                                  The Input string not include PathHdr section.\r
 \r
@@ -240,10 +240,10 @@ ExtractNameSpace (
 \r
   @param  String                 KeywordRequestformat string.\r
   @param  Keyword                return the extract keyword string.\r
 \r
   @param  String                 KeywordRequestformat string.\r
   @param  Keyword                return the extract keyword string.\r
-  @param  NextString             return the next string follow this keyword sectin.\r
+  @param  NextString             return the next string follow this keyword section.\r
 \r
   @retval EFI_SUCCESS            Success to get the keyword string.\r
 \r
   @retval EFI_SUCCESS            Success to get the keyword string.\r
-  @retval EFI_INVALID_PARAMETER  Parsr the input string return error.\r
+  @retval EFI_INVALID_PARAMETER  Parse the input string return error.\r
 \r
 **/\r
 EFI_STATUS\r
 \r
 **/\r
 EFI_STATUS\r
@@ -306,10 +306,10 @@ ExtractKeyword (
 \r
   @param  String                 KeywordRequestformat string.\r
   @param  Value                  return the extract value string.\r
 \r
   @param  String                 KeywordRequestformat string.\r
   @param  Value                  return the extract value string.\r
-  @param  NextString             return the next string follow this keyword sectin.\r
+  @param  NextString             return the next string follow this keyword section.\r
 \r
   @retval EFI_SUCCESS            Success to get the keyword string.\r
 \r
   @retval EFI_SUCCESS            Success to get the keyword string.\r
-  @retval EFI_INVALID_PARAMETER  Parsr the input string return error.\r
+  @retval EFI_INVALID_PARAMETER  Parse the input string return error.\r
 \r
 **/\r
 EFI_STATUS\r
 \r
 **/\r
 EFI_STATUS\r
@@ -361,10 +361,10 @@ ExtractValue (
 \r
   @param  String                 KeywordRequestformat string.\r
   @param  FilterFlags            return the filter condition.\r
 \r
   @param  String                 KeywordRequestformat string.\r
   @param  FilterFlags            return the filter condition.\r
-  @param  NextString             return the next string follow this keyword sectin.\r
+  @param  NextString             return the next string follow this keyword section.\r
 \r
   @retval EFI_SUCCESS            Success to get the keyword string.\r
 \r
   @retval EFI_SUCCESS            Success to get the keyword string.\r
-  @retval EFI_INVALID_PARAMETER  Parsr the input string return error.\r
+  @retval EFI_INVALID_PARAMETER  Parse the input string return error.\r
 \r
 **/\r
 BOOLEAN\r
 \r
 **/\r
 BOOLEAN\r
@@ -477,7 +477,7 @@ ExtractFilter (
         String = KeywordPtr;\r
       } else {\r
         //\r
         String = KeywordPtr;\r
       } else {\r
         //\r
-        // Only has paltform defined filter section, just skip it.\r
+        // Only has platform defined filter section, just skip it.\r
         //\r
         String += StrLen (String);\r
       }\r
         //\r
         String += StrLen (String);\r
       }\r
@@ -520,9 +520,9 @@ ExtractReadOnlyFromOpCode (
 \r
   This is a internal function.\r
 \r
 \r
   This is a internal function.\r
 \r
-  @param  OpCodeData             The questin binary ifr data.\r
+  @param  OpCodeData             The question binary ifr data.\r
   @param  KeywordRequest         KeywordRequestformat string.\r
   @param  KeywordRequest         KeywordRequestformat string.\r
-  @param  NextString             return the next string follow this keyword sectin.\r
+  @param  NextString             return the next string follow this keyword section.\r
   @param  ReadOnly               Return whether this question is read only.\r
 \r
   @retval KEYWORD_HANDLER_NO_ERROR                     Success validate.\r
   @param  ReadOnly               Return whether this question is read only.\r
 \r
   @retval KEYWORD_HANDLER_NO_ERROR                     Success validate.\r
@@ -711,7 +711,7 @@ GetRecordFromDevicePath (
   @param  BufferSize             Length of the buffer.\r
   @param  StringDest             Buffer to store the string text. \r
 \r
   @param  BufferSize             Length of the buffer.\r
   @param  StringDest             Buffer to store the string text. \r
 \r
-  @retval EFI_SUCCESS            The string text was outputed successfully.\r
+  @retval EFI_SUCCESS            The string text was outputted successfully.\r
   @retval EFI_OUT_OF_RESOURCES   Out of resource.\r
 \r
 **/\r
   @retval EFI_OUT_OF_RESOURCES   Out of resource.\r
 \r
 **/\r
@@ -875,7 +875,7 @@ GetStringIdFromString (
       if (EFI_ERROR (Status)) {\r
         goto Done;\r
       }\r
       if (EFI_ERROR (Status)) {\r
         goto Done;\r
       }\r
-      \r
+      ASSERT (String != NULL);\r
       if (StrCmp(KeywordValue, String) == 0) {\r
         *StringId = CurrentStringId;\r
         goto Done;\r
       if (StrCmp(KeywordValue, String) == 0) {\r
         *StringId = CurrentStringId;\r
         goto Done;\r
@@ -895,7 +895,7 @@ GetStringIdFromString (
       if (EFI_ERROR (Status)) {\r
         goto Done;\r
       }\r
       if (EFI_ERROR (Status)) {\r
         goto Done;\r
       }\r
-      \r
+      ASSERT (String != NULL);\r
       if (StrCmp(KeywordValue, String) == 0) {\r
         *StringId = CurrentStringId;\r
         goto Done;\r
       if (StrCmp(KeywordValue, String) == 0) {\r
         *StringId = CurrentStringId;\r
         goto Done;\r
@@ -914,7 +914,7 @@ GetStringIdFromString (
         if (EFI_ERROR (Status)) {\r
           goto Done;\r
         }\r
         if (EFI_ERROR (Status)) {\r
           goto Done;\r
         }\r
-\r
+        ASSERT (String != NULL);\r
         BlockSize += StringSize;\r
         if (StrCmp(KeywordValue, String) == 0) {\r
           *StringId = CurrentStringId;\r
         BlockSize += StringSize;\r
         if (StrCmp(KeywordValue, String) == 0) {\r
           *StringId = CurrentStringId;\r
@@ -939,7 +939,7 @@ GetStringIdFromString (
         if (EFI_ERROR (Status)) {\r
           goto Done;\r
         }\r
         if (EFI_ERROR (Status)) {\r
           goto Done;\r
         }\r
-\r
+        ASSERT (String != NULL);\r
         BlockSize += StringSize;\r
         if (StrCmp(KeywordValue, String) == 0) {\r
           *StringId = CurrentStringId;\r
         BlockSize += StringSize;\r
         if (StrCmp(KeywordValue, String) == 0) {\r
           *StringId = CurrentStringId;\r
@@ -1310,7 +1310,7 @@ GetNextStringId (
   @param  KeywordValue                   Keyword value.\r
   @param  StringId                       String Id for this keyword.\r
 \r
   @param  KeywordValue                   Keyword value.\r
   @param  StringId                       String Id for this keyword.\r
 \r
-  @retval KEYWORD_HANDLER_NO_ERROR                     Get String id succes.\r
+  @retval KEYWORD_HANDLER_NO_ERROR                     Get String id successfully.\r
   @retval KEYWORD_HANDLER_KEYWORD_NOT_FOUND            Not found the string id in the string package.\r
   @retval KEYWORD_HANDLER_NAMESPACE_ID_NOT_FOUND       Not found the string package for this namespace.\r
   @retval KEYWORD_HANDLER_UNDEFINED_PROCESSING_ERROR   Out of resource error.\r
   @retval KEYWORD_HANDLER_KEYWORD_NOT_FOUND            Not found the string id in the string package.\r
   @retval KEYWORD_HANDLER_NAMESPACE_ID_NOT_FOUND       Not found the string package for this namespace.\r
   @retval KEYWORD_HANDLER_UNDEFINED_PROCESSING_ERROR   Out of resource error.\r
@@ -1609,7 +1609,7 @@ GetWidth (
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
-  Converts all hex dtring characters in range ['A'..'F'] to ['a'..'f'] for \r
+  Converts all hex string characters in range ['A'..'F'] to ['a'..'f'] for\r
   hex digits that appear between a '=' and a '&' in a config string.\r
 \r
   If ConfigString is NULL, then ASSERT().\r
   hex digits that appear between a '=' and a '&' in a config string.\r
 \r
   If ConfigString is NULL, then ASSERT().\r
@@ -1657,7 +1657,7 @@ InternalLowerConfigString (
   @param[in]  DriverHandle  The driver handle which supports a Device Path Protocol\r
                             that is the routing information PATH.  Each byte of\r
                             the Device Path associated with DriverHandle is converted\r
   @param[in]  DriverHandle  The driver handle which supports a Device Path Protocol\r
                             that is the routing information PATH.  Each byte of\r
                             the Device Path associated with DriverHandle is converted\r
-                            to a 2 Unicode character hexidecimal string.\r
+                            to a 2 Unicode character hexadecimal string.\r
 \r
   @retval NULL   DriverHandle does not support the Device Path Protocol.\r
   @retval Other  A pointer to the Null-terminate Unicode <ConfigHdr> string\r
 \r
   @retval NULL   DriverHandle does not support the Device Path Protocol.\r
   @retval Other  A pointer to the Null-terminate Unicode <ConfigHdr> string\r
@@ -2356,7 +2356,7 @@ GetStringIdFromDatabase (
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
-  Genereate the KeywordResp String.\r
+  Generate the KeywordResp String.\r
 \r
   <KeywordResp> ::= <NameSpaceId><PathHdr>'&'<Keyword>'&VALUE='<Number>['&READONLY']\r
 \r
 \r
   <KeywordResp> ::= <NameSpaceId><PathHdr>'&'<Keyword>'&VALUE='<Number>['&READONLY']\r
 \r
@@ -2419,7 +2419,7 @@ GenerateKeywordResp (
   RespStrLen += StrLen (PathHdr);\r
 \r
   //\r
   RespStrLen += StrLen (PathHdr);\r
 \r
   //\r
-  // 1.3 Keyword setion.\r
+  // 1.3 Keyword section.\r
   // 'KEYWORD='<String>[':'<DecCh>(1/4)]\r
   //\r
   RespStrLen += 8 + StrLen (KeywordData);\r
   // 'KEYWORD='<String>[':'<DecCh>(1/4)]\r
   //\r
   RespStrLen += 8 + StrLen (KeywordData);\r
@@ -2709,7 +2709,7 @@ Error:
   }\r
 \r
   //\r
   }\r
 \r
   //\r
-  // return the already get MultiKeywordString even error occured.\r
+  // return the already get MultiKeywordString even error occurred.\r
   //\r
   if (MultiKeywordResp == NULL) {\r
     Status = EFI_NOT_FOUND;\r
   //\r
   if (MultiKeywordResp == NULL) {\r
     Status = EFI_NOT_FOUND;\r
@@ -2907,11 +2907,11 @@ EfiConfigKeywordHandlerSetData (
     StringPtr = NextStringPtr;\r
 \r
     //\r
     StringPtr = NextStringPtr;\r
 \r
     //\r
-    // 5. Find ReadOnly filter.\r
+    // 5. Find READONLY tag.\r
     //\r
     //\r
-    if ((StringPtr != NULL) && StrnCmp (StringPtr, L"&ReadOnly", StrLen (L"&ReadOnly")) == 0) {\r
+    if ((StringPtr != NULL) && StrnCmp (StringPtr, L"&READONLY", StrLen (L"&READONLY")) == 0) {\r
       ReadOnly = TRUE;\r
       ReadOnly = TRUE;\r
-      StringPtr += StrLen (L"&ReadOnly");\r
+      StringPtr += StrLen (L"&READONLY");\r
     } else {\r
       ReadOnly = FALSE;\r
     }\r
     } else {\r
       ReadOnly = FALSE;\r
     }\r
@@ -2937,9 +2937,18 @@ EfiConfigKeywordHandlerSetData (
     // 8. Check the readonly flag.\r
     //\r
     if (ExtractReadOnlyFromOpCode (OpCode) != ReadOnly) {\r
     // 8. Check the readonly flag.\r
     //\r
     if (ExtractReadOnlyFromOpCode (OpCode) != ReadOnly) {\r
+      //\r
+      // Extracting readonly flag form opcode and extracting "READONLY" tag form KeywordString should have the same results.\r
+      // If not, the input KeywordString must be incorrect, return the error status to caller.\r
+      //\r
+      *ProgressErr = KEYWORD_HANDLER_INCOMPATIBLE_VALUE_DETECTED;\r
+      Status = EFI_INVALID_PARAMETER;\r
+      goto Done;\r
+    }\r
+    if (ReadOnly) {\r
       *ProgressErr = KEYWORD_HANDLER_ACCESS_NOT_PERMITTED;\r
       Status = EFI_ACCESS_DENIED;\r
       *ProgressErr = KEYWORD_HANDLER_ACCESS_NOT_PERMITTED;\r
       Status = EFI_ACCESS_DENIED;\r
-      goto Done;      \r
+      goto Done;\r
     }\r
     \r
     //\r
     }\r
     \r
     //\r
@@ -3062,7 +3071,7 @@ Done:
   @retval EFI_SUCCESS             The specified action was completed successfully.\r
   \r
   @retval EFI_INVALID_PARAMETER   One or more of the following are TRUE:\r
   @retval EFI_SUCCESS             The specified action was completed successfully.\r
   \r
   @retval EFI_INVALID_PARAMETER   One or more of the following are TRUE:\r
-                                  1.Progress, ProgressErr, or Resuts is NULL.\r
+                                  1.Progress, ProgressErr, or Results is NULL.\r
                                   2.Parsing of the KeywordString resulted in an error. See\r
                                     Progress and ProgressErr for more data.\r
   \r
                                   2.Parsing of the KeywordString resulted in an error. See\r
                                     Progress and ProgressErr for more data.\r
   \r