[sim] change applink for tohost/fromhost
authorYunsup Lee <yunsup@cs.berkeley.edu>
Wed, 8 Sep 2010 21:16:13 +0000 (14:16 -0700)
committerYunsup Lee <yunsup@cs.berkeley.edu>
Wed, 8 Sep 2010 21:16:13 +0000 (14:16 -0700)
riscv/applink.cc
riscv/sim.cc

index d8fddaded421420c9e11b67be094d16b86a4a5e7..659243843b13e3b691651e3faabdf655369cbd94 100644 (file)
@@ -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
index 06a9cba410f48b45f0b15482186410fd2e747252..2bc1775cb7fb2a7b185d8995734b4c1aca49b43b 100644 (file)
@@ -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;
 }