]> glassweightruler.freedombox.rocks Git - Ventoy.git/commitdiff
Add F5 Tools ---> Hardware Information menu
authorlongpanda <admin@ventoy.net>
Wed, 6 Apr 2022 11:12:59 +0000 (19:12 +0800)
committerlongpanda <admin@ventoy.net>
Wed, 6 Apr 2022 11:12:59 +0000 (19:12 +0800)
31 files changed:
GRUB2/MOD_SRC/grub-2.04/grub-core/Makefile.core.def
GRUB2/MOD_SRC/grub-2.04/grub-core/commands/efi/smbios.c [new file with mode: 0644]
GRUB2/MOD_SRC/grub-2.04/grub-core/commands/i386/pc/smbios.c [new file with mode: 0644]
GRUB2/MOD_SRC/grub-2.04/grub-core/commands/smbios.c [new file with mode: 0644]
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy.c
GRUB2/MOD_SRC/grub-2.04/include/grub/efi/api.h
GRUB2/MOD_SRC/grub-2.04/install.sh
IMG/cpio/ventoy/hook/ventoy-hook-lib.sh
INSTALL/grub/arm64-efi/command.lst
INSTALL/grub/arm64-efi/fwload.mod [new file with mode: 0644]
INSTALL/grub/arm64-efi/moddep.lst
INSTALL/grub/arm64-efi/smbios.mod [new file with mode: 0644]
INSTALL/grub/debug.cfg
INSTALL/grub/grub.cfg
INSTALL/grub/hwinfo.cfg [new file with mode: 0644]
INSTALL/grub/i386-efi/command.lst
INSTALL/grub/i386-efi/moddep.lst
INSTALL/grub/i386-efi/mouse.mod [deleted file]
INSTALL/grub/i386-efi/smbios.mod [new file with mode: 0644]
INSTALL/grub/i386-pc/command.lst
INSTALL/grub/i386-pc/core.img
INSTALL/grub/i386-pc/moddep.lst
INSTALL/grub/i386-pc/smbios.mod [new file with mode: 0644]
INSTALL/grub/mips64el-efi/command.lst
INSTALL/grub/mips64el-efi/fwload.mod [new file with mode: 0644]
INSTALL/grub/mips64el-efi/moddep.lst
INSTALL/grub/mips64el-efi/smbios.mod [new file with mode: 0644]
INSTALL/grub/x86_64-efi/command.lst
INSTALL/grub/x86_64-efi/moddep.lst
INSTALL/grub/x86_64-efi/mouse.mod [deleted file]
INSTALL/grub/x86_64-efi/smbios.mod [new file with mode: 0644]

index dbb1f1cc20edd30e1281b89c698d14b4f1836d93..2853b8e573498be9b4a36820da7eb0b3b2e979c8 100644 (file)
@@ -1129,6 +1129,21 @@ module = {
   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 = {
   name = suspend;
   ieee1275 = commands/ieee1275/suspend.c;
diff --git a/GRUB2/MOD_SRC/grub-2.04/grub-core/commands/efi/smbios.c b/GRUB2/MOD_SRC/grub-2.04/grub-core/commands/efi/smbios.c
new file mode 100644 (file)
index 0000000..75202d5
--- /dev/null
@@ -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;
+}
diff --git a/GRUB2/MOD_SRC/grub-2.04/grub-core/commands/i386/pc/smbios.c b/GRUB2/MOD_SRC/grub-2.04/grub-core/commands/i386/pc/smbios.c
new file mode 100644 (file)
index 0000000..069d663
--- /dev/null
@@ -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;
+}
diff --git a/GRUB2/MOD_SRC/grub-2.04/grub-core/commands/smbios.c b/GRUB2/MOD_SRC/grub-2.04/grub-core/commands/smbios.c
new file mode 100644 (file)
index 0000000..b1a15bc
--- /dev/null
@@ -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);
+}
+
index 8d6a8272ab822f4d8e1fb1cdd15dbf1ccb4a97f1..410369504907ce27dbd5eb20416c3361365e7ef9 100644 (file)
 #include <grub/misc.h>
 #include <grub/kernel.h>
 #include <grub/time.h>
+#include <grub/memory.h>
+#ifdef GRUB_MACHINE_EFI
+#include <grub/efi/efi.h>
+#endif
 #include <grub/ventoy.h>
 #include "ventoy_def.h"
 
@@ -162,8 +166,52 @@ static int ventoy_arch_mode_init(void)
     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)
 {
+    ventoy_hwinfo_init();
     ventoy_env_init();
     ventoy_arch_mode_init();
     ventoy_register_all_cmd();
index 5635882e6638347c32f527c8bd2642109bf80f8d..16cfef9c514a5a563fb98ba74cb9bb59e860bb1a 100644 (file)
     { 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 \
   { 0xeb9d2d32, 0x2d88, 0x11d3, \
       { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
index 6222037b6e4ffdb45fba35a2718e2d6f140256c0..35830c26fe85cc21015411df7833abd103f7eca7 100644 (file)
@@ -12,10 +12,10 @@ make install
 PATH=$PATH:$VT_DIR/GRUB2/INSTALL/bin/:$VT_DIR/GRUB2/INSTALL/sbin/
 
 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"
-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"
+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"
 
index 88bfe7389ad8e18f6d5725ca5e01d4d78d573810..ad05c7c806ab186eeff3863cd7bd19932efd14be 100644 (file)
@@ -225,7 +225,11 @@ ventoy_check_dm_module() {
 
 ventoy_need_dm_patch() {
     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
 
     if $GREP -q 'device-mapper' /proc/devices; then
index 743d25592d36fe77f805d4e719bcfd04a5318079..aefec3f0aa3a65b958dbcb9fe4a4e96893532637 100644 (file)
Binary files a/INSTALL/grub/arm64-efi/command.lst and b/INSTALL/grub/arm64-efi/command.lst differ
diff --git a/INSTALL/grub/arm64-efi/fwload.mod b/INSTALL/grub/arm64-efi/fwload.mod
new file mode 100644 (file)
index 0000000..0024623
Binary files /dev/null and b/INSTALL/grub/arm64-efi/fwload.mod differ
index e727820c8a5211555105b387fe8c01f6ffbe7579..c92f6837368aa9a2410c0677992f19635bb4ebe5 100644 (file)
Binary files a/INSTALL/grub/arm64-efi/moddep.lst and b/INSTALL/grub/arm64-efi/moddep.lst differ
diff --git a/INSTALL/grub/arm64-efi/smbios.mod b/INSTALL/grub/arm64-efi/smbios.mod
new file mode 100644 (file)
index 0000000..8b60677
Binary files /dev/null and b/INSTALL/grub/arm64-efi/smbios.mod differ
index 6b8f8c2b4bb508f1d6e1b8aade23ac1bcbab6b17..31525238c7f854fcb6509b51e183abeda24f2386 100644 (file)
@@ -1,5 +1,6 @@
 
 source $prefix/power.cfg
+source $prefix/hwinfo.cfg
 source $prefix/keyboard.cfg
 
 submenu "Resolution Configuration" --class=debug_resolution --class=F5tool {
index f359d015506684a86fcd7eb31d4aef7a6f833019..0b6bcb2c93e8b0c741cdfb7aa23767e61458973b 100644 (file)
@@ -2267,6 +2267,11 @@ else
     terminal_output  gfxterm
 fi
 
+if [ "$grub_platform" = "efi" ]; then
+    set mouse_delta=4000
+    # terminal_input --append mouse
+fi
+
 if [ -n "$VTOY_DEFAULT_KBD_LAYOUT" ]; then
     set_keyboard_layout "$VTOY_DEFAULT_KBD_LAYOUT"
 fi
diff --git a/INSTALL/grub/hwinfo.cfg b/INSTALL/grub/hwinfo.cfg
new file mode 100644 (file)
index 0000000..3d3be5a
--- /dev/null
@@ -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
+}
index 18d5963b8f5e3915a228cc1b62b329390794da31..896bb3db4f628da3ddc5735bb351cb07930ddfeb 100644 (file)
@@ -12,6 +12,8 @@
 *extract_syslinux_entries_source: syslinuxcfg
 *file: file
 *functional_test: functional_test
+*fwconnect: fwload
+*fwload: fwload
 *gettext: gettext
 *hashsum: hashsum
 *hdparm: hdparm
@@ -50,6 +52,7 @@
 *sha256sum: hashsum
 *sha512sum: hashsum
 *sleep: sleep
+*smbios: smbios
 *submenu: normal
 *syslinux_configfile: syslinuxcfg
 *syslinux_source: syslinuxcfg
index d3fd2c2f4c769a7ff96caaa567595d89eba12dcf..5ce89d849254051ab4e1bb7ea1ca528ca5ecfe54 100644 (file)
@@ -49,6 +49,7 @@ test_blockarg: extcmd normal
 true:
 affs: fshelp
 iso9660: fshelp
+smbios: extcmd
 exfat: fshelp
 setjmp_test: setjmp functional_test
 gfxterm: font video
@@ -120,7 +121,7 @@ ehci: cs5536 usb boot
 crypto:
 part_bsd: part_msdos
 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
 password: crypto normal
 fshelp:
@@ -181,6 +182,7 @@ usbtest: usb
 relocator: mmap
 acpi: extcmd mmap
 tga: bufio bitmap
+fwload: extcmd
 reboot:
 serial: extcmd terminfo
 zfscrypt: crypto pbkdf2 extcmd zfs gcry_sha1 gcry_rijndael
diff --git a/INSTALL/grub/i386-efi/mouse.mod b/INSTALL/grub/i386-efi/mouse.mod
deleted file mode 100644 (file)
index d371e5f..0000000
Binary files a/INSTALL/grub/i386-efi/mouse.mod and /dev/null differ
diff --git a/INSTALL/grub/i386-efi/smbios.mod b/INSTALL/grub/i386-efi/smbios.mod
new file mode 100644 (file)
index 0000000..5d1555f
Binary files /dev/null and b/INSTALL/grub/i386-efi/smbios.mod differ
index fdc541a55a89e95cdd6fc7094bc7c952404f630b..a21a2f969b69d27be65951e6deb315acb4422dc8 100644 (file)
@@ -54,6 +54,7 @@
 *sha256sum: hashsum
 *sha512sum: hashsum
 *sleep: sleep
+*smbios: smbios
 *submenu: normal
 *syslinux_configfile: syslinuxcfg
 *syslinux_source: syslinuxcfg
index cb8be2e8f2216f2961f68f3d0ef7a75c309007f6..9a2eb2a281bd9a62ad07ebd41a8314ff51ec5670 100644 (file)
Binary files a/INSTALL/grub/i386-pc/core.img and b/INSTALL/grub/i386-pc/core.img differ
index 5e32ffad5c16eb58b91868af2e55003ee08d692f..25bbd536088268b145cb14780edc324261f32873 100644 (file)
@@ -50,6 +50,7 @@ test_blockarg: extcmd normal
 true:
 affs: fshelp
 iso9660: fshelp
+smbios: extcmd acpi
 exfat: fshelp
 setjmp_test: setjmp functional_test
 gfxterm: font video
diff --git a/INSTALL/grub/i386-pc/smbios.mod b/INSTALL/grub/i386-pc/smbios.mod
new file mode 100644 (file)
index 0000000..bbd6f8e
Binary files /dev/null and b/INSTALL/grub/i386-pc/smbios.mod differ
index fcc9e843b290b6ce49c138e1895acbdd9159d482..1a5b7f83e3a1957175829b0b5e9f2d0056d8cdda 100644 (file)
Binary files a/INSTALL/grub/mips64el-efi/command.lst and b/INSTALL/grub/mips64el-efi/command.lst differ
diff --git a/INSTALL/grub/mips64el-efi/fwload.mod b/INSTALL/grub/mips64el-efi/fwload.mod
new file mode 100644 (file)
index 0000000..14a0d32
Binary files /dev/null and b/INSTALL/grub/mips64el-efi/fwload.mod differ
index 6041b3b8d41e3156d41c3a16b337307cbf73be00..66987c4dd3257d55181b9b0553a9b1085c2f4e43 100644 (file)
Binary files a/INSTALL/grub/mips64el-efi/moddep.lst and b/INSTALL/grub/mips64el-efi/moddep.lst differ
diff --git a/INSTALL/grub/mips64el-efi/smbios.mod b/INSTALL/grub/mips64el-efi/smbios.mod
new file mode 100644 (file)
index 0000000..21fd7d4
Binary files /dev/null and b/INSTALL/grub/mips64el-efi/smbios.mod differ
index b9743610a61b810b1ed65fac6dc1151621cefce9..96cba291ca800f96858014cabf1102bd4110abe3 100644 (file)
@@ -12,6 +12,8 @@
 *extract_syslinux_entries_source: syslinuxcfg
 *file: file
 *functional_test: functional_test
+*fwconnect: fwload
+*fwload: fwload
 *gettext: gettext
 *hashsum: hashsum
 *hdparm: hdparm
@@ -50,6 +52,7 @@
 *sha256sum: hashsum
 *sha512sum: hashsum
 *sleep: sleep
+*smbios: smbios
 *submenu: normal
 *syslinux_configfile: syslinuxcfg
 *syslinux_source: syslinuxcfg
index 24d5da78c61151f5e82a7df2866b59577fec553b..a0a40bcba0ca745593b9813255d765d908989d75 100644 (file)
@@ -49,6 +49,7 @@ test_blockarg: extcmd normal
 true:
 affs: fshelp
 iso9660: fshelp
+smbios: extcmd
 exfat: fshelp
 setjmp_test: setjmp functional_test
 gfxterm: font video
@@ -120,7 +121,7 @@ ehci: cs5536 usb boot
 crypto:
 part_bsd: part_msdos
 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
 password: crypto normal
 fshelp:
@@ -183,6 +184,7 @@ relocator: mmap
 acpi: extcmd mmap
 tga: bufio bitmap
 reboot:
+fwload: extcmd
 serial: extcmd terminfo
 zfscrypt: crypto pbkdf2 extcmd zfs gcry_sha1 gcry_rijndael
 efi_uga: video video_fb
diff --git a/INSTALL/grub/x86_64-efi/mouse.mod b/INSTALL/grub/x86_64-efi/mouse.mod
deleted file mode 100644 (file)
index 18724b3..0000000
Binary files a/INSTALL/grub/x86_64-efi/mouse.mod and /dev/null differ
diff --git a/INSTALL/grub/x86_64-efi/smbios.mod b/INSTALL/grub/x86_64-efi/smbios.mod
new file mode 100644 (file)
index 0000000..0176d06
Binary files /dev/null and b/INSTALL/grub/x86_64-efi/smbios.mod differ