2 * Copyright (c) 2010 ARM Limited
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions are
16 * met: redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer;
18 * redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution;
21 * neither the name of the copyright holders nor the names of its
22 * contributors may be used to endorse or promote products derived from
23 * this software without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 * Authors: Prakash Ramrakhyani
42 #include "jni_gem5Op.h"
46 C library interface for gem5Op JNI
50 JNIEXPORT
void JNICALL
51 Java_jni_gem5Op_arm(JNIEnv
*env
, jobject obj
, jlong j_address
)
56 JNIEXPORT
void JNICALL
57 Java_jni_gem5Op_quiesce(JNIEnv
*env
, jobject obj
)
62 JNIEXPORT
void JNICALL
63 Java_jni_gem5Op_quiesceNs(JNIEnv
*env
, jobject obj
, jlong j_ns
)
68 JNIEXPORT
void JNICALL
69 Java_jni_gem5Op_quiesceCycle(JNIEnv
*env
, jobject obj
, jlong j_cycles
)
71 quiesceCycle(j_cycles
);
74 JNIEXPORT jlong JNICALL
75 Java_jni_gem5Op_quiesceTime(JNIEnv
*env
, jobject obj
)
77 uint64_t time
= quiesceTime();
78 if (time
& 0x8000000000000000ULL
)
79 printf("Truncated return value from quiesceTime() to 63 bits\n");
80 return (time
& 0x7FFFFFFFFFFFFFFFULL
);
83 JNIEXPORT jlong JNICALL
84 Java_jni_gem5Op_rpns(JNIEnv
*env
, jobject obj
)
86 uint64_t time
= rpns();
87 if (time
& 0x8000000000000000ULL
)
88 printf("Truncated return value from rpns() to 63 bits\n");
89 return (time
& 0x7FFFFFFFFFFFFFFFULL
);
92 JNIEXPORT
void JNICALL
93 Java_jni_gem5Op_wakeCPU(JNIEnv
*env
, jobject obj
, jlong j_cpuid
)
98 JNIEXPORT
void JNICALL
99 Java_jni_gem5Op_exit(JNIEnv
*env
, jobject obj
, jlong j_ns_delay
)
104 JNIEXPORT
void JNICALL
105 Java_jni_gem5Op_fail(JNIEnv
*env
, jobject obj
, jlong j_ns_delay
, jlong j_code
)
107 m5_fail(j_ns_delay
, j_code
);
110 JNIEXPORT jlong JNICALL
111 Java_jni_gem5Op_initparam(JNIEnv
*env
, jobject obj
, jlong j_key_str1
,
114 uint64_t param
= m5_initparam(j_key_str1
, j_key_str2
);
115 if (param
& 0x8000000000000000ULL
)
116 printf("Truncated return value from m_initparam() to 63 bits\n");
117 return (param
& 0x7FFFFFFFFFFFFFFFULL
);
120 JNIEXPORT
void JNICALL
121 Java_jni_gem5Op_checkpoint(JNIEnv
*env
, jobject obj
,
122 jlong j_ns_delay
, jlong j_ns_period
)
124 m5_checkpoint(j_ns_delay
, j_ns_period
);
127 JNIEXPORT
void JNICALL
128 Java_jni_gem5Op_reset_1stats(JNIEnv
*env
, jobject obj
,
129 jlong j_ns_delay
, jlong j_ns_period
)
131 m5_reset_stats(j_ns_delay
, j_ns_period
);
134 JNIEXPORT
void JNICALL
135 Java_jni_gem5Op_dump_1stats(JNIEnv
*env
, jobject obj
,
136 jlong j_ns_delay
, jlong j_ns_period
)
138 m5_dump_stats(j_ns_delay
, j_ns_period
);
141 JNIEXPORT
void JNICALL
142 Java_jni_gem5Op_dumpreset_1stats(JNIEnv
*env
, jobject obj
,
143 jlong j_ns_delay
, jlong j_ns_period
)
145 m5_dumpreset_stats(j_ns_delay
, j_ns_period
);
148 JNIEXPORT
void JNICALL
149 Java_jni_gem5Op_debugbreak(JNIEnv
*env
, jobject obj
)
154 JNIEXPORT
void JNICALL
155 Java_jni_gem5Op_switchcpu (JNIEnv
*env
, jobject obj
)
160 JNIEXPORT
void JNICALL
161 Java_jni_gem5Op_panic(JNIEnv
*env
, jobject obj
)
166 JNIEXPORT
void JNICALL
167 Java_jni_gem5Op_work_1begin(JNIEnv
*env
, jobject obj
,
168 jlong j_workid
, jlong j_threadid
)
170 m5_work_begin(j_workid
, j_threadid
);
173 JNIEXPORT
void JNICALL
174 Java_jni_gem5Op_work_1end(JNIEnv
*env
, jobject obj
,
175 jlong j_workid
, jlong j_threadid
)
177 m5_work_end(j_workid
, j_threadid
);