- // turn control over to the image
- // TODO: (optionally) re-enable the EFI watchdog timer!
- ReturnStatus = Status = refit_call3_wrapper(BS->StartImage, ChildImageHandle, NULL, NULL);
- // control returns here when the child image calls Exit()
- SPrint(ErrorInfo, 255, L"returned from %s", ImageTitle);
+ // load the image into memory (and execute it, in the case of a MOK image).
+ ReturnStatus = Status = EFI_NOT_FOUND; // in case the list is empty
+ for (DevicePathIndex = 0; DevicePaths[DevicePathIndex] != NULL; DevicePathIndex++) {
+ ReturnStatus = Status = refit_call6_wrapper(BS->LoadImage, FALSE, SelfImageHandle, DevicePaths[DevicePathIndex],
+ NULL, 0, &ChildImageHandle);
+ // ReturnStatus = Status = refit_call6_wrapper(BS->LoadImage, FALSE, SelfImageHandle, DevicePaths[DevicePathIndex],
+ // ImageData, ImageSize, &ChildImageHandle);
+ // TODO: Commented-out version above is more efficient if the below FindVolumeAndFilename()
+ // and ReadFile() calls (and surrounding logic) are moved earlier; however, this causes
+ // some computers, including my 32-bit Mac Mini and 64-bit Intel machine, to fail when
+ // launching a Linux kernel, with a "Failed to handle fs_proto" error message from the
+ // kernel. Find out what's causing this and fix it.
+ if (ReturnStatus == EFI_ACCESS_DENIED) {
+ // TODO: I originally had the next few lines a
+ FindVolumeAndFilename(DevicePaths[DevicePathIndex], &DeviceVolume, &loader);
+ if (DeviceVolume != NULL) {
+ Status = ReadFile(DeviceVolume->RootDir, loader, &File, &ImageSize);
+ ImageData = File.Buffer;
+ } else {
+ Status = EFI_NOT_FOUND;
+ Print(L"Error: device volume not found!\n");
+ } // if/else
+ ReturnStatus = Status = start_image(SelfImageHandle, loader, ImageData, ImageSize, FullLoadOptions, DeviceVolume);
+ if (ReturnStatus == EFI_SUCCESS) {
+ UseMok = TRUE;
+ } // if
+ }
+ if (ReturnStatus != EFI_NOT_FOUND) {
+ break;
+ }
+ }
+ SPrint(ErrorInfo, 255, L"while loading %s", ImageTitle);