ApertureOS
priv_virt_mem_manager.h
Go to the documentation of this file.
1 #ifndef _PRIV_VIRT_MEM_MANAGER_H_
2 #define _PRIV_VIRT_MEM_MANAGER_H_
3 
4 #include "types.h"
5 #include "virt_mem_manager.h"
6 #include "managers.h"
7 
8 #define KMEM_START 0
9 #define KMEM_END 0x40000000
10 #define KMEM_SIZE (KMEM_END-KMEM_START)
11 
12 #define PAT_MSR 0x277
13 
14 //Page Directory Pointer Table Entry
15 typedef struct
16 {
17  uint64_t present : 1;
18  uint64_t res0 : 2;
19  uint64_t write_through : 1;
20  uint64_t cache_disable : 1;
21  uint64_t res1 : 7;
22  uint64_t addr : 40; //Watch out! This is addr we want >> 12
23  uint64_t res2 : 12;
24 } PDPT_Entry;
25 
26 //Page Directory Entry
27 typedef struct
28 {
29  uint64_t present : 1;
30  uint64_t read_write : 1;
31  uint64_t user_supervisor : 1;
32  uint64_t write_through : 1;
33  uint64_t cache_disable : 1;
34  uint64_t accessed : 1;
35  uint64_t res1 : 6;
36  uint64_t addr : 40; //Watch out! This is addr we want >> 12
37  uint64_t res2 : 11;
38  uint64_t nx : 1;
39 } PD_Entry;
40 
41 //Page Directory Entry 2MB pages
42 typedef struct
43 {
44  uint64_t present : 1;
45  uint64_t read_write : 1;
46  uint64_t user_supervisor : 1;
47  uint64_t write_through : 1;
48  uint64_t cache_disable : 1;
49  uint64_t accessed : 1;
50  uint64_t dirty : 1;
51  uint64_t page_size : 1;
52  uint64_t global : 1;
53  uint64_t res1 : 3;
54  uint64_t pat : 1;
55  uint64_t res2 : 8;
56  uint64_t addr : 42; //Watch out! This is addr we want >> 12
57  uint64_t nx : 1;
58 } PD_Entry_PSE;
59 
60 //Page Table Entry
61 typedef struct
62 {
63  uint64_t present : 1;
64  uint64_t read_write : 1;
65  uint64_t user_supervisor : 1;
66  uint64_t write_through : 1;
67  uint64_t cache_disable : 1;
68  uint64_t accessed : 1;
69  uint64_t dirty : 1;
70  uint64_t pat : 1;
71  uint64_t global : 1;
72  uint64_t res1 : 3;
73  uint64_t addr : 40; //Watch out! This is addr we want >> 12
74  uint64_t res2 : 11;
75  uint64_t nx : 1;
76 } PT_Entry;
77 
78 #define GET_ADDR(x) (((PDPT_Entry*)x)->addr << 12)
79 #define SET_ADDR(val) (((uint64_t)(val)) >> 12)
80 
81 #define PDPT_STORAGE_SIZE_U64 ((PAGE_DIR_STORAGE_POOL_SIZE/KB(12)) * 4)
82 
83 uint64_t* virtMemMan_GetFreePDPTEntry();
86 
87 #endif /* end of include guard: _PRIV_VIRT_MEM_MANAGER_H_ */
uint64_t * virtMemMan_GetFreePDPTEntry()
Definition: virt_mem_manager.c:424
Definition: idt.h:10
Definition: priv_virt_mem_manager.h:42
Definition: priv_virt_mem_manager.h:15
uint32_t virtMemMan_PageFaultHandler(Registers *regs)
Definition: virt_mem_manager.c:470
PD_Entry_PSE * virtMemMan_GetFreePageDirEntry()
Definition: virt_mem_manager.c:433
Registers regs
Definition: threads.h:11
Definition: priv_virt_mem_manager.h:27
Definition: priv_virt_mem_manager.h:61