changeset 3f262c18ad5d in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=3f262c18ad5d
description:
dev/arm: get rid of AmbaDev namespace
It was confusing having an AmbaDev namespace along with an
AmbaDevice class. The namespace stuff is now moved in to
a new base AmbaDevice class, which is a mixin for classes
AmbaPioDevice (the former AmbaDevice) and AmbaDmaDevice
to provide the readId function as an inherited member function.
Committed by: Nilay Vaish <[email protected]>
diffstat:
src/dev/arm/RealView.py | 10 +++++-----
src/dev/arm/amba_device.cc | 12 +++++-------
src/dev/arm/amba_device.hh | 37 ++++++++++++++++++++-----------------
src/dev/arm/amba_fake.cc | 4 +---
src/dev/arm/amba_fake.hh | 2 +-
src/dev/arm/kmi.cc | 2 +-
src/dev/arm/pl011.cc | 2 +-
src/dev/arm/pl011.hh | 3 ++-
src/dev/arm/pl111.cc | 4 +---
src/dev/arm/rtc_pl031.cc | 6 ++----
src/dev/arm/timer_sp804.cc | 4 +---
src/dev/arm/timer_sp804.hh | 2 +-
12 files changed, 41 insertions(+), 47 deletions(-)
diffs (297 lines):
diff -r a4339e26b429 -r 3f262c18ad5d src/dev/arm/RealView.py
--- a/src/dev/arm/RealView.py Thu Jul 11 21:56:24 2013 -0500
+++ b/src/dev/arm/RealView.py Thu Jul 11 21:56:39 2013 -0500
@@ -52,13 +52,13 @@
from SimpleMemory import SimpleMemory
from Gic import *
-class AmbaDevice(BasicPioDevice):
- type = 'AmbaDevice'
+class AmbaPioDevice(BasicPioDevice):
+ type = 'AmbaPioDevice'
abstract = True
cxx_header = "dev/arm/amba_device.hh"
amba_id = Param.UInt32("ID of AMBA device for kernel detection")
-class AmbaIntDevice(AmbaDevice):
+class AmbaIntDevice(AmbaPioDevice):
type = 'AmbaIntDevice'
abstract = True
cxx_header = "dev/arm/amba_device.hh"
@@ -88,7 +88,7 @@
proc_id1 = Param.UInt32(0x0C000222, "Processor ID, SYS_PROCID1")
idreg = Param.UInt32(0x00000000, "ID Register, SYS_ID")
-class AmbaFake(AmbaDevice):
+class AmbaFake(AmbaPioDevice):
type = 'AmbaFake'
cxx_header = "dev/arm/amba_fake.hh"
ignore_access = Param.Bool(False, "Ignore reads/writes to this device,
(e.g. IsaFake + AMBA)")
@@ -102,7 +102,7 @@
end_on_eot = Param.Bool(False, "End the simulation when a EOT is received
on the UART")
int_delay = Param.Latency("100ns", "Time between action and interrupt
generation by UART")
-class Sp804(AmbaDevice):
+class Sp804(AmbaPioDevice):
type = 'Sp804'
cxx_header = "dev/arm/timer_sp804.hh"
gic = Param.BaseGic(Parent.any, "Gic to use for interrupting")
diff -r a4339e26b429 -r 3f262c18ad5d src/dev/arm/amba_device.cc
--- a/src/dev/arm/amba_device.cc Thu Jul 11 21:56:24 2013 -0500
+++ b/src/dev/arm/amba_device.cc Thu Jul 11 21:56:39 2013 -0500
@@ -49,13 +49,13 @@
const uint64_t AmbaVendor = ULL(0xb105f00d00000000);
-AmbaDevice::AmbaDevice(const Params *p)
+AmbaPioDevice::AmbaPioDevice(const Params *p)
: BasicPioDevice(p), ambaId(AmbaVendor | p->amba_id)
{
}
AmbaIntDevice::AmbaIntDevice(const Params *p)
- : AmbaDevice(p), intNum(p->int_num), gic(p->gic), intDelay(p->int_delay)
+ : AmbaPioDevice(p), intNum(p->int_num), gic(p->gic), intDelay(p->int_delay)
{
}
@@ -68,9 +68,8 @@
{
}
-namespace AmbaDev {
bool
-readId(PacketPtr pkt, uint64_t amba_id, Addr pio_addr)
+AmbaDevice::readId(PacketPtr pkt, uint64_t amba_id, Addr pio_addr)
{
Addr daddr = pkt->getAddr() - pio_addr;
if (daddr < AMBA_PER_ID0 || daddr > AMBA_CEL_ID3)
@@ -80,11 +79,10 @@
int byte = (daddr - AMBA_PER_ID0) << 1;
// Too noisy right now
- DPRINTF(AMBA, "Returning %#x for offset %#x(%d)\n", (amba_id >> byte) &
0xFF,
+ DPRINTF(AMBA, "Returning %#x for offset %#x(%d)\n",
+ (amba_id >> byte) & 0xFF,
pkt->getAddr() - pio_addr, byte);
assert(pkt->getSize() == 4);
pkt->set<uint32_t>((amba_id >> byte) & 0xFF);
return true;
}
-
-} // namespace AmbaDev
diff -r a4339e26b429 -r 3f262c18ad5d src/dev/arm/amba_device.hh
--- a/src/dev/arm/amba_device.hh Thu Jul 11 21:56:24 2013 -0500
+++ b/src/dev/arm/amba_device.hh Thu Jul 11 21:56:39 2013 -0500
@@ -54,35 +54,38 @@
#include "dev/io_device.hh"
#include "mem/packet.hh"
#include "mem/packet_access.hh"
-#include "params/AmbaDevice.hh"
+#include "params/AmbaPioDevice.hh"
#include "params/AmbaDmaDevice.hh"
#include "params/AmbaIntDevice.hh"
-namespace AmbaDev {
-const int AMBA_PER_ID0 = 0xFE0;
-const int AMBA_PER_ID1 = 0xFE4;
-const int AMBA_PER_ID2 = 0xFE8;
-const int AMBA_PER_ID3 = 0xFEC;
-const int AMBA_CEL_ID0 = 0xFF0;
-const int AMBA_CEL_ID1 = 0xFF4;
-const int AMBA_CEL_ID2 = 0xFF8;
-const int AMBA_CEL_ID3 = 0xFFC;
+class AmbaDevice
+{
+ protected:
+ static const int AMBA_PER_ID0 = 0xFE0;
+ static const int AMBA_PER_ID1 = 0xFE4;
+ static const int AMBA_PER_ID2 = 0xFE8;
+ static const int AMBA_PER_ID3 = 0xFEC;
+ static const int AMBA_CEL_ID0 = 0xFF0;
+ static const int AMBA_CEL_ID1 = 0xFF4;
+ static const int AMBA_CEL_ID2 = 0xFF8;
+ static const int AMBA_CEL_ID3 = 0xFFC;
-bool readId(PacketPtr pkt, uint64_t amba_id, Addr pio_addr);
-}
+ bool readId(PacketPtr pkt, uint64_t amba_id, Addr pio_addr);
+};
-class AmbaDevice : public BasicPioDevice
+
+class AmbaPioDevice : public BasicPioDevice, public AmbaDevice
{
protected:
uint64_t ambaId;
public:
- typedef AmbaDeviceParams Params;
- AmbaDevice(const Params *p);
+ typedef AmbaPioDeviceParams Params;
+ AmbaPioDevice(const Params *p);
};
-class AmbaIntDevice : public AmbaDevice
+class AmbaIntDevice : public AmbaPioDevice
{
protected:
int intNum;
@@ -94,7 +97,7 @@
AmbaIntDevice(const Params *p);
};
-class AmbaDmaDevice : public DmaDevice
+class AmbaDmaDevice : public DmaDevice, public AmbaDevice
{
protected:
uint64_t ambaId;
diff -r a4339e26b429 -r 3f262c18ad5d src/dev/arm/amba_fake.cc
--- a/src/dev/arm/amba_fake.cc Thu Jul 11 21:56:24 2013 -0500
+++ b/src/dev/arm/amba_fake.cc Thu Jul 11 21:56:39 2013 -0500
@@ -46,10 +46,8 @@
#include "mem/packet.hh"
#include "mem/packet_access.hh"
-using namespace AmbaDev;
-
AmbaFake::AmbaFake(const Params *p)
- : AmbaDevice(p)
+ : AmbaPioDevice(p)
{
pioSize = 0xfff;
}
diff -r a4339e26b429 -r 3f262c18ad5d src/dev/arm/amba_fake.hh
--- a/src/dev/arm/amba_fake.hh Thu Jul 11 21:56:24 2013 -0500
+++ b/src/dev/arm/amba_fake.hh Thu Jul 11 21:56:39 2013 -0500
@@ -54,7 +54,7 @@
#include "dev/arm/amba_device.hh"
#include "params/AmbaFake.hh"
-class AmbaFake : public AmbaDevice
+class AmbaFake : public AmbaPioDevice
{
public:
typedef AmbaFakeParams Params;
diff -r a4339e26b429 -r 3f262c18ad5d src/dev/arm/kmi.cc
--- a/src/dev/arm/kmi.cc Thu Jul 11 21:56:24 2013 -0500
+++ b/src/dev/arm/kmi.cc Thu Jul 11 21:56:39 2013 -0500
@@ -108,7 +108,7 @@
DPRINTF(Pl050, "Read Interrupts: %#x\n", (uint32_t)interrupts);
break;
default:
- if (AmbaDev::readId(pkt, ambaId, pioAddr)) {
+ if (readId(pkt, ambaId, pioAddr)) {
// Hack for variable size accesses
data = pkt->get<uint32_t>();
break;
diff -r a4339e26b429 -r 3f262c18ad5d src/dev/arm/pl011.cc
--- a/src/dev/arm/pl011.cc Thu Jul 11 21:56:24 2013 -0500
+++ b/src/dev/arm/pl011.cc Thu Jul 11 21:56:39 2013 -0500
@@ -116,7 +116,7 @@
data = maskInt;
break;
default:
- if (AmbaDev::readId(pkt, AMBA_ID, pioAddr)) {
+ if (readId(pkt, AMBA_ID, pioAddr)) {
// Hack for variable size accesses
data = pkt->get<uint32_t>();
break;
diff -r a4339e26b429 -r 3f262c18ad5d src/dev/arm/pl011.hh
--- a/src/dev/arm/pl011.hh Thu Jul 11 21:56:24 2013 -0500
+++ b/src/dev/arm/pl011.hh Thu Jul 11 21:56:39 2013 -0500
@@ -50,13 +50,14 @@
#include "base/bitfield.hh"
#include "base/bitunion.hh"
+#include "dev/arm/amba_device.hh"
#include "dev/io_device.hh"
#include "dev/uart.hh"
#include "params/Pl011.hh"
class BaseGic;
-class Pl011 : public Uart
+class Pl011 : public Uart, public AmbaDevice
{
protected:
static const uint64_t AMBA_ID = ULL(0xb105f00d00341011);
diff -r a4339e26b429 -r 3f262c18ad5d src/dev/arm/pl111.cc
--- a/src/dev/arm/pl111.cc Thu Jul 11 21:56:24 2013 -0500
+++ b/src/dev/arm/pl111.cc Thu Jul 11 21:56:39 2013 -0500
@@ -55,8 +55,6 @@
// we open up the entire namespace std
using std::vector;
-using namespace AmbaDev;
-
// initialize clcd registers
Pl111::Pl111(const Params *p)
: AmbaDmaDevice(p), lcdTiming0(0), lcdTiming1(0), lcdTiming2(0),
@@ -181,7 +179,7 @@
data = clcdCrsrMis;
break;
default:
- if (AmbaDev::readId(pkt, AMBA_ID, pioAddr)) {
+ if (readId(pkt, AMBA_ID, pioAddr)) {
// Hack for variable size accesses
data = pkt->get<uint32_t>();
break;
diff -r a4339e26b429 -r 3f262c18ad5d src/dev/arm/rtc_pl031.cc
--- a/src/dev/arm/rtc_pl031.cc Thu Jul 11 21:56:24 2013 -0500
+++ b/src/dev/arm/rtc_pl031.cc Thu Jul 11 21:56:39 2013 -0500
@@ -48,8 +48,6 @@
#include "mem/packet.hh"
#include "mem/packet_access.hh"
-using namespace AmbaDev;
-
PL031::PL031(Params *p)
: AmbaIntDevice(p), timeVal(mkutctime(&p->time)), lastWrittenTick(0),
loadVal(0), matchVal(0), rawInt(false), maskInt(false),
@@ -93,7 +91,7 @@
data = pendingInt;
break;
default:
- if (AmbaDev::readId(pkt, ambaId, pioAddr)) {
+ if (readId(pkt, ambaId, pioAddr)) {
// Hack for variable sized access
data = pkt->get<uint32_t>();
break;
@@ -156,7 +154,7 @@
}
break;
default:
- if (AmbaDev::readId(pkt, ambaId, pioAddr))
+ if (readId(pkt, ambaId, pioAddr))
break;
panic("Tried to read PL031 at offset %#x that doesn't exist\n", daddr);
break;
diff -r a4339e26b429 -r 3f262c18ad5d src/dev/arm/timer_sp804.cc
--- a/src/dev/arm/timer_sp804.cc Thu Jul 11 21:56:24 2013 -0500
+++ b/src/dev/arm/timer_sp804.cc Thu Jul 11 21:56:39 2013 -0500
@@ -46,10 +46,8 @@
#include "mem/packet.hh"
#include "mem/packet_access.hh"
-using namespace AmbaDev;
-
Sp804::Sp804(Params *p)
- : AmbaDevice(p), gic(p->gic), timer0(name() + ".timer0", this,
p->int_num0, p->clock0),
+ : AmbaPioDevice(p), gic(p->gic), timer0(name() + ".timer0", this,
p->int_num0, p->clock0),
timer1(name() + ".timer1", this, p->int_num1, p->clock1)
{
pioSize = 0xfff;
diff -r a4339e26b429 -r 3f262c18ad5d src/dev/arm/timer_sp804.hh
--- a/src/dev/arm/timer_sp804.hh Thu Jul 11 21:56:24 2013 -0500
+++ b/src/dev/arm/timer_sp804.hh Thu Jul 11 21:56:39 2013 -0500
@@ -49,7 +49,7 @@
class BaseGic;
-class Sp804 : public AmbaDevice
+class Sp804 : public AmbaPioDevice
{
protected:
class Timer
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev