diff --git a/GRUB2/MOD_SRC/grub-2.04/grub-core/kern/efi/mm.c b/GRUB2/MOD_SRC/grub-2.04/grub-core/kern/efi/mm.c index 6676d6d6..cb65cb35 100644 --- a/GRUB2/MOD_SRC/grub-2.04/grub-core/kern/efi/mm.c +++ b/GRUB2/MOD_SRC/grub-2.04/grub-core/kern/efi/mm.c @@ -49,6 +49,9 @@ static grub_efi_uintn_t finish_desc_size; static grub_efi_uint32_t finish_desc_version; int grub_efi_is_finished = 0; +static grub_efi_uint64_t g_total_pages; +static grub_efi_uint64_t g_required_pages; + /* * We need to roll back EFI allocations on exit. Remember allocations that * we'll free on exit. @@ -614,6 +617,9 @@ grub_efi_mm_init (void) else if (required_pages > BYTES_TO_PAGES (MAX_HEAP_SIZE)) required_pages = BYTES_TO_PAGES (MAX_HEAP_SIZE); + g_total_pages = total_pages; + g_required_pages = required_pages; + /* Sort the filtered descriptors, so that GRUB can allocate pages from smaller regions. */ sort_memory_map (filtered_memory_map, desc_size, filtered_memory_map_end); @@ -670,3 +676,10 @@ grub_efi_get_ram_base(grub_addr_t *base_addr) return GRUB_ERR_NONE; } #endif + +void grub_efi_get_reserved_page_num(grub_uint64_t *total, grub_uint64_t *required) +{ + *total = g_total_pages; + *required = g_required_pages; +} + diff --git a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c index 5bde7a3d..25bfed6a 100644 --- a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c +++ b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c @@ -5568,6 +5568,28 @@ static grub_err_t ventoy_cmd_fn_mutex_lock(grub_extcmd_context_t ctxt, int argc, VENTOY_CMD_RETURN(GRUB_ERR_NONE); } +static grub_err_t ventoy_cmd_dump_rsv_page(grub_extcmd_context_t ctxt, int argc, char **args) +{ + grub_uint64_t total; + grub_uint64_t required; + + (void)ctxt; + (void)argc; + (void)args; + +#ifdef GRUB_MACHINE_EFI + grub_efi_get_reserved_page_num(&total, &required); + grub_printf("Total pages: %llu\n", (unsigned long long)total); + grub_printf("Required pages: %llu\n", (unsigned long long)required); +#else + grub_printf("Non EFI mode!\n"); +#endif + + grub_refresh(); + + VENTOY_CMD_RETURN(GRUB_ERR_NONE); +} + int ventoy_env_init(void) { char buf[64]; @@ -5769,6 +5791,7 @@ static cmd_para ventoy_cmds[] = { "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 }, + { "vt_efi_dump_rsv_page", ventoy_cmd_dump_rsv_page, 0, NULL, "", "", NULL }, }; int ventoy_register_all_cmd(void) diff --git a/GRUB2/MOD_SRC/grub-2.04/include/grub/efi/efi.h b/GRUB2/MOD_SRC/grub-2.04/include/grub/efi/efi.h index 4abd5db6..7aea5b2a 100644 --- a/GRUB2/MOD_SRC/grub-2.04/include/grub/efi/efi.h +++ b/GRUB2/MOD_SRC/grub-2.04/include/grub/efi/efi.h @@ -88,7 +88,7 @@ EXPORT_FUNC (grub_efi_compare_device_paths) (const grub_efi_device_path_t *dp1, void * EXPORT_FUNC (grub_efi_allocate_iso_buf) (grub_uint64_t size); void * EXPORT_FUNC (grub_efi_allocate_chain_buf) (grub_uint64_t size); - +void EXPORT_FUNC (grub_efi_get_reserved_page_num) (grub_uint64_t *total, grub_uint64_t *required); extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd, char **device,