The Pedigree Project
0.1
|
#include <MemoryMappedFile.h>
Public Member Functions | |
AnonymousMemoryMap (uintptr_t address, size_t length, Permissions perms) | |
virtual MemoryMappedObject * | clone () |
virtual MemoryMappedObject * | split (uintptr_t at) |
virtual bool | remove (size_t length) |
virtual void | setPermissions (MemoryMappedObject::Permissions perms) |
virtual void | unmap () |
virtual bool | trap (uintptr_t address, bool bWrite) |
Public Member Functions inherited from MemoryMappedObject | |
MemoryMappedObject (uintptr_t address, bool bCopyOnWrite, size_t length, Permissions perms) | |
virtual void | sync (uintptr_t at, bool async) |
virtual void | invalidate (uintptr_t at) |
virtual bool | compact () |
bool | matches (uintptr_t address) |
uintptr_t | address () const |
size_t | length () const |
Private Member Functions | |
void | unmapUnlocked () |
Private Attributes | |
List< void * > | m_Mappings |
Spinlock | m_Lock |
Static Private Attributes | |
static physical_uintptr_t | m_Zero = 0 |
Additional Inherited Members | |
Public Types inherited from MemoryMappedObject | |
typedef int | Permissions |
Static Public Attributes inherited from MemoryMappedObject | |
static const int | None = 0x0 |
static const int | Read = 0x1 |
static const int | Write = 0x2 |
static const int | Exec = 0x4 |
Protected Attributes inherited from MemoryMappedObject | |
bool | m_bCopyOnWrite |
uintptr_t | m_Address |
size_t | m_Length |
Permissions | m_Permissions |
Anonymous memory map object.
Anonymous memory maps do not map back to an actual file; they back onto a common page full of zeroes with forced copy-on-write. This is perfect for mapping in large .bss sections in binaries or for getting huge amounts of zeroed memory.
Definition at line 284 of file MemoryMappedFile.h.
|
virtual |
Clones the existing metadata of this object into another.
Returns a MemoryMappedObject that exactly matches this one, but which can be used for reference in a new address space. Used for address space clones.
Note that mappings are automatically cloned - only clone metadata in this method.
Implements MemoryMappedObject.
Definition at line 72 of file MemoryMappedFile.cc.
References m_Mappings.
|
virtual |
Removes pages from the start of this MemoryMappedObject.
To remove pages from the middle or end of a MemoryMappedObject, use split() and then remove()/unmap() on the returned object).
Implements MemoryMappedObject.
Definition at line 126 of file MemoryMappedFile.cc.
References List< T, nodePoolSize >::begin(), PhysicalMemoryManager::freePage(), VirtualAddressSpace::getMapping(), PhysicalMemoryManager::getPageSize(), Processor::information(), PhysicalMemoryManager::instance(), VirtualAddressSpace::isMapped(), and VirtualAddressSpace::unmap().
|
virtual |
Sets permissions on this object.
This may trigger unmaps if the new permissions.
Implements MemoryMappedObject.
Definition at line 174 of file MemoryMappedFile.cc.
References List< T, nodePoolSize >::begin(), VirtualAddressSpace::Execute, VirtualAddressSpace::getMapping(), Processor::information(), VirtualAddressSpace::isMapped(), VirtualAddressSpace::setFlags(), VirtualAddressSpace::Shared, and VirtualAddressSpace::Write.
|
virtual |
Splits the metadata of this object at the given address and creates a new MemoryMappedObject that begins at the page of the split.
Implements MemoryMappedObject.
Definition at line 82 of file MemoryMappedFile.cc.
References List< T, nodePoolSize >::begin(), ERROR, m_Mappings, and List< T, nodePoolSize >::pushBack().
|
virtual |
Trap entry
Implement this in your implementation to actually perform the mapping of memory into the address space.
Implements MemoryMappedObject.
Definition at line 233 of file MemoryMappedFile.cc.
References PhysicalMemoryManager::allocatePage(), assert, List< T, nodePoolSize >::begin(), ERROR, VirtualAddressSpace::Execute, PhysicalMemoryManager::freePage(), VirtualAddressSpace::getMapping(), PhysicalMemoryManager::getPageSize(), Hex, Processor::information(), PhysicalMemoryManager::instance(), VirtualAddressSpace::isMapped(), VirtualAddressSpace::map(), NOTICE, PhysicalMemoryManager::pin(), VirtualAddressSpace::Shared, VirtualAddressSpace::unmap(), and VirtualAddressSpace::Write.
|
virtual |
Unmaps existing mappings in this object from the address space.
Implementations are expected to track these as necessary for the implementation.
Implements MemoryMappedObject.
Definition at line 226 of file MemoryMappedFile.cc.
|
private |
Lock for anything to do with the memory mapping.
Definition at line 312 of file MemoryMappedFile.h.
|
private |
List of existing virtual addresses we've mapped in.
Definition at line 309 of file MemoryMappedFile.h.