1 /* 2 * Copyright (c) 2015 Google, Inc. All rights reserved 3 * 4 * Use of this source code is governed by a MIT-style 5 * license that can be found in the LICENSE file or at 6 * https://opensource.org/licenses/MIT 7 */ 8 #pragma once 9 10 #include <arch.h> 11 #include <stddef.h> 12 #include <stdlib.h> 13 #include <lk/compiler.h> 14 15 __BEGIN_CDECLS 16 17 #define PAGE_ALIGN(x) ALIGN(x, PAGE_SIZE) 18 #define IS_PAGE_ALIGNED(x) IS_ALIGNED(x, PAGE_SIZE) 19 20 // arena bitmaps for novm_alloc_pages 21 #define NOVM_ARENA_ANY (UINT32_MAX) 22 #define NOVM_ARENA_MAIN (1<<0) 23 #define NOVM_ARENA_SECONDARY (~NOVM_ARENA_MAIN) 24 25 void *novm_alloc_pages(size_t pages, uint32_t arena_bitmap); 26 void novm_free_pages(void *address, size_t pages); 27 status_t novm_alloc_specific_pages(void *address, size_t pages); 28 29 // You can call this once and it will give you some possibly unaligned memory 30 // that would otherwise go to waste. The memory can't be freed. 31 void *novm_alloc_unaligned(size_t *size_return); 32 33 void novm_add_arena(const char *name, uintptr_t arena_start, uintptr_t arena_size); 34 35 struct page_range { 36 void *address; 37 size_t size; 38 }; 39 40 int novm_get_arenas(struct page_range *ranges, int number_of_ranges); 41 42 __END_CDECLS 43