Add functionality for peripherals to read/write simulator memory
MODIFY
src/io/iobase.h
src/io/iobase.h
@@ -94,11 +94,17 @@ public:
virtual uint32_t size() const = 0;
/**
- * Hardware read/write functions
+ * Read/write functions from processor
*/
virtual uint32_t ioRead(uint32_t offset, unsigned size) = 0;
virtual void ioWrite(uint32_t offset, uint32_t value, unsigned size) = 0;
+ /**
+ * Read/write functions from peripheral to bus (memory/other periphs)
+ */
+ std::function<void(uint32_t, uint32_t, uint32_t)> memWrite;
+ std::function<uint32_t(uint32_t, uint32_t)> memRead;
+
signals:
/**
* @brief regMapChanged

MODIFY
src/io/iomanager.cpp
src/io/iomanager.cpp
@@ -55,6 +55,13 @@ void IOManager::registerPeripheralWithProcessor(IOBase* peripheral) {
vsrtl::core::IOFunctors{
[peripheral](uint32_t offset, uint32_t value, uint32_t size) { peripheral->ioWrite(offset, value, size); },
[peripheral](uint32_t offset, uint32_t size) { return peripheral->ioRead(offset, size); }});
+
+ peripheral->memWrite = [](uint32_t address, uint32_t value, uint32_t size) {
+ ProcessorHandler::get()->getMemory().writeMem(address, value, size);
+ };
+ peripheral->memRead = [](uint32_t address, uint32_t size) {
+ return ProcessorHandler::get()->getMemory().readMem(address, size);
+ };
}
void IOManager::unregisterPeripheralWithProcessor(IOBase* peripheral) {

Add functionality for peripherals to read/write simulator memory