]> git.buserror.net Git - polintos/scott/priv.git/blob - kernel/include/kern/pagetable.h
45d5f2324aa5b472c95b5b8d050ad4afb5b6977f
[polintos/scott/priv.git] / kernel / include / kern / pagetable.h
1 #ifndef _KERN_PAGETABLE_H
2 #define _KERN_PAGETABLE_H
3
4 #include <kern/mem.h>
5 #include <kern/rmap.h>
6
7 namespace Mem {
8         class PageTable {
9         public:
10                 void *toplevel;
11                 RMapTable rmap_table;
12                 const bool is_process;
13
14                 typedef Mem::PTEFlags Flags;
15                 typedef System::Mem::Region Region;
16                 typedef System::Mem::RegionWithOffset RegionWithOffset;
17                 
18                 PageTable(bool process) : is_process(process)
19                 {
20                 }
21
22                 virtual ~PageTable()
23                 {
24                 }
25                 
26                 // Region is virtual, offset is physical
27                 virtual void map(RegionWithOffset region, Flags flags) = 0;
28                 virtual void unmap(Region region) = 0;
29
30                 // Sets the flags which are set in mask to their value in flags.
31                 // Flags not set in mask are untouched.
32                 
33                 virtual void set_flags(Region region, Flags flags, Flags mask) = 0;
34                 
35                 // Returns the physical address and flags associated with a given
36                 // virtual address.  If flags.Valid is not set, then phys and all
37                 // other flags are undefined.  This function is mainly used for
38                 // propagating stacked aspace PTEs.
39                 
40                 virtual void get_mapping(u64 vaddr, u64 *phys, Flags *flags) = 0;
41                 
42                 virtual void get_size(u64 *size) = 0;
43                 
44                 // This is called when a PTE is replaced.  It handles refcounting,
45                 // dirty page queueing, and TLB invalidation.  vaddr is only
46                 // valid for process address spaces, so it doesn't need to be
47                 // 64-bit (except on 64-bit hardware, of course).  When it is
48                 // known that only flags are changing, set no_release so that
49                 // the page refcount is not decremented.
50                 
51                 void kill_pte(ulong vaddr, u64 physaddr, bool dirty, bool valid,
52                               bool no_release = false);
53         };
54 }
55
56 #endif