ruby: MI protocol: add a missing transition
[gem5.git] / src / mem / port_proxy.hh
index 31ad4c1cd599f1a7c2e739937c3f1331f1f6af98..4600cd40713e53b17383572f5f497a3f62810da7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011 ARM Limited
+ * Copyright (c) 2011-2012 ARM Limited
  * All rights reserved
  *
  * The license below extends only to copyright in the software and shall
  * @file
  * PortProxy Object Declaration.
  *
- * Port proxies are used when non structural entities need access to
- * the memory system. Proxy objects replace the previous
- * FunctionalPort, TranslatingPort and VirtualPort objects, which
- * provided the same functionality as the proxies, but were instances
- * of ports not corresponding to real structural ports of the
- * simulated system. Via the port proxies all the accesses go through
- * an actual port and thus are transparent to a potentially
+ * Port proxies are used when non-structural entities need access to
+ * the memory system (or structural entities that want to peak into
+ * the memory system without making a real memory access).
+ *
+ * Proxy objects replace the previous FunctionalPort, TranslatingPort
+ * and VirtualPort objects, which provided the same functionality as
+ * the proxies, but were instances of ports not corresponding to real
+ * structural ports of the simulated system. Via the port proxies all
+ * the accesses go through an actual port (either the system port,
+ * e.g. for processes or initialisation, or a the data port of the
+ * CPU, e.g. for threads) and thus are transparent to a potentially
  * distributed memory and automatically adhere to the memory map of
  * the system.
  */
     #include "arch/isa_traits.hh"
 #endif
 
-#include "base/types.hh"
 #include "mem/port.hh"
 #include "sim/byteswap.hh"
 
 /**
- * This object is a proxy for a structural port,
- * to be used for debug accesses.
+ * This object is a proxy for a structural port, to be used for debug
+ * accesses.
  *
  * This proxy object is used when non structural entities
  * (e.g. thread contexts, object file loaders) need access to the
  */
 class PortProxy
 {
-  protected:
-    Port &_port;
+  private:
+
+    /** The actual physical port used by this proxy. */
+    MasterPort &_port;
+
+    void blobHelper(Addr addr, uint8_t *p, int size, MemCmd cmd) const;
 
   public:
-    PortProxy(Port &port) : _port(port) { }
+    PortProxy(MasterPort &port) : _port(port) { }
     virtual ~PortProxy() { }
 
-  public:
     /**
      * Read size bytes memory at address and store in p.
      */
-    virtual void readBlob(Addr address, uint8_t* p, int size)
-    { _port.readBlob(address, p, size); }
+    virtual void readBlob(Addr addr, uint8_t* p, int size) const
+    { blobHelper(addr, p, size, MemCmd::ReadReq); }
 
     /**
      * Write size bytes from p to address.
      */
-    virtual void writeBlob(Addr address, uint8_t* p, int size)
-    { _port.writeBlob(address, p, size); }
+    virtual void writeBlob(Addr addr, uint8_t* p, int size) const
+    { blobHelper(addr, p, size, MemCmd::WriteReq); }
 
     /**
      * Fill size bytes starting at addr with byte value val.
      */
-    virtual void memsetBlob(Addr address, uint8_t  v, int size)
-    { _port.memsetBlob(address, v, size); }
+    virtual void memsetBlob(Addr addr, uint8_t v, int size) const;
 
     /**
      * Read sizeof(T) bytes from address and return as object T.
      */
     template <typename T>
-    T read(Addr address);
+    T read(Addr address) const;
 
     /**
      * Write object T to address. Writes sizeof(T) bytes.
      */
     template <typename T>
-    void write(Addr address, T data);
+    void write(Addr address, T data) const;
 
 #if THE_ISA != NO_ISA
     /**
@@ -124,21 +129,21 @@ class PortProxy
      * Performs Guest to Host endianness transform.
      */
     template <typename T>
-    T readGtoH(Addr address);
+    T readGtoH(Addr address) const;
 
     /**
      * Write object T to address. Writes sizeof(T) bytes.
      * Performs Host to Guest endianness transform.
      */
     template <typename T>
-    void writeHtoG(Addr address, T data);
+    void writeHtoG(Addr address, T data) const;
 #endif
 };
 
 
 template <typename T>
 T
-PortProxy::read(Addr address)
+PortProxy::read(Addr address) const
 {
     T data;
     readBlob(address, (uint8_t*)&data, sizeof(T));
@@ -147,7 +152,7 @@ PortProxy::read(Addr address)
 
 template <typename T>
 void
-PortProxy::write(Addr address, T data)
+PortProxy::write(Addr address, T data) const
 {
     writeBlob(address, (uint8_t*)&data, sizeof(T));
 }
@@ -155,7 +160,7 @@ PortProxy::write(Addr address, T data)
 #if THE_ISA != NO_ISA
 template <typename T>
 T
-PortProxy::readGtoH(Addr address)
+PortProxy::readGtoH(Addr address) const
 {
     T data;
     readBlob(address, (uint8_t*)&data, sizeof(T));
@@ -164,7 +169,7 @@ PortProxy::readGtoH(Addr address)
 
 template <typename T>
 void
-PortProxy::writeHtoG(Addr address, T data)
+PortProxy::writeHtoG(Addr address, T data) const
 {
     data = TheISA::htog(data);
     writeBlob(address, (uint8_t*)&data, sizeof(T));