1 /* 2 * Copyright 2016 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include <boot/platform.h> 8 #include <boot/stage2.h> 9 10 #include "efi_platform.h" 11 12 13 #define STAGE_PAGES 0x2000 /* 32 MB */ 14 15 16 static efi_physical_addr staging; 17 18 19 extern "C" void 20 platform_release_heap(struct stage2_args *args, void *base) 21 { 22 if ((void*)staging != base) 23 panic("Attempt to release heap with wrong base address!"); 24 25 kBootServices->FreePages(staging, STAGE_PAGES); 26 } 27 28 29 extern "C" status_t 30 platform_init_heap(struct stage2_args *args, void **_base, void **_top) 31 { 32 if (kBootServices->AllocatePages(AllocateAnyPages, EfiLoaderData, 33 STAGE_PAGES, &staging) != EFI_SUCCESS) 34 return B_NO_MEMORY; 35 36 *_base = (void*)staging; 37 *_top = (void*)((int8*)staging + STAGE_PAGES * B_PAGE_SIZE); 38 39 return B_OK; 40 } 41