ARM: Change how the AMBA device ID checking is done to make it more generic

This commit is contained in:
Ali Saidi 2010-08-23 11:18:40 -05:00
parent 330fada1aa
commit c0ca01ec36
7 changed files with 64 additions and 45 deletions

View file

@ -41,7 +41,7 @@
from m5.params import *
from m5.proxy import *
from Device import BasicPioDevice, PioDevice, IsaFake, BadAddr
from Device import BasicPioDevice, PioDevice, IsaFake, BadAddr, DmaDevice
from Platform import Platform
from Terminal import Terminal
from Uart import Uart
@ -51,6 +51,11 @@ class AmbaDevice(BasicPioDevice):
abstract = True
amba_id = Param.UInt32("ID of AMBA device for kernel detection")
class AmbaDmaDevice(DmaDevice):
type = 'AmbaDmaDevice'
abstract = True
amba_id = Param.UInt32("ID of AMBA device for kernel detection")
class RealViewCtrl(BasicPioDevice):
type = 'RealViewCtrl'
proc_id = Param.UInt32(0x0C000000, "Platform ID")

View file

@ -50,22 +50,29 @@ AmbaDevice::AmbaDevice(const Params *p)
{
}
bool
AmbaDevice::readId(PacketPtr pkt)
AmbaDmaDevice::AmbaDmaDevice(const Params *p)
: DmaDevice(p), ambaId(ULL(0xb105f00d00000000) | p->amba_id)
{
Addr daddr = pkt->getAddr() - pioAddr;
}
namespace AmbaDev {
bool
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)
return false;
pkt->allocate();
daddr -= AMBA_PER_ID0;
daddr <<= 1;
int byte = (daddr - AMBA_PER_ID0) << 1;
// Too noisy right now
//DPRINTF(AMBA, "Returning %#x for offset %#x(%d)\n", (ambaId >> daddr) & 0xFF,
// pkt->getAddr() - pioAddr, daddr);
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>((ambaId >> daddr) & 0xFF);
pkt->set<uint32_t>((amba_id >> byte) & 0xFF);
return true;
}
} // namespace AmbaDev

View file

@ -50,33 +50,45 @@
#define __DEV_ARM_AMBA_DEVICE_H__
#include "base/range.hh"
#include "mem/packet.hh"
#include "mem/packet_access.hh"
#include "dev/io_device.hh"
#include "params/AmbaDevice.hh"
#include "params/AmbaDmaDevice.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;
bool readId(PacketPtr pkt, uint64_t amba_id, Addr pio_addr);
}
class AmbaDevice : public BasicPioDevice
{
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;
uint64_t ambaId;
public:
typedef AmbaDeviceParams Params;
const Params *
params() const
{
return dynamic_cast<const Params *>(_params);
}
typedef AmbaDeviceParams Params;
AmbaDevice(const Params *p);
bool readId(PacketPtr pkt);
};
#endif //__DEV_ARM_AMBA_FAKE_H__
class AmbaDmaDevice : public DmaDevice
{
protected:
uint64_t ambaId;
public:
typedef AmbaDmaDeviceParams Params;
AmbaDmaDevice(const Params *p);
};
#endif //__DEV_ARM_AMBA_DEVICE_H__

View file

@ -45,6 +45,8 @@
#include "mem/packet.hh"
#include "mem/packet_access.hh"
using namespace AmbaDev;
AmbaFake::AmbaFake(const Params *p)
: AmbaDevice(p)
{
@ -62,7 +64,7 @@ AmbaFake::read(PacketPtr pkt)
DPRINTF(AMBA, " read register %#x\n", daddr);
pkt->set<uint32_t>(0);
if (!readId(pkt) && !params()->ignore_access)
if (!readId(pkt, ambaId, pioAddr) && !params()->ignore_access)
panic("Tried to read AmbaFake at offset %#x that doesn't exist\n", daddr);
pkt->makeAtomicResponse();

View file

@ -41,6 +41,7 @@
*/
#include "base/trace.hh"
#include "dev/arm/amba_device.hh"
#include "dev/arm/gic.hh"
#include "dev/arm/pl011.hh"
#include "dev/terminal.hh"
@ -113,15 +114,12 @@ Pl011::read(PacketPtr pkt)
data = maskInt;
break;
default:
if (daddr >= UART_PER_ID0 && daddr <= UART_CEL_ID3) {
// AMBA ID information
int byte;
byte = (daddr - UART_PER_ID0) << 1;
DPRINTF(AMBA, "--daddr=%#x shift=%d val=%#x\n", daddr, byte,
(ULL(0xb105f00d00341011) >> byte) & 0xFF);
data = (ULL(0xb105f00d00341011) >> byte) & 0xFF;
if (AmbaDev::readId(pkt, AMBA_ID, pioAddr)) {
// Hack for variable size accesses
data = pkt->get<uint32_t>();
break;
}
panic("Tried to read PL011 at offset %#x that doesn't exist\n", daddr);
break;
}

View file

@ -58,6 +58,7 @@ class Gic;
class Pl011 : public Uart
{
protected:
static const uint64_t AMBA_ID = ULL(0xb105f00d00341011);
static const int UART_DR = 0x000;
static const int UART_FR = 0x018;
static const int UART_FR_CTS = 0x001;
@ -72,14 +73,6 @@ class Pl011 : public Uart
static const int UART_RIS = 0x03C;
static const int UART_MIS = 0x040;
static const int UART_ICR = 0x044;
static const int UART_PER_ID0 = 0xFE0;
static const int UART_PER_ID1 = 0xFE4;
static const int UART_PER_ID2 = 0xFE8;
static const int UART_PER_ID3 = 0xFEC;
static const int UART_CEL_ID0 = 0xFF0;
static const int UART_CEL_ID1 = 0xFF4;
static const int UART_CEL_ID2 = 0xFF8;
static const int UART_CEL_ID3 = 0xFFC;
uint16_t control;

View file

@ -44,6 +44,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),
timer1(name() + ".timer1", this, p->int_num1, p->clock1)
@ -71,7 +73,7 @@ Sp804::read(PacketPtr pkt)
timer0.read(pkt, daddr);
else if ((daddr - Timer::Size) < Timer::Size)
timer1.read(pkt, daddr - Timer::Size);
else if (!readId(pkt))
else if (!readId(pkt, ambaId, pioAddr))
panic("Tried to read SP804 at offset %#x that doesn't exist\n", daddr);
pkt->makeAtomicResponse();
return pioDelay;
@ -127,7 +129,7 @@ Sp804::write(PacketPtr pkt)
timer0.write(pkt, daddr);
else if ((daddr - Timer::Size) < Timer::Size)
timer1.write(pkt, daddr - Timer::Size);
else if (!readId(pkt))
else if (!readId(pkt, ambaId, pioAddr))
panic("Tried to write SP804 at offset %#x that doesn't exist\n", daddr);
pkt->makeAtomicResponse();
return pioDelay;