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
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")
{
}
+AmbaDmaDevice::AmbaDmaDevice(const Params *p)
+ : DmaDevice(p), ambaId(ULL(0xb105f00d00000000) | p->amba_id)
+{
+}
+
+
+namespace AmbaDev {
bool
-AmbaDevice::readId(PacketPtr pkt)
+readId(PacketPtr pkt, uint64_t amba_id, Addr pio_addr)
{
- Addr daddr = pkt->getAddr() - pioAddr;
+ 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
#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);
+class AmbaDmaDevice : public DmaDevice
+{
+ protected:
+ uint64_t ambaId;
+
+ public:
+ typedef AmbaDmaDeviceParams Params;
+ AmbaDmaDevice(const Params *p);
};
-#endif //__DEV_ARM_AMBA_FAKE_H__
+
+#endif //__DEV_ARM_AMBA_DEVICE_H__
#include "mem/packet.hh"
#include "mem/packet_access.hh"
+using namespace AmbaDev;
+
AmbaFake::AmbaFake(const Params *p)
: AmbaDevice(p)
{
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();
*/
#include "base/trace.hh"
+#include "dev/arm/amba_device.hh"
#include "dev/arm/gic.hh"
#include "dev/arm/pl011.hh"
#include "dev/terminal.hh"
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;
}
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;
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;
#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)
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;
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;