Hello Nikos Nikoleris,

I'd like you to do a code review. Please visit

    https://gem5-review.googlesource.com/2327

to review the following change.


Change subject: dev, arm: Add a VirtIO MMIO device
......................................................................

dev, arm: Add a VirtIO MMIO device

Add an ARM-specific VirtIO MMIO device to the VExpress_GEM5_V1
platform.

Change-Id: Id1e75398e039aad9d637f46f653cda9084d3d2fe
Signed-off-by: Andreas Sandberg <[email protected]>
Reviewed-by: Sudhanshu Jha <[email protected]>
Reviewed-by: Nikos Nikoleris <[email protected]>
Reviewed-by: Rekai Gonzalez Alberquilla <[email protected]>
---
M src/dev/arm/RealView.py
M src/dev/arm/SConscript
A src/dev/arm/virtio_arm.cc
A src/dev/arm/virtio_arm.hh
M system/arm/dt/platforms/vexpress_gem5_v1.dtsi
5 files changed, 157 insertions(+), 1 deletion(-)



diff --git a/src/dev/arm/RealView.py b/src/dev/arm/RealView.py
index 20112d4..36155db 100644
--- a/src/dev/arm/RealView.py
+++ b/src/dev/arm/RealView.py
@@ -56,6 +56,7 @@
 from EnergyCtrl import EnergyCtrl
 from ClockDomain import SrcClockDomain
 from SubSystem import SubSystem
+from VirtIO import MmioVirtIO

 # Platforms with KVM support should generally use in-kernel GIC
 # emulation. Use a GIC model that automatically switches between
@@ -111,6 +112,13 @@
     int_policy = Param.ArmPciIntRouting("PCI interrupt routing policy")
     int_base = Param.Unsigned("PCI interrupt base")
int_count = Param.Unsigned("Maximum number of interrupts used by this host")
+
+class ArmMmioVirtIO(MmioVirtIO):
+    type = 'ArmMmioVirtIO'
+    cxx_header = "dev/arm/virtio_arm.hh"
+
+    gic = Param.BaseGic(Parent.any, "Gic to use for interrupting")
+    int_num = Param.UInt32("Interrupt number that connects to GIC")

 class RealViewCtrl(BasicPioDevice):
     type = 'RealViewCtrl'
@@ -828,6 +836,7 @@
        0x1c0a0000-0x1c0affff: UART1 (reserved)
        0x1c0b0000-0x1c0bffff: UART2 (reserved)
        0x1c0c0000-0x1c0cffff: UART3 (reserved)
+       0x1c130000-0x1c13ffff: VirtIO (gem5/FM extension)
        0x1c170000-0x1c17ffff: RTC

    0x20000000-0x3fffffff: On-chip peripherals:
@@ -872,6 +881,7 @@
         48   : Reserved (USB)
     95-255: On-chip interrupt sources (we use these for
             gem5-specific devices, SPIs)
+         74    : VirtIO (gem5/FM extension)
          95    : HDLCD
          96- 98: GPU (reserved)
         100-103: PCI
@@ -933,6 +943,9 @@

     energy_ctrl = EnergyCtrl(pio_addr=0x10000000)

+    vio0 = ArmMmioVirtIO(pio_addr=0x1c130000, pio_size=0x1000,
+                         gic=Parent.gic, int_num=74)
+

     def _off_chip_devices(self):
         return [
@@ -942,6 +955,7 @@
             self.rtc,
             self.pci_host,
             self.energy_ctrl,
+            self.vio0,
         ]

     def attachPciDevice(self, device, *args, **kwargs):
diff --git a/src/dev/arm/SConscript b/src/dev/arm/SConscript
index 7a55992..328242f 100644
--- a/src/dev/arm/SConscript
+++ b/src/dev/arm/SConscript
@@ -1,6 +1,6 @@
 # -*- mode:python -*-

-# Copyright (c) 2009, 2012-2013 ARM Limited
+# Copyright (c) 2009, 2012-2013, 2016 ARM Limited
 # All rights reserved.
 #
 # The license below extends only to copyright in the software and shall
@@ -70,6 +70,7 @@
     Source('vgic.cc')
     Source('ufs_device.cc')
     Source('energy_ctrl.cc')
+    Source('virtio_arm.cc')

     DebugFlag('AMBA')
     DebugFlag('FlashDevice')
diff --git a/src/dev/arm/virtio_arm.cc b/src/dev/arm/virtio_arm.cc
new file mode 100644
index 0000000..1ef7585
--- /dev/null
+++ b/src/dev/arm/virtio_arm.cc
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2016 ARM Limited
+ * All rights reserved
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder.  You may use the software subject to the license
+ * terms below provided that you ensure that this notice is replicated
+ * unmodified and in its entirety in all distributions of the software,
+ * modified or unmodified, in source code or in binary form.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * 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: Andreas Sandberg
+ */
+
+#include "dev/arm/virtio_arm.hh"
+
+#include "dev/arm/base_gic.hh"
+#include "params/ArmMmioVirtIO.hh"
+
+ArmMmioVirtIO::ArmMmioVirtIO(const ArmMmioVirtIOParams *p)
+    : MmioVirtIO(p),
+      gic(p->gic),
+      vioInterrupt(p->int_num)
+{
+    fatal_if(!gic, "No GIC specified!\n");
+}
+
+void
+ArmMmioVirtIO::raiseInterrupt()
+{
+    gic->sendInt(vioInterrupt);
+}
+
+void
+ArmMmioVirtIO::clearInterrupt()
+{
+    gic->clearInt(vioInterrupt);
+}
+
+
+ArmMmioVirtIO *
+ArmMmioVirtIOParams::create()
+{
+    return new ArmMmioVirtIO(this);
+}
diff --git a/src/dev/arm/virtio_arm.hh b/src/dev/arm/virtio_arm.hh
new file mode 100644
index 0000000..cd8e2c4
--- /dev/null
+++ b/src/dev/arm/virtio_arm.hh
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2016 ARM Limited
+ * All rights reserved
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder.  You may use the software subject to the license
+ * terms below provided that you ensure that this notice is replicated
+ * unmodified and in its entirety in all distributions of the software,
+ * modified or unmodified, in source code or in binary form.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * 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: Andreas Sandberg
+ */
+
+#ifndef __DEV_ARM_VIRTIO_ARM_HH__
+#define __DEV_ARM_VIRTIO_ARM_HH__
+
+#include "dev/virtio/mmio.hh"
+
+class BaseGic;
+struct ArmMmioVirtIOParams;
+
+class ArmMmioVirtIO
+    : public MmioVirtIO
+{
+  public:
+    ArmMmioVirtIO(const ArmMmioVirtIOParams *p);
+    virtual ~ArmMmioVirtIO() {}
+
+  protected: // MmioVirtIO
+    void raiseInterrupt() override;
+    void clearInterrupt() override;
+
+  protected: // Params
+    BaseGic *const gic;
+
+    const uint32_t vioInterrupt;
+};
+
+#endif // __DEV_ARM_VIRTIO_ARM_HH__
diff --git a/system/arm/dt/platforms/vexpress_gem5_v1.dtsi b/system/arm/dt/platforms/vexpress_gem5_v1.dtsi
index 4d463e7..fbbe3e8 100644
--- a/system/arm/dt/platforms/vexpress_gem5_v1.dtsi
+++ b/system/arm/dt/platforms/vexpress_gem5_v1.dtsi
@@ -140,6 +140,12 @@
                #gpio-cells = <2>;
        };

+       vio@1c130000 {
+               compatible = "virtio,mmio";
+               reg = <0 0x1c130000 0x0 0x1000>;
+               interrupts = <0 42 4>;
+       };
+
        dcc {
                compatible = "arm,vexpress,config-bus";
                arm,vexpress,config-bridge = <&v2m_sysreg>;

--
To view, visit https://gem5-review.googlesource.com/2327
To unsubscribe, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id1e75398e039aad9d637f46f653cda9084d3d2fe
Gerrit-Change-Number: 2327
Gerrit-PatchSet: 1
Gerrit-Owner: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Nikos Nikoleris <[email protected]>
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to