X86: Make the real time clock actually keep track of time.
[gem5.git] / src / dev / pcidev.hh
index 5ddbe84a0f91a29442f3f1748ed31c0ce5b5f44c..5da8b2dfcdbfa4c51a4692401ef87cbf76476e32 100644 (file)
@@ -42,6 +42,7 @@
 #include "dev/io_device.hh"
 #include "dev/pcireg.h"
 #include "dev/platform.hh"
+#include "params/PciDevice.hh"
 #include "sim/byteswap.hh"
 
 #define BAR_IO_MASK 0x3
 #define BAR_NUMBER(x) (((x) - PCI0_BASE_ADDR0) >> 0x2);
 
 
-/**
- * This class encapulates the first 64 bytes of a singles PCI
- * devices config space that in configured by the configuration file.
- */
-class PciConfigData : public SimObject
-{
-  public:
-    /**
-     * Constructor to initialize the devices config space to 0.
-     */
-    PciConfigData(const std::string &name)
-        : SimObject(name)
-    {
-        std::memset(config.data, 0, sizeof(config.data));
-        std::memset(BARSize, 0, sizeof(BARSize));
-    }
-
-    /** The first 64 bytes */
-    PCIConfig config;
-
-    /** The size of the BARs */
-    uint32_t BARSize[6];
-};
-
 
 /**
  * PCI device, base implementation is only config space.
@@ -105,38 +82,15 @@ class PciDev : public DmaDevice
     };
 
   public:
-    struct Params : public DmaDevice::Params
+    typedef PciDeviceParams Params;
+    const Params *
+    params() const
     {
-        /**
-         * A pointer to the object that contains the first 64 bytes of
-         * config space
-         */
-        PciConfigData *configData;
-
-        /** The bus number we are on */
-        uint32_t busNum;
-
-        /** The device number we have */
-        uint32_t deviceNum;
-
-        /** The function number */
-        uint32_t functionNum;
-
-        /** The latency for pio accesses. */
-        Tick pio_delay;
-
-        /** The latency for a config access. */
-        Tick config_delay;
-    };
-
-  public:
-    const Params *params() const { return (const Params *)_params; }
+        return dynamic_cast<const Params *>(_params);
+    }
 
   protected:
-    /** The current config space. Unlike the PciConfigData this is
-     * updated during simulation while continues to reflect what was
-     * in the config file.
-     */
+    /** The current config space.  */
     PCIConfig config;
 
     /** The size of the BARs */
@@ -145,6 +99,9 @@ class PciDev : public DmaDevice
     /** The current address mapping of the BARs */
     Addr BARAddrs[6];
 
+    /** Whether the BARs are really hardwired legacy IO locations. */
+    bool legacyIO[6];
+
     /**
      * Does the given address lie within the space mapped by the given
      * base address register?
@@ -193,7 +150,6 @@ class PciDev : public DmaDevice
 
   protected:
     Platform *plat;
-    PciConfigData *configData;
     Tick pioDelay;
     Tick configDelay;
     PciConfigPort *configPort;
@@ -221,15 +177,15 @@ class PciDev : public DmaDevice
 
     void
     intrPost()
-    { plat->postPciInt(letoh(configData->config.interruptLine)); }
+    { plat->postPciInt(letoh(config.interruptLine)); }
 
     void
     intrClear()
-    { plat->clearPciInt(letoh(configData->config.interruptLine)); }
+    { plat->clearPciInt(letoh(config.interruptLine)); }
 
     uint8_t
     interruptLine()
-    { return letoh(configData->config.interruptLine); }
+    { return letoh(config.interruptLine); }
 
     /** return the address ranges that this device responds to.
      * @params range_list range list to populate with ranges
@@ -241,7 +197,7 @@ class PciDev : public DmaDevice
      * config file object PCIConfigData and registers the device with
      * a PciConfigAll object.
      */
-    PciDev(Params *params);
+    PciDev(const Params *params);
 
     virtual void init();
 
@@ -266,8 +222,8 @@ class PciDev : public DmaDevice
         if (if_name == "config") {
             if (configPort != NULL)
                 panic("pciconfig port already connected to.");
-            configPort = new PciConfigPort(this, params()->busNum,
-                    params()->deviceNum, params()->functionNum,
+            configPort = new PciConfigPort(this, params()->pci_bus,
+                    params()->pci_dev, params()->pci_func,
                     params()->platform);
             return configPort;
         }