Set tval to 0 on traps with no specified tval
[riscv-isa-sim.git] / riscv / remote_bitbang.h
index c0aa7e040ff3909a1097b644b20dfb2808366348..1db4d550140ea8bad605663911579bbe8e857501 100644 (file)
@@ -5,45 +5,6 @@
 
 #include "jtag_dtm.h"
 
-template <typename T>
-class circular_buffer_t
-{
-public:
-  // The buffer can store capacity-1 data elements.
-  circular_buffer_t(unsigned int capacity) : data(new T[capacity]),
-      start(0), end(0), capacity(capacity) {}
-  circular_buffer_t() : start(0), end(0), capacity(0) {}
-  ~circular_buffer_t() { delete[] data; }
-
-  T *data;
-  unsigned int start;   // Data start, inclusive.
-  unsigned int end;     // Data end, exclusive.
-  unsigned int capacity;    // Size of the buffer.
-  unsigned int size() const;
-  bool empty() const { return start == end; }
-  bool full() const { return ((end+1) % capacity) == start; }
-  T entry(unsigned index) { return data[(start + index) % capacity]; }
-
-  // Return size and address of the block of RAM where more data can be copied
-  // to be added to the buffer.
-  unsigned int contiguous_empty_size() const;
-  T *contiguous_empty() { return data + end; }
-  void data_added(unsigned int bytes);
-
-  unsigned int contiguous_data_size() const;
-  T *contiguous_data() { return data + start; }
-  // Tell the buffer that some bytes were consumed from the start of the
-  // buffer.
-  void consume(unsigned int bytes);
-
-  void reset();
-
-  T operator[](unsigned int i) const { return data[(start + i) % capacity]; }
-
-  void append(const T *src, unsigned int count);
-  void append(T value);
-};
-
 class remote_bitbang_t
 {
 public:
@@ -59,18 +20,15 @@ private:
 
   int socket_fd;
   int client_fd;
-  circular_buffer_t<uint8_t> recv_buf;
-  circular_buffer_t<uint8_t> send_buf;
+
+  static const ssize_t buf_size = 64 * 1024;
+  char recv_buf[buf_size];
+  ssize_t recv_start, recv_end;
 
   // Check for a client connecting, and accept if there is one.
   void accept();
-  // Read as much into recv_buf as possible.
-  void read();
-  // Write as much of send_buf as possible.
-  void write();
-
-  // Process the input buffer.
-  void process_input();
+  // Execute any commands the client has for us.
+  void execute_commands();
 };
 
 #endif