cpu: Apply the ARM TLB rework to the O3 checker CPU.
[gem5.git] / src / mem / port_proxy.cc
index f13bcbe447fab809675865e2e5b9671d039e7e5c..b630d310a3830acfa3b8c9690f802924fcc8bed8 100644 (file)
@@ -43,7 +43,7 @@
 
 void
 PortProxy::readBlobPhys(Addr addr, Request::Flags flags,
-                        uint8_t *p, int size) const
+                        void *p, int size) const
 {
     for (ChunkGenerator gen(addr, size, _cacheLineSize); !gen.done();
          gen.next()) {
@@ -52,15 +52,15 @@ PortProxy::readBlobPhys(Addr addr, Request::Flags flags,
             gen.addr(), gen.size(), flags, Request::funcMasterId);
 
         Packet pkt(req, MemCmd::ReadReq);
-        pkt.dataStatic(p);
-        _port.sendFunctional(&pkt);
-        p += gen.size();
+        pkt.dataStatic(static_cast<uint8_t *>(p));
+        sendFunctional(&pkt);
+        p = static_cast<uint8_t *>(p) + gen.size();
     }
 }
 
 void
 PortProxy::writeBlobPhys(Addr addr, Request::Flags flags,
-                         const uint8_t *p, int size) const
+                         const void *p, int size) const
 {
     for (ChunkGenerator gen(addr, size, _cacheLineSize); !gen.done();
          gen.next()) {
@@ -69,9 +69,9 @@ PortProxy::writeBlobPhys(Addr addr, Request::Flags flags,
             gen.addr(), gen.size(), flags, Request::funcMasterId);
 
         Packet pkt(req, MemCmd::WriteReq);
-        pkt.dataStaticConst(p);
-        _port.sendFunctional(&pkt);
-        p += gen.size();
+        pkt.dataStaticConst(static_cast<const uint8_t *>(p));
+        sendFunctional(&pkt);
+        p = static_cast<const uint8_t *>(p) + gen.size();
     }
 }
 
@@ -87,3 +87,41 @@ PortProxy::memsetBlobPhys(Addr addr, Request::Flags flags,
 
     delete [] buf;
 }
+
+bool
+PortProxy::tryWriteString(Addr addr, const char *str) const
+{
+    do {
+        if (!tryWriteBlob(addr++, str, 1))
+            return false;
+    } while (*str++);
+    return true;
+}
+
+bool
+PortProxy::tryReadString(std::string &str, Addr addr) const
+{
+    while (true) {
+        uint8_t c;
+        if (!tryReadBlob(addr++, &c, 1))
+            return false;
+        if (!c)
+            return true;
+        str += c;
+    }
+}
+
+bool
+PortProxy::tryReadString(char *str, Addr addr, size_t maxlen) const
+{
+    assert(maxlen);
+    while (maxlen--) {
+        if (!tryReadBlob(addr++, str, 1))
+            return false;
+        if (!*str++)
+            return true;
+    }
+    // We ran out of room, so back up and add a terminator.
+    *--str = '\0';
+    return true;
+}