small reorder to make tohost output more readable

This commit is contained in:
Eyck-Alexander Jentzsch 2024-10-21 17:01:33 +02:00
parent 978c3db06e
commit 82a70efdb8
1 changed files with 8 additions and 6 deletions

View File

@ -1130,8 +1130,8 @@ iss::status riscv_hart_m_p<BASE, FEAT, LOGCAT>::write_mem(phys_addr_t paddr, uns
reg_t loaded_payload[8];
read(address_type::PHYSICAL, access_type::READ, traits<BASE>::MEM, payload_addr, sizeof(loaded_payload),
reinterpret_cast<uint8_t*>(loaded_payload));
reg_t syscall_no = loaded_payload[0];
if(syscall_no == 64) { // SYS_WRITE
reg_t syscall_num = loaded_payload[0];
if(syscall_num == 64) { // SYS_WRITE
reg_t fd = loaded_payload[1];
reg_t buf_ptr = loaded_payload[2];
reg_t len = loaded_payload[3];
@ -1140,15 +1140,17 @@ iss::status riscv_hart_m_p<BASE, FEAT, LOGCAT>::write_mem(phys_addr_t paddr, uns
reinterpret_cast<uint8_t*>(buf.data()));
// we disregard the fd and just log to stdout
for(size_t i = 0; i < len; i++) {
io_buf << buf[i];
}
if(buf[i] == '\n') {
CPPLOG(INFO) << "tohost send '" << io_buf.str() << "'";
io_buf.str("");
} else
io_buf << buf[i];
}
// Not sure what the correct return value should be
uint8_t ret_val = 1;
write(address_type::PHYSICAL, access_type::WRITE, traits<BASE>::MEM, fromhost, 1, &ret_val);
} else {
CPPLOG(ERR) << "tohost syscall with number " << std::hex << syscall_no << std::dec << " (" << syscall_no
CPPLOG(ERR) << "tohost syscall with number " << std::hex << syscall_num << std::dec << " (" << syscall_num
<< ") not implemented";
this->reg.trap_state = std::numeric_limits<uint32_t>::max();
this->interrupt_sim = payload;