bringelle/src/core/paging.h

36 lines
785 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-14 18:16:31 +02:00
#define PADDR(entry) (((u32)entry)&0xFFFFF000)
2021-04-11 20:53:06 +02:00
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-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-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);
/**
* Create a new page directory containing
* p pages.
*/
2021-04-14 14:13:44 +02:00
int *paging_allocate(int p);
2021-04-13 15:31:45 +02:00
void paging_dump(int min,int max);
2021-04-13 18:09:43 +02:00
/**
* Handler of page fault
*/
void paging_page_fault();
2021-04-11 20:53:06 +02:00
#endif