Add debug info

This commit is contained in:
longpanda 2022-05-02 21:05:58 +08:00
parent 63f9331c31
commit d4d8736620
3 changed files with 37 additions and 1 deletions

View File

@ -49,6 +49,9 @@ static grub_efi_uintn_t finish_desc_size;
static grub_efi_uint32_t finish_desc_version; static grub_efi_uint32_t finish_desc_version;
int grub_efi_is_finished = 0; 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 need to roll back EFI allocations on exit. Remember allocations that
* we'll free on exit. * we'll free on exit.
@ -614,6 +617,9 @@ grub_efi_mm_init (void)
else if (required_pages > BYTES_TO_PAGES (MAX_HEAP_SIZE)) else if (required_pages > BYTES_TO_PAGES (MAX_HEAP_SIZE))
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 /* Sort the filtered descriptors, so that GRUB can allocate pages
from smaller regions. */ from smaller regions. */
sort_memory_map (filtered_memory_map, desc_size, filtered_memory_map_end); 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; return GRUB_ERR_NONE;
} }
#endif #endif
void grub_efi_get_reserved_page_num(grub_uint64_t *total, grub_uint64_t *required)
{
*total = g_total_pages;
*required = g_required_pages;
}

View File

@ -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); 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) int ventoy_env_init(void)
{ {
char buf[64]; 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_clear", ventoy_iso_vd_id_clear, 0, NULL, "", "", NULL },
{ "vt_iso_vd_id_begin", ventoy_cmd_iso_vd_id_begin, 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_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) int ventoy_register_all_cmd(void)

View File

@ -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_iso_buf) (grub_uint64_t size);
void * EXPORT_FUNC (grub_efi_allocate_chain_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, extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd,
char **device, char **device,