memblock can now self re-allocate its internal buffers

memory allocated by memblock_alloc() can now be limited to a certain region.
This commit is contained in:
2023-01-08 12:13:59 +00:00
parent 02211e6eba
commit 0d77d97561
6 changed files with 125 additions and 12 deletions

View File

@@ -52,6 +52,14 @@ typedef struct memblock_type {
} memblock_type_t;
typedef struct memblock {
/* bounds of the memory region that can be used by memblock_alloc()
both of these are virtual addresses */
uintptr_t m_alloc_start, m_alloc_end;
/* memblock assumes that all memory in the alloc zone is contiguously mapped
(if paging is enabled). m_voffset is the offset that needs to be added to
a given physical address to get the corresponding virtual address */
uintptr_t m_voffset;
struct memblock_type memory;
struct memblock_type reserved;
} memblock_t;
@@ -67,6 +75,8 @@ extern memblock_t memblock;
extern int __next_mem_range(memblock_iter_t *it);
extern int memblock_init(uintptr_t alloc_start, uintptr_t alloc_end, uintptr_t voffset);
extern int memblock_add(phys_addr_t base, size_t size);
extern int memblock_reserve(phys_addr_t base, size_t size);