blob: 1941cb95efb8d474f4d79dccb9fef33d88456c06 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#ifndef MELVIX_PAGING_H
#define MELVIX_PAGING_H
#include <stdint.h>
struct page {
uint32_t present : 1;
uint32_t rw : 1;
uint32_t user : 1;
uint32_t accessed : 1;
uint32_t dirty : 1;
uint32_t unused : 7;
uint32_t frame : 20;
};
struct page_table {
struct page pages[1024];
};
struct page_directory {
struct page_table *tables[1024];
};
struct page_directory *paging_root_directory;
struct page_table *get_cr3();
uint32_t get_cr0();
void set_cr3(struct page_directory *dir);
void set_cr0(uint32_t new_cr0);
void paging_disable();
void paging_enable();
void paging_switch_directory(struct page_directory *dir);
struct page_directory *paging_make_directory();
struct page_table *paging_make_table();
void paging_install();
void paging_map(struct page_directory *cr3, uint32_t virt, uint32_t phys);
void paging_map_user(struct page_directory *cr3, uint32_t virt, uint32_t phys);
void paging_convert_page(struct page_directory *kdir);
struct page_directory *paging_copy_user_directory(struct page_directory *dir);
#define EMPTY_TAB ((struct page_table *)0x00000002)
#define PAGE_S 0x400000
#endif
|