#include "BBSsupport.h"\r
\r
/**\r
- EDES_TODO: Add function description.\r
+ Create a menu entry give a Menu type.\r
\r
- @param MenuType Use this parameter to identify current\r
- Menu type\r
+ @param MenuType The Menu type to be created.\r
\r
- EDES_TODO: Incomplete Descriptions NULL Cannot allocate memory for current menu\r
- EDES_TODO: Incomplete Descriptions entry\r
- EDES_TODO: Incomplete Descriptions Others A valid pointer pointing to the allocated\r
- EDES_TODO: Incomplete Descriptions memory pool for current menu entry\r
+\r
+ @retval NULL If failed to create the menu.\r
+ @return The menu.\r
\r
**/\r
BM_MENU_ENTRY *\r
return NULL;\r
}\r
\r
- MenuEntry = EfiAllocateZeroPool (sizeof (BM_MENU_ENTRY));\r
+ MenuEntry = AllocateZeroPool (sizeof (BM_MENU_ENTRY));\r
if (NULL == MenuEntry) {\r
return MenuEntry;\r
}\r
\r
- MenuEntry->VariableContext = EfiAllocateZeroPool (ContextSize);\r
+ MenuEntry->VariableContext = AllocateZeroPool (ContextSize);\r
if (NULL == MenuEntry->VariableContext) {\r
SafeFreePool (MenuEntry);\r
MenuEntry = NULL;\r
}\r
\r
/**\r
- EDES_TODO: Add function description.\r
+ Free up all resource allocated for a BM_MENU_ENTRY.\r
\r
- @param MenuEntry EDES_TODO: Add parameter description\r
+ @param MenuEntry A pointer to BM_MENU_ENTRY.\r
\r
- @return EDES_TODO: Add description for return value\r
+ @retval VOID\r
\r
**/\r
VOID\r
}\r
\r
/**\r
- EDES_TODO: Add function description.\r
+ Get the Menu Entry from the list in Menu Entry List.\r
+\r
+ If MenuNumber is great or equal to the number of Menu\r
+ Entry in the list, then ASSERT.\r
\r
- @param MenuOption EDES_TODO: Add parameter description\r
- @param MenuNumber EDES_TODO: Add parameter description\r
+ @param MenuOption The Menu Entry List to read the menu entry.\r
+ @param MenuNumber The index of Menu Entry.\r
\r
- @return EDES_TODO: Add description for return value\r
+ @return The Menu Entry.\r
\r
**/\r
BM_MENU_ENTRY *\r
UINTN Index;\r
LIST_ENTRY *List;\r
\r
- if (MenuNumber >= MenuOption->MenuNumber) {\r
- return NULL;\r
- }\r
+ ASSERT (MenuNumber < MenuOption->MenuNumber);\r
\r
List = MenuOption->Head.ForwardLink;\r
for (Index = 0; Index < MenuNumber; Index++) {\r
}\r
\r
/**\r
- EDES_TODO: Add function description.\r
+ This function build the FsOptionMenu list which records all\r
+ available file system in the system. They includes all instances\r
+ of EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, all instances of EFI_LOAD_FILE_SYSTEM\r
+ and all type of legacy boot device.\r
\r
@param CallbackData BMM context data\r
\r
// Issue a dummy read to trigger reinstall of BlockIo protocol for removable media\r
//\r
if (BlkIo->Media->RemovableMedia) {\r
- Buffer = EfiAllocateZeroPool (BlkIo->Media->BlockSize);\r
+ Buffer = AllocateZeroPool (BlkIo->Media->BlockSize);\r
if (NULL == Buffer) {\r
SafeFreePool (BlkIoHandle);\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
TempStr = MenuEntry->HelpString;\r
- MenuEntry->DisplayString = EfiAllocateZeroPool (MAX_CHAR);\r
+ MenuEntry->DisplayString = AllocateZeroPool (MAX_CHAR);\r
ASSERT (MenuEntry->DisplayString != NULL);\r
UnicodeSPrint (\r
MenuEntry->DisplayString,\r
MenuEntry->HelpString = DevicePathToStr (FileContext->DevicePath);\r
\r
TempStr = MenuEntry->HelpString;\r
- MenuEntry->DisplayString = EfiAllocateZeroPool (MAX_CHAR);\r
+ MenuEntry->DisplayString = AllocateZeroPool (MAX_CHAR);\r
ASSERT (MenuEntry->DisplayString != NULL);\r
UnicodeSPrint (\r
MenuEntry->DisplayString,\r
MenuEntry->HelpString = DevicePathToStr (FileContext->DevicePath);\r
\r
TempStr = MenuEntry->HelpString;\r
- MenuEntry->DisplayString = EfiAllocateZeroPool (MAX_CHAR);\r
+ MenuEntry->DisplayString = AllocateZeroPool (MAX_CHAR);\r
ASSERT (MenuEntry->DisplayString != NULL);\r
UnicodeSPrint (\r
MenuEntry->DisplayString,\r
return EFI_SUCCESS;\r
}\r
\r
-VOID\r
-BOpt_FreeMenu (\r
- BM_MENU_OPTION *FreeMenu\r
- )\r
-/*++\r
-\r
-Routine Description\r
+/**\r
Free resources allocated in Allocate Rountine\r
\r
-Arguments:\r
- FreeMenu Menu to be freed\r
+ @param FreeMenu Menu to be freed\r
\r
-Returns:\r
- VOID\r
+ @return VOID\r
\r
---*/\r
+**/\r
+VOID\r
+BOpt_FreeMenu (\r
+ BM_MENU_OPTION *FreeMenu\r
+ )\r
{\r
BM_MENU_ENTRY *MenuEntry;\r
while (!IsListEmpty (&FreeMenu->Head)) {\r
}\r
}\r
\r
-EFI_STATUS\r
-BOpt_FindFiles (\r
- IN BMM_CALLBACK_DATA *CallbackData,\r
- IN BM_MENU_ENTRY *MenuEntry\r
- )\r
-/*++\r
-\r
-Routine Description\r
+/**\r
Find files under current directory\r
All files and sub-directories in current directory\r
will be stored in DirectoryMenu for future use.\r
\r
-Arguments:\r
- FileOption -- Pointer for Dir to explore\r
+ @param FileOption Pointer for Dir to explore.\r
\r
-Returns:\r
- TRUE -- Get files from current dir successfully\r
- FALSE -- Can't get files from current dir\r
+ @retval TRUE Get files from current dir successfully.\r
+ @retval FALSE Can't get files from current dir.\r
\r
---*/\r
+**/\r
+EFI_STATUS\r
+BOpt_FindFiles (\r
+ IN BMM_CALLBACK_DATA *CallbackData,\r
+ IN BM_MENU_ENTRY *MenuEntry\r
+ )\r
{\r
EFI_FILE_HANDLE NewDir;\r
EFI_FILE_HANDLE Dir;\r
);\r
\r
DirBufferSize = sizeof (EFI_FILE_INFO) + 1024;\r
- DirInfo = EfiAllocateZeroPool (DirBufferSize);\r
+ DirInfo = AllocateZeroPool (DirBufferSize);\r
if (DirInfo == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
if (NewFileContext->IsDir) {\r
BufferSize = StrLen (DirInfo->FileName) * 2 + 6;\r
- NewMenuEntry->DisplayString = EfiAllocateZeroPool (BufferSize);\r
+ NewMenuEntry->DisplayString = AllocateZeroPool (BufferSize);\r
\r
UnicodeSPrint (\r
NewMenuEntry->DisplayString,\r
return EFI_SUCCESS;\r
}\r
\r
-EFI_STATUS\r
-BOpt_GetLegacyOptions (\r
- VOID\r
- )\r
-/*++\r
-Routine Description:\r
-\r
+/**\r
Build the LegacyFDMenu LegacyHDMenu LegacyCDMenu according to LegacyBios.GetBbsInfo().\r
\r
-Arguments:\r
- None\r
+ @param VOID\r
\r
-Returns:\r
- The device info of legacy device.\r
+ @retval EFI_SUCCESS The function complete successfully.\r
+ @retval EFI_OUT_OF_RESOURCES No enough memory to complete this function.\r
\r
---*/\r
+**/\r
+EFI_STATUS\r
+BOpt_GetLegacyOptions (\r
+ VOID\r
+ )\r
{\r
BM_MENU_ENTRY *NewMenuEntry;\r
BM_LEGACY_DEVICE_CONTEXT *NewLegacyDevContext;\r
sizeof (DescString),\r
DescString\r
);\r
- NewLegacyDevContext->Description = EfiAllocateZeroPool (StrSize (DescString));\r
+ NewLegacyDevContext->Description = AllocateZeroPool (StrSize (DescString));\r
if (NULL == NewLegacyDevContext->Description) {\r
break;\r
}\r
return EFI_SUCCESS;\r
}\r
\r
+/**\r
+ Free out resouce allocated from Legacy Boot Options.\r
+\r
+ @param VOID.\r
+\r
+ @return VOID.\r
+\r
+**/\r
VOID\r
BOpt_FreeLegacyOptions (\r
VOID\r
BOpt_FreeMenu (&LegacyBEVMenu);\r
}\r
\r
-EFI_STATUS\r
-BOpt_GetBootOptions (\r
- IN BMM_CALLBACK_DATA *CallbackData\r
- )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
\r
Build the BootOptionMenu according to BootOrder Variable.\r
- This Routine will access the Boot#### to get EFI_LOAD_OPTION\r
+ This Routine will access the Boot#### to get EFI_LOAD_OPTION.\r
\r
-Arguments:\r
- None\r
+ @param None\r
\r
-Returns:\r
- The number of the Var Boot####\r
+ @return The number of the Var Boot####.\r
\r
---*/\r
+**/\r
+EFI_STATUS\r
+BOpt_GetBootOptions (\r
+ IN BMM_CALLBACK_DATA *CallbackData\r
+ )\r
{\r
UINTN Index;\r
UINT16 BootString[10];\r
continue;\r
}\r
\r
- LoadOption = EfiAllocateZeroPool (BootOptionSize);\r
+ LoadOption = AllocateZeroPool (BootOptionSize);\r
if (LoadOption == NULL) {\r
continue;\r
}\r
LoadOptionPtr += sizeof (UINT16);\r
\r
StringSize = StrSize ((UINT16 *) LoadOptionPtr);\r
- NewLoadContext->Description = EfiAllocateZeroPool (StringSize);\r
+ NewLoadContext->Description = AllocateZeroPool (StringSize);\r
ASSERT (NewLoadContext->Description != NULL);\r
CopyMem (\r
NewLoadContext->Description,\r
\r
LoadOptionPtr += StringSize;\r
\r
- NewLoadContext->FilePathList = EfiAllocateZeroPool (NewLoadContext->FilePathListLength);\r
+ NewLoadContext->FilePathList = AllocateZeroPool (NewLoadContext->FilePathListLength);\r
ASSERT (NewLoadContext->FilePathList != NULL);\r
CopyMem (\r
NewLoadContext->FilePathList,\r
StringSize -\r
NewLoadContext->FilePathListLength;\r
\r
- NewLoadContext->OptionalData = EfiAllocateZeroPool (OptionalDataSize);\r
+ NewLoadContext->OptionalData = AllocateZeroPool (OptionalDataSize);\r
ASSERT (NewLoadContext->OptionalData != NULL);\r
CopyMem (\r
NewLoadContext->OptionalData,\r
return MenuCount;\r
}\r
\r
-CHAR16 *\r
-BdsStrCpy (\r
- OUT CHAR16 *Destination,\r
- IN CONST CHAR16 *Source\r
- )\r
-{\r
- CHAR16 *ReturnValue;\r
+/**\r
\r
- //\r
- // Destination cannot be NULL\r
- //\r
- ASSERT (Destination != NULL);\r
+ Append file name to existing file name.\r
\r
- ReturnValue = Destination;\r
- while (*Source != L'\0') {\r
- *(Destination++) = *(Source++);\r
- }\r
- *Destination = 0;\r
- return ReturnValue;\r
-}\r
+ @param Str1 The existing file name\r
+ @param Str2 The file name to be appended\r
\r
+ @return Allocate a new string to hold the appended result.\r
+ Caller is responsible to free the returned string.\r
+\r
+**/\r
CHAR16 *\r
BOpt_AppendFileName (\r
IN CHAR16 *Str1,\r
IN CHAR16 *Str2\r
)\r
-/*++\r
-\r
-Routine Description\r
- Append file name to existing file name.\r
-\r
-Arguments:\r
- Str1 - existing file name\r
- Str2 - file name to be appended\r
-\r
-Returns:\r
- Allocate a new string to hold the appended result.\r
- Caller is responsible to free the returned string.\r
-\r
---*/\r
{\r
UINTN Size1;\r
UINTN Size2;\r
\r
Size1 = StrSize (Str1);\r
Size2 = StrSize (Str2);\r
- Str = EfiAllocateZeroPool (Size1 + Size2 + sizeof (CHAR16));\r
+ Str = AllocateZeroPool (Size1 + Size2 + sizeof (CHAR16));\r
ASSERT (Str != NULL);\r
\r
StrCat (Str, Str1);\r
// DO NOT convert the .. if it is at the end of the string. This will\r
// break the .. behavior in changing directories.\r
//\r
- BdsStrCpy (LastSlash, Ptr + 3);\r
+ StrCpy (LastSlash, Ptr + 3);\r
Ptr = LastSlash;\r
} else if (*Ptr == '\\' && *(Ptr + 1) == '.' && *(Ptr + 2) == '\\') {\r
//\r
// Convert a "\.\" to a "\"\r
//\r
- BdsStrCpy (Ptr, Ptr + 2);\r
+ StrCpy (Ptr, Ptr + 2);\r
Ptr = LastSlash;\r
} else if (*Ptr == '\\') {\r
LastSlash = Ptr;\r
return Str;\r
}\r
\r
-BOOLEAN\r
-BOpt_IsEfiImageName (\r
- IN UINT16 *FileName\r
- )\r
-/*++\r
+/**\r
\r
-Routine Description\r
Check whether current FileName point to a valid\r
Efi Image File.\r
\r
-Arguments:\r
- FileName - File need to be checked.\r
+ @param FileName File need to be checked.\r
\r
-Returns:\r
- TRUE - Is Efi Image\r
- FALSE - Not a valid Efi Image\r
+ @retval TRUE Is Efi Image\r
+ @retval FALSE Not a valid Efi Image\r
\r
---*/\r
+**/\r
+BOOLEAN\r
+BOpt_IsEfiImageName (\r
+ IN UINT16 *FileName\r
+ )\r
{\r
//\r
// Search for ".efi" extension\r
return FALSE;\r
}\r
\r
-BOOLEAN\r
-BOpt_IsEfiApp (\r
- IN EFI_FILE_HANDLE Dir,\r
- IN UINT16 *FileName\r
- )\r
-/*++\r
+/**\r
\r
-Routine Description:\r
Check whether current FileName point to a valid Efi Application\r
\r
-Arguments:\r
- Dir - Pointer to current Directory\r
- FileName - Pointer to current File name.\r
+ @param Dir Pointer to current Directory\r
+ @param FileName Pointer to current File name.\r
\r
-Returns:\r
- TRUE - Is a valid Efi Application\r
- FALSE - not a valid Efi Application\r
+ @retval TRUE Is a valid Efi Application\r
+ @retval FALSE not a valid Efi Application\r
\r
---*/\r
+**/\r
+BOOLEAN\r
+BOpt_IsEfiApp (\r
+ IN EFI_FILE_HANDLE Dir,\r
+ IN UINT16 *FileName\r
+ )\r
{\r
UINTN BufferSize;\r
EFI_IMAGE_DOS_HEADER DosHdr;\r
}\r
}\r
\r
-EFI_STATUS\r
-BOpt_FindDrivers (\r
- VOID\r
- )\r
-/*++\r
+/**\r
\r
-Routine Description\r
Find drivers that will be added as Driver#### variables from handles\r
in current system environment\r
All valid handles in the system except those consume SimpleFs, LoadFile\r
are stored in DriverMenu for future use.\r
\r
-Arguments:\r
- None\r
+ @param VOID \r
\r
-Returns:\r
- EFI_SUCCESS\r
- Others\r
+ @retval EFI_SUCCESS The function complets successfully.\r
+ @return Other value if failed to build the DriverMenu.\r
\r
---*/\r
+**/\r
+EFI_STATUS\r
+BOpt_FindDrivers (\r
+ VOID\r
+ )\r
{\r
UINTN NoDevicePathHandles;\r
EFI_HANDLE *DevicePathHandle;\r
for (Index = 0; Index < NoDevicePathHandles; Index++) {\r
CurHandle = DevicePathHandle[Index];\r
\r
- //\r
- // Check whether this handle support\r
- // driver binding\r
- //\r
Status = gBS->HandleProtocol (\r
CurHandle,\r
&gEfiSimpleFileSystemProtocolGuid,\r
return EFI_SUCCESS;\r
}\r
\r
-UINT16\r
-BOpt_GetBootOptionNumber (\r
- VOID\r
- )\r
-/*++\r
+/**\r
\r
-Routine Description:\r
- Get the Option Number that does not used\r
+ Get the Option Number that has not been allocated for use.\r
\r
-Arguments:\r
+ @param VOID\r
\r
-Returns:\r
- The Option Number\r
+ @return The available Option Number.\r
\r
---*/\r
+**/\r
+UINT16\r
+BOpt_GetBootOptionNumber (\r
+ VOID\r
+ )\r
{\r
BM_MENU_ENTRY *NewMenuEntry;\r
UINT16 *BootOrderList;\r
}\r
\r
if (Found) {\r
- UnicodeSPrint (StrTemp, 100, L"Boot%04x", Index);\r
- DEBUG((DEBUG_ERROR,"INdex= %s\n", StrTemp));\r
- OptionBuffer = BdsLibGetVariableAndSize (\r
- StrTemp,\r
- &gEfiGlobalVariableGuid,\r
- &OptionSize\r
- );\r
- if (NULL == OptionBuffer)\r
- break;\r
+ UnicodeSPrint (StrTemp, 100, L"Boot%04x", Index);\r
+ DEBUG((DEBUG_ERROR,"INdex= %s\n", StrTemp));\r
+ OptionBuffer = BdsLibGetVariableAndSize (\r
+ StrTemp,\r
+ &gEfiGlobalVariableGuid,\r
+ &OptionSize\r
+ );\r
+ if (NULL == OptionBuffer) {\r
+ break;\r
+ }\r
}\r
}\r
//\r
return Number;\r
}\r
\r
-UINT16\r
-BOpt_GetDriverOptionNumber (\r
- VOID\r
- )\r
-/*++\r
+/**\r
\r
-Routine Description:\r
- Get the Option Number that does not used\r
+ Get the Option Number that is not in use.\r
\r
-Arguments:\r
+ @param VOID\r
\r
-Returns:\r
- The Option Number\r
+ @return The unused Option Number.\r
\r
---*/\r
+**/\r
+UINT16\r
+BOpt_GetDriverOptionNumber (\r
+ VOID\r
+ )\r
{\r
BM_MENU_ENTRY *NewMenuEntry;\r
UINT16 *DriverOrderList;\r
return Number;\r
}\r
\r
-EFI_STATUS\r
-BOpt_GetDriverOptions (\r
- IN BMM_CALLBACK_DATA *CallbackData\r
- )\r
-/*++\r
+/**\r
\r
-Routine Description:\r
Build up all DriverOptionMenu\r
\r
-Arguments:\r
+ @param CallbackData The BMM context data.\r
\r
-Returns:\r
- The Option Number\r
+ @return EFI_SUCESS The functin completes successfully.\r
+ @retval EFI_OUT_OF_RESOURCES Not enough memory to compete the operation.\r
+ \r
\r
---*/\r
+**/\r
+EFI_STATUS\r
+BOpt_GetDriverOptions (\r
+ IN BMM_CALLBACK_DATA *CallbackData\r
+ )\r
{\r
UINTN Index;\r
UINT16 DriverString[12];\r
continue;\r
}\r
\r
- LoadOption = EfiAllocateZeroPool (DriverOptionSize);\r
+ LoadOption = AllocateZeroPool (DriverOptionSize);\r
if (LoadOption == NULL) {\r
continue;\r
}\r
LoadOptionPtr += sizeof (UINT16);\r
\r
StringSize = StrSize ((UINT16 *) LoadOptionPtr);\r
- NewLoadContext->Description = EfiAllocateZeroPool (StringSize);\r
+ NewLoadContext->Description = AllocateZeroPool (StringSize);\r
ASSERT (NewLoadContext->Description != NULL);\r
CopyMem (\r
NewLoadContext->Description,\r
\r
LoadOptionPtr += StringSize;\r
\r
- NewLoadContext->FilePathList = EfiAllocateZeroPool (NewLoadContext->FilePathListLength);\r
+ NewLoadContext->FilePathList = AllocateZeroPool (NewLoadContext->FilePathListLength);\r
ASSERT (NewLoadContext->FilePathList != NULL);\r
CopyMem (\r
NewLoadContext->FilePathList,\r
StringSize -\r
NewLoadContext->FilePathListLength;\r
\r
- NewLoadContext->OptionalData = EfiAllocateZeroPool (OptionalDataSize);\r
+ NewLoadContext->OptionalData = AllocateZeroPool (OptionalDataSize);\r
ASSERT (NewLoadContext->OptionalData != NULL);\r
CopyMem (\r
NewLoadContext->OptionalData,\r