The Sparta Modeling Framework
|
Class that provides a BlockingMemoryIF over a raw pointer. More...
#include <DMIBlockingMemoryIF.hpp>
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 TranslationIF * | getTranslationIF () |
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< AccessWindow > | acc_windows_ |
Vector of access windows representing this memory. | |
TranslationIF * | trans_ |
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. | |
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:
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.Definition at line 50 of file DMIBlockingMemoryIF.hpp.
|
inline |
Wraps a raw pointer and provides BlockingMemoryIF to it.
raw_pointer | The raw data pointer with memory to access |
start_addr | The expected "start address" of this raw pointer |
size | The 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.
|
inline |
Typically called by the creator of the DMI Mem IF.
Definition at line 93 of file DMIBlockingMemoryIF.hpp.
|
inline |
Get a raw pointer to the memory held (dangerous)
SpartaException | if 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.
|
inline |
Definition at line 90 of file DMIBlockingMemoryIF.hpp.
|
inlinefinaloverridevirtual |
Override of sparta::BlockingMemoryIF::tryRead.
Reimplemented from sparta::memory::BlockingMemoryIF.
Definition at line 99 of file DMIBlockingMemoryIF.hpp.
|
inlinefinaloverridevirtual |
Override of sparta::BlockingMemoryIF::tryWrite.
Reimplemented from sparta::memory::BlockingMemoryIF.
Definition at line 113 of file DMIBlockingMemoryIF.hpp.