\r
\r
@param AStr Pointer to input Ascii string.\r
- @param Size The number of characters to translate.\r
+ @param Size The number of characters to translate.\r
@param UStr Pointer to output Unicode string buffer.\r
\r
- @return None\r
-\r
**/\r
VOID\r
AsciiToUnicodeSize (\r
UStr[Idx] = 0;\r
}\r
\r
-/**\r
-\r
- change a Unicode string t ASCII string\r
-\r
-\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
- @return Actual length\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
- //\r
- // just buffer copy, not character copy\r
- //\r
- for (Index = 0; Index < Length; Index++) {\r
- *AStr++ = (CHAR8) *UStr++;\r
- }\r
-\r
- return Index;\r
-}\r
-\r
/**\r
Build Legacy Device Name String according.\r
\r
@param BufSize The buffer size.\r
@param BootString The output string.\r
\r
- @return VOID No output.\r
-\r
**/\r
VOID\r
BdsBuildLegacyDevNameString (\r
- IN BBS_TABLE *CurBBSEntry,\r
- IN UINTN Index,\r
- IN UINTN BufSize,\r
- OUT CHAR16 *BootString\r
+ IN BBS_TABLE *CurBBSEntry,\r
+ IN UINTN Index,\r
+ IN UINTN BufSize,\r
+ OUT CHAR16 *BootString\r
)\r
{\r
CHAR16 *Fmt;\r
BOOLEAN IndexNotFound;\r
BBS_BBS_DEVICE_PATH *NewBbsDevPathNode;\r
\r
- if (NULL == (*BootOrderList)) {\r
+ if ((*BootOrderList) == NULL) {\r
CurrentBootOptionNo = 0;\r
} else {\r
for (ArrayIndex = 0; ArrayIndex < (UINTN) (*BootOrderListSize / sizeof (UINT16)); ArrayIndex++) {\r
//\r
// Create new BBS device path node with description string\r
//\r
- UnicodeToAscii (BootDesc, StrSize (BootDesc), HelpString);\r
+ UnicodeStrToAsciiStr ((CONST CHAR16*)&BootDesc, (CHAR8*)&HelpString);\r
+\r
StringLen = AsciiStrLen (HelpString);\r
NewBbsDevPathNode = AllocateZeroPool (sizeof (BBS_BBS_DEVICE_PATH) + StringLen);\r
if (NewBbsDevPathNode == NULL) {\r
/**\r
Delete all the invalid legacy boot options.\r
\r
- \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
SafeFreePool (BootOrder);\r
return EFI_OUT_OF_RESOURCES;\r
}\r
-\r
+ \r
+ //\r
+ // Skip Non-Legacy boot options\r
+ // \r
if (!BdsIsLegacyBootOption (BootOptionVar, &BbsEntry, &BbsIndex)) {\r
SafeFreePool (BootOptionVar);\r
Index++;\r
);\r
}\r
\r
+ //\r
+ // Adjust the number of boot options.\r
+ //\r
if (BootOrderSize != 0) {\r
Status = gRT->SetVariable (\r
L"BootOrder",\r
return Found;\r
}\r
\r
+ //\r
+ // Loop all boot option from variable\r
+ //\r
for (BootOrderIndex = 0; BootOrderIndex < BootOptionNum; BootOrderIndex++) {\r
Index = (UINTN) BootOrder[BootOrderIndex];\r
UnicodeSPrint (BootOption, sizeof (BootOption), L"Boot%04x", Index);\r
continue;\r
}\r
\r
+ //\r
+ // Skip Non-legacy boot option\r
+ //\r
if (!BdsIsLegacyBootOption (BootOptionVar, &BbsEntry, BbsIndex)) {\r
SafeFreePool (BootOptionVar);\r
continue;\r
\r
DevPath = NULL;\r
\r
+ //\r
+ // Create device path node.\r
+ //\r
BbsDevPathNode.Header.Type = BBS_DEVICE_PATH;\r
BbsDevPathNode.Header.SubType = BBS_BBS_DP;\r
SetDevicePathNodeLength (&BbsDevPathNode.Header, sizeof (BBS_BBS_DEVICE_PATH));\r
\r
Add the legacy boot options from BBS table if they do not exist.\r
\r
- \r
-\r
@retval EFI_SUCCESS The boot options are added successfully \r
or they are already in boot options.\r
\r
Ptr = NULL;\r
Status = EFI_SUCCESS;\r
\r
+ //\r
+ // Count all boot devices\r
+ //\r
for (Index = 0; Index < BbsCount; Index++) {\r
if (BbsTable[Index].BootPriority == BBS_IGNORE_ENTRY) {\r
continue;\r
TotalSize += (HeaderSize + sizeof (UINT16) * NETCount);\r
TotalSize += (HeaderSize + sizeof (UINT16) * BEVCount);\r
\r
+ //\r
+ // Create buffer to hold all boot device order\r
+ //\r
DevOrder = AllocateZeroPool (TotalSize);\r
if (NULL == DevOrder) {\r
return EFI_OUT_OF_RESOURCES;\r
Ptr = (UINT8 *) BdsFillDevOrderBuf (BbsTable, BBS_BEV_DEVICE, BbsCount, (UINT16 *) Ptr);\r
}\r
\r
+ //\r
+ // Save device order for legacy boot device to variable.\r
+ //\r
Status = gRT->SetVariable (\r
VAR_LEGACY_DEV_ORDER,\r
&EfiLegacyDevOrderGuid,\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
+ @return status of BdsSetBootPriority4SameTypeDev()\r
**/\r
EFI_STATUS\r
BdsRefreshBbsTableForBoot (\r