The Pedigree Project  0.1
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
AnonymousMemoryMap Class Reference

#include <MemoryMappedFile.h>

+ Inheritance diagram for AnonymousMemoryMap:
+ Collaboration diagram for AnonymousMemoryMap:

Public Member Functions

 AnonymousMemoryMap (uintptr_t address, size_t length, Permissions perms)
 
virtual MemoryMappedObjectclone ()
 
virtual MemoryMappedObjectsplit (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
 

Detailed Description

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.

Member Function Documentation

MemoryMappedObject * AnonymousMemoryMap::clone ( )
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.

bool AnonymousMemoryMap::remove ( size_t  length)
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).

Returns
true if the remove() has effectively removed the entire MemoryMappedObject, false otherwise.

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().

void AnonymousMemoryMap::setPermissions ( MemoryMappedObject::Permissions  perms)
virtual
MemoryMappedObject * AnonymousMemoryMap::split ( uintptr_t  at)
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().

bool AnonymousMemoryMap::trap ( uintptr_t  address,
bool  bWrite 
)
virtual
void AnonymousMemoryMap::unmap ( )
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.

Member Data Documentation

Spinlock AnonymousMemoryMap::m_Lock
private

Lock for anything to do with the memory mapping.

Definition at line 312 of file MemoryMappedFile.h.

List<void *> AnonymousMemoryMap::m_Mappings
private

List of existing virtual addresses we've mapped in.

Definition at line 309 of file MemoryMappedFile.h.

Referenced by clone(), and split().


The documentation for this class was generated from the following files: