Gabe Black has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/28184 )

Change subject: util: Expose addr config mechanisms in the gem5 op java wrapper.
......................................................................

util: Expose addr config mechanisms in the gem5 op java wrapper.

These allow you to set the target physical address, and map or unmap the
region of physical memory. This is not automatic for two reasons. First,
the address needs to be configured before the mapping is done, and
there's no way to ensure that ordering when everything is handled
automatically. Second, if the user isn't going to use the address based
mechanism, then the mapping and access to /dev/mem isn't necessary and
may prevent using the other call types.

Change-Id: I0f9c32d6bfa402ba59ea1bf5672fb7f11003568d
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/28184
Reviewed-by: Gabe Black <gabe.bl...@gmail.com>
Maintainer: Bobby R. Bruce <bbr...@ucdavis.edu>
Tested-by: kokoro <noreply+kok...@google.com>
---
M util/m5/README.md
M util/m5/src/java/gem5/Ops.java
M util/m5/src/java/gem5/ops.cc
3 files changed, 36 insertions(+), 0 deletions(-)

Approvals:
  Gabe Black: Looks good to me, approved
  Bobby R. Bruce: Looks good to me, approved
  kokoro: Regressions pass



diff --git a/util/m5/README.md b/util/m5/README.md
index b9ccbff..cbdff1d 100644
--- a/util/m5/README.md
+++ b/util/m5/README.md
@@ -362,6 +362,19 @@
 long sum = gem5_ops.sum(1, 2, 3, 4, 5, 6);
 ```

+To configure the address based trigger mechanism, you can use these static
+methods.
+
+void setAddr(long addr);
+Set the address for the "magic" address region.
+
+void mapMem();
+Map the "magic" physical address region into the process' address space, likely
+by mmapping the "/dev/mem" device file.
+
+void unmapMem();
+Unmap the "magic" physical address region that was previously mapped.
+


 # lua module
diff --git a/util/m5/src/java/gem5/Ops.java b/util/m5/src/java/gem5/Ops.java
index f6ab178..ab25419 100644
--- a/util/m5/src/java/gem5/Ops.java
+++ b/util/m5/src/java/gem5/Ops.java
@@ -53,6 +53,10 @@
     private static Map<String, Ops> _callTypes;
     public static final Map<String, Ops> callTypes;

+    public static native void setAddr(long addr);
+    public static native void mapMem();
+    public static native void unmapMem();
+
     static {
         try {
             File temp_lib = File.createTempFile("gem5Ops", ".so");
diff --git a/util/m5/src/java/gem5/ops.cc b/util/m5/src/java/gem5/ops.cc
index c1f36e4..da21840 100644
--- a/util/m5/src/java/gem5/ops.cc
+++ b/util/m5/src/java/gem5/ops.cc
@@ -44,6 +44,7 @@
 #include "call_type/semi_dt.hh"
 #include "gem5/m5ops.h"
 #include "java/gem5_Ops.h"
+#include "m5_mmap.h"

 #define _stringify(x) #x
 #define stringify(x) _stringify(x)
@@ -108,6 +109,24 @@
     env->DeleteLocalRef(map);
 }

+JNIEXPORT void JNICALL
+Java_gem5_Ops_setAddr(JNIEnv *env, jclass clazz, jlong addr)
+{
+    m5op_addr = addr;
+}
+
+JNIEXPORT void JNICALL
+Java_gem5_Ops_mapMem(JNIEnv *env, jclass clazz)
+{
+    map_m5_mem();
+}
+
+JNIEXPORT void JNICALL
+Java_gem5_Ops_unmapMem(JNIEnv *env, jclass clazz)
+{
+    unmap_m5_mem();
+}
+
 static DispatchTable *
 getDispatchTable(JNIEnv *env, jobject obj)
 {

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/28184
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: I0f9c32d6bfa402ba59ea1bf5672fb7f11003568d
Gerrit-Change-Number: 28184
Gerrit-PatchSet: 31
Gerrit-Owner: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Bobby R. Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Earl Ou <shunhsin...@google.com>
Gerrit-Reviewer: Gabe Black <gabe.bl...@gmail.com>
Gerrit-Reviewer: Giacomo Travaglini <giacomo.travagl...@arm.com>
Gerrit-Reviewer: Jason Lowe-Power <power...@gmail.com>
Gerrit-Reviewer: Pouya Fotouhi <pfoto...@ucdavis.edu>
Gerrit-Reviewer: Yu-hsin Wang <yuhsi...@google.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
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