#ifndef PMM_H #define PMM_H #include #include #define PAGE_SIZE 4096 typedef uintptr_t phys_addr_t; typedef enum { PMM_ZONE_DMA, // < 16 MB PMM_ZONE_NORMAL, // Any other memory PMM_ZONE_HIGHMEM // > 4 GB (if 64-bit or PAE, but we are 32-bit for now) - actually sticking to DMA and NORMAL is enough for 32-bit typically } pmm_zone_t; /* * Initialize the physical memory manager. * @param multiboot_addr Address of the multiboot info structure */ void init_pmm(uint32_t multiboot_addr); /* * Allocate a physical page. * @param zone The preferred zone to allocate from. * @return Physical address of the allocated page, or 0 if out of memory. */ phys_addr_t pmm_alloc_page(pmm_zone_t zone); /** * Free a physical page. * @param addr Physical address of the page to free. */ void pmm_free_page(phys_addr_t addr); /** * Get the total detected upper memory in KiB. * @return Upper memory size in KiB as reported by Multiboot. */ uint32_t pmm_get_memory_size(void); #endif