Go to the documentation of this file.
18 #pragma clang optimize off
19 #pragma GCC push_options
20 #pragma GCC optimize ("O0")
22 #include <FreeNOS/System.h>
31 , m_mapRangeSparseCallback(this, &
MemoryContext::mapRangeSparseCallback)
33 , m_numSparsePages(
ZERO)
120 Size currentSize = 0;
123 while (addr < r.
virt+r.
size && currentSize < size)
137 if (currentSize >= size)
Memory::Range * m_savedRange
Saved range input for use in the mapRangeSparse Callback.
virtual Result allocate(Range &args)
Allocate physical memory.
Virtual memory abstract interface.
virtual Result unmapRange(Memory::Range *range)
Unmaps a range of virtual memory.
MemoryContext(MemoryMap *map, SplitAllocator *alloc)
Constructor.
virtual Result release(Address virt)
Release a memory page mapping.
#define PAGESIZE
ARM uses 4K pages.
virtual Result map(Address virt, Address phys, Memory::Access access)=0
Map a physical page to a virtual address.
unsigned long Address
A memory address.
Address address
Starting address of the memory range.
virtual Result unmap(Address virt)=0
Unmap a virtual address.
Size alignment
Alignment in bytes or ZERO for default alignment.
Size size
Amount of memory in bytes.
Allocator which separates kernel mapped memory at virtual and physical addresses.
virtual Result lookup(Address virt, Address *phys) const =0
Translate virtual address to physical address.
Callback< MemoryContext, Address > m_mapRangeSparseCallback
Callback object for mapRangeSparseCallback function.
Address phys
Physical address.
Memory::Range range(Region region) const
Get memory range for the given region.
virtual void mapRangeSparseCallback(Address *phys)
Callback to provide intermediate Range object during mapRangeSparse()
virtual Result findFree(Size size, MemoryMap::Region region, Address *virt) const
Find unused memory.
Describes virtual memory map layout.
unsigned int Size
Any sane size indicator cannot go negative.
static MemoryContext * getCurrent()
Get currently active MemoryContext.
Describes a range of memory.
Size m_numSparsePages
Number of pages allocated via mapRangeSparse Callback.
#define assert(exp)
Insert program diagnostics.
virtual Result release(const Address addr)
Release memory page.
static MemoryContext * m_current
The currently active MemoryContext.
virtual ~MemoryContext()
Destructor.
Address virt
Virtual address.
Size size
Size in number of bytes.
Access access
Page access flags.
SplitAllocator * m_alloc
Physical memory allocator.
virtual Result mapRangeContiguous(Memory::Range *range)
Map a range of contiguous physical pages to virtual addresses.
virtual Result mapRangeSparse(Memory::Range *range)
Map and allocate a range of sparse (non-contiguous) physical pages to virtual addresses.
MemoryMap * m_map
Virtual memory layout.
Result allocateSparse(const Range &range, CallbackFunction *function)
Allocate sparse (non-contiguous) physical memory.