#include <kernel/kernel_map.h>
Go to the source code of this file.
Data Structures | |||||||
struct | PAGE_TABLE | ||||||
Page table structure. More... | |||||||
Defines | |||||||
#define | PAGE_SIZE 4096U | ||||||
The page size. | |||||||
#define | P_PRESENT 0x01 | ||||||
Page present flag. | |||||||
#define | P_WRITE 0x02 | ||||||
Page writeable flag. | |||||||
#define | P_USER 0x04 | ||||||
Page at user privilege level. | |||||||
#define | P_ACCESSED 0x20 | ||||||
Page accessed flag. | |||||||
#define | P_DIRTY 0x40 | ||||||
Page dirty flag (the page has been written). | |||||||
#define | P_ADDR_16MB (0x1000000 / PAGE_SIZE) | ||||||
16MB expressed in pages. | |||||||
#define | P_ADDR_4GB 0x100000 | ||||||
4GB expressed in pages. | |||||||
#define | PAGE_ALIGN_UP(addr) (((addr) + PAGE_SIZE - 1) & -PAGE_SIZE) | ||||||
Rounds an address up to a page boundary. | |||||||
#define | PAGE_ALIGN(addr) ((addr) & -PAGE_SIZE) | ||||||
Rounds an address down to a page boundary. | |||||||
#define | PAGE_DIR_ALIGN_UP(addr) (((addr) & -(PAGE_SIZE*1024)) + PAGE_SIZE*1024) | ||||||
Rounds an address up to a page directory boundary. | |||||||
#define | PAGE_DIR_ALIGN(addr) ((addr) & -(PAGE_SIZE*1024)) | ||||||
Rounds an address down to a page directory boundary. | |||||||
#define | ADDR_TO_PAGE(addr) (addr / PAGE_SIZE) | ||||||
Converts from address to page. | |||||||
#define | PAGE_TO_ADDR(p_addr) (p_addr * PAGE_SIZE) | ||||||
Converts from page to address. | |||||||
#define | GET_PDBR() (*ADDR_TO_PDE(PAGE_TABLE_MAP) & -PAGE_SIZE) | ||||||
Get current page directory base address. | |||||||
#define | ADDR_TO_PDE(addr) (dword *)(PAGE_DIR_MAP + (((dword) (addr) / (1024 * 1024))&(~0x3))) | ||||||
Access to the page directory entry referred to the virtual address addr . | |||||||
#define | ADDR_TO_PTE(addr) (dword *)(PAGE_TABLE_MAP + ((((dword) (addr) / 1024))&(~0x3))) | ||||||
Access to the page table entry referred to the virtual address addr . | |||||||
#define | PHYSICAL(addr) (addr+PHYS_MEM_START) | ||||||
Access to an address into the mapped physical memory area. | |||||||
#define | flush_tlb_single(addr) __asm__ __volatile__("invlpg %0": :"m" (*(char *) addr)) | ||||||
Flush a single entry into the TLB cache (address translation).
| |||||||
#define | flush_tlb_all() | ||||||
Flush every entry into the TLB cache (address translation). | |||||||
Typedefs | |||||||
typedef PAGE_TABLE | page_table_t | ||||||
Page table structure. | |||||||
Functions | |||||||
void | init_paging () | ||||||
Initialize the paging mechanism.
| |||||||
dword | pop_frame () | ||||||
Pop a free frame from the free frames stack.
| |||||||
void | push_frame (dword p_addr) | ||||||
Push a free frame into the free frames stack.
| |||||||
bool | map_page (dword vir_addr, dword phys_addr, word attribs) | ||||||
Map a physical address into a virtual address for the current address space.
| |||||||
void | unmap_page (dword vir_addr) | ||||||
Unmap a page, but doesn't destroy the physical frame.
| |||||||
void | delete_page (dword vir_addr) | ||||||
Unmap a page and destroy the physical frame where the address is mapped.
| |||||||
void * | get_temp_page () | ||||||
Get a free virtual page from the temporary memory area.
| |||||||
void | free_temp_page (void *p, bool do_delete) | ||||||
Free a virtual temporary page allocated by get_temp_page().
| |||||||
dword | vir_to_phys (dword vir_addr) | ||||||
Translate a virtual address into the physical address.
| |||||||
int | page_fault_handler (dword err_code, dword cr2) | ||||||
This is the page-fault handler. Every time a page-fault occurs, this routine must be invoked.
| |||||||
void | dump_dirty_pages () | ||||||
Dump the dirty pages to stdout. | |||||||
void | dump_free_frames () | ||||||
Dump the free frames to stdout. | |||||||
void | check_free_frames_integrity () | ||||||
This process checks the free frames stack integrity.
|
Definition in file paging.h.
|
Converts from address to page.
|
|
Access to the page directory entry referred to the virtual address
|
|
Access to the page table entry referred to the virtual address
|
|
Value: do { \ unsigned int tmpreg; \ \ __asm__ __volatile__( \ "movl %%cr3, %0; # flush TLB \n" \ "movl %0, %%cr3; \n" \ : "=r" (tmpreg) \ :: "memory"); \ } while (0)
|
|
Flush a single entry into the TLB cache (address translation).
|
|
Get current page directory base address.
|
|
Page accessed flag.
|
|
16MB expressed in pages.
|
|
4GB expressed in pages.
|
|
Page dirty flag (the page has been written).
|
|
Page present flag.
|
|
Page at user privilege level.
|
|
Page writeable flag.
|
|
Rounds an address down to a page boundary.
|
|
Rounds an address up to a page boundary.
|
|
Rounds an address down to a page directory boundary.
|
|
Rounds an address up to a page directory boundary.
|
|
The page size.
|
|
Converts from page to address.
|
|
Access to an address into the mapped physical memory area.
|
|
Page table structure.
|