Hello Nikos Nikoleris,
I'd like you to do a code review. Please visit
https://gem5-review.googlesource.com/2521
to review the following change.
Change subject: dev, arm: Add a GIC-based interrupt adaptor implementations
......................................................................
dev, arm: Add a GIC-based interrupt adaptor implementations
Add GIC-based interrupt adaptor implementations that support PPI and
SPI delivery. In addition to being useful for "normal" memory-mapped
devices, the PPI adaptor makes it possible to use the same device
model to generate both PPIs and SPIs (e.g., the PMU).
Change-Id: I73d6591c168040faef2443430c4f1da10c387a2a
Signed-off-by: Andreas Sandberg <[email protected]>
Reviewed-by: Nikos Nikoleris <[email protected]>
---
M src/dev/arm/Gic.py
M src/dev/arm/base_gic.cc
M src/dev/arm/base_gic.hh
3 files changed, 115 insertions(+), 5 deletions(-)
diff --git a/src/dev/arm/Gic.py b/src/dev/arm/Gic.py
index bc7794a..7a198b3 100644
--- a/src/dev/arm/Gic.py
+++ b/src/dev/arm/Gic.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2012-2013 ARM Limited
+# Copyright (c) 2012-2013, 2017 ARM Limited
# All rights reserved.
#
# The license below extends only to copyright in the software and shall
@@ -39,7 +39,7 @@
from m5.proxy import *
from m5.SimObject import SimObject
-from Device import PioDevice
+from Device import PioDevice, InterruptAdaptor
from Platform import Platform
class BaseGic(PioDevice):
@@ -49,6 +49,23 @@
platform = Param.Platform(Parent.any, "Platform this device is part
of.")
+class ArmInterrupt(InterruptAdaptor):
+ type = 'ArmInterrupt'
+ cxx_header = "dev/arm/base_gic.hh"
+ abstract = True
+
+ platform = Param.Platform(Parent.any, "Platform with interrupt
controller")
+ num = Param.UInt32("Interrupt number in GIC")
+
+class ArmSPI(ArmInterrupt):
+ type = 'ArmSPI'
+ cxx_header = "dev/arm/base_gic.hh"
+
+class ArmPPI(ArmInterrupt):
+ type = 'ArmPPI'
+ cxx_header = "dev/arm/base_gic.hh"
+
+
class Pl390(BaseGic):
type = 'Pl390'
cxx_header = "dev/arm/gic_pl390.hh"
diff --git a/src/dev/arm/base_gic.cc b/src/dev/arm/base_gic.cc
index ece8352..14a2556 100644
--- a/src/dev/arm/base_gic.cc
+++ b/src/dev/arm/base_gic.cc
@@ -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
@@ -40,6 +40,9 @@
#include "dev/arm/base_gic.hh"
#include "dev/arm/realview.hh"
+#include "params/ArmInterrupt.hh"
+#include "params/ArmPPI.hh"
+#include "params/ArmSPI.hh"
#include "params/BaseGic.hh"
BaseGic::BaseGic(const Params *p)
@@ -65,3 +68,58 @@
{
return dynamic_cast<const Params *>(_params);
}
+
+
+ArmInterrupt::ArmInterrupt(const ArmInterruptParams *p)
+ : InterruptAdaptor(p),
+ platform(dynamic_cast<RealView*>(p->platform)), int_num(p->num)
+{
+ fatal_if(!platform, "Interrupt not connected to a RealView platform");
+}
+
+ArmSPI::ArmSPI(const ArmSPIParams *p)
+ : ArmInterrupt(p)
+{
+}
+
+void
+ArmSPI::raise()
+{
+ platform->gic->sendInt(int_num);
+}
+
+void
+ArmSPI::clear()
+{
+ platform->gic->clearInt(int_num);
+}
+
+ArmPPI::ArmPPI(const ArmPPIParams *p)
+ : ArmInterrupt(p)
+{
+}
+
+void
+ArmPPI::raise()
+{
+ platform->gic->sendPPInt(int_num, targetContext());
+}
+
+void
+ArmPPI::clear()
+{
+ platform->gic->clearPPInt(int_num, targetContext());
+}
+
+
+ArmSPI *
+ArmSPIParams::create()
+{
+ return new ArmSPI(this);
+}
+
+ArmPPI *
+ArmPPIParams::create()
+{
+ return new ArmPPI(this);
+}
diff --git a/src/dev/arm/base_gic.hh b/src/dev/arm/base_gic.hh
index facc990..c91a0d4 100644
--- a/src/dev/arm/base_gic.hh
+++ b/src/dev/arm/base_gic.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2013 ARM Limited
+ * Copyright (c) 2012-2013, 2017 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
@@ -47,11 +47,17 @@
#include "dev/io_device.hh"
class Platform;
+class RealView;
+
+struct ArmInterruptParams;
+struct ArmPPIParams;
+struct ArmSPIParams;
+struct BaseGicParams;
class BaseGic : public PioDevice
{
public:
- typedef struct BaseGicParams Params;
+ typedef BaseGicParams Params;
BaseGic(const Params *p);
virtual ~BaseGic();
@@ -92,4 +98,33 @@
Platform *platform;
};
+class ArmInterrupt : public InterruptAdaptor
+{
+ public:
+ ArmInterrupt(const ArmInterruptParams *p);
+
+ protected:
+ RealView *const platform;
+ const uint32_t int_num;
+};
+
+class ArmSPI : public ArmInterrupt
+{
+ public:
+ ArmSPI(const ArmSPIParams *p);
+
+ void raise() override;
+ void clear() override;
+};
+
+class ArmPPI : public ArmInterrupt
+{
+ public:
+ ArmPPI(const ArmPPIParams *p);
+
+ void raise() override;
+ void clear() override;
+};
+
+
#endif
--
To view, visit https://gem5-review.googlesource.com/2521
To unsubscribe, visit https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I73d6591c168040faef2443430c4f1da10c387a2a
Gerrit-Change-Number: 2521
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