bringelle/src/core/paging.h

47 lines
1,012 B
C
Raw Normal View History

2021-04-11 20:53:06 +02:00
#ifndef PAGING_H
#define PAGING_H
#define PAGING_CR0_BIT 0x80000000
2021-04-13 15:31:45 +02:00
#define PAGING_PAGE_SIZE 4096
2021-04-13 18:09:43 +02:00
#define PAGING_MAX_PAGES 2048 // At least 1024 for the kernel
2021-04-13 15:31:45 +02:00
#if PAGING_MAX_PAGES%1024>0
#define PAGING_MAX_DIR_ENTRY PAGING_MAX_PAGES/1024+1
#else
#define PAGING_MAX_DIR_ENTRY PAGING_MAX_PAGES/1024
#endif
2021-04-16 14:39:24 +02:00
#define PAGING_PADDR(entry) ((int*)(((u32)entry)&0xFFFFF000))
#define PAGING_ENTRY_POINT_VIRT (1024*PAGING_PAGE_SIZE+3*PAGING_PAGE_SIZE)
#define PAGING_ENTRY_POINT_PHY(page_dir) ((int*)(((int*)((((int*)page_dir)[1])&0xFFFFF000))[3]&0xFFFFF000))
2021-04-13 18:09:43 +02:00
/**
2021-04-12 10:13:21 +02:00
* Configure and enable paging
*/
2021-04-11 20:53:06 +02:00
void paging_enable();
2021-04-16 20:20:29 +02:00
2021-04-13 18:09:43 +02:00
/**
* Allocate a new page and return its address
*/
2021-04-13 15:31:45 +02:00
char* paging_allocate_next_page();
2021-04-16 20:20:29 +02:00
2021-04-13 18:09:43 +02:00
/**
* Set usage status of a page
*/
2021-04-13 15:31:45 +02:00
void paging_set_usage(int addr,char state);
2021-04-16 20:20:29 +02:00
2021-04-13 15:31:45 +02:00
/**
* Create a new page directory containing
* p pages.
*/
2021-04-14 14:13:44 +02:00
int *paging_allocate(int p);
2021-04-16 20:20:29 +02:00
/**
* Simple dump
*/
2021-04-13 15:31:45 +02:00
void paging_dump(int min,int max);
2021-04-16 20:20:29 +02:00
2021-04-13 18:09:43 +02:00
/**
* Handler of page fault
*/
void paging_page_fault();
2021-04-16 20:20:29 +02:00
2021-04-11 20:53:06 +02:00
#endif