72 start_addr_(start_addr),
73 raw_pointer_(raw_pointer)
102 const void *in_supplement=
nullptr,
103 void *out_supplement=
nullptr) override final
105 if(
false ==
isValid()) {
return false; }
116 const void *in_supplement=
nullptr,
117 void *out_supplement=
nullptr) override final
119 if(
false ==
isValid()) {
return false; }
127 sparta_assert(
false,
"You cannot get a DMI interface from a DMI interface!");
131 void *computeHostAddress_(
const addr_t addr)
const
133 return (uint8_t *)raw_pointer_ + (addr - start_addr_);
138 bool tryRead_(
addr_t addr,
142 void *)
noexcept override
144 ::memcpy(buf, computeHostAddress_(addr), size);
150 bool tryWrite_(
addr_t addr,
154 void *)
noexcept override
156 ::memcpy(computeHostAddress_(addr), buf, size);
162 bool tryPeek_(
addr_t addr,
addr_t size, uint8_t *buf)
const noexcept override
164 ::memcpy(buf, computeHostAddress_(addr), size);
170 bool tryPoke_(
addr_t addr,
addr_t size,
const uint8_t *buf)
noexcept override
172 ::memcpy(computeHostAddress_(addr), buf, size);
177 void * raw_pointer_ =
nullptr;
File that contains BlockingMemoryIF.
#define sparta_assert(...)
Simple variadic assertion that will throw a sparta_exception if the condition fails.
Pure-virtual memory interface which represents a simple, immediately accessible (blocking) address-sp...
virtual bool tryRead(addr_t addr, addr_t size, uint8_t *buf, const void *in_supplement=nullptr, void *out_supplement=nullptr)
Attempt to read memory of size size at address addr.
virtual bool tryWrite(addr_t addr, addr_t size, const uint8_t *buf, const void *in_supplement=nullptr, void *out_supplement=nullptr)
Attempt to write memory of size size at address addr.
Class that provides a BlockingMemoryIF over a raw pointer.
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.
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.
void clearValid()
Typically called by the creator of the DMI Mem IF.
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)
uint64_t addr_t
Type for generic address representation in generic interfaces, errors and printouts within SPARTA.
Macros for handling exponential backoff.