util: Add missing functions to the java wrapper for m5 ops.
authorGabe Black <gabeblack@google.com>
Wed, 25 Mar 2020 22:50:07 +0000 (15:50 -0700)
committerGabe Black <gabeblack@google.com>
Mon, 27 Apr 2020 21:03:28 +0000 (21:03 +0000)
Change-Id: I9bdef3cb78cc01b0743ea38eec6f6d28cd2f6765
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/27225
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
util/m5/src/jni/gem5Op.java
util/m5/src/jni_gem5Op.c

index 52c36fff6b18b5142c4273bbd59f067aebcfbeb2..11403bfbbda32b7e3f4d8ecd89d329b6ea94b1ee 100644 (file)
@@ -57,8 +57,14 @@ public class gem5Op {
     public native void reset_stats(long ns_delay, long ns_period);
     public native void dump_stats(long ns_delay, long ns_period);
     public native void dump_reset_stats(long ns_delay, long ns_period);
+    public native long read_file(byte[] buffer, long len, long offset);
+    public native long write_file(byte[] buffer, long len, long offset,
+                                  String filename);
     public native void debug_break();
     public native void switch_cpu();
+    public native void dist_toggle_sync();
+    public native void add_symbol(long addr, String symbol);
+    public native void load_symbol();
     public native void panic();
     public native void work_begin(long workid, long threadid);
     public native void work_end(long workid, long threadid);
index 6c3f69657ec79eb7ca15e649dea59c3418dc2f6e..83a9512e22fe516430a87bc05469f325ceef0225 100644 (file)
@@ -142,6 +142,33 @@ Java_jni_gem5Op_dump_1reset_1stats(JNIEnv *env, jobject obj,
     m5_dump_reset_stats(j_ns_delay, j_ns_period);
 }
 
+JNIEXPORT jlong JNICALL
+Java_jni_gem5Op_read_1file(JNIEnv *env, jobject obj,
+                           jbyteArray j_buffer, jlong j_len, jlong j_offset)
+{
+    jbyte *buffer = (*env)->GetByteArrayElements(env, j_buffer, 0);
+
+    uint64_t result = m5_read_file(buffer, j_len, j_offset);
+
+    (*env)->ReleaseByteArrayElements(env, j_buffer, buffer, JNI_ABORT);
+    return (result & 0x7FFFFFFFFFFFFFFFULL);
+}
+
+JNIEXPORT jlong JNICALL
+Java_jni_gem5Op_write_1file(JNIEnv *env, jobject obj,
+                            jbyteArray j_buffer, jlong j_len, jlong j_offset,
+                            jstring j_filename)
+{
+    jbyte *buffer = (*env)->GetByteArrayElements(env, j_buffer, 0);
+    const char *filename = (*env)->GetStringUTFChars(env, j_filename, NULL);
+
+    uint64_t result = m5_write_file(buffer, j_len, j_offset, filename);
+
+    (*env)->ReleaseStringUTFChars(env, j_filename, filename);
+    (*env)->ReleaseByteArrayElements(env, j_buffer, buffer, JNI_ABORT);
+    return (result & 0x7FFFFFFFFFFFFFFFULL);
+}
+
 JNIEXPORT void JNICALL
 Java_jni_gem5Op_debug_1break(JNIEnv *env, jobject obj)
 {
@@ -154,6 +181,29 @@ Java_jni_gem5Op_switch_1cpu (JNIEnv *env, jobject obj)
     m5_switch_cpu();
 }
 
+JNIEXPORT void JNICALL
+Java_jni_gem5Op_dist_1toggle_1sync(JNIEnv *env, jobject obj)
+{
+    m5_dist_toggle_sync();
+}
+
+JNIEXPORT void JNICALL
+Java_jni_gem5Op_add_symbol(JNIEnv *env, jobject obj,
+        jlong j_addr, jstring j_symbol)
+{
+    const char *symbol = (*env)->GetStringUTFChars(env, j_symbol, NULL);
+
+    m5_add_symbol(j_addr, symbol);
+
+    (*env)->ReleaseStringUTFChars(env, j_symbol, symbol);
+}
+
+JNIEXPORT void JNICALL
+Java_jni_gem5Op_load_1symbol(JNIEnv *env, jobject obj)
+{
+    m5_load_symbol();
+}
+
 JNIEXPORT void JNICALL
 Java_jni_gem5Op_panic(JNIEnv *env, jobject obj)
 {