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 <nilay@cs.wisc.edu>
This commit is contained in:
Steve Reinhardt
2013-07-11 21:56:39 -05:00
parent b0b1c0205c
commit 2737650a69
12 changed files with 41 additions and 47 deletions

View File

@@ -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")

View File

@@ -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<uint32_t>((amba_id >> byte) & 0xFF);
return true;
}
} // namespace AmbaDev

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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<uint32_t>();
break;

View File

@@ -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<uint32_t>();
break;

View File

@@ -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);

View File

@@ -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<uint32_t>();
break;

View File

@@ -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<uint32_t>();
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;

View File

@@ -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;

View File

@@ -49,7 +49,7 @@
class BaseGic;
class Sp804 : public AmbaDevice
class Sp804 : public AmbaPioDevice
{
protected:
class Timer