adds initial semihosting host capabilities

This commit is contained in:
2024-01-08 17:17:59 +01:00
parent f4f90c5e65
commit 207f778ee6
12 changed files with 332 additions and 143 deletions

View File

@@ -0,0 +1,22 @@
#include "semihosting.h"
#include <exception>
#include <iss/vm_types.h>
#include <stdexcept>
template <typename T> void semihosting_callback(iss::arch_if* arch_if_ptr, T a0, T a1) {
if(a0 == 0x04 /*WRITE0*/) {
uint8_t character;
while(1) {
auto res = arch_if_ptr->read(iss::address_type::PHYSICAL, iss::access_type::DEBUG_READ, 0, a1, 1, &character);
if(res != iss::Ok)
return;
if(character == 0)
break;
putchar(character);
a1++;
}
} else {
throw std::runtime_error("Not Implemented Error");
}
}
template void semihosting_callback<uint32_t>(iss::arch_if* arch_if_ptr, uint32_t a0, uint32_t a1);
template void semihosting_callback<uint64_t>(iss::arch_if* arch_if_ptr, uint64_t a0, uint64_t a1);

View File

@@ -0,0 +1,6 @@
#ifndef _SEMIHOSTING_H_
#define _SEMIHOSTING_H_
#include <iss/arch_if.h>
template <typename T> void semihosting_callback(iss::arch_if* arch_if_ptr, T a0, T a1);
#endif