summaryrefslogtreecommitdiff
path: root/arch/i386/kernel/pmem.c
diff options
context:
space:
mode:
authorDanny Holman <dholman@gymli.org>2025-01-12 01:17:36 -0600
committerDanny Holman <dholman@gymli.org>2025-01-12 01:19:11 -0600
commit95cd78840f0891e60f5ebecc8a8eb4fbaf3c2ebf (patch)
treec8c35347b50477929727fa5be9f5d0f55cbe18fd /arch/i386/kernel/pmem.c
parent5e166f3042a8e7b3031aae4da7006f80caa53ecc (diff)
PROJECT RESTRUCTURING
Move the entire kernel into its own directory. Create new directories for system commands, libraries and other required essentials for a complete Unix-like operating system. Signed-off-by: Danny Holman <dholman@gymli.org>
Diffstat (limited to 'arch/i386/kernel/pmem.c')
-rw-r--r--arch/i386/kernel/pmem.c45
1 files changed, 0 insertions, 45 deletions
diff --git a/arch/i386/kernel/pmem.c b/arch/i386/kernel/pmem.c
deleted file mode 100644
index 40e3400..0000000
--- a/arch/i386/kernel/pmem.c
+++ /dev/null
@@ -1,45 +0,0 @@
-#include <kernel/pmem.h>
-#include <kernel/asm.h>
-#include <kernel/vmem.h>
-#include <kernel/panic.h>
-#include <kernel/paging.h>
-#include <libk/io.h>
-#include <libk/string.h>
-
-static struct pfa_page freelist;
-
-void pfa_init(struct mboot_info *header) {
- struct mboot_mmap_entry *mme;
- for (uintptr_t i = 0; i < header->mmap_length; i += sizeof(struct mboot_mmap_entry)) {
- mme = (struct mboot_mmap_entry*)(header->mmap_addr + i);
- if (mme->type == MBOOT_MEM_AVAILABLE)
- pfa_free(mme->addr_low, mme->len_low / PAGE_SIZE);
- }
-}
-
-uintptr_t pfa_alloc(size_t num_pages) {
- struct pfa_page *temp = (struct pfa_page*)PAGE_TMP_MAP;
- map_page(freelist.next, PAGE_TMP_MAP, PD_PRES | PD_RW);
- uintptr_t ret = freelist.next;
- freelist.next = temp->next;
- memset(temp, 0, 32);
- unmap_page(PAGE_TMP_MAP);
- return ret;
-}
-
-void pfa_free(uintptr_t paddr, size_t num_pages) {
- uintptr_t addr;
- struct pfa_page *temp = (struct pfa_page*)PAGE_TMP_MAP;
- for (size_t i = 0; i < num_pages; i++) {
- addr = (i * PAGE_SIZE + paddr);
- if (addr >= KSTART && addr < KEND)
- continue;
- if (addr == 0)
- continue;
- map_page(addr, PAGE_TMP_MAP, PD_PRES | PD_RW);
- memset(PAGE_TMP_MAP, 1, 32);
- temp->next = freelist.next;
- freelist.next = addr;
- unmap_page(PAGE_TMP_MAP);
- }
-}