gem5  v22.1.0.0
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
gem5::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 43 of file vma.hh.

Constructor & Destructor Documentation

◆ VMA()

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

Member Function Documentation

◆ contains()

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

Definition at line 135 of file vma.hh.

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

◆ end()

Addr gem5::VMA::end ( )
inline

Definition at line 114 of file vma.hh.

References _addrRange, and gem5::AddrRange::end().

◆ fillMemPages()

void gem5::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 40 of file vma.cc.

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

◆ getName()

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

Definition at line 107 of file vma.hh.

References _vmaName.

◆ hasHostBuf()

bool gem5::VMA::hasHostBuf ( ) const
inline

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

Definition at line 83 of file vma.hh.

References _origHostBuf.

Referenced by sliceRegionLeft(), and sliceRegionRight().

◆ intersects()

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

Definition at line 123 of file vma.hh.

References _addrRange, gem5::AddrRange::intersects(), and gem5::VegaISA::r.

◆ isStrictSuperset()

bool gem5::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 54 of file vma.cc.

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

◆ isSubset()

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

Definition at line 129 of file vma.hh.

References _addrRange, gem5::AddrRange::isSubset(), and gem5::VegaISA::r.

◆ mergesWith()

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

Definition at line 117 of file vma.hh.

References _addrRange, gem5::AddrRange::mergesWith(), and gem5::VegaISA::r.

◆ remap()

void gem5::VMA::remap ( Addr  new_start)
inline

Remap the virtual memory area starting at new_start.

Definition at line 69 of file vma.hh.

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

◆ sanityCheck()

void gem5::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 101 of file vma.cc.

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

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

◆ size()

Addr gem5::VMA::size ( )
inline

Defer AddrRange related calls to the AddrRange.

Definition at line 112 of file vma.hh.

References _addrRange, and gem5::AddrRange::size().

Referenced by fillMemPages().

◆ sliceRegionLeft()

void gem5::VMA::sliceRegionLeft ( Addr  slice_addr)

Remove the address range to the left of slice_addr.

Definition at line 76 of file vma.cc.

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

◆ sliceRegionRight()

void gem5::VMA::sliceRegionRight ( Addr  slice_addr)

Remove the address range to the right of slice_addr.

Definition at line 60 of file vma.cc.

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

◆ start()

Addr gem5::VMA::start ( )
inline

Definition at line 113 of file vma.hh.

References _addrRange, and gem5::AddrRange::start().

Referenced by fillMemPages().

Member Data Documentation

◆ _addrRange

AddrRange gem5::VMA::_addrRange
private

Address range for this virtual memory area.

Definition at line 146 of file vma.hh.

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

◆ _hostBuf

void* gem5::VMA::_hostBuf
private

Host buffer ptr for this virtual memory area.

Definition at line 165 of file vma.hh.

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

◆ _hostBufLen

uint64_t gem5::VMA::_hostBufLen
private

Length of host buffer for this virtual memory area.

Definition at line 170 of file vma.hh.

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

◆ _origHostBuf

std::shared_ptr<MappedFileBuffer> gem5::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 160 of file vma.hh.

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

◆ _pageBytes

Addr gem5::VMA::_pageBytes
private

Number of bytes in an OS page.

Definition at line 151 of file vma.hh.

Referenced by fillMemPages(), and sanityCheck().

◆ _vmaName

std::string gem5::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 178 of file vma.hh.

Referenced by getName().


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

Generated on Wed Dec 21 2022 10:23:31 for gem5 by doxygen 1.9.1