FreeNOS
ARMPaging.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_ARM_PAGING_H
19 #define __LIBARCH_ARM_PAGING_H
20 
21 #include <Types.h>
22 #include "MemoryContext.h"
23 #include "MemoryMap.h"
24 
26 class SplitAllocator;
27 class ARMFirstTable;
28 
43 class ARMPaging : public MemoryContext
44 {
45  public:
46 
54 
62  ARMPaging(MemoryMap *map, Address firstTableAddress, Address kernelBaseAddress);
63 
67  virtual ~ARMPaging();
68 
74  virtual Result initialize();
75 
85  virtual Result activate(bool initializeMMU = false);
86 
96  virtual Result map(Address virt, Address phys, Memory::Access access);
97 
108  virtual Result unmap(Address virt);
109 
118  virtual Result lookup(Address virt, Address *phys) const;
119 
128  virtual Result access(Address virt, Memory::Access *access) const;
129 
142  virtual Result releaseSection(const Memory::Range & range,
143  const bool tablesOnly = false);
144 
152  virtual Result releaseRange(Memory::Range *range);
153 
154  private:
155 
163  void setupFirstTable(MemoryMap *map, Address firstTableAddress, Address kernelBaseAddress);
164 
170  Result enableMMU();
171 
172  private:
173 
176 
179 
182 
185 };
186 
187 namespace Arch
188 {
189  typedef ARMPaging Memory;
190 };
191 
198 #endif /* __LIBARCH_ARM_PAGING_H */
ARMPaging::activate
virtual Result activate(bool initializeMMU=false)
Activate the MemoryContext.
Definition: ARMPaging.cpp:198
Memory::Range
Memory range.
Definition: Memory.h:55
MemoryContext
Virtual memory abstract interface.
Definition: MemoryContext.h:42
ARMPaging::m_cache
Arch::Cache m_cache
Caching implementation.
Definition: ARMPaging.h:184
Types.h
ARMPaging::ARMPaging
ARMPaging(MemoryMap *map, SplitAllocator *alloc)
Constructor.
Definition: ARMPaging.cpp:28
ARMPaging::releaseRange
virtual Result releaseRange(Memory::Range *range)
Release range of memory.
Definition: ARMPaging.cpp:285
ARMPaging
ARM virtual memory implementation.
Definition: ARMPaging.h:43
Arch
Definition: ARMCacheV6.h:103
ARMFirstTable
ARM first level page table.
Definition: ARMFirstTable.h:43
Address
unsigned long Address
A memory address.
Definition: Types.h:131
ARMPaging::initialize
virtual Result initialize()
Initialize the MemoryContext.
Definition: ARMPaging.cpp:55
ARMPaging::~ARMPaging
virtual ~ARMPaging()
Destructor.
Definition: ARMPaging.cpp:36
ARMPaging::m_firstTable
ARMFirstTable * m_firstTable
Pointer to the first level page table.
Definition: ARMPaging.h:175
ARMPaging::setupFirstTable
void setupFirstTable(MemoryMap *map, Address firstTableAddress, Address kernelBaseAddress)
Installs default mappings on 1st level page table.
ARMPaging::m_kernelBaseAddr
Address m_kernelBaseAddr
Kernel base address.
Definition: ARMPaging.h:181
SplitAllocator
Allocator which separates kernel mapped memory at virtual and physical addresses.
Definition: SplitAllocator.h:37
ARMPaging::lookup
virtual Result lookup(Address virt, Address *phys) const
Translate virtual address to physical address.
Definition: ARMPaging.cpp:269
MemoryContext::Result
Result
Result codes.
Definition: MemoryContext.h:49
ARMCacheV6
ARMv6 cache management implementation.
Definition: ARMCacheV6.h:42
MemoryMap
Describes virtual memory map layout.
Definition: MemoryMap.h:38
ARMPaging::access
virtual Result access(Address virt, Memory::Access *access) const
Get Access flags for a virtual address.
Definition: ARMPaging.cpp:274
MemoryMap.h
Memory::Access
Access
Memory access flags.
Definition: Memory.h:38
ARMPaging::m_firstTableAddr
Address m_firstTableAddr
Physical address of the first level page table.
Definition: ARMPaging.h:178
Arch::Memory
ARMPaging Memory
Definition: ARMPaging.h:189
ARMPaging::map
virtual Result map(Address virt, Address phys, Memory::Access access)
Map a physical page to a virtual address.
Definition: ARMPaging.cpp:237
ARMPaging::releaseSection
virtual Result releaseSection(const Memory::Range &range, const bool tablesOnly=false)
Release memory sections.
Definition: ARMPaging.cpp:279
ARMPaging::enableMMU
Result enableMMU()
Enable the MMU.
MemoryContext.h
ARMPaging::unmap
virtual Result unmap(Address virt)
Unmap a virtual address.
Definition: ARMPaging.cpp:251