Removed dynamic cast to get interrupt frequency and replaced with a
authorAli Saidi <saidi@eecs.umich.edu>
Tue, 1 Jun 2004 21:36:38 +0000 (17:36 -0400)
committerAli Saidi <saidi@eecs.umich.edu>
Tue, 1 Jun 2004 21:36:38 +0000 (17:36 -0400)
virtual function in alphaaccess.cc

dev/alpha_console.cc:
dev/alpha_console.hh:
dev/platform.hh:
dev/tsunami.cc:
dev/tsunami.hh:
dev/tsunami_io.hh:
    Removed dynamic cast to get interrupt frequency and replaced with a
    virtual function

--HG--
extra : convert_revision : 01f514a33d8f76c6527ab25a713d5c86f9fd646e

dev/alpha_console.cc
dev/alpha_console.hh
dev/platform.hh
dev/tsunami.cc
dev/tsunami.hh
dev/tsunami_io.hh

index 111b23c816dcae23f8396e724a6c05677c885b54..3d2ad0ec6f7f57886111679f24f1bb8deb77f367 100644 (file)
@@ -55,7 +55,7 @@
 using namespace std;
 
 AlphaConsole::AlphaConsole(const string &name, SimConsole *cons, SimpleDisk *d,
-                           System *system, BaseCPU *cpu, SimObject *clock,
+                           System *system, BaseCPU *cpu, Platform *platform,
                            int num_cpus, MemoryController *mmu, Addr a,
                            HierParams *hier, Bus *bus)
     : PioDevice(name), disk(d), console(cons), addr(a)
@@ -80,14 +80,7 @@ AlphaConsole::AlphaConsole(const string &name, SimConsole *cons, SimpleDisk *d,
     alphaAccess->numCPUs = num_cpus;
     alphaAccess->mem_size = system->physmem->size();
     alphaAccess->cpuClock = cpu->getFreq() / 1000000;
-    TsunamiIO *clock_linux = dynamic_cast<TsunamiIO *>(clock);
-    TlaserClock *clock_tru64 = dynamic_cast<TlaserClock *>(clock);
-    if (clock_linux)
-        alphaAccess->intrClockFrequency = clock_linux->frequency();
-    else if (clock_tru64)
-        alphaAccess->intrClockFrequency = clock_tru64->frequency();
-    else
-        panic("clock must be of type TlaserClock or TsunamiIO\n");
+        alphaAccess->intrClockFrequency = platform->intrFrequency();
     alphaAccess->diskUnit = 1;
 }
 
@@ -274,7 +267,7 @@ BEGIN_DECLARE_SIM_OBJECT_PARAMS(AlphaConsole)
     Param<Addr> addr;
     SimObjectParam<System *> system;
     SimObjectParam<BaseCPU *> cpu;
-    SimObjectParam<SimObject *> clock;
+    SimObjectParam<Platform *> platform;
     SimObjectParam<Bus*> io_bus;
     SimObjectParam<HierParams *> hier;
 
@@ -289,7 +282,7 @@ BEGIN_INIT_SIM_OBJECT_PARAMS(AlphaConsole)
     INIT_PARAM(addr, "Device Address"),
     INIT_PARAM(system, "system object"),
     INIT_PARAM(cpu, "Processor"),
-    INIT_PARAM(clock, "Clock"),
+    INIT_PARAM(platform, "platform"),
     INIT_PARAM_DFLT(io_bus, "The IO Bus to attach to", NULL),
     INIT_PARAM_DFLT(hier, "Hierarchy global variables", &defaultHierParams)
 
@@ -298,7 +291,7 @@ END_INIT_SIM_OBJECT_PARAMS(AlphaConsole)
 CREATE_SIM_OBJECT(AlphaConsole)
 {
     return new AlphaConsole(getInstanceName(), sim_console, disk,
-                            system, cpu, clock, num_cpus, mmu,
+                            system, cpu, platform, num_cpus, mmu,
                             addr, hier, io_bus);
 }
 
index 4986d0e5f0702bf039f461903180b0b2b6793e84..fa527dc3202cc27883eca8283117c2034b22f308 100644 (file)
 #include "dev/alpha_access.h"
 #include "dev/io_device.hh"
 #include "sim/host.hh"
-#include "dev/tsunami_io.hh"
 #include "sim/sim_object.hh"
 
 class BaseCPU;
 class SimConsole;
 class System;
-class TlaserClock;
+class Platform;
 class SimpleDisk;
 
 /*
@@ -91,7 +90,7 @@ class AlphaConsole : public PioDevice
   public:
     /** Standard Constructor */
     AlphaConsole(const std::string &name, SimConsole *cons, SimpleDisk *d,
-                 System *system, BaseCPU *cpu, SimObject *clock,
+                 System *system, BaseCPU *cpu, Platform *platform,
                  int num_cpus, MemoryController *mmu, Addr addr,
                  HierParams *hier, Bus *bus);
 
index 407f58406cd80cf0a392691764c2aae01b877aaa..f77b520a3b710de9afc1cbcce0cb1630ff6973ce 100644 (file)
@@ -60,6 +60,7 @@ class Platform : public SimObject
     virtual ~Platform() {}
     virtual void postConsoleInt() = 0;
     virtual void clearConsoleInt() = 0;
+    virtual Tick intrFrequency() = 0;
 };
 
 #endif // __PLATFORM_HH_
index 8956ee557f8a2ee96cb4077c50d0046938558127..b5e7ab3b8af835d163902fe585c4781e571793fb 100644 (file)
@@ -56,6 +56,12 @@ Tsunami::Tsunami(const string &name, System *s,
         intr_sum_type[i] = 0;
 }
 
+Tick
+Tsunami::intrFrequency()
+{
+    return io->frequency();
+}
+
 void
 Tsunami::postConsoleInt()
 {
index c5dbe797b8a1dde8d149b88e32eb63e89b2b8f07..a237a8035072f5da88f1a8c3e35add93ee0d4358 100644 (file)
@@ -95,6 +95,12 @@ class Tsunami : public Platform
     Tsunami(const std::string &name, System *s, IntrControl *intctrl,
             PciConfigAll *pci, int intrFreq);
 
+    /**
+     * Return the interrupting frequency to AlphaAccess
+     * @return frequency of RTC interrupts
+     */
+     virtual Tick intrFrequency();
+
     /**
      * Cause the cpu to post a serial interrupt to the CPU.
      */
index 1dd7762e3136801ada693511fbad7f8dd5d23325..62af2153b3715fdd50af60e475b9e2452b9965aa 100644 (file)
@@ -192,8 +192,11 @@ class TsunamiIO : public FunctionalMemory
 
 
   public:
-    /** Return the freqency of the RTC */
-    uint32_t  frequency() const { return RTC_RATE; }
+    /**
+     * Return the freqency of the RTC
+     * @return interrupt rate of the RTC
+     */
+    Tick  frequency() const { return RTC_RATE; }
 
 
     /**