diff options
author | Danny Holman <dholman@gymli.org> | 2024-03-28 21:30:12 -0500 |
---|---|---|
committer | Danny Holman <dholman@gymli.org> | 2024-03-28 21:30:12 -0500 |
commit | cbe2690cd5d1b290633c466ebb4df7b64b09b037 (patch) | |
tree | 99f77ef19f303c42c028be11cbb4210245b8a583 /arch/i386/include/kernel/pmem.h | |
parent | 891f1010bbdc1351bda8d2a6139094a14bdfd5e1 (diff) |
arch: i386: kernel: add mostly finished PFA and paging system
Add the mostly finished physical memory allocator and expose its
functions to the paging system.
Signed-off-by: Danny Holman <dholman@gymli.org>
Diffstat (limited to 'arch/i386/include/kernel/pmem.h')
-rw-r--r-- | arch/i386/include/kernel/pmem.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/arch/i386/include/kernel/pmem.h b/arch/i386/include/kernel/pmem.h new file mode 100644 index 0000000..ddd9c8b --- /dev/null +++ b/arch/i386/include/kernel/pmem.h @@ -0,0 +1,28 @@ +#ifndef I386_PMEM_H +#define I386_PMEM_H + +#include <kernel/multiboot.h> +#include <stdint.h> + +#define PFA_BLOCK_FREE 1 +#define PFA_BLOCK_ALLOC 3 + +#define PFA_ALLOC_ERR 0xFFFFFFFF + +struct pfa_page { + struct pfa_page *next; +}; + +struct pfa_zone { + uintptr_t start; + uintptr_t size; + struct pfa_page *freelist; +}; + +int pfa_init(struct mboot_info *header); + +uintptr_t pfa_alloc(void); +void pfa_free(struct pfa_zone *zone, uintptr_t paddr); +void pfa_free_range(struct pfa_zone *zone, uintptr_t pstart, uintptr_t pend); + +#endif |