The Sparta Modeling Framework
Loading...
Searching...
No Matches
sparta::memory::DMIBlockingMemoryIF Class Referencefinal

Class that provides a BlockingMemoryIF over a raw pointer. More...

#include <DMIBlockingMemoryIF.hpp>

Inheritance diagram for sparta::memory::DMIBlockingMemoryIF:
Collaboration diagram for sparta::memory::DMIBlockingMemoryIF:

Public Member Functions

 DMIBlockingMemoryIF (void *raw_pointer, addr_t start_addr, addr_t size)
 Wraps a raw pointer and provides BlockingMemoryIF to it.
 
void * getRawDataPtr ()
 Get a raw pointer to the memory held (dangerous)
 
bool isValid () const
 
void clearValid ()
 Typically called by the creator of the DMI Mem IF.
 
bool tryRead (addr_t addr, addr_t size, uint8_t *buf, const void *in_supplement=nullptr, void *out_supplement=nullptr) override final
 Override of sparta::BlockingMemoryIF::tryRead.
 
bool tryWrite (addr_t addr, addr_t size, const uint8_t *buf, const void *in_supplement=nullptr, void *out_supplement=nullptr) override final
 Override of sparta::BlockingMemoryIF::tryWrite.
 
- Public Member Functions inherited from sparta::memory::BlockingMemoryIF
std::string stringize (bool pretty=false) const
 Render description of this BlockingMemoryIF as a string.
 
 BlockingMemoryIF (const std::string &desc, addr_t block_size, const DebugMemoryIF::AccessWindow &window, TranslationIF *transif=nullptr)
 Construct a blocking memory interface.
 
void read (addr_t addr, addr_t size, uint8_t *buf, const void *in_supplement=nullptr, void *out_supplement=nullptr)
 Attempts to read memory.
 
void write (addr_t addr, addr_t size, const uint8_t *buf, const void *in_supplement=nullptr, void *out_supplement=nullptr)
 Attempts to write memory.
 
virtual void invalidateAllDMI ()
 Invalidate all DMI's.
 
- Public Member Functions inherited from sparta::memory::DebugMemoryIF
 DebugMemoryIF ()=delete
 Default constuctor.
 
 DebugMemoryIF (const std::string &desc, addr_t block_size, const AccessWindow &window, TranslationIF *transif=nullptr)
 Construct a DebugMemoryInterface.
 
virtual ~DebugMemoryIF ()
 Virutal destructor.
 
virtual const TranslationIFgetTranslationIF ()
 Gets the translation interface associated with this Debug memory interface (if any).
 
const std::string & getDescription ()
 Returns the description specified at construction.
 
addr_t getBlockSize () const
 Returns the block size of memory represented by this interface. Read and write accesses must not span block boundaries (where addr % block_size == 0).
 
addr_t getRange () const
 Gets the total span of this interface's valid address range.
 
addr_t getLowEnd () const
 Gets the lowest address accessible.
 
addr_t getHighEnd () const
 Gets the highest address accessible + 1.
 
addr_t getAccessibleSize () const
 Gets the total accessible size of this interface's valid addresses within the total size (getRange) excluding holes between access windows.
 
const std::vector< AccessWindow > & getWindows () const
 Gets the vector of windows representing this interface.
 
bool isAddressInWindows (addr_t addr) const noexcept
 Determines if the given address is in an access window defined for this interface.
 
void verifyInAccessWindows (addr_t addr, addr_t size) const
 Verifies that the range [addr, addr+size) is within the access windows for this interface.
 
bool isInAccessWindows (addr_t addr, addr_t size) const
 Determines if the range [addr, addr+size) is within the access windows for this interface.
 
void verifyNoBlockSpan (addr_t addr, addr_t size) const
 Verifies that the given address does not span block boundaries defined for this interface.
 
bool doesAccessSpan (addr_t addr, addr_t size) const noexcept
 Determines if the given address spans block boundaries defined for this interface. Accesses which span blocks are illegal for read/write accesses, but allowed for peak/poke debug accesses.
 
bool tryPeek (addr_t addr, addr_t size, uint8_t *buf) const
 Attempts to 'peek' memory without having any side effects, size-limitations, alignment constraints except that all bytes peeked are inside an access window for this interface.
 
void peek (addr_t addr, addr_t size, uint8_t *buf) const
 Wrapper on tryPeek which throws a MemoryAccessError if the peek is not legal.
 
bool tryPoke (addr_t addr, addr_t size, const uint8_t *buf)
 Attempts to 'poke' memory without having any side effects other than changing the bytes within the range [ addr , addr + size ). Poke has no size-limitations or alignment constraints except that all bytes peeked are inside an access window for this interface.
 
void poke (addr_t addr, addr_t size, const uint8_t *buf)
 Wrapper on tryPoke which throws a MemoryAccessError if the poke is not legal.
 

Additional Inherited Members

Access and Query Implementations
- Protected Attributes inherited from sparta::memory::DebugMemoryIF
const addr_t block_size_
 Size of a block accessed through this interface.
 
addr_t block_mask_
 Mask applied to an address to get only bits representing the block ID.
 
addr_t block_idx_lsb_
 rshift applied to an address to get the block ID
 
const std::vector< AccessWindowacc_windows_
 Vector of access windows representing this memory.
 
TranslationIFtrans_
 Translation interface created for this interface. Externally owned.
 
const std::string *const desc_ptr_
 Description pointer.
 
addr_t total_range_
 Range of addresses from highest accessible to lowest.
 
addr_t low_end_
 Lowest accessible address.
 
addr_t high_end_
 Highest accessible address + 1.
 
addr_t accessible_size_
 Number of bytes accessible through this interface.
 

Detailed Description

Class that provides a BlockingMemoryIF over a raw pointer.

Instances of this class are returned from BlockingMemoryIFNode::getDMI which allows a user to gain "backdoor" access to memory in the sparta::ArchData memory pool. Think of a DMIBlockingMemoryIF instance as a "view" into a segment of memory between start_addr and (start_addr + size)

The user of this class should be aware of the following caveats:

  1. The DMIBlockingMemoryIF can be invalidated at any time. Invalidations could result from changes in mappings, permissions, etc. Users that derive from BlockingMemoryIFNode and provide their own DMI memory access can invalidate at any time.
  2. Using the method getRawDataPtr is a means to improve simulation speed, but overruns are possible and not checked. The suggestion to use read/write methods is strongly encouraged.
  3. The DMI's access window, if returned from BlockingMemoryIFNode, is soley based on the size of the sparta::memory::MemoryObject originally programmed in BlockingMemoryIFNode and not total memory. For example, if the user creates sparta::memory::MemoryObject with block size of 64 bytes and a total of 1024 bytes of memory, a DMI object can only access 64 bytes of memory at a time.
  4. Using a DMI will bypass read/write counts in BlockingMemoryIFNode showing fewer reads/writes than actually occurred
  5. Using a DMI will bypass pre/post read/write notifications.

Definition at line 50 of file DMIBlockingMemoryIF.hpp.

Constructor & Destructor Documentation

◆ DMIBlockingMemoryIF()

sparta::memory::DMIBlockingMemoryIF::DMIBlockingMemoryIF ( void *  raw_pointer,
addr_t  start_addr,
addr_t  size 
)
inline

Wraps a raw pointer and provides BlockingMemoryIF to it.

Parameters
raw_pointerThe raw data pointer with memory to access
start_addrThe expected "start address" of this raw pointer
sizeThe expected size of the data

Typically created by BlockingMemoryObjectIFNode when DMI request is made, this class will wrap a raw data pointer and provide the functionality of the BlockingMemoryIF. This includes window access checking and bounds checking for the raw pointer.

Note that memory observeration is completely bypassed when using a DMI interface.

Definition at line 68 of file DMIBlockingMemoryIF.hpp.

Member Function Documentation

◆ clearValid()

void sparta::memory::DMIBlockingMemoryIF::clearValid ( )
inline

Typically called by the creator of the DMI Mem IF.

Definition at line 93 of file DMIBlockingMemoryIF.hpp.

◆ getRawDataPtr()

void * sparta::memory::DMIBlockingMemoryIF::getRawDataPtr ( )
inline

Get a raw pointer to the memory held (dangerous)

Returns
The internal raw pointer.
Exceptions
SpartaExceptionif the pointer is not valid

This is dangerous to use directly as memory bounds checking can easily be bypassed

Definition at line 84 of file DMIBlockingMemoryIF.hpp.

Here is the call graph for this function:

◆ isValid()

bool sparta::memory::DMIBlockingMemoryIF::isValid ( ) const
inline
Returns
true if the DMI is still valid to use

Definition at line 90 of file DMIBlockingMemoryIF.hpp.

◆ tryRead()

bool sparta::memory::DMIBlockingMemoryIF::tryRead ( addr_t  addr,
addr_t  size,
uint8_t *  buf,
const void *  in_supplement = nullptr,
void *  out_supplement = nullptr 
)
inlinefinaloverridevirtual

Override of sparta::BlockingMemoryIF::tryRead.

Returns
false if the DMI is not valid

Reimplemented from sparta::memory::BlockingMemoryIF.

Definition at line 99 of file DMIBlockingMemoryIF.hpp.

Here is the call graph for this function:

◆ tryWrite()

bool sparta::memory::DMIBlockingMemoryIF::tryWrite ( addr_t  addr,
addr_t  size,
const uint8_t *  buf,
const void *  in_supplement = nullptr,
void *  out_supplement = nullptr 
)
inlinefinaloverridevirtual

Override of sparta::BlockingMemoryIF::tryWrite.

Returns
false if the DMI is not valid

Reimplemented from sparta::memory::BlockingMemoryIF.

Definition at line 113 of file DMIBlockingMemoryIF.hpp.

Here is the call graph for this function:

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