FreeNOS
IntelPageDirectory.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Niek Linnenbank
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __LIBARCH_INTEL_PAGEDIRECTORY_H
19 #define __LIBARCH_INTEL_PAGEDIRECTORY_H
20 
21 #include <Types.h>
22 #include <MemoryContext.h>
23 #include "IntelPageTable.h"
24 
26 class SplitAllocator;
27 
43 {
44  public:
45 
56  Address from,
57  Address to);
58 
70  Address phys,
72  SplitAllocator *alloc);
73 
83  SplitAllocator *alloc);
84 
95  Address *phys,
96  SplitAllocator *alloc) const;
97 
109  SplitAllocator *alloc) const;
110 
121  SplitAllocator *alloc,
122  const bool tablesOnly);
123 
133  SplitAllocator *alloc);
134 
135  private:
136 
143  inline void releasePhysical(SplitAllocator *alloc,
144  const Address phys);
145 
154  IntelPageTable * getPageTable(Address virt, SplitAllocator *alloc) const;
155 
164 
165  private:
166 
168  u32 m_tables[1024];
169 };
170 
177 #endif /* __LIBARCH_INTEL_PAGEDIRECTORY_H */
IntelPageDirectory::releaseSection
MemoryContext::Result releaseSection(const Memory::Range range, SplitAllocator *alloc, const bool tablesOnly)
Release memory sections.
Definition: IntelPageDirectory.cpp:189
Memory::Range
Memory range.
Definition: Memory.h:55
IntelPageTable
Intel second level page table implementation.
Definition: IntelPageTable.h:39
Types.h
IntelPageDirectory::unmap
MemoryContext::Result unmap(Address virt, SplitAllocator *alloc)
Remove virtual address mapping.
Definition: IntelPageDirectory.cpp:92
IntelPageDirectory::m_tables
u32 m_tables[1024]
Array of page directory entries.
Definition: IntelPageDirectory.h:168
Address
unsigned long Address
A memory address.
Definition: Types.h:131
IntelPageTable.h
IntelPageDirectory::copy
MemoryContext::Result copy(IntelPageDirectory *directory, Address from, Address to)
Copy mappings from another directory.
Definition: IntelPageDirectory.cpp:52
IntelPageDirectory::releasePhysical
void releasePhysical(SplitAllocator *alloc, const Address phys)
Release a single physical page.
Definition: IntelPageDirectory.cpp:143
IntelPageDirectory::translate
MemoryContext::Result translate(Address virt, Address *phys, SplitAllocator *alloc) const
Translate virtual address to physical address.
Definition: IntelPageDirectory.cpp:101
SplitAllocator
Allocator which separates kernel mapped memory at virtual and physical addresses.
Definition: SplitAllocator.h:37
MemoryContext::Result
Result
Result codes.
Definition: MemoryContext.h:49
u32
unsigned int u32
Unsigned 32-bit number.
Definition: Types.h:53
IntelPageDirectory::access
MemoryContext::Result access(Address virt, Memory::Access *access, SplitAllocator *alloc) const
Get Access flags for a virtual address.
Definition: IntelPageDirectory.cpp:122
Memory::Access
Access
Memory access flags.
Definition: Memory.h:38
IntelPageDirectory
Intel page directory implementation.
Definition: IntelPageDirectory.h:42
IntelPageDirectory::flags
u32 flags(Memory::Access access) const
Convert Memory::Access to page directory flags.
Definition: IntelPageDirectory.cpp:133
IntelPageDirectory::releaseRange
MemoryContext::Result releaseRange(const Memory::Range range, SplitAllocator *alloc)
Release range of memory.
Definition: IntelPageDirectory.cpp:163
IntelPageDirectory::map
MemoryContext::Result map(Address virt, Address phys, Memory::Access access, SplitAllocator *alloc)
Map a virtual address to a physical address.
Definition: IntelPageDirectory.cpp:64
MemoryContext.h
IntelPageDirectory::getPageTable
IntelPageTable * getPageTable(Address virt, SplitAllocator *alloc) const
Retrieve second level page table.
Definition: IntelPageDirectory.cpp:41