|
The Pedigree Project 0.1
|
#include <MemoryMappedFile.h>
Inheritance diagram for MemoryMappedObject:
Collaboration diagram for MemoryMappedObject:Public Types | |
| typedef int | Permissions |
Public Member Functions | |
| MemoryMappedObject (uintptr_t address, bool bCopyOnWrite, size_t length, Permissions perms, Permissions maximumPerms=Read|Write|Exec) | |
| virtual MemoryMappedObject * | clone ()=0 |
| virtual MemoryMappedObject * | split (uintptr_t at)=0 |
| virtual MemoryMappedObject * | stageSlice (uintptr_t source, size_t sourceLength, uintptr_t destination, size_t destinationLength)=0 |
| void | setMappingOwnership (bool ownsMappings) |
| virtual void | releaseDetachedPage (uintptr_t oldAddress, const VirtualAddressSpace::DetachedPage &page)=0 |
| virtual void | discardRange (VirtualAddressSpace &space, uintptr_t base, size_t length)=0 |
| virtual File * | backingFile () const |
| virtual bool | backingRangeValid (uintptr_t source, size_t length) const |
| virtual bool | resident (VirtualAddressSpace &space, uintptr_t address, FileResidencyAccess access, void *credentials) |
| virtual bool | remove (size_t length)=0 |
| virtual void | setPermissions (Permissions perms)=0 |
| virtual bool | preparePermissions (uintptr_t base, size_t length, Permissions perms) |
| virtual bool | sync (uintptr_t at, bool async) |
| virtual bool | syncRange (uintptr_t at, size_t length, bool async) |
| virtual void | invalidate (uintptr_t at) |
| virtual bool | sharedBacking (uintptr_t at, uintptr_t &identity, size_t &offset) const |
| virtual bool | usesBacking (uintptr_t identity) const |
| virtual bool | beyondBackingEnd (uintptr_t at) const |
| virtual void | discardFilePages (VirtualAddressSpace &space, size_t end) |
| virtual void | unmap ()=0 |
| virtual bool | trap (VirtualAddressSpace &space, uintptr_t address, bool bWrite, PopulationStatus *population=nullptr)=0 |
| virtual PopulationStatus | prepareResidentAccess (VirtualAddressSpace &space, uintptr_t address) |
| PopulationStatus | populatePage (VirtualAddressSpace &space, uintptr_t address) |
| MemoryLockMode | lockMode () const |
| virtual bool | supportsPageOut (VirtualAddressSpace &space, uintptr_t address) |
| virtual SwapStatus | pageOutAt (VirtualAddressSpace &space, uintptr_t address, bool &released) |
| virtual bool | reclaimAnonymousPage (VirtualAddressSpace &space) |
| virtual SwapStatus | restoreSwapPages (VirtualAddressSpace &space) |
| virtual bool | compact () |
| bool | matches (uintptr_t address) |
| uintptr_t | address () const |
| size_t | length () const |
| Permissions | permissions () const |
| Permissions | maximumPermissions () const |
Static Public Attributes | |
| static const int | None = 0x0 |
| static const int | Read = 0x1 |
| static const int | Write = 0x2 |
| static const int | Exec = 0x4 |
Protected Attributes | |
| bool | m_bCopyOnWrite |
| uintptr_t | m_Address |
| size_t | m_Length |
| Permissions | m_Permissions |
| Permissions | m_MaximumPermissions |
| SharedPointer< MappingAttachment > | m_Attachment |
| Process * | m_OwnerProcess |
| bool | m_OwnsMappings |
| MemoryLockMode | m_LockMode |
Private Member Functions | |
| MemoryMappedObject () | |
Friends | |
| class | MemoryMapManager |
Generic base for a memory mapped file or object.
Provides the interface for implementation, while centralising common functionality (such as extents, CoW flags, shared state, etc)
Definition at line 138 of file MemoryMappedFile.h.
| typedef int MemoryMappedObject::Permissions |
Permissions to assign to a mapping when it is created.
Definition at line 147 of file MemoryMappedFile.h.
|
private |
Default constructor, don't use.
|
inline |
Constructor - bring up common metadata.
Definition at line 155 of file MemoryMappedFile.h.
|
virtual |
Definition at line 138 of file MemoryMappedFile.cc.
|
inline |
Getter for base address.
Definition at line 309 of file MemoryMappedFile.h.
References m_Address.
Referenced by MemoryMapManager::allows(), AnonymousMemoryMap::clone(), MemoryMapManager::clone(), MemoryMappedFile::compact(), MemoryMapManager::findAttachment(), matches(), MemoryMapManager::removeAttachment(), AnonymousMemoryMap::setPermissions(), MemoryMappedFile::setPermissions(), AnonymousMemoryMap::split(), AnonymousMemoryMap::stageSlice(), AnonymousMemoryMap::supportsPageOut(), MemoryMappedFile::syncRange(), AnonymousMemoryMap::trap(), and MemoryMappedFile::trap().
Here is the caller graph for this function:
|
inlinevirtual |
Definition at line 197 of file MemoryMappedFile.h.
|
inlinevirtual |
Definition at line 200 of file MemoryMappedFile.h.
|
inlinevirtual |
Definition at line 248 of file MemoryMappedFile.h.
|
pure 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.
Implemented in AnonymousMemoryMap, and MemoryMappedFile.
Referenced by MemoryMapManager::clone().
Here is the caller graph for this function:
|
inlinevirtual |
Reimplemented in MemoryMappedFile.
Definition at line 295 of file MemoryMappedFile.h.
|
inlinevirtual |
Definition at line 251 of file MemoryMappedFile.h.
|
inlinevirtual |
Invalidate cached state without discarding private modifications.
Reimplemented in MemoryMappedFile.
Definition at line 239 of file MemoryMappedFile.h.
|
inline |
Getter for length.
Definition at line 316 of file MemoryMappedFile.h.
References m_Length.
Referenced by MemoryMapManager::allows(), AnonymousMemoryMap::remove(), MemoryMappedFile::remove(), syncRange(), MemoryMappedFile::syncRange(), MemoryMapManager::unmap(), and MemoryMapManager::unmapAllUnlocked().
Here is the caller graph for this function:
|
inline |
Definition at line 274 of file MemoryMappedFile.h.
|
inline |
Determines if the given address is within this object's mapping.
Definition at line 302 of file MemoryMappedFile.h.
References address(), m_Address, and m_Length.
Referenced by MemoryMapManager::contains().
Here is the caller graph for this function:
|
inline |
Definition at line 325 of file MemoryMappedFile.h.
|
inlinevirtual |
Definition at line 286 of file MemoryMappedFile.h.
|
inline |
Permissions granted to this mapping.
Definition at line 321 of file MemoryMappedFile.h.
References m_Permissions.
Referenced by MemoryMapManager::allows(), and AnonymousMemoryMap::setPermissions().
Here is the caller graph for this function:| PopulationStatus MemoryMappedObject::populatePage | ( | VirtualAddressSpace & | space, |
| uintptr_t | address | ||
| ) |
Definition at line 73 of file MemoryMappedFile-lock.cc.
|
inlinevirtual |
Definition at line 224 of file MemoryMappedFile.h.
|
inlinevirtual |
Definition at line 270 of file MemoryMappedFile.h.
|
inlinevirtual |
Definition at line 289 of file MemoryMappedFile.h.
|
pure 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).
Implemented in AnonymousMemoryMap, and MemoryMappedFile.
|
virtual |
Definition at line 12 of file MemoryMappedFile-advice.cc.
|
inlinevirtual |
Definition at line 292 of file MemoryMappedFile.h.
|
inline |
Definition at line 191 of file MemoryMappedFile.h.
|
pure virtual |
Sets permissions on this object.
Resident pages retain their contents and ownership.
Implemented in AnonymousMemoryMap, and MemoryMappedFile.
|
inlinevirtual |
Definition at line 241 of file MemoryMappedFile.h.
|
pure virtual |
Splits the metadata of this object at the given address and creates a new MemoryMappedObject that begins at the page of the split.
Implemented in AnonymousMemoryMap, and MemoryMappedFile.
|
pure virtual |
Prepared slices transfer existing page ownership only after publication.
Implemented in AnonymousMemoryMap, and MemoryMappedFile.
|
inlinevirtual |
Release memory that can be released.
Default implementation returns 'no pages released'.
Reimplemented in AnonymousMemoryMap.
Definition at line 283 of file MemoryMappedFile.h.
|
inlinevirtual |
Sync back the given page to a backing store, if one exists.
Reimplemented in MemoryMappedFile.
Definition at line 231 of file MemoryMappedFile.h.
Referenced by syncRange().
Here is the caller graph for this function:
|
virtual |
Synchronise a contiguous mapping range without imposing a barrier per page.
Reimplemented in MemoryMappedFile.
Definition at line 470 of file MemoryMappedFile.cc.
References PhysicalMemoryManager::getPageSize(), length(), and sync().
|
pure virtual |
Trap entry
Implement this in your implementation to actually perform the mapping of memory into the address space.
Implemented in AnonymousMemoryMap, and MemoryMappedFile.
|
pure virtual |
Unmaps existing mappings in this object from the address space.
Implementations are expected to track these as necessary for the implementation.
Implemented in AnonymousMemoryMap, and MemoryMappedFile.
|
inlinevirtual |
Definition at line 245 of file MemoryMappedFile.h.
|
friend |
Definition at line 139 of file MemoryMappedFile.h.
|
static |
Definition at line 152 of file MemoryMappedFile.h.
|
protected |
Base address of this mapping.
The region from base -> base+length will trap into this object when an access attempt is made that faults.
Definition at line 345 of file MemoryMappedFile.h.
Referenced by address(), AnonymousMemoryMap::clone(), MemoryMappedFile::clone(), MemoryMappedFile::compact(), matches(), AnonymousMemoryMap::remove(), MemoryMappedFile::remove(), MemoryMappedFile::setPermissions(), AnonymousMemoryMap::split(), MemoryMappedFile::split(), AnonymousMemoryMap::stageSlice(), MemoryMappedFile::stageSlice(), MemoryMappedFile::sync(), MemoryMappedFile::syncRange(), and MemoryMappedFile::trap().
|
protected |
Definition at line 366 of file MemoryMappedFile.h.
|
protected |
Is this a Copy-on-Write mapping?
A non-copy-on-write mapping will cause writes to hit the backing store directly. This makes sense for some types of mapping and not for others.
Definition at line 337 of file MemoryMappedFile.h.
Referenced by MemoryMappedFile::clone(), MemoryMappedFile::compact(), MemoryMapManager::hasSharedWriteCapability(), MemoryMappedFile::remove(), MemoryMappedFile::setPermissions(), MemoryMappedFile::split(), AnonymousMemoryMap::stageSlice(), MemoryMappedFile::stageSlice(), AnonymousMemoryMap::supportsPageOut(), MemoryMappedFile::sync(), MemoryMappedFile::syncRange(), and MemoryMappedFile::trap().
|
protected |
Size of the object.
To clarify, this is the size of the mapping itself, not of the entire backing object.
Definition at line 353 of file MemoryMappedFile.h.
Referenced by AnonymousMemoryMap::clone(), MemoryMappedFile::clone(), MemoryMappedFile::compact(), length(), matches(), AnonymousMemoryMap::remove(), MemoryMappedFile::remove(), AnonymousMemoryMap::split(), MemoryMappedFile::split(), AnonymousMemoryMap::stageSlice(), MemoryMappedFile::stageSlice(), MemoryMappedFile::sync(), MemoryMappedFile::syncRange(), and MemoryMappedFile::trap().
|
protected |
Definition at line 371 of file MemoryMappedFile.h.
|
protected |
Definition at line 365 of file MemoryMappedFile.h.
|
protected |
Definition at line 369 of file MemoryMappedFile.h.
|
protected |
Definition at line 370 of file MemoryMappedFile.h.
|
protected |
Permissions for mappings created by this object.
For example, 'None' would mean that a trap will NEVER succeed, and that no premapping will be done. 'Read' might mean that writes will never magically map in a page for writing to.
'Exec' only works on systems that support this (eg, x86_64).
Definition at line 364 of file MemoryMappedFile.h.
Referenced by AnonymousMemoryMap::clone(), MemoryMappedFile::clone(), permissions(), AnonymousMemoryMap::setPermissions(), MemoryMappedFile::setPermissions(), MemoryMappedFile::split(), AnonymousMemoryMap::stageSlice(), MemoryMappedFile::stageSlice(), AnonymousMemoryMap::trap(), and MemoryMappedFile::trap().
|
static |
Definition at line 149 of file MemoryMappedFile.h.
|
static |
Definition at line 150 of file MemoryMappedFile.h.
|
static |
Definition at line 151 of file MemoryMappedFile.h.