My Kernel v0.1.0
pmm.h File Reference
#include <kernel/memory.h>
#include <kernel/types.h>
#include <utils/bits.h>
#include <multiboot.h>
#include <stdbool.h>
Include dependency graph for pmm.h:

Go to the source code of this file.

Data Structures

struct  page
 Represents a physical pageframe. More...
 

Macros

#define PMM_INVALID_PAGEFRAME   (0xFFFFFFFFUL)
 Error value returned by the PMM in case of errors.
 
#define TOTAL_PAGEFRAMES_COUNT   (ADDRESS_SPACE_SIZE / PAGE_SIZE)
 Total number of pageframes. More...
 
#define TO_PFN(_pageframe)   (((native_t)(_pageframe)) >> PAGE_SHIFT)
 Convert pageframe address to page frame number.
 
#define FROM_PFN(_pageframe)   ((_pageframe) << PAGE_SHIFT)
 Convert pageframe number to pageframe address.
 
#define pmm_allocate()   pmm_allocate_pages(PAGE_SIZE)
 Allocate a previously unused pageframe. More...
 

Enumerations

enum  page_flags { PAGE_AVAILABLE = BIT(0) , PAGE_COW = BIT(1) }
 Flags used for struct page 'flags' field. More...
 

Functions

static paddr_t page_address (const struct page *page)
 
static struct pagepfn_to_page (unsigned int pfn)
 
static struct pageaddress_to_page (paddr_t addr)
 
struct pagepage_get (struct page *page)
 Increase the page's refcount.
 
void page_put (struct page *page)
 Decrease the page's refcount. More...
 
static bool page_is_cow (struct page *page)
 
bool pmm_init (struct multiboot_info *)
 Initialize the Physical Memory Mapper. More...
 
paddr_t pmm_allocate_pages (size_t size)
 Allocate previously unused pageframes. More...
 
void pmm_free_pages (paddr_t pageframe, size_t size)
 Release previously allocated contiguous pageframes.
 

Variables

struct page pmm_pageframes [TOTAL_PAGEFRAMES_COUNT]
 The array of all existing pageframes. More...