jni_gem5Op.c (8547:5979b029bbb4) jni_gem5Op.c (11358:cd41493e8b7e)
1/*
2 * Copyright (c) 2010 ARM Limited
3 * All rights reserved
4 *
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.
13 *
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.
24 *
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.
36 *
37 * Authors: Prakash Ramrakhyani
38 */
39
40#include <stdint.h>
41
42#include "jni_gem5Op.h"
43#include "m5op.h"
44
45/**
46 C library interface for gem5Op JNI
47
48*/
49
50JNIEXPORT void JNICALL
51Java_jni_gem5Op_arm(JNIEnv *env, jobject obj, jlong j_address)
52{
53 arm(j_address);
54}
55
56JNIEXPORT void JNICALL
57Java_jni_gem5Op_quiesce(JNIEnv *env, jobject obj)
58{
59 quiesce();
60}
61
62JNIEXPORT void JNICALL
63Java_jni_gem5Op_quiesceNs(JNIEnv *env, jobject obj, jlong j_ns)
64{
65 quiesceNs(j_ns);
66}
67
68JNIEXPORT void JNICALL
69Java_jni_gem5Op_quiesceCycle(JNIEnv *env, jobject obj, jlong j_cycles)
70{
71 quiesceCycle(j_cycles);
72}
73
74JNIEXPORT jlong JNICALL
75Java_jni_gem5Op_quiesceTime(JNIEnv *env, jobject obj)
76{
77 uint64_t time = quiesceTime();
78 if (time & 0x8000000000000000ULL)
79 printf("Truncated return value from quiesceTime() to 63 bits\n");
80 return (time & 0x7FFFFFFFFFFFFFFFULL);
81}
82
83JNIEXPORT jlong JNICALL
84Java_jni_gem5Op_rpns(JNIEnv *env, jobject obj)
85{
86 uint64_t time = rpns();
87 if (time & 0x8000000000000000ULL)
88 printf("Truncated return value from rpns() to 63 bits\n");
89 return (time & 0x7FFFFFFFFFFFFFFFULL);
90}
91
92JNIEXPORT void JNICALL
93Java_jni_gem5Op_wakeCPU(JNIEnv *env, jobject obj, jlong j_cpuid)
94{
95 wakeCPU(j_cpuid);
96}
97
98JNIEXPORT void JNICALL
99Java_jni_gem5Op_exit(JNIEnv *env, jobject obj, jlong j_ns_delay)
100{
101 m5_exit(j_ns_delay);
102}
103
1/*
2 * Copyright (c) 2010 ARM Limited
3 * All rights reserved
4 *
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.
13 *
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.
24 *
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.
36 *
37 * Authors: Prakash Ramrakhyani
38 */
39
40#include <stdint.h>
41
42#include "jni_gem5Op.h"
43#include "m5op.h"
44
45/**
46 C library interface for gem5Op JNI
47
48*/
49
50JNIEXPORT void JNICALL
51Java_jni_gem5Op_arm(JNIEnv *env, jobject obj, jlong j_address)
52{
53 arm(j_address);
54}
55
56JNIEXPORT void JNICALL
57Java_jni_gem5Op_quiesce(JNIEnv *env, jobject obj)
58{
59 quiesce();
60}
61
62JNIEXPORT void JNICALL
63Java_jni_gem5Op_quiesceNs(JNIEnv *env, jobject obj, jlong j_ns)
64{
65 quiesceNs(j_ns);
66}
67
68JNIEXPORT void JNICALL
69Java_jni_gem5Op_quiesceCycle(JNIEnv *env, jobject obj, jlong j_cycles)
70{
71 quiesceCycle(j_cycles);
72}
73
74JNIEXPORT jlong JNICALL
75Java_jni_gem5Op_quiesceTime(JNIEnv *env, jobject obj)
76{
77 uint64_t time = quiesceTime();
78 if (time & 0x8000000000000000ULL)
79 printf("Truncated return value from quiesceTime() to 63 bits\n");
80 return (time & 0x7FFFFFFFFFFFFFFFULL);
81}
82
83JNIEXPORT jlong JNICALL
84Java_jni_gem5Op_rpns(JNIEnv *env, jobject obj)
85{
86 uint64_t time = rpns();
87 if (time & 0x8000000000000000ULL)
88 printf("Truncated return value from rpns() to 63 bits\n");
89 return (time & 0x7FFFFFFFFFFFFFFFULL);
90}
91
92JNIEXPORT void JNICALL
93Java_jni_gem5Op_wakeCPU(JNIEnv *env, jobject obj, jlong j_cpuid)
94{
95 wakeCPU(j_cpuid);
96}
97
98JNIEXPORT void JNICALL
99Java_jni_gem5Op_exit(JNIEnv *env, jobject obj, jlong j_ns_delay)
100{
101 m5_exit(j_ns_delay);
102}
103
104JNIEXPORT void JNICALL
105Java_jni_gem5Op_fail(JNIEnv *env, jobject obj, jlong j_ns_delay, jlong j_code)
106{
107 m5_fail(j_ns_delay, j_code);
108}
109
104JNIEXPORT jlong JNICALL
110JNIEXPORT jlong JNICALL
105Java_jni_gem5Op_initparam(JNIEnv *env, jobject obj)
111Java_jni_gem5Op_initparam(JNIEnv *env, jobject obj, jlong j_key_str1,
112 jlong j_key_str2)
106{
113{
107 uint64_t param = m5_initparam();
114 uint64_t param = m5_initparam(j_key_str1, j_key_str2);
108 if (param & 0x8000000000000000ULL)
109 printf("Truncated return value from m_initparam() to 63 bits\n");
110 return (param & 0x7FFFFFFFFFFFFFFFULL);
111}
112
113JNIEXPORT void JNICALL
114Java_jni_gem5Op_checkpoint(JNIEnv *env, jobject obj,
115 jlong j_ns_delay, jlong j_ns_period)
116{
117 m5_checkpoint(j_ns_delay, j_ns_period);
118}
119
120JNIEXPORT void JNICALL
121Java_jni_gem5Op_reset_1stats(JNIEnv *env, jobject obj,
122 jlong j_ns_delay, jlong j_ns_period)
123{
124 m5_reset_stats(j_ns_delay, j_ns_period);
125}
126
127JNIEXPORT void JNICALL
128Java_jni_gem5Op_dump_1stats(JNIEnv *env, jobject obj,
129 jlong j_ns_delay, jlong j_ns_period)
130{
131 m5_dump_stats(j_ns_delay, j_ns_period);
132}
133
134JNIEXPORT void JNICALL
135Java_jni_gem5Op_dumpreset_1stats(JNIEnv *env, jobject obj,
136 jlong j_ns_delay, jlong j_ns_period)
137{
138 m5_dumpreset_stats(j_ns_delay, j_ns_period);
139}
140
141JNIEXPORT void JNICALL
142Java_jni_gem5Op_debugbreak(JNIEnv *env, jobject obj)
143{
144 m5_debugbreak();
145}
146
147JNIEXPORT void JNICALL
148Java_jni_gem5Op_switchcpu (JNIEnv *env, jobject obj)
149{
150 m5_switchcpu();
151}
152
153JNIEXPORT void JNICALL
154Java_jni_gem5Op_panic(JNIEnv *env, jobject obj)
155{
156 m5_panic();
157}
158
159JNIEXPORT void JNICALL
160Java_jni_gem5Op_work_1begin(JNIEnv *env, jobject obj,
161 jlong j_workid, jlong j_threadid)
162{
163 m5_work_begin(j_workid, j_threadid);
164}
165
166JNIEXPORT void JNICALL
167Java_jni_gem5Op_work_1end(JNIEnv *env, jobject obj,
168 jlong j_workid, jlong j_threadid)
169{
170 m5_work_end(j_workid, j_threadid);
171}
172
115 if (param & 0x8000000000000000ULL)
116 printf("Truncated return value from m_initparam() to 63 bits\n");
117 return (param & 0x7FFFFFFFFFFFFFFFULL);
118}
119
120JNIEXPORT void JNICALL
121Java_jni_gem5Op_checkpoint(JNIEnv *env, jobject obj,
122 jlong j_ns_delay, jlong j_ns_period)
123{
124 m5_checkpoint(j_ns_delay, j_ns_period);
125}
126
127JNIEXPORT void JNICALL
128Java_jni_gem5Op_reset_1stats(JNIEnv *env, jobject obj,
129 jlong j_ns_delay, jlong j_ns_period)
130{
131 m5_reset_stats(j_ns_delay, j_ns_period);
132}
133
134JNIEXPORT void JNICALL
135Java_jni_gem5Op_dump_1stats(JNIEnv *env, jobject obj,
136 jlong j_ns_delay, jlong j_ns_period)
137{
138 m5_dump_stats(j_ns_delay, j_ns_period);
139}
140
141JNIEXPORT void JNICALL
142Java_jni_gem5Op_dumpreset_1stats(JNIEnv *env, jobject obj,
143 jlong j_ns_delay, jlong j_ns_period)
144{
145 m5_dumpreset_stats(j_ns_delay, j_ns_period);
146}
147
148JNIEXPORT void JNICALL
149Java_jni_gem5Op_debugbreak(JNIEnv *env, jobject obj)
150{
151 m5_debugbreak();
152}
153
154JNIEXPORT void JNICALL
155Java_jni_gem5Op_switchcpu (JNIEnv *env, jobject obj)
156{
157 m5_switchcpu();
158}
159
160JNIEXPORT void JNICALL
161Java_jni_gem5Op_panic(JNIEnv *env, jobject obj)
162{
163 m5_panic();
164}
165
166JNIEXPORT void JNICALL
167Java_jni_gem5Op_work_1begin(JNIEnv *env, jobject obj,
168 jlong j_workid, jlong j_threadid)
169{
170 m5_work_begin(j_workid, j_threadid);
171}
172
173JNIEXPORT void JNICALL
174Java_jni_gem5Op_work_1end(JNIEnv *env, jobject obj,
175 jlong j_workid, jlong j_threadid)
176{
177 m5_work_end(j_workid, j_threadid);
178}
179