#include <Ventoy.h>
BOOLEAN gDebugPrint = FALSE;
+BOOLEAN gDotEfiBoot = FALSE;
BOOLEAN gLoadIsoEfi = FALSE;
ventoy_ram_disk g_ramdisk_param;
ventoy_chain_head *g_chain;
UINT32 g_virt_chunk_num;
vtoy_block_data gBlockData;
static grub_env_get_pf grub_env_get = NULL;
+static grub_env_set_pf grub_env_set = NULL;
ventoy_grub_param_file_replace *g_file_replace_list = NULL;
ventoy_efi_file_replace g_efi_file_replace;
Status = gRT->SetVariable(L"VentoyRamDisk", &VarGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof(g_ramdisk_param), &(g_ramdisk_param));
- debug("set efi variable %r", Status);
+ debug("set ramdisk variable %r", Status);
return Status;
}
{
gDebugPrint = TRUE;
}
+
+ if (StrStr(pCmdLine, L"dotefi"))
+ {
+ gDotEfiBoot = TRUE;
+ }
if (StrStr(pCmdLine, L"isoefi=on"))
{
pGrubParam = (ventoy_grub_param *)StrHexToUintn(pPos + StrLen(L"env_param="));
grub_env_get = pGrubParam->grub_env_get;
+ grub_env_set = pGrubParam->grub_env_set;
g_file_replace_list = &pGrubParam->file_replace;
old_cnt = g_file_replace_list->old_file_cnt;
size = StrDecimalToUintn(pPos + 5);
debug("memory addr:%p size:%lu", chain, size);
-
- g_chain = AllocatePool(size);
- CopyMem(g_chain, chain, size);
+
+ if (StrStr(pCmdLine, L"sector512"))
+ {
+ gSector512Mode = TRUE;
+ }
if (StrStr(pCmdLine, L"memdisk"))
{
- g_iso_buf_size = size;
+ g_iso_data_buf = (UINT8 *)chain + sizeof(ventoy_chain_head);
+ g_iso_buf_size = size - sizeof(ventoy_chain_head);
+ debug("memdisk mode iso_buf_size:%u", g_iso_buf_size);
+
+ g_chain = chain;
gMemdiskMode = TRUE;
}
else
{
+ debug("This is normal mode");
+ g_chain = AllocatePool(size);
+ CopyMem(g_chain, chain, size);
+
g_chunk = (ventoy_img_chunk *)((char *)g_chain + g_chain->img_chunk_offset);
g_img_chunk_num = g_chain->img_chunk_num;
g_override_chunk = (ventoy_override_chunk *)((char *)g_chain + g_chain->override_chunk_offset);
}
}
+ ventoy_debug_pause();
+
FreePool(pCmdLine);
return EFI_SUCCESS;
}
if (Find == 0)
{
+ if (gDotEfiBoot)
+ {
+ break;
+ }
+
debug("Fs not found, now wait and retry...");
sleep(2);
}
if (gMemdiskMode)
{
- g_ramdisk_param.PhyAddr = (UINT64)(UINTN)g_chain;
+ g_ramdisk_param.PhyAddr = (UINT64)(UINTN)g_iso_data_buf;
g_ramdisk_param.DiskSize = (UINT64)g_iso_buf_size;
ventoy_save_ramdisk_param();
+
+ if (gLoadIsoEfi)
+ {
+ ventoy_find_iso_disk(ImageHandle);
+ ventoy_find_iso_disk_fs(ImageHandle);
+ ventoy_load_isoefi_driver(ImageHandle);
+ }
ventoy_install_blockio(ImageHandle, g_iso_buf_size);
+ ventoy_debug_pause();
+
Status = ventoy_boot(ImageHandle);
ventoy_delete_ramdisk_param();
+
+ if (gLoadIsoEfi && gBlockData.IsoDriverImage)
+ {
+ gBS->UnloadImage(gBlockData.IsoDriverImage);
+ }
+
+ gBS->DisconnectController(gBlockData.Handle, NULL, NULL);
+ gBS->UninstallMultipleProtocolInterfaces(gBlockData.Handle,
+ &gEfiBlockIoProtocolGuid, &gBlockData.BlockIo,
+ &gEfiDevicePathProtocolGuid, gBlockData.Path,
+ NULL);
}
else
{
ventoy_clean_env();
}
- if (EFI_NOT_FOUND == Status)
+ if (FALSE == gDotEfiBoot)
{
- gST->ConOut->OutputString(gST->ConOut, L"No bootfile found for UEFI!\r\n");
- gST->ConOut->OutputString(gST->ConOut, L"Maybe the image does not support " VENTOY_UEFI_DESC L"!\r\n");
- sleep(30);
+ if (EFI_NOT_FOUND == Status)
+ {
+ gST->ConOut->OutputString(gST->ConOut, L"No bootfile found for UEFI!\r\n");
+ gST->ConOut->OutputString(gST->ConOut, L"Maybe the image does not support " VENTOY_UEFI_DESC L"!\r\n");
+ sleep(30);
+ }
}
-
+
ventoy_clear_input();
gST->ConOut->ClearScreen(gST->ConOut);
+ if (gDotEfiBoot && (EFI_NOT_FOUND == Status))
+ {
+ grub_env_set("vtoy_dotefi_retry", "YES");
+ }
+
return EFI_SUCCESS;
}