]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
xnu: supply ramsize to the kernel.
authorVladimir Serbinenko <phcoder@gmail.com>
Thu, 11 Feb 2016 10:58:28 +0000 (11:58 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Thu, 11 Feb 2016 10:58:28 +0000 (11:58 +0100)
Without this info recent kernels crash as they allocate no heap.

grub-core/loader/i386/xnu.c
include/grub/i386/xnu.h

index a4a6f932e7d2b9012a9980f24b3869c92bed480c..7962b0e1dc3fe3ade5412280dc02d4f90324f999 100644 (file)
@@ -897,6 +897,28 @@ grub_xnu_set_video (struct grub_xnu_boot_params_common *params)
   return GRUB_ERR_NONE;
 }
 
+static int
+total_ram_hook (grub_uint64_t addr __attribute__ ((unused)), grub_uint64_t size,
+               grub_memory_type_t type,
+               void *data)
+{
+  grub_uint64_t *result = data;
+
+  if (type != GRUB_MEMORY_AVAILABLE)
+    return 0;
+  *result += size;
+  return 0;
+}
+
+static grub_uint64_t
+get_total_ram (void)
+{
+  grub_uint64_t result = 0;
+
+  grub_mmap_iterate (total_ram_hook, &result);
+  return result;
+}
+
 /* Boot xnu. */
 grub_err_t
 grub_xnu_boot (void)
@@ -973,6 +995,7 @@ grub_xnu_boot (void)
     {
       bootparams_common = &bootparams->v2.common;
       bootparams->v2.fsbfreq = fsbfreq;
+      bootparams->v2.ram_size = get_total_ram();
     }
   else
     bootparams_common = &bootparams->v1.common;
index a076b8a97c5dbfa1e9edda2d2b0022df900053f2..062a7ddbe661e66101485cc1b8c3aa504c4c2068 100644 (file)
@@ -89,7 +89,8 @@ struct grub_xnu_boot_params_v2
 
   grub_uint64_t efi_runtime_first_page_virtual;
   grub_uint32_t efi_system_table;
-  grub_uint32_t unused2[11];
+  grub_uint32_t unused2[9];
+  grub_uint64_t ram_size;
   grub_uint64_t fsbfreq;
   grub_uint32_t unused3[734];
 } GRUB_PACKED;