Yu-hsin Wang has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/45268 )

Change subject: fastmodel: add iris readMem and writeMem function
......................................................................

fastmodel: add iris readMem and writeMem function

Iris memory API allows us to access the memory inside the core, for
example the tightly coupled memory (TCM). If we access a memory address
which is not in the CPU, it also fire a request to memory system.

Change-Id: I5925214534a10e3a55b780c3d4ed06e7559aafe0
---
M src/arch/arm/fastmodel/iris/thread_context.cc
M src/arch/arm/fastmodel/iris/thread_context.hh
2 files changed, 23 insertions(+), 0 deletions(-)



diff --git a/src/arch/arm/fastmodel/iris/thread_context.cc b/src/arch/arm/fastmodel/iris/thread_context.cc
index 0cf1899..e6168eb 100644
--- a/src/arch/arm/fastmodel/iris/thread_context.cc
+++ b/src/arch/arm/fastmodel/iris/thread_context.cc
@@ -40,6 +40,7 @@
 #include "arch/arm/fastmodel/iris/thread_context.hh"

 #include <utility>
+#include <vector>

 #include "arch/arm/system.hh"
 #include "arch/arm/utility.hh"
@@ -416,6 +417,26 @@
     return true;
 }

+void
+ThreadContext::readMem(Addr addr, unsigned char *p, size_t size)
+{
+    iris::r0master::MemoryReadResult r;
+    auto err = call().memory_read(_instId, r, 0, addr, 1, size);
+    panic_if(err != iris::r0master::E_ok, "readMem failed.");
+    memcpy(p, r.data.data(), size);
+}
+
+void
+ThreadContext::writeMem(Addr addr, unsigned char *p, size_t size)
+{
+    std::vector<uint64_t> data(size);
+    for (int i = 0; i < size; ++i)
+        data[i] = p[i];
+    iris::MemoryWriteResult r;
+    auto err = call().memory_write(_instId, r, 0, addr, 1, size, data);
+    panic_if(err != iris::r0master::E_ok, "writeMem failed.");
+}
+
 bool
 ThreadContext::translateAddress(Addr &paddr, iris::MemorySpaceId p_space,
                                 Addr vaddr, iris::MemorySpaceId v_space)
diff --git a/src/arch/arm/fastmodel/iris/thread_context.hh b/src/arch/arm/fastmodel/iris/thread_context.hh
index 019baca..1d4fcf7 100644
--- a/src/arch/arm/fastmodel/iris/thread_context.hh
+++ b/src/arch/arm/fastmodel/iris/thread_context.hh
@@ -162,6 +162,8 @@
     iris::IrisCppAdapter &call() const { return client.irisCall(); }
iris::IrisCppAdapter &noThrow() const { return client.irisCallNoThrow(); }

+    void readMem(Addr addr, unsigned char *p, size_t size);
+    void writeMem(Addr addr, unsigned char *p, size_t size);
     bool translateAddress(Addr &paddr, iris::MemorySpaceId p_space,
                           Addr vaddr, iris::MemorySpaceId v_space);


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/45268
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I5925214534a10e3a55b780c3d4ed06e7559aafe0
Gerrit-Change-Number: 45268
Gerrit-PatchSet: 1
Gerrit-Owner: Yu-hsin Wang <yuhsi...@google.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to