]> glassweightruler.freedombox.rocks Git - Ventoy.git/blobdiff - GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy.c
Fix the chain load memory alloc failure in UEFI mode.
[Ventoy.git] / GRUB2 / MOD_SRC / grub-2.04 / grub-core / ventoy / ventoy.c
index 410369504907ce27dbd5eb20416c3361365e7ef9..2f1faa3413f77fb250d8f8a249e2ff5707df8334 100644 (file)
@@ -38,6 +38,7 @@
 #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"
@@ -135,6 +136,22 @@ int ventoy_is_efi_os(void)
     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