Add callback for processor checking whether a given address is executable
MODIFY
src/processorhandler.cpp
src/processorhandler.cpp
@@ -107,6 +107,7 @@ void ProcessorHandler::selectProcessor(const ProcessorID& id, RegisterInitializa
// Processor initializations
m_currentProcessor = ProcessorRegistry::constructProcessor(m_currentID);
m_currentProcessor->handleSysCall.Connect(this, &ProcessorHandler::handleSysCall);
+ m_currentProcessor->isExecutableAddress = [=](uint32_t address) { return isExecutableAddress(address); };
// Register initializations
auto& regs = m_currentProcessor->getRegisters();
@@ -210,9 +211,13 @@ void ProcessorHandler::stop() {
m_stopRunningFlag = false;
}
+bool ProcessorHandler::isExecutableAddress(uint32_t address) const {
+ return m_validExecutionRange.first <= address && address < m_validExecutionRange.second;
+}
+
void ProcessorHandler::checkValidExecutionRange() const {
const auto pc = m_currentProcessor->nextFetchedAddress();
- if (!(m_validExecutionRange.first <= pc && pc < m_validExecutionRange.second)) {
+ if (!isExecutableAddress(pc)) {
m_currentProcessor->finalize(true);
} else {
m_currentProcessor->finalize(false);

MODIFY
src/processorhandler.h
src/processorhandler.h
@@ -52,6 +52,12 @@ public:
*/
void checkValidExecutionRange() const;
+ /**
+ * @brief isExecutableAddress
+ * @returns whether @param address is within the executable section of the currently loaded program.
+ */
+ bool isExecutableAddress(uint32_t address) const;
+
/**
* @brief getCurrentProgramSize
* @return size (in bytes) of the currently loaded .text segment

MODIFY
src/processors/ripesprocessor.h
src/processors/ripesprocessor.h
@@ -115,6 +115,13 @@ public:
m_instructionsRetired = 0;
}
+ /**
+ * @brief isExecutableAddress
+ * Callback registerred by the environment instantiating the processor. The environment shall return whether the @p
+ * address is an address which is valid to be executed.
+ */
+ std::function<bool(uint32_t)> isExecutableAddress;
+
/**
* @brief handleSysCall
* Signal for passing control to the outside environment whenever a system call must be handled (RISC-V ecall

Add callback for processor checking whether a given address is executable