-
Notifications
You must be signed in to change notification settings - Fork 0
/
paging.h
57 lines (47 loc) · 1.32 KB
/
paging.h
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
#ifndef _PAGING_H
#define _PAGING_H
#include "types.h"
#define page_dir_size 1024
#define page_table_size 1024
#define num_process 8
#define space_dir_task num_process * page_dir_size
#define space_tab_task num_process * page_table_size
#ifndef ASM
//page directory entry
struct page_directory{
uint32_t present : 1;
uint32_t read_write : 1;
uint32_t user_supervisor : 1;
uint32_t write_through : 1;
uint32_t cache_disabled : 1;
uint32_t accessed : 1;
uint32_t reserved : 1;
uint32_t page_size : 1;
uint32_t global_page : 1;
uint32_t avail : 3;
uint32_t page_table_base : 20;
}__attribute__((packed));
typedef struct page_directory page_dir_entry;
//page table entry
struct page_table{
uint32_t present : 1;
uint32_t read_write : 1;
uint32_t user_supervisor : 1;
uint32_t write_through : 1;
uint32_t cache_disabled : 1;
uint32_t accessed : 1;
uint32_t dirty : 1;
uint32_t pat : 1;
uint32_t global_page : 1;
uint32_t avail : 3;
uint32_t page_base : 20;
}__attribute__((packed));
typedef struct page_table page_table_entry;
//declared in page.S
extern page_dir_entry page_dir[page_dir_size];
extern page_table_entry page_tab[page_table_size];
extern page_dir_entry page_dir_task[num_process][page_dir_size];
extern page_table_entry page_tab_task[num_process][page_table_size];
void init_paging(void);
#endif
#endif