From ce80ee8d40b0a2b48bfbbceac9a0baee189c5e1b Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sat, 16 Jul 2022 16:49:55 +0200 Subject: amd64: just enough paging support to map init --- src/kernel/mem/alloc.c | 6 ++++++ src/kernel/mem/alloc.h | 3 +++ 2 files changed, 9 insertions(+) (limited to 'src/kernel/mem') diff --git a/src/kernel/mem/alloc.c b/src/kernel/mem/alloc.c index 797b018..e0cc5f4 100644 --- a/src/kernel/mem/alloc.c +++ b/src/kernel/mem/alloc.c @@ -93,6 +93,12 @@ void *page_alloc(size_t pages) { panic_unimplemented(); } +void *page_zalloc(size_t pages) { + void *p = page_alloc(pages); + memset(p, 0, pages * PAGE_SIZE); + return p; +} + // frees `pages` consecutive pages starting from *first void page_free(void *first_addr, size_t pages) { size_t first = (uintptr_t)(first_addr - page_bitmap_start) / PAGE_SIZE; diff --git a/src/kernel/mem/alloc.h b/src/kernel/mem/alloc.h index a92d866..14c4361 100644 --- a/src/kernel/mem/alloc.h +++ b/src/kernel/mem/alloc.h @@ -9,7 +9,10 @@ void mem_init(struct kmain_info *); void mem_debugprint(void); // allocates `pages` consecutive pages +// TODO deprecate void *page_alloc(size_t pages); +// zeroes the allocated pages +void *page_zalloc(size_t pages); // frees `pages` consecutive pages starting from *first void page_free(void *first, size_t pages); -- cgit v1.2.3