1 #ifndef _ALLOC_PHYS_H_ 2 #define _ALLOC_PHYS_H_ 3 /* 4 * phys_alloc is a very simple allocator which allows physical memory 5 * to be partitioned into regions until all memory is allocated. 6 * 7 * Note: This is such a simple allocator that there is no way to free 8 * a region. For more complicated memory management a single region 9 * can be allocated, but then have its memory managed by a more 10 * sophisticated allocator, e.g. a page allocator. 11 * 12 * Copyright (C) 2014, Red Hat Inc, Andrew Jones <drjones@redhat.com> 13 * 14 * This work is licensed under the terms of the GNU LGPL, version 2. 15 */ 16 #include "libcflat.h" 17 18 #define DEFAULT_MINIMUM_ALIGNMENT 32 19 20 /* 21 * phys_alloc_init creates the initial free memory region of size @size 22 * at @base. The minimum alignment is set to DEFAULT_MINIMUM_ALIGNMENT. 23 */ 24 extern void phys_alloc_init(phys_addr_t base, phys_addr_t size); 25 26 /* 27 * phys_alloc_set_minimum_alignment sets the minimum alignment to 28 * @align. 29 */ 30 extern void phys_alloc_set_minimum_alignment(phys_addr_t align); 31 32 /* 33 * phys_alloc_show outputs all currently allocated regions with the 34 * following format 35 * <start_addr>-<end_addr> [<USED|FREE>] 36 */ 37 extern void phys_alloc_show(void); 38 39 /* 40 * phys_alloc_get_unused allocates all remaining memory from the region 41 * passed to phys_alloc_init, returning the newly allocated memory's base 42 * and top addresses. phys_alloc_get_unused will still return base and top 43 * when no free memory is remaining, but base will equal top. 44 */ 45 extern void phys_alloc_get_unused(phys_addr_t *p_base, phys_addr_t *p_top); 46 47 /* 48 * Search for memory that can only be used when the MMU is on, and reinitialize 49 * the physical memory allocator using it. 50 */ 51 extern void find_highmem(void); 52 53 #endif /* _ALLOC_PHYS_H_ */ 54