]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c
Code scrube for MdeModule Definitions.
[mirror_edk2.git] / MdeModulePkg / Universal / BdsDxe / BootMaint / BBSsupport.c
index cb253c2fdfa527d30bcbf9752a1c8402561386dd..853bede9435422760df55c78bfcb34f64b670f65 100644 (file)
@@ -23,32 +23,27 @@ EFI_DEVICE_PATH_PROTOCOL  EndDevicePath[] = {
   0\r
 };\r
 \r
+/**\r
+\r
+  Translate the first n characters of an Ascii string to\r
+  Unicode characters. The count n is indicated by parameter\r
+  Size. If Size is greater than the length of string, then\r
+  the entire string is translated.\r
+\r
+\r
+  @param a               Pointer to input Ascii string.\r
+  @param Size            The number of characters to translate.\r
+  @param u               Pointer to output Unicode string buffer.\r
+\r
+  @return None\r
+\r
+**/\r
 VOID\r
 AsciiToUnicodeSize (\r
   IN UINT8              *a,\r
   IN UINTN              Size,\r
   OUT UINT16            *u\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-    Translate the first n characters of an Ascii string to\r
-    Unicode characters. The count n is indicated by parameter\r
-    Size. If Size is greater than the length of string, then\r
-    the entire string is translated.\r
-\r
-  Arguments:\r
-\r
-    a         - Pointer to input Ascii string.\r
-    Size      - The number of characters to translate.\r
-    u         - Pointer to output Unicode string buffer.\r
-\r
-  Returns:\r
-\r
-    None\r
-\r
---*/\r
 {\r
   UINTN i;\r
 \r
@@ -64,28 +59,25 @@ AsciiToUnicodeSize (
   u[i] = 0;\r
 }\r
 \r
-UINTN\r
-UnicodeToAscii (\r
-  IN  CHAR16  *UStr,\r
-  IN  UINTN   Length,\r
-  OUT CHAR8   *AStr\r
-  )\r
-/*++\r
-Routine Description:\r
+/**\r
 \r
   change a Unicode string t ASCII string\r
 \r
-Arguments:\r
-\r
-  UStr   - Unicode string\r
-  Lenght - most possible length of AStr\r
-  AStr   - ASCII string to pass out\r
 \r
-Returns:\r
+  @param UStr            Unicode string\r
+                         Lenght - most possible length of AStr\r
+  @param Length          The length of UStr.\r
+  @param AStr            ASCII string to pass out\r
 \r
-  Actuall length\r
+  @return Actual length\r
 \r
---*/\r
+**/\r
+UINTN\r
+UnicodeToAscii (\r
+  IN  CHAR16  *UStr,\r
+  IN  UINTN   Length,\r
+  OUT CHAR8   *AStr\r
+  )\r
 {\r
   UINTN Index;\r
 \r
@@ -99,6 +91,17 @@ Returns:
   return Index;\r
 }\r
 \r
+/**\r
+  EDES_TODO: Add function description.\r
+\r
+  @param CurBBSEntry     EDES_TODO: Add parameter description\r
+  @param Index           EDES_TODO: Add parameter description\r
+  @param BufSize         EDES_TODO: Add parameter description\r
+  @param BootString      EDES_TODO: Add parameter description\r
+\r
+  @return EDES_TODO: Add description for return value\r
+\r
+**/\r
 VOID\r
 BdsBuildLegacyDevNameString (\r
   IN BBS_TABLE                 *CurBBSEntry,\r
@@ -205,6 +208,27 @@ BdsBuildLegacyDevNameString (
   }\r
 }\r
 \r
+/**\r
+\r
+  Create a legacy boot option for the specified entry of\r
+  BBS table, save it as variable, and append it to the boot\r
+  order list.\r
+\r
+\r
+  @param CurrentBbsEntry Pointer to current BBS table.\r
+  @param CurrentBbsDevPath Pointer to the Device Path Protocol instance of BBS\r
+  @param Index           Index of the specified entry in BBS table.\r
+  @param BootOrderList   On input, the original boot order list.\r
+                         On output, the new boot order list attached with the\r
+                         created node.\r
+  @param BootOrderListSize On input, the original size of boot order list.\r
+                         - On output, the size of new boot order list.\r
+\r
+  @retval  EFI_SUCCESS             Boot Option successfully created.\r
+  @retval  EFI_OUT_OF_RESOURCES    Fail to allocate necessary memory.\r
+  @retval  Other                   Error occurs while setting variable.\r
+\r
+**/\r
 EFI_STATUS\r
 BdsCreateLegacyBootOption (\r
   IN BBS_TABLE                        *CurrentBbsEntry,\r
@@ -213,32 +237,6 @@ BdsCreateLegacyBootOption (
   IN OUT UINT16                       **BootOrderList,\r
   IN OUT UINTN                        *BootOrderListSize\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-    Create a legacy boot option for the specified entry of\r
-    BBS table, save it as variable, and append it to the boot\r
-    order list.\r
-\r
-  Arguments:\r
-\r
-    CurrentBbsEntry        - Pointer to current BBS table.\r
-    CurrentBbsDevPath      - Pointer to the Device Path Protocol instance of BBS\r
-    Index                  - Index of the specified entry in BBS table.\r
-    BootOrderList          - On input, the original boot order list.\r
-                             On output, the new boot order list attached with the\r
-                             created node.\r
-    BootOrderListSize      - On input, the original size of boot order list.\r
-                           - On output, the size of new boot order list.\r
-\r
-  Returns:\r
-\r
-    EFI_SUCCESS            - Boot Option successfully created.\r
-    EFI_OUT_OF_RESOURCES   - Fail to allocate necessary memory.\r
-    Other                  - Error occurs while setting variable.\r
-\r
---*/\r
 {\r
   EFI_STATUS           Status;\r
   UINT16               CurrentBootOptionNo;\r
@@ -394,6 +392,16 @@ BdsCreateLegacyBootOption (
   return Status;\r
 }\r
 \r
+/**\r
+  EDES_TODO: Add function description.\r
+\r
+  @param BootOptionVar   EDES_TODO: Add parameter description\r
+  @param BbsEntry        EDES_TODO: Add parameter description\r
+  @param BbsIndex        EDES_TODO: Add parameter description\r
+\r
+  @return EDES_TODO: Add description for return value\r
+\r
+**/\r
 BOOLEAN\r
 BdsIsLegacyBootOption (\r
   IN UINT8                 *BootOptionVar,\r
@@ -426,6 +434,16 @@ BdsIsLegacyBootOption (
   return Ret;\r
 }\r
 \r
+/**\r
+  EDES_TODO: Add function description.\r
+\r
+  @param OptionNumber    EDES_TODO: Add parameter description\r
+  @param BootOrder       EDES_TODO: Add parameter description\r
+  @param BootOrderSize   EDES_TODO: Add parameter description\r
+\r
+  @return EDES_TODO: Add description for return value\r
+\r
+**/\r
 EFI_STATUS\r
 BdsDeleteBootOption (\r
   IN UINTN                       OptionNumber,\r
@@ -467,29 +485,24 @@ BdsDeleteBootOption (
 \r
 }\r
 \r
-EFI_STATUS\r
-BdsDeleteAllInvalidLegacyBootOptions (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-    Delete all the invalid legacy boot options.\r
+/**\r
 \r
-  Arguments:\r
+  Delete all the invalid legacy boot options.\r
 \r
-    None.\r
 \r
-  Returns:\r
+  @param VOID            EDES_TODO: Add parameter description\r
 \r
-    EFI_SUCCESS            - All invalide legacy boot options are deleted.\r
-    EFI_OUT_OF_RESOURCES   - Fail to allocate necessary memory.\r
-    EFI_NOT_FOUND          - Fail to retrive variable of boot order.\r
-    Other                  - Error occurs while setting variable or locating\r
-                             protocol.\r
+  @retval  EFI_SUCCESS             All invalide legacy boot options are deleted.\r
+  @retval  EFI_OUT_OF_RESOURCES    Fail to allocate necessary memory.\r
+  @retval  EFI_NOT_FOUND           Fail to retrive variable of boot order.\r
+  @retval  Other                   Error occurs while setting variable or locating\r
+                                   protocol.\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+BdsDeleteAllInvalidLegacyBootOptions (\r
+  VOID\r
+  )\r
 {\r
   UINT16                    *BootOrder;\r
   UINT8                     *BootOptionVar;\r
@@ -593,7 +606,7 @@ BdsDeleteAllInvalidLegacyBootOptions (
       );\r
   }\r
 \r
-  if (BootOrderSize) {\r
+  if (BootOrderSize != 0) {\r
     Status = gRT->SetVariable (\r
                     L"BootOrder",\r
                     &gEfiGlobalVariableGuid,\r
@@ -610,6 +623,19 @@ BdsDeleteAllInvalidLegacyBootOptions (
   return Status;\r
 }\r
 \r
+/**\r
+  EDES_TODO: Add function description.\r
+\r
+  @param BootOrder       EDES_TODO: Add parameter description\r
+  @param BootOptionNum   EDES_TODO: Add parameter description\r
+  @param DevType         EDES_TODO: Add parameter description\r
+  @param Attribute       EDES_TODO: Add parameter description\r
+  @param BbsIndex        EDES_TODO: Add parameter description\r
+  @param OptionNumber    EDES_TODO: Add parameter description\r
+\r
+  @return EDES_TODO: Add description for return value\r
+\r
+**/\r
 BOOLEAN\r
 BdsFindLegacyBootOptionByDevType (\r
   IN UINT16                 *BootOrder,\r
@@ -667,6 +693,17 @@ BdsFindLegacyBootOptionByDevType (
   return Found;\r
 }\r
 \r
+/**\r
+  EDES_TODO: Add function description.\r
+\r
+  @param BbsItem         EDES_TODO: Add parameter description\r
+  @param Index           EDES_TODO: Add parameter description\r
+  @param BootOrderList   EDES_TODO: Add parameter description\r
+  @param BootOrderListSize EDES_TODO: Add parameter description\r
+\r
+  @return EDES_TODO: Add description for return value\r
+\r
+**/\r
 EFI_STATUS\r
 BdsCreateOneLegacyBootOption (\r
   IN BBS_TABLE              *BbsItem,\r
@@ -709,26 +746,21 @@ BdsCreateOneLegacyBootOption (
   return Status;\r
 }\r
 \r
-EFI_STATUS\r
-BdsAddNonExistingLegacyBootOptions (\r
-  VOID\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Add the legacy boot options from BBS table if they do not exist.\r
 \r
-Arguments:\r
-\r
-  None.\r
 \r
-Returns:\r
+  @param VOID            EDES_TODO: Add parameter description\r
 \r
-  EFI_SUCCESS       - The boot options are added successfully or they are already in boot options.\r
-  others            - An error occurred when creating legacy boot options.\r
+  @retval  EFI_SUCCESS        The boot options are added successfully or they are already in boot options.\r
+  @retval  others             An error occurred when creating legacy boot options.\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+BdsAddNonExistingLegacyBootOptions (\r
+  VOID\r
+  )\r
 {\r
   UINT16                    *BootOrder;\r
   UINTN                     BootOrderSize;\r
@@ -825,6 +857,17 @@ Returns:
   return Status;\r
 }\r
 \r
+/**\r
+  EDES_TODO: Add function description.\r
+\r
+  @param BbsTable        EDES_TODO: Add parameter description\r
+  @param BbsType         EDES_TODO: Add parameter description\r
+  @param BbsCount        EDES_TODO: Add parameter description\r
+  @param Buf             EDES_TODO: Add parameter description\r
+\r
+  @return EDES_TODO: Add description for return value\r
+\r
+**/\r
 UINT16 *\r
 BdsFillDevOrderBuf (\r
   IN BBS_TABLE                    *BbsTable,\r
@@ -851,6 +894,15 @@ BdsFillDevOrderBuf (
   return Buf;\r
 }\r
 \r
+/**\r
+  EDES_TODO: Add function description.\r
+\r
+  @param BbsTable        EDES_TODO: Add parameter description\r
+  @param BbsCount        EDES_TODO: Add parameter description\r
+\r
+  @return EDES_TODO: Add description for return value\r
+\r
+**/\r
 EFI_STATUS\r
 BdsCreateDevOrder (\r
   IN BBS_TABLE                  *BbsTable,\r
@@ -928,7 +980,7 @@ BdsCreateDevOrder (
   Ptr += sizeof (BBS_TYPE);\r
   *((UINT16 *) Ptr) = (UINT16) (sizeof (UINT16) + FDCount * sizeof (UINT16));\r
   Ptr += sizeof (UINT16);\r
-  if (FDCount) {\r
+  if (FDCount != 0) {\r
     Ptr = (UINT8 *) BdsFillDevOrderBuf (BbsTable, BBS_FLOPPY, BbsCount, (UINT16 *) Ptr);\r
   }\r
 \r
@@ -936,7 +988,7 @@ BdsCreateDevOrder (
   Ptr += sizeof (BBS_TYPE);\r
   *((UINT16 *) Ptr) = (UINT16) (sizeof (UINT16) + HDCount * sizeof (UINT16));\r
   Ptr += sizeof (UINT16);\r
-  if (HDCount) {\r
+  if (HDCount != 0) {\r
     Ptr = (UINT8 *) BdsFillDevOrderBuf (BbsTable, BBS_HARDDISK, BbsCount, (UINT16 *) Ptr);\r
   }\r
 \r
@@ -944,7 +996,7 @@ BdsCreateDevOrder (
   Ptr += sizeof (BBS_TYPE);\r
   *((UINT16 *) Ptr) = (UINT16) (sizeof (UINT16) + CDCount * sizeof (UINT16));\r
   Ptr += sizeof (UINT16);\r
-  if (CDCount) {\r
+  if (CDCount != 0) {\r
     Ptr = (UINT8 *) BdsFillDevOrderBuf (BbsTable, BBS_CDROM, BbsCount, (UINT16 *) Ptr);\r
   }\r
 \r
@@ -952,7 +1004,7 @@ BdsCreateDevOrder (
   Ptr += sizeof (BBS_TYPE);\r
   *((UINT16 *) Ptr) = (UINT16) (sizeof (UINT16) + NETCount * sizeof (UINT16));\r
   Ptr += sizeof (UINT16);\r
-  if (NETCount) {\r
+  if (NETCount != 0) {\r
     Ptr = (UINT8 *) BdsFillDevOrderBuf (BbsTable, BBS_EMBED_NETWORK, BbsCount, (UINT16 *) Ptr);\r
   }\r
 \r
@@ -960,12 +1012,12 @@ BdsCreateDevOrder (
   Ptr += sizeof (BBS_TYPE);\r
   *((UINT16 *) Ptr) = (UINT16) (sizeof (UINT16) + BEVCount * sizeof (UINT16));\r
   Ptr += sizeof (UINT16);\r
-  if (BEVCount) {\r
+  if (BEVCount != 0) {\r
     Ptr = (UINT8 *) BdsFillDevOrderBuf (BbsTable, BBS_BEV_DEVICE, BbsCount, (UINT16 *) Ptr);\r
   }\r
 \r
   Status = gRT->SetVariable (\r
-                  VarLegacyDevOrder,\r
+                  VAR_LEGACY_DEV_ORDER,\r
                   &EfiLegacyDevOrderGuid,\r
                   VAR_FLAG,\r
                   TotalSize,\r
@@ -976,21 +1028,18 @@ BdsCreateDevOrder (
   return Status;\r
 }\r
 \r
+/**\r
+  EDES_TODO: Add function description.\r
+\r
+  @param VOID            EDES_TODO: Add parameter description\r
+\r
+  @return EDES_TODO: Add description for return value\r
+\r
+**/\r
 EFI_STATUS\r
 BdsUpdateLegacyDevOrder (\r
   VOID\r
   )\r
-/*++\r
-Format of LegacyDevOrder variable:\r
-|-----------------------------------------------------------------------------------------------------------------\r
-| BBS_FLOPPY | Length | Index0 | Index1 | ... | BBS_HARDDISK | Length | Index0 | Index1 | ... | BBS_CDROM | Length | Index0 | ...\r
-|-----------------------------------------------------------------------------------------------------------------\r
-\r
-Length is a 16 bit integer, it indicates how many Indexes follows, including the size of itself.\r
-Index# is a 16 bit integer, the low byte of it stands for the index in BBS table\r
-           the high byte of it only have two value 0 and 0xFF, 0xFF means this device has been\r
-           disabled by user.\r
---*/\r
 {\r
   UINT8                     *DevOrder;\r
   UINT8                     *NewDevOrder;\r
@@ -1058,7 +1107,7 @@ Index# is a 16 bit integer, the low byte of it stands for the index in BBS table
                 );\r
 \r
   DevOrder = (UINT8 *) BdsLibGetVariableAndSize (\r
-                        VarLegacyDevOrder,\r
+                        VAR_LEGACY_DEV_ORDER,\r
                         &EfiLegacyDevOrderGuid,\r
                         &DevOrderSize\r
                         );\r
@@ -1285,7 +1334,7 @@ Index# is a 16 bit integer, the low byte of it stands for the index in BBS table
     // at this point we have copied those valid indexes to new buffer\r
     // and we should check if there is any new appeared boot device\r
     //\r
-    if (Idx) {\r
+    if (Idx != 0) {\r
       for (Index2 = 0; Index2 < *Idx; Index2++) {\r
         if ((NewDevPtr[Index2] & 0xFF) == (UINT16) Index) {\r
           break;\r
@@ -1304,7 +1353,7 @@ Index# is a 16 bit integer, the low byte of it stands for the index in BBS table
     }\r
   }\r
 \r
-  if (FDCount) {\r
+  if (FDCount != 0) {\r
     //\r
     // Just to make sure that disabled indexes are all at the end of the array\r
     //\r
@@ -1324,7 +1373,7 @@ Index# is a 16 bit integer, the low byte of it stands for the index in BBS table
     }\r
   }\r
 \r
-  if (HDCount) {\r
+  if (HDCount != 0) {\r
     //\r
     // Just to make sure that disabled indexes are all at the end of the array\r
     //\r
@@ -1344,7 +1393,7 @@ Index# is a 16 bit integer, the low byte of it stands for the index in BBS table
     }\r
   }\r
 \r
-  if (CDCount) {\r
+  if (CDCount != 0) {\r
     //\r
     // Just to make sure that disabled indexes are all at the end of the array\r
     //\r
@@ -1364,7 +1413,7 @@ Index# is a 16 bit integer, the low byte of it stands for the index in BBS table
     }\r
   }\r
 \r
-  if (NETCount) {\r
+  if (NETCount != 0) {\r
     //\r
     // Just to make sure that disabled indexes are all at the end of the array\r
     //\r
@@ -1384,7 +1433,7 @@ Index# is a 16 bit integer, the low byte of it stands for the index in BBS table
     }\r
   }\r
 \r
-  if (BEVCount) {\r
+  if (BEVCount!= 0) {\r
     //\r
     // Just to make sure that disabled indexes are all at the end of the array\r
     //\r
@@ -1407,7 +1456,7 @@ Index# is a 16 bit integer, the low byte of it stands for the index in BBS table
   SafeFreePool (DevOrder);\r
 \r
   Status = gRT->SetVariable (\r
-                  VarLegacyDevOrder,\r
+                  VAR_LEGACY_DEV_ORDER,\r
                   &EfiLegacyDevOrderGuid,\r
                   VAR_FLAG,\r
                   TotalSize,\r
@@ -1418,18 +1467,22 @@ Index# is a 16 bit integer, the low byte of it stands for the index in BBS table
   return Status;\r
 }\r
 \r
+/**\r
+  EDES_TODO: Add function description.\r
+\r
+  @param DeviceType      EDES_TODO: Add parameter description\r
+  @param LocalBbsTable   EDES_TODO: Add parameter description\r
+  @param Priority        EDES_TODO: Add parameter description\r
+\r
+  @return EDES_TODO: Add description for return value\r
+\r
+**/\r
 EFI_STATUS\r
 BdsSetBootPriority4SameTypeDev (\r
   IN UINT16                                              DeviceType,\r
   IN OUT BBS_TABLE                                       *LocalBbsTable,\r
   IN OUT UINT16                                          *Priority\r
   )\r
-/*++\r
-DeviceType           - BBS_FLOPPY, BBS_HARDDISK, BBS_CDROM and so on\r
-LocalBbsTable       - BBS table instance\r
-Priority                 - As input arg, it is the start point of boot priority, as output arg, it is the start point of boot\r
-                              priority can be used next time.\r
---*/\r
 {\r
   UINT8   *DevOrder;\r
 \r
@@ -1440,7 +1493,7 @@ Priority                 - As input arg, it is the start point of boot priority,
   UINTN   Index;\r
 \r
   DevOrder = BdsLibGetVariableAndSize (\r
-              VarLegacyDevOrder,\r
+              VAR_LEGACY_DEV_ORDER,\r
               &EfiLegacyDevOrderGuid,\r
               &DevOrderSize\r
               );\r
@@ -1484,6 +1537,14 @@ Priority                 - As input arg, it is the start point of boot priority,
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  EDES_TODO: Add function description.\r
+\r
+  @param LocalBbsTable   EDES_TODO: Add parameter description\r
+\r
+  @return EDES_TODO: Add description for return value\r
+\r
+**/\r
 VOID\r
 PrintBbsTable (\r
   IN BBS_TABLE                      *LocalBbsTable\r
@@ -1504,7 +1565,7 @@ PrintBbsTable (
 \r
     DEBUG (\r
       (DEBUG_ERROR,\r
-      " %02x: %04x %02x/%02x/%02x %02x/02%x %04x %04x %04x:%04x\n",\r
+      " %02x: %04x %02x/%02x/%02x %02x/%02x %04x %04x %04x:%04x\n",\r
       (UINTN) Idx,\r
       (UINTN) LocalBbsTable[Idx].BootPriority,\r
       (UINTN) LocalBbsTable[Idx].Bus,\r
@@ -1524,6 +1585,14 @@ PrintBbsTable (
   DEBUG ((DEBUG_ERROR, "\n"));\r
 }\r
 \r
+/**\r
+  EDES_TODO: Add function description.\r
+\r
+  @param Entry           EDES_TODO: Add parameter description\r
+\r
+  @return EDES_TODO: Add description for return value\r
+\r
+**/\r
 EFI_STATUS\r
 BdsRefreshBbsTableForBoot (\r
   IN BDS_COMMON_OPTION        *Entry\r
@@ -1602,7 +1671,7 @@ BdsRefreshBbsTableForBoot (
                           &gEfiGlobalVariableGuid,\r
                           &BootOrderSize\r
                           );\r
-  for (Index = 0; BootOrder && Index < BootOrderSize / sizeof (UINT16); Index++) {\r
+  for (Index = 0; ((BootOrder != NULL) && (Index < BootOrderSize / sizeof (UINT16))); Index++) {\r
     UnicodeSPrint (BootOption, sizeof (BootOption), L"Boot%04x", BootOrder[Index]);\r
     BootOptionVar = BdsLibGetVariableAndSize (\r
                       BootOption,\r
@@ -1645,7 +1714,7 @@ BdsRefreshBbsTableForBoot (
     }\r
   }\r
 \r
-  if (BootOrder) {\r
+  if (BootOrder != NULL) {\r
     SafeFreePool (BootOrder);\r
   }\r
   //\r