adds initial semihosting host capabilities
This commit is contained in:
22
src/iss/semihosting/semihosting.cpp
Normal file
22
src/iss/semihosting/semihosting.cpp
Normal 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);
|
6
src/iss/semihosting/semihosting.h
Normal file
6
src/iss/semihosting/semihosting.h
Normal 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
|
Reference in New Issue
Block a user