diff --git a/src/iss/arch/riscv_hart_m_p.h b/src/iss/arch/riscv_hart_m_p.h index e8f71f7..6dc80d5 100644 --- a/src/iss/arch/riscv_hart_m_p.h +++ b/src/iss/arch/riscv_hart_m_p.h @@ -1130,8 +1130,8 @@ iss::status riscv_hart_m_p::write_mem(phys_addr_t paddr, uns reg_t loaded_payload[8]; read(address_type::PHYSICAL, access_type::READ, traits::MEM, payload_addr, sizeof(loaded_payload), reinterpret_cast(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::write_mem(phys_addr_t paddr, uns reinterpret_cast(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]; } - CPPLOG(INFO) << "tohost send '" << io_buf.str() << "'"; - io_buf.str(""); // Not sure what the correct return value should be uint8_t ret_val = 1; write(address_type::PHYSICAL, access_type::WRITE, traits::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::max(); this->interrupt_sim = payload;