Fix paddr_bits computation prior to VM setup
[riscv-isa-sim.git] / riscv / htif.h
index 805cc4ff6ed7cd69bc6c0e7e0a1b742d07205da8..4e1025e7b5e94e4986475fc9c7c79cd1113fad41 100644 (file)
@@ -1,39 +1,31 @@
+// See LICENSE for license details.
+
 #ifndef _HTIF_H
 #define _HTIF_H
 
-#include <stdint.h>
+#include <fesvr/htif_pthread.h>
 
 class sim_t;
 struct packet;
 
 // this class implements the host-target interface for program loading, etc.
-class htif_t
+// a simpler implementation would implement the high-level interface
+// (read/write cr, read/write chunk) directly, but we implement the lower-
+// level serialized interface to be more similar to real target machines.
+
+class htif_isasim_t : public htif_pthread_t
 {
 public:
-  htif_t(int _tohost_fd, int _fromhost_fd);
-  ~htif_t();
-  void init(sim_t* _sim);
-
-  // wait for host to send start command
-  void wait_for_start();
-
-  // we block on the host if the target machine reads the fromhost register,
-  // which provides determinism in tohost/fromhost communication.
-  void wait_for_tohost_write();
-  void wait_for_fromhost_write();
-
-  // check to see if there's a pending packet and process it if so
-  void poll();
+  htif_isasim_t(sim_t* _sim, const std::vector<std::string>& args);
+  bool tick();
+  bool done();
 
 private:
   sim_t* sim;
-  int tohost_fd;
-  int fromhost_fd;
-  uint16_t seqno;
+  bool reset;
+  uint8_t seqno;
 
-  void nack(uint16_t seqno);
-  void send_packet(packet* p);
-  int wait_for_packet();
+  void tick_once();
 };
 
 #endif