]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Universal/HiiDataBaseDxe/Forms.c
Modules clean up.
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / HiiDataBaseDxe / Forms.c
index c9a8d9aaf490be449db9363693c725fad7fb35ab..ab39d8a84ed0b6c961ad36e6fdb41a8ed1f1b06c 100644 (file)
@@ -1,22 +1,17 @@
 /**@file\r
   This file contains the form processing code to the HII database.\r
-  \r
+\r
 Copyright (c) 2006 - 2007 Intel Corporation. <BR>\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
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \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
+http://opensource.org/licenses/bsd-license.php\r
 \r
-**/\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
+**/\r
 \r
-//\r
-// Include common header file for this module.\r
-//\r
-#include "CommonHeader.h"\r
 \r
 #include "HiiDatabase.h"\r
 \r
@@ -27,24 +22,24 @@ Ascii2Unicode (
   IN  CHAR8          *AsciiStr\r
   )\r
 /*++\r
-  \r
+\r
   Routine Description:\r
 \r
     This function converts ASCII string to Unicode string.\r
-  \r
+\r
   Arguments:\r
 \r
     UnicodeStr     - NULL terminated Unicode output string.\r
     AsciieStr      - NULL terminated ASCII input string.\r
\r
-  Returns: \r
+\r
+  Returns:\r
 \r
     Start of the Unicode ouput string.\r
-    \r
+\r
 --*/\r
 \r
 {\r
-  CHAR16      *Str = UnicodeStr;  \r
+  CHAR16      *Str = UnicodeStr;\r
   while (TRUE) {\r
     *(UnicodeStr++) = (CHAR16) *AsciiStr;\r
     if (*(AsciiStr++) == '\0') {\r
@@ -60,24 +55,24 @@ Unicode2Ascii (
   IN  CHAR16         *UnicodeStr\r
   )\r
 /*++\r
-  \r
+\r
   Routine Description:\r
 \r
     This function converts Unicode string to ASCII string.\r
-  \r
+\r
   Arguments:\r
 \r
     AsciieStr      - NULL terminated ASCII output string.\r
     UnicodeStr     - NULL terminated Unicode input string.\r
\r
-  Returns: \r
+\r
+  Returns:\r
 \r
     Start of the ASCII ouput string.\r
-    \r
+\r
 --*/\r
 \r
 {\r
-  CHAR8      *Str = AsciiStr;  \r
+  CHAR8      *Str = AsciiStr;\r
   while (TRUE) {\r
     *(AsciiStr++) = (CHAR8) *UnicodeStr;\r
     if (*(UnicodeStr++) == '\0') {\r
@@ -96,10 +91,10 @@ ExtractDevicePathData (
 /*++\r
 \r
 Routine Description:\r
-  \r
+\r
 Arguments:\r
 \r
-Returns: \r
+Returns:\r
 \r
 --*/\r
 {\r
@@ -141,22 +136,22 @@ ExtractVariableData (
 \r
 Routine Description:\r
 \r
-  This function extract the EFI_HII_VARIABLE_PACK portion from the \r
+  This function extract the EFI_HII_VARIABLE_PACK portion from the\r
   each of the EFI_HII_PACKAGE_INSTANCE in HII handle database.\r
-  \r
+\r
 Arguments:\r
 \r
   DataTable       - On input, this parameter point to the EFI_HII_DATA_TABLE structure\r
                     of the final data buffer for the EFI_HII_EXPORT interface. This function\r
                     update the NumberOfVariableData attribute.\r
   IfrData         - It points to a staring address of a EFI_HII_IFR_PACK structure.\r
-  ExportBufferPtr - On input, it points the starting address of the data buffer to \r
+  ExportBufferPtr - On input, it points the starting address of the data buffer to\r
                     host the variable pack. On output, it is the starting address\r
                     of data buffer for the next extraction operation.\r
-Returns: \r
+Returns:\r
 \r
   VOID\r
-  \r
+\r
 --*/\r
 {\r
   EFI_HII_VARIABLE_PACK       *VariableContents;\r
@@ -356,13 +351,13 @@ HiiExportDatabase (
 /*++\r
 \r
 Routine Description:\r
-  \r
-  This function allows a program to extract a form or form package that has \r
+\r
+  This function allows a program to extract a form or form package that has\r
   previously been registered with the EFI HII database.\r
 \r
 Arguments:\r
 \r
-Returns: \r
+Returns:\r
 \r
 --*/\r
 {\r
@@ -414,7 +409,7 @@ Returns:
     //\r
     // Extract Size of Export Package\r
     //\r
-    SizeNeeded = SizeNeeded + PackageInstance->IfrSize \r
+    SizeNeeded = SizeNeeded + PackageInstance->IfrSize\r
                             + PackageInstance->StringSize\r
                             + sizeof (EFI_HII_DATA_TABLE)\r
                             + sizeof (EFI_HII_DEVICE_PATH_PACK);\r
@@ -696,35 +691,35 @@ HiiGetForms (
 /*++\r
 \r
 Routine Description:\r
-  \r
-  This function allows a program to extract a form or form package that has \r
+\r
+  This function allows a program to extract a form or form package that has\r
   previously been registered with the EFI HII database.\r
 \r
 Arguments:\r
   This         - A pointer to the EFI_HII_PROTOCOL instance.\r
-  \r
-  Handle       - Handle on which the form resides. Type EFI_HII_HANDLE is defined in \r
+\r
+  Handle       - Handle on which the form resides. Type EFI_HII_HANDLE is defined in\r
                  EFI_HII_PROTOCOL.NewPack() in the Packages section.\r
-            \r
+\r
   FormId       - The ID of the form to return. If the ID is zero, the entire form package is returned.\r
                  Type EFI_FORM_ID is defined in "Related Definitions" below.\r
-            \r
+\r
   BufferLength - On input, the length of the Buffer. On output, the length of the returned buffer, if\r
                  the length was sufficient and, if it was not, the length that is required to fit the\r
                  requested form(s).\r
-                  \r
+\r
   Buffer       - The buffer designed to receive the form(s).\r
 \r
-Returns: \r
+Returns:\r
 \r
   EFI_SUCCESS           -  Buffer filled with the requested forms. BufferLength\r
                            was updated.\r
-                           \r
+\r
   EFI_INVALID_PARAMETER -  The handle is unknown.\r
-  \r
+\r
   EFI_NOT_FOUND         -  A form on the requested handle cannot be found with the\r
                            requested FormId.\r
-                           \r
+\r
   EFI_BUFFER_TOO_SMALL  - The buffer provided was not large enough to allow the form to be stored.\r
 \r
 --*/\r
@@ -824,7 +819,7 @@ Returns:
             *BufferLengthTemp = FormLength;\r
             return EFI_BUFFER_TOO_SMALL;\r
           }\r
-          \r
+\r
           //\r
           // Rewind to start offset of the found Form\r
           //\r
@@ -857,21 +852,21 @@ HiiGetDefaultImageInitPack (
   IN     EFI_IFR_VARSTORE            *VarStore\r
   )\r
 /*++\r
-    \r
+\r
   Routine Description:\r
 \r
     Initialize the EFI_HII_VARIABLE_PACK_LIST structure and\r
     prepare it ready to be used by HiiGetDefaultImagePopulateMap ().\r
-      \r
+\r
   Arguments:\r
 \r
     VariablePackItem     - Variable Package List.\r
     VarStore             - IFR variable storage.\r
-   \r
-  Returns: \r
+\r
+  Returns:\r
 \r
     Return the pointer to the Map space.\r
-      \r
+\r
 --*/\r
 {\r
   CHAR16                *Name16;\r
@@ -900,7 +895,7 @@ HiiGetDefaultImageInitPack (
   VariablePack->VariableId         = VarStore->VarId;\r
   CopyMem (&VariablePack->VariableGuid, &VarStore->Guid, sizeof (EFI_GUID));\r
   VariablePack->VariableNameLength = (UINT32) ((StrLen (Name16) + 1) * 2);\r
-  VariablePack->Header.Length      = sizeof (*VariablePack) \r
+  VariablePack->Header.Length      = sizeof (*VariablePack)\r
                                               + VariablePack->VariableNameLength\r
                                               + VarStore->Size;\r
   //\r
@@ -914,28 +909,28 @@ HiiGetDefaultImageInitPack (
 STATIC\r
 VOID\r
 HiiGetDefaultImagePopulateMap (\r
-  IN OUT UINT8                        *Map,  \r
+  IN OUT UINT8                        *Map,\r
   IN     EFI_IFR_OP_HEADER            *FormSet,\r
   IN     EFI_IFR_VARSTORE             *VarStore,\r
   IN     UINTN                        DefaultMask\r
   )\r
 /*++\r
-    \r
+\r
   Routine Description:\r
 \r
    Fill the Map with all the default values either from NV or Hii database.\r
-      \r
+\r
   Arguments:\r
 \r
    Map         - Memory pointer to hold the default values.\r
    FormSet     - The starting EFI_IFR_OP_HEADER to begin retriving default values.\r
    VarStore    - IFR variable storage.\r
    DefaultMask - The mask used to get the default variable.\r
-   \r
-  Returns: \r
+\r
+  Returns:\r
 \r
    VOID\r
-      \r
+\r
 --*/\r
 {\r
   EFI_STATUS                     Status;\r
@@ -950,7 +945,7 @@ HiiGetDefaultImagePopulateMap (
   EFI_IFR_NV_DATA                *IfrNvData;\r
   EFI_GUID                       Guid;\r
   CHAR16                         *Name16;\r
-  CHAR8                          *Name8;  \r
+  CHAR8                          *Name8;\r
   EFI_HANDLE                      CallbackHandle;\r
   EFI_FORM_CALLBACK_PROTOCOL     *FormCallbackProt;\r
 \r
@@ -993,7 +988,7 @@ HiiGetDefaultImagePopulateMap (
   }\r
   if (!EFI_ERROR (Status)) {\r
     //\r
-    // Either Defaults/Manufacturing variable exists and appears to be valid. \r
+    // Either Defaults/Manufacturing variable exists and appears to be valid.\r
     // The map is read, exit w/ success now.\r
     //\r
     FreePool (Name16);\r
@@ -1002,10 +997,10 @@ HiiGetDefaultImagePopulateMap (
 \r
   //\r
   // First, prime the map with what already is in the NV.\r
-  // This is needed to cover a situation where the IFR does not contain all the \r
+  // This is needed to cover a situation where the IFR does not contain all the\r
   // defaults; either deliberately not having appropriate IFR, or in case of IFR_STRING, there is no default.\r
-  // Ignore status. Either it gets read or not. \r
-  //  \r
+  // Ignore status. Either it gets read or not.\r
+  //\r
   FormCallbackProt = NULL;\r
   CopyMem (&CallbackHandle, &((EFI_IFR_FORM_SET*) FormSet)->CallbackHandle, sizeof (CallbackHandle));\r
   if (CallbackHandle != NULL) {\r
@@ -1042,7 +1037,7 @@ HiiGetDefaultImagePopulateMap (
     }\r
   } else {\r
     //\r
-    // No callback available for this formset, read straight from NV. Deliberately ignore the Status. \r
+    // No callback available for this formset, read straight from NV. Deliberately ignore the Status.\r
     // The buffer will only be written if variable exists nd has correct size.\r
     //\r
     Status = EfiLibHiiVariableRetrieveFromNv (\r
@@ -1056,8 +1051,8 @@ HiiGetDefaultImagePopulateMap (
   //\r
   // Iterate all IFR statements and for applicable, retrieve the default into the Map.\r
   //\r
-  for (IfrItem = FormSet, VarId = 0; \r
-       IfrItem->OpCode != EFI_IFR_END_FORM_SET_OP; \r
+  for (IfrItem = FormSet, VarId = 0;\r
+       IfrItem->OpCode != EFI_IFR_END_FORM_SET_OP;\r
        IfrItem = (EFI_IFR_OP_HEADER *) ((UINT8*) IfrItem + IfrItem->Length)\r
       ) {\r
 \r
@@ -1073,11 +1068,11 @@ HiiGetDefaultImagePopulateMap (
 \r
     //\r
     // Skip opcodes that reference other VarStore than that specific to current map.\r
-    // \r
+    //\r
     if (VarId != VarStore->VarId) {\r
       continue;\r
     }\r
-    \r
+\r
     //\r
     // Extract the default value from this opcode if applicable, and apply it to the map.\r
     //\r
@@ -1089,7 +1084,7 @@ HiiGetDefaultImagePopulateMap (
         //\r
         // Get to the first EFI_IFR_ONE_OF_OPTION_OP\r
         //\r
-        IfrItem = (EFI_IFR_OP_HEADER *) ((UINT8*) IfrItem + IfrItem->Length); \r
+        IfrItem = (EFI_IFR_OP_HEADER *) ((UINT8*) IfrItem + IfrItem->Length);\r
         ASSERT (EFI_IFR_ONE_OF_OPTION_OP == IfrItem->OpCode);\r
 \r
         OneOfOpt = (EFI_IFR_ONE_OF_OPTION *)IfrItem;\r
@@ -1126,7 +1121,7 @@ HiiGetDefaultImagePopulateMap (
 \r
       case EFI_IFR_CHECKBOX_OP:\r
         ASSERT (IfrNvData->QuestionId + IfrNvData->StorageWidth <= VarStore->Size);\r
-        CheckBox = (EFI_IFR_CHECK_BOX *)IfrItem;        \r
+        CheckBox = (EFI_IFR_CHECK_BOX *)IfrItem;\r
         if (DefaultMask == EFI_IFR_FLAG_MANUFACTURING) {\r
           if (0 != (CheckBox->Flags & EFI_IFR_FLAG_MANUFACTURING)) {\r
             *(UINT8 *) (Map + IfrNvData->QuestionId) = TRUE;\r
@@ -1168,25 +1163,25 @@ HiiGetDefaultImage (
   OUT    EFI_HII_VARIABLE_PACK_LIST  **VariablePackList\r
   )\r
 /*++\r
-    \r
+\r
   Routine Description:\r
 \r
-  This function allows a program to extract the NV Image \r
+  This function allows a program to extract the NV Image\r
   that represents the default storage image\r
-      \r
+\r
   Arguments:\r
     This             - A pointer to the EFI_HII_PROTOCOL instance.\r
     Handle           - The HII handle from which will have default data retrieved.\r
     UINTN            - Mask used to retrieve the default image.\r
-    VariablePackList - Callee allocated, tightly-packed, link list data \r
+    VariablePackList - Callee allocated, tightly-packed, link list data\r
                          structure that contain all default varaible packs\r
                          from the Hii Database.\r
-    \r
-  Returns: \r
+\r
+  Returns:\r
     EFI_NOT_FOUND         - If Hii database does not contain any default images.\r
     EFI_INVALID_PARAMETER - Invalid input parameter.\r
     EFI_SUCCESS           - Operation successful.\r
-      \r
+\r
 --*/\r
 {\r
   EFI_HII_HANDLE_DATABASE        *HandleDatabase;\r
@@ -1198,7 +1193,7 @@ HiiGetDefaultImage (
   UINTN                          SetupMapNameSize;\r
   UINTN                          SizeOfMaps;\r
   EFI_HII_VARIABLE_PACK_LIST     *PackList;\r
-  EFI_HII_VARIABLE_PACK_LIST     *PackListNext;  \r
+  EFI_HII_VARIABLE_PACK_LIST     *PackListNext;\r
   EFI_HII_VARIABLE_PACK_LIST     *PackListLast;\r
   UINT8                          *Map;\r
 \r
@@ -1232,26 +1227,26 @@ HiiGetDefaultImage (
       //\r
       // Size of the map\r
       //\r
-      SizeOfMaps += VarStore->Size; \r
+      SizeOfMaps += VarStore->Size;\r
       //\r
       // add the size of the string, in Unicode\r
       //\r
-      SizeOfMaps += (VarStore->Header.Length - sizeof (*VarStore)) * 2; \r
+      SizeOfMaps += (VarStore->Header.Length - sizeof (*VarStore)) * 2;\r
       //\r
       // Space for node\r
       //\r
-      SizeOfMaps += sizeof (EFI_HII_VARIABLE_PACK);      \r
+      SizeOfMaps += sizeof (EFI_HII_VARIABLE_PACK);\r
       //\r
-      // Space for linked list node \r
+      // Space for linked list node\r
       //\r
-      SizeOfMaps += sizeof (EFI_HII_VARIABLE_PACK_LIST); \r
+      SizeOfMaps += sizeof (EFI_HII_VARIABLE_PACK_LIST);\r
     }\r
 \r
     IfrItem = (EFI_IFR_OP_HEADER *) ((UINT8 *) IfrItem + IfrItem->Length);\r
   }\r
 \r
   //\r
-  // If the FormSet OpCode has a non-zero NvDataSize. There is a default \r
+  // If the FormSet OpCode has a non-zero NvDataSize. There is a default\r
   // NvMap with ID=0, GUID that of the formset itself and "Setup" as name.\r
   //\r
   SetupMapNameSize = StrLen (SETUP_MAP_NAME) + 1;\r
@@ -1269,33 +1264,33 @@ HiiGetDefaultImage (
     //\r
     // Size of the map\r
     //\r
-    SizeOfMaps += VarStoreDefault->Size; \r
+    SizeOfMaps += VarStoreDefault->Size;\r
     //\r
     // add the size of the string\r
     //\r
-    SizeOfMaps += sizeof (SETUP_MAP_NAME); \r
+    SizeOfMaps += sizeof (SETUP_MAP_NAME);\r
     //\r
     // Space for node\r
     //\r
-    SizeOfMaps += sizeof (EFI_HII_VARIABLE_PACK);      \r
+    SizeOfMaps += sizeof (EFI_HII_VARIABLE_PACK);\r
     //\r
-    // Space for linked list node \r
+    // Space for linked list node\r
     //\r
-    SizeOfMaps += sizeof (EFI_HII_VARIABLE_PACK_LIST); \r
+    SizeOfMaps += sizeof (EFI_HII_VARIABLE_PACK_LIST);\r
   }\r
 \r
   if (0 == SizeOfMaps) {\r
     //\r
     // The IFR does not have any explicit or default map(s).\r
     //\r
-    return EFI_NOT_FOUND; \r
+    return EFI_NOT_FOUND;\r
   }\r
 \r
   //\r
   // Allocate the return buffer\r
   //\r
   PackList = AllocateZeroPool (SizeOfMaps);\r
-  ASSERT (NULL != PackList); \r
+  ASSERT (NULL != PackList);\r
 \r
   PackListNext = PackList;\r
   PackListLast = PackList;\r
@@ -1337,7 +1332,7 @@ HiiGetDefaultImage (
 \r
   PackListLast->NextVariablePack = NULL;\r
   *VariablePackList = PackList;\r
-  \r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -1354,7 +1349,7 @@ HiiUpdateForm (
 /*++\r
 \r
 Routine Description:\r
-  This function allows the caller to update a form that has \r
+  This function allows the caller to update a form that has\r
   previously been registered with the EFI HII database.\r
 \r
 Arguments:\r
@@ -1363,7 +1358,7 @@ Arguments:
   AddData    - If TRUE, add data.  If FALSE, remove data\r
   Data       - If adding data, this is the pointer to the data to add\r
 \r
-Returns: \r
+Returns:\r
   EFI_SUCCESS - Update success.\r
   Other       - Update fail.\r
 \r