From 2d425ffdd57845e4c967b468f8cee164d2ddc85f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 11 Feb 2016 11:58:28 +0100 Subject: [PATCH] xnu: supply ramsize to the kernel. Without this info recent kernels crash as they allocate no heap. --- grub-core/loader/i386/xnu.c | 23 +++++++++++++++++++++++ include/grub/i386/xnu.h | 3 ++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c index a4a6f932e..7962b0e1d 100644 --- a/grub-core/loader/i386/xnu.c +++ b/grub-core/loader/i386/xnu.c @@ -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; diff --git a/include/grub/i386/xnu.h b/include/grub/i386/xnu.h index a076b8a97..062a7ddbe 100644 --- a/include/grub/i386/xnu.h +++ b/include/grub/i386/xnu.h @@ -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;