fdt: move interrupt controller into its own node
[riscv-isa-sim.git] / riscv / devices.h
index 83781884b9910aa7fd8934efee25b538194a85ae..f3ecb67a3c7f3ac46c5385aee18bb175ea93395c 100644 (file)
@@ -11,9 +11,6 @@ class abstract_device_t {
  public:
   virtual bool load(reg_t addr, size_t len, uint8_t* bytes) = 0;
   virtual bool store(reg_t addr, size_t len, const uint8_t* bytes) = 0;
-  // Return a pointer to the start of the page that addr falls in, or NULL if
-  // there is no IO device at that address.
-  virtual char* page(reg_t addr) { return NULL; }
   virtual ~abstract_device_t() {}
 };
 
@@ -21,9 +18,6 @@ class bus_t : public abstract_device_t {
  public:
   bool load(reg_t addr, size_t len, uint8_t* bytes);
   bool store(reg_t addr, size_t len, const uint8_t* bytes);
-  // Return a pointer to the start of the page that addr falls in, or NULL if
-  // there is no IO device at that address.
-  char* page(reg_t paddr);
   void add_device(reg_t addr, abstract_device_t* dev);
 
  private:
@@ -40,17 +34,20 @@ class rom_device_t : public abstract_device_t {
   std::vector<char> data;
 };
 
-class rtc_t : public abstract_device_t {
+class clint_t : public abstract_device_t {
  public:
-  rtc_t(std::vector<processor_t*>&);
+  clint_t(std::vector<processor_t*>&);
   bool load(reg_t addr, size_t len, uint8_t* bytes);
   bool store(reg_t addr, size_t len, const uint8_t* bytes);
-  size_t size() { return regs.size() * sizeof(regs[0]); }
+  size_t size() { return CLINT_SIZE; }
   void increment(reg_t inc);
  private:
+  typedef uint64_t mtime_t;
+  typedef uint64_t mtimecmp_t;
+  typedef uint32_t msip_t;
   std::vector<processor_t*>& procs;
-  std::vector<uint64_t> regs;
-  uint64_t time() { return regs[0]; }
+  mtime_t mtime;
+  std::vector<mtimecmp_t> mtimecmp;
 };
 
 #endif