blob: f91fe376d44ea50d788c5b73f235d3d0b2111c3c (
plain) (
tree)
|
|
#ifndef DEF_PAGING_H
#define DEF_PAGING_H
#include <types.h>
#include <task/idt.h>
#include <mem/mem.h>
#define FIRST_KERNEL_PAGETABLE (K_HIGHHALF_ADDR >> 22)
struct page {
uint32_t present : 1; //Page mapped to a frame ?
uint32_t rw : 1; //Page read/write ?
uint32_t user : 1; //Page user readable ?
uint32_t accessed : 1; //Was page accessed ?
uint32_t dirty : 1; //Was page modified ?
uint32_t unused : 7;
uint32_t frame : 20; //Frame address (physical address)
};
struct page_table {
page pages[1024];
};
struct segment_map;
struct page_directory {
page_table *tables[1024]; //Virtual addresses of page tables
uint32_t *tablesPhysical; //Pointer to the virtual address of the page directory (contain phys addr of pt)
uint32_t physicalAddr; //Physical address of info above
segment_map *mappedSegs;
};
extern page_directory *kernel_pagedir, *current_pagedir;
uint32_t frame_alloc();
void frame_free(uint32_t id);
void paging_init(size_t totalRam);
void paging_cleanup();
void pagedir_switch(page_directory *pd);
page_directory *pagedir_new(); //Creates a brand new empty page directory for a process, with kernel pages
void pagedir_delete(page_directory *pagedir);
page *pagedir_getPage(page_directory *pd, uint32_t address, int make);
void page_map(page *page, uint32_t frame, uint32_t user, uint32_t rw);
void page_unmap(page *page);
void page_unmapFree(page *page);
uint32_t paging_fault(registers *regs); //returns a boolean : 1 if unhandled, 0 if ok
#endif
|