gem5  v20.1.0.0
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
VMA Class Reference

#include <vma.hh>

Classes

class  MappedFileBuffer
 MappedFileBuffer is a wrapper around a region of host memory backed by a file. More...
 

Public Member Functions

 VMA (AddrRange r, Addr page_bytes, const std::string &vma_name="anon", int fd=-1, off_t off=0)
 
void remap (Addr new_start)
 Remap the virtual memory area starting at new_start. More...
 
bool hasHostBuf () const
 Check if the virtual memory area has an equivalent buffer on the host machine. More...
 
void fillMemPages (Addr start, Addr size, PortProxy &port) const
 Copy memory from a buffer which resides on the host machine into a section of memory on the target. More...
 
bool isStrictSuperset (const AddrRange &range) const
 Returns true if desired range exists within this virtual memory area and does not include the start and end addresses. More...
 
void sliceRegionRight (Addr slice_addr)
 Remove the address range to the right of slice_addr. More...
 
void sliceRegionLeft (Addr slice_addr)
 Remove the address range to the left of slice_addr. More...
 
const std::string & getName ()
 
Addr size ()
 Defer AddrRange related calls to the AddrRange. More...
 
Addr start ()
 
Addr end ()
 
bool mergesWith (const AddrRange &r) const
 
bool intersects (const AddrRange &r) const
 
bool isSubset (const AddrRange &r) const
 
bool contains (const Addr &a) const
 

Private Member Functions

void sanityCheck ()
 

Private Attributes

AddrRange _addrRange
 Address range for this virtual memory area. More...
 
Addr _pageBytes
 Number of bytes in an OS page. More...
 
std::shared_ptr< MappedFileBuffer_origHostBuf
 The host file backing will be chopped up and reassigned as pages are mapped, remapped, and unmapped. More...
 
void * _hostBuf
 Host buffer ptr for this virtual memory area. More...
 
uint64_t _hostBufLen
 Length of host buffer for this virtual memory area. More...
 
std::string _vmaName
 Human-readable name associated with the virtual memory area. More...
 

Detailed Description

Definition at line 40 of file vma.hh.

Constructor & Destructor Documentation

◆ VMA()

VMA::VMA ( AddrRange  r,
Addr  page_bytes,
const std::string &  vma_name = "anon",
int  fd = -1,
off_t  off = 0 
)
inline

Definition at line 45 of file vma.hh.

References _hostBuf, _hostBufLen, _origHostBuf, DPRINTF, ArmISA::fd, MipsISA::r, and sanityCheck().

Member Function Documentation

◆ contains()

bool VMA::contains ( const Addr a) const
inline

Definition at line 132 of file vma.hh.

References _addrRange, ArmISA::a, and AddrRange::contains().

◆ end()

Addr VMA::end ( )
inline

Definition at line 111 of file vma.hh.

References _addrRange, and AddrRange::end().

◆ fillMemPages()

void VMA::fillMemPages ( Addr  start,
Addr  size,
PortProxy port 
) const

Copy memory from a buffer which resides on the host machine into a section of memory on the target.

Try to copy a full page, but don't overrun the size of the file.

Definition at line 38 of file vma.cc.

References _addrRange, _hostBuf, _hostBufLen, _pageBytes, ArmISA::offset, size(), start(), AddrRange::start(), and PortProxy::writeBlob().

◆ getName()

const std::string& VMA::getName ( )
inline

Definition at line 104 of file vma.hh.

References _vmaName.

◆ hasHostBuf()

bool VMA::hasHostBuf ( ) const
inline

Check if the virtual memory area has an equivalent buffer on the host machine.

Definition at line 80 of file vma.hh.

References _origHostBuf.

Referenced by sliceRegionLeft(), and sliceRegionRight().

◆ intersects()

bool VMA::intersects ( const AddrRange r) const
inline

Definition at line 120 of file vma.hh.

References _addrRange, AddrRange::intersects(), and MipsISA::r.

◆ isStrictSuperset()

bool VMA::isStrictSuperset ( const AddrRange range) const

Returns true if desired range exists within this virtual memory area and does not include the start and end addresses.

Definition at line 52 of file vma.cc.

References _addrRange, AddrRange::end(), MipsISA::r, and AddrRange::start().

◆ isSubset()

bool VMA::isSubset ( const AddrRange r) const
inline

Definition at line 126 of file vma.hh.

References _addrRange, AddrRange::isSubset(), and MipsISA::r.

◆ mergesWith()

bool VMA::mergesWith ( const AddrRange r) const
inline

Definition at line 114 of file vma.hh.

References _addrRange, AddrRange::mergesWith(), and MipsISA::r.

◆ remap()

void VMA::remap ( Addr  new_start)
inline

Remap the virtual memory area starting at new_start.

Definition at line 66 of file vma.hh.

References _addrRange, DPRINTF, AddrRange::end(), sanityCheck(), AddrRange::size(), and AddrRange::start().

◆ sanityCheck()

void VMA::sanityCheck ( )
private

Avoid regions without a length.

Avoid regions with an end point before the start point

Avoid non-aligned regions; we assume in the code that the regions are page aligned so consider this to be a bug.

Definition at line 99 of file vma.cc.

References _addrRange, _pageBytes, AddrRange::end(), and AddrRange::start().

Referenced by remap(), sliceRegionLeft(), sliceRegionRight(), and VMA().

◆ size()

Addr VMA::size ( )
inline

Defer AddrRange related calls to the AddrRange.

Definition at line 109 of file vma.hh.

References _addrRange, and AddrRange::size().

Referenced by fillMemPages().

◆ sliceRegionLeft()

void VMA::sliceRegionLeft ( Addr  slice_addr)

Remove the address range to the left of slice_addr.

Definition at line 74 of file vma.cc.

References _addrRange, _hostBuf, _hostBufLen, _origHostBuf, DPRINTF, AddrRange::end(), hasHostBuf(), sanityCheck(), and AddrRange::start().

◆ sliceRegionRight()

void VMA::sliceRegionRight ( Addr  slice_addr)

Remove the address range to the right of slice_addr.

Definition at line 58 of file vma.cc.

References _addrRange, _hostBufLen, DPRINTF, AddrRange::end(), hasHostBuf(), sanityCheck(), and AddrRange::start().

◆ start()

Addr VMA::start ( )
inline

Definition at line 110 of file vma.hh.

References _addrRange, and AddrRange::start().

Referenced by fillMemPages().

Member Data Documentation

◆ _addrRange

AddrRange VMA::_addrRange
private

Address range for this virtual memory area.

Definition at line 143 of file vma.hh.

Referenced by contains(), end(), fillMemPages(), intersects(), isStrictSuperset(), isSubset(), mergesWith(), remap(), sanityCheck(), size(), sliceRegionLeft(), sliceRegionRight(), and start().

◆ _hostBuf

void* VMA::_hostBuf
private

Host buffer ptr for this virtual memory area.

Definition at line 162 of file vma.hh.

Referenced by fillMemPages(), sliceRegionLeft(), and VMA().

◆ _hostBufLen

uint64_t VMA::_hostBufLen
private

Length of host buffer for this virtual memory area.

Definition at line 167 of file vma.hh.

Referenced by fillMemPages(), sliceRegionLeft(), sliceRegionRight(), and VMA().

◆ _origHostBuf

std::shared_ptr<MappedFileBuffer> VMA::_origHostBuf
private

The host file backing will be chopped up and reassigned as pages are mapped, remapped, and unmapped.

In addition to the current host pointer and length, each virtual memory area will also keep a reference-counted handle to the original host memory. The last virtual memory area to die cleans up the host memory it handles.

Definition at line 157 of file vma.hh.

Referenced by hasHostBuf(), sliceRegionLeft(), and VMA().

◆ _pageBytes

Addr VMA::_pageBytes
private

Number of bytes in an OS page.

Definition at line 148 of file vma.hh.

Referenced by fillMemPages(), and sanityCheck().

◆ _vmaName

std::string VMA::_vmaName
private

Human-readable name associated with the virtual memory area.

The name is useful for debugging and also exposing vma state through the psuedo file system (i.e. Linux's /proc/self/maps) to the application.

Definition at line 175 of file vma.hh.

Referenced by getName().


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

Generated on Wed Sep 30 2020 14:02:34 for gem5 by doxygen 1.8.17