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.
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);
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;
+}
+
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];
{ "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)
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,