ARM: Change how the AMBA device ID checking is done to make it more generic
authorAli Saidi <Ali.Saidi@arm.com>
Mon, 23 Aug 2010 16:18:40 +0000 (11:18 -0500)
committerAli Saidi <Ali.Saidi@arm.com>
Mon, 23 Aug 2010 16:18:40 +0000 (11:18 -0500)
src/dev/arm/RealView.py
src/dev/arm/amba_device.cc
src/dev/arm/amba_device.hh
src/dev/arm/amba_fake.cc
src/dev/arm/pl011.cc
src/dev/arm/pl011.hh
src/dev/arm/timer_sp804.cc

index 27d1e6b45d533216784ac371c823a995705af1f8..0efaa73bb6610d72c5daa165d11d7d856672d87a 100644 (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")
index 81c740aec46949ed43a9f6a14067ed7db44d893e..0acd7208aeed1a870c097668c9babd47f7fea68e 100644 (file)
@@ -50,22 +50,29 @@ AmbaDevice::AmbaDevice(const Params *p)
 {
 }
 
+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
index b2d7af043767d035520243dc499642ae9704339a..679202c8470218d2487d6983e263badd5de53b6e 100644 (file)
 #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__
index 25206c6745366ea63f63c33eefd7f4be999ac0f8..f2115048b0c8cdc6ff15920177a84058043afd38 100644 (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();
index 2afc9977dc5f91014519256f57d93e39a69143fd..555636f04625465c34d3986e3c99187a102b7612 100644 (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;
     }
index 63289fc38b1ef339c8affff812b268ad48895ee6..ddfd8305bcbc09fe482fe8d3051134013233abf1 100644 (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;
 
index 6a6792f609855ef515d672b1b2dc91e320657fb7..c662d35bb008216c429a9be4a61e213eb65fea80 100644 (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;