|
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) | |
| virtual MemoryMappedObject * | clone ()=0 |
| virtual MemoryMappedObject * | split (uintptr_t at)=0 |
| virtual bool | remove (size_t length)=0 |
| virtual void | setPermissions (Permissions perms)=0 |
| virtual void | sync (uintptr_t at, bool async) |
| virtual void | invalidate (uintptr_t at) |
| virtual void | unmap ()=0 |
| virtual bool | trap (uintptr_t address, bool bWrite)=0 |
| virtual bool | compact () |
| bool | matches (uintptr_t address) |
| uintptr_t | address () const |
| size_t | length () 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 |
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 108 of file MemoryMappedFile.h.
| typedef int MemoryMappedObject::Permissions |
Permissions to assign to a mapping when it is created.
Definition at line 118 of file MemoryMappedFile.h.
|
private |
Default constructor, don't use.
|
inline |
Constructor - bring up common metadata.
Definition at line 126 of file MemoryMappedFile.h.
References clone(), length(), setPermissions(), and split().
|
inline |
Getter for base address.
Definition at line 225 of file MemoryMappedFile.h.
References m_Address.
Referenced by MemoryMapManager::instance(), invalidate(), MemoryMapManager::remove(), and MemoryMapManager::setPermissions().
Here is the caller graph for this function:
|
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 MemoryMappedFile, and AnonymousMemoryMap.
Referenced by MemoryMapManager::clone(), MemoryMapManager::instance(), and MemoryMappedObject().
Here is the caller graph for this function:
|
inlinevirtual |
Release memory that can be released.
Default implementation returns 'no pages released'.
Reimplemented in MemoryMappedFile.
Definition at line 209 of file MemoryMappedFile.h.
Referenced by MemoryMapManager::instance().
Here is the caller graph for this function:
|
inlinevirtual |
If the given page is dirty (and this is a CoW mapping), restore it to the file's actual content.
Reimplemented in MemoryMappedFile.
Definition at line 183 of file MemoryMappedFile.h.
References address(), trap(), and unmap().
Referenced by MemoryMapManager::contains(), and MemoryMapManager::instance().
Here is the caller graph for this function:
|
inline |
Getter for length.
Definition at line 233 of file MemoryMappedFile.h.
References m_Length.
Referenced by MemoryMapManager::instance(), MemoryMappedObject(), MemoryMapManager::remove(), and MemoryMapManager::setPermissions().
Here is the caller graph for this function:
|
inline |
Determines if the given address is within this object's mapping.
Definition at line 217 of file MemoryMappedFile.h.
References m_Address, and m_Length.
Referenced by MemoryMapManager::contains(), and MemoryMapManager::trap().
Here is the caller graph for this function:
|
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 MemoryMappedFile, and AnonymousMemoryMap.
Referenced by MemoryMapManager::remove().
Here is the caller graph for this function:
|
pure virtual |
Sets permissions on this object.
This may trigger unmaps if the new permissions.
Implemented in MemoryMappedFile, and AnonymousMemoryMap.
Referenced by MemoryMapManager::instance(), MemoryMappedObject(), and MemoryMapManager::setPermissions().
Here is the caller graph for this function:
|
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 MemoryMappedFile, and AnonymousMemoryMap.
Referenced by MemoryMappedObject(), MemoryMapManager::remove(), and MemoryMapManager::setPermissions().
Here is the caller graph for this function:
|
inlinevirtual |
Sync back the given page to a backing store, if one exists.
Reimplemented in MemoryMappedFile.
Definition at line 175 of file MemoryMappedFile.h.
Referenced by MemoryMapManager::contains(), and MemoryMapManager::instance().
Here is the caller graph for this function:
|
pure virtual |
Trap entry
Implement this in your implementation to actually perform the mapping of memory into the address space.
Implemented in MemoryMappedFile, and AnonymousMemoryMap.
Referenced by MemoryMapManager::instance(), invalidate(), and MemoryMapManager::trap().
Here is the caller graph for this function:
|
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 MemoryMappedFile, and AnonymousMemoryMap.
Referenced by MemoryMapManager::instance(), invalidate(), and MemoryMapManager::remove().
Here is the caller graph for this function:
|
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 254 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 246 of file MemoryMappedFile.h.
|
protected |
Size of the object.
To clarify, this is the size of the mapping itself, not of the entire backing object.
Definition at line 262 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 273 of file MemoryMappedFile.h.
1.8.11