misc: Merge branch v20.1.0.3 hotfix into develop
[gem5.git] / src / dev / x86 / i8254.hh
index e1de8a1bbf9c5f1836682953061ab22cf642bc4e..cbde5fea3a162530aa20bc77871952732e6b773d 100644 (file)
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Authors: Gabe Black
  */
 
 #ifndef __DEV_X86_I8254_HH__
 #define __DEV_X86_I8254_HH__
 
 #include "dev/intel_8254_timer.hh"
+#include "dev/intpin.hh"
 #include "dev/io_device.hh"
 #include "params/I8254.hh"
 
 namespace X86ISA
 {
 
-class IntSourcePin;
-
 class I8254 : public BasicPioDevice
 {
   protected:
@@ -64,25 +61,38 @@ class I8254 : public BasicPioDevice
 
     X86Intel8254Timer pit;
 
-    IntSourcePin *intPin;
+    std::vector<IntSourcePin<I8254> *> intPin;
 
     void counterInterrupt(unsigned int num);
 
   public:
     typedef I8254Params Params;
 
-    const Params *
+    Port &
+    getPort(const std::string &if_name, PortID idx=InvalidPortID) override
+    {
+        if (if_name == "int_pin")
+            return *intPin.at(idx);
+        else
+            return BasicPioDevice::getPort(if_name, idx);
+    }
+
+    const Params &
     params() const
     {
-        return dynamic_cast<const Params *>(_params);
+        return dynamic_cast<const Params &>(_params);
     }
 
-    I8254(Params *p) : BasicPioDevice(p, 4), latency(p->pio_latency),
-            pit(p->name, this), intPin(p->int_pin)
+    I8254(const Params &p) : BasicPioDevice(p, 4), latency(p.pio_latency),
+            pit(p.name, this)
     {
+        for (int i = 0; i < p.port_int_pin_connection_count; i++) {
+            intPin.push_back(new IntSourcePin<I8254>(csprintf(
+                            "%s.int_pin[%d]", name(), i), i, this));
+        }
     }
-    Tick read(PacketPtr pkt) override;
 
+    Tick read(PacketPtr pkt) override;
     Tick write(PacketPtr pkt) override;
 
     bool