FreeNOS
|
Allocates virtual memory using the memory server. More...
#include <PageAllocator.h>
Public Member Functions | |
PageAllocator (const Range range) | |
Class constructor. More... | |
virtual Size | available () const |
Get memory available. More... | |
virtual Result | allocate (Range &args) |
Allocate memory. More... | |
virtual Result | release (const Address addr) |
Release memory. More... | |
Public Member Functions inherited from Allocator | |
Allocator () | |
Default class constructor. More... | |
Allocator (const Range range) | |
Class constructor with Range input. More... | |
virtual | ~Allocator () |
Class destructor. More... | |
void | setParent (Allocator *parent) |
Set parent allocator. More... | |
Allocator * | parent () |
Get parent Allocator. More... | |
Address | base () const |
Get memory base address for allocations. More... | |
Size | alignment () const |
Get memory alignment in bytes for allocations. More... | |
virtual Size | size () const |
Get memory size. More... | |
Private Attributes | |
Size | m_allocated |
Total number of bytes allocated. More... | |
Static Private Attributes | |
static const Size | MinimumAllocationSize = PAGESIZE * 32U |
Minimum size required for allocations. More... | |
Additional Inherited Members | |
Public Types inherited from Allocator | |
enum | Result { Success = 0, InvalidAddress, InvalidSize, InvalidAlignment, OutOfMemory } |
Allocation results. More... | |
typedef struct Allocator::Range | Range |
Describes a range of memory. More... | |
Static Public Member Functions inherited from Allocator | |
static void | setDefault (Allocator *alloc) |
Makes the given Allocator the default. More... | |
static Allocator * | getDefault () |
Retrieve the currently default Allocator. More... | |
Protected Member Functions inherited from Allocator | |
Address | aligned (const Address addr, const Size boundary) const |
Align memory address. More... | |
Allocates virtual memory using the memory server.
Definition at line 36 of file PageAllocator.h.
PageAllocator::PageAllocator | ( | const Range | range | ) |
Class constructor.
range | Block of continguous memory to be managed. |
Definition at line 21 of file PageAllocator.cpp.
|
virtual |
Allocate memory.
args | Contains the requested size and alignment on input. On output, contains the actual allocated address. |
Reimplemented from Allocator.
Definition at line 32 of file PageAllocator.cpp.
References Memory::Range::access, Allocator::Range::address, Allocator::aligned(), Allocator::base(), ERROR, m_allocated, MapSparse, MinimumAllocationSize, Allocator::OutOfMemory, PAGESIZE, Memory::Range::phys, MemoryMap::range(), Memory::Readable, SELF, Memory::Range::size, Allocator::Range::size, Allocator::Success, API::Success, Memory::User, MemoryMap::UserHeap, Memory::Range::virt, VMCtl(), Memory::Writable, and ZERO.
|
virtual |
Get memory available.
Reimplemented from Allocator.
Definition at line 27 of file PageAllocator.cpp.
References m_allocated, and Allocator::size().
|
virtual |
Release memory.
addr | Points to memory previously returned by allocate(). |
Reimplemented from Allocator.
Definition at line 73 of file PageAllocator.cpp.
References Allocator::InvalidAddress.
|
private |
Total number of bytes allocated.
Definition at line 87 of file PageAllocator.h.
Referenced by allocate(), and available().
Minimum size required for allocations.
Definition at line 41 of file PageAllocator.h.
Referenced by allocate().