gem5 v24.0.0.0
Loading...
Searching...
No Matches
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.
 
bool hasHostBuf () const
 Check if the virtual memory area has an equivalent buffer on the host machine.
 
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.
 
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.
 
void sliceRegionRight (Addr slice_addr)
 Remove the address range to the right of slice_addr.
 
void sliceRegionLeft (Addr slice_addr)
 Remove the address range to the left of slice_addr.
 
const std::string & getName ()
 
off_t getFileMappingOffset () const
 
Addr size ()
 Defer AddrRange related calls to the AddrRange.
 
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.
 
Addr _pageBytes
 Number of bytes in an OS page.
 
std::shared_ptr< MappedFileBuffer_origHostBuf
 The host file backing will be chopped up and reassigned as pages are mapped, remapped, and unmapped.
 
void * _hostBuf
 Host buffer ptr for this virtual memory area.
 
uint64_t _hostBufLen
 Length of host buffer for this virtual memory area.
 
std::string _vmaName
 Human-readable name associated with the virtual memory area.
 

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 139 of file vma.hh.

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

◆ end()

Addr gem5::VMA::end ( )
inline

Definition at line 118 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(), gem5::AddrRange::start(), start(), and gem5::PortProxy::writeBlob().

◆ getFileMappingOffset()

off_t gem5::VMA::getFileMappingOffset ( ) const
inline

Definition at line 108 of file vma.hh.

References _origHostBuf, and hasHostBuf().

◆ 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 getFileMappingOffset(), sliceRegionLeft(), and sliceRegionRight().

◆ intersects()

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

Definition at line 127 of file vma.hh.

References _addrRange, gem5::AddrRange::intersects(), and gem5::MipsISA::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::MipsISA::r, and gem5::AddrRange::start().

◆ isSubset()

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

Definition at line 133 of file vma.hh.

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

◆ mergesWith()

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

Definition at line 121 of file vma.hh.

References _addrRange, gem5::AddrRange::mergesWith(), and gem5::MipsISA::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 116 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 117 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 150 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 169 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 174 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 164 of file vma.hh.

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

◆ _pageBytes

Addr gem5::VMA::_pageBytes
private

Number of bytes in an OS page.

Definition at line 155 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 182 of file vma.hh.

Referenced by getName().


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

Generated on Tue Jun 18 2024 16:24:15 for gem5 by doxygen 1.11.0