mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-09-22 19:51:14 +00:00
Compare commits
60 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
da20eb5568 | ||
|
2d76fa7303 | ||
|
8fc8cc6867 | ||
|
132649c4e5 | ||
|
c3c8100866 | ||
|
94e24e63c5 | ||
|
c19cd649d8 | ||
|
20914350fb | ||
|
8b411663cf | ||
|
01292939d3 | ||
|
dcc5889677 | ||
|
04828df028 | ||
|
2f95139c77 | ||
|
f2bb3667c4 | ||
|
791da48673 | ||
|
f683bcbd59 | ||
|
15b8b1f358 | ||
|
a20592ecd1 | ||
|
ed1aa3d5be | ||
|
8e66110374 | ||
|
f5f65aa868 | ||
|
4e5fcf211b | ||
|
9789069c0d | ||
|
1cf45ac0c5 | ||
|
40fe21f909 | ||
|
e6bdf075ca | ||
|
7c76e57bf4 | ||
|
7fe038b697 | ||
|
c01c69db3b | ||
|
0e996e74c9 | ||
|
1371159f0b | ||
|
44b38dce74 | ||
|
392d8ef4fa | ||
|
d1900c75cd | ||
|
fa7e1d5fa0 | ||
|
6ae8bf840d | ||
|
ce862da402 | ||
|
6d4f5ff00b | ||
|
ab0f25d097 | ||
|
ff14c07c4e | ||
|
f7fac26c91 | ||
|
ebae102f41 | ||
|
c3718d6001 | ||
|
d0744513a6 | ||
|
5b0fca8468 | ||
|
27918eb3f9 | ||
|
7859271b20 | ||
|
1c27c0b489 | ||
|
0f89c2767f | ||
|
d1584c10b4 | ||
|
43e921878b | ||
|
23f4f18e27 | ||
|
53b95ae17b | ||
|
e3506c0f10 | ||
|
9118d5fe45 | ||
|
f130325a9c | ||
|
1ca48923da | ||
|
730fdd5198 | ||
|
d0f3597b26 | ||
|
045f53d768 |
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
@@ -6,7 +6,7 @@ open_collective: # Replace with a single Open Collective username
|
|||||||
ko_fi: # Replace with a single Ko-fi username
|
ko_fi: # Replace with a single Ko-fi username
|
||||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||||
liberapay: # Replace with a single Liberapay username
|
liberapay: Ventoy
|
||||||
issuehunt: # Replace with a single IssueHunt username
|
issuehunt: # Replace with a single IssueHunt username
|
||||||
otechie: # Replace with a single Otechie username
|
otechie: # Replace with a single Otechie username
|
||||||
custom: ['https://www.paypal.me/ventoy', 'https://www.ventoy.net/en/donation.html'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
custom: ['https://www.paypal.me/ventoy', 'https://www.ventoy.net/en/donation.html'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||||
|
2
.github/ISSUE_TEMPLATE/issue_template.yml
vendored
2
.github/ISSUE_TEMPLATE/issue_template.yml
vendored
@@ -21,7 +21,7 @@ body:
|
|||||||
attributes:
|
attributes:
|
||||||
label: Ventoy Version
|
label: Ventoy Version
|
||||||
description: What version of ventoy are you running?
|
description: What version of ventoy are you running?
|
||||||
placeholder: 1.0.68
|
placeholder: 1.0.72
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: dropdown
|
- type: dropdown
|
||||||
|
@@ -108,10 +108,10 @@
|
|||||||
cd /home/Ventoy-master/VtoyTool
|
cd /home/Ventoy-master/VtoyTool
|
||||||
sh build.sh
|
sh build.sh
|
||||||
|
|
||||||
4.8 == Build vtoyfat ==
|
4.8 == Build vtoycli ==
|
||||||
cd /home/Ventoy-master/vtoyfat/fat_io_lib
|
cd /home/Ventoy-master/vtoycli/fat_io_lib
|
||||||
sh buildlib.sh
|
sh buildlib.sh
|
||||||
cd /home/Ventoy-master/vtoyfat
|
cd /home/Ventoy-master/vtoycli
|
||||||
sh build.sh
|
sh build.sh
|
||||||
|
|
||||||
4.9 == Build exfat-util ==
|
4.9 == Build exfat-util ==
|
||||||
|
@@ -913,6 +913,12 @@ module = {
|
|||||||
enable = x86_64_efi;
|
enable = x86_64_efi;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
module = {
|
||||||
|
name = fwload;
|
||||||
|
efi = commands/efi/fwload.c;
|
||||||
|
enable = efi;
|
||||||
|
};
|
||||||
|
|
||||||
module = {
|
module = {
|
||||||
name = gptsync;
|
name = gptsync;
|
||||||
common = commands/gptsync.c;
|
common = commands/gptsync.c;
|
||||||
@@ -1123,6 +1129,21 @@ module = {
|
|||||||
common = commands/sleep.c;
|
common = commands/sleep.c;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
module = {
|
||||||
|
name = smbios;
|
||||||
|
|
||||||
|
common = commands/smbios.c;
|
||||||
|
efi = commands/efi/smbios.c;
|
||||||
|
i386_pc = commands/i386/pc/smbios.c;
|
||||||
|
i386_coreboot = commands/i386/pc/smbios.c;
|
||||||
|
i386_multiboot = commands/i386/pc/smbios.c;
|
||||||
|
|
||||||
|
enable = efi;
|
||||||
|
enable = i386_pc;
|
||||||
|
enable = i386_coreboot;
|
||||||
|
enable = i386_multiboot;
|
||||||
|
};
|
||||||
|
|
||||||
module = {
|
module = {
|
||||||
name = suspend;
|
name = suspend;
|
||||||
ieee1275 = commands/ieee1275/suspend.c;
|
ieee1275 = commands/ieee1275/suspend.c;
|
||||||
@@ -1622,6 +1643,12 @@ module = {
|
|||||||
common = term/setkey.c;
|
common = term/setkey.c;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
module = {
|
||||||
|
name = mouse;
|
||||||
|
efi = term/efi/mouse.c;
|
||||||
|
enable = efi;
|
||||||
|
};
|
||||||
|
|
||||||
module = {
|
module = {
|
||||||
name = hello;
|
name = hello;
|
||||||
common = hello/hello.c;
|
common = hello/hello.c;
|
||||||
|
205
GRUB2/MOD_SRC/grub-2.04/grub-core/commands/efi/fwload.c
Normal file
205
GRUB2/MOD_SRC/grub-2.04/grub-core/commands/efi/fwload.c
Normal file
@@ -0,0 +1,205 @@
|
|||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2022 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* GRUB is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* GRUB is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <grub/dl.h>
|
||||||
|
#include <grub/efi/api.h>
|
||||||
|
#include <grub/efi/efi.h>
|
||||||
|
#include <grub/err.h>
|
||||||
|
#include <grub/extcmd.h>
|
||||||
|
#include <grub/file.h>
|
||||||
|
#include <grub/i18n.h>
|
||||||
|
#include <grub/misc.h>
|
||||||
|
#include <grub/mm.h>
|
||||||
|
#include <grub/types.h>
|
||||||
|
|
||||||
|
GRUB_MOD_LICENSE ("GPLv3+");
|
||||||
|
|
||||||
|
static grub_efi_guid_t loaded_image_guid = GRUB_EFI_LOADED_IMAGE_GUID;
|
||||||
|
|
||||||
|
static grub_efi_status_t
|
||||||
|
grub_efi_connect_all (void)
|
||||||
|
{
|
||||||
|
grub_efi_status_t status;
|
||||||
|
grub_efi_uintn_t handle_count;
|
||||||
|
grub_efi_handle_t *handle_buffer;
|
||||||
|
grub_efi_uintn_t index;
|
||||||
|
grub_efi_boot_services_t *b;
|
||||||
|
grub_dprintf ("efi", "Connecting ...\n");
|
||||||
|
b = grub_efi_system_table->boot_services;
|
||||||
|
status = efi_call_5 (b->locate_handle_buffer,
|
||||||
|
GRUB_EFI_ALL_HANDLES, NULL, NULL,
|
||||||
|
&handle_count, &handle_buffer);
|
||||||
|
|
||||||
|
if (status != GRUB_EFI_SUCCESS)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
for (index = 0; index < handle_count; index++)
|
||||||
|
{
|
||||||
|
status = efi_call_4 (b->connect_controller,
|
||||||
|
handle_buffer[index], NULL, NULL, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (handle_buffer)
|
||||||
|
{
|
||||||
|
efi_call_1 (b->free_pool, handle_buffer);
|
||||||
|
}
|
||||||
|
return GRUB_EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_efi_load_driver (grub_size_t size, void *boot_image, int connect)
|
||||||
|
{
|
||||||
|
grub_efi_status_t status;
|
||||||
|
grub_efi_handle_t driver_handle;
|
||||||
|
grub_efi_boot_services_t *b;
|
||||||
|
grub_efi_loaded_image_t *loaded_image;
|
||||||
|
|
||||||
|
b = grub_efi_system_table->boot_services;
|
||||||
|
|
||||||
|
status = efi_call_6 (b->load_image, 0, grub_efi_image_handle, NULL,
|
||||||
|
boot_image, size, &driver_handle);
|
||||||
|
if (status != GRUB_EFI_SUCCESS)
|
||||||
|
{
|
||||||
|
if (status == GRUB_EFI_OUT_OF_RESOURCES)
|
||||||
|
grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of resources");
|
||||||
|
else
|
||||||
|
grub_error (GRUB_ERR_BAD_OS, "cannot load image");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
loaded_image = grub_efi_get_loaded_image (driver_handle);
|
||||||
|
if (! loaded_image)
|
||||||
|
{
|
||||||
|
grub_error (GRUB_ERR_BAD_OS, "no loaded image available");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
grub_dprintf ("efi", "Registering loaded image\n");
|
||||||
|
status = efi_call_3 (b->handle_protocol, driver_handle,
|
||||||
|
&loaded_image_guid, (void **)&loaded_image);
|
||||||
|
if (status != GRUB_EFI_SUCCESS)
|
||||||
|
{
|
||||||
|
grub_error (GRUB_ERR_BAD_OS, "not a dirver");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
grub_dprintf ("efi", "StartImage: %p\n", boot_image);
|
||||||
|
status = efi_call_3 (b->start_image, driver_handle, NULL, NULL);
|
||||||
|
if (status != GRUB_EFI_SUCCESS)
|
||||||
|
{
|
||||||
|
grub_error (GRUB_ERR_BAD_OS, "StartImage failed");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
if (connect)
|
||||||
|
{
|
||||||
|
status = grub_efi_connect_all ();
|
||||||
|
if (status != GRUB_EFI_SUCCESS)
|
||||||
|
{
|
||||||
|
grub_error (GRUB_ERR_BAD_OS, "cannot connect controllers\n");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
grub_dprintf ("efi", "Driver installed\n");
|
||||||
|
return 0;
|
||||||
|
fail:
|
||||||
|
return grub_errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct grub_arg_option options_fwload[] =
|
||||||
|
{
|
||||||
|
{"nc", 'n', 0, N_("Loads the driver, but does not connect the driver."), 0, 0},
|
||||||
|
{0, 0, 0, 0, 0, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_cmd_fwload (grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
|
{
|
||||||
|
struct grub_arg_list *state = ctxt->state;
|
||||||
|
int connect = 1;
|
||||||
|
grub_file_t file = 0;
|
||||||
|
grub_efi_boot_services_t *b;
|
||||||
|
grub_efi_status_t status;
|
||||||
|
grub_efi_uintn_t pages = 0;
|
||||||
|
grub_ssize_t size;
|
||||||
|
grub_efi_physical_address_t address;
|
||||||
|
void *boot_image = 0;
|
||||||
|
|
||||||
|
b = grub_efi_system_table->boot_services;
|
||||||
|
if (argc != 1)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
file = grub_file_open (args[0], GRUB_FILE_TYPE_EFI_CHAINLOADED_IMAGE);
|
||||||
|
if (! file)
|
||||||
|
goto fail;
|
||||||
|
size = grub_file_size (file);
|
||||||
|
if (!size)
|
||||||
|
{
|
||||||
|
grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), args[0]);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
pages = (((grub_efi_uintn_t) size + ((1 << 12) - 1)) >> 12);
|
||||||
|
status = efi_call_4 (b->allocate_pages, GRUB_EFI_ALLOCATE_ANY_PAGES,
|
||||||
|
GRUB_EFI_LOADER_CODE, pages, &address);
|
||||||
|
if (status != GRUB_EFI_SUCCESS)
|
||||||
|
{
|
||||||
|
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
boot_image = (void *) ((grub_addr_t) address);
|
||||||
|
if (grub_file_read (file, boot_image, size) != size)
|
||||||
|
{
|
||||||
|
if (grub_errno == GRUB_ERR_NONE)
|
||||||
|
grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), args[0]);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
grub_file_close (file);
|
||||||
|
if (state[0].set)
|
||||||
|
connect = 0;
|
||||||
|
if (grub_efi_load_driver (size, boot_image, connect))
|
||||||
|
goto fail;
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
fail:
|
||||||
|
if (file)
|
||||||
|
grub_file_close (file);
|
||||||
|
if (address)
|
||||||
|
efi_call_2 (b->free_pages, address, pages);
|
||||||
|
return grub_errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_cmd_fwconnect (grub_extcmd_context_t ctxt __attribute__ ((unused)),
|
||||||
|
int argc __attribute__ ((unused)),
|
||||||
|
char **args __attribute__ ((unused)))
|
||||||
|
{
|
||||||
|
grub_efi_connect_all ();
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_extcmd_t cmd_fwload, cmd_fwconnect;
|
||||||
|
|
||||||
|
GRUB_MOD_INIT(fwload)
|
||||||
|
{
|
||||||
|
cmd_fwload = grub_register_extcmd ("fwload", grub_cmd_fwload, 0, N_("FILE"),
|
||||||
|
N_("Install UEFI driver."), options_fwload);
|
||||||
|
cmd_fwconnect = grub_register_extcmd ("fwconnect", grub_cmd_fwconnect, 0,
|
||||||
|
NULL, N_("Connect drivers."), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
GRUB_MOD_FINI(fwload)
|
||||||
|
{
|
||||||
|
grub_unregister_extcmd (cmd_fwload);
|
||||||
|
grub_unregister_extcmd (cmd_fwconnect);
|
||||||
|
}
|
61
GRUB2/MOD_SRC/grub-2.04/grub-core/commands/efi/smbios.c
Normal file
61
GRUB2/MOD_SRC/grub-2.04/grub-core/commands/efi/smbios.c
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
/* smbios.c - get smbios tables. */
|
||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2019 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* GRUB is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* GRUB is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <grub/smbios.h>
|
||||||
|
#include <grub/misc.h>
|
||||||
|
#include <grub/efi/efi.h>
|
||||||
|
#include <grub/efi/api.h>
|
||||||
|
|
||||||
|
struct grub_smbios_eps *
|
||||||
|
grub_machine_smbios_get_eps (void)
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
static grub_efi_packed_guid_t smbios_guid = GRUB_EFI_SMBIOS_TABLE_GUID;
|
||||||
|
|
||||||
|
for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
|
||||||
|
{
|
||||||
|
grub_efi_packed_guid_t *guid =
|
||||||
|
&grub_efi_system_table->configuration_table[i].vendor_guid;
|
||||||
|
|
||||||
|
if (! grub_memcmp (guid, &smbios_guid, sizeof (grub_efi_packed_guid_t)))
|
||||||
|
return (struct grub_smbios_eps *)
|
||||||
|
grub_efi_system_table->configuration_table[i].vendor_table;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct grub_smbios_eps3 *
|
||||||
|
grub_machine_smbios_get_eps3 (void)
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
static grub_efi_packed_guid_t smbios3_guid = GRUB_EFI_SMBIOS3_TABLE_GUID;
|
||||||
|
|
||||||
|
for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
|
||||||
|
{
|
||||||
|
grub_efi_packed_guid_t *guid =
|
||||||
|
&grub_efi_system_table->configuration_table[i].vendor_guid;
|
||||||
|
|
||||||
|
if (! grub_memcmp (guid, &smbios3_guid, sizeof (grub_efi_packed_guid_t)))
|
||||||
|
return (struct grub_smbios_eps3 *)
|
||||||
|
grub_efi_system_table->configuration_table[i].vendor_table;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
52
GRUB2/MOD_SRC/grub-2.04/grub-core/commands/i386/pc/smbios.c
Normal file
52
GRUB2/MOD_SRC/grub-2.04/grub-core/commands/i386/pc/smbios.c
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/* smbios.c - get smbios tables. */
|
||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2019 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* GRUB is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* GRUB is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <grub/acpi.h>
|
||||||
|
#include <grub/smbios.h>
|
||||||
|
#include <grub/misc.h>
|
||||||
|
|
||||||
|
struct grub_smbios_eps *
|
||||||
|
grub_machine_smbios_get_eps (void)
|
||||||
|
{
|
||||||
|
grub_uint8_t *ptr;
|
||||||
|
|
||||||
|
grub_dprintf ("smbios", "Looking for SMBIOS EPS. Scanning BIOS\n");
|
||||||
|
|
||||||
|
for (ptr = (grub_uint8_t *) 0xf0000; ptr < (grub_uint8_t *) 0x100000; ptr += 16)
|
||||||
|
if (grub_memcmp (ptr, "_SM_", 4) == 0
|
||||||
|
&& grub_byte_checksum (ptr, sizeof (struct grub_smbios_eps)) == 0)
|
||||||
|
return (struct grub_smbios_eps *) ptr;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct grub_smbios_eps3 *
|
||||||
|
grub_machine_smbios_get_eps3 (void)
|
||||||
|
{
|
||||||
|
grub_uint8_t *ptr;
|
||||||
|
|
||||||
|
grub_dprintf ("smbios", "Looking for SMBIOS3 EPS. Scanning BIOS\n");
|
||||||
|
|
||||||
|
for (ptr = (grub_uint8_t *) 0xf0000; ptr < (grub_uint8_t *) 0x100000; ptr += 16)
|
||||||
|
if (grub_memcmp (ptr, "_SM3_", 5) == 0
|
||||||
|
&& grub_byte_checksum (ptr, sizeof (struct grub_smbios_eps3)) == 0)
|
||||||
|
return (struct grub_smbios_eps3 *) ptr;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
@@ -68,7 +68,7 @@ iterate_device (const char *name, void *data)
|
|||||||
/* Skip floppy drives when requested. */
|
/* Skip floppy drives when requested. */
|
||||||
if (ctx->no_floppy &&
|
if (ctx->no_floppy &&
|
||||||
name[0] == 'f' && name[1] == 'd' && name[2] >= '0' && name[2] <= '9')
|
name[0] == 'f' && name[1] == 'd' && name[2] >= '0' && name[2] <= '9')
|
||||||
return 1;
|
return 0;
|
||||||
|
|
||||||
if (g_no_vtoyefi_part && (grub_strcmp(name, g_vtoyefi_dosname) == 0 || grub_strcmp(name, g_vtoyefi_gptname) == 0)) {
|
if (g_no_vtoyefi_part && (grub_strcmp(name, g_vtoyefi_dosname) == 0 || grub_strcmp(name, g_vtoyefi_gptname) == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
399
GRUB2/MOD_SRC/grub-2.04/grub-core/commands/smbios.c
Normal file
399
GRUB2/MOD_SRC/grub-2.04/grub-core/commands/smbios.c
Normal file
@@ -0,0 +1,399 @@
|
|||||||
|
/* smbios.c - retrieve smbios information. */
|
||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2019 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* GRUB is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* GRUB is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <grub/dl.h>
|
||||||
|
#include <grub/env.h>
|
||||||
|
#include <grub/extcmd.h>
|
||||||
|
#include <grub/i18n.h>
|
||||||
|
#include <grub/misc.h>
|
||||||
|
#include <grub/mm.h>
|
||||||
|
#include <grub/smbios.h>
|
||||||
|
|
||||||
|
GRUB_MOD_LICENSE ("GPLv3+");
|
||||||
|
|
||||||
|
/* Abstract useful values found in either the SMBIOS3 or SMBIOS EPS. */
|
||||||
|
static struct {
|
||||||
|
grub_addr_t start;
|
||||||
|
grub_addr_t end;
|
||||||
|
grub_uint16_t structures;
|
||||||
|
} table_desc;
|
||||||
|
|
||||||
|
static grub_extcmd_t cmd;
|
||||||
|
|
||||||
|
/* Locate the SMBIOS entry point structure depending on the hardware. */
|
||||||
|
struct grub_smbios_eps *
|
||||||
|
grub_smbios_get_eps (void)
|
||||||
|
{
|
||||||
|
static struct grub_smbios_eps *eps = NULL;
|
||||||
|
|
||||||
|
if (eps != NULL)
|
||||||
|
return eps;
|
||||||
|
|
||||||
|
eps = grub_machine_smbios_get_eps ();
|
||||||
|
|
||||||
|
return eps;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Locate the SMBIOS3 entry point structure depending on the hardware. */
|
||||||
|
static struct grub_smbios_eps3 *
|
||||||
|
grub_smbios_get_eps3 (void)
|
||||||
|
{
|
||||||
|
static struct grub_smbios_eps3 *eps = NULL;
|
||||||
|
|
||||||
|
if (eps != NULL)
|
||||||
|
return eps;
|
||||||
|
|
||||||
|
eps = grub_machine_smbios_get_eps3 ();
|
||||||
|
|
||||||
|
return eps;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
linux_string (const char *value)
|
||||||
|
{
|
||||||
|
char *out = grub_malloc( grub_strlen (value) + 1);
|
||||||
|
const char *src = value;
|
||||||
|
char *dst = out;
|
||||||
|
|
||||||
|
for (; *src; src++)
|
||||||
|
if (*src > ' ' && *src < 127 && *src != ':')
|
||||||
|
*dst++ = *src;
|
||||||
|
|
||||||
|
*dst = 0;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These functions convert values from the various SMBIOS structure field types
|
||||||
|
* into a string formatted to be returned to the user. They expect that the
|
||||||
|
* structure and offset were already validated. When the requested data is
|
||||||
|
* successfully retrieved and formatted, the pointer to the string is returned;
|
||||||
|
* otherwise, NULL is returned on failure. Don't free the result.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
grub_smbios_format_byte (const grub_uint8_t *structure, grub_uint8_t offset)
|
||||||
|
{
|
||||||
|
static char buffer[sizeof ("255")];
|
||||||
|
|
||||||
|
grub_snprintf (buffer, sizeof (buffer), "%u", structure[offset]);
|
||||||
|
|
||||||
|
return (const char *)buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
grub_smbios_format_word (const grub_uint8_t *structure, grub_uint8_t offset)
|
||||||
|
{
|
||||||
|
static char buffer[sizeof ("65535")];
|
||||||
|
|
||||||
|
grub_uint16_t value = grub_get_unaligned16 (structure + offset);
|
||||||
|
grub_snprintf (buffer, sizeof (buffer), "%u", value);
|
||||||
|
|
||||||
|
return (const char *)buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
grub_smbios_format_dword (const grub_uint8_t *structure, grub_uint8_t offset)
|
||||||
|
{
|
||||||
|
static char buffer[sizeof ("4294967295")];
|
||||||
|
|
||||||
|
grub_uint32_t value = grub_get_unaligned32 (structure + offset);
|
||||||
|
grub_snprintf (buffer, sizeof (buffer), "%" PRIuGRUB_UINT32_T, value);
|
||||||
|
|
||||||
|
return (const char *)buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
grub_smbios_format_qword (const grub_uint8_t *structure, grub_uint8_t offset)
|
||||||
|
{
|
||||||
|
static char buffer[sizeof ("18446744073709551615")];
|
||||||
|
|
||||||
|
grub_uint64_t value = grub_get_unaligned64 (structure + offset);
|
||||||
|
grub_snprintf (buffer, sizeof (buffer), "%" PRIuGRUB_UINT64_T, value);
|
||||||
|
|
||||||
|
return (const char *)buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
grub_smbios_get_string (const grub_uint8_t *structure, grub_uint8_t offset)
|
||||||
|
{
|
||||||
|
const grub_uint8_t *ptr = structure + structure[1];
|
||||||
|
const grub_uint8_t *table_end = (const grub_uint8_t *)table_desc.end;
|
||||||
|
const grub_uint8_t referenced_string_number = structure[offset];
|
||||||
|
grub_uint8_t i;
|
||||||
|
|
||||||
|
/* A string referenced with zero is interpreted as unset. */
|
||||||
|
if (referenced_string_number == 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* Search the string set. */
|
||||||
|
for (i = 1; *ptr != 0 && ptr < table_end; i++)
|
||||||
|
if (i == referenced_string_number)
|
||||||
|
{
|
||||||
|
const char *str = (const char *)ptr;
|
||||||
|
while (*ptr++ != 0)
|
||||||
|
if (ptr >= table_end)
|
||||||
|
return NULL; /* The string isn't terminated. */
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
while (*ptr++ != 0 && ptr < table_end);
|
||||||
|
|
||||||
|
/* The string number is greater than the number of strings in the set. */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
grub_smbios_format_uuid (const grub_uint8_t *structure, grub_uint8_t offset)
|
||||||
|
{
|
||||||
|
static char buffer[sizeof ("ffffffff-ffff-ffff-ffff-ffffffffffff")];
|
||||||
|
const grub_uint8_t *f = structure + offset; /* little-endian fields */
|
||||||
|
const grub_uint8_t *g = f + 8; /* byte-by-byte fields */
|
||||||
|
|
||||||
|
grub_snprintf (buffer, sizeof (buffer),
|
||||||
|
"%02x%02x%02x%02x-%02x%02x-%02x%02x-"
|
||||||
|
"%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||||
|
f[3], f[2], f[1], f[0], f[5], f[4], f[7], f[6],
|
||||||
|
g[0], g[1], g[2], g[3], g[4], g[5], g[6], g[7]);
|
||||||
|
|
||||||
|
return (const char *)buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* List the field formatting functions and the number of bytes they need. */
|
||||||
|
static const struct {
|
||||||
|
const char *(*format) (const grub_uint8_t *structure, grub_uint8_t offset);
|
||||||
|
grub_uint8_t field_length;
|
||||||
|
} field_extractors[] = {
|
||||||
|
{grub_smbios_format_byte, 1},
|
||||||
|
{grub_smbios_format_word, 2},
|
||||||
|
{grub_smbios_format_dword, 4},
|
||||||
|
{grub_smbios_format_qword, 8},
|
||||||
|
{grub_smbios_get_string, 1},
|
||||||
|
{grub_smbios_format_uuid, 16}
|
||||||
|
};
|
||||||
|
|
||||||
|
/* List command options, with structure field getters ordered as above. */
|
||||||
|
#define FIRST_GETTER_OPT (3)
|
||||||
|
#define SETTER_OPT (FIRST_GETTER_OPT + ARRAY_SIZE(field_extractors))
|
||||||
|
#define LINUX_OPT (FIRST_GETTER_OPT + ARRAY_SIZE(field_extractors) + 1)
|
||||||
|
|
||||||
|
static const struct grub_arg_option options[] = {
|
||||||
|
{"type", 't', 0, N_("Match structures with the given type."),
|
||||||
|
N_("type"), ARG_TYPE_INT},
|
||||||
|
{"handle", 'h', 0, N_("Match structures with the given handle."),
|
||||||
|
N_("handle"), ARG_TYPE_INT},
|
||||||
|
{"match", 'm', 0, N_("Select a structure when several match."),
|
||||||
|
N_("match"), ARG_TYPE_INT},
|
||||||
|
{"get-byte", 'b', 0, N_("Get the byte's value at the given offset."),
|
||||||
|
N_("offset"), ARG_TYPE_INT},
|
||||||
|
{"get-word", 'w', 0, N_("Get two bytes' value at the given offset."),
|
||||||
|
N_("offset"), ARG_TYPE_INT},
|
||||||
|
{"get-dword", 'd', 0, N_("Get four bytes' value at the given offset."),
|
||||||
|
N_("offset"), ARG_TYPE_INT},
|
||||||
|
{"get-qword", 'q', 0, N_("Get eight bytes' value at the given offset."),
|
||||||
|
N_("offset"), ARG_TYPE_INT},
|
||||||
|
{"get-string", 's', 0, N_("Get the string specified at the given offset."),
|
||||||
|
N_("offset"), ARG_TYPE_INT},
|
||||||
|
{"get-uuid", 'u', 0, N_("Get the UUID's value at the given offset."),
|
||||||
|
N_("offset"), ARG_TYPE_INT},
|
||||||
|
{"set", '\0', 0, N_("Store the value in the given variable name."),
|
||||||
|
N_("variable"), ARG_TYPE_STRING},
|
||||||
|
{"linux", '\0', 0, N_("Filter the result like linux does."),
|
||||||
|
N_("variable"), ARG_TYPE_NONE},
|
||||||
|
{0, 0, 0, 0, 0, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return a matching SMBIOS structure.
|
||||||
|
*
|
||||||
|
* This method can use up to three criteria for selecting a structure:
|
||||||
|
* - The "type" field (use -1 to ignore)
|
||||||
|
* - The "handle" field (use -1 to ignore)
|
||||||
|
* - Which to return if several match (use 0 to ignore)
|
||||||
|
*
|
||||||
|
* The return value is a pointer to the first matching structure. If no
|
||||||
|
* structures match the given parameters, NULL is returned.
|
||||||
|
*/
|
||||||
|
static const grub_uint8_t *
|
||||||
|
grub_smbios_match_structure (const grub_int16_t type,
|
||||||
|
const grub_int32_t handle,
|
||||||
|
const grub_uint16_t match)
|
||||||
|
{
|
||||||
|
const grub_uint8_t *ptr = (const grub_uint8_t *)table_desc.start;
|
||||||
|
const grub_uint8_t *table_end = (const grub_uint8_t *)table_desc.end;
|
||||||
|
grub_uint16_t structures = table_desc.structures;
|
||||||
|
grub_uint16_t structure_count = 0;
|
||||||
|
grub_uint16_t matches = 0;
|
||||||
|
|
||||||
|
while (ptr < table_end
|
||||||
|
&& ptr[1] >= 4 /* Valid structures include the 4-byte header. */
|
||||||
|
&& (structure_count++ < structures || structures == 0))
|
||||||
|
{
|
||||||
|
grub_uint16_t structure_handle = grub_get_unaligned16 (ptr + 2);
|
||||||
|
grub_uint8_t structure_type = ptr[0];
|
||||||
|
|
||||||
|
if ((handle < 0 || handle == structure_handle)
|
||||||
|
&& (type < 0 || type == structure_type)
|
||||||
|
&& (match == 0 || match == ++matches))
|
||||||
|
return ptr;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ptr += ptr[1];
|
||||||
|
while ((*ptr++ != 0 || *ptr++ != 0) && ptr < table_end);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (structure_type == GRUB_SMBIOS_TYPE_END_OF_TABLE)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_cmd_smbios (grub_extcmd_context_t ctxt,
|
||||||
|
int argc __attribute__ ((unused)),
|
||||||
|
char **argv __attribute__ ((unused)))
|
||||||
|
{
|
||||||
|
struct grub_arg_list *state = ctxt->state;
|
||||||
|
|
||||||
|
grub_int16_t type = -1;
|
||||||
|
grub_int32_t handle = -1;
|
||||||
|
grub_uint16_t match = 0;
|
||||||
|
grub_uint8_t offset = 0;
|
||||||
|
|
||||||
|
const grub_uint8_t *structure;
|
||||||
|
const char *value;
|
||||||
|
char *modified_value = NULL;
|
||||||
|
grub_int32_t option;
|
||||||
|
grub_int8_t field_type = -1;
|
||||||
|
grub_uint8_t i;
|
||||||
|
|
||||||
|
if (table_desc.start == 0)
|
||||||
|
return grub_error (GRUB_ERR_IO,
|
||||||
|
N_("the SMBIOS entry point structure was not found"));
|
||||||
|
|
||||||
|
/* Read the given filtering options. */
|
||||||
|
if (state[0].set)
|
||||||
|
{
|
||||||
|
option = grub_strtol (state[0].arg, NULL, 0);
|
||||||
|
if (option < 0 || option > 255)
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||||
|
N_("the type must be between 0 and 255"));
|
||||||
|
type = (grub_int16_t)option;
|
||||||
|
}
|
||||||
|
if (state[1].set)
|
||||||
|
{
|
||||||
|
option = grub_strtol (state[1].arg, NULL, 0);
|
||||||
|
if (option < 0 || option > 65535)
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||||
|
N_("the handle must be between 0 and 65535"));
|
||||||
|
handle = (grub_int32_t)option;
|
||||||
|
}
|
||||||
|
if (state[2].set)
|
||||||
|
{
|
||||||
|
option = grub_strtol (state[2].arg, NULL, 0);
|
||||||
|
if (option <= 0 || option > 65535)
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||||
|
N_("the match must be a positive integer"));
|
||||||
|
match = (grub_uint16_t)option;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Determine the data type of the structure field to retrieve. */
|
||||||
|
for (i = 0; i < ARRAY_SIZE(field_extractors); i++)
|
||||||
|
if (state[FIRST_GETTER_OPT + i].set)
|
||||||
|
{
|
||||||
|
if (field_type >= 0)
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||||
|
N_("only one --get option is usable at a time"));
|
||||||
|
field_type = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Require a choice of a structure field to return. */
|
||||||
|
if (field_type < 0)
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||||
|
N_("one of the --get options is required"));
|
||||||
|
|
||||||
|
/* Locate a matching SMBIOS structure. */
|
||||||
|
structure = grub_smbios_match_structure (type, handle, match);
|
||||||
|
if (structure == NULL)
|
||||||
|
return grub_error (GRUB_ERR_IO,
|
||||||
|
N_("no structure matched the given options"));
|
||||||
|
|
||||||
|
/* Ensure the requested byte offset is inside the structure. */
|
||||||
|
option = grub_strtol (state[FIRST_GETTER_OPT + field_type].arg, NULL, 0);
|
||||||
|
if (option < 0 || option >= structure[1])
|
||||||
|
return grub_error (GRUB_ERR_OUT_OF_RANGE,
|
||||||
|
N_("the given offset is outside the structure"));
|
||||||
|
|
||||||
|
/* Ensure the requested data type at the offset is inside the structure. */
|
||||||
|
offset = (grub_uint8_t)option;
|
||||||
|
if (offset + field_extractors[field_type].field_length > structure[1])
|
||||||
|
return grub_error (GRUB_ERR_OUT_OF_RANGE,
|
||||||
|
N_("the field ends outside the structure"));
|
||||||
|
|
||||||
|
/* Format the requested structure field into a readable string. */
|
||||||
|
value = field_extractors[field_type].format (structure, offset);
|
||||||
|
if (value == NULL)
|
||||||
|
return grub_error (GRUB_ERR_IO,
|
||||||
|
N_("failed to retrieve the structure field"));
|
||||||
|
|
||||||
|
if (state[LINUX_OPT].set)
|
||||||
|
value = modified_value = linux_string (value);
|
||||||
|
|
||||||
|
/* Store or print the formatted value. */
|
||||||
|
if (state[SETTER_OPT].set)
|
||||||
|
grub_env_set (state[SETTER_OPT].arg, value);
|
||||||
|
else
|
||||||
|
grub_printf ("%s\n", value);
|
||||||
|
|
||||||
|
grub_free(modified_value);
|
||||||
|
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
GRUB_MOD_INIT(smbios)
|
||||||
|
{
|
||||||
|
struct grub_smbios_eps3 *eps3;
|
||||||
|
struct grub_smbios_eps *eps;
|
||||||
|
|
||||||
|
if ((eps3 = grub_smbios_get_eps3 ()))
|
||||||
|
{
|
||||||
|
table_desc.start = (grub_addr_t)eps3->table_address;
|
||||||
|
table_desc.end = table_desc.start + eps3->maximum_table_length;
|
||||||
|
table_desc.structures = 0; /* SMBIOS3 drops the structure count. */
|
||||||
|
}
|
||||||
|
else if ((eps = grub_smbios_get_eps ()))
|
||||||
|
{
|
||||||
|
table_desc.start = (grub_addr_t)eps->intermediate.table_address;
|
||||||
|
table_desc.end = table_desc.start + eps->intermediate.table_length;
|
||||||
|
table_desc.structures = eps->intermediate.structures;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd = grub_register_extcmd ("smbios", grub_cmd_smbios, 0,
|
||||||
|
N_("[-t type] [-h handle] [-m match] "
|
||||||
|
"(-b|-w|-d|-q|-s|-u) offset "
|
||||||
|
"[--set variable]"),
|
||||||
|
N_("Retrieve SMBIOS information."), options);
|
||||||
|
}
|
||||||
|
|
||||||
|
GRUB_MOD_FINI(smbios)
|
||||||
|
{
|
||||||
|
grub_unregister_extcmd (cmd);
|
||||||
|
}
|
||||||
|
|
@@ -426,7 +426,7 @@ grub_fshelp_read_file (grub_disk_t disk, grub_fshelp_node_t node,
|
|||||||
if (grub_errno)
|
if (grub_errno)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else if (read_hook != (grub_disk_read_hook_t)grub_disk_blocklist_read)
|
else if (read_hook != (grub_disk_read_hook_t)(void *)grub_disk_blocklist_read)
|
||||||
grub_memset (buf, 0, blockend);
|
grub_memset (buf, 0, blockend);
|
||||||
|
|
||||||
buf += blocksize - skipfirst;
|
buf += blocksize - skipfirst;
|
||||||
|
@@ -995,19 +995,8 @@ grub_ntfs_dir_iter (const char *filename, enum grub_fshelp_filetype filetype,
|
|||||||
info.mtime = grub_divmod64 (node->mtime, 10000000, 0)
|
info.mtime = grub_divmod64 (node->mtime, 10000000, 0)
|
||||||
- 86400ULL * 365 * (1970 - 1601)
|
- 86400ULL * 365 * (1970 - 1601)
|
||||||
- 86400ULL * ((1970 - 1601) / 4) + 86400ULL * ((1970 - 1601) / 100);
|
- 86400ULL * ((1970 - 1601) / 4) + 86400ULL * ((1970 - 1601) / 100);
|
||||||
|
|
||||||
if (!info.dir)
|
if (!info.dir)
|
||||||
{
|
info.size = node->size;
|
||||||
struct grub_ntfs_file *mft = (struct grub_ntfs_file *)node;
|
|
||||||
info.size = mft->size;
|
|
||||||
if (!mft->inode_read)
|
|
||||||
{
|
|
||||||
init_file(mft, mft->ino);
|
|
||||||
info.size = mft->size;
|
|
||||||
free_file(mft);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
grub_free (node);
|
grub_free (node);
|
||||||
return ctx->hook (filename, &info, ctx->hook_data);
|
return ctx->hook (filename, &info, ctx->hook_data);
|
||||||
}
|
}
|
||||||
|
@@ -119,6 +119,8 @@ grub_gfxmenu_try (int entry, grub_menu_t menu, int nested)
|
|||||||
view->menu = menu;
|
view->menu = menu;
|
||||||
view->nested = nested;
|
view->nested = nested;
|
||||||
view->first_timeout = -1;
|
view->first_timeout = -1;
|
||||||
|
if (menu->size)
|
||||||
|
view->menu_title_offset = grub_zalloc (sizeof (*view->menu_title_offset) * menu->size);
|
||||||
|
|
||||||
grub_video_set_viewport (0, 0, mode_info.width, mode_info.height);
|
grub_video_set_viewport (0, 0, mode_info.width, mode_info.height);
|
||||||
if (view->double_repaint)
|
if (view->double_repaint)
|
||||||
@@ -134,6 +136,8 @@ grub_gfxmenu_try (int entry, grub_menu_t menu, int nested)
|
|||||||
instance->fini = grub_gfxmenu_viewer_fini;
|
instance->fini = grub_gfxmenu_viewer_fini;
|
||||||
instance->print_timeout = grub_gfxmenu_print_timeout;
|
instance->print_timeout = grub_gfxmenu_print_timeout;
|
||||||
instance->clear_timeout = grub_gfxmenu_clear_timeout;
|
instance->clear_timeout = grub_gfxmenu_clear_timeout;
|
||||||
|
if (view->menu_title_offset)
|
||||||
|
instance->scroll_chosen_entry = grub_gfxmenu_scroll_chosen_entry;
|
||||||
|
|
||||||
grub_menu_register_viewer (instance);
|
grub_menu_register_viewer (instance);
|
||||||
|
|
||||||
|
961
GRUB2/MOD_SRC/grub-2.04/grub-core/gfxmenu/gui_list.c
Normal file
961
GRUB2/MOD_SRC/grub-2.04/grub-core/gfxmenu/gui_list.c
Normal file
@@ -0,0 +1,961 @@
|
|||||||
|
/* gui_list.c - GUI component to display a selectable list of items. */
|
||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2008,2009 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* GRUB is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* GRUB is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <grub/mm.h>
|
||||||
|
#include <grub/misc.h>
|
||||||
|
#include <grub/gui.h>
|
||||||
|
#include <grub/gui_string_util.h>
|
||||||
|
#include <grub/gfxmenu_view.h>
|
||||||
|
#include <grub/gfxwidgets.h>
|
||||||
|
#include <grub/color.h>
|
||||||
|
#include <grub/charset.h>
|
||||||
|
|
||||||
|
enum scrollbar_slice_mode {
|
||||||
|
SCROLLBAR_SLICE_WEST,
|
||||||
|
SCROLLBAR_SLICE_CENTER,
|
||||||
|
SCROLLBAR_SLICE_EAST
|
||||||
|
};
|
||||||
|
|
||||||
|
struct grub_gui_list_impl
|
||||||
|
{
|
||||||
|
struct grub_gui_list list;
|
||||||
|
|
||||||
|
grub_gui_container_t parent;
|
||||||
|
grub_video_rect_t bounds;
|
||||||
|
char *id;
|
||||||
|
int visible;
|
||||||
|
|
||||||
|
int icon_width;
|
||||||
|
int icon_height;
|
||||||
|
int item_height;
|
||||||
|
int item_padding;
|
||||||
|
int item_icon_space;
|
||||||
|
int item_spacing;
|
||||||
|
grub_font_t item_font;
|
||||||
|
int selected_item_font_inherit;
|
||||||
|
grub_font_t selected_item_font;
|
||||||
|
grub_video_rgba_color_t item_color;
|
||||||
|
int selected_item_color_inherit;
|
||||||
|
grub_video_rgba_color_t selected_item_color;
|
||||||
|
|
||||||
|
int draw_scrollbar;
|
||||||
|
int need_to_recreate_scrollbar;
|
||||||
|
char *scrollbar_frame_pattern;
|
||||||
|
char *scrollbar_thumb_pattern;
|
||||||
|
grub_gfxmenu_box_t scrollbar_frame;
|
||||||
|
grub_gfxmenu_box_t scrollbar_thumb;
|
||||||
|
int scrollbar_thumb_overlay;
|
||||||
|
int scrollbar_width;
|
||||||
|
enum scrollbar_slice_mode scrollbar_slice;
|
||||||
|
int scrollbar_left_pad;
|
||||||
|
int scrollbar_right_pad;
|
||||||
|
int scrollbar_top_pad;
|
||||||
|
int scrollbar_bottom_pad;
|
||||||
|
|
||||||
|
int first_shown_index;
|
||||||
|
|
||||||
|
int need_to_recreate_boxes;
|
||||||
|
char *theme_dir;
|
||||||
|
char *menu_box_pattern;
|
||||||
|
char *item_box_pattern;
|
||||||
|
int selected_item_box_pattern_inherit;
|
||||||
|
char *selected_item_box_pattern;
|
||||||
|
grub_gfxmenu_box_t menu_box;
|
||||||
|
grub_gfxmenu_box_t selected_item_box;
|
||||||
|
grub_gfxmenu_box_t item_box;
|
||||||
|
|
||||||
|
grub_gfxmenu_icon_manager_t icon_manager;
|
||||||
|
|
||||||
|
grub_gfxmenu_view_t view;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct grub_gui_list_impl *list_impl_t;
|
||||||
|
|
||||||
|
static void
|
||||||
|
list_destroy (void *vself)
|
||||||
|
{
|
||||||
|
list_impl_t self = vself;
|
||||||
|
|
||||||
|
grub_free (self->theme_dir);
|
||||||
|
grub_free (self->menu_box_pattern);
|
||||||
|
grub_free (self->item_box_pattern);
|
||||||
|
grub_free (self->selected_item_box_pattern);
|
||||||
|
if (self->menu_box)
|
||||||
|
self->menu_box->destroy (self->menu_box);
|
||||||
|
if (self->item_box)
|
||||||
|
self->item_box->destroy (self->item_box);
|
||||||
|
if (self->selected_item_box)
|
||||||
|
self->selected_item_box->destroy (self->selected_item_box);
|
||||||
|
if (self->icon_manager)
|
||||||
|
grub_gfxmenu_icon_manager_destroy (self->icon_manager);
|
||||||
|
if (self->scrollbar_thumb)
|
||||||
|
self->scrollbar_thumb->destroy (self->scrollbar_thumb);
|
||||||
|
if (self->scrollbar_frame)
|
||||||
|
self->scrollbar_frame->destroy (self->scrollbar_frame);
|
||||||
|
grub_free (self->scrollbar_thumb_pattern);
|
||||||
|
grub_free (self->scrollbar_frame_pattern);
|
||||||
|
grub_free (self);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
get_num_shown_items (list_impl_t self)
|
||||||
|
{
|
||||||
|
int boxpad = self->item_padding;
|
||||||
|
int item_vspace = self->item_spacing;
|
||||||
|
int item_height = self->item_height;
|
||||||
|
|
||||||
|
grub_gfxmenu_box_t box = self->menu_box;
|
||||||
|
int box_top_pad = box->get_top_pad (box);
|
||||||
|
int box_bottom_pad = box->get_bottom_pad (box);
|
||||||
|
grub_gfxmenu_box_t itembox = self->item_box;
|
||||||
|
grub_gfxmenu_box_t selbox = self->selected_item_box;
|
||||||
|
int item_top_pad = itembox->get_top_pad (itembox);
|
||||||
|
int item_bottom_pad = itembox->get_bottom_pad (itembox);
|
||||||
|
int sel_top_pad = selbox->get_top_pad (selbox);
|
||||||
|
int sel_bottom_pad = selbox->get_bottom_pad (selbox);
|
||||||
|
int max_top_pad = grub_max (item_top_pad, sel_top_pad);
|
||||||
|
int max_bottom_pad = grub_max (item_bottom_pad, sel_bottom_pad);
|
||||||
|
|
||||||
|
if (item_height + item_vspace <= 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return (self->bounds.height + item_vspace - 2 * boxpad
|
||||||
|
- max_top_pad - max_bottom_pad
|
||||||
|
- box_top_pad - box_bottom_pad) / (item_height + item_vspace);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
check_boxes (list_impl_t self)
|
||||||
|
{
|
||||||
|
if (self->need_to_recreate_boxes)
|
||||||
|
{
|
||||||
|
grub_gui_recreate_box (&self->menu_box,
|
||||||
|
self->menu_box_pattern,
|
||||||
|
self->theme_dir);
|
||||||
|
|
||||||
|
grub_gui_recreate_box (&self->item_box,
|
||||||
|
self->item_box_pattern,
|
||||||
|
self->theme_dir);
|
||||||
|
|
||||||
|
grub_gui_recreate_box (&self->selected_item_box,
|
||||||
|
self->selected_item_box_pattern,
|
||||||
|
self->theme_dir);
|
||||||
|
|
||||||
|
self->need_to_recreate_boxes = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (self->menu_box != 0 && self->selected_item_box != 0
|
||||||
|
&& self->item_box != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
check_scrollbar (list_impl_t self)
|
||||||
|
{
|
||||||
|
if (self->need_to_recreate_scrollbar)
|
||||||
|
{
|
||||||
|
grub_gui_recreate_box (&self->scrollbar_frame,
|
||||||
|
self->scrollbar_frame_pattern,
|
||||||
|
self->theme_dir);
|
||||||
|
|
||||||
|
grub_gui_recreate_box (&self->scrollbar_thumb,
|
||||||
|
self->scrollbar_thumb_pattern,
|
||||||
|
self->theme_dir);
|
||||||
|
|
||||||
|
self->need_to_recreate_scrollbar = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self->scrollbar_frame == 0 || self->scrollbar_thumb == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Sanity checks. */
|
||||||
|
grub_gfxmenu_box_t frame = self->scrollbar_frame;
|
||||||
|
grub_gfxmenu_box_t thumb = self->scrollbar_thumb;
|
||||||
|
grub_gfxmenu_box_t menu = self->menu_box;
|
||||||
|
int min_width = frame->get_left_pad (frame)
|
||||||
|
+ frame->get_right_pad (frame);
|
||||||
|
int min_height = frame->get_top_pad (frame)
|
||||||
|
+ frame->get_bottom_pad (frame)
|
||||||
|
+ self->scrollbar_top_pad + self->scrollbar_bottom_pad
|
||||||
|
+ menu->get_top_pad (menu)
|
||||||
|
+ menu->get_bottom_pad (menu);
|
||||||
|
if (!self->scrollbar_thumb_overlay)
|
||||||
|
{
|
||||||
|
min_width += thumb->get_left_pad (thumb)
|
||||||
|
+ thumb->get_right_pad (thumb);
|
||||||
|
min_height += thumb->get_top_pad (thumb)
|
||||||
|
+ thumb->get_bottom_pad (thumb);
|
||||||
|
}
|
||||||
|
if (min_width <= self->scrollbar_width
|
||||||
|
&& min_height <= (int) self->bounds.height)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* Unprintable dimenstions. */
|
||||||
|
self->draw_scrollbar = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
list_get_id (void *vself)
|
||||||
|
{
|
||||||
|
list_impl_t self = vself;
|
||||||
|
return self->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
list_is_instance (void *vself __attribute__((unused)), const char *type)
|
||||||
|
{
|
||||||
|
return (grub_strcmp (type, "component") == 0
|
||||||
|
|| grub_strcmp (type, "list") == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct grub_video_bitmap *
|
||||||
|
get_item_icon (list_impl_t self, int item_index)
|
||||||
|
{
|
||||||
|
grub_menu_entry_t entry;
|
||||||
|
entry = grub_menu_get_entry (self->view->menu, item_index);
|
||||||
|
if (! entry)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return grub_gfxmenu_icon_manager_get_icon (self->icon_manager, entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
make_selected_item_visible (list_impl_t self)
|
||||||
|
{
|
||||||
|
int selected_index = self->view->selected;
|
||||||
|
if (selected_index < 0)
|
||||||
|
return; /* No item is selected. */
|
||||||
|
int num_shown_items = get_num_shown_items (self);
|
||||||
|
int last_shown_index = self->first_shown_index + (num_shown_items - 1);
|
||||||
|
if (selected_index < self->first_shown_index)
|
||||||
|
self->first_shown_index = selected_index;
|
||||||
|
else if (selected_index > last_shown_index)
|
||||||
|
self->first_shown_index = selected_index - (num_shown_items - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Draw a scrollbar on the menu. */
|
||||||
|
static void
|
||||||
|
draw_scrollbar (list_impl_t self,
|
||||||
|
int value, int extent, int min, int max,
|
||||||
|
int scrollbar_width, int scrollbar_height)
|
||||||
|
{
|
||||||
|
unsigned thumby, thumbheight;
|
||||||
|
|
||||||
|
grub_gfxmenu_box_t frame = self->scrollbar_frame;
|
||||||
|
grub_gfxmenu_box_t thumb = self->scrollbar_thumb;
|
||||||
|
int frame_vertical_pad = (frame->get_top_pad (frame)
|
||||||
|
+ frame->get_bottom_pad (frame));
|
||||||
|
int frame_horizontal_pad = (frame->get_left_pad (frame)
|
||||||
|
+ frame->get_right_pad (frame));
|
||||||
|
unsigned thumb_vertical_pad = (thumb->get_top_pad (thumb)
|
||||||
|
+ thumb->get_bottom_pad (thumb));
|
||||||
|
int thumb_horizontal_pad = (thumb->get_left_pad (thumb)
|
||||||
|
+ thumb->get_right_pad (thumb));
|
||||||
|
int tracktop = frame->get_top_pad (frame);
|
||||||
|
unsigned tracklen;
|
||||||
|
if (scrollbar_height <= frame_vertical_pad)
|
||||||
|
tracklen = 0;
|
||||||
|
else
|
||||||
|
tracklen = scrollbar_height - frame_vertical_pad;
|
||||||
|
frame->set_content_size (frame,
|
||||||
|
scrollbar_width - frame_horizontal_pad,
|
||||||
|
tracklen);
|
||||||
|
if (self->scrollbar_thumb_overlay)
|
||||||
|
{
|
||||||
|
tracklen += thumb_vertical_pad;
|
||||||
|
tracktop -= thumb->get_top_pad (thumb);
|
||||||
|
}
|
||||||
|
if (value <= min || max <= min)
|
||||||
|
thumby = 0;
|
||||||
|
else
|
||||||
|
thumby = ((unsigned) tracklen * (value - min))
|
||||||
|
/ ((unsigned) (max - min));
|
||||||
|
if (max <= min)
|
||||||
|
thumbheight = 1;
|
||||||
|
else
|
||||||
|
thumbheight = ((unsigned) (tracklen * extent)
|
||||||
|
/ ((unsigned) (max - min))) + 1;
|
||||||
|
/* Rare occasion: too many entries or too low height. */
|
||||||
|
if (thumbheight < thumb_vertical_pad)
|
||||||
|
{
|
||||||
|
thumbheight = thumb_vertical_pad;
|
||||||
|
if (value <= min || max <= extent
|
||||||
|
|| tracklen <= thumb_vertical_pad)
|
||||||
|
thumby = 0;
|
||||||
|
else
|
||||||
|
thumby = ((unsigned) ((tracklen - thumb_vertical_pad) * (value - min))
|
||||||
|
/ ((unsigned)(max - extent)));
|
||||||
|
}
|
||||||
|
thumby += tracktop;
|
||||||
|
int thumbx = frame->get_left_pad (frame);
|
||||||
|
int thumbwidth = scrollbar_width - frame_horizontal_pad;
|
||||||
|
if (!self->scrollbar_thumb_overlay)
|
||||||
|
thumbwidth -= thumb_horizontal_pad;
|
||||||
|
else
|
||||||
|
thumbx -= thumb->get_left_pad (thumb);
|
||||||
|
thumb->set_content_size (thumb, thumbwidth,
|
||||||
|
thumbheight - thumb_vertical_pad);
|
||||||
|
frame->draw (frame, 0, 0);
|
||||||
|
thumb->draw (thumb, thumbx, thumby);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Draw the list of items. */
|
||||||
|
static void
|
||||||
|
draw_menu (list_impl_t self, int num_shown_items)
|
||||||
|
{
|
||||||
|
if (! self->menu_box || ! self->selected_item_box || ! self->item_box)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int boxpad = self->item_padding;
|
||||||
|
int icon_text_space = self->item_icon_space;
|
||||||
|
int item_vspace = self->item_spacing;
|
||||||
|
|
||||||
|
int ascent = grub_font_get_ascent (self->item_font);
|
||||||
|
int descent = grub_font_get_descent (self->item_font);
|
||||||
|
int selected_ascent = grub_font_get_ascent (self->selected_item_font);
|
||||||
|
int selected_descent = grub_font_get_descent (self->selected_item_font);
|
||||||
|
int text_box_height = self->item_height;
|
||||||
|
|
||||||
|
make_selected_item_visible (self);
|
||||||
|
|
||||||
|
grub_gfxmenu_box_t itembox = self->item_box;
|
||||||
|
grub_gfxmenu_box_t selbox = self->selected_item_box;
|
||||||
|
int item_leftpad = itembox->get_left_pad (itembox);
|
||||||
|
int item_rightpad = itembox->get_right_pad (itembox);
|
||||||
|
int item_border_width = item_leftpad + item_rightpad;
|
||||||
|
int item_toppad = itembox->get_top_pad (itembox);
|
||||||
|
int sel_leftpad = selbox->get_left_pad (selbox);
|
||||||
|
int sel_rightpad = selbox->get_right_pad (selbox);
|
||||||
|
int sel_border_width = sel_leftpad + sel_rightpad;
|
||||||
|
int sel_toppad = selbox->get_top_pad (selbox);
|
||||||
|
|
||||||
|
int max_leftpad = grub_max (item_leftpad, sel_leftpad);
|
||||||
|
int max_toppad = grub_max (item_toppad, sel_toppad);
|
||||||
|
int item_top = 0;
|
||||||
|
int menu_index;
|
||||||
|
int visible_index;
|
||||||
|
struct grub_video_rect oviewport;
|
||||||
|
|
||||||
|
grub_video_get_viewport (&oviewport.x, &oviewport.y,
|
||||||
|
&oviewport.width, &oviewport.height);
|
||||||
|
grub_video_set_viewport (oviewport.x + boxpad,
|
||||||
|
oviewport.y + boxpad,
|
||||||
|
oviewport.width - 2 * boxpad,
|
||||||
|
oviewport.height - 2 * boxpad);
|
||||||
|
|
||||||
|
int cwidth = oviewport.width - 2 * boxpad;
|
||||||
|
|
||||||
|
itembox->set_content_size (itembox, cwidth - item_border_width,
|
||||||
|
text_box_height);
|
||||||
|
selbox->set_content_size (selbox, cwidth - sel_border_width,
|
||||||
|
text_box_height);
|
||||||
|
|
||||||
|
int text_left_offset = self->icon_width + icon_text_space;
|
||||||
|
int item_text_top_offset = (text_box_height - (ascent + descent)) / 2 + ascent;
|
||||||
|
int sel_text_top_offset = (text_box_height - (selected_ascent
|
||||||
|
+ selected_descent)) / 2
|
||||||
|
+ selected_ascent;
|
||||||
|
|
||||||
|
grub_video_rect_t svpsave, sviewport;
|
||||||
|
sviewport.x = max_leftpad + text_left_offset;
|
||||||
|
int text_viewport_width = cwidth - sviewport.x;
|
||||||
|
sviewport.height = text_box_height;
|
||||||
|
|
||||||
|
grub_video_color_t item_color;
|
||||||
|
grub_video_color_t sel_color;
|
||||||
|
item_color = grub_video_map_rgba_color (self->item_color);
|
||||||
|
sel_color = grub_video_map_rgba_color (self->selected_item_color);
|
||||||
|
|
||||||
|
int item_box_top_offset = max_toppad - item_toppad;
|
||||||
|
int sel_box_top_offset = max_toppad - sel_toppad;
|
||||||
|
int item_viewport_width = text_viewport_width - item_rightpad;
|
||||||
|
int sel_viewport_width = text_viewport_width - sel_rightpad;
|
||||||
|
int tmp_icon_top_offset = (text_box_height - self->icon_height) / 2;
|
||||||
|
int item_icon_top_offset = item_toppad + tmp_icon_top_offset;
|
||||||
|
int sel_icon_top_offset = sel_toppad + tmp_icon_top_offset;
|
||||||
|
|
||||||
|
for (visible_index = 0, menu_index = self->first_shown_index;
|
||||||
|
visible_index < num_shown_items && menu_index < self->view->menu->size;
|
||||||
|
visible_index++, menu_index++)
|
||||||
|
{
|
||||||
|
int is_selected = (menu_index == self->view->selected);
|
||||||
|
struct grub_video_bitmap *icon;
|
||||||
|
grub_font_t font;
|
||||||
|
grub_video_color_t color;
|
||||||
|
int text_top_offset;
|
||||||
|
int top_pad;
|
||||||
|
int icon_top_offset;
|
||||||
|
int viewport_width;
|
||||||
|
|
||||||
|
if (is_selected)
|
||||||
|
{
|
||||||
|
selbox->draw (selbox, 0, item_top + sel_box_top_offset);
|
||||||
|
font = self->selected_item_font;
|
||||||
|
color = sel_color;
|
||||||
|
text_top_offset = sel_text_top_offset;
|
||||||
|
top_pad = sel_toppad;
|
||||||
|
icon_top_offset = sel_icon_top_offset;
|
||||||
|
viewport_width = sel_viewport_width;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itembox->draw (itembox, 0, item_top + item_box_top_offset);
|
||||||
|
font = self->item_font;
|
||||||
|
color = item_color;
|
||||||
|
text_top_offset = item_text_top_offset;
|
||||||
|
top_pad = item_toppad;
|
||||||
|
icon_top_offset = item_icon_top_offset;
|
||||||
|
viewport_width = item_viewport_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
icon = get_item_icon (self, menu_index);
|
||||||
|
if (icon != 0)
|
||||||
|
grub_video_blit_bitmap (icon, GRUB_VIDEO_BLIT_BLEND,
|
||||||
|
max_leftpad,
|
||||||
|
item_top + icon_top_offset,
|
||||||
|
0, 0, self->icon_width, self->icon_height);
|
||||||
|
|
||||||
|
const char *item_title =
|
||||||
|
grub_menu_get_entry (self->view->menu, menu_index)->title;
|
||||||
|
|
||||||
|
|
||||||
|
int off = self->view->menu_title_offset[menu_index];
|
||||||
|
const char *scrolled_title =
|
||||||
|
grub_utf8_offset_code (item_title, grub_strlen (item_title), off);
|
||||||
|
if (scrolled_title)
|
||||||
|
item_title = scrolled_title;
|
||||||
|
|
||||||
|
sviewport.y = item_top + top_pad;
|
||||||
|
sviewport.width = viewport_width;
|
||||||
|
grub_gui_set_viewport (&sviewport, &svpsave);
|
||||||
|
grub_font_draw_string (item_title,
|
||||||
|
font,
|
||||||
|
color,
|
||||||
|
0,
|
||||||
|
text_top_offset);
|
||||||
|
grub_gui_restore_viewport (&svpsave);
|
||||||
|
|
||||||
|
item_top += text_box_height + item_vspace;
|
||||||
|
}
|
||||||
|
grub_video_set_viewport (oviewport.x,
|
||||||
|
oviewport.y,
|
||||||
|
oviewport.width,
|
||||||
|
oviewport.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
list_paint (void *vself, const grub_video_rect_t *region)
|
||||||
|
{
|
||||||
|
list_impl_t self = vself;
|
||||||
|
grub_video_rect_t vpsave;
|
||||||
|
|
||||||
|
if (! self->visible)
|
||||||
|
return;
|
||||||
|
if (!grub_video_have_common_points (region, &self->bounds))
|
||||||
|
return;
|
||||||
|
|
||||||
|
check_boxes (self);
|
||||||
|
|
||||||
|
if (! self->menu_box || ! self->selected_item_box || ! self->item_box)
|
||||||
|
return;
|
||||||
|
|
||||||
|
grub_gui_set_viewport (&self->bounds, &vpsave);
|
||||||
|
{
|
||||||
|
grub_gfxmenu_box_t box = self->menu_box;
|
||||||
|
int box_left_pad = box->get_left_pad (box);
|
||||||
|
int box_top_pad = box->get_top_pad (box);
|
||||||
|
int box_right_pad = box->get_right_pad (box);
|
||||||
|
int box_bottom_pad = box->get_bottom_pad (box);
|
||||||
|
grub_video_rect_t vpsave2, content_rect;
|
||||||
|
int num_shown_items = get_num_shown_items (self);
|
||||||
|
int drawing_scrollbar = (self->draw_scrollbar
|
||||||
|
&& (num_shown_items < self->view->menu->size)
|
||||||
|
&& check_scrollbar (self));
|
||||||
|
int scrollbar_width = self->scrollbar_width;
|
||||||
|
|
||||||
|
content_rect.x = box_left_pad;
|
||||||
|
content_rect.y = box_top_pad;
|
||||||
|
content_rect.width = self->bounds.width - box_left_pad - box_right_pad;
|
||||||
|
content_rect.height = self->bounds.height - box_top_pad - box_bottom_pad;
|
||||||
|
|
||||||
|
box->set_content_size (box, content_rect.width, content_rect.height);
|
||||||
|
|
||||||
|
box->draw (box, 0, 0);
|
||||||
|
|
||||||
|
switch (self->scrollbar_slice)
|
||||||
|
{
|
||||||
|
case SCROLLBAR_SLICE_WEST:
|
||||||
|
content_rect.x += self->scrollbar_right_pad;
|
||||||
|
content_rect.width -= self->scrollbar_right_pad;
|
||||||
|
break;
|
||||||
|
case SCROLLBAR_SLICE_CENTER:
|
||||||
|
if (drawing_scrollbar)
|
||||||
|
content_rect.width -= scrollbar_width + self->scrollbar_left_pad
|
||||||
|
+ self->scrollbar_right_pad;
|
||||||
|
break;
|
||||||
|
case SCROLLBAR_SLICE_EAST:
|
||||||
|
content_rect.width -= self->scrollbar_left_pad;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_gui_set_viewport (&content_rect, &vpsave2);
|
||||||
|
draw_menu (self, num_shown_items);
|
||||||
|
grub_gui_restore_viewport (&vpsave2);
|
||||||
|
|
||||||
|
if (drawing_scrollbar)
|
||||||
|
{
|
||||||
|
content_rect.y += self->scrollbar_top_pad;
|
||||||
|
content_rect.height -= self->scrollbar_top_pad
|
||||||
|
+ self->scrollbar_bottom_pad;
|
||||||
|
content_rect.width = scrollbar_width;
|
||||||
|
switch (self->scrollbar_slice)
|
||||||
|
{
|
||||||
|
case SCROLLBAR_SLICE_WEST:
|
||||||
|
if (box_left_pad > scrollbar_width)
|
||||||
|
{
|
||||||
|
content_rect.x = box_left_pad - scrollbar_width;
|
||||||
|
content_rect.width = scrollbar_width;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
content_rect.x = 0;
|
||||||
|
content_rect.width = box_left_pad;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SCROLLBAR_SLICE_CENTER:
|
||||||
|
content_rect.x = self->bounds.width - box_right_pad
|
||||||
|
- scrollbar_width - self->scrollbar_right_pad;
|
||||||
|
content_rect.width = scrollbar_width;
|
||||||
|
break;
|
||||||
|
case SCROLLBAR_SLICE_EAST:
|
||||||
|
content_rect.x = self->bounds.width - box_right_pad;
|
||||||
|
content_rect.width = box_right_pad;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_gui_set_viewport (&content_rect, &vpsave2);
|
||||||
|
draw_scrollbar (self,
|
||||||
|
self->first_shown_index, num_shown_items,
|
||||||
|
0, self->view->menu->size,
|
||||||
|
scrollbar_width,
|
||||||
|
content_rect.height);
|
||||||
|
grub_gui_restore_viewport (&vpsave2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_gui_restore_viewport (&vpsave);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
list_set_parent (void *vself, grub_gui_container_t parent)
|
||||||
|
{
|
||||||
|
list_impl_t self = vself;
|
||||||
|
self->parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_gui_container_t
|
||||||
|
list_get_parent (void *vself)
|
||||||
|
{
|
||||||
|
list_impl_t self = vself;
|
||||||
|
return self->parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
list_set_bounds (void *vself, const grub_video_rect_t *bounds)
|
||||||
|
{
|
||||||
|
list_impl_t self = vself;
|
||||||
|
self->bounds = *bounds;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
list_get_bounds (void *vself, grub_video_rect_t *bounds)
|
||||||
|
{
|
||||||
|
list_impl_t self = vself;
|
||||||
|
*bounds = self->bounds;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
list_get_minimal_size (void *vself, unsigned *width, unsigned *height)
|
||||||
|
{
|
||||||
|
list_impl_t self = vself;
|
||||||
|
|
||||||
|
if (check_boxes (self))
|
||||||
|
{
|
||||||
|
int boxpad = self->item_padding;
|
||||||
|
int item_vspace = self->item_spacing;
|
||||||
|
int item_height = self->item_height;
|
||||||
|
int num_items = 3;
|
||||||
|
|
||||||
|
grub_gfxmenu_box_t box = self->menu_box;
|
||||||
|
int box_left_pad = box->get_left_pad (box);
|
||||||
|
int box_top_pad = box->get_top_pad (box);
|
||||||
|
int box_right_pad = box->get_right_pad (box);
|
||||||
|
int box_bottom_pad = box->get_bottom_pad (box);
|
||||||
|
unsigned width_s;
|
||||||
|
|
||||||
|
grub_gfxmenu_box_t selbox = self->selected_item_box;
|
||||||
|
int sel_top_pad = selbox->get_top_pad (selbox);
|
||||||
|
int sel_bottom_pad = selbox->get_bottom_pad (selbox);
|
||||||
|
int sel_left_pad = selbox->get_left_pad (selbox);
|
||||||
|
int sel_right_pad = selbox->get_right_pad (selbox);
|
||||||
|
|
||||||
|
grub_gfxmenu_box_t itembox = self->item_box;
|
||||||
|
int item_top_pad = itembox->get_top_pad (itembox);
|
||||||
|
int item_bottom_pad = itembox->get_bottom_pad (itembox);
|
||||||
|
int item_left_pad = itembox->get_left_pad (itembox);
|
||||||
|
int item_right_pad = itembox->get_right_pad (itembox);
|
||||||
|
|
||||||
|
int max_left_pad = grub_max (item_left_pad, sel_left_pad);
|
||||||
|
int max_right_pad = grub_max (item_right_pad, sel_right_pad);
|
||||||
|
int max_top_pad = grub_max (item_top_pad, sel_top_pad);
|
||||||
|
int max_bottom_pad = grub_max (item_bottom_pad, sel_bottom_pad);
|
||||||
|
|
||||||
|
*width = grub_font_get_string_width (self->item_font, "Typical OS");
|
||||||
|
width_s = grub_font_get_string_width (self->selected_item_font,
|
||||||
|
"Typical OS");
|
||||||
|
if (*width < width_s)
|
||||||
|
*width = width_s;
|
||||||
|
|
||||||
|
*width += 2 * boxpad + box_left_pad + box_right_pad
|
||||||
|
+ max_left_pad + max_right_pad
|
||||||
|
+ self->item_icon_space + self->icon_width;
|
||||||
|
|
||||||
|
switch (self->scrollbar_slice)
|
||||||
|
{
|
||||||
|
case SCROLLBAR_SLICE_WEST:
|
||||||
|
*width += self->scrollbar_right_pad;
|
||||||
|
break;
|
||||||
|
case SCROLLBAR_SLICE_CENTER:
|
||||||
|
*width += self->scrollbar_width + self->scrollbar_left_pad
|
||||||
|
+ self->scrollbar_right_pad;
|
||||||
|
break;
|
||||||
|
case SCROLLBAR_SLICE_EAST:
|
||||||
|
*width += self->scrollbar_left_pad;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the menu box height to fit the items. */
|
||||||
|
*height = (item_height * num_items
|
||||||
|
+ item_vspace * (num_items - 1)
|
||||||
|
+ 2 * boxpad
|
||||||
|
+ box_top_pad + box_bottom_pad
|
||||||
|
+ max_top_pad + max_bottom_pad);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*width = 0;
|
||||||
|
*height = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
list_set_property (void *vself, const char *name, const char *value)
|
||||||
|
{
|
||||||
|
list_impl_t self = vself;
|
||||||
|
if (grub_strcmp (name, "item_font") == 0)
|
||||||
|
{
|
||||||
|
self->item_font = grub_font_get (value);
|
||||||
|
if (self->selected_item_font_inherit)
|
||||||
|
self->selected_item_font = self->item_font;
|
||||||
|
}
|
||||||
|
else if (grub_strcmp (name, "selected_item_font") == 0)
|
||||||
|
{
|
||||||
|
if (! value || grub_strcmp (value, "inherit") == 0)
|
||||||
|
{
|
||||||
|
self->selected_item_font = self->item_font;
|
||||||
|
self->selected_item_font_inherit = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
self->selected_item_font = grub_font_get (value);
|
||||||
|
self->selected_item_font_inherit = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (grub_strcmp (name, "item_color") == 0)
|
||||||
|
{
|
||||||
|
grub_video_rgba_color_t color;
|
||||||
|
if (grub_video_parse_color (value, &color) == GRUB_ERR_NONE)
|
||||||
|
{
|
||||||
|
self->item_color = color;
|
||||||
|
if (self->selected_item_color_inherit)
|
||||||
|
self->selected_item_color = self->item_color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (grub_strcmp (name, "selected_item_color") == 0)
|
||||||
|
{
|
||||||
|
if (! value || grub_strcmp (value, "inherit") == 0)
|
||||||
|
{
|
||||||
|
self->selected_item_color = self->item_color;
|
||||||
|
self->selected_item_color_inherit = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
grub_video_rgba_color_t color;
|
||||||
|
if (grub_video_parse_color (value, &color)
|
||||||
|
== GRUB_ERR_NONE)
|
||||||
|
{
|
||||||
|
self->selected_item_color = color;
|
||||||
|
self->selected_item_color_inherit = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (grub_strcmp (name, "icon_width") == 0)
|
||||||
|
{
|
||||||
|
self->icon_width = grub_strtol (value, 0, 10);
|
||||||
|
grub_gfxmenu_icon_manager_set_icon_size (self->icon_manager,
|
||||||
|
self->icon_width,
|
||||||
|
self->icon_height);
|
||||||
|
}
|
||||||
|
else if (grub_strcmp (name, "icon_height") == 0)
|
||||||
|
{
|
||||||
|
self->icon_height = grub_strtol (value, 0, 10);
|
||||||
|
grub_gfxmenu_icon_manager_set_icon_size (self->icon_manager,
|
||||||
|
self->icon_width,
|
||||||
|
self->icon_height);
|
||||||
|
}
|
||||||
|
else if (grub_strcmp (name, "item_height") == 0)
|
||||||
|
{
|
||||||
|
self->item_height = grub_strtol (value, 0, 10);
|
||||||
|
}
|
||||||
|
else if (grub_strcmp (name, "item_padding") == 0)
|
||||||
|
{
|
||||||
|
self->item_padding = grub_strtol (value, 0, 10);
|
||||||
|
}
|
||||||
|
else if (grub_strcmp (name, "item_icon_space") == 0)
|
||||||
|
{
|
||||||
|
self->item_icon_space = grub_strtol (value, 0, 10);
|
||||||
|
}
|
||||||
|
else if (grub_strcmp (name, "item_spacing") == 0)
|
||||||
|
{
|
||||||
|
self->item_spacing = grub_strtol (value, 0, 10);
|
||||||
|
}
|
||||||
|
else if (grub_strcmp (name, "visible") == 0)
|
||||||
|
{
|
||||||
|
self->visible = grub_strcmp (value, "false") != 0;
|
||||||
|
}
|
||||||
|
else if (grub_strcmp (name, "menu_pixmap_style") == 0)
|
||||||
|
{
|
||||||
|
self->need_to_recreate_boxes = 1;
|
||||||
|
grub_free (self->menu_box_pattern);
|
||||||
|
self->menu_box_pattern = value ? grub_strdup (value) : 0;
|
||||||
|
}
|
||||||
|
else if (grub_strcmp (name, "item_pixmap_style") == 0)
|
||||||
|
{
|
||||||
|
self->need_to_recreate_boxes = 1;
|
||||||
|
grub_free (self->item_box_pattern);
|
||||||
|
self->item_box_pattern = value ? grub_strdup (value) : 0;
|
||||||
|
if (self->selected_item_box_pattern_inherit)
|
||||||
|
{
|
||||||
|
grub_free (self->selected_item_box_pattern);
|
||||||
|
self->selected_item_box_pattern = value ? grub_strdup (value) : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (grub_strcmp (name, "selected_item_pixmap_style") == 0)
|
||||||
|
{
|
||||||
|
if (!value || grub_strcmp (value, "inherit") == 0)
|
||||||
|
{
|
||||||
|
grub_free (self->selected_item_box_pattern);
|
||||||
|
char *tmp = self->item_box_pattern;
|
||||||
|
self->selected_item_box_pattern = tmp ? grub_strdup (tmp) : 0;
|
||||||
|
self->selected_item_box_pattern_inherit = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
self->need_to_recreate_boxes = 1;
|
||||||
|
grub_free (self->selected_item_box_pattern);
|
||||||
|
self->selected_item_box_pattern = value ? grub_strdup (value) : 0;
|
||||||
|
self->selected_item_box_pattern_inherit = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (grub_strcmp (name, "scrollbar_frame") == 0)
|
||||||
|
{
|
||||||
|
self->need_to_recreate_scrollbar = 1;
|
||||||
|
grub_free (self->scrollbar_frame_pattern);
|
||||||
|
self->scrollbar_frame_pattern = value ? grub_strdup (value) : 0;
|
||||||
|
}
|
||||||
|
else if (grub_strcmp (name, "scrollbar_thumb") == 0)
|
||||||
|
{
|
||||||
|
self->need_to_recreate_scrollbar = 1;
|
||||||
|
grub_free (self->scrollbar_thumb_pattern);
|
||||||
|
self->scrollbar_thumb_pattern = value ? grub_strdup (value) : 0;
|
||||||
|
}
|
||||||
|
else if (grub_strcmp (name, "scrollbar_thumb_overlay") == 0)
|
||||||
|
{
|
||||||
|
self->scrollbar_thumb_overlay = grub_strcmp (value, "true") == 0;
|
||||||
|
}
|
||||||
|
else if (grub_strcmp (name, "scrollbar_width") == 0)
|
||||||
|
{
|
||||||
|
self->scrollbar_width = grub_strtol (value, 0, 10);
|
||||||
|
}
|
||||||
|
else if (grub_strcmp (name, "scrollbar_slice") == 0)
|
||||||
|
{
|
||||||
|
if (grub_strcmp (value, "west") == 0)
|
||||||
|
self->scrollbar_slice = SCROLLBAR_SLICE_WEST;
|
||||||
|
else if (grub_strcmp (value, "center") == 0)
|
||||||
|
self->scrollbar_slice = SCROLLBAR_SLICE_CENTER;
|
||||||
|
else if (grub_strcmp (value, "east") == 0)
|
||||||
|
self->scrollbar_slice = SCROLLBAR_SLICE_EAST;
|
||||||
|
}
|
||||||
|
else if (grub_strcmp (name, "scrollbar_left_pad") == 0)
|
||||||
|
{
|
||||||
|
self->scrollbar_left_pad = grub_strtol (value, 0, 10);
|
||||||
|
}
|
||||||
|
else if (grub_strcmp (name, "scrollbar_right_pad") == 0)
|
||||||
|
{
|
||||||
|
self->scrollbar_right_pad = grub_strtol (value, 0, 10);
|
||||||
|
}
|
||||||
|
else if (grub_strcmp (name, "scrollbar_top_pad") == 0)
|
||||||
|
{
|
||||||
|
self->scrollbar_top_pad = grub_strtol (value, 0, 10);
|
||||||
|
}
|
||||||
|
else if (grub_strcmp (name, "scrollbar_bottom_pad") == 0)
|
||||||
|
{
|
||||||
|
self->scrollbar_bottom_pad = grub_strtol (value, 0, 10);
|
||||||
|
}
|
||||||
|
else if (grub_strcmp (name, "scrollbar") == 0)
|
||||||
|
{
|
||||||
|
self->draw_scrollbar = grub_strcmp (value, "false") != 0;
|
||||||
|
}
|
||||||
|
else if (grub_strcmp (name, "theme_dir") == 0)
|
||||||
|
{
|
||||||
|
self->need_to_recreate_boxes = 1;
|
||||||
|
grub_free (self->theme_dir);
|
||||||
|
self->theme_dir = value ? grub_strdup (value) : 0;
|
||||||
|
}
|
||||||
|
else if (grub_strcmp (name, "id") == 0)
|
||||||
|
{
|
||||||
|
grub_free (self->id);
|
||||||
|
if (value)
|
||||||
|
self->id = grub_strdup (value);
|
||||||
|
else
|
||||||
|
self->id = 0;
|
||||||
|
}
|
||||||
|
return grub_errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set necessary information that the gfxmenu view provides. */
|
||||||
|
static void
|
||||||
|
list_set_view_info (void *vself,
|
||||||
|
grub_gfxmenu_view_t view)
|
||||||
|
{
|
||||||
|
list_impl_t self = vself;
|
||||||
|
grub_gfxmenu_icon_manager_set_theme_path (self->icon_manager,
|
||||||
|
view->theme_path);
|
||||||
|
self->view = view;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Refresh list variables */
|
||||||
|
static void
|
||||||
|
list_refresh_info (void *vself,
|
||||||
|
grub_gfxmenu_view_t view)
|
||||||
|
{
|
||||||
|
list_impl_t self = vself;
|
||||||
|
if (view->nested)
|
||||||
|
self->first_shown_index = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct grub_gui_component_ops list_comp_ops =
|
||||||
|
{
|
||||||
|
.destroy = list_destroy,
|
||||||
|
.get_id = list_get_id,
|
||||||
|
.is_instance = list_is_instance,
|
||||||
|
.paint = list_paint,
|
||||||
|
.set_parent = list_set_parent,
|
||||||
|
.get_parent = list_get_parent,
|
||||||
|
.set_bounds = list_set_bounds,
|
||||||
|
.get_bounds = list_get_bounds,
|
||||||
|
.get_minimal_size = list_get_minimal_size,
|
||||||
|
.set_property = list_set_property
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct grub_gui_list_ops list_ops =
|
||||||
|
{
|
||||||
|
.set_view_info = list_set_view_info,
|
||||||
|
.refresh_list = list_refresh_info
|
||||||
|
};
|
||||||
|
|
||||||
|
grub_gui_component_t
|
||||||
|
grub_gui_list_new (void)
|
||||||
|
{
|
||||||
|
list_impl_t self;
|
||||||
|
grub_font_t default_font;
|
||||||
|
grub_video_rgba_color_t default_fg_color;
|
||||||
|
|
||||||
|
self = grub_zalloc (sizeof (*self));
|
||||||
|
if (! self)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
self->list.ops = &list_ops;
|
||||||
|
self->list.component.ops = &list_comp_ops;
|
||||||
|
|
||||||
|
self->visible = 1;
|
||||||
|
|
||||||
|
default_font = grub_font_get ("Unknown Regular 16");
|
||||||
|
default_fg_color = grub_video_rgba_color_rgb (0, 0, 0);
|
||||||
|
|
||||||
|
self->icon_width = 32;
|
||||||
|
self->icon_height = 32;
|
||||||
|
self->item_height = 42;
|
||||||
|
self->item_padding = 14;
|
||||||
|
self->item_icon_space = 4;
|
||||||
|
self->item_spacing = 16;
|
||||||
|
self->item_font = default_font;
|
||||||
|
self->selected_item_font_inherit = 1; /* Default to using the item_font. */
|
||||||
|
self->selected_item_font = default_font;
|
||||||
|
self->item_color = default_fg_color;
|
||||||
|
self->selected_item_color_inherit = 1; /* Default to using the item_color. */
|
||||||
|
self->selected_item_color = default_fg_color;
|
||||||
|
|
||||||
|
self->draw_scrollbar = 1;
|
||||||
|
self->need_to_recreate_scrollbar = 1;
|
||||||
|
self->scrollbar_frame = 0;
|
||||||
|
self->scrollbar_thumb = 0;
|
||||||
|
self->scrollbar_frame_pattern = 0;
|
||||||
|
self->scrollbar_thumb_pattern = 0;
|
||||||
|
self->scrollbar_thumb_overlay = 0;
|
||||||
|
self->scrollbar_width = 16;
|
||||||
|
self->scrollbar_slice = SCROLLBAR_SLICE_EAST;
|
||||||
|
self->scrollbar_left_pad = 2;
|
||||||
|
self->scrollbar_right_pad = 0;
|
||||||
|
self->scrollbar_top_pad = 0;
|
||||||
|
self->scrollbar_bottom_pad = 0;
|
||||||
|
|
||||||
|
self->first_shown_index = 0;
|
||||||
|
|
||||||
|
self->need_to_recreate_boxes = 0;
|
||||||
|
self->theme_dir = 0;
|
||||||
|
self->menu_box_pattern = 0;
|
||||||
|
self->item_box_pattern = 0;
|
||||||
|
self->selected_item_box_pattern_inherit = 1;/*Default to using the item_box.*/
|
||||||
|
self->selected_item_box_pattern = 0;
|
||||||
|
self->menu_box = grub_gfxmenu_create_box (0, 0);
|
||||||
|
self->item_box = grub_gfxmenu_create_box (0, 0);
|
||||||
|
self->selected_item_box = grub_gfxmenu_create_box (0, 0);
|
||||||
|
|
||||||
|
self->icon_manager = grub_gfxmenu_icon_manager_new ();
|
||||||
|
if (! self->icon_manager)
|
||||||
|
{
|
||||||
|
self->list.component.ops->destroy (self);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
grub_gfxmenu_icon_manager_set_icon_size (self->icon_manager,
|
||||||
|
self->icon_width,
|
||||||
|
self->icon_height);
|
||||||
|
return (grub_gui_component_t) self;
|
||||||
|
}
|
@@ -163,6 +163,12 @@ theme_set_string (grub_gfxmenu_view_t view,
|
|||||||
grub_video_parse_color (value, &view->message_color);
|
grub_video_parse_color (value, &view->message_color);
|
||||||
else if (! grub_strcmp ("message-bg-color", name))
|
else if (! grub_strcmp ("message-bg-color", name))
|
||||||
grub_video_parse_color (value, &view->message_bg_color);
|
grub_video_parse_color (value, &view->message_bg_color);
|
||||||
|
else if (! grub_strcmp("menu-tip-left", name))
|
||||||
|
grub_env_set("VTOY_TIP_LEFT", value);
|
||||||
|
else if (! grub_strcmp("menu-tip-top", name))
|
||||||
|
grub_env_set("VTOY_TIP_TOP", value);
|
||||||
|
else if (! grub_strcmp("menu-tip-color", name))
|
||||||
|
grub_env_set("VTOY_TIP_COLOR", value);
|
||||||
else if (! grub_strcmp ("desktop-image", name))
|
else if (! grub_strcmp ("desktop-image", name))
|
||||||
{
|
{
|
||||||
struct grub_video_bitmap *raw_bitmap;
|
struct grub_video_bitmap *raw_bitmap;
|
||||||
@@ -450,7 +456,8 @@ read_expression (struct parsebuf *p)
|
|||||||
/* Read as a single word -- for numeric values or words without
|
/* Read as a single word -- for numeric values or words without
|
||||||
whitespace. */
|
whitespace. */
|
||||||
start = p->pos;
|
start = p->pos;
|
||||||
while (has_more (p) && ! is_whitespace (peek_char (p)))
|
while (has_more (p) && ! is_whitespace (peek_char (p))
|
||||||
|
&& peek_char (p) != '}')
|
||||||
read_char (p);
|
read_char (p);
|
||||||
end = p->pos;
|
end = p->pos;
|
||||||
}
|
}
|
||||||
@@ -740,6 +747,7 @@ extern int g_menu_update_mode;
|
|||||||
grub_err_t
|
grub_err_t
|
||||||
grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
|
grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
|
||||||
{
|
{
|
||||||
|
int flag = 0;
|
||||||
grub_file_t file;
|
grub_file_t file;
|
||||||
struct parsebuf p;
|
struct parsebuf p;
|
||||||
|
|
||||||
@@ -783,32 +791,7 @@ grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
const char *tip = grub_env_get("VTOY_MENU_TIP_ENABLE");
|
|
||||||
if (tip && tip[0] == '1')
|
|
||||||
{
|
|
||||||
char tmpmsg[512];
|
|
||||||
|
|
||||||
grub_memset(tmpmsg, 'w', 500);
|
|
||||||
tmpmsg[500] = 0;
|
|
||||||
|
|
||||||
g_menu_update_mode = 1;
|
|
||||||
p.len += grub_snprintf(p.buf + p.len, 4096,
|
|
||||||
"\n+ vbox{\n left = %s\n top = %s\n"
|
|
||||||
"+ label { id=\"VTOY_MENU_TIP_1\" text = \"%s\" color = \"%s\" align = \"%s\"}\n"
|
|
||||||
"+ label { id=\"VTOY_MENU_TIP_2\" text = \"%s\" color = \"%s\" align = \"%s\"}\n"
|
|
||||||
"}\n",
|
|
||||||
grub_env_get("VTOY_TIP_LEFT"),
|
|
||||||
grub_env_get("VTOY_TIP_TOP"),
|
|
||||||
tmpmsg,
|
|
||||||
grub_env_get("VTOY_TIP_COLOR"),
|
|
||||||
grub_env_get("VTOY_TIP_ALIGN"),
|
|
||||||
tmpmsg,
|
|
||||||
grub_env_get("VTOY_TIP_COLOR"),
|
|
||||||
grub_env_get("VTOY_TIP_ALIGN")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (view->canvas)
|
if (view->canvas)
|
||||||
view->canvas->component.ops->destroy (view->canvas);
|
view->canvas->component.ops->destroy (view->canvas);
|
||||||
@@ -820,6 +803,7 @@ grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
|
|||||||
->ops->set_bounds ((grub_gui_component_t) view->canvas,
|
->ops->set_bounds ((grub_gui_component_t) view->canvas,
|
||||||
&view->screen);
|
&view->screen);
|
||||||
|
|
||||||
|
parse:
|
||||||
while (has_more (&p))
|
while (has_more (&p))
|
||||||
{
|
{
|
||||||
/* Skip comments (lines beginning with #). */
|
/* Skip comments (lines beginning with #). */
|
||||||
@@ -848,6 +832,40 @@ grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (flag == 0)
|
||||||
|
{
|
||||||
|
const char *tip = grub_env_get("VTOY_MENU_TIP_ENABLE");
|
||||||
|
if (tip && tip[0] == '1')
|
||||||
|
{
|
||||||
|
char tmpmsg[512];
|
||||||
|
|
||||||
|
grub_memset(tmpmsg, 'w', 500);
|
||||||
|
tmpmsg[500] = 0;
|
||||||
|
|
||||||
|
g_menu_update_mode = 1;
|
||||||
|
p.len += grub_snprintf(p.buf + p.len, 4096,
|
||||||
|
"\n+ vbox{\n left = %s\n top = %s\n"
|
||||||
|
"+ label { id=\"VTOY_MENU_TIP_1\" text = \"%s\" color = \"%s\" align = \"%s\"}\n"
|
||||||
|
"+ label { id=\"VTOY_MENU_TIP_2\" text = \"%s\" color = \"%s\" align = \"%s\"}\n"
|
||||||
|
"}\n",
|
||||||
|
grub_env_get("VTOY_TIP_LEFT"),
|
||||||
|
grub_env_get("VTOY_TIP_TOP"),
|
||||||
|
tmpmsg,
|
||||||
|
grub_env_get("VTOY_TIP_COLOR"),
|
||||||
|
grub_env_get("VTOY_TIP_ALIGN"),
|
||||||
|
tmpmsg,
|
||||||
|
grub_env_get("VTOY_TIP_COLOR"),
|
||||||
|
grub_env_get("VTOY_TIP_ALIGN")
|
||||||
|
);
|
||||||
|
|
||||||
|
flag = 1;
|
||||||
|
goto parse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Set the new theme path. */
|
/* Set the new theme path. */
|
||||||
grub_free (view->theme_path);
|
grub_free (view->theme_path);
|
||||||
view->theme_path = grub_strdup (theme_path);
|
view->theme_path = grub_strdup (theme_path);
|
||||||
|
@@ -37,6 +37,7 @@
|
|||||||
#include <grub/gui_string_util.h>
|
#include <grub/gui_string_util.h>
|
||||||
#include <grub/icon_manager.h>
|
#include <grub/icon_manager.h>
|
||||||
#include <grub/i18n.h>
|
#include <grub/i18n.h>
|
||||||
|
#include <grub/charset.h>
|
||||||
|
|
||||||
static void
|
static void
|
||||||
init_terminal (grub_gfxmenu_view_t view);
|
init_terminal (grub_gfxmenu_view_t view);
|
||||||
@@ -142,6 +143,8 @@ grub_gfxmenu_view_destroy (grub_gfxmenu_view_t view)
|
|||||||
grub_free (view->title_text);
|
grub_free (view->title_text);
|
||||||
grub_free (view->progress_message_text);
|
grub_free (view->progress_message_text);
|
||||||
grub_free (view->theme_path);
|
grub_free (view->theme_path);
|
||||||
|
if (view->menu_title_offset)
|
||||||
|
grub_free (view->menu_title_offset);
|
||||||
if (view->canvas)
|
if (view->canvas)
|
||||||
view->canvas->component.ops->destroy (view->canvas);
|
view->canvas->component.ops->destroy (view->canvas);
|
||||||
grub_free (view);
|
grub_free (view);
|
||||||
@@ -428,6 +431,32 @@ grub_gfxmenu_set_chosen_entry (int entry, void *data)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_gfxmenu_scroll_chosen_entry (void *data, int diren)
|
||||||
|
{
|
||||||
|
grub_gfxmenu_view_t view = data;
|
||||||
|
const char *item_title;
|
||||||
|
int off;
|
||||||
|
int max;
|
||||||
|
|
||||||
|
if (!view->menu->size)
|
||||||
|
return;
|
||||||
|
|
||||||
|
item_title = grub_menu_get_entry (view->menu, view->selected)->title;
|
||||||
|
off = view->menu_title_offset[view->selected] + diren;
|
||||||
|
max = grub_utf8_get_num_code (item_title, grub_strlen(item_title));
|
||||||
|
|
||||||
|
if (diren == 1000000)
|
||||||
|
off = (max >= 20) ? (max - 20) : 0;
|
||||||
|
else if (off < 0)
|
||||||
|
off = 0;
|
||||||
|
else if (off > max)
|
||||||
|
off = max;
|
||||||
|
|
||||||
|
view->menu_title_offset[view->selected] = off;
|
||||||
|
grub_gfxmenu_redraw_menu (view);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
grub_gfxmenu_draw_terminal_box (void)
|
grub_gfxmenu_draw_terminal_box (void)
|
||||||
{
|
{
|
||||||
|
@@ -471,7 +471,7 @@ grub_err_t
|
|||||||
grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector,
|
grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector,
|
||||||
grub_off_t offset, grub_size_t size, void *buf)
|
grub_off_t offset, grub_size_t size, void *buf)
|
||||||
{
|
{
|
||||||
if (disk->read_hook == (grub_disk_read_hook_t)grub_disk_blocklist_read)
|
if (disk->read_hook == (grub_disk_read_hook_t)(void *)grub_disk_blocklist_read)
|
||||||
{
|
{
|
||||||
return grub_disk_blocklist_read((ventoy_img_chunk_list *)disk->read_hook_data, sector, size, disk->log_sector_size);
|
return grub_disk_blocklist_read((ventoy_img_chunk_list *)disk->read_hook_data, sector, size, disk->log_sector_size);
|
||||||
}
|
}
|
||||||
|
1352
GRUB2/MOD_SRC/grub-2.04/grub-core/normal/charset.c
Normal file
1352
GRUB2/MOD_SRC/grub-2.04/grub-core/normal/charset.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -461,6 +461,15 @@ menu_set_chosen_entry (grub_menu_t menu, int entry)
|
|||||||
cur->set_chosen_entry (entry, cur->data);
|
cur->set_chosen_entry (entry, cur->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
menu_scroll_chosen_entry (int diren)
|
||||||
|
{
|
||||||
|
struct grub_menu_viewer *cur;
|
||||||
|
for (cur = viewers; cur; cur = cur->next)
|
||||||
|
if (cur->scroll_chosen_entry)
|
||||||
|
cur->scroll_chosen_entry (cur->data, diren);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
menu_print_timeout (int timeout)
|
menu_print_timeout (int timeout)
|
||||||
{
|
{
|
||||||
@@ -846,6 +855,19 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
|||||||
menu_set_chosen_entry (menu, current_entry);
|
menu_set_chosen_entry (menu, current_entry);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case GRUB_TERM_KEY_RIGHT:
|
||||||
|
menu_scroll_chosen_entry (1);
|
||||||
|
break;
|
||||||
|
case GRUB_TERM_KEY_LEFT:
|
||||||
|
menu_scroll_chosen_entry (-1);
|
||||||
|
break;
|
||||||
|
case GRUB_TERM_CTRL | GRUB_TERM_KEY_RIGHT:
|
||||||
|
menu_scroll_chosen_entry (1000000);
|
||||||
|
break;
|
||||||
|
case GRUB_TERM_CTRL | GRUB_TERM_KEY_LEFT:
|
||||||
|
menu_scroll_chosen_entry (-1000000);
|
||||||
|
break;
|
||||||
|
|
||||||
case '\n':
|
case '\n':
|
||||||
case '\r':
|
case '\r':
|
||||||
// case GRUB_TERM_KEY_RIGHT:
|
// case GRUB_TERM_KEY_RIGHT:
|
||||||
|
@@ -42,6 +42,7 @@ struct menu_viewer_data
|
|||||||
TIMEOUT_TERSE_NO_MARGIN
|
TIMEOUT_TERSE_NO_MARGIN
|
||||||
} timeout_msg;
|
} timeout_msg;
|
||||||
grub_menu_t menu;
|
grub_menu_t menu;
|
||||||
|
int *menu_title_offset;
|
||||||
struct grub_term_output *term;
|
struct grub_term_output *term;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -524,6 +525,37 @@ menu_text_set_chosen_entry (int entry, void *dataptr)
|
|||||||
grub_term_refresh (data->term);
|
grub_term_refresh (data->term);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
menu_text_scroll_chosen_entry (void *dataptr, int diren)
|
||||||
|
{
|
||||||
|
struct menu_viewer_data *data = dataptr;
|
||||||
|
const char *orig_title, *scrolled_title;
|
||||||
|
int off;
|
||||||
|
int selected;
|
||||||
|
grub_menu_entry_t entry;
|
||||||
|
|
||||||
|
if (!data->menu->size)
|
||||||
|
return;
|
||||||
|
|
||||||
|
selected = data->first + data->offset;
|
||||||
|
entry = grub_menu_get_entry (data->menu, selected);
|
||||||
|
orig_title = entry->title;
|
||||||
|
off = data->menu_title_offset[selected] + diren;
|
||||||
|
if (off < 0
|
||||||
|
|| off > grub_utf8_get_num_code (orig_title, grub_strlen(orig_title)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
scrolled_title =
|
||||||
|
grub_utf8_offset_code (orig_title, grub_strlen (orig_title), off);
|
||||||
|
if (scrolled_title)
|
||||||
|
entry->title = scrolled_title;
|
||||||
|
print_entry (data->geo.first_entry_y + data->offset, 1, entry, data);
|
||||||
|
|
||||||
|
entry->title = orig_title;
|
||||||
|
data->menu_title_offset[selected] = off;
|
||||||
|
grub_term_refresh (data->term);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
menu_text_fini (void *dataptr)
|
menu_text_fini (void *dataptr)
|
||||||
{
|
{
|
||||||
@@ -531,6 +563,8 @@ menu_text_fini (void *dataptr)
|
|||||||
|
|
||||||
grub_term_setcursor (data->term, 1);
|
grub_term_setcursor (data->term, 1);
|
||||||
grub_term_cls (data->term);
|
grub_term_cls (data->term);
|
||||||
|
if (data->menu_title_offset)
|
||||||
|
grub_free (data->menu_title_offset);
|
||||||
grub_free (data);
|
grub_free (data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -585,9 +619,14 @@ grub_menu_try_text (struct grub_term_output *term,
|
|||||||
return grub_errno;
|
return grub_errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (menu->size)
|
||||||
|
data->menu_title_offset = grub_zalloc (sizeof (*data->menu_title_offset) * menu->size);
|
||||||
|
|
||||||
data->term = term;
|
data->term = term;
|
||||||
instance->data = data;
|
instance->data = data;
|
||||||
instance->set_chosen_entry = menu_text_set_chosen_entry;
|
instance->set_chosen_entry = menu_text_set_chosen_entry;
|
||||||
|
if (data->menu_title_offset)
|
||||||
|
instance->scroll_chosen_entry = menu_text_scroll_chosen_entry;
|
||||||
instance->print_timeout = menu_text_print_timeout;
|
instance->print_timeout = menu_text_print_timeout;
|
||||||
instance->clear_timeout = menu_text_clear_timeout;
|
instance->clear_timeout = menu_text_clear_timeout;
|
||||||
instance->fini = menu_text_fini;
|
instance->fini = menu_text_fini;
|
||||||
|
260
GRUB2/MOD_SRC/grub-2.04/grub-core/term/efi/mouse.c
Normal file
260
GRUB2/MOD_SRC/grub-2.04/grub-core/term/efi/mouse.c
Normal file
@@ -0,0 +1,260 @@
|
|||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2022 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* GRUB is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* GRUB is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <grub/dl.h>
|
||||||
|
#include <grub/term.h>
|
||||||
|
#include <grub/misc.h>
|
||||||
|
#include <grub/types.h>
|
||||||
|
#include <grub/command.h>
|
||||||
|
#include <grub/i18n.h>
|
||||||
|
#include <grub/err.h>
|
||||||
|
#include <grub/env.h>
|
||||||
|
#include <grub/efi/efi.h>
|
||||||
|
#include <grub/efi/api.h>
|
||||||
|
|
||||||
|
GRUB_MOD_LICENSE ("GPLv3+");
|
||||||
|
|
||||||
|
#define GRUB_EFI_SIMPLE_POINTER_GUID \
|
||||||
|
{ 0x31878c87, 0x0b75, 0x11d5, \
|
||||||
|
{ 0x9a, 0x4f, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
grub_efi_int32_t x;
|
||||||
|
grub_efi_int32_t y;
|
||||||
|
grub_efi_int32_t z;
|
||||||
|
grub_efi_boolean_t left;
|
||||||
|
grub_efi_boolean_t right;
|
||||||
|
} grub_efi_mouse_state;
|
||||||
|
|
||||||
|
grub_efi_mouse_state no_move = {0, 0, 0, 0, 0};
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
grub_efi_uint64_t x;
|
||||||
|
grub_efi_uint64_t y;
|
||||||
|
grub_efi_uint64_t z;
|
||||||
|
grub_efi_boolean_t left;
|
||||||
|
grub_efi_boolean_t right;
|
||||||
|
} grub_efi_mouse_mode;
|
||||||
|
|
||||||
|
struct grub_efi_simple_pointer_protocol
|
||||||
|
{
|
||||||
|
grub_efi_status_t (*reset) (struct grub_efi_simple_pointer_protocol *this,
|
||||||
|
grub_efi_boolean_t extended_verification);
|
||||||
|
grub_efi_status_t (*get_state) (struct grub_efi_simple_pointer_protocol *this,
|
||||||
|
grub_efi_mouse_state *state);
|
||||||
|
grub_efi_event_t *wait_for_input;
|
||||||
|
grub_efi_mouse_mode *mode;
|
||||||
|
};
|
||||||
|
typedef struct grub_efi_simple_pointer_protocol grub_efi_simple_pointer_protocol_t;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
grub_efi_uintn_t count;
|
||||||
|
grub_efi_simple_pointer_protocol_t **mouse;
|
||||||
|
} grub_efi_mouse_prot_t;
|
||||||
|
|
||||||
|
static grub_int32_t
|
||||||
|
mouse_div (grub_int32_t a, grub_uint64_t b)
|
||||||
|
{
|
||||||
|
grub_int32_t s = 1, q, ret;
|
||||||
|
grub_uint64_t n = a;
|
||||||
|
if (!b)
|
||||||
|
return 0;
|
||||||
|
if (a < 0)
|
||||||
|
{
|
||||||
|
s = -1;
|
||||||
|
n = -a;
|
||||||
|
}
|
||||||
|
q = grub_divmod64 (n, b, NULL);
|
||||||
|
ret = s * (q > 0 ? q : -q);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_efi_mouse_prot_t *
|
||||||
|
grub_efi_mouse_prot_init (void)
|
||||||
|
{
|
||||||
|
grub_efi_status_t status;
|
||||||
|
grub_efi_guid_t mouse_guid = GRUB_EFI_SIMPLE_POINTER_GUID;
|
||||||
|
grub_efi_mouse_prot_t *mouse_input = NULL;
|
||||||
|
grub_efi_boot_services_t *b = grub_efi_system_table->boot_services;
|
||||||
|
grub_efi_handle_t *buf;
|
||||||
|
grub_efi_uintn_t count;
|
||||||
|
grub_efi_uintn_t i;
|
||||||
|
|
||||||
|
status = efi_call_5 (b->locate_handle_buffer, GRUB_EFI_BY_PROTOCOL,
|
||||||
|
&mouse_guid, NULL, &count, &buf);
|
||||||
|
if (status != GRUB_EFI_SUCCESS)
|
||||||
|
{
|
||||||
|
#ifdef MOUSE_DEBUG
|
||||||
|
grub_printf ("ERROR: SimplePointerProtocol not found.\n");
|
||||||
|
#endif
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
mouse_input = grub_malloc (sizeof (grub_efi_mouse_prot_t));
|
||||||
|
if (!mouse_input)
|
||||||
|
goto end;
|
||||||
|
mouse_input->mouse = grub_malloc (count
|
||||||
|
* sizeof (grub_efi_simple_pointer_protocol_t *));
|
||||||
|
if (!mouse_input->mouse)
|
||||||
|
{
|
||||||
|
grub_free (mouse_input);
|
||||||
|
mouse_input = NULL;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
mouse_input->count = count;
|
||||||
|
for (i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
efi_call_3 (b->handle_protocol,
|
||||||
|
buf[i], &mouse_guid, (void **)&mouse_input->mouse[i]);
|
||||||
|
#ifdef MOUSE_DEBUG
|
||||||
|
grub_printf ("%d %p ", (int)i, mouse_input->mouse[i]);
|
||||||
|
#endif
|
||||||
|
efi_call_2 (mouse_input->mouse[i]->reset, mouse_input->mouse[i], 1);
|
||||||
|
#ifdef MOUSE_DEBUG
|
||||||
|
grub_printf
|
||||||
|
("[%"PRIuGRUB_UINT64_T"] [%"PRIuGRUB_UINT64_T"] [%"PRIuGRUB_UINT64_T"]\n",
|
||||||
|
mouse_input->mouse[i]->mode->x,
|
||||||
|
mouse_input->mouse[i]->mode->y, mouse_input->mouse[i]->mode->z);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
end:
|
||||||
|
efi_call_1(b->free_pool, buf);
|
||||||
|
|
||||||
|
return mouse_input;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_efi_mouse_input_init (struct grub_term_input *term)
|
||||||
|
{
|
||||||
|
grub_efi_mouse_prot_t *mouse_input = NULL;
|
||||||
|
if (term->data)
|
||||||
|
return 0;
|
||||||
|
mouse_input = grub_efi_mouse_prot_init ();
|
||||||
|
if (!mouse_input)
|
||||||
|
return GRUB_ERR_BAD_OS;
|
||||||
|
|
||||||
|
term->data = (void *)mouse_input;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
grub_mouse_getkey (struct grub_term_input *term)
|
||||||
|
{
|
||||||
|
grub_efi_mouse_state cur;
|
||||||
|
grub_efi_mouse_prot_t *mouse = term->data;
|
||||||
|
//int x;
|
||||||
|
int y;
|
||||||
|
int delta = 0;
|
||||||
|
const char *env;
|
||||||
|
grub_efi_uintn_t i;
|
||||||
|
if (!mouse)
|
||||||
|
return GRUB_TERM_NO_KEY;
|
||||||
|
|
||||||
|
env = grub_env_get("mouse_delta");
|
||||||
|
if (env)
|
||||||
|
delta = (int)grub_strtol(env, NULL, 10);
|
||||||
|
|
||||||
|
for (i = 0; i < mouse->count; i++)
|
||||||
|
{
|
||||||
|
efi_call_2 (mouse->mouse[i]->get_state, mouse->mouse[i], &cur);
|
||||||
|
if (grub_memcmp (&cur, &no_move, sizeof (grub_efi_mouse_state)) != 0)
|
||||||
|
{
|
||||||
|
y = mouse_div (cur.y, mouse->mouse[i]->mode->y);
|
||||||
|
if (cur.left)
|
||||||
|
return 0x0d;
|
||||||
|
if (cur.right)
|
||||||
|
return GRUB_TERM_ESC;
|
||||||
|
if (y > delta)
|
||||||
|
return GRUB_TERM_KEY_DOWN;
|
||||||
|
if (y < -delta)
|
||||||
|
return GRUB_TERM_KEY_UP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GRUB_TERM_NO_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef MOUSE_DEBUG
|
||||||
|
static grub_err_t
|
||||||
|
grub_cmd_mouse_test (grub_command_t cmd __attribute__ ((unused)),
|
||||||
|
int argc __attribute__ ((unused)),
|
||||||
|
char **args __attribute__ ((unused)))
|
||||||
|
|
||||||
|
{
|
||||||
|
grub_efi_mouse_state cur;
|
||||||
|
int x = 0, y = 0, z = 0;
|
||||||
|
grub_efi_uintn_t i;
|
||||||
|
grub_efi_mouse_prot_t *mouse = NULL;
|
||||||
|
|
||||||
|
mouse = grub_efi_mouse_prot_init ();
|
||||||
|
if (!mouse)
|
||||||
|
return grub_error (GRUB_ERR_BAD_OS, "mouse not found.\n");
|
||||||
|
grub_printf ("Press [1] to exit.\n");
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
if (grub_getkey_noblock () == '1')
|
||||||
|
break;
|
||||||
|
for (i = 0; i < mouse->count; i++)
|
||||||
|
{
|
||||||
|
efi_call_2 (mouse->mouse[i]->get_state, mouse->mouse[i], &cur);
|
||||||
|
if (grub_memcmp (&cur, &no_move, sizeof (grub_efi_mouse_state)) != 0)
|
||||||
|
{
|
||||||
|
x = mouse_div (cur.x, mouse->mouse[i]->mode->x);
|
||||||
|
y = mouse_div (cur.y, mouse->mouse[i]->mode->y);
|
||||||
|
z = mouse_div (cur.z, mouse->mouse[i]->mode->z);
|
||||||
|
grub_printf ("[ID=%d] X=%d Y=%d Z=%d L=%d R=%d\n",
|
||||||
|
(int)i, x, y, z, cur.left, cur.right);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
grub_refresh ();
|
||||||
|
}
|
||||||
|
grub_free (mouse->mouse);
|
||||||
|
grub_free (mouse);
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
static grub_command_t cmd;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static struct grub_term_input grub_mouse_term_input =
|
||||||
|
{
|
||||||
|
.name = "mouse",
|
||||||
|
.getkey = grub_mouse_getkey,
|
||||||
|
.init = grub_efi_mouse_input_init,
|
||||||
|
};
|
||||||
|
|
||||||
|
GRUB_MOD_INIT(mouse)
|
||||||
|
{
|
||||||
|
grub_term_register_input ("mouse", &grub_mouse_term_input);
|
||||||
|
#ifdef MOUSE_DEBUG
|
||||||
|
cmd = grub_register_command ("mouse_test", grub_cmd_mouse_test, 0,
|
||||||
|
N_("UEFI mouse test."));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
GRUB_MOD_FINI(mouse)
|
||||||
|
{
|
||||||
|
grub_term_unregister_input (&grub_mouse_term_input);
|
||||||
|
#ifdef MOUSE_DEBUG
|
||||||
|
grub_unregister_command (cmd);
|
||||||
|
#endif
|
||||||
|
}
|
@@ -35,6 +35,10 @@
|
|||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/kernel.h>
|
#include <grub/kernel.h>
|
||||||
#include <grub/time.h>
|
#include <grub/time.h>
|
||||||
|
#include <grub/memory.h>
|
||||||
|
#ifdef GRUB_MACHINE_EFI
|
||||||
|
#include <grub/efi/efi.h>
|
||||||
|
#endif
|
||||||
#include <grub/ventoy.h>
|
#include <grub/ventoy.h>
|
||||||
#include "ventoy_def.h"
|
#include "ventoy_def.h"
|
||||||
|
|
||||||
@@ -162,8 +166,52 @@ static int ventoy_arch_mode_init(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef GRUB_MACHINE_EFI
|
||||||
|
static void ventoy_get_uefi_version(char *str, grub_size_t len)
|
||||||
|
{
|
||||||
|
grub_efi_uint8_t uefi_minor_1, uefi_minor_2;
|
||||||
|
|
||||||
|
uefi_minor_1 = (grub_efi_system_table->hdr.revision & 0xffff) / 10;
|
||||||
|
uefi_minor_2 = (grub_efi_system_table->hdr.revision & 0xffff) % 10;
|
||||||
|
grub_snprintf(str, len, "%d.%d", (grub_efi_system_table->hdr.revision >> 16), uefi_minor_1);
|
||||||
|
if (uefi_minor_2)
|
||||||
|
grub_snprintf(str, len, "%s.%d", str, uefi_minor_2);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static int ventoy_calc_totalmem(grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type, void *data)
|
||||||
|
{
|
||||||
|
grub_uint64_t *total_mem = (grub_uint64_t *)data;
|
||||||
|
|
||||||
|
(void)addr;
|
||||||
|
(void)type;
|
||||||
|
|
||||||
|
*total_mem += size;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ventoy_hwinfo_init(void)
|
||||||
|
{
|
||||||
|
char str[256];
|
||||||
|
grub_uint64_t total_mem = 0;
|
||||||
|
|
||||||
|
grub_machine_mmap_iterate(ventoy_calc_totalmem, &total_mem);
|
||||||
|
|
||||||
|
grub_snprintf(str, sizeof(str), "%ld", (long)(total_mem / VTOY_SIZE_1MB));
|
||||||
|
ventoy_env_export("grub_total_ram", str);
|
||||||
|
|
||||||
|
#ifdef GRUB_MACHINE_EFI
|
||||||
|
ventoy_get_uefi_version(str, sizeof(str));
|
||||||
|
ventoy_env_export("grub_uefi_version", str);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
GRUB_MOD_INIT(ventoy)
|
GRUB_MOD_INIT(ventoy)
|
||||||
{
|
{
|
||||||
|
ventoy_hwinfo_init();
|
||||||
ventoy_env_init();
|
ventoy_env_init();
|
||||||
ventoy_arch_mode_init();
|
ventoy_arch_mode_init();
|
||||||
ventoy_register_all_cmd();
|
ventoy_register_all_cmd();
|
||||||
|
@@ -137,6 +137,10 @@ static grub_uint64_t g_enumerate_start_time_ms;
|
|||||||
static grub_uint64_t g_enumerate_finish_time_ms;
|
static grub_uint64_t g_enumerate_finish_time_ms;
|
||||||
int g_vtoy_file_flt[VTOY_FILE_FLT_BUTT] = {0};
|
int g_vtoy_file_flt[VTOY_FILE_FLT_BUTT] = {0};
|
||||||
|
|
||||||
|
static char g_iso_vd_id_publisher[130];
|
||||||
|
static char g_iso_vd_id_prepare[130];
|
||||||
|
static char g_iso_vd_id_application[130];
|
||||||
|
|
||||||
static int g_pager_flag = 0;
|
static int g_pager_flag = 0;
|
||||||
static char g_old_pager[32];
|
static char g_old_pager[32];
|
||||||
|
|
||||||
@@ -3148,7 +3152,7 @@ int ventoy_get_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, gr
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
file->read_hook = (grub_disk_read_hook_t)grub_disk_blocklist_read;
|
file->read_hook = (grub_disk_read_hook_t)(void *)grub_disk_blocklist_read;
|
||||||
file->read_hook_data = chunklist;
|
file->read_hook_data = chunklist;
|
||||||
|
|
||||||
for (size = file->size; size > 0; size -= read)
|
for (size = file->size; size > 0; size -= read)
|
||||||
@@ -5469,6 +5473,98 @@ out:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static grub_err_t ventoy_iso_vd_id_clear(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
|
{
|
||||||
|
(void)ctxt;
|
||||||
|
(void)argc;
|
||||||
|
(void)args;
|
||||||
|
|
||||||
|
g_iso_vd_id_publisher[0] = 0;
|
||||||
|
g_iso_vd_id_prepare[0] = 0;
|
||||||
|
g_iso_vd_id_application[0] = 0;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t ventoy_cmd_iso_vd_id_parse(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
|
{
|
||||||
|
int ret = 1;
|
||||||
|
int offset = 318;
|
||||||
|
grub_file_t file = NULL;
|
||||||
|
|
||||||
|
(void)ctxt;
|
||||||
|
(void)argc;
|
||||||
|
|
||||||
|
file = grub_file_open(args[0], VENTOY_FILE_TYPE);
|
||||||
|
if (!file)
|
||||||
|
{
|
||||||
|
grub_printf("Failed to open %s\n", args[0]);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_file_seek(file, 16 * 2048 + offset);
|
||||||
|
grub_file_read(file, g_iso_vd_id_publisher, 128);
|
||||||
|
|
||||||
|
offset += 128;
|
||||||
|
grub_file_seek(file, 16 * 2048 + offset);
|
||||||
|
grub_file_read(file, g_iso_vd_id_prepare, 128);
|
||||||
|
|
||||||
|
offset += 128;
|
||||||
|
grub_file_seek(file, 16 * 2048 + offset);
|
||||||
|
grub_file_read(file, g_iso_vd_id_application, 128);
|
||||||
|
|
||||||
|
out:
|
||||||
|
|
||||||
|
check_free(file, grub_file_close);
|
||||||
|
grub_errno = GRUB_ERR_NONE;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t ventoy_cmd_iso_vd_id_begin(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
|
{
|
||||||
|
int ret = 1;
|
||||||
|
char *id = g_iso_vd_id_publisher;
|
||||||
|
|
||||||
|
(void)ctxt;
|
||||||
|
(void)argc;
|
||||||
|
|
||||||
|
if (args[0][0] == '1')
|
||||||
|
{
|
||||||
|
id = g_iso_vd_id_prepare;
|
||||||
|
}
|
||||||
|
else if (args[0][0] == '2')
|
||||||
|
{
|
||||||
|
id = g_iso_vd_id_application;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[1][0] == '0' && grub_strncasecmp(id, args[2], grub_strlen(args[2])) == 0)
|
||||||
|
{
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[1][0] == '1' && grub_strncmp(id, args[2], grub_strlen(args[2])) == 0)
|
||||||
|
{
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_errno = GRUB_ERR_NONE;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t ventoy_cmd_fn_mutex_lock(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
|
{
|
||||||
|
(void)ctxt;
|
||||||
|
(void)argc;
|
||||||
|
|
||||||
|
g_ventoy_fn_mutex = 0;
|
||||||
|
if (argc == 1 && args[0][0] == '1' && args[0][1] == 0)
|
||||||
|
{
|
||||||
|
g_ventoy_fn_mutex = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
int ventoy_env_init(void)
|
int ventoy_env_init(void)
|
||||||
{
|
{
|
||||||
char buf[64];
|
char buf[64];
|
||||||
@@ -5630,7 +5726,9 @@ static cmd_para ventoy_cmds[] =
|
|||||||
{ "vt_unix_parse_freebsd_ver", ventoy_cmd_unix_freebsd_ver, 0, NULL, "", "", NULL },
|
{ "vt_unix_parse_freebsd_ver", ventoy_cmd_unix_freebsd_ver, 0, NULL, "", "", NULL },
|
||||||
{ "vt_unix_parse_freebsd_ver_elf", ventoy_cmd_unix_freebsd_ver_elf, 0, NULL, "", "", NULL },
|
{ "vt_unix_parse_freebsd_ver_elf", ventoy_cmd_unix_freebsd_ver_elf, 0, NULL, "", "", NULL },
|
||||||
{ "vt_unix_reset", ventoy_cmd_unix_reset, 0, NULL, "", "", NULL },
|
{ "vt_unix_reset", ventoy_cmd_unix_reset, 0, NULL, "", "", NULL },
|
||||||
|
{ "vt_unix_check_vlnk", ventoy_cmd_unix_check_vlnk, 0, NULL, "", "", NULL },
|
||||||
{ "vt_unix_replace_conf", ventoy_cmd_unix_replace_conf, 0, NULL, "", "", NULL },
|
{ "vt_unix_replace_conf", ventoy_cmd_unix_replace_conf, 0, NULL, "", "", NULL },
|
||||||
|
{ "vt_unix_replace_grub_conf", ventoy_cmd_unix_replace_grub_conf, 0, NULL, "", "", NULL },
|
||||||
{ "vt_unix_replace_ko", ventoy_cmd_unix_replace_ko, 0, NULL, "", "", NULL },
|
{ "vt_unix_replace_ko", ventoy_cmd_unix_replace_ko, 0, NULL, "", "", NULL },
|
||||||
{ "vt_unix_ko_fillmap", ventoy_cmd_unix_ko_fillmap, 0, NULL, "", "", NULL },
|
{ "vt_unix_ko_fillmap", ventoy_cmd_unix_ko_fillmap, 0, NULL, "", "", NULL },
|
||||||
{ "vt_unix_fill_image_desc", ventoy_cmd_unix_fill_image_desc, 0, NULL, "", "", NULL },
|
{ "vt_unix_fill_image_desc", ventoy_cmd_unix_fill_image_desc, 0, NULL, "", "", NULL },
|
||||||
@@ -5664,6 +5762,10 @@ static cmd_para ventoy_cmds[] =
|
|||||||
{ "vt_get_vlnk_dst", grub_cmd_get_vlnk_dst, 0, NULL, "", "", NULL },
|
{ "vt_get_vlnk_dst", grub_cmd_get_vlnk_dst, 0, NULL, "", "", NULL },
|
||||||
{ "vt_set_fake_vlnk", ventoy_cmd_set_fake_vlnk, 0, NULL, "", "", NULL },
|
{ "vt_set_fake_vlnk", ventoy_cmd_set_fake_vlnk, 0, NULL, "", "", NULL },
|
||||||
{ "vt_reset_fake_vlnk", ventoy_cmd_reset_fake_vlnk, 0, NULL, "", "", NULL },
|
{ "vt_reset_fake_vlnk", ventoy_cmd_reset_fake_vlnk, 0, NULL, "", "", NULL },
|
||||||
|
{ "vt_iso_vd_id_parse", ventoy_cmd_iso_vd_id_parse, 0, NULL, "", "", NULL },
|
||||||
|
{ "vt_iso_vd_id_clear", ventoy_iso_vd_id_clear, 0, NULL, "", "", NULL },
|
||||||
|
{ "vt_iso_vd_id_begin", ventoy_cmd_iso_vd_id_begin, 0, NULL, "", "", NULL },
|
||||||
|
{ "vt_fn_mutex_lock", ventoy_cmd_fn_mutex_lock, 0, NULL, "", "", NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
int ventoy_register_all_cmd(void)
|
int ventoy_register_all_cmd(void)
|
||||||
|
@@ -1019,6 +1019,7 @@ extern int g_ventoy_grub2_mode;
|
|||||||
extern int g_ventoy_wimboot_mode;
|
extern int g_ventoy_wimboot_mode;
|
||||||
extern int g_ventoy_iso_uefi_drv;
|
extern int g_ventoy_iso_uefi_drv;
|
||||||
extern int g_ventoy_case_insensitive;
|
extern int g_ventoy_case_insensitive;
|
||||||
|
extern int g_ventoy_fn_mutex;
|
||||||
extern grub_uint8_t g_ventoy_chain_type;
|
extern grub_uint8_t g_ventoy_chain_type;
|
||||||
extern int g_vhdboot_enable;
|
extern int g_vhdboot_enable;
|
||||||
|
|
||||||
@@ -1093,7 +1094,9 @@ grub_err_t ventoy_cmd_locate_wim_patch(grub_extcmd_context_t ctxt, int argc, cha
|
|||||||
grub_err_t ventoy_cmd_unix_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
|
grub_err_t ventoy_cmd_unix_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||||
int ventoy_get_disk_guid(const char *filename, grub_uint8_t *guid, grub_uint8_t *signature);
|
int ventoy_get_disk_guid(const char *filename, grub_uint8_t *guid, grub_uint8_t *signature);
|
||||||
grub_err_t ventoy_cmd_unix_reset(grub_extcmd_context_t ctxt, int argc, char **args);
|
grub_err_t ventoy_cmd_unix_reset(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||||
|
grub_err_t ventoy_cmd_unix_check_vlnk(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||||
grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, char **args);
|
grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||||
|
grub_err_t ventoy_cmd_unix_replace_grub_conf(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||||
grub_err_t ventoy_cmd_unix_replace_ko(grub_extcmd_context_t ctxt, int argc, char **args);
|
grub_err_t ventoy_cmd_unix_replace_ko(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||||
grub_err_t ventoy_cmd_unix_ko_fillmap(grub_extcmd_context_t ctxt, int argc, char **args);
|
grub_err_t ventoy_cmd_unix_ko_fillmap(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||||
grub_err_t ventoy_cmd_unix_fill_image_desc(grub_extcmd_context_t ctxt, int argc, char **args);
|
grub_err_t ventoy_cmd_unix_fill_image_desc(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||||
|
@@ -960,7 +960,7 @@ static int ventoy_plugin_parse_pwdstr(char *pwdstr, vtoy_password *pwd)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len - 1 - (int)(long)(pos - pwdstr) != 32)
|
if (len - 1 - ((long)pos - (long)pwdstr) != 32)
|
||||||
{
|
{
|
||||||
if (NULL == pwd) grub_printf("Invalid md5 salt password format %s\n", pwdstr);
|
if (NULL == pwd) grub_printf("Invalid md5 salt password format %s\n", pwdstr);
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -48,6 +48,7 @@ int g_mod_new_len = 0;
|
|||||||
char *g_mod_new_data = NULL;
|
char *g_mod_new_data = NULL;
|
||||||
|
|
||||||
int g_mod_search_magic = 0;
|
int g_mod_search_magic = 0;
|
||||||
|
int g_unix_vlnk_boot = 0;
|
||||||
|
|
||||||
int g_ko_fillmap_len = 0;
|
int g_ko_fillmap_len = 0;
|
||||||
char *g_ko_fillmap_data = NULL;
|
char *g_ko_fillmap_data = NULL;
|
||||||
@@ -273,13 +274,14 @@ static void ventoy_unix_fill_virt_data( grub_uint64_t isosize, ventoy_chain_h
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ventoy_freebsd_append_conf(char *buf, const char *isopath)
|
static int ventoy_freebsd_append_conf(char *buf, const char *isopath, const char *alias)
|
||||||
{
|
{
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
grub_uint32_t i;
|
grub_uint32_t i;
|
||||||
grub_disk_t disk;
|
grub_disk_t disk;
|
||||||
grub_file_t isofile;
|
grub_file_t isofile;
|
||||||
char uuid[64] = {0};
|
char uuid[64] = {0};
|
||||||
|
const char *val = NULL;
|
||||||
ventoy_img_chunk *chunk;
|
ventoy_img_chunk *chunk;
|
||||||
grub_uint8_t disk_sig[4];
|
grub_uint8_t disk_sig[4];
|
||||||
grub_uint8_t disk_guid[16];
|
grub_uint8_t disk_guid[16];
|
||||||
@@ -294,6 +296,22 @@ static int ventoy_freebsd_append_conf(char *buf, const char *isopath)
|
|||||||
|
|
||||||
vtoy_ssprintf(buf, pos, "ventoy_load=\"%s\"\n", "YES");
|
vtoy_ssprintf(buf, pos, "ventoy_load=\"%s\"\n", "YES");
|
||||||
vtoy_ssprintf(buf, pos, "ventoy_name=\"%s\"\n", g_ko_mod_path);
|
vtoy_ssprintf(buf, pos, "ventoy_name=\"%s\"\n", g_ko_mod_path);
|
||||||
|
|
||||||
|
if (alias)
|
||||||
|
{
|
||||||
|
vtoy_ssprintf(buf, pos, "hint.ventoy.0.alias=\"%s\"\n", alias);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_unix_vlnk_boot)
|
||||||
|
{
|
||||||
|
vtoy_ssprintf(buf, pos, "hint.ventoy.0.vlnk=%d\n", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
val = ventoy_get_env("VTOY_UNIX_REMOUNT");
|
||||||
|
if (val && val[0] == '1' && val[1] == 0)
|
||||||
|
{
|
||||||
|
vtoy_ssprintf(buf, pos, "hint.ventoy.0.remount=%d\n", 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (g_mod_search_magic)
|
if (g_mod_search_magic)
|
||||||
{
|
{
|
||||||
@@ -301,6 +319,8 @@ static int ventoy_freebsd_append_conf(char *buf, const char *isopath)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debug("Fill hint.ventoy info\n");
|
||||||
|
|
||||||
disk = isofile->device->disk;
|
disk = isofile->device->disk;
|
||||||
|
|
||||||
ventoy_get_disk_guid(isofile->name, disk_guid, disk_sig);
|
ventoy_get_disk_guid(isofile->name, disk_guid, disk_sig);
|
||||||
@@ -349,6 +369,7 @@ grub_err_t ventoy_cmd_unix_reset(grub_extcmd_context_t ctxt, int argc, char **ar
|
|||||||
(void)argc;
|
(void)argc;
|
||||||
(void)args;
|
(void)args;
|
||||||
|
|
||||||
|
g_unix_vlnk_boot = 0;
|
||||||
g_mod_search_magic = 0;
|
g_mod_search_magic = 0;
|
||||||
g_conf_new_len = 0;
|
g_conf_new_len = 0;
|
||||||
g_mod_new_len = 0;
|
g_mod_new_len = 0;
|
||||||
@@ -363,6 +384,27 @@ grub_err_t ventoy_cmd_unix_reset(grub_extcmd_context_t ctxt, int argc, char **ar
|
|||||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
grub_err_t ventoy_cmd_unix_check_vlnk(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
|
{
|
||||||
|
grub_file_t file;
|
||||||
|
|
||||||
|
(void)ctxt;
|
||||||
|
|
||||||
|
if (argc != 1)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
file = grub_file_open(args[0], VENTOY_FILE_TYPE);
|
||||||
|
if (file)
|
||||||
|
{
|
||||||
|
g_unix_vlnk_boot = file->vlnk;
|
||||||
|
grub_file_close(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
grub_err_t ventoy_cmd_parse_freenas_ver(grub_extcmd_context_t ctxt, int argc, char **args)
|
grub_err_t ventoy_cmd_parse_freenas_ver(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
{
|
{
|
||||||
grub_file_t file;
|
grub_file_t file;
|
||||||
@@ -647,6 +689,109 @@ out:
|
|||||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
grub_err_t ventoy_cmd_unix_replace_grub_conf(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
|
{
|
||||||
|
int len = 0;
|
||||||
|
grub_uint32_t i;
|
||||||
|
char *data;
|
||||||
|
char *pos;
|
||||||
|
const char *val = NULL;
|
||||||
|
grub_uint64_t offset;
|
||||||
|
grub_file_t file;
|
||||||
|
char extcfg[512];
|
||||||
|
const char *confile = NULL;
|
||||||
|
const char * loader_conf[] =
|
||||||
|
{
|
||||||
|
"/boot/grub/grub.cfg",
|
||||||
|
};
|
||||||
|
|
||||||
|
(void)ctxt;
|
||||||
|
|
||||||
|
if (argc != 1 && argc != 2)
|
||||||
|
{
|
||||||
|
debug("Replace conf invalid argc %d\n", argc);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < sizeof(loader_conf) / sizeof(loader_conf[0]); i++)
|
||||||
|
{
|
||||||
|
if (ventoy_get_file_override(loader_conf[i], &offset) == 0)
|
||||||
|
{
|
||||||
|
confile = loader_conf[i];
|
||||||
|
g_conf_override_offset = offset;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (confile == NULL)
|
||||||
|
{
|
||||||
|
debug("Can't find grub.cfg file from %u locations\n", i);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
file = ventoy_grub_file_open(GRUB_FILE_TYPE_LINUX_INITRD, "(loop)/%s", confile);
|
||||||
|
if (!file)
|
||||||
|
{
|
||||||
|
debug("Failed to open %s \n", confile);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
debug("old grub2 conf file size:%d\n", (int)file->size);
|
||||||
|
|
||||||
|
data = grub_malloc(VTOY_MAX_SCRIPT_BUF);
|
||||||
|
if (!data)
|
||||||
|
{
|
||||||
|
grub_file_close(file);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_file_read(file, data, file->size);
|
||||||
|
grub_file_close(file);
|
||||||
|
|
||||||
|
g_conf_new_data = data;
|
||||||
|
g_conf_new_len = (int)file->size;
|
||||||
|
|
||||||
|
pos = grub_strstr(data, "kfreebsd /boot/kernel/kernel");
|
||||||
|
if (pos)
|
||||||
|
{
|
||||||
|
pos += grub_strlen("kfreebsd /boot/kernel/kernel");
|
||||||
|
if (grub_strncmp(pos, ".gz", 3) == 0)
|
||||||
|
{
|
||||||
|
pos += 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc == 2)
|
||||||
|
{
|
||||||
|
vtoy_ssprintf(extcfg, len, ";kfreebsd_module_elf %s; set kFreeBSD.hint.ventoy.0.alias=\"%s\"", args[0], args[1]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vtoy_ssprintf(extcfg, len, ";kfreebsd_module_elf %s", args[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_unix_vlnk_boot)
|
||||||
|
{
|
||||||
|
vtoy_ssprintf(extcfg, len, ";set kFreeBSD.hint.ventoy.0.vlnk=%d", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
val = ventoy_get_env("VTOY_UNIX_REMOUNT");
|
||||||
|
if (val && val[0] == '1' && val[1] == 0)
|
||||||
|
{
|
||||||
|
vtoy_ssprintf(extcfg, len, ";set kFreeBSD.hint.ventoy.0.remount=%d", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_memmove(pos + len, pos, (int)(file->size - (pos - data)));
|
||||||
|
grub_memcpy(pos, extcfg, len);
|
||||||
|
g_conf_new_len += len;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
debug("no kfreebsd found\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, char **args)
|
grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
{
|
{
|
||||||
grub_uint32_t i;
|
grub_uint32_t i;
|
||||||
@@ -662,7 +807,7 @@ grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, ch
|
|||||||
|
|
||||||
(void)ctxt;
|
(void)ctxt;
|
||||||
|
|
||||||
if (argc != 2)
|
if (argc != 2 && argc != 3)
|
||||||
{
|
{
|
||||||
debug("Replace conf invalid argc %d\n", argc);
|
debug("Replace conf invalid argc %d\n", argc);
|
||||||
return 1;
|
return 1;
|
||||||
@@ -691,7 +836,7 @@ grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, ch
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
debug("old conf file size:%d\n", (int)file->size);
|
debug("old conf file <%s> size:%d\n", confile, (int)file->size);
|
||||||
|
|
||||||
data = grub_malloc(VTOY_MAX_SCRIPT_BUF);
|
data = grub_malloc(VTOY_MAX_SCRIPT_BUF);
|
||||||
if (!data)
|
if (!data)
|
||||||
@@ -708,7 +853,7 @@ grub_err_t ventoy_cmd_unix_replace_conf(grub_extcmd_context_t ctxt, int argc, ch
|
|||||||
|
|
||||||
if (grub_strcmp(args[0], "FreeBSD") == 0)
|
if (grub_strcmp(args[0], "FreeBSD") == 0)
|
||||||
{
|
{
|
||||||
g_conf_new_len += ventoy_freebsd_append_conf(data + file->size, args[1]);
|
g_conf_new_len += ventoy_freebsd_append_conf(data + file->size, args[1], (argc > 2) ? args[2] : NULL);
|
||||||
}
|
}
|
||||||
else if (grub_strcmp(args[0], "DragonFly") == 0)
|
else if (grub_strcmp(args[0], "DragonFly") == 0)
|
||||||
{
|
{
|
||||||
@@ -723,13 +868,13 @@ static int ventoy_unix_search_magic(char *data, int len)
|
|||||||
int i;
|
int i;
|
||||||
grub_uint32_t *magic = NULL;
|
grub_uint32_t *magic = NULL;
|
||||||
|
|
||||||
for (i = 0; i < len; i += 65536)
|
for (i = 0; i < len; i += 4096)
|
||||||
{
|
{
|
||||||
magic = (grub_uint32_t *)(data + i);
|
magic = (grub_uint32_t *)(data + i);
|
||||||
if (magic[0] == VENTOY_UNIX_SEG_MAGIC0 && magic[1] == VENTOY_UNIX_SEG_MAGIC1 &&
|
if (magic[0] == VENTOY_UNIX_SEG_MAGIC0 && magic[1] == VENTOY_UNIX_SEG_MAGIC1 &&
|
||||||
magic[2] == VENTOY_UNIX_SEG_MAGIC2 && magic[3] == VENTOY_UNIX_SEG_MAGIC3)
|
magic[2] == VENTOY_UNIX_SEG_MAGIC2 && magic[3] == VENTOY_UNIX_SEG_MAGIC3)
|
||||||
{
|
{
|
||||||
debug("unix find search magic at 0x%x loop:%d\n", i, (i >> 16));
|
debug("unix find search magic at 0x%x loop:%d\n", i, (i >> 12));
|
||||||
g_mod_search_magic = i;
|
g_mod_search_magic = i;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
329
GRUB2/MOD_SRC/grub-2.04/include/grub/charset.h
Normal file
329
GRUB2/MOD_SRC/grub-2.04/include/grub/charset.h
Normal file
@@ -0,0 +1,329 @@
|
|||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* GRUB is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* GRUB is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GRUB_CHARSET_HEADER
|
||||||
|
#define GRUB_CHARSET_HEADER 1
|
||||||
|
|
||||||
|
#include <grub/types.h>
|
||||||
|
|
||||||
|
#define GRUB_UINT8_1_LEADINGBIT 0x80
|
||||||
|
#define GRUB_UINT8_2_LEADINGBITS 0xc0
|
||||||
|
#define GRUB_UINT8_3_LEADINGBITS 0xe0
|
||||||
|
#define GRUB_UINT8_4_LEADINGBITS 0xf0
|
||||||
|
#define GRUB_UINT8_5_LEADINGBITS 0xf8
|
||||||
|
#define GRUB_UINT8_6_LEADINGBITS 0xfc
|
||||||
|
#define GRUB_UINT8_7_LEADINGBITS 0xfe
|
||||||
|
|
||||||
|
#define GRUB_UINT8_1_TRAILINGBIT 0x01
|
||||||
|
#define GRUB_UINT8_2_TRAILINGBITS 0x03
|
||||||
|
#define GRUB_UINT8_3_TRAILINGBITS 0x07
|
||||||
|
#define GRUB_UINT8_4_TRAILINGBITS 0x0f
|
||||||
|
#define GRUB_UINT8_5_TRAILINGBITS 0x1f
|
||||||
|
#define GRUB_UINT8_6_TRAILINGBITS 0x3f
|
||||||
|
|
||||||
|
#define GRUB_MAX_UTF8_PER_UTF16 4
|
||||||
|
/* You need at least one UTF-8 byte to have one UTF-16 word.
|
||||||
|
You need at least three UTF-8 bytes to have 2 UTF-16 words (surrogate pairs).
|
||||||
|
*/
|
||||||
|
#define GRUB_MAX_UTF16_PER_UTF8 1
|
||||||
|
#define GRUB_MAX_UTF8_PER_CODEPOINT 4
|
||||||
|
|
||||||
|
#define GRUB_UCS2_LIMIT 0x10000
|
||||||
|
#define GRUB_UTF16_UPPER_SURROGATE(code) \
|
||||||
|
(0xD800 | ((((code) - GRUB_UCS2_LIMIT) >> 10) & 0x3ff))
|
||||||
|
#define GRUB_UTF16_LOWER_SURROGATE(code) \
|
||||||
|
(0xDC00 | (((code) - GRUB_UCS2_LIMIT) & 0x3ff))
|
||||||
|
|
||||||
|
/* Process one character from UTF8 sequence.
|
||||||
|
At beginning set *code = 0, *count = 0. Returns 0 on failure and
|
||||||
|
1 on success. *count holds the number of trailing bytes. */
|
||||||
|
static inline int
|
||||||
|
grub_utf8_process (grub_uint8_t c, grub_uint32_t *code, int *count)
|
||||||
|
{
|
||||||
|
if (*count)
|
||||||
|
{
|
||||||
|
if ((c & GRUB_UINT8_2_LEADINGBITS) != GRUB_UINT8_1_LEADINGBIT)
|
||||||
|
{
|
||||||
|
*count = 0;
|
||||||
|
/* invalid */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*code <<= 6;
|
||||||
|
*code |= (c & GRUB_UINT8_6_TRAILINGBITS);
|
||||||
|
(*count)--;
|
||||||
|
/* Overlong. */
|
||||||
|
if ((*count == 1 && *code <= 0x1f)
|
||||||
|
|| (*count == 2 && *code <= 0xf))
|
||||||
|
{
|
||||||
|
*code = 0;
|
||||||
|
*count = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((c & GRUB_UINT8_1_LEADINGBIT) == 0)
|
||||||
|
{
|
||||||
|
*code = c;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if ((c & GRUB_UINT8_3_LEADINGBITS) == GRUB_UINT8_2_LEADINGBITS)
|
||||||
|
{
|
||||||
|
*count = 1;
|
||||||
|
*code = c & GRUB_UINT8_5_TRAILINGBITS;
|
||||||
|
/* Overlong */
|
||||||
|
if (*code <= 1)
|
||||||
|
{
|
||||||
|
*count = 0;
|
||||||
|
*code = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if ((c & GRUB_UINT8_4_LEADINGBITS) == GRUB_UINT8_3_LEADINGBITS)
|
||||||
|
{
|
||||||
|
*count = 2;
|
||||||
|
*code = c & GRUB_UINT8_4_TRAILINGBITS;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if ((c & GRUB_UINT8_5_LEADINGBITS) == GRUB_UINT8_4_LEADINGBITS)
|
||||||
|
{
|
||||||
|
*count = 3;
|
||||||
|
*code = c & GRUB_UINT8_3_TRAILINGBITS;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Convert a (possibly null-terminated) UTF-8 string of at most SRCSIZE
|
||||||
|
bytes (if SRCSIZE is -1, it is ignored) in length to a UTF-16 string.
|
||||||
|
Return the number of characters converted. DEST must be able to hold
|
||||||
|
at least DESTSIZE characters. If an invalid sequence is found, return -1.
|
||||||
|
If SRCEND is not NULL, then *SRCEND is set to the next byte after the
|
||||||
|
last byte used in SRC. */
|
||||||
|
static inline grub_size_t
|
||||||
|
grub_utf8_to_utf16 (grub_uint16_t *dest, grub_size_t destsize,
|
||||||
|
const grub_uint8_t *src, grub_size_t srcsize,
|
||||||
|
const grub_uint8_t **srcend)
|
||||||
|
{
|
||||||
|
grub_uint16_t *p = dest;
|
||||||
|
int count = 0;
|
||||||
|
grub_uint32_t code = 0;
|
||||||
|
|
||||||
|
if (srcend)
|
||||||
|
*srcend = src;
|
||||||
|
|
||||||
|
while (srcsize && destsize)
|
||||||
|
{
|
||||||
|
int was_count = count;
|
||||||
|
if (srcsize != (grub_size_t)-1)
|
||||||
|
srcsize--;
|
||||||
|
if (!grub_utf8_process (*src++, &code, &count))
|
||||||
|
{
|
||||||
|
code = '?';
|
||||||
|
count = 0;
|
||||||
|
/* Character c may be valid, don't eat it. */
|
||||||
|
if (was_count)
|
||||||
|
src--;
|
||||||
|
}
|
||||||
|
if (count != 0)
|
||||||
|
continue;
|
||||||
|
if (code == 0)
|
||||||
|
break;
|
||||||
|
if (destsize < 2 && code >= GRUB_UCS2_LIMIT)
|
||||||
|
break;
|
||||||
|
if (code >= GRUB_UCS2_LIMIT)
|
||||||
|
{
|
||||||
|
*p++ = GRUB_UTF16_UPPER_SURROGATE (code);
|
||||||
|
*p++ = GRUB_UTF16_LOWER_SURROGATE (code);
|
||||||
|
destsize -= 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*p++ = code;
|
||||||
|
destsize--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (srcend)
|
||||||
|
*srcend = src;
|
||||||
|
return p - dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Determine the last position where the UTF-8 string [beg, end) can
|
||||||
|
be safely cut. */
|
||||||
|
static inline grub_size_t
|
||||||
|
grub_getend (const char *beg, const char *end)
|
||||||
|
{
|
||||||
|
const char *ptr;
|
||||||
|
for (ptr = end - 1; ptr >= beg; ptr--)
|
||||||
|
if ((*ptr & GRUB_UINT8_2_LEADINGBITS) != GRUB_UINT8_1_LEADINGBIT)
|
||||||
|
break;
|
||||||
|
if (ptr < beg)
|
||||||
|
return 0;
|
||||||
|
if ((*ptr & GRUB_UINT8_1_LEADINGBIT) == 0)
|
||||||
|
return ptr + 1 - beg;
|
||||||
|
if ((*ptr & GRUB_UINT8_3_LEADINGBITS) == GRUB_UINT8_2_LEADINGBITS
|
||||||
|
&& ptr + 2 <= end)
|
||||||
|
return ptr + 2 - beg;
|
||||||
|
if ((*ptr & GRUB_UINT8_4_LEADINGBITS) == GRUB_UINT8_3_LEADINGBITS
|
||||||
|
&& ptr + 3 <= end)
|
||||||
|
return ptr + 3 - beg;
|
||||||
|
if ((*ptr & GRUB_UINT8_5_LEADINGBITS) == GRUB_UINT8_4_LEADINGBITS
|
||||||
|
&& ptr + 4 <= end)
|
||||||
|
return ptr + 4 - beg;
|
||||||
|
/* Invalid character or incomplete. Cut before it. */
|
||||||
|
return ptr - beg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Convert UTF-16 to UTF-8. */
|
||||||
|
static inline grub_uint8_t *
|
||||||
|
grub_utf16_to_utf8 (grub_uint8_t *dest, const grub_uint16_t *src,
|
||||||
|
grub_size_t size)
|
||||||
|
{
|
||||||
|
grub_uint32_t code_high = 0;
|
||||||
|
|
||||||
|
while (size--)
|
||||||
|
{
|
||||||
|
grub_uint32_t code = *src++;
|
||||||
|
|
||||||
|
if (code_high)
|
||||||
|
{
|
||||||
|
if (code >= 0xDC00 && code <= 0xDFFF)
|
||||||
|
{
|
||||||
|
/* Surrogate pair. */
|
||||||
|
code = ((code_high - 0xD800) << 10) + (code - 0xDC00) + 0x10000;
|
||||||
|
|
||||||
|
*dest++ = (code >> 18) | 0xF0;
|
||||||
|
*dest++ = ((code >> 12) & 0x3F) | 0x80;
|
||||||
|
*dest++ = ((code >> 6) & 0x3F) | 0x80;
|
||||||
|
*dest++ = (code & 0x3F) | 0x80;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Error... */
|
||||||
|
*dest++ = '?';
|
||||||
|
/* *src may be valid. Don't eat it. */
|
||||||
|
src--;
|
||||||
|
}
|
||||||
|
|
||||||
|
code_high = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (code <= 0x007F)
|
||||||
|
*dest++ = code;
|
||||||
|
else if (code <= 0x07FF)
|
||||||
|
{
|
||||||
|
*dest++ = (code >> 6) | 0xC0;
|
||||||
|
*dest++ = (code & 0x3F) | 0x80;
|
||||||
|
}
|
||||||
|
else if (code >= 0xD800 && code <= 0xDBFF)
|
||||||
|
{
|
||||||
|
code_high = code;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (code >= 0xDC00 && code <= 0xDFFF)
|
||||||
|
{
|
||||||
|
/* Error... */
|
||||||
|
*dest++ = '?';
|
||||||
|
}
|
||||||
|
else if (code < 0x10000)
|
||||||
|
{
|
||||||
|
*dest++ = (code >> 12) | 0xE0;
|
||||||
|
*dest++ = ((code >> 6) & 0x3F) | 0x80;
|
||||||
|
*dest++ = (code & 0x3F) | 0x80;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*dest++ = (code >> 18) | 0xF0;
|
||||||
|
*dest++ = ((code >> 12) & 0x3F) | 0x80;
|
||||||
|
*dest++ = ((code >> 6) & 0x3F) | 0x80;
|
||||||
|
*dest++ = (code & 0x3F) | 0x80;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define GRUB_MAX_UTF8_PER_LATIN1 2
|
||||||
|
|
||||||
|
/* Convert Latin1 to UTF-8. */
|
||||||
|
static inline grub_uint8_t *
|
||||||
|
grub_latin1_to_utf8 (grub_uint8_t *dest, const grub_uint8_t *src,
|
||||||
|
grub_size_t size)
|
||||||
|
{
|
||||||
|
while (size--)
|
||||||
|
{
|
||||||
|
if (!(*src & 0x80))
|
||||||
|
*dest++ = *src;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*dest++ = (*src >> 6) | 0xC0;
|
||||||
|
*dest++ = (*src & 0x3F) | 0x80;
|
||||||
|
}
|
||||||
|
src++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Convert UCS-4 to UTF-8. */
|
||||||
|
char *grub_ucs4_to_utf8_alloc (const grub_uint32_t *src, grub_size_t size);
|
||||||
|
|
||||||
|
int
|
||||||
|
grub_is_valid_utf8 (const grub_uint8_t *src, grub_size_t srcsize);
|
||||||
|
|
||||||
|
grub_ssize_t grub_utf8_to_ucs4_alloc (const char *msg,
|
||||||
|
grub_uint32_t **unicode_msg,
|
||||||
|
grub_uint32_t **last_position);
|
||||||
|
|
||||||
|
/* Returns the number of bytes the string src would occupy is converted
|
||||||
|
to UTF-8, excluding \0. */
|
||||||
|
grub_size_t
|
||||||
|
grub_get_num_of_utf8_bytes (const grub_uint32_t *src, grub_size_t size);
|
||||||
|
|
||||||
|
/* Converts UCS-4 to UTF-8. Returns the number of bytes effectively written
|
||||||
|
excluding the trailing \0. */
|
||||||
|
grub_size_t
|
||||||
|
grub_ucs4_to_utf8 (const grub_uint32_t *src, grub_size_t size,
|
||||||
|
grub_uint8_t *dest, grub_size_t destsize);
|
||||||
|
grub_size_t grub_utf8_to_ucs4 (grub_uint32_t *dest, grub_size_t destsize,
|
||||||
|
const grub_uint8_t *src, grub_size_t srcsize,
|
||||||
|
const grub_uint8_t **srcend);
|
||||||
|
/* Returns -2 if not enough space, -1 on invalid character. */
|
||||||
|
grub_ssize_t
|
||||||
|
grub_encode_utf8_character (grub_uint8_t *dest, grub_uint8_t *destend,
|
||||||
|
grub_uint32_t code);
|
||||||
|
|
||||||
|
const grub_uint32_t *
|
||||||
|
grub_unicode_get_comb_start (const grub_uint32_t *str,
|
||||||
|
const grub_uint32_t *cur);
|
||||||
|
|
||||||
|
int
|
||||||
|
grub_utf8_get_num_code (const char *src, grub_size_t srcsize);
|
||||||
|
|
||||||
|
const char *
|
||||||
|
grub_utf8_offset_code (const char *src, grub_size_t srcsize, int num);
|
||||||
|
|
||||||
|
#endif
|
@@ -314,6 +314,11 @@
|
|||||||
{ 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
|
{ 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define GRUB_EFI_SMBIOS3_TABLE_GUID \
|
||||||
|
{ 0xf2fd1544, 0x9794, 0x4a2c, \
|
||||||
|
{ 0x99, 0x2e, 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94 } \
|
||||||
|
}
|
||||||
|
|
||||||
#define GRUB_EFI_SAL_TABLE_GUID \
|
#define GRUB_EFI_SAL_TABLE_GUID \
|
||||||
{ 0xeb9d2d32, 0x2d88, 0x11d3, \
|
{ 0xeb9d2d32, 0x2d88, 0x11d3, \
|
||||||
{ 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
|
{ 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
|
||||||
|
128
GRUB2/MOD_SRC/grub-2.04/include/grub/gfxmenu_view.h
Normal file
128
GRUB2/MOD_SRC/grub-2.04/include/grub/gfxmenu_view.h
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
/* gfxmenu_view.h - gfxmenu view interface. */
|
||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2008,2009 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* GRUB is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* GRUB is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GRUB_GFXMENU_VIEW_HEADER
|
||||||
|
#define GRUB_GFXMENU_VIEW_HEADER 1
|
||||||
|
|
||||||
|
#include <grub/types.h>
|
||||||
|
#include <grub/err.h>
|
||||||
|
#include <grub/menu.h>
|
||||||
|
#include <grub/font.h>
|
||||||
|
#include <grub/gfxwidgets.h>
|
||||||
|
|
||||||
|
struct grub_gfxmenu_view; /* Forward declaration of opaque type. */
|
||||||
|
typedef struct grub_gfxmenu_view *grub_gfxmenu_view_t;
|
||||||
|
|
||||||
|
|
||||||
|
grub_gfxmenu_view_t grub_gfxmenu_view_new (const char *theme_path,
|
||||||
|
int width, int height);
|
||||||
|
|
||||||
|
void grub_gfxmenu_view_destroy (grub_gfxmenu_view_t view);
|
||||||
|
|
||||||
|
/* Set properties on the view based on settings from the specified
|
||||||
|
theme file. */
|
||||||
|
grub_err_t grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view,
|
||||||
|
const char *theme_path);
|
||||||
|
|
||||||
|
grub_err_t grub_gui_recreate_box (grub_gfxmenu_box_t *boxptr,
|
||||||
|
const char *pattern, const char *theme_dir);
|
||||||
|
|
||||||
|
void grub_gfxmenu_view_draw (grub_gfxmenu_view_t view);
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_gfxmenu_redraw_menu (grub_gfxmenu_view_t view);
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_gfxmenu_redraw_timeout (grub_gfxmenu_view_t view);
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_gfxmenu_view_redraw (grub_gfxmenu_view_t view,
|
||||||
|
const grub_video_rect_t *region);
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_gfxmenu_clear_timeout (void *data);
|
||||||
|
void
|
||||||
|
grub_gfxmenu_print_timeout (int timeout, void *data);
|
||||||
|
void
|
||||||
|
grub_gfxmenu_set_chosen_entry (int entry, void *data);
|
||||||
|
void
|
||||||
|
grub_gfxmenu_scroll_chosen_entry (void *data, int diren);
|
||||||
|
|
||||||
|
grub_err_t grub_font_draw_string (const char *str,
|
||||||
|
grub_font_t font,
|
||||||
|
grub_video_color_t color,
|
||||||
|
int left_x, int baseline_y);
|
||||||
|
int grub_font_get_string_width (grub_font_t font,
|
||||||
|
const char *str);
|
||||||
|
|
||||||
|
|
||||||
|
/* Implementation details -- this should not be used outside of the
|
||||||
|
view itself. */
|
||||||
|
|
||||||
|
#include <grub/video.h>
|
||||||
|
#include <grub/bitmap.h>
|
||||||
|
#include <grub/bitmap_scale.h>
|
||||||
|
#include <grub/gui.h>
|
||||||
|
#include <grub/gfxwidgets.h>
|
||||||
|
#include <grub/icon_manager.h>
|
||||||
|
|
||||||
|
/* Definition of the private representation of the view. */
|
||||||
|
struct grub_gfxmenu_view
|
||||||
|
{
|
||||||
|
grub_video_rect_t screen;
|
||||||
|
|
||||||
|
int need_to_check_sanity;
|
||||||
|
grub_video_rect_t terminal_rect;
|
||||||
|
int terminal_border;
|
||||||
|
|
||||||
|
grub_font_t title_font;
|
||||||
|
grub_font_t message_font;
|
||||||
|
char *terminal_font_name;
|
||||||
|
grub_video_rgba_color_t title_color;
|
||||||
|
grub_video_rgba_color_t message_color;
|
||||||
|
grub_video_rgba_color_t message_bg_color;
|
||||||
|
struct grub_video_bitmap *raw_desktop_image;
|
||||||
|
struct grub_video_bitmap *scaled_desktop_image;
|
||||||
|
grub_video_bitmap_selection_method_t desktop_image_scale_method;
|
||||||
|
grub_video_bitmap_h_align_t desktop_image_h_align;
|
||||||
|
grub_video_bitmap_v_align_t desktop_image_v_align;
|
||||||
|
grub_video_rgba_color_t desktop_color;
|
||||||
|
grub_gfxmenu_box_t terminal_box;
|
||||||
|
char *title_text;
|
||||||
|
char *progress_message_text;
|
||||||
|
char *theme_path;
|
||||||
|
|
||||||
|
grub_gui_container_t canvas;
|
||||||
|
|
||||||
|
int double_repaint;
|
||||||
|
|
||||||
|
int selected;
|
||||||
|
|
||||||
|
grub_video_rect_t progress_message_frame;
|
||||||
|
|
||||||
|
grub_menu_t menu;
|
||||||
|
|
||||||
|
int nested;
|
||||||
|
|
||||||
|
int first_timeout;
|
||||||
|
|
||||||
|
int *menu_title_offset;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* ! GRUB_GFXMENU_VIEW_HEADER */
|
49
GRUB2/MOD_SRC/grub-2.04/include/grub/menu_viewer.h
Normal file
49
GRUB2/MOD_SRC/grub-2.04/include/grub/menu_viewer.h
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
/* menu_viewer.h - Interface to menu viewer implementations. */
|
||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2009 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* GRUB is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* GRUB is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GRUB_MENU_VIEWER_HEADER
|
||||||
|
#define GRUB_MENU_VIEWER_HEADER 1
|
||||||
|
|
||||||
|
#include <grub/err.h>
|
||||||
|
#include <grub/symbol.h>
|
||||||
|
#include <grub/types.h>
|
||||||
|
#include <grub/menu.h>
|
||||||
|
#include <grub/term.h>
|
||||||
|
|
||||||
|
struct grub_menu_viewer
|
||||||
|
{
|
||||||
|
struct grub_menu_viewer *next;
|
||||||
|
void *data;
|
||||||
|
void (*set_chosen_entry) (int entry, void *data);
|
||||||
|
void (*scroll_chosen_entry) (void *data, int diren);
|
||||||
|
void (*print_timeout) (int timeout, void *data);
|
||||||
|
void (*clear_timeout) (void *data);
|
||||||
|
void (*fini) (void *fini);
|
||||||
|
};
|
||||||
|
|
||||||
|
void grub_menu_register_viewer (struct grub_menu_viewer *viewer);
|
||||||
|
|
||||||
|
grub_err_t
|
||||||
|
grub_menu_try_text (struct grub_term_output *term,
|
||||||
|
int entry, grub_menu_t menu, int nested);
|
||||||
|
|
||||||
|
extern grub_err_t (*grub_gfxmenu_try_hook) (int entry, grub_menu_t menu,
|
||||||
|
int nested);
|
||||||
|
|
||||||
|
#endif /* GRUB_MENU_VIEWER_HEADER */
|
@@ -12,10 +12,10 @@ make install
|
|||||||
PATH=$PATH:$VT_DIR/GRUB2/INSTALL/bin/:$VT_DIR/GRUB2/INSTALL/sbin/
|
PATH=$PATH:$VT_DIR/GRUB2/INSTALL/bin/:$VT_DIR/GRUB2/INSTALL/sbin/
|
||||||
|
|
||||||
net_modules_legacy="net tftp http"
|
net_modules_legacy="net tftp http"
|
||||||
all_modules_legacy="file setkey date drivemap blocklist regexp newc vga_text ntldr search at_keyboard usb_keyboard gcry_md5 hashsum gzio xzio lzopio lspci pci ext2 xfs ventoy chain read halt iso9660 linux16 test true sleep reboot echo videotest videoinfo videotest_checksum video_colors video_cirrus video_bochs vga vbe video_fb font video gettext extcmd terminal linux minicmd help configfile tr trig boot biosdisk disk ls tar squash4 password_pbkdf2 all_video png jpeg part_gpt part_msdos fat exfat ntfs loopback gzio normal udf gfxmenu gfxterm gfxterm_background gfxterm_menu"
|
all_modules_legacy="file setkey date drivemap blocklist regexp newc vga_text ntldr search at_keyboard usb_keyboard gcry_md5 hashsum gzio xzio lzopio lspci pci ext2 xfs ventoy chain read halt iso9660 linux16 test true sleep reboot echo videotest videoinfo videotest_checksum video_colors video_cirrus video_bochs vga vbe video_fb font video gettext extcmd terminal linux minicmd help configfile tr trig boot biosdisk disk ls tar squash4 password_pbkdf2 all_video png jpeg part_gpt part_msdos fat exfat ntfs loopback gzio normal udf gfxmenu gfxterm gfxterm_background gfxterm_menu smbios"
|
||||||
|
|
||||||
net_modules_uefi="efinet net tftp http"
|
net_modules_uefi="efinet net tftp http"
|
||||||
all_modules_uefi="file setkey blocklist ventoy test true regexp newc search at_keyboard usb_keyboard gcry_md5 hashsum gzio xzio lzopio ext2 xfs read halt sleep serial terminfo png password_pbkdf2 gcry_sha512 pbkdf2 part_gpt part_msdos ls tar squash4 loopback part_apple minicmd diskfilter linux relocator jpeg iso9660 udf hfsplus halt acpi mmap gfxmenu video_colors trig bitmap_scale gfxterm bitmap font fat exfat ntfs fshelp efifwsetup reboot echo configfile normal terminal gettext chain priority_queue bufio datetime cat extcmd crypto gzio boot all_video efi_gop efi_uga video_bochs video_cirrus video video_fb gfxterm_background gfxterm_menu"
|
all_modules_uefi="file setkey blocklist ventoy test true regexp newc search at_keyboard usb_keyboard gcry_md5 hashsum gzio xzio lzopio ext2 xfs read halt sleep serial terminfo png password_pbkdf2 gcry_sha512 pbkdf2 part_gpt part_msdos ls tar squash4 loopback part_apple minicmd diskfilter linux relocator jpeg iso9660 udf hfsplus halt acpi mmap gfxmenu video_colors trig bitmap_scale gfxterm bitmap font fat exfat ntfs fshelp efifwsetup reboot echo configfile normal terminal gettext chain priority_queue bufio datetime cat extcmd crypto gzio boot all_video efi_gop efi_uga video_bochs video_cirrus video video_fb gfxterm_background gfxterm_menu mouse fwload smbios"
|
||||||
|
|
||||||
all_modules_arm64_uefi="file setkey blocklist ventoy test true regexp newc search gcry_md5 hashsum gzio xzio lzopio ext2 xfs read halt sleep serial terminfo png password_pbkdf2 gcry_sha512 pbkdf2 part_gpt part_msdos ls tar squash4 loopback part_apple minicmd diskfilter linux jpeg iso9660 udf hfsplus halt acpi mmap gfxmenu video_colors trig bitmap_scale gfxterm bitmap font fat exfat ntfs fshelp efifwsetup reboot echo configfile normal terminal gettext chain priority_queue bufio datetime cat extcmd crypto gzio boot all_video efi_gop video video_fb gfxterm_background gfxterm_menu"
|
all_modules_arm64_uefi="file setkey blocklist ventoy test true regexp newc search gcry_md5 hashsum gzio xzio lzopio ext2 xfs read halt sleep serial terminfo png password_pbkdf2 gcry_sha512 pbkdf2 part_gpt part_msdos ls tar squash4 loopback part_apple minicmd diskfilter linux jpeg iso9660 udf hfsplus halt acpi mmap gfxmenu video_colors trig bitmap_scale gfxterm bitmap font fat exfat ntfs fshelp efifwsetup reboot echo configfile normal terminal gettext chain priority_queue bufio datetime cat extcmd crypto gzio boot all_video efi_gop video video_fb gfxterm_background gfxterm_menu"
|
||||||
|
|
||||||
|
@@ -1165,6 +1165,7 @@ main (int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
case GRUB_INSTALL_PLATFORM_MIPS64EL_EFI:
|
case GRUB_INSTALL_PLATFORM_MIPS64EL_EFI:
|
||||||
efi_file = "grubmips64el.efi";
|
efi_file = "grubmips64el.efi";
|
||||||
|
break;
|
||||||
case GRUB_INSTALL_PLATFORM_RISCV32_EFI:
|
case GRUB_INSTALL_PLATFORM_RISCV32_EFI:
|
||||||
efi_file = "grubriscv32.efi";
|
efi_file = "grubriscv32.efi";
|
||||||
break;
|
break;
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||||
|
|
||||||
if $GREP -q '^"$mount_handler"' /init; then
|
if $GREP -q '^"$mount_handler"' /init; then
|
||||||
echo 'use mount_handler ...' >> $VTLOG
|
echo 'use mount_handler1 ...' >> $VTLOG
|
||||||
|
|
||||||
vthookfile=/hooks/archiso
|
vthookfile=/hooks/archiso
|
||||||
|
|
||||||
@@ -37,6 +37,9 @@ if $GREP -q '^"$mount_handler"' /init; then
|
|||||||
if [ -f $vthookfile ]; then
|
if [ -f $vthookfile ]; then
|
||||||
$SED '/while ! poll_device "${dev}"/a\ if /ventoy/busybox/sh /ventoy/hook/arch/ventoy-timeout.sh ${dev}; then break; fi' -i $vthookfile
|
$SED '/while ! poll_device "${dev}"/a\ if /ventoy/busybox/sh /ventoy/hook/arch/ventoy-timeout.sh ${dev}; then break; fi' -i $vthookfile
|
||||||
fi
|
fi
|
||||||
|
elif $GREP -q '^$mount_handler' /init; then
|
||||||
|
echo 'use mount_handler2 ...' >> $VTLOG
|
||||||
|
$SED "/^\$mount_handler/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/arch/ventoy-disk.sh" -i /init
|
||||||
|
|
||||||
elif $GREP -q '^KEEP_SEARCHING' /init; then
|
elif $GREP -q '^KEEP_SEARCHING' /init; then
|
||||||
echo 'KEEP_SEARCHING found ...' >> $VTLOG
|
echo 'KEEP_SEARCHING found ...' >> $VTLOG
|
||||||
|
@@ -225,7 +225,11 @@ ventoy_check_dm_module() {
|
|||||||
|
|
||||||
ventoy_need_dm_patch() {
|
ventoy_need_dm_patch() {
|
||||||
if [ "$VTOY_LINUX_REMOUNT" != "01" ]; then
|
if [ "$VTOY_LINUX_REMOUNT" != "01" ]; then
|
||||||
$BUSYBOX_PATH/false; return
|
if $GREP -q 'VTOY_LINUX_REMOUNT=1' /proc/cmdline; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
$BUSYBOX_PATH/false; return
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $GREP -q 'device-mapper' /proc/devices; then
|
if $GREP -q 'device-mapper' /proc/devices; then
|
||||||
|
@@ -78,8 +78,14 @@ ventoy_unpack_initramfs() {
|
|||||||
rm -f $VTOY_PATH/xzlog
|
rm -f $VTOY_PATH/xzlog
|
||||||
${vtx:5} $vtfile 2> $VTOY_PATH/xzlog | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
|
${vtx:5} $vtfile 2> $VTOY_PATH/xzlog | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
|
||||||
if grep -q 'corrupted data' $VTOY_PATH/xzlog; then
|
if grep -q 'corrupted data' $VTOY_PATH/xzlog; then
|
||||||
echo 'xzcat failed, now try xzcat_musl ...' >> $VTLOG
|
echo 'xzcat failed, now try xzminidec...' >> $VTLOG
|
||||||
xzcat_musl $vtfile | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
|
rm -f $VTOY_PATH/xzlog
|
||||||
|
cat $vtfile | xzminidec 2> $VTOY_PATH/xzlog | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
|
||||||
|
|
||||||
|
if grep -q 'limit' $VTOY_PATH/xzlog; then
|
||||||
|
echo 'xzminidec failed, now try xzcat_musl ...' >> $VTLOG
|
||||||
|
xzcat_musl $vtfile | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
${vtx:5} $vtfile | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
|
${vtx:5} $vtfile | (cpio -idmu 2>>$VTLOG; cat > $vttmp)
|
||||||
|
@@ -52,8 +52,12 @@ ventoy_get_os_type() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# PrimeOS :
|
||||||
|
if $GREP -q 'PrimeOS' /proc/version; then
|
||||||
|
echo 'primeos'; return
|
||||||
|
|
||||||
# Debian :
|
# Debian :
|
||||||
if $GREP -q '[Dd]ebian' /proc/version; then
|
elif $GREP -q '[Dd]ebian' /proc/version; then
|
||||||
echo 'debian'; return
|
echo 'debian'; return
|
||||||
|
|
||||||
# Ubuntu : do the same process with debian
|
# Ubuntu : do the same process with debian
|
||||||
@@ -338,6 +342,24 @@ ventoy_get_os_type() {
|
|||||||
echo "openEuler"; return
|
echo "openEuler"; return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
#special arch based iso file check
|
||||||
|
if [ -f /init ]; then
|
||||||
|
if $GREP -q 'mount_handler' /init; then
|
||||||
|
if [ -d /hooks ]; then
|
||||||
|
if $BUSYBOX_PATH/ls -1 /hooks/ | $GREP -q '.*iso$'; then
|
||||||
|
echo "arch"; return
|
||||||
|
fi
|
||||||
|
elif [ -d /hook ]; then
|
||||||
|
if $BUSYBOX_PATH/ls -1 /hook/ | $GREP -q '.*iso$'; then
|
||||||
|
echo "arch"; return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo "default"
|
echo "default"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
INSTALL/grub/arm64-efi/fwload.mod
Normal file
BIN
INSTALL/grub/arm64-efi/fwload.mod
Normal file
Binary file not shown.
Binary file not shown.
BIN
INSTALL/grub/arm64-efi/mouse.mod
Normal file
BIN
INSTALL/grub/arm64-efi/mouse.mod
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
INSTALL/grub/arm64-efi/smbios.mod
Normal file
BIN
INSTALL/grub/arm64-efi/smbios.mod
Normal file
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
source $prefix/power.cfg
|
source $prefix/power.cfg
|
||||||
|
source $prefix/hwinfo.cfg
|
||||||
source $prefix/keyboard.cfg
|
source $prefix/keyboard.cfg
|
||||||
|
|
||||||
submenu "Resolution Configuration" --class=debug_resolution --class=F5tool {
|
submenu "Resolution Configuration" --class=debug_resolution --class=F5tool {
|
||||||
|
@@ -257,6 +257,10 @@ function distro_specify_initrd_file {
|
|||||||
vt_linux_specify_initrd_file /isolinux/initrd.gz
|
vt_linux_specify_initrd_file /isolinux/initrd.gz
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if vt_str_begin "$vt_volume_id" "QUBES"; then
|
||||||
|
vt_linux_specify_initrd_file /images/pxeboot/initrd.img
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$vt_chosen_size" = "1133375488" ]; then
|
if [ "$vt_chosen_size" = "1133375488" ]; then
|
||||||
if [ -d (loop)/boot/grub/x86_64-efi ]; then
|
if [ -d (loop)/boot/grub/x86_64-efi ]; then
|
||||||
vt_cpio_busybox64 "64h"
|
vt_cpio_busybox64 "64h"
|
||||||
@@ -496,6 +500,8 @@ function ventoy_freebsd_proc {
|
|||||||
if [ "$vt_freebsd_ver" = "xx" ]; then
|
if [ "$vt_freebsd_ver" = "xx" ]; then
|
||||||
if [ -e (loop)/boot/kernel/kernel ]; then
|
if [ -e (loop)/boot/kernel/kernel ]; then
|
||||||
vt_unix_parse_freebsd_ver_elf (loop)/boot/kernel/kernel $vt_freebsd_bit vt_freebsd_ver
|
vt_unix_parse_freebsd_ver_elf (loop)/boot/kernel/kernel $vt_freebsd_bit vt_freebsd_ver
|
||||||
|
elif [ -e (loop)/boot/kernel/kernel.gz ]; then
|
||||||
|
vt_unix_parse_freebsd_ver_elf (loop)/boot/kernel/kernel.gz $vt_freebsd_bit vt_freebsd_ver
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$vt_freebsd_ver" = "xx" ]; then
|
if [ "$vt_freebsd_ver" = "xx" ]; then
|
||||||
@@ -515,8 +521,17 @@ function ventoy_freebsd_proc {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
vt_unix_replace_ko $vt_unix_mod_path (vtunix)/ventoy_unix/$vtFreeBsdDistro/geom_ventoy_ko/$vt_freebsd_ver/$vt_freebsd_bit/geom_ventoy.ko.xz
|
if [ -n "$vt_unix_mod_path" ]; then
|
||||||
vt_unix_replace_conf FreeBSD "${1}${chosen_path}"
|
vt_unix_replace_ko $vt_unix_mod_path (vtunix)/ventoy_unix/$vtFreeBsdDistro/geom_ventoy_ko/$vt_freebsd_ver/$vt_freebsd_bit/geom_ventoy.ko.xz
|
||||||
|
vt_unix_replace_conf FreeBSD "${1}${chosen_path}"
|
||||||
|
elif [ -e (loop)/easyre.ufs.uzip ]; then
|
||||||
|
vt_unix_replace_ko "/boot/grub/i386-pc/linux.mod" (vtunix)/ventoy_unix/$vtFreeBsdDistro/geom_ventoy_ko/$vt_freebsd_ver/$vt_freebsd_bit/geom_ventoy.ko.xz
|
||||||
|
if [ "$grub_platform" = "pc" ]; then
|
||||||
|
vt_unix_replace_grub_conf "/boot/grub/i386-pc/linux.mod" "cd9"
|
||||||
|
else
|
||||||
|
vt_unix_replace_conf FreeBSD "${1}${chosen_path}" "cd9"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function ventoy_dragonfly_proc {
|
function ventoy_dragonfly_proc {
|
||||||
@@ -538,6 +553,8 @@ function ventoy_dragonfly_proc {
|
|||||||
function ventoy_unix_comm_proc {
|
function ventoy_unix_comm_proc {
|
||||||
vt_unix_reset
|
vt_unix_reset
|
||||||
|
|
||||||
|
vt_unix_check_vlnk "${1}${chosen_path}"
|
||||||
|
|
||||||
if [ "$ventoy_compatible" = "NO" ]; then
|
if [ "$ventoy_compatible" = "NO" ]; then
|
||||||
loopback vtunix $vtoy_efi_part/ventoy/ventoy_unix.cpio
|
loopback vtunix $vtoy_efi_part/ventoy/ventoy_unix.cpio
|
||||||
|
|
||||||
@@ -742,7 +759,16 @@ function uefi_linux_menu_func {
|
|||||||
ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
|
ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
|
||||||
ventoy_cli_console
|
ventoy_cli_console
|
||||||
|
|
||||||
|
unset vtGrub2Mode
|
||||||
if vt_check_mode 3; then
|
if vt_check_mode 3; then
|
||||||
|
set vtGrub2Mode=1
|
||||||
|
elif vt_str_begin "$vt_volume_id" "KRD"; then
|
||||||
|
if [ -f (loop)/boot/grub/grub.cfg.sig ]; then
|
||||||
|
set vtGrub2Mode=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$vtGrub2Mode" ]; then
|
||||||
ventoy_debug_pause
|
ventoy_debug_pause
|
||||||
else
|
else
|
||||||
if [ "$VTOY_EFI_ARCH" != "mips" ]; then
|
if [ "$VTOY_EFI_ARCH" != "mips" ]; then
|
||||||
@@ -1290,14 +1316,32 @@ function iso_common_menuentry {
|
|||||||
set vtcompat=1
|
set vtcompat=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# auto memdisk mode for some special ISO files
|
||||||
|
vt_iso_vd_id_parse "${vtoy_iso_part}${vt_chosen_path}"
|
||||||
|
unset vtMemDiskBoot
|
||||||
|
if vt_check_mode 0; then
|
||||||
|
set vtMemDiskBoot=1
|
||||||
|
else
|
||||||
|
if [ "$grub_platform" = "pc" ]; then
|
||||||
|
if vt_iso_vd_id_begin 1 0 "Memtest86+"; then
|
||||||
|
set vtMemDiskBoot=1
|
||||||
|
elif vt_iso_vd_id_begin 0 1 "KolibriOS"; then
|
||||||
|
set vtMemDiskBoot=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
vt_iso_vd_id_clear
|
||||||
|
|
||||||
|
|
||||||
if [ "$grub_platform" = "pc" ]; then
|
if [ "$grub_platform" = "pc" ]; then
|
||||||
if vt_check_mode 0; then
|
if [ -n "$vtMemDiskBoot" ]; then
|
||||||
legacy_iso_memdisk $vtoy_iso_part "$vt_chosen_path"
|
legacy_iso_memdisk $vtoy_iso_part "$vt_chosen_path"
|
||||||
else
|
else
|
||||||
legacy_iso_menu_func $vtoy_iso_part "$vt_chosen_path"
|
legacy_iso_menu_func $vtoy_iso_part "$vt_chosen_path"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if vt_check_mode 0; then
|
if [ -n "$vtMemDiskBoot" ]; then
|
||||||
uefi_iso_memdisk $vtoy_iso_part "$vt_chosen_path"
|
uefi_iso_memdisk $vtoy_iso_part "$vt_chosen_path"
|
||||||
else
|
else
|
||||||
uefi_iso_menu_func $vtoy_iso_part "$vt_chosen_path"
|
uefi_iso_menu_func $vtoy_iso_part "$vt_chosen_path"
|
||||||
@@ -2069,7 +2113,7 @@ function img_unsupport_menuentry {
|
|||||||
#############################################################
|
#############################################################
|
||||||
#############################################################
|
#############################################################
|
||||||
|
|
||||||
set VENTOY_VERSION="1.0.68"
|
set VENTOY_VERSION="1.0.73"
|
||||||
|
|
||||||
#ACPI not compatible with Window7/8, so disable by default
|
#ACPI not compatible with Window7/8, so disable by default
|
||||||
set VTOY_PARAM_NO_ACPI=1
|
set VTOY_PARAM_NO_ACPI=1
|
||||||
@@ -2223,6 +2267,11 @@ else
|
|||||||
terminal_output gfxterm
|
terminal_output gfxterm
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$grub_platform" = "efi" ]; then
|
||||||
|
set mouse_delta=4000
|
||||||
|
# terminal_input --append mouse
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -n "$VTOY_DEFAULT_KBD_LAYOUT" ]; then
|
if [ -n "$VTOY_DEFAULT_KBD_LAYOUT" ]; then
|
||||||
set_keyboard_layout "$VTOY_DEFAULT_KBD_LAYOUT"
|
set_keyboard_layout "$VTOY_DEFAULT_KBD_LAYOUT"
|
||||||
fi
|
fi
|
||||||
@@ -2292,33 +2341,6 @@ export VTOY_HELP_TXT_LANGUAGE
|
|||||||
export VTOY_CHKSUM_FILE_PATH
|
export VTOY_CHKSUM_FILE_PATH
|
||||||
|
|
||||||
|
|
||||||
#special VTOY_DEFAULT_IMAGE process
|
|
||||||
if [ -n "$VTOY_DEFAULT_IMAGE" ]; then
|
|
||||||
if regexp --set 1:vtHotkey --set 2:vtDefault "(F[2-9])>(.*)" "$VTOY_DEFAULT_IMAGE"; then
|
|
||||||
|
|
||||||
set default="$vtDefault"
|
|
||||||
if [ -z "$VTOY_MENU_TIMEOUT" ]; then
|
|
||||||
set timeout=0
|
|
||||||
else
|
|
||||||
set timeout=$VTOY_MENU_TIMEOUT
|
|
||||||
fi
|
|
||||||
|
|
||||||
export timeout
|
|
||||||
export default
|
|
||||||
|
|
||||||
if [ "$vtHotkey" = "F4" ]; then
|
|
||||||
ventoy_localboot
|
|
||||||
elif [ "$vtHotkey" = "F5" ]; then
|
|
||||||
ventoy_diagnosis
|
|
||||||
elif [ "$vtHotkey" = "F6" ]; then
|
|
||||||
ventoy_ext_menu
|
|
||||||
fi
|
|
||||||
|
|
||||||
unset timeout
|
|
||||||
unset default
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
#colect all image files (iso files)
|
#colect all image files (iso files)
|
||||||
set ventoy_img_count=0
|
set ventoy_img_count=0
|
||||||
vt_list_img $vtoy_iso_part ventoy_img_count
|
vt_list_img $vtoy_iso_part ventoy_img_count
|
||||||
@@ -2332,14 +2354,50 @@ if [ $ventoy_img_count -gt 0 ]; then
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ -n "$VTOY_NO_ISO_TIP" ]; then
|
if [ -n "$VTOY_NO_ISO_TIP" ]; then
|
||||||
NO_ISO_MENU="No ISO files found, $VTOY_NO_ISO_TIP"
|
NO_ISO_MENU="No ISO or supported IMG files found, $VTOY_NO_ISO_TIP"
|
||||||
elif [ -n "$VTOY_DEFAULT_SEARCH_ROOT" ]; then
|
elif [ -n "$VTOY_DEFAULT_SEARCH_ROOT" ]; then
|
||||||
NO_ISO_MENU="No ISO files found, please check VTOY_DEFAULT_SEARCH_ROOT"
|
NO_ISO_MENU="No ISO or supported IMG files found, please check VTOY_DEFAULT_SEARCH_ROOT"
|
||||||
else
|
else
|
||||||
NO_ISO_MENU="No ISO files found"
|
NO_ISO_MENU="No ISO or supported IMG files found"
|
||||||
fi
|
fi
|
||||||
menuentry "$NO_ISO_MENU (Press enter to reboot ...)" {
|
menuentry "$NO_ISO_MENU (Press enter to reboot ...)" {
|
||||||
echo -e "\n Rebooting ... "
|
echo -e "\n Rebooting ... "
|
||||||
reboot
|
reboot
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
#special VTOY_DEFAULT_IMAGE process
|
||||||
|
if [ -n "$VTOY_DEFAULT_IMAGE" ]; then
|
||||||
|
if regexp --set 1:vtHotkey --set 2:vtDefault "(F[2-9])>(.*)" "$VTOY_DEFAULT_IMAGE"; then
|
||||||
|
|
||||||
|
set default="$vtDefault"
|
||||||
|
if [ -z "$VTOY_MENU_TIMEOUT" ]; then
|
||||||
|
set timeout=0
|
||||||
|
else
|
||||||
|
set timeout=$VTOY_MENU_TIMEOUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
export timeout
|
||||||
|
export default
|
||||||
|
|
||||||
|
vt_fn_mutex_lock 1
|
||||||
|
|
||||||
|
if [ "$vtHotkey" = "F2" ]; then
|
||||||
|
unset timeout
|
||||||
|
vt_browser_disk
|
||||||
|
elif [ "$vtHotkey" = "F4" ]; then
|
||||||
|
ventoy_localboot
|
||||||
|
elif [ "$vtHotkey" = "F5" ]; then
|
||||||
|
ventoy_diagnosis
|
||||||
|
elif [ "$vtHotkey" = "F6" ]; then
|
||||||
|
ventoy_ext_menu
|
||||||
|
fi
|
||||||
|
|
||||||
|
vt_fn_mutex_lock 0
|
||||||
|
|
||||||
|
unset timeout
|
||||||
|
unset default
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
@@ -1,17 +1,18 @@
|
|||||||
h - Prikazuje ove informacije
|
h - Prikazuje ove informacije
|
||||||
F1 - Memdisk način rada (samo za male WinPE/LiveCD imidž fajlove)
|
F1 - Memdisk način rada (samo za male WinPE/LiveCD imidž fajlove)
|
||||||
F2 - Browse and boot files in local disk
|
F2 - Pokreće imidž fajlove na lokalnom disku
|
||||||
F3 - Mijenja meni između TreeView <-> ListView
|
F3 - Mijenja meni između TreeView <-> ListView
|
||||||
F4 - Pokreće Windows/Linux na lokalnom disku
|
F4 - Pokreće Windows/Linux na lokalnom disku
|
||||||
F5 - Postavke
|
F5 - Alati
|
||||||
F6 - Učitava prilagođen GRUB2 meni
|
F6 - Učitava prilagođen GRUB2 meni
|
||||||
F7 - Mijenja između GUI načina rada <-> TEXT načina rada
|
F7 - Mijenja između GUI <-> TEXT načina rada
|
||||||
|
|
||||||
m - Generira kontrolnu sumu odabranog imidž fajla (md5/sha1/sha256/sha512)
|
m - Generira heš odabranog imidž fajla (md5/sha1/sha256/sha512)
|
||||||
Ctrl + w - WIMBOOT način rada (samo za standardne Windows imidž fajlove)
|
Ctrl+w - WIMBOOT način rada (samo za standardne Windows imidž fajlove)
|
||||||
Ctrl + r - GRUB2 način rada (samo za neke Linux distribucije)
|
Ctrl+r - GRUB2 način rada (samo za neke Linux distribucije)
|
||||||
Ctrl + i - Kompatibilni način rada (samo za testiranje)
|
Ctrl+i - Kompatibilni način rada (samo za testiranje)
|
||||||
Ctrl + u - Load ISO efi driver (Just only for debug, can not be used officially)
|
Ctrl+u - Učitava EFI drajver za imidž fajlove (samo za testiranje)
|
||||||
|
|
||||||
|
|
||||||
Pritisnite ESC za povratak...
|
|
||||||
|
Pritisnite ESC za povratak ......
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
h - この画面を表示する
|
h - この画面を表示する
|
||||||
F1 - 主記憶装置上に記憶域を作成する(容量の小さなWinPE・LiveCD専用)
|
F1 - 主記憶装置上に記憶域を作成する(容量の小さなWinPE・LiveCD専用)
|
||||||
F2 - Browse and boot files in local disk
|
F2 - 手元の記憶装置にある起動ファイルを選択して実行する
|
||||||
F3 - 表示形式を切り替える(一覧 ↔ 階層)
|
F3 - 表示形式を切り替える(一覧 ↔ 階層)
|
||||||
F4 - 手元の記憶装置にあるOSを起動する
|
F4 - 手元の記憶装置にあるWindowsまたはLinuxを起動する
|
||||||
F5 - 諸機能
|
F5 - 諸機能
|
||||||
F6 - Grub2の構成を読み込む
|
F6 - Grub2の構成を読み込む
|
||||||
F7 - 操作形式を切り替える(GUI ↔ CUI)
|
F7 - 操作形式を切り替える(GUI ↔ CUI)
|
||||||
@@ -15,4 +15,4 @@ Ctrl+u - ISO efiドライバーを読み取る(開発用,非公式)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
この画面を閉じるにはESCを押してください
|
この画面を閉じるにはESCを押してください ......
|
||||||
|
18
INSTALL/grub/help/ko_KR.txt
Normal file
18
INSTALL/grub/help/ko_KR.txt
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
h - 이 도움말 정보 표시
|
||||||
|
F1 - Memdisk 모드 (작은 WinPE/LiveCD ISO/IMG 전용)
|
||||||
|
F2 - 로컬 디스크에서 파일 찾아보기 및 부팅
|
||||||
|
F3 - 트리보기 <-> 목록보기 간에 메뉴 모드 전환
|
||||||
|
F4 - 로컬 디스크에서 Windows/Linux 부팅
|
||||||
|
F5 - 유틸리티
|
||||||
|
F6 - 사용자 지정 Grub2 메뉴 로드
|
||||||
|
F7 - GUI 모드 <-> TEXT 모드 간에 전환
|
||||||
|
|
||||||
|
m - 체크섬 이미지 파일 (md5/sha1/sha256/sha512)
|
||||||
|
Ctrl+w - WIMBOOT 모드 (표준 Windows ISO 전용)
|
||||||
|
Ctrl+r - Grub2 모드 (일부 Linux 배포판에만 해당)
|
||||||
|
Ctrl+i - 호환 모드 (디버그 전용)
|
||||||
|
Ctrl+u - ISO eFi 드라이버 로드 (디버그 전용, 공식적으로 사용할 수 없음)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
돌아가려면 ESC를 누르십시오 ......
|
@@ -1,17 +0,0 @@
|
|||||||
h - Приказује ове информације
|
|
||||||
F1 - Memdisk начин рада (само за мале WinPE/LiveCD имиџ фајлове)
|
|
||||||
F2 - Browse and boot files in local disk
|
|
||||||
F3 - Мијења мени између TreeView <-> ListView
|
|
||||||
F4 - Покреће Windows/Linux на локалном диску
|
|
||||||
F5 - Поставке
|
|
||||||
F6 - Учитава прилагођен GRUB2 мени
|
|
||||||
F7 - Мијења између GUI начина рада <-> TEXT начина рада
|
|
||||||
|
|
||||||
m - Генерира контролну суму одабраног имиџ фајла (md5/sha1/sha256/sha512)
|
|
||||||
Ctrl + w - WIMBOOT начин рада (само за стандардне Windows имиџ фајлове)
|
|
||||||
Ctrl + r - GRUB2 начин рада (само за неке Linux дистрибуције)
|
|
||||||
Ctrl + i - Компатибилни начин рада (само за тестиранје)
|
|
||||||
Ctrl + u - Load ISO efi driver (Just only for debug, can not be used officially)
|
|
||||||
|
|
||||||
|
|
||||||
Притисните ESC за повратак...
|
|
18
INSTALL/grub/help/sr_RS.txt
Normal file
18
INSTALL/grub/help/sr_RS.txt
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
h - Приказује ове информације
|
||||||
|
F1 - Memdisk начин рада (само за мале WinPE/LiveCD имиџ фајлове)
|
||||||
|
F2 - Покреће имиџ фајлове на локалном диску
|
||||||
|
F3 - Мења мени између TreeView <-> ListView
|
||||||
|
F4 - Покреће Windows/Linux на локалном диску
|
||||||
|
F5 - Алати
|
||||||
|
F6 - Учитава прилагођен GRUB2 мени
|
||||||
|
F7 - Мења између GUI <-> TEXT начина рада
|
||||||
|
|
||||||
|
m - Генерира хеш одабраног имиџ фајла (md5/sha1/sha256/sha512)
|
||||||
|
Ctrl+w - WIMBOOT начин рада (само за стандардне Windows имиџ фајлове)
|
||||||
|
Ctrl+r - GRUB2 начин рада (само за неке Linux дистрибуције)
|
||||||
|
Ctrl+i - Компатибилни начин рада (само за тестирање)
|
||||||
|
Ctrl+u - Учитава EFI драјвер за имиџ фајлове (само за тестирање)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Притисните ESC за повратак ......
|
@@ -1,17 +0,0 @@
|
|||||||
h - Prikazuje ove informacije
|
|
||||||
F1 - Memdisk način rada (samo za male WinPE/LiveCD imidž fajlove)
|
|
||||||
F2 - Browse and boot files in local disk
|
|
||||||
F3 - Mijenja meni između TreeView <-> ListView
|
|
||||||
F4 - Pokreće Windows/Linux na lokalnom disku
|
|
||||||
F5 - Postavke
|
|
||||||
F6 - Učitava prilagođen GRUB2 meni
|
|
||||||
F7 - Mijenja između GUI načina rada <-> TEXT načina rada
|
|
||||||
|
|
||||||
m - Generira kontrolnu sumu odabranog imidž fajla (md5/sha1/sha256/sha512)
|
|
||||||
Ctrl + w - WIMBOOT način rada (samo za standardne Windows imidž fajlove)
|
|
||||||
Ctrl + r - GRUB2 način rada (samo za neke Linux distribucije)
|
|
||||||
Ctrl + i - Kompatibilni način rada (samo za testiranje)
|
|
||||||
Ctrl+u - Load ISO efi driver (Just only for debug, can not be used officially)
|
|
||||||
|
|
||||||
|
|
||||||
Pritisnite ESC za povratak...
|
|
@@ -1,6 +1,6 @@
|
|||||||
h - Yardım bilgilerini göster
|
h - Yardım bilgilerini göster
|
||||||
F1 - Memdisk Modu başlatır(Yalnızca küçük WinPE/LiveCD ISO/IMG ler için bu modu kullanabilirsiniz)
|
F1 - Memdisk Modu başlatır(Yalnızca küçük WinPE/LiveCD ISO/IMG ler için bu modu kullanabilirsiniz)
|
||||||
F2 - Browse and boot files in local disk
|
F2 - Yerel diskteki dosyalara GÖZAT ve ÖNYÜKLE'meyi sağlar
|
||||||
F3 - Ventoy Menü modu olarak,Klasör görünümü(Treeview) ile Liste görünümü(ListView) arasında geçiş yapmayı sağlar.
|
F3 - Ventoy Menü modu olarak,Klasör görünümü(Treeview) ile Liste görünümü(ListView) arasında geçiş yapmayı sağlar.
|
||||||
F4 - Bilgisayarınızda yüklü olan Windows yada Linux işletim sistemini, sabit diskten başlatır.
|
F4 - Bilgisayarınızda yüklü olan Windows yada Linux işletim sistemini, sabit diskten başlatır.
|
||||||
F5 - Ventoy Araçlar menüsü
|
F5 - Ventoy Araçlar menüsü
|
||||||
|
61
INSTALL/grub/hwinfo.cfg
Normal file
61
INSTALL/grub/hwinfo.cfg
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
menuentry 'Hardware Information' --class=debug_hwinfo --class=F5tool {
|
||||||
|
smbios -t 4 -s 0x10 --set=cpu_brand
|
||||||
|
|
||||||
|
set system_vendor="-";
|
||||||
|
smbios -t 1 -s 0x04 --set=system_vendor;
|
||||||
|
set system_product="-";
|
||||||
|
smbios -t 1 -s 0x05 --set=system_product;
|
||||||
|
set system_version="-";
|
||||||
|
smbios -t 1 -s 0x06 --set=system_version;
|
||||||
|
|
||||||
|
set board_vendor="-";
|
||||||
|
smbios -t 2 -s 0x04 --set=board_vendor;
|
||||||
|
set board_product="-";
|
||||||
|
smbios -t 2 -s 0x05 --set=board_product;
|
||||||
|
set board_version="-";
|
||||||
|
smbios -t 2 -s 0x06 --set=board_version;
|
||||||
|
|
||||||
|
set bios_vendor="-";
|
||||||
|
smbios -t 0 -s 0x04 --set=bios_vendor;
|
||||||
|
set bios_version="-";
|
||||||
|
smbios -t 0 -s 0x05 --set=bios_ver;
|
||||||
|
set bios_date="-";
|
||||||
|
smbios -t 0 -s 0x08 --set=bios_date;
|
||||||
|
set bios_size="-";
|
||||||
|
smbios -t 0 -b 0x09 --set=bios_size;
|
||||||
|
|
||||||
|
|
||||||
|
echo "Platform $grub_cpu-$grub_platform"
|
||||||
|
if [ "$grub_platform" != "pc" ]; then
|
||||||
|
echo "UEFI Version $grub_uefi_version"
|
||||||
|
if vt_check_secureboot_var; then
|
||||||
|
echo "Secure Boot Enabled"
|
||||||
|
else
|
||||||
|
echo "Secure Boot Disabled"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "CPU Model $cpu_brand"
|
||||||
|
echo "Physical RAM $grub_total_ram MB"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Manufacture $system_vendor"
|
||||||
|
echo "Product Name $system_product"
|
||||||
|
echo "Version $system_version"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Board Manufacture $board_vendor"
|
||||||
|
echo "Board Name $board_product"
|
||||||
|
echo "Board Version $board_version"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "BIOS Manufacture $bios_vendor"
|
||||||
|
echo "BIOS Version $bios_ver"
|
||||||
|
echo "BIOS Date $bios_date"
|
||||||
|
echo "BIOS ROM Size $bios_size"
|
||||||
|
|
||||||
|
|
||||||
|
echo -e "\n\n\npress ENTER to exit ..."
|
||||||
|
read vtInputKey
|
||||||
|
}
|
@@ -12,6 +12,8 @@
|
|||||||
*extract_syslinux_entries_source: syslinuxcfg
|
*extract_syslinux_entries_source: syslinuxcfg
|
||||||
*file: file
|
*file: file
|
||||||
*functional_test: functional_test
|
*functional_test: functional_test
|
||||||
|
*fwconnect: fwload
|
||||||
|
*fwload: fwload
|
||||||
*gettext: gettext
|
*gettext: gettext
|
||||||
*hashsum: hashsum
|
*hashsum: hashsum
|
||||||
*hdparm: hdparm
|
*hdparm: hdparm
|
||||||
@@ -50,6 +52,7 @@
|
|||||||
*sha256sum: hashsum
|
*sha256sum: hashsum
|
||||||
*sha512sum: hashsum
|
*sha512sum: hashsum
|
||||||
*sleep: sleep
|
*sleep: sleep
|
||||||
|
*smbios: smbios
|
||||||
*submenu: normal
|
*submenu: normal
|
||||||
*syslinux_configfile: syslinuxcfg
|
*syslinux_configfile: syslinuxcfg
|
||||||
*syslinux_source: syslinuxcfg
|
*syslinux_source: syslinuxcfg
|
||||||
|
Binary file not shown.
@@ -26,7 +26,7 @@ sfs: fshelp
|
|||||||
reiserfs: fshelp
|
reiserfs: fshelp
|
||||||
part_sunpc:
|
part_sunpc:
|
||||||
zstd:
|
zstd:
|
||||||
gfxmenu: trig video_colors gfxterm bitmap_scale font normal video bitmap
|
gfxmenu: video_colors trig gfxterm bitmap_scale font normal video bitmap
|
||||||
backtrace:
|
backtrace:
|
||||||
jfs:
|
jfs:
|
||||||
help: extcmd normal
|
help: extcmd normal
|
||||||
@@ -49,6 +49,7 @@ test_blockarg: extcmd normal
|
|||||||
true:
|
true:
|
||||||
affs: fshelp
|
affs: fshelp
|
||||||
iso9660: fshelp
|
iso9660: fshelp
|
||||||
|
smbios: extcmd
|
||||||
exfat: fshelp
|
exfat: fshelp
|
||||||
setjmp_test: setjmp functional_test
|
setjmp_test: setjmp functional_test
|
||||||
gfxterm: font video
|
gfxterm: font video
|
||||||
@@ -120,7 +121,7 @@ ehci: cs5536 usb boot
|
|||||||
crypto:
|
crypto:
|
||||||
part_bsd: part_msdos
|
part_bsd: part_msdos
|
||||||
cs5536:
|
cs5536:
|
||||||
ventoy: fshelp ext2 elf btrfs font crypto gcry_md5 exfat udf div extcmd datetime normal video gcry_sha1 iso9660
|
ventoy: ext2 fshelp elf btrfs font crypto gcry_md5 exfat udf div extcmd datetime normal video gcry_sha1 mmap iso9660
|
||||||
gcry_sha512: crypto
|
gcry_sha512: crypto
|
||||||
password: crypto normal
|
password: crypto normal
|
||||||
fshelp:
|
fshelp:
|
||||||
@@ -181,6 +182,7 @@ usbtest: usb
|
|||||||
relocator: mmap
|
relocator: mmap
|
||||||
acpi: extcmd mmap
|
acpi: extcmd mmap
|
||||||
tga: bufio bitmap
|
tga: bufio bitmap
|
||||||
|
fwload: extcmd
|
||||||
reboot:
|
reboot:
|
||||||
serial: extcmd terminfo
|
serial: extcmd terminfo
|
||||||
zfscrypt: crypto pbkdf2 extcmd zfs gcry_sha1 gcry_rijndael
|
zfscrypt: crypto pbkdf2 extcmd zfs gcry_sha1 gcry_rijndael
|
||||||
@@ -226,6 +228,7 @@ gcry_sha256: crypto
|
|||||||
ls: extcmd normal
|
ls: extcmd normal
|
||||||
usbserial_common: serial usb
|
usbserial_common: serial usb
|
||||||
ntfscomp: ntfs
|
ntfscomp: ntfs
|
||||||
|
mouse:
|
||||||
lzopio: crypto
|
lzopio: crypto
|
||||||
video_cirrus: video video_fb
|
video_cirrus: video video_fb
|
||||||
hello: extcmd
|
hello: extcmd
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
INSTALL/grub/i386-efi/smbios.mod
Normal file
BIN
INSTALL/grub/i386-efi/smbios.mod
Normal file
Binary file not shown.
@@ -1,4 +1,5 @@
|
|||||||
iat_keyboard: at_keyboard
|
iat_keyboard: at_keyboard
|
||||||
|
imouse: mouse
|
||||||
iserial: serial
|
iserial: serial
|
||||||
iserial_*: serial
|
iserial_*: serial
|
||||||
oaudio: morse
|
oaudio: morse
|
||||||
|
@@ -54,6 +54,7 @@
|
|||||||
*sha256sum: hashsum
|
*sha256sum: hashsum
|
||||||
*sha512sum: hashsum
|
*sha512sum: hashsum
|
||||||
*sleep: sleep
|
*sleep: sleep
|
||||||
|
*smbios: smbios
|
||||||
*submenu: normal
|
*submenu: normal
|
||||||
*syslinux_configfile: syslinuxcfg
|
*syslinux_configfile: syslinuxcfg
|
||||||
*syslinux_source: syslinuxcfg
|
*syslinux_source: syslinuxcfg
|
||||||
|
Binary file not shown.
@@ -26,7 +26,7 @@ sfs: fshelp
|
|||||||
reiserfs: fshelp
|
reiserfs: fshelp
|
||||||
part_sunpc:
|
part_sunpc:
|
||||||
zstd:
|
zstd:
|
||||||
gfxmenu: trig video_colors gfxterm bitmap_scale font normal video bitmap
|
gfxmenu: video_colors trig gfxterm bitmap_scale font normal video bitmap
|
||||||
backtrace:
|
backtrace:
|
||||||
jfs:
|
jfs:
|
||||||
help: extcmd normal
|
help: extcmd normal
|
||||||
@@ -50,6 +50,7 @@ test_blockarg: extcmd normal
|
|||||||
true:
|
true:
|
||||||
affs: fshelp
|
affs: fshelp
|
||||||
iso9660: fshelp
|
iso9660: fshelp
|
||||||
|
smbios: extcmd acpi
|
||||||
exfat: fshelp
|
exfat: fshelp
|
||||||
setjmp_test: setjmp functional_test
|
setjmp_test: setjmp functional_test
|
||||||
gfxterm: font video
|
gfxterm: font video
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
INSTALL/grub/i386-pc/smbios.mod
Normal file
BIN
INSTALL/grub/i386-pc/smbios.mod
Normal file
Binary file not shown.
Binary file not shown.
BIN
INSTALL/grub/mips64el-efi/fwload.mod
Normal file
BIN
INSTALL/grub/mips64el-efi/fwload.mod
Normal file
Binary file not shown.
Binary file not shown.
BIN
INSTALL/grub/mips64el-efi/mouse.mod
Normal file
BIN
INSTALL/grub/mips64el-efi/mouse.mod
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
INSTALL/grub/mips64el-efi/smbios.mod
Normal file
BIN
INSTALL/grub/mips64el-efi/smbios.mod
Normal file
Binary file not shown.
Binary file not shown.
@@ -10,6 +10,14 @@ submenu "Power" --class=debug_power --class=F5tool {
|
|||||||
sleep 1
|
sleep 1
|
||||||
halt
|
halt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if [ "$grub_platform" != "pc" ]; then
|
||||||
|
menuentry 'Reboot to EFI setup' --class=debug_efisetup --class=debug_power --class=F5tool {
|
||||||
|
echo -e '\n\nRebooting to enter UEFI firmware setup ... \n'
|
||||||
|
sleep 1
|
||||||
|
fwsetup
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
menuentry 'Return to previous menu [Esc]' --class=vtoyret VTOY_RET {
|
menuentry 'Return to previous menu [Esc]' --class=vtoyret VTOY_RET {
|
||||||
echo 'Return ...'
|
echo 'Return ...'
|
||||||
|
@@ -12,6 +12,8 @@
|
|||||||
*extract_syslinux_entries_source: syslinuxcfg
|
*extract_syslinux_entries_source: syslinuxcfg
|
||||||
*file: file
|
*file: file
|
||||||
*functional_test: functional_test
|
*functional_test: functional_test
|
||||||
|
*fwconnect: fwload
|
||||||
|
*fwload: fwload
|
||||||
*gettext: gettext
|
*gettext: gettext
|
||||||
*hashsum: hashsum
|
*hashsum: hashsum
|
||||||
*hdparm: hdparm
|
*hdparm: hdparm
|
||||||
@@ -50,6 +52,7 @@
|
|||||||
*sha256sum: hashsum
|
*sha256sum: hashsum
|
||||||
*sha512sum: hashsum
|
*sha512sum: hashsum
|
||||||
*sleep: sleep
|
*sleep: sleep
|
||||||
|
*smbios: smbios
|
||||||
*submenu: normal
|
*submenu: normal
|
||||||
*syslinux_configfile: syslinuxcfg
|
*syslinux_configfile: syslinuxcfg
|
||||||
*syslinux_source: syslinuxcfg
|
*syslinux_source: syslinuxcfg
|
||||||
|
Binary file not shown.
@@ -26,7 +26,7 @@ sfs: fshelp
|
|||||||
reiserfs: fshelp
|
reiserfs: fshelp
|
||||||
part_sunpc:
|
part_sunpc:
|
||||||
zstd:
|
zstd:
|
||||||
gfxmenu: trig video_colors gfxterm bitmap_scale font normal video bitmap
|
gfxmenu: video_colors trig gfxterm bitmap_scale font normal video bitmap
|
||||||
backtrace:
|
backtrace:
|
||||||
jfs:
|
jfs:
|
||||||
help: extcmd normal
|
help: extcmd normal
|
||||||
@@ -49,6 +49,7 @@ test_blockarg: extcmd normal
|
|||||||
true:
|
true:
|
||||||
affs: fshelp
|
affs: fshelp
|
||||||
iso9660: fshelp
|
iso9660: fshelp
|
||||||
|
smbios: extcmd
|
||||||
exfat: fshelp
|
exfat: fshelp
|
||||||
setjmp_test: setjmp functional_test
|
setjmp_test: setjmp functional_test
|
||||||
gfxterm: font video
|
gfxterm: font video
|
||||||
@@ -120,7 +121,7 @@ ehci: cs5536 usb boot
|
|||||||
crypto:
|
crypto:
|
||||||
part_bsd: part_msdos
|
part_bsd: part_msdos
|
||||||
cs5536:
|
cs5536:
|
||||||
ventoy: fshelp ext2 elf btrfs font crypto gcry_md5 exfat udf div extcmd datetime normal video gcry_sha1 iso9660
|
ventoy: ext2 fshelp elf btrfs font crypto gcry_md5 exfat udf div extcmd datetime normal video gcry_sha1 mmap iso9660
|
||||||
gcry_sha512: crypto
|
gcry_sha512: crypto
|
||||||
password: crypto normal
|
password: crypto normal
|
||||||
fshelp:
|
fshelp:
|
||||||
@@ -183,6 +184,7 @@ relocator: mmap
|
|||||||
acpi: extcmd mmap
|
acpi: extcmd mmap
|
||||||
tga: bufio bitmap
|
tga: bufio bitmap
|
||||||
reboot:
|
reboot:
|
||||||
|
fwload: extcmd
|
||||||
serial: extcmd terminfo
|
serial: extcmd terminfo
|
||||||
zfscrypt: crypto pbkdf2 extcmd zfs gcry_sha1 gcry_rijndael
|
zfscrypt: crypto pbkdf2 extcmd zfs gcry_sha1 gcry_rijndael
|
||||||
efi_uga: video video_fb
|
efi_uga: video video_fb
|
||||||
@@ -227,6 +229,7 @@ gcry_sha256: crypto
|
|||||||
ls: extcmd normal
|
ls: extcmd normal
|
||||||
usbserial_common: serial usb
|
usbserial_common: serial usb
|
||||||
ntfscomp: ntfs
|
ntfscomp: ntfs
|
||||||
|
mouse:
|
||||||
lzopio: crypto
|
lzopio: crypto
|
||||||
video_cirrus: video video_fb
|
video_cirrus: video video_fb
|
||||||
hello: extcmd
|
hello: extcmd
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
INSTALL/grub/x86_64-efi/smbios.mod
Normal file
BIN
INSTALL/grub/x86_64-efi/smbios.mod
Normal file
Binary file not shown.
@@ -1,4 +1,5 @@
|
|||||||
iat_keyboard: at_keyboard
|
iat_keyboard: at_keyboard
|
||||||
|
imouse: mouse
|
||||||
iserial: serial
|
iserial: serial
|
||||||
iserial_*: serial
|
iserial_*: serial
|
||||||
oaudio: morse
|
oaudio: morse
|
||||||
|
@@ -3,11 +3,11 @@
|
|||||||
. ./tool/ventoy_lib.sh
|
. ./tool/ventoy_lib.sh
|
||||||
|
|
||||||
print_usage() {
|
print_usage() {
|
||||||
|
|
||||||
echo 'Usage: Ventoy2Disk.sh CMD [ OPTION ] /dev/sdX'
|
echo 'Usage: Ventoy2Disk.sh CMD [ OPTION ] /dev/sdX'
|
||||||
echo ' CMD:'
|
echo ' CMD:'
|
||||||
echo ' -i install Ventoy to sdX (fails if disk already installed with Ventoy)'
|
echo ' -i install Ventoy to sdX (fails if disk already installed with Ventoy)'
|
||||||
echo ' -I force install Ventoy to sdX (no matter installed or not)'
|
echo ' -I force install Ventoy to sdX (no matter if installed or not)'
|
||||||
echo ' -u update Ventoy in sdX'
|
echo ' -u update Ventoy in sdX'
|
||||||
echo ' -l list Ventoy information in sdX'
|
echo ' -l list Ventoy information in sdX'
|
||||||
echo ''
|
echo ''
|
||||||
@@ -67,7 +67,7 @@ while [ -n "$1" ]; do
|
|||||||
DISK=$(readlink -e -n "$DISK")
|
DISK=$(readlink -e -n "$DISK")
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -113,19 +113,19 @@ if [ "$MODE" = "list" ]; then
|
|||||||
version=$(get_disk_ventoy_version $DISK)
|
version=$(get_disk_ventoy_version $DISK)
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo "Ventoy Version in Disk: $version"
|
echo "Ventoy Version in Disk: $version"
|
||||||
|
|
||||||
vtPart1Type=$(dd if=$DISK bs=1 count=1 skip=450 status=none | hexdump -n1 -e '1/1 "%02X"')
|
vtPart1Type=$(dd if=$DISK bs=1 count=1 skip=450 status=none | hexdump -n1 -e '1/1 "%02X"')
|
||||||
if [ "$vtPart1Type" = "EE" ]; then
|
if [ "$vtPart1Type" = "EE" ]; then
|
||||||
echo "Disk Partition Style : GPT"
|
echo "Disk Partition Style : GPT"
|
||||||
else
|
else
|
||||||
echo "Disk Partition Style : MBR"
|
echo "Disk Partition Style : MBR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if check_disk_secure_boot $DISK; then
|
if check_disk_secure_boot $DISK; then
|
||||||
echo "Secure Boot Support : YES"
|
echo "Secure Boot Support : YES"
|
||||||
else
|
else
|
||||||
echo "Secure Boot Support : NO"
|
echo "Secure Boot Support : NO"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Ventoy Version: NA"
|
echo "Ventoy Version: NA"
|
||||||
fi
|
fi
|
||||||
@@ -149,7 +149,7 @@ if swapon --help 2>&1 | grep -q '^ \-s,'; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#check access
|
#check access
|
||||||
if dd if="$DISK" of=/dev/null bs=1 count=1 >/dev/null 2>&1; then
|
if dd if="$DISK" of=/dev/null bs=1 count=1 >/dev/null 2>&1; then
|
||||||
vtdebug "root permission check ok ..."
|
vtdebug "root permission check ok ..."
|
||||||
else
|
else
|
||||||
@@ -165,7 +165,7 @@ if [ -d ./tmp_mnt ]; then
|
|||||||
umount ./tmp_mnt >/dev/null 2>&1
|
umount ./tmp_mnt >/dev/null 2>&1
|
||||||
rm -rf ./tmp_mnt
|
rm -rf ./tmp_mnt
|
||||||
if [ -d ./tmp_mnt ]; then
|
if [ -d ./tmp_mnt ]; then
|
||||||
vterr "tmp_mnt directory exits, please delete it first."
|
vterr "tmp_mnt directory exists, please delete it first."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -192,7 +192,7 @@ if [ "$MODE" = "install" -a -z "$NONDESTRUCTIVE" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
version=$(get_disk_ventoy_version $DISK)
|
version=$(get_disk_ventoy_version $DISK)
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
if [ -z "$FORCE" ]; then
|
if [ -z "$FORCE" ]; then
|
||||||
@@ -203,7 +203,7 @@ if [ "$MODE" = "install" -a -z "$NONDESTRUCTIVE" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
disk_sector_num=$(cat /sys/block/${DISK#/dev/}/size)
|
disk_sector_num=$(cat /sys/block/${DISK#/dev/}/size)
|
||||||
disk_size_gb=$(expr $disk_sector_num / 2097152)
|
disk_size_gb=$(expr $disk_sector_num / 2097152)
|
||||||
|
|
||||||
@@ -215,7 +215,7 @@ if [ "$MODE" = "install" -a -z "$NONDESTRUCTIVE" ]; then
|
|||||||
if [ -n "$RESERVE_SPACE" ]; then
|
if [ -n "$RESERVE_SPACE" ]; then
|
||||||
sum_size_mb=$(expr $RESERVE_SIZE_MB + $VENTOY_PART_SIZE_MB)
|
sum_size_mb=$(expr $RESERVE_SIZE_MB + $VENTOY_PART_SIZE_MB)
|
||||||
reserve_sector_num=$(expr $sum_size_mb \* 2048)
|
reserve_sector_num=$(expr $sum_size_mb \* 2048)
|
||||||
|
|
||||||
if [ $disk_sector_num -le $reserve_sector_num ]; then
|
if [ $disk_sector_num -le $reserve_sector_num ]; then
|
||||||
vterr "Can't reserve $RESERVE_SIZE_MB MB space from $DISK"
|
vterr "Can't reserve $RESERVE_SIZE_MB MB space from $DISK"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -225,12 +225,12 @@ if [ "$MODE" = "install" -a -z "$NONDESTRUCTIVE" ]; then
|
|||||||
#Print disk info
|
#Print disk info
|
||||||
echo "Disk : $DISK"
|
echo "Disk : $DISK"
|
||||||
parted -s $DISK p 2>&1 | grep Model
|
parted -s $DISK p 2>&1 | grep Model
|
||||||
echo "Size : $disk_size_gb GB"
|
echo "Size : $disk_size_gb GB"
|
||||||
if [ -n "$VTGPT" ]; then
|
if [ -n "$VTGPT" ]; then
|
||||||
echo "Style: GPT"
|
echo "Style: GPT"
|
||||||
else
|
else
|
||||||
echo "Style: MBR"
|
echo "Style: MBR"
|
||||||
fi
|
fi
|
||||||
echo ''
|
echo ''
|
||||||
|
|
||||||
if [ -n "$RESERVE_SPACE" ]; then
|
if [ -n "$RESERVE_SPACE" ]; then
|
||||||
@@ -259,7 +259,7 @@ if [ "$MODE" = "install" -a -z "$NONDESTRUCTIVE" ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $disk_sector_num -le $VENTOY_SECTOR_NUM ]; then
|
if [ $disk_sector_num -le $VENTOY_SECTOR_NUM ]; then
|
||||||
vterr "No enough space in disk $DISK"
|
vterr "No enough space in disk $DISK"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -290,8 +290,8 @@ if [ "$MODE" = "install" -a -z "$NONDESTRUCTIVE" ]; then
|
|||||||
cluster_sectors=64
|
cluster_sectors=64
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PART1=$(get_disk_part_name $DISK 1)
|
PART1=$(get_disk_part_name $DISK 1)
|
||||||
PART2=$(get_disk_part_name $DISK 2)
|
PART2=$(get_disk_part_name $DISK 2)
|
||||||
|
|
||||||
#clean part2
|
#clean part2
|
||||||
dd status=none conv=fsync if=/dev/zero of=$DISK bs=512 count=32 seek=$part2_start_sector
|
dd status=none conv=fsync if=/dev/zero of=$DISK bs=512 count=32 seek=$part2_start_sector
|
||||||
@@ -315,11 +315,11 @@ if [ "$MODE" = "install" -a -z "$NONDESTRUCTIVE" ]; then
|
|||||||
vterr "${PART1} NOT exist"
|
vterr "${PART1} NOT exist"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
vtinfo "writing data to disk ..."
|
vtinfo "writing data to disk ..."
|
||||||
dd status=none conv=fsync if=./boot/boot.img of=$DISK bs=1 count=446
|
dd status=none conv=fsync if=./boot/boot.img of=$DISK bs=1 count=446
|
||||||
|
|
||||||
if [ -n "$VTGPT" ]; then
|
if [ -n "$VTGPT" ]; then
|
||||||
echo -en '\x22' | dd status=none of=$DISK conv=fsync bs=1 count=1 seek=92
|
echo -en '\x22' | dd status=none of=$DISK conv=fsync bs=1 count=1 seek=92
|
||||||
xzcat ./boot/core.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=2014 seek=34
|
xzcat ./boot/core.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=2014 seek=34
|
||||||
echo -en '\x23' | dd of=$DISK conv=fsync bs=1 count=1 seek=17908 status=none
|
echo -en '\x23' | dd of=$DISK conv=fsync bs=1 count=1 seek=17908 status=none
|
||||||
else
|
else
|
||||||
@@ -328,23 +328,24 @@ if [ "$MODE" = "install" -a -z "$NONDESTRUCTIVE" ]; then
|
|||||||
|
|
||||||
# check and umount
|
# check and umount
|
||||||
check_umount_disk "$DISK"
|
check_umount_disk "$DISK"
|
||||||
|
|
||||||
xzcat ./ventoy/ventoy.disk.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=$VENTOY_SECTOR_NUM seek=$part2_start_sector
|
xzcat ./ventoy/ventoy.disk.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=$VENTOY_SECTOR_NUM seek=$part2_start_sector
|
||||||
|
|
||||||
#test UUID
|
#test UUID
|
||||||
testUUIDStr=$(vtoy_gen_uuid | hexdump -C)
|
testUUIDStr=$(vtoy_gen_uuid | hexdump -C)
|
||||||
vtdebug "test uuid: $testUUIDStr"
|
vtdebug "test uuid: $testUUIDStr"
|
||||||
|
|
||||||
#disk uuid
|
#disk uuid
|
||||||
vtoy_gen_uuid | dd status=none conv=fsync of=${DISK} seek=384 bs=1 count=16
|
vtoy_gen_uuid | dd status=none conv=fsync of=${DISK} seek=384 bs=1 count=16
|
||||||
|
|
||||||
#disk signature
|
#disk signature
|
||||||
vtoy_gen_uuid | dd status=none conv=fsync of=${DISK} skip=12 seek=440 bs=1 count=4
|
vtoy_gen_uuid | dd status=none conv=fsync of=${DISK} skip=12 seek=440 bs=1 count=4
|
||||||
|
|
||||||
vtinfo "sync data ..."
|
vtinfo "sync data ..."
|
||||||
sync
|
sync
|
||||||
|
|
||||||
vtinfo "esp partition processing ..."
|
vtinfo "esp partition processing ..."
|
||||||
|
|
||||||
if [ "$SECUREBOOT" != "YES" ]; then
|
if [ "$SECUREBOOT" != "YES" ]; then
|
||||||
sleep 2
|
sleep 2
|
||||||
check_umount_disk "$DISK"
|
check_umount_disk "$DISK"
|
||||||
@@ -551,7 +552,7 @@ else
|
|||||||
vtinfo "Upgrade operation is safe, all the data in the 1st partition (iso files and other) will be unchanged!"
|
vtinfo "Upgrade operation is safe, all the data in the 1st partition (iso files and other) will be unchanged!"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
read -p "Update Ventoy $oldver ===> $curver Continue? (y/n)" Answer
|
read -p "Update Ventoy $oldver ===> $curver Continue? (y/n) " Answer
|
||||||
if [ "$Answer" != "y" ]; then
|
if [ "$Answer" != "y" ]; then
|
||||||
if [ "$Answer" != "Y" ]; then
|
if [ "$Answer" != "Y" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
@@ -561,13 +562,13 @@ else
|
|||||||
PART2=$(get_disk_part_name $DISK 2)
|
PART2=$(get_disk_part_name $DISK 2)
|
||||||
SHORT_PART2=${PART2#/dev/}
|
SHORT_PART2=${PART2#/dev/}
|
||||||
part2_start=$(cat /sys/class/block/$SHORT_PART2/start)
|
part2_start=$(cat /sys/class/block/$SHORT_PART2/start)
|
||||||
|
|
||||||
PART1_TYPE=$(dd if=$DISK bs=1 count=1 skip=450 status=none | hexdump -n1 -e '1/1 "%02X"')
|
PART1_TYPE=$(dd if=$DISK bs=1 count=1 skip=450 status=none | hexdump -n1 -e '1/1 "%02X"')
|
||||||
|
|
||||||
#reserve disk uuid
|
#reserve disk uuid
|
||||||
rm -f ./diskuuid.bin
|
rm -f ./diskuuid.bin
|
||||||
dd status=none conv=fsync if=${DISK} skip=384 bs=1 count=16 of=./diskuuid.bin
|
dd status=none conv=fsync if=${DISK} skip=384 bs=1 count=16 of=./diskuuid.bin
|
||||||
|
|
||||||
dd status=none conv=fsync if=./boot/boot.img of=$DISK bs=1 count=440
|
dd status=none conv=fsync if=./boot/boot.img of=$DISK bs=1 count=440
|
||||||
dd status=none conv=fsync if=./diskuuid.bin of=$DISK bs=1 count=16 seek=384
|
dd status=none conv=fsync if=./diskuuid.bin of=$DISK bs=1 count=16 seek=384
|
||||||
rm -f ./diskuuid.bin
|
rm -f ./diskuuid.bin
|
||||||
@@ -577,16 +578,16 @@ else
|
|||||||
dd status=none conv=fsync if=${DISK} skip=2040 bs=512 count=8 of=./rsvdata.bin
|
dd status=none conv=fsync if=${DISK} skip=2040 bs=512 count=8 of=./rsvdata.bin
|
||||||
|
|
||||||
if [ "$PART1_TYPE" = "EE" ]; then
|
if [ "$PART1_TYPE" = "EE" ]; then
|
||||||
vtdebug "This is GPT partition style ..."
|
vtdebug "This is GPT partition style ..."
|
||||||
echo -en '\x22' | dd status=none of=$DISK conv=fsync bs=1 count=1 seek=92
|
echo -en '\x22' | dd status=none of=$DISK conv=fsync bs=1 count=1 seek=92
|
||||||
xzcat ./boot/core.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=2014 seek=34
|
xzcat ./boot/core.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=2014 seek=34
|
||||||
echo -en '\x23' | dd of=$DISK conv=fsync bs=1 count=1 seek=17908 status=none
|
echo -en '\x23' | dd of=$DISK conv=fsync bs=1 count=1 seek=17908 status=none
|
||||||
else
|
else
|
||||||
vtdebug "This is MBR partition style ..."
|
vtdebug "This is MBR partition style ..."
|
||||||
|
|
||||||
PART1_ACTIVE=$(dd if=$DISK bs=1 count=1 skip=446 status=none | hexdump -n1 -e '1/1 "%02X"')
|
PART1_ACTIVE=$(dd if=$DISK bs=1 count=1 skip=446 status=none | hexdump -n1 -e '1/1 "%02X"')
|
||||||
PART2_ACTIVE=$(dd if=$DISK bs=1 count=1 skip=462 status=none | hexdump -n1 -e '1/1 "%02X"')
|
PART2_ACTIVE=$(dd if=$DISK bs=1 count=1 skip=462 status=none | hexdump -n1 -e '1/1 "%02X"')
|
||||||
|
|
||||||
vtdebug "PART1_ACTIVE=$PART1_ACTIVE PART2_ACTIVE=$PART2_ACTIVE"
|
vtdebug "PART1_ACTIVE=$PART1_ACTIVE PART2_ACTIVE=$PART2_ACTIVE"
|
||||||
if [ "$PART1_ACTIVE" = "00" ] && [ "$PART2_ACTIVE" = "80" ]; then
|
if [ "$PART1_ACTIVE" = "00" ] && [ "$PART2_ACTIVE" = "80" ]; then
|
||||||
vtdebug "change 1st partition active, 2nd partition inactive ..."
|
vtdebug "change 1st partition active, 2nd partition inactive ..."
|
||||||
@@ -614,7 +615,7 @@ else
|
|||||||
echo ""
|
echo ""
|
||||||
vtinfo "Update Ventoy on $DISK successfully finished."
|
vtinfo "Update Ventoy on $DISK successfully finished."
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -176,6 +176,13 @@ chmod +x $tmpdir/VentoyWeb.sh
|
|||||||
chmod +x $tmpdir/VentoyPlugson.sh
|
chmod +x $tmpdir/VentoyPlugson.sh
|
||||||
chmod +x $tmpdir/VentoyVlnk.sh
|
chmod +x $tmpdir/VentoyVlnk.sh
|
||||||
chmod +x $tmpdir/VentoyGUI*
|
chmod +x $tmpdir/VentoyGUI*
|
||||||
|
chmod +x $tmpdir/tool/*.sh
|
||||||
|
|
||||||
|
for d in i386 x86_64 aarch64 mips64el; do
|
||||||
|
chmod +x $tmpdir/tool/$d/xzcat
|
||||||
|
chmod +x $tmpdir/tool/$d/Ventoy2Disk.*
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
cp $OPT $LANG_DIR/languages.json $tmpdir/tool/
|
cp $OPT $LANG_DIR/languages.json $tmpdir/tool/
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user