]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c
Clean up BootMaint module in BdsDxe.
[mirror_edk2.git] / MdeModulePkg / Universal / BdsDxe / BootMaint / BBSsupport.c
index cb253c2fdfa527d30bcbf9752a1c8402561386dd..11ae2b115cdc115d3e21dbd409e1acf88381b18a 100644 (file)
@@ -16,39 +16,27 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include "BBSsupport.h"\r
 \r
-EFI_DEVICE_PATH_PROTOCOL  EndDevicePath[] = {\r
-  END_DEVICE_PATH_TYPE,\r
-  END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
-  END_DEVICE_PATH_LENGTH,\r
-  0\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 +52,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
+  @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
-Returns:\r
+  @return Actual length\r
 \r
-  Actuall 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 +84,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 +201,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 +230,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
@@ -293,7 +284,7 @@ BdsCreateLegacyBootOption (
   //\r
   UnicodeToAscii (BootDesc, StrSize (BootDesc), HelpString);\r
   StringLen = AsciiStrLen (HelpString);\r
-  NewBbsDevPathNode = EfiAllocateZeroPool (sizeof (BBS_BBS_DEVICE_PATH) + StringLen);\r
+  NewBbsDevPathNode = AllocateZeroPool (sizeof (BBS_BBS_DEVICE_PATH) + StringLen);\r
   if (NewBbsDevPathNode == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
@@ -322,7 +313,7 @@ BdsCreateLegacyBootOption (
     sizeof (BBS_TABLE) +\r
     sizeof (UINT16);\r
 \r
-  Buffer = EfiAllocateZeroPool (BufferSize);\r
+  Buffer = AllocateZeroPool (BufferSize);\r
   if (Buffer == NULL) {\r
     FreePool (NewBbsDevPathNode);\r
     FreePool (CurrentBbsDevPath);\r
@@ -371,7 +362,7 @@ BdsCreateLegacyBootOption (
   SafeFreePool (Buffer);\r
   Buffer = NULL;\r
 \r
-  NewBootOrderList = EfiAllocateZeroPool (*BootOrderListSize + sizeof (UINT16));\r
+  NewBootOrderList = AllocateZeroPool (*BootOrderListSize + sizeof (UINT16));\r
   if (NULL == NewBootOrderList) {\r
     FreePool (NewBbsDevPathNode);\r
     FreePool (CurrentBbsDevPath);\r
@@ -394,6 +385,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,7 +427,19 @@ BdsIsLegacyBootOption (
   return Ret;\r
 }\r
 \r
+/**\r
+\r
+  Delete boot option specified by OptionNumber and adjust the boot order.\r
+\r
+  @param  OptionNumber      The boot option to be deleted.\r
+  @param  BootOrder         Boot order list to be adjusted by remove this boot option.\r
+  @param  BootOrderSize     The size of Boot order list will be modified.\r
+  \r
+  @retval EFI_SUCCESS       The boot option is deleted successfully.\r
+\r
+**/\r
 EFI_STATUS\r
+EFIAPI\r
 BdsDeleteBootOption (\r
   IN UINTN                       OptionNumber,\r
   IN OUT UINT16                  *BootOrder,\r
@@ -467,29 +480,18 @@ BdsDeleteBootOption (
 \r
 }\r
 \r
+/**\r
+  Delete all the invalid legacy boot options.\r
+\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
+**/\r
 EFI_STATUS\r
+EFIAPI\r
 BdsDeleteAllInvalidLegacyBootOptions (\r
   VOID\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-    Delete all the invalid legacy boot options.\r
-\r
-  Arguments:\r
-\r
-    None.\r
-\r
-  Returns:\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
-\r
---*/\r
 {\r
   UINT16                    *BootOrder;\r
   UINT8                     *BootOptionVar;\r
@@ -593,7 +595,7 @@ BdsDeleteAllInvalidLegacyBootOptions (
       );\r
   }\r
 \r
-  if (BootOrderSize) {\r
+  if (BootOrderSize != 0) {\r
     Status = gRT->SetVariable (\r
                     L"BootOrder",\r
                     &gEfiGlobalVariableGuid,\r
@@ -610,6 +612,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 +682,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 +735,19 @@ 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
+  @retval EFI_SUCCESS       The boot options are added successfully \r
+                            or they are already in boot options.\r
 \r
-Returns:\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
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsAddNonExistingLegacyBootOptions (\r
+  VOID\r
+  )\r
 {\r
   UINT16                    *BootOrder;\r
   UINTN                     BootOrderSize;\r
@@ -825,6 +844,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 +881,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
@@ -917,7 +956,7 @@ BdsCreateDevOrder (
   TotalSize += (HeaderSize + sizeof (UINT16) * NETCount);\r
   TotalSize += (HeaderSize + sizeof (UINT16) * BEVCount);\r
 \r
-  DevOrder = EfiAllocateZeroPool (TotalSize);\r
+  DevOrder = AllocateZeroPool (TotalSize);\r
   if (NULL == DevOrder) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
@@ -928,7 +967,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 +975,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 +983,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 +991,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 +999,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 +1015,19 @@ BdsCreateDevOrder (
   return Status;\r
 }\r
 \r
+/**\r
+\r
+  Add the legacy boot devices from BBS table into \r
+  the legacy device boot order.\r
+\r
+  @retval EFI_SUCCESS       The boot devices are added successfully.\r
+\r
+**/\r
 EFI_STATUS\r
+EFIAPI\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 +1095,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
@@ -1107,7 +1144,7 @@ Index# is a 16 bit integer, the low byte of it stands for the index in BBS table
   TotalSize += (HeaderSize + NETCount * sizeof (UINT16));\r
   TotalSize += (HeaderSize + BEVCount * sizeof (UINT16));\r
 \r
-  NewDevOrder = EfiAllocateZeroPool (TotalSize);\r
+  NewDevOrder = AllocateZeroPool (TotalSize);\r
   if (NULL == NewDevOrder) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
@@ -1285,7 +1322,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 +1341,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 +1361,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 +1381,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 +1401,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 +1421,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 +1444,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 +1455,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 +1481,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 +1525,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 +1553,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,7 +1573,17 @@ PrintBbsTable (
   DEBUG ((DEBUG_ERROR, "\n"));\r
 }\r
 \r
+/**\r
+\r
+  Set the boot priority for BBS entries based on boot option entry and boot order.\r
+\r
+  @param  Entry             The boot option is to be checked for refresh BBS table.\r
+  \r
+  @retval EFI_SUCCESS       The boot priority for BBS entries is refreshed successfully.\r
+\r
+**/\r
 EFI_STATUS\r
+EFIAPI\r
 BdsRefreshBbsTableForBoot (\r
   IN BDS_COMMON_OPTION        *Entry\r
   )\r
@@ -1602,7 +1661,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 +1704,7 @@ BdsRefreshBbsTableForBoot (
     }\r
   }\r
 \r
-  if (BootOrder) {\r
+  if (BootOrder != NULL) {\r
     SafeFreePool (BootOrder);\r
   }\r
   //\r