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
52
53
54
55
56
57
58
59
60
61
|
#ifndef MELVIX_PAGING_H
#define MELVIX_PAGING_H
#include <stdint.h>
#define PAGE_SIZE 0x400000
#define PD_PRESENT 1 << 0
#define PD_RW 1 << 1
#define PD_USER 1 << 2
#define PD_WRITETHR 1 << 3
#define PD_CACHE_D 1 << 4
#define PD_ACCESSED 1 << 5
#define PD_4M_PAGE 1 << 7
#define PT_PRESENT 1 << 0
#define PT_RW 1 << 1
#define PT_USER 1 << 2
#define PT_WRITETHR 1 << 3
#define PT_CACHE_D 1 << 4
#define PT_ACCESSED 1 << 5
#define PT_DIRTY 1 << 6
#define PT_GLOBAL 1 << 8
#define PT_USED 1 << 9
struct page_table {
u32 pages[1024] __attribute__((aligned(4096)));
};
struct page_directory {
struct page_table *tables[1024] __attribute__((aligned(4096)));
};
struct page_directory *paging_kernel_directory __attribute__((aligned(4096)));
int paging_enabled;
void paging_install(u32 multiboot_address);
void paging_enable();
void paging_disable();
struct page_directory *paging_make_directory(int user);
void paging_switch_directory(struct page_directory *dir);
void paging_map(u32 phy, u32 virt, u16 flags);
u32 paging_get_phys(u32 virt);
u16 paging_get_flags(u32 virt);
u32 paging_get_used_pages();
void paging_set_flags(u32 virt, u32 count, u16 flags);
void paging_set_flag_up(u32 virt, u32 count, u32 flag);
void paging_set_flag_down(u32 virt, u32 count, u32 flag);
void paging_set_present(u32 virt, u32 count);
void paging_set_absent(u32 virt, u32 count);
void paging_set_used(u32 virt, u32 count);
void paging_set_free(u32 virt, u32 count);
void paging_set_user(u32 virt, u32 count);
u32 paging_find_pages(u32 count);
u32 paging_alloc_pages(u32 count);
#endif
|