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; }
/** The function will load and start every Driver####/SysPrep####. @param LoadOptions Load option array. @param LoadOptionCount Load option count. **/ VOID ProcessLoadOptions ( IN EFI_BOOT_MANAGER_LOAD_OPTION *LoadOptions, IN UINTN LoadOptionCount ) { EFI_STATUS Status; UINTN Index; BOOLEAN ReconnectAll; EFI_BOOT_MANAGER_LOAD_OPTION_TYPE LoadOptionType; ReconnectAll = FALSE; LoadOptionType = LoadOptionTypeMax; // // Process the driver option // for (Index = 0; Index < LoadOptionCount; Index++) { // // All the load options in the array should be of the same type. // if (LoadOptionType == LoadOptionTypeMax) { LoadOptionType = LoadOptions[Index].OptionType; } ASSERT (LoadOptionType == LoadOptions[Index].OptionType); ASSERT (LoadOptionType == LoadOptionTypeDriver || LoadOptionType == LoadOptionTypeSysPrep); Status = EfiBootManagerProcessLoadOption (&LoadOptions[Index]); if (!EFI_ERROR (Status) && ((LoadOptions[Index].Attributes & LOAD_OPTION_FORCE_RECONNECT) != 0)) { ReconnectAll = TRUE; } } // // If a driver load option is marked as LOAD_OPTION_FORCE_RECONNECT, // then all of the EFI drivers in the system will be disconnected and // reconnected after the last driver load option is processed. // if (ReconnectAll && LoadOptionType == LoadOptionTypeDriver) { EfiBootManagerDisconnectAll (); EfiBootManagerConnectAll (); } }