From 3af5e6b1a55efd9e5a0d21258c23575353d33719 Mon Sep 17 00:00:00 2001 From: Yunsup Lee Date: Wed, 8 Sep 2010 14:16:13 -0700 Subject: [PATCH] [sim] change applink for tohost/fromhost --- riscv/applink.cc | 10 ++++++++++ riscv/sim.cc | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/riscv/applink.cc b/riscv/applink.cc index d8fddad..6592438 100644 --- a/riscv/applink.cc +++ b/riscv/applink.cc @@ -53,6 +53,16 @@ void appserver_link_t::wait_for_start() while(wait_for_packet() != APP_CMD_START); } +void appserver_link_t::wait_for_tohost() +{ + while(wait_for_packet() != APP_CMD_READ_CONTROL_REG); +} + +void appserver_link_t::wait_for_fromhost() +{ + while(wait_for_packet() != APP_CMD_WRITE_CONTROL_REG); +} + void appserver_link_t::send_packet(packet* p) { while(1) try diff --git a/riscv/sim.cc b/riscv/sim.cc index 06a9cba..2bc1775 100644 --- a/riscv/sim.cc +++ b/riscv/sim.cc @@ -27,12 +27,12 @@ void sim_t::set_tohost(reg_t val) { fromhost = 0; tohost = val; + applink->wait_for_tohost(); } reg_t sim_t::get_fromhost() { - while(fromhost == 0) - applink->wait_for_packet(); + applink->wait_for_fromhost(); return fromhost; } -- 2.30.2