Add support for RTC to interrupt, HACK in alpha_console temporary
authorRon Dreslinski <rdreslin@umich.edu>
Wed, 28 Jan 2004 02:36:46 +0000 (21:36 -0500)
committerRon Dreslinski <rdreslin@umich.edu>
Wed, 28 Jan 2004 02:36:46 +0000 (21:36 -0500)
dev/alpha_console.cc:
    Fix reference to tlaserclock, HACK FOR NOW
dev/alpha_console.hh:
    fix reference to tlaser_clock, HACK FOR NOW
dev/tsunami.cc:
    Add proper tsunami chip pointers
dev/tsunami.hh:
    add proper tsunami chip pointers add RTC interrupt capabilities
dev/tsunami_cchip.cc:
    Add proper Interrupt for RTC
dev/tsunami_cchip.hh:
    Add proper interrupt for RTC
dev/tsunami_io.cc:
dev/tsunami_io.hh:
    Make RTC interrupt
dev/tsunami_pchip.cc:
dev/tsunami_pchip.hh:
    Add back pointer to tsunami

--HG--
extra : convert_revision : 2b0a8616b0bed8d9962ee5ca643dce56b9922d52

dev/alpha_console.cc
dev/alpha_console.hh
dev/tsunami.cc
dev/tsunami.hh
dev/tsunami_cchip.cc
dev/tsunami_cchip.hh
dev/tsunami_io.cc
dev/tsunami_io.hh
dev/tsunami_pchip.cc
dev/tsunami_pchip.hh

index ccf6c33fd3582ad86112119b26604fb6b3b6c2ec..359995693ce8f9d28f1a21f19c465ccc1fc4bf4e 100644 (file)
 #include "mem/functional_mem/memory_control.hh"
 #include "sim/builder.hh"
 #include "sim/system.hh"
+#include "dev/tsunami_io.hh"
 
 using namespace std;
 
 AlphaConsole::AlphaConsole(const string &name, SimConsole *cons,
                            SimpleDisk *d, int size, System *system,
-                           BaseCPU *cpu, TlaserClock *clock, int num_cpus,
+                           BaseCPU *cpu, TsunamiIO *clock, int num_cpus,
                            Addr addr, Addr mask, MemoryController *mmu)
     : MmapDevice(name, addr, mask, mmu), disk(d), console(cons)
 {
@@ -250,7 +251,7 @@ BEGIN_DECLARE_SIM_OBJECT_PARAMS(AlphaConsole)
     Param<Addr> mask;
     SimObjectParam<System *> system;
     SimObjectParam<BaseCPU *> cpu;
-    SimObjectParam<TlaserClock *> clock;
+    SimObjectParam<TsunamiIO *> clock;
 
 END_DECLARE_SIM_OBJECT_PARAMS(AlphaConsole)
 
index 9e774773ee048bfb4059178b42e97b47b8c9c3db..105b03849f54248bbfb7143e3805925bed946344 100644 (file)
@@ -36,6 +36,7 @@
 #include "sim/host.hh"
 #include "dev/alpha_access.h"
 #include "mem/functional_mem/mmap_device.hh"
+#include "dev/tsunami_io.hh"
 
 class BaseCPU;
 class SimConsole;
@@ -87,7 +88,7 @@ class AlphaConsole : public MmapDevice
     AlphaConsole(const std::string &name, SimConsole *cons,
                  SimpleDisk *d, int size,
                  System *system, BaseCPU *cpu,
-                 TlaserClock *clock, int num_cpus,
+                 TsunamiIO *clock, int num_cpus,
                  Addr addr, Addr mask, MemoryController *mmu);
 
   public:
index 95c6714959d9e81f13631c97b103476879c88fbb..a8cf551d324970bea1a6d7ef0e583f5c6617e563 100644 (file)
 using namespace std;
 
 Tsunami::Tsunami(const string &name, ScsiController *s, EtherDev *e,
-                       TlaserClock *c, TsunamiCChip *cc, TsunamiPChip *pc, SimConsole *con,
-               IntrControl *ic, int intr_freq)
-    : SimObject(name), intctrl(ic), cons(con), scsi(s), ethernet(e),
-      clock(c), cchip(cc), pchip(pc), interrupt_frequency(intr_freq)
+                       SimConsole *con, IntrControl *ic, int intr_freq)
+    : SimObject(name), intrctrl(ic), cons(con), scsi(s), ethernet(e),
+      interrupt_frequency(intr_freq)
 {
     for (int i = 0; i < Tsunami::Max_CPUs; i++)
         intr_sum_type[i] = 0;
@@ -69,9 +68,6 @@ BEGIN_DECLARE_SIM_OBJECT_PARAMS(Tsunami)
 
     SimObjectParam<ScsiController *> scsi;
     SimObjectParam<EtherDev *> ethernet;
-    SimObjectParam<TlaserClock *> clock;
-    SimObjectParam<TsunamiCChip *> cchip;
-    SimObjectParam<TsunamiPChip *> pchip;
     SimObjectParam<SimConsole *> cons;
     SimObjectParam<IntrControl *> intrctrl;
     Param<int> interrupt_frequency;
@@ -82,9 +78,6 @@ BEGIN_INIT_SIM_OBJECT_PARAMS(Tsunami)
 
     INIT_PARAM(scsi, "scsi controller"),
     INIT_PARAM(ethernet, "ethernet controller"),
-    INIT_PARAM(clock, "turbolaser clock"),
-    INIT_PARAM(cchip, "cchip"),
-    INIT_PARAM(pchip, "pchip"),
     INIT_PARAM(cons, "system console"),
     INIT_PARAM(intrctrl, "interrupt controller"),
     INIT_PARAM_DFLT(interrupt_frequency, "frequency of interrupts", 1200)
@@ -94,8 +87,8 @@ END_INIT_SIM_OBJECT_PARAMS(Tsunami)
 
 CREATE_SIM_OBJECT(Tsunami)
 {
-    return new Tsunami(getInstanceName(), scsi, ethernet, clock,
-                           cchip, pchip, cons, intrctrl, interrupt_frequency);
+    return new Tsunami(getInstanceName(), scsi, ethernet,
+                           cons, intrctrl, interrupt_frequency);
 }
 
 REGISTER_SIM_OBJECT("Tsunami", Tsunami)
index 0ba3cdf67daa333768af747f1fd54cea82fddaa5..57e4b89918f2c8d6f67833c3c1db5d912a12d70f 100644 (file)
@@ -46,14 +46,13 @@ class Tsunami : public SimObject
 
     static const int Max_CPUs = 4;
 
-    IntrControl *intctrl;
+    IntrControl *intrctrl;
 //    ConsoleListener *listener;
     SimConsole *cons;
 
     ScsiController *scsi;
     EtherDev *ethernet;
 
-    TlaserClock *clock;
     TsunamiCChip *cchip;
     TsunamiPChip *pchip;
 
@@ -64,7 +63,7 @@ class Tsunami : public SimObject
 
   public:
     Tsunami(const std::string &name, ScsiController *scsi,
-               EtherDev *ethernet, TlaserClock *clock, TsunamiCChip *cc, TsunamiPChip *pc,
+               EtherDev *ethernet,
                SimConsole *, IntrControl *intctrl, int intrFreq);
 
     virtual void serialize(std::ostream &os);
index ca9eae18485330a46adab5d631b72c94bab1f7b5..6559f38090ea6a0ca6bed3b2b5f9772a90d645d1 100644 (file)
 #include "dev/tsunami_cchip.hh"
 #include "dev/tsunamireg.h"
 #include "dev/tsunami.hh"
+#include "cpu/intr_control.hh"
 #include "mem/functional_mem/memory_control.hh"
 #include "sim/builder.hh"
 #include "sim/system.hh"
 
 using namespace std;
 
-TsunamiCChip::TsunamiCChip(const string &name, /*Tsunami *t,*/
+TsunamiCChip::TsunamiCChip(const string &name, Tsunami *t,
                        Addr addr, Addr mask, MemoryController *mmu)
-    : MmapDevice(name, addr, mask, mmu)/*, tsunami(t) */
+    : MmapDevice(name, addr, mask, mmu), tsunami(t)
 {
     for(int i=0; i < Tsunami::Max_CPUs; i++) {
         dim[i] = 0;
@@ -33,6 +34,11 @@ TsunamiCChip::TsunamiCChip(const string &name, /*Tsunami *t,*/
     }
 
     drir = 0;
+    misc = 0;
+    RTCInterrupting = false;
+
+    //Put back pointer in tsunami
+    tsunami->cchip = this;
 }
 
 Fault
@@ -56,7 +62,7 @@ TsunamiCChip::read(MemReqPtr req, uint8_t *data)
                   panic("TSDEV_CC_MTR not implemeted\n");
                    return No_Fault;
               case TSDEV_CC_MISC:
-                  panic("TSDEV_CC_MISC not implemented\n");
+                *(uint64_t*)data = misc;
                   return No_Fault;
               case TSDEV_CC_AAR0:
               case TSDEV_CC_AAR1:
@@ -141,7 +147,12 @@ TsunamiCChip::write(MemReqPtr req, const uint8_t *data)
                   panic("TSDEV_CC_MTR write not implemented\n");
                    return No_Fault;
               case TSDEV_CC_MISC:
-                  panic("TSDEV_CC_MISC write not implemented\n");
+                //If it is the seventh bit, clear the RTC interrupt
+                if ((*(uint64_t*) data) & (1<<7)) {
+                    RTCInterrupting = false;
+                    tsunami->intrctrl->clear(0, TheISA::INTLEVEL_IRQ2, 0);
+                    misc &= ~(1<<7);
+                } else panic("TSDEV_CC_MISC write not implemented\n");
                   return No_Fault;
               case TSDEV_CC_AAR0:
               case TSDEV_CC_AAR1:
@@ -216,7 +227,7 @@ TsunamiCChip::unserialize(Checkpoint *cp, const std::string &section)
 
 BEGIN_DECLARE_SIM_OBJECT_PARAMS(TsunamiCChip)
 
//   SimObjectParam<Tsunami *> tsunami;
+    SimObjectParam<Tsunami *> tsunami;
     SimObjectParam<MemoryController *> mmu;
     Param<Addr> addr;
     Param<Addr> mask;
@@ -225,7 +236,7 @@ END_DECLARE_SIM_OBJECT_PARAMS(TsunamiCChip)
 
 BEGIN_INIT_SIM_OBJECT_PARAMS(TsunamiCChip)
 
-//    INIT_PARAM(tsunami, "Tsunami"),
+    INIT_PARAM(tsunami, "Tsunami"),
     INIT_PARAM(mmu, "Memory Controller"),
     INIT_PARAM(addr, "Device Address"),
     INIT_PARAM(mask, "Address Mask")
@@ -234,7 +245,7 @@ END_INIT_SIM_OBJECT_PARAMS(TsunamiCChip)
 
 CREATE_SIM_OBJECT(TsunamiCChip)
 {
-    return new TsunamiCChip(getInstanceName(), /*tsunami,*/ addr, mask, mmu);
+    return new TsunamiCChip(getInstanceName(), tsunami, addr, mask, mmu);
 }
 
 REGISTER_SIM_OBJECT("TsunamiCChip", TsunamiCChip)
index b5b2d194cacc83f5a0143560dee62012f0905ba3..287fbdf7058c6ee18b554f9abf96aee505ec3602 100644 (file)
@@ -50,7 +50,7 @@ class TsunamiCChip : public MmapDevice
     uint64_t drir;
 
   public:
-    TsunamiCChip(const std::string &name, /*Tsunami *t,*/
+    TsunamiCChip(const std::string &name, Tsunami *t,
                Addr addr, Addr mask, MemoryController *mmu);
 
     virtual Fault read(MemReqPtr req, uint8_t *data);
@@ -58,6 +58,9 @@ class TsunamiCChip : public MmapDevice
 
     virtual void serialize(std::ostream &os);
     virtual void unserialize(Checkpoint *cp, const std::string &section);
+
+    uint64_t misc;
+    bool RTCInterrupting;
 };
 
 #endif // __TSUNAMI_CCHIP_HH__
index b6533dcbacb76a78d49cd59a8fe78a8b65a8e0f9..611496e58730f1985bf48d87525e1c138f8c7666 100644 (file)
@@ -19,6 +19,7 @@
 #include "dev/tsunami.hh"
 #include "mem/functional_mem/memory_control.hh"
 #include "sim/builder.hh"
+#include "dev/tsunami_cchip.hh"
 
 using namespace std;
 
@@ -28,8 +29,8 @@ using namespace std;
 #define RTC_RATE  1024
 
 // Timer Event for Periodic interrupt of RTC
-TsunamiIO::RTCEvent::RTCEvent()
-    : Event(&mainEventQueue)
+TsunamiIO::RTCEvent::RTCEvent(Tsunami* t)
+    : Event(&mainEventQueue), tsunami(t)
 {
     DPRINTF(MC146818, "RTC Event Initilizing\n");
     schedule(curTick + ticksPerSecond/RTC_RATE);
@@ -41,6 +42,11 @@ TsunamiIO::RTCEvent::process()
     DPRINTF(MC146818, "Timer Interrupt\n");
     schedule(curTick + ticksPerSecond/RTC_RATE);
     //Actually interrupt the processor here
+    if (!tsunami->cchip->RTCInterrupting) {
+        tsunami->cchip->misc |= 1 << 7;
+        tsunami->cchip->RTCInterrupting = true;
+        tsunami->intrctrl->post(0, TheISA::INTLEVEL_IRQ2, 0);
+    }
 }
 
 const char *
@@ -98,9 +104,9 @@ TsunamiIO::ClockEvent::Status()
 
 
 
-TsunamiIO::TsunamiIO(const string &name, /*Tsunami *t,*/ time_t init_time,
-                       Addr addr, Addr mask, MemoryController *mmu)
-    : MmapDevice(name, addr, mask, mmu)/*, tsunami(t) */
+TsunamiIO::TsunamiIO(const string &name, Tsunami *t, time_t init_time,
+                       Addr addr, Addr mask, uint32_t f, MemoryController *mmu)
+    : MmapDevice(name, addr, mask, mmu), tsunami(t), rtc(t), freq(f)
 {
     timerData = 0;
     set_time(init_time == 0 ? time(NULL) : init_time);
@@ -289,28 +295,31 @@ TsunamiIO::unserialize(Checkpoint *cp, const std::string &section)
 
 BEGIN_DECLARE_SIM_OBJECT_PARAMS(TsunamiIO)
 
//   SimObjectParam<Tsunami *> tsunami;
+    SimObjectParam<Tsunami *> tsunami;
     Param<time_t> time;
     SimObjectParam<MemoryController *> mmu;
     Param<Addr> addr;
     Param<Addr> mask;
+    Param<uint32_t> frequency;
 
 END_DECLARE_SIM_OBJECT_PARAMS(TsunamiIO)
 
 BEGIN_INIT_SIM_OBJECT_PARAMS(TsunamiIO)
 
-//    INIT_PARAM(tsunami, "Tsunami"),
+    INIT_PARAM(tsunami, "Tsunami"),
     INIT_PARAM_DFLT(time, "System time to use "
             "(0 for actual time, default is 1/1/06", ULL(1136073600)),
     INIT_PARAM(mmu, "Memory Controller"),
     INIT_PARAM(addr, "Device Address"),
-    INIT_PARAM(mask, "Address Mask")
+    INIT_PARAM(mask, "Address Mask"),
+    INIT_PARAM(frequency, "clock interrupt frequency")
 
 END_INIT_SIM_OBJECT_PARAMS(TsunamiIO)
 
 CREATE_SIM_OBJECT(TsunamiIO)
 {
-    return new TsunamiIO(getInstanceName(), /*tsunami,*/ time,  addr, mask, mmu);
+    return new TsunamiIO(getInstanceName(), tsunami, time,  addr,
+                         mask, frequency, mmu);
 }
 
 REGISTER_SIM_OBJECT("TsunamiIO", TsunamiIO)
index fe904605c6c5d0f495d102f5f310270814d12933..e945eb53d88a1a69e25b7988ce76b461b65a2f1b 100644 (file)
@@ -72,8 +72,10 @@ class TsunamiIO : public MmapDevice
 
     class RTCEvent : public Event
     {
+      protected:
+        Tsunami* tsunami;
       public:
-        RTCEvent();
+        RTCEvent(Tsunami* t);
 
         virtual void process();
         virtual const char *description();
@@ -86,6 +88,8 @@ class TsunamiIO : public MmapDevice
       uint8_t mode1;
       uint8_t mode2;
 
+    Tsunami *tsunami;
+
       /* This timer is initilized, but after I wrote the code
          it doesn't seem to be used again, and best I can tell
          it too is not connected to any interrupt port */
@@ -103,9 +107,13 @@ class TsunamiIO : public MmapDevice
 
       uint32_t timerData;
 
+    uint32_t  freq;
+
   public:
-    TsunamiIO(const std::string &name, /*Tsunami *t,*/ time_t init_time,
-               Addr addr, Addr mask, MemoryController *mmu);
+    uint32_t  frequency() const { return freq; }
+
+    TsunamiIO(const std::string &name, Tsunami *t, time_t init_time,
+               Addr addr, Addr mask, uint32_t f, MemoryController *mmu);
 
     void set_time(time_t t);
 
index aced6f940a332cf61c40c71b3998c6bff5336c01..aadcf998ff3ef339327216e3a6dae44e097a6b16 100644 (file)
@@ -23,9 +23,9 @@
 
 using namespace std;
 
-TsunamiPChip::TsunamiPChip(const string &name, /*Tsunami *t,*/
+TsunamiPChip::TsunamiPChip(const string &name, Tsunami *t,
                        Addr addr, Addr mask, MemoryController *mmu)
-    : MmapDevice(name, addr, mask, mmu)/*, tsunami(t) */
+    : MmapDevice(name, addr, mask, mmu), tsunami(t)
 {
     wsba0 = 0;
     wsba1 = 0;
@@ -40,6 +40,8 @@ TsunamiPChip::TsunamiPChip(const string &name, /*Tsunami *t,*/
     tba2 = 0;
     tba3 = 0;
 
+    //Set back pointer in tsunami
+    tsunami->pchip = this;
 }
 
 Fault
@@ -234,7 +236,7 @@ TsunamiPChip::unserialize(Checkpoint *cp, const std::string &section)
 
 BEGIN_DECLARE_SIM_OBJECT_PARAMS(TsunamiPChip)
 
-/*    SimObjectParam<Tsunami *> tsunami;*/
+    SimObjectParam<Tsunami *> tsunami;
     SimObjectParam<MemoryController *> mmu;
     Param<Addr> addr;
     Param<Addr> mask;
@@ -243,7 +245,7 @@ END_DECLARE_SIM_OBJECT_PARAMS(TsunamiPChip)
 
 BEGIN_INIT_SIM_OBJECT_PARAMS(TsunamiPChip)
 
-    /*INIT_PARAM(tsunami, "Tsunami"),*/
+    INIT_PARAM(tsunami, "Tsunami"),
     INIT_PARAM(mmu, "Memory Controller"),
     INIT_PARAM(addr, "Device Address"),
     INIT_PARAM(mask, "Address Mask")
@@ -252,7 +254,7 @@ END_INIT_SIM_OBJECT_PARAMS(TsunamiPChip)
 
 CREATE_SIM_OBJECT(TsunamiPChip)
 {
-    return new TsunamiPChip(getInstanceName(), /*tsunami,*/ addr, mask, mmu);
+    return new TsunamiPChip(getInstanceName(), tsunami, addr, mask, mmu);
 }
 
 REGISTER_SIM_OBJECT("TsunamiPChip", TsunamiPChip)
index cd87cf03aaeeddd7ee8dd0fa3ccaf62df577a053..6a7f24e95339724b6b2374bd0fa6013195d524e6 100644 (file)
@@ -61,7 +61,7 @@ class TsunamiPChip : public MmapDevice
 
 
   public:
-    TsunamiPChip(const std::string &name, /*Tsunami *t,*/
+    TsunamiPChip(const std::string &name, Tsunami *t,
                Addr addr, Addr mask, MemoryController *mmu);
 
     virtual Fault read(MemReqPtr req, uint8_t *data);