Hello Nikos Nikoleris,
I'd like you to do a code review. Please visit
https://gem5-review.googlesource.com/2520
to review the following change.
Change subject: dev: Add an InterruptAdaptor class to wrap plain interrupts
......................................................................
dev: Add an InterruptAdaptor class to wrap plain interrupts
Plain interrupts are delivered using platform-specific interrupt
controllers. This makes it hard to implement MMIO devices with
interrupts (e.g., VirtIO). This change introduces an abstract
interrupt adaptor class that can be implemented by platforms that need
to support such devices.
Change-Id: I181d952f17958549f25883e8aed4b00681550158
Signed-off-by: Andreas Sandberg <[email protected]>
Reviewed-by: Nikos Nikoleris <[email protected]>
---
M src/dev/Device.py
M src/dev/io_device.cc
M src/dev/io_device.hh
3 files changed, 92 insertions(+), 2 deletions(-)
diff --git a/src/dev/Device.py b/src/dev/Device.py
index d51d7bd..679bbd1 100644
--- a/src/dev/Device.py
+++ b/src/dev/Device.py
@@ -1,3 +1,15 @@
+# Copyright (c) 2012-2017 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.
+#
# Copyright (c) 2005-2007 The Regents of The University of Michigan
# All rights reserved.
#
@@ -29,6 +41,7 @@
from m5.params import *
from m5.proxy import *
from MemObject import MemObject
+from m5.SimObject import SimObject
class PioDevice(MemObject):
type = 'PioDevice'
@@ -37,6 +50,11 @@
pio = SlavePort("Programmed I/O port")
system = Param.System(Parent.any, "System this device is part of")
+class InterruptAdaptor(SimObject):
+ type = "InterruptAdaptor"
+ cxx_header = "dev/io_device.hh"
+ abstract = True
+
class BasicPioDevice(PioDevice):
type = 'BasicPioDevice'
cxx_header = "dev/io_device.hh"
diff --git a/src/dev/io_device.cc b/src/dev/io_device.cc
index 28ea52a..d4c4f2b 100644
--- a/src/dev/io_device.cc
+++ b/src/dev/io_device.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2015 ARM Limited
+ * Copyright (c) 2012, 2015, 2017 ARM Limited
* All rights reserved.
*
* The license below extends only to copyright in the software and shall
@@ -44,7 +44,9 @@
#include "dev/io_device.hh"
#include "base/trace.hh"
+#include "cpu/thread_context.hh"
#include "debug/AddrRanges.hh"
+#include "params/InterruptAdaptor.hh"
#include "sim/system.hh"
PioPort::PioPort(PioDevice *dev)
@@ -71,6 +73,32 @@
return device->getAddrRanges();
}
+
+
+InterruptAdaptor::InterruptAdaptor(const InterruptAdaptorParams *p)
+ : SimObject(p),
+ threadContext(nullptr)
+{
+}
+
+void
+InterruptAdaptor::setThreadContext(ThreadContext *tc)
+{
+ panic_if(threadContext,
+ "InterruptAdaptor::setThreadContext called twice\n");
+
+ threadContext = tc;
+}
+
+ContextID
+InterruptAdaptor::targetContext() const
+{
+ panic_if(!threadContext, "Per-context interrupt triggered without a " \
+ "call to InterruptAdaptor::setThreadContext.\n");
+ return threadContext->contextId();
+}
+
+
PioDevice::PioDevice(const Params *p)
: MemObject(p), sys(p->system), pioPort(this)
{}
diff --git a/src/dev/io_device.hh b/src/dev/io_device.hh
index 7e323b3..373f0a6 100644
--- a/src/dev/io_device.hh
+++ b/src/dev/io_device.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012 ARM Limited
+ * Copyright (c) 2012, 2017 ARM Limited
* All rights reserved.
*
* The license below extends only to copyright in the software and shall
@@ -51,6 +51,9 @@
class PioDevice;
class System;
+class ThreadContext;
+
+struct InterruptAdaptorParams;
/**
* The PioPort class is a programmed i/o port that all devices that are
@@ -75,6 +78,47 @@
};
/**
+ * This is an abstract wrapper around an interrupt. It is used as an
+ * adaptor to send platform-specific interrupts.
+ */
+class InterruptAdaptor : public SimObject
+{
+ public:
+ InterruptAdaptor(const InterruptAdaptorParams *p);
+
+ public: /* Public interface */
+ /**
+ * Set the thread context owning this interrupt.
+ *
+ * This method is used to set the thread context for interrupts
+ * that are thread/CPU-specific. Only devices that are used in
+ * such a context are expected to call this method.
+ */
+ void setThreadContext(ThreadContext *tc);
+
+ /** Signal an interrupt */
+ virtual void raise() = 0;
+ /** Clear a signalled interrupt */
+ virtual void clear() = 0;
+
+ protected:
+ /**
+ * Get the target context ID of this interrupt.
+ *
+ * @pre setThreadContext() must have been called prior to calling
+ * this method.
+ */
+ ContextID targetContext() const;
+
+ /**
+ * Pointer to the thread context that owns this interrupt in case
+ * it is a thread-/CPU-private interrupt
+ */
+ const ThreadContext *threadContext;
+};
+
+
+/**
* This device is the base class which all devices senstive to an address
range
* inherit from. There are three pure virtual functions which all devices
must
* implement getAddrRanges(), read(), and write(). The magic do choose
which
--
To view, visit https://gem5-review.googlesource.com/2520
To unsubscribe, visit https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I181d952f17958549f25883e8aed4b00681550158
Gerrit-Change-Number: 2520
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