/** Install Boot Manager Menu driver. @param ImageHandle The image handle. @param SystemTable The system table. @retval EFI_SUCEESS Install Boot manager menu success. @retval Other Return error status. **/ EFI_STATUS EFIAPI BootManagerLibConstructor ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; // // Install Device Path Protocol and Config Access protocol to driver handle // gBootManagerPrivate.DriverHandle = NULL; Status = gBS->InstallMultipleProtocolInterfaces ( &gBootManagerPrivate.DriverHandle, &gEfiDevicePathProtocolGuid, &mBootManagerHiiVendorDevicePath, &gEfiHiiConfigAccessProtocolGuid, &gBootManagerPrivate.ConfigAccess, NULL ); ASSERT_EFI_ERROR (Status); // // Publish our HII data // gBootManagerPrivate.HiiHandle = HiiAddPackages ( &mBootManagerGuid, gBootManagerPrivate.DriverHandle, BootManagerVfrBin, BootManagerLibStrings, NULL ); ASSERT (gBootManagerPrivate.HiiHandle != NULL); // // Update boot manager page // UpdateBootManager (); return EFI_SUCCESS; }
/** 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 ) { EFI_BOOT_MANAGER_LOAD_OPTION *BootOption; UINTN BootOptionCount; EFI_INPUT_KEY Key; if (Action == EFI_BROWSER_ACTION_FORM_OPEN) { // //Means enter the boot manager form. //Update the boot manage page,because the boot option may changed. // if (QuestionId == 0x1212){ UpdateBootManager(); } return EFI_SUCCESS; } 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; } BootOption = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot); // // Clear the screen before. // gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)); gST->ConOut->ClearScreen (gST->ConOut); // // parse the selected option // BmBdsSetConsoleMode (FALSE); EfiBootManagerBoot (&BootOption[QuestionId - 1]); BmBdsSetConsoleMode (TRUE); if (EFI_ERROR (BootOption[QuestionId - 1].Status)) { gST->ConOut->OutputString ( gST->ConOut, HiiGetString (gBootManagerPrivate.HiiHandle, STRING_TOKEN (STR_ANY_KEY_CONTINUE), NULL) ); gST->ConIn->ReadKeyStroke (gST->ConIn, &Key); } EfiBootManagerFreeLoadOptions (BootOption, BootOptionCount); return EFI_SUCCESS; }