EFI_STATUS UtilStartEfiApplication ( IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN UINTN LoadOptionsSize, IN VOID* LoadOptions ) { EFI_STATUS Status; EFI_BOOT_MANAGER_LOAD_OPTION NewOption; Status = EfiBootManagerInitializeLoadOption ( &NewOption, LoadOptionNumberUnassigned, LoadOptionTypeSysPrep, LOAD_OPTION_ACTIVE, L"", DevicePath, LoadOptions, LoadOptionsSize ); ASSERT_EFI_ERROR (Status); EfiBootManagerProcessLoadOption(&NewOption); Status = NewOption.Status; EfiBootManagerFreeLoadOption(&NewOption); return Status; }
STATIC EFI_STATUS CreatePlatformBootOptionFromPath ( IN CHAR16 *PathStr, IN CHAR16 *Description, IN OUT EFI_BOOT_MANAGER_LOAD_OPTION *BootOption ) { EFI_STATUS Status; EFI_DEVICE_PATH *DevicePath; DevicePath = (EFI_DEVICE_PATH *)ConvertTextToDevicePath (PathStr); ASSERT (DevicePath != NULL); Status = EfiBootManagerInitializeLoadOption ( BootOption, LoadOptionNumberUnassigned, LoadOptionTypeBoot, LOAD_OPTION_ACTIVE, Description, DevicePath, NULL, 0 ); FreePool (DevicePath); return Status; }
/** Boot a file selected by user at File Expoloer of BMM. @param FileContext The file context data, which contains the device path of the file to be boot from. @retval EFI_SUCCESS The function completed successfull. @return Other value if the boot from the file fails. **/ EFI_STATUS BootThisFile ( IN BM_FILE_CONTEXT *FileContext ) { EFI_BOOT_MANAGER_LOAD_OPTION BootOption; EfiBootManagerInitializeLoadOption ( &BootOption, 0, LoadOptionTypeBoot, LOAD_OPTION_ACTIVE, FileContext->FileName, FileContext->DevicePath, NULL, 0 ); // // Since current no boot from removable media directly is allowed */ // gST->ConOut->ClearScreen (gST->ConOut); BdsSetConsoleMode (FALSE); EfiBootManagerBoot (&BootOption); BdsSetConsoleMode (TRUE); EfiBootManagerFreeLoadOption (&BootOption); return BootOption.Status; }
/** Boot the file specified by the input file path info. @param FilePath Point to the file path. @retval TRUE Exit caller function. @retval FALSE Not exit caller function. **/ BOOLEAN BootFromFile ( IN EFI_DEVICE_PATH_PROTOCOL *FilePath ) { EFI_BOOT_MANAGER_LOAD_OPTION BootOption; CHAR16 *FileName; FileName = ExtractFileNameFromDevicePath(FilePath); EfiBootManagerInitializeLoadOption ( &BootOption, 0, LoadOptionTypeBoot, LOAD_OPTION_ACTIVE, FileName, FilePath, NULL, 0 ); // // Since current no boot from removable media directly is allowed */ // gST->ConOut->ClearScreen (gST->ConOut); BmmBdsSetConsoleMode (FALSE); EfiBootManagerBoot (&BootOption); BmmBdsSetConsoleMode (TRUE); FreePool(FileName); EfiBootManagerFreeLoadOption (&BootOption); return FALSE; }
VOID PlatformRegisterFvBootOption ( EFI_GUID *FileGuid, CHAR16 *Description, UINT32 Attributes ) { EFI_STATUS Status; UINTN OptionIndex; EFI_BOOT_MANAGER_LOAD_OPTION NewOption; EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; UINTN BootOptionCount; MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode; EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; EFI_DEVICE_PATH_PROTOCOL *DevicePath; Status = gBS->HandleProtocol (gImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage); ASSERT_EFI_ERROR (Status); EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid); DevicePath = AppendDevicePathNode ( DevicePathFromHandle (LoadedImage->DeviceHandle), (EFI_DEVICE_PATH_PROTOCOL *) &FileNode ); Status = EfiBootManagerInitializeLoadOption ( &NewOption, LoadOptionNumberUnassigned, LoadOptionTypeBoot, Attributes, Description, DevicePath, NULL, 0 ); if (!EFI_ERROR (Status)) { BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot); OptionIndex = PlatformFindLoadOption (&NewOption, BootOptions, BootOptionCount); if (OptionIndex == -1) { Status = EfiBootManagerAddLoadOptionVariable (&NewOption, (UINTN) -1); ASSERT_EFI_ERROR (Status); } EfiBootManagerFreeLoadOption (&NewOption); EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount); } }
STATIC EFI_STATUS CreatePlatformBootOptionFromGuid ( IN EFI_GUID *FileGuid, IN CHAR16 *Description, IN OUT EFI_BOOT_MANAGER_LOAD_OPTION *BootOption ) { EFI_STATUS Status; EFI_DEVICE_PATH *DevicePath; EFI_DEVICE_PATH *TempDevicePath; EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode; Status = gBS->HandleProtocol ( gImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage ); ASSERT_EFI_ERROR (Status); EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid); TempDevicePath = DevicePathFromHandle (LoadedImage->DeviceHandle); ASSERT (TempDevicePath != NULL); DevicePath = AppendDevicePathNode ( TempDevicePath, (EFI_DEVICE_PATH_PROTOCOL *) &FileNode ); ASSERT (DevicePath != NULL); Status = EfiBootManagerInitializeLoadOption ( BootOption, LoadOptionNumberUnassigned, LoadOptionTypeBoot, LOAD_OPTION_ACTIVE, Description, DevicePath, NULL, 0 ); FreePool (DevicePath); return Status; }
/** Create one boot option for BootManagerMenuApp. @param FileGuid Input file guid for the BootManagerMenuApp. @param Description Description of the BootManagerMenuApp boot option. @param Position Position of the new load option to put in the ****Order variable. @param IsBootCategory Whether this is a boot category. @retval OptionNumber Return the option number info. **/ UINTN RegisterBootManagerMenuAppBootOption ( EFI_GUID *FileGuid, CHAR16 *Description, UINTN Position, BOOLEAN IsBootCategory ) { EFI_STATUS Status; EFI_BOOT_MANAGER_LOAD_OPTION NewOption; EFI_DEVICE_PATH_PROTOCOL *DevicePath; UINTN OptionNumber; DevicePath = FvFilePath (FileGuid); Status = EfiBootManagerInitializeLoadOption ( &NewOption, LoadOptionNumberUnassigned, LoadOptionTypeBoot, IsBootCategory ? LOAD_OPTION_ACTIVE : LOAD_OPTION_CATEGORY_APP, Description, DevicePath, NULL, 0 ); ASSERT_EFI_ERROR (Status); FreePool (DevicePath); Status = EfiBootManagerAddLoadOptionVariable (&NewOption, Position); ASSERT_EFI_ERROR (Status); OptionNumber = NewOption.OptionNumber; EfiBootManagerFreeLoadOption (&NewOption); return OptionNumber; }
/** Build the Boot#### or Driver#### option from the VariableName. @param VariableName Variable name of the load option @param VendorGuid Variable GUID of the load option @param Option Return the load option. @retval EFI_SUCCESS Get the option just been created @retval EFI_NOT_FOUND Failed to get the new option **/ EFI_STATUS EFIAPI EfiBootManagerVariableToLoadOptionEx ( IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN OUT EFI_BOOT_MANAGER_LOAD_OPTION *Option ) { EFI_STATUS Status; UINT32 Attribute; UINT16 FilePathSize; UINT8 *Variable; UINT8 *VariablePtr; UINTN VariableSize; EFI_DEVICE_PATH_PROTOCOL *FilePath; UINT8 *OptionalData; UINT32 OptionalDataSize; CHAR16 *Description; EFI_BOOT_MANAGER_LOAD_OPTION_TYPE OptionType; UINT16 OptionNumber; if ((VariableName == NULL) || (Option == NULL)) { return EFI_INVALID_PARAMETER; } if (!BmIsValidLoadOptionVariableName (VariableName, &OptionType, &OptionNumber)) { return EFI_INVALID_PARAMETER; } // // Read the variable // GetVariable2 (VariableName, VendorGuid, (VOID **) &Variable, &VariableSize); if (Variable == NULL) { return EFI_NOT_FOUND; } // // Validate *#### variable data. // if (!BmValidateOption(Variable, VariableSize)) { FreePool (Variable); return EFI_INVALID_PARAMETER; } // // Get the option attribute // VariablePtr = Variable; Attribute = ReadUnaligned32 ((UINT32 *) VariablePtr); VariablePtr += sizeof (UINT32); // // Get the option's device path size // FilePathSize = ReadUnaligned16 ((UINT16 *) VariablePtr); VariablePtr += sizeof (UINT16); // // Get the option's description string // Description = (CHAR16 *) VariablePtr; // // Get the option's description string size // VariablePtr += StrSize ((CHAR16 *) VariablePtr); // // Get the option's device path // FilePath = (EFI_DEVICE_PATH_PROTOCOL *) VariablePtr; VariablePtr += FilePathSize; OptionalDataSize = (UINT32) (VariableSize - (UINTN) (VariablePtr - Variable)); if (OptionalDataSize == 0) { OptionalData = NULL; } else { OptionalData = VariablePtr; } Status = EfiBootManagerInitializeLoadOption ( Option, OptionNumber, OptionType, Attribute, Description, FilePath, OptionalData, OptionalDataSize ); ASSERT_EFI_ERROR (Status); CopyGuid (&Option->VendorGuid, VendorGuid); FreePool (Variable); return Status; }
/** Emuerate all possible bootable medias in the following order: 1. Removable BlockIo - The boot option only points to the removable media device, like USB key, DVD, Floppy etc. 2. Fixed BlockIo - The boot option only points to a Fixed blockIo device, like HardDisk. 3. Non-BlockIo SimpleFileSystem - The boot option points to a device supporting SimpleFileSystem Protocol, but not supporting BlockIo protocol. 4. LoadFile - The boot option points to the media supporting LoadFile protocol. Reference: UEFI Spec chapter 3.3 Boot Option Variables Default Boot Behavior @param BootOptionCount Return the boot option count which has been found. @retval Pointer to the boot option array. **/ EFI_BOOT_MANAGER_LOAD_OPTION * BdsEnumerateBootOptions ( UINTN *BootOptionCount ) { EFI_STATUS Status; EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; UINTN HandleCount; EFI_HANDLE *Handles; EFI_BLOCK_IO_PROTOCOL *BlkIo; UINTN Removable; UINTN Index; ASSERT (BootOptionCount != NULL); *BootOptionCount = 0; BootOptions = NULL; // // Parse removable block io followed by fixed block io // gBS->LocateHandleBuffer ( ByProtocol, &gEfiBlockIoProtocolGuid, NULL, &HandleCount, &Handles ); for (Removable = 0; Removable < 2; Removable++) { for (Index = 0; Index < HandleCount; Index++) { Status = gBS->HandleProtocol ( Handles[Index], &gEfiBlockIoProtocolGuid, (VOID **) &BlkIo ); if (EFI_ERROR (Status)) { continue; } // // Skip the logical partitions // if (BlkIo->Media->LogicalPartition) { continue; } // // Skip the fixed block io then the removable block io // if (BlkIo->Media->RemovableMedia == ((Removable == 0) ? FALSE : TRUE)) { continue; } BootOptions = ReallocatePool ( sizeof (EFI_BOOT_MANAGER_LOAD_OPTION) * (*BootOptionCount), sizeof (EFI_BOOT_MANAGER_LOAD_OPTION) * (*BootOptionCount + 1), BootOptions ); ASSERT (BootOptions != NULL); Status = EfiBootManagerInitializeLoadOption ( &BootOptions[(*BootOptionCount)++], LoadOptionNumberUnassigned, LoadOptionTypeBoot, LOAD_OPTION_ACTIVE, mRecoveryBoot, DevicePathFromHandle (Handles[Index]), NULL, 0 ); ASSERT_EFI_ERROR (Status); } } if (HandleCount != 0) { FreePool (Handles); } // // Parse simple file system not based on block io // gBS->LocateHandleBuffer ( ByProtocol, &gEfiSimpleFileSystemProtocolGuid, NULL, &HandleCount, &Handles ); for (Index = 0; Index < HandleCount; Index++) { Status = gBS->HandleProtocol ( Handles[Index], &gEfiBlockIoProtocolGuid, (VOID **) &BlkIo ); if (!EFI_ERROR (Status)) { // // Skip if the file system handle supports a BlkIo protocol, which we've handled in above // continue; } BootOptions = ReallocatePool ( sizeof (EFI_BOOT_MANAGER_LOAD_OPTION) * (*BootOptionCount), sizeof (EFI_BOOT_MANAGER_LOAD_OPTION) * (*BootOptionCount + 1), BootOptions ); ASSERT (BootOptions != NULL); Status = EfiBootManagerInitializeLoadOption ( &BootOptions[(*BootOptionCount)++], LoadOptionNumberUnassigned, LoadOptionTypeBoot, LOAD_OPTION_ACTIVE, mRecoveryBoot, DevicePathFromHandle (Handles[Index]), NULL, 0 ); ASSERT_EFI_ERROR (Status); } if (HandleCount != 0) { FreePool (Handles); } // // Parse load file, assuming UEFI Network boot option // gBS->LocateHandleBuffer ( ByProtocol, &gEfiLoadFileProtocolGuid, NULL, &HandleCount, &Handles ); for (Index = 0; Index < HandleCount; Index++) { BootOptions = ReallocatePool ( sizeof (EFI_BOOT_MANAGER_LOAD_OPTION) * (*BootOptionCount), sizeof (EFI_BOOT_MANAGER_LOAD_OPTION) * (*BootOptionCount + 1), BootOptions ); ASSERT (BootOptions != NULL); Status = EfiBootManagerInitializeLoadOption ( &BootOptions[(*BootOptionCount)++], LoadOptionNumberUnassigned, LoadOptionTypeBoot, LOAD_OPTION_ACTIVE, mRecoveryBoot, DevicePathFromHandle (Handles[Index]), NULL, 0 ); ASSERT_EFI_ERROR (Status); } if (HandleCount != 0) { FreePool (Handles); } return BootOptions; }
/** This call back function is registered with Boot Manager formset. When user selects a boot option, this call back function will be triggered. The boot option is saved for later processing. @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL. @param Action Specifies the type of action taken by the browser. @param QuestionId A unique value which is sent to the original exporting driver so that it can identify the type of data to expect. @param Type The type of value for the question. @param Value A pointer to the data being sent to the original exporting driver. @param ActionRequest On return, points to the action requested by the callback function. @retval EFI_SUCCESS The callback successfully handled the action. @retval EFI_INVALID_PARAMETER The setup browser call this function with invalid parameters. **/ EFI_STATUS EFIAPI BootManagerCallback ( IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN EFI_BROWSER_ACTION Action, IN EFI_QUESTION_ID QuestionId, IN UINT8 Type, IN EFI_IFR_TYPE_VALUE *Value, OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest ) { UINTN Index; EFI_BOOT_MANAGER_LOAD_OPTION *BootOption; UINTN BootOptionCount; UINT16 KeyCount; EFI_INPUT_KEY Key; EFI_BOOT_MANAGER_LOAD_OPTION Option; if (Action != EFI_BROWSER_ACTION_CHANGED) { // // Do nothing for other UEFI Action. Only do call back when data is changed. // return EFI_UNSUPPORTED; } if ((Value == NULL) || (ActionRequest == NULL)) { return EFI_INVALID_PARAMETER; } // // Initialize the key count // KeyCount = 0; Option.Attributes = 0; BootOption = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot); for (Index = 0; Index < BootOptionCount; Index++) { KeyCount++; EfiBootManagerInitializeLoadOption ( &Option, BootOption[Index].OptionNumber, BootOption[Index].OptionType, BootOption[Index].Attributes, BootOption[Index].Description, BootOption[Index].FilePath, BootOption[Index].OptionalData, BootOption[Index].OptionalDataSize ); // // Is this device the one chosen? // if (KeyCount == QuestionId) { // // Clear the screen before. // gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)); gST->ConOut->ClearScreen (gST->ConOut); // // Check any reset required change is applied? if yes, reset system // SetupResetReminder(); // // Parse the selected option. // BdsSetConsoleMode(FALSE); EfiBootManagerBoot (&Option); BdsSetConsoleMode(TRUE); if (EFI_ERROR (Option.Status)) { gST->ConOut->OutputString ( gST->ConOut, GetStringById (STRING_TOKEN (STR_ANY_KEY_CONTINUE)) ); gST->ConIn->ReadKeyStroke (gST->ConIn, &Key); } break; } } EfiBootManagerFreeLoadOptions (BootOption, BootOptionCount); return EFI_SUCCESS; }
/** This function create a currently loaded Boot Option from the BMM. It then appends this Boot Option to the end of the "BootOrder" list. It also append this Boot Opotion to the end of BootOptionMenu. @param CallbackData The BMM context data. @retval other Contain some errors when excuting this function. See function EfiBootManagerInitializeLoadOption/EfiBootManagerAddLoadOptionVariabl for detail return information. @retval EFI_SUCCESS If function completes successfully. **/ EFI_STATUS Var_UpdateBootOption ( IN BMM_CALLBACK_DATA *CallbackData ) { UINT16 BootString[10]; UINT16 Index; BM_MENU_ENTRY *NewMenuEntry; BM_LOAD_CONTEXT *NewLoadContext; BOOLEAN OptionalDataExist; EFI_STATUS Status; BMM_FAKE_NV_DATA *NvRamMap; EFI_BOOT_MANAGER_LOAD_OPTION LoadOption; UINT8 *OptionalData; UINT32 OptionalDataSize; OptionalDataExist = FALSE; NvRamMap = &CallbackData->BmmFakeNvData; OptionalData = NULL; OptionalDataSize = 0; Index = BOpt_GetBootOptionNumber () ; UnicodeSPrint (BootString, sizeof (BootString), L"Boot%04x", Index); if (NvRamMap->BootDescriptionData[0] == 0x0000) { StrCpyS (NvRamMap->BootDescriptionData, sizeof (NvRamMap->BootDescriptionData) / sizeof (NvRamMap->BootDescriptionData[0]), BootString); } if (NvRamMap->BootOptionalData[0] != 0x0000) { OptionalDataExist = TRUE; OptionalData = (UINT8 *)NvRamMap->BootOptionalData; OptionalDataSize = (UINT32)StrSize (NvRamMap->BootOptionalData); } NewMenuEntry = BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT); if (NULL == NewMenuEntry) { return EFI_OUT_OF_RESOURCES; } Status = EfiBootManagerInitializeLoadOption ( &LoadOption, Index, LoadOptionTypeBoot, LOAD_OPTION_ACTIVE, NvRamMap->BootDescriptionData, CallbackData->LoadContext->FilePathList, OptionalData, OptionalDataSize ); if (EFI_ERROR (Status)){ return Status; } Status = EfiBootManagerAddLoadOptionVariable (&LoadOption,(UINTN) -1 ); if (EFI_ERROR (Status)) { EfiBootManagerFreeLoadOption(&LoadOption); return Status; } NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext; NewLoadContext->Deleted = FALSE; NewLoadContext->Attributes = LoadOption.Attributes; NewLoadContext->FilePathListLength = (UINT16) GetDevicePathSize (LoadOption.FilePath); NewLoadContext->Description = AllocateZeroPool (StrSize (NvRamMap->BootDescriptionData)); ASSERT (NewLoadContext->Description != NULL); NewMenuEntry->DisplayString = NewLoadContext->Description; CopyMem ( NewLoadContext->Description, LoadOption.Description, StrSize (NvRamMap->BootDescriptionData) ); NewLoadContext->FilePathList = AllocateZeroPool (GetDevicePathSize (CallbackData->LoadContext->FilePathList)); ASSERT (NewLoadContext->FilePathList != NULL); CopyMem ( NewLoadContext->FilePathList, LoadOption.FilePath, GetDevicePathSize (CallbackData->LoadContext->FilePathList) ); NewMenuEntry->HelpString = UiDevicePathToStr (NewLoadContext->FilePathList); NewMenuEntry->OptionNumber = Index; NewMenuEntry->DisplayStringToken = HiiSetString (CallbackData->BmmHiiHandle, 0, NewMenuEntry->DisplayString, NULL); NewMenuEntry->HelpStringToken = HiiSetString (CallbackData->BmmHiiHandle, 0, NewMenuEntry->HelpString, NULL); if (OptionalDataExist) { NewLoadContext->OptionalData = AllocateZeroPool (LoadOption.OptionalDataSize); ASSERT (NewLoadContext->OptionalData != NULL); CopyMem ( NewLoadContext->OptionalData, LoadOption.OptionalData, LoadOption.OptionalDataSize ); } InsertTailList (&BootOptionMenu.Head, &NewMenuEntry->Link); BootOptionMenu.MenuNumber++; EfiBootManagerFreeLoadOption(&LoadOption); return EFI_SUCCESS; }
/** This function create a currently loaded Drive Option from the BMM. It then appends this Driver Option to the end of the "DriverOrder" list. It append this Driver Opotion to the end of DriverOptionMenu. @param CallbackData The BMM context data. @param HiiHandle The HII handle associated with the BMM formset. @param DescriptionData The description of this driver option. @param OptionalData The optional load option. @param ForceReconnect If to force reconnect. @retval other Contain some errors when excuting this function.See function EfiBootManagerInitializeLoadOption/EfiBootManagerAddLoadOptionVariabl for detail return information. @retval EFI_SUCCESS If function completes successfully. **/ EFI_STATUS Var_UpdateDriverOption ( IN BMM_CALLBACK_DATA *CallbackData, IN EFI_HII_HANDLE HiiHandle, IN UINT16 *DescriptionData, IN UINT16 *OptionalData, IN UINT8 ForceReconnect ) { UINT16 Index; UINT16 DriverString[12]; BM_MENU_ENTRY *NewMenuEntry; BM_LOAD_CONTEXT *NewLoadContext; BOOLEAN OptionalDataExist; EFI_STATUS Status; EFI_BOOT_MANAGER_LOAD_OPTION LoadOption; UINT8 *OptionalDesData; UINT32 OptionalDataSize; OptionalDataExist = FALSE; OptionalDesData = NULL; OptionalDataSize = 0; Index = BOpt_GetDriverOptionNumber (); UnicodeSPrint ( DriverString, sizeof (DriverString), L"Driver%04x", Index ); if (*DescriptionData == 0x0000) { StrCpyS (DescriptionData, MAX_MENU_NUMBER, DriverString); } if (*OptionalData != 0x0000) { OptionalDataExist = TRUE; OptionalDesData = (UINT8 *)OptionalData; OptionalDataSize = (UINT32)StrSize (OptionalData); } NewMenuEntry = BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT); if (NULL == NewMenuEntry) { return EFI_OUT_OF_RESOURCES; } Status = EfiBootManagerInitializeLoadOption ( &LoadOption, Index, LoadOptionTypeDriver, LOAD_OPTION_ACTIVE | (ForceReconnect << 1), DescriptionData, CallbackData->LoadContext->FilePathList, OptionalDesData, OptionalDataSize ); if (EFI_ERROR (Status)){ return Status; } Status = EfiBootManagerAddLoadOptionVariable (&LoadOption,(UINTN) -1 ); if (EFI_ERROR (Status)) { EfiBootManagerFreeLoadOption(&LoadOption); return Status; } NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext; NewLoadContext->Deleted = FALSE; NewLoadContext->Attributes = LoadOption.Attributes; NewLoadContext->FilePathListLength = (UINT16)GetDevicePathSize (LoadOption.FilePath); NewLoadContext->Description = AllocateZeroPool (StrSize (DescriptionData)); ASSERT (NewLoadContext->Description != NULL); NewMenuEntry->DisplayString = NewLoadContext->Description; CopyMem ( NewLoadContext->Description, LoadOption.Description, StrSize (DescriptionData) ); NewLoadContext->FilePathList = AllocateZeroPool (GetDevicePathSize (CallbackData->LoadContext->FilePathList)); ASSERT (NewLoadContext->FilePathList != NULL); CopyMem ( NewLoadContext->FilePathList, LoadOption.FilePath, GetDevicePathSize (CallbackData->LoadContext->FilePathList) ); NewMenuEntry->HelpString = UiDevicePathToStr (NewLoadContext->FilePathList); NewMenuEntry->OptionNumber = Index; NewMenuEntry->DisplayStringToken = HiiSetString (HiiHandle, 0, NewMenuEntry->DisplayString, NULL); NewMenuEntry->HelpStringToken = HiiSetString (HiiHandle, 0, NewMenuEntry->HelpString, NULL); if (OptionalDataExist) { NewLoadContext->OptionalData = AllocateZeroPool (LoadOption.OptionalDataSize); ASSERT (NewLoadContext->OptionalData != NULL); CopyMem ( NewLoadContext->OptionalData, LoadOption.OptionalData, LoadOption.OptionalDataSize ); } InsertTailList (&DriverOptionMenu.Head, &NewMenuEntry->Link); DriverOptionMenu.MenuNumber++; EfiBootManagerFreeLoadOption(&LoadOption); return EFI_SUCCESS; }