18#include <FreeNOS/System.h>
33#define PAGE1_TABLE (1 << 0)
34#define PAGE1_SECTION (1 << 1)
55#define PAGE1_UNCACHED (PAGE1_TEX)
58#define PAGE1_CACHE_WRITEBACK (PAGE1_TEX | PAGE1_CACHE | PAGE1_BUFFER)
61#define PAGE1_CACHE_WRITETHROUGH (PAGE1_CACHE)
64#define PAGE1_DEVICE_PRIV ((1 << 13))
67#define PAGE1_DEVICE_SHARED (PAGE1_BUFFER)
69#define PAGE1_TEX (1 << 12)
70#define PAGE1_CACHE (1 << 3)
71#define PAGE1_BUFFER (1 << 2)
72#define PAGE1_SHARED (1 << 16)
84#define PAGE1_NOEXEC (1 << 4)
88#define PAGE1_APX (1 << 15)
90#define PAGE1_APX (1 << 9)
94#define PAGE1_AP_USER (1 << 11)
97#define PAGE1_AP_SYS (1 << 10)
110#define DIRENTRY(vaddr) \
111 ((vaddr) >> DIRSHIFT)
163 if (range.
size & 0xfffff)
197 return table->
unmap(virt);
255 const Size allocSize = alloc->
size();
256 if (phys < allocBase || phys > allocBase + allocSize)
297 const bool tablesOnly)
#define DIRENTRY(vaddr)
Entry inside the page directory of a given virtual address.
#define PAGE1_CACHE_WRITEBACK
Outer and Inner Write-Back.
#define PAGE1_UNCACHED
Disable all caching.
#define PAGE1_NOEXEC
No-execution flag.
#define PAGE1_DEVICE_SHARED
Memory Mapped Device (Shared)
ARMv6 cache management implementation.
MemoryContext::Result unmap(Address virt, SplitAllocator *alloc)
Remove virtual address mapping.
ARMSecondTable * getSecondTable(Address virt, SplitAllocator *alloc) const
Retrieve second level page table.
MemoryContext::Result map(Address virt, Address phys, Memory::Access access, SplitAllocator *alloc)
Map a virtual address to a physical address.
MemoryContext::Result releaseSection(const Memory::Range range, SplitAllocator *alloc, const bool tablesOnly)
Release memory sections.
MemoryContext::Result translate(Address virt, Address *phys, SplitAllocator *alloc) const
Translate virtual address to physical address.
MemoryContext::Result releaseRange(const Memory::Range range, SplitAllocator *alloc)
Release range of memory.
u32 flags(Memory::Access access) const
Convert Memory::Access to first level page table flags.
MemoryContext::Result access(Address virt, Memory::Access *access, SplitAllocator *alloc) const
Get Access flags for a virtual address.
MemoryContext::Result mapLarge(Memory::Range range, SplitAllocator *alloc)
Map a contigous range of virtual memory to physical memory.
void releasePhysical(SplitAllocator *alloc, const Address phys)
Release a single physical page.
u32 m_tables[4096]
Array of page table entries.
ARM second level page table implementation.
MemoryContext::Result map(Address virt, Address phys, Memory::Access)
Map a virtual address to a physical address.
MemoryContext::Result access(Address virt, Memory::Access *access) const
Get Access flags for a virtual address.
MemoryContext::Result translate(Address virt, Address *phys) const
Translate virtual address to physical address.
MemoryContext::Result unmap(Address virt)
Remove virtual address mapping.
Address base() const
Get memory base address for allocations.
virtual Size size() const
Get memory size.
virtual Result cleanData(Address addr)
Clean one data page.
static void * set(void *dest, int ch, unsigned count)
Fill memory with a constant byte.
Allocator which separates kernel mapped memory at virtual and physical addresses.
virtual Result allocate(Range &args)
Allocate physical memory.
bool isAllocated(const Address page) const
Check if a physical page is allocated.
Address toVirtual(const Address phys) const
Convert Address to virtual pointer.
virtual Result release(const Address addr)
Release memory page.
#define PAGESIZE
ARM uses 4K pages.
#define PAGEMASK
Mask to find the page.
#define SECTIONMASK
Mask for large 1MiB section mappings.
unsigned int u32
Unsigned 32-bit number.
unsigned long Address
A memory address.
#define MegaByte(v)
Convert megabytes to bytes.
unsigned int Size
Any sane size indicator cannot go negative.
Access
Memory access flags.
Describes a range of memory.
Size alignment
Alignment in bytes or ZERO for default alignment.
Address address
Starting address of the memory range.
Size size
Amount of memory in bytes.
Size size
Size in number of bytes.
Address phys
Physical address.
Address virt
Virtual address.
Access access
Page access flags.