#include <grub/memory.h>
#ifdef GRUB_MACHINE_EFI
#include <grub/efi/efi.h>
+#include <grub/efi/memory.h>
#endif
#include <grub/ventoy.h>
#include "ventoy_def.h"
return g_efi_os;
}
+void * ventoy_alloc_chain(grub_size_t size)
+{
+ void *p = NULL;
+
+ p = grub_malloc(size);
+#ifdef GRUB_MACHINE_EFI
+ if (!p)
+ {
+ p = grub_efi_allocate_any_pages(GRUB_EFI_BYTES_TO_PAGES(size));
+ }
+#endif
+
+ return p;
+}
+
+
static int ventoy_arch_mode_init(void)
{
#ifdef GRUB_MACHINE_EFI
grub_err_t ventoy_cmd_browser_disk(grub_extcmd_context_t ctxt, int argc, char **args);
int ventoy_get_fs_type(const char *fs);
int ventoy_img_name_valid(const char *filename, grub_size_t namelen);
+void * ventoy_alloc_chain(grub_size_t size);
#endif /* __VENTOY_DEF_H__ */
}
}
- chain = grub_malloc(size);
+ chain = ventoy_alloc_chain(size);
if (!chain)
{
- grub_printf("Failed to alloc chain memory size %u\n", size);
+ grub_printf("Failed to alloc chain linux memory size %u\n", size);
grub_file_close(file);
return 1;
}
}
}
- chain = grub_malloc(size);
+ chain = ventoy_alloc_chain(size);
if (!chain)
{
- grub_printf("Failed to alloc chain memory size %u\n", size);
+ grub_printf("Failed to alloc chain unix memory size %u\n", size);
grub_file_close(file);
return 1;
}
}
}
- chain = grub_malloc(size);
+ chain = ventoy_alloc_chain(size);
if (!chain)
{
- grub_printf("Failed to alloc chain memory size %u\n", size);
+ grub_printf("Failed to alloc chain raw memory size %u\n", size);
grub_file_close(file);
return 1;
}
}
}
- chain = grub_malloc(size);
+ chain = ventoy_alloc_chain(size);
if (!chain)
{
- grub_printf("Failed to alloc chain memory size %u\n", size);
+ grub_printf("Failed to alloc chain win1 memory size %u\n", size);
grub_file_close(file);
return 1;
}
}
}
- chain = grub_malloc(size);
+ chain = ventoy_alloc_chain(size);
if (!chain)
{
- grub_printf("Failed to alloc chain memory size %u\n", size);
+ grub_printf("Failed to alloc chain win2 memory size %u\n", size);
grub_file_close(file);
return 1;
}
}
}
- chain = grub_malloc(size);
+ chain = ventoy_alloc_chain(size);
if (!chain)
{
- grub_printf("Failed to alloc chain memory size %u\n", size);
+ grub_printf("Failed to alloc chain win3 memory size %u\n", size);
grub_file_close(file);
return 1;
}