diff options
author | Alex Auvolat <alex@adnab.me> | 2015-03-14 16:36:31 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2015-03-14 16:36:31 +0100 |
commit | 3e2a3170501fb02b5b46a342c47d2ba8b1a6e244 (patch) | |
tree | 6cd0a3f3ded016de581e3b3841ab19f1e511dd86 /src/common/include/region_alloc.h | |
parent | 57c5eceb846f3109d017b4e6d4cbd7c507c0d098 (diff) | |
download | kogata-3e2a3170501fb02b5b46a342c47d2ba8b1a6e244.tar.gz kogata-3e2a3170501fb02b5b46a342c47d2ba8b1a6e244.zip |
Factorize region allocator between kernel and user processes (same code was there twice)
Diffstat (limited to 'src/common/include/region_alloc.h')
-rw-r--r-- | src/common/include/region_alloc.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/common/include/region_alloc.h b/src/common/include/region_alloc.h new file mode 100644 index 0000000..d314bd5 --- /dev/null +++ b/src/common/include/region_alloc.h @@ -0,0 +1,32 @@ +#pragma once + +// Virtual memory region allocator + +// This is entirely thread-safe + +#include <stdint.h> +#include <stddef.h> +#include <stdbool.h> + +struct region_info; + +typedef bool (*map_page_fun_t)(void* addr); // map a single page (used by region allocator) + +typedef struct region_info { + void* addr; + size_t size; + char* type; +} region_info_t; + +// rsvd_end : when used for kernel memory region management, a reserved region +// exists between begin (=K_HIGHHALF_ADDR) and the end of kernel static data +// for user processes, use rsvd_end = begin (no reserved region) +void region_allocator_init(void* begin, void* rsvd_end, void* end, map_page_fun_t map); + +void* region_alloc(size_t size, char* type); // returns 0 on error +region_info_t *find_region(void* addr); +void region_free(void* addr); + +void dbg_print_region_info(); + +/* vim: set ts=4 sw=4 tw=0 noet :*/ |