Skip to content

Commit

Permalink
update for new release
Browse files Browse the repository at this point in the history
  • Loading branch information
ventoy committed Aug 29, 2020
1 parent 1bf3e73 commit 8dce0ad
Show file tree
Hide file tree
Showing 110 changed files with 2,610 additions and 103 deletions.
8 changes: 8 additions & 0 deletions DOC/BuildVentoyFromSource.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@
https://busybox.net/downloads/busybox-1.32.0.tar.bz2
use BUSYBOX/64h.config and uclibc to build busybox-1.32

4.19 == Build lunzip32/lunzip64 ==
http://mirror.yongbok.net/nongnu/lzip/lunzip/lunzip-1.11.tar.gz
PATH=$PATH:/opt/diet/bin
./configure --disable-nls CC='diet gcc -nostdinc'
make
strip --strip-all lunzip



==========================================
5. Binaries
Expand Down
29 changes: 29 additions & 0 deletions DOC/LoopExBuild.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

1. LAKKA dm-mod.ko
LaKKa config
https://github.com/libretro/Lakka-LibreELEC/releases download source code
\projects\Generic\linux\linux.x86_64.conf

Linux Kernel
linux-4.11.12.tar.xz & patch-4.11.12-rt14.patch.xz
patch -p1 < ../patch-4.11.12-rt14

make menuconfig
select device mapper as module
make -j 16
get drivers\md\dm-mod.ko

2. LibreELEC dm-mod.ko
LibreELEC config
https://github.com/LibreELEC/LibreELEC.tv/releases download source code
\projects\Generic\linux\linux.x86_64.conf

Linux Kernel
linux-5.1.6.tar.xz
make menuconfig
select device mapper as module
make -j 16
get drivers\md\dm-mod.ko



Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <Ventoy.h>

BOOLEAN gDebugPrint = FALSE;
BOOLEAN gDotEfiBoot = FALSE;
BOOLEAN gLoadIsoEfi = FALSE;
ventoy_ram_disk g_ramdisk_param;
ventoy_chain_head *g_chain;
Expand All @@ -49,6 +50,7 @@ ventoy_virt_chunk *g_virt_chunk;
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;
Expand Down Expand Up @@ -602,6 +604,11 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
{
gDebugPrint = TRUE;
}

if (StrStr(pCmdLine, L"dotefi"))
{
gDotEfiBoot = TRUE;
}

if (StrStr(pCmdLine, L"isoefi=on"))
{
Expand Down Expand Up @@ -643,6 +650,7 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)

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;
Expand All @@ -664,6 +672,11 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)

debug("memory addr:%p size:%lu", chain, size);

if (StrStr(pCmdLine, L"sector512"))
{
gSector512Mode = TRUE;
}

if (StrStr(pCmdLine, L"memdisk"))
{
g_iso_data_buf = (UINT8 *)chain + sizeof(ventoy_chain_head);
Expand Down Expand Up @@ -906,6 +919,11 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle)

if (Find == 0)
{
if (gDotEfiBoot)
{
break;
}

debug("Fs not found, now wait and retry...");
sleep(2);
}
Expand Down Expand Up @@ -972,6 +990,12 @@ EFI_STATUS EFIAPI VentoyEfiMain
{
gBS->UnloadImage(gBlockData.IsoDriverImage);
}

gBS->DisconnectController(gBlockData.Handle, NULL, NULL);
gBS->UninstallMultipleProtocolInterfaces(gBlockData.Handle,
&gEfiBlockIoProtocolGuid, &gBlockData.BlockIo,
&gEfiDevicePathProtocolGuid, gBlockData.Path,
NULL);
}
else
{
Expand All @@ -995,16 +1019,24 @@ EFI_STATUS EFIAPI VentoyEfiMain
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;
}

Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ if (gDebugPrint) \
gBS->WaitForEvent(1, &gST->ConIn->WaitForKey, &__Index);\
}

typedef int (*grub_env_set_pf)(const char *name, const char *val);
typedef const char * (*grub_env_get_pf)(const char *name);
typedef int (*grub_env_printf_pf)(const char *fmt, ...);

Expand Down Expand Up @@ -255,6 +256,7 @@ typedef struct ventoy_grub_param_file_replace
typedef struct ventoy_grub_param
{
grub_env_get_pf grub_env_get;
grub_env_set_pf grub_env_set;
ventoy_grub_param_file_replace file_replace;
grub_env_printf_pf grub_env_printf;
}ventoy_grub_param;
Expand Down Expand Up @@ -338,6 +340,7 @@ extern ventoy_efi_file_replace g_efi_file_replace;
extern ventoy_sector_flag *g_sector_flag;
extern UINT32 g_sector_flag_num;
extern BOOLEAN gMemdiskMode;
extern BOOLEAN gSector512Mode;
extern UINTN g_iso_buf_size;
extern UINT8 *g_iso_data_buf;
extern ventoy_grub_param_file_replace *g_file_replace_list;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
UINT8 *g_iso_data_buf = NULL;
UINTN g_iso_buf_size = 0;
BOOLEAN gMemdiskMode = FALSE;
BOOLEAN gSector512Mode = FALSE;

ventoy_sector_flag *g_sector_flag = NULL;
UINT32 g_sector_flag_num = 0;
Expand Down Expand Up @@ -68,6 +69,9 @@ STATIC EFI_INPUT_READ_KEY g_org_read_key = NULL;

STATIC EFI_LOCATE_HANDLE g_org_locate_handle = NULL;

STATIC UINT8 g_sector_buf[2048];
STATIC EFI_BLOCK_READ g_sector_2048_read = NULL;

BOOLEAN ventoy_is_cdrom_dp_exist(VOID)
{
UINTN i = 0;
Expand Down Expand Up @@ -571,6 +575,64 @@ EFI_STATUS EFIAPI ventoy_connect_driver(IN EFI_HANDLE ControllerHandle, IN CONST
return Status;
}

EFI_STATUS EFIAPI ventoy_block_io_read_512
(
IN EFI_BLOCK_IO_PROTOCOL *This,
IN UINT32 MediaId,
IN EFI_LBA Lba,
IN UINTN BufferSize,
OUT VOID *Buffer
)
{
EFI_LBA Mod;
UINTN ReadSize;
UINT8 *CurBuf = NULL;
EFI_STATUS Status = EFI_SUCCESS;

debug("ventoy_block_io_read_512 %lu %lu\n", Lba, BufferSize / 512);

CurBuf = (UINT8 *)Buffer;

Mod = Lba % 4;
if (Mod > 0)
{
Status |= g_sector_2048_read(This, MediaId, Lba / 4, 2048, g_sector_buf);

if (BufferSize <= (4 - Mod) * 512)
{
CopyMem(CurBuf, g_sector_buf + Mod * 512, BufferSize);
return EFI_SUCCESS;
}
else
{
ReadSize = (4 - Mod) * 512;
CopyMem(CurBuf, g_sector_buf + Mod * 512, ReadSize);
CurBuf += ReadSize;
Lba += (4 - Mod);
BufferSize -= ReadSize;
}
}

if (BufferSize >= 2048)
{
ReadSize = BufferSize / 2048 * 2048;

Status |= g_sector_2048_read(This, MediaId, Lba / 4, ReadSize, CurBuf);
CurBuf += ReadSize;

Lba += ReadSize / 512;
BufferSize -= ReadSize;
}

if (BufferSize > 0)
{
Status |= g_sector_2048_read(This, MediaId, Lba / 4, 2048, g_sector_buf);
CopyMem(CurBuf, g_sector_buf, BufferSize);
}

return Status;
}

EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 ImgSize)
{
EFI_STATUS Status = EFI_SUCCESS;
Expand All @@ -580,17 +642,36 @@ EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 Im

debug("install block io protocol %p", ImageHandle);
ventoy_debug_pause();

if (gSector512Mode)
{
gBlockData.Media.BlockSize = 512;
gBlockData.Media.LastBlock = ImgSize / 512 - 1;
}
else
{
gBlockData.Media.BlockSize = 2048;
gBlockData.Media.LastBlock = ImgSize / 2048 - 1;
}

gBlockData.Media.BlockSize = 2048;
gBlockData.Media.LastBlock = ImgSize / 2048 - 1;
gBlockData.Media.ReadOnly = TRUE;
gBlockData.Media.MediaPresent = 1;
gBlockData.Media.LogicalBlocksPerPhysicalBlock = 1;

pBlockIo->Revision = EFI_BLOCK_IO_PROTOCOL_REVISION3;
pBlockIo->Media = &(gBlockData.Media);
pBlockIo->Reset = ventoy_block_io_reset;
pBlockIo->ReadBlocks = gMemdiskMode ? ventoy_block_io_ramdisk_read : ventoy_block_io_read;

if (gSector512Mode)
{
g_sector_2048_read = gMemdiskMode ? ventoy_block_io_ramdisk_read : ventoy_block_io_read;
pBlockIo->ReadBlocks = ventoy_block_io_read_512;
}
else
{
pBlockIo->ReadBlocks = gMemdiskMode ? ventoy_block_io_ramdisk_read : ventoy_block_io_read;
}

pBlockIo->WriteBlocks = ventoy_block_io_write;
pBlockIo->FlushBlocks = ventoy_block_io_flush;

Expand All @@ -603,10 +684,10 @@ EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 Im
{
return Status;
}

Status = ventoy_connect_driver(gBlockData.Handle, L"Disk I/O Driver");
debug("Connect disk IO driver %r", Status);

Status = ventoy_connect_driver(gBlockData.Handle, L"Partition Driver");
debug("Connect partition driver %r", Status);
if (EFI_ERROR(Status))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#pragma pack(1)

typedef EFI_STATUS (*VTOY_UTIL_PROC_PF)(IN EFI_HANDLE ImageHandle, IN CONST CHAR16 *CmdLine);
typedef int (*grub_env_set_pf)(const char *name, const char *val);
typedef const char * (*grub_env_get_pf)(const char *name);
typedef int (*grub_env_printf_pf)(const char *fmt, ...);

Expand All @@ -38,6 +39,7 @@ typedef struct ventoy_grub_param_file_replace
typedef struct ventoy_grub_param
{
grub_env_get_pf grub_env_get;
grub_env_set_pf grub_env_set;
ventoy_grub_param_file_replace file_replace;
grub_env_printf_pf grub_env_printf;
}ventoy_grub_param;
Expand Down
1 change: 1 addition & 0 deletions EfiISO/ISO/EFI/BOOT/BOOTX64.EFI
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
13 changes: 13 additions & 0 deletions EfiISO/mkefiiso.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

rm -f ventoy_efiboot.img.*

cd ISO
mkisofs -R -D -sysid VENTOY -V VENTOY -P "longpanda admin@ventoy.net" -p 'https://www.ventoy.net' -o ../ventoy_efiboot.img ./
cd ..

xz --check=crc32 ventoy_efiboot.img

rm -f ../INSTALL/ventoy/ventoy_efiboot.img.xz
cp -a ventoy_efiboot.img.xz ../INSTALL/ventoy/

7 changes: 6 additions & 1 deletion GRUB2/MOD_SRC/grub-2.04/grub-core/loader/i386/linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,11 @@ static int ventoy_boot_opt_filter(char *opt)
return 1;
}

if (grub_strcmp(opt, "vga=current") == 0)
{
return 1;
}

if (grub_strncmp(opt, "rdinit=", 7) == 0)
{
if (grub_strcmp(opt, "rdinit=/vtoy/vtoy") != 0)
Expand Down Expand Up @@ -1224,7 +1229,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
linux_mem_size = 0;
for (i = 1; i < argc; i++)
#ifdef GRUB_MACHINE_PCBIOS
if (grub_memcmp (argv[i], "vga=", 4) == 0)
if (grub_memcmp (argv[i], "vga=", 4) == 0 && (grub_memcmp (argv[i], "vga=current", 11) != 0))
{
/* Video mode selection support. */
char *val = argv[i] + 4;
Expand Down
Loading

0 comments on commit 8dce0ad

Please sign in to comment.