From 2737650a69f0c56d325c2d9cfd45eef099fbd581 Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Thu, 11 Jul 2013 21:56:39 -0500 Subject: 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 --- 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(-) diff --git a/src/dev/arm/RealView.py b/src/dev/arm/RealView.py index 5c2768fb9..731e8abe7 100644 --- a/src/dev/arm/RealView.py +++ b/src/dev/arm/RealView.py @@ -52,13 +52,13 @@ from Uart import Uart 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 @@ class RealViewCtrl(BasicPioDevice): 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 @@ class Pl011(Uart): 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 --git a/src/dev/arm/amba_device.cc b/src/dev/arm/amba_device.cc index a9a163fd2..617a67d79 100644 --- a/src/dev/arm/amba_device.cc +++ b/src/dev/arm/amba_device.cc @@ -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 @@ AmbaDmaDevice::AmbaDmaDevice(const Params *p) { } -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 @@ readId(PacketPtr pkt, uint64_t amba_id, Addr pio_addr) 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((amba_id >> byte) & 0xFF); return true; } - -} // namespace AmbaDev diff --git a/src/dev/arm/amba_device.hh b/src/dev/arm/amba_device.hh index 6a3ed1c9e..d908ae616 100644 --- a/src/dev/arm/amba_device.hh +++ b/src/dev/arm/amba_device.hh @@ -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 @@ class AmbaIntDevice : public AmbaDevice AmbaIntDevice(const Params *p); }; -class AmbaDmaDevice : public DmaDevice +class AmbaDmaDevice : public DmaDevice, public AmbaDevice { protected: uint64_t ambaId; diff --git a/src/dev/arm/amba_fake.cc b/src/dev/arm/amba_fake.cc index cc1f51761..654bd3112 100644 --- a/src/dev/arm/amba_fake.cc +++ b/src/dev/arm/amba_fake.cc @@ -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 --git a/src/dev/arm/amba_fake.hh b/src/dev/arm/amba_fake.hh index 24b326e8a..98bdf3269 100644 --- a/src/dev/arm/amba_fake.hh +++ b/src/dev/arm/amba_fake.hh @@ -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 --git a/src/dev/arm/kmi.cc b/src/dev/arm/kmi.cc index b5819c9d8..01b1fa737 100644 --- a/src/dev/arm/kmi.cc +++ b/src/dev/arm/kmi.cc @@ -108,7 +108,7 @@ Pl050::read(PacketPtr pkt) 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(); break; diff --git a/src/dev/arm/pl011.cc b/src/dev/arm/pl011.cc index 8593c4e54..8af270878 100644 --- a/src/dev/arm/pl011.cc +++ b/src/dev/arm/pl011.cc @@ -116,7 +116,7 @@ Pl011::read(PacketPtr pkt) 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(); break; diff --git a/src/dev/arm/pl011.hh b/src/dev/arm/pl011.hh index a13f635f0..b5c55beab 100644 --- a/src/dev/arm/pl011.hh +++ b/src/dev/arm/pl011.hh @@ -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 --git a/src/dev/arm/pl111.cc b/src/dev/arm/pl111.cc index 5929da07c..c3d684f29 100644 --- a/src/dev/arm/pl111.cc +++ b/src/dev/arm/pl111.cc @@ -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 @@ Pl111::read(PacketPtr pkt) 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(); break; diff --git a/src/dev/arm/rtc_pl031.cc b/src/dev/arm/rtc_pl031.cc index 99436c280..ca1486f04 100644 --- a/src/dev/arm/rtc_pl031.cc +++ b/src/dev/arm/rtc_pl031.cc @@ -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 @@ PL031::read(PacketPtr pkt) data = pendingInt; break; default: - if (AmbaDev::readId(pkt, ambaId, pioAddr)) { + if (readId(pkt, ambaId, pioAddr)) { // Hack for variable sized access data = pkt->get(); break; @@ -156,7 +154,7 @@ PL031::write(PacketPtr pkt) } 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 --git a/src/dev/arm/timer_sp804.cc b/src/dev/arm/timer_sp804.cc index 18a22e108..d4550845d 100644 --- a/src/dev/arm/timer_sp804.cc +++ b/src/dev/arm/timer_sp804.cc @@ -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 --git a/src/dev/arm/timer_sp804.hh b/src/dev/arm/timer_sp804.hh index c000985bd..03dc20ec1 100644 --- a/src/dev/arm/timer_sp804.hh +++ b/src/dev/arm/timer_sp804.hh @@ -49,7 +49,7 @@ class BaseGic; -class Sp804 : public AmbaDevice +class Sp804 : public AmbaPioDevice { protected: class Timer -- cgit v1.2.3