Skip to content

Commit 9d96ae6

Browse files
committed
rvvm: Update librvvm bindings
1 parent 7d9da31 commit 9d96ae6

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

src/main/java/lekkit/rvvm/RVVMMachine.java

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,23 @@
1111
public class RVVMMachine {
1212
private long machine = 0;
1313

14-
public static final int RVVM_OPT_NONE = 0;
15-
public static final int RVVM_OPT_JIT = 1; // Enable JIT
16-
public static final int RVVM_OPT_JIT_CACHE = 2; // Amount of per-core JIT cache (In bytes)
17-
public static final int RVVM_OPT_JIT_HARVARD = 3; // No dirty code tracking, explicit ifence, slower
18-
public static final int RVVM_OPT_VERBOSITY = 4; // Verbosity level of internal logic
19-
public static final int RVVM_OPT_HW_IMITATE = 5; // Imitate traits or identity of physical hardware
20-
public static final int RVVM_OPT_MAX_CPU_CENT = 6; // Max CPU load % per guest/host CPUs
21-
public static final int RVVM_OPT_RESET_PC = 7; // Physical jump address at reset, defaults to mem_base
22-
public static final int RVVM_OPT_DTB_ADDR = 8; // Pass DTB address if non-zero, omits FDT generation
23-
public static final int RVVM_MAX_OPTS = 9;
24-
25-
public static final int RVVM_OPT_MEM_BASE = 0x80000001; // Physical RAM base address
26-
public static final int RVVM_OPT_MEM_SIZE = 0x80000002; // Physical RAM size
27-
public static final int RVVM_OPT_HART_COUNT = 0x80000003; // Amount of harts
28-
29-
public RVVMMachine(long mem_mb, int smp, boolean rv64) {
14+
public static final int RVVM_OPT_NONE = 0x0;
15+
public static final int RVVM_OPT_RESET_PC = 0x1; //!< Physical jump address at reset, defaults to 0x80000000
16+
public static final int RVVM_OPT_DTB_ADDR = 0x2; //!< Pass DTB address if non-zero, omits FDT generation
17+
public static final int RVVM_OPT_TIME_FREQ = 0x3; //!< Machine timer frequency, 10Mhz by default
18+
public static final int RVVM_OPT_HW_IMITATE = 0x4; //!< Imitate traits or identity of physical hardware
19+
public static final int RVVM_OPT_MAX_CPU_CENT = 0x5; //!< Max CPU load % per guest/host CPUs
20+
public static final int RVVM_OPT_JIT = 0x6; //!< Enable JIT
21+
public static final int RVVM_OPT_JIT_CACHE = 0x7; //!< Amount of per-core JIT cache (In bytes)
22+
public static final int RVVM_OPT_JIT_HARVARD = 0x8; //!< No dirty code tracking, explicit ifence, slower
23+
24+
public static final int RVVM_OPT_MEM_BASE = 0x80000001; //!< Physical RAM base address, defaults to 0x80000000
25+
public static final int RVVM_OPT_MEM_SIZE = 0x80000002; //!< Physical RAM size
26+
public static final int RVVM_OPT_HART_COUNT = 0x80000003; //!< Amount of harts
27+
28+
public RVVMMachine(long mem_mb, int smp, String isa) {
3029
if (RVVMNative.isLoaded()) {
31-
this.machine = RVVMNative.create_machine(RVVMNative.DEFAULT_MEMBASE, mem_mb << 20, smp, rv64);
30+
this.machine = RVVMNative.create_machine(mem_mb << 20, smp, isa);
3231
}
3332

3433
if (isValid()) {

src/main/java/lekkit/rvvm/RVVMNative.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ public class RVVMNative {
1515
public static boolean loaded = false;
1616

1717
private static void checkABI() {
18-
int abi = get_abi_version();
19-
if (abi == 7) {
18+
if (check_abi(8)) {
2019
loaded = true;
2120
} else {
22-
System.out.println("ERROR: Invalid librvvm ABI version: " + Integer.toString(abi));
21+
System.out.println("ERROR: Invalid librvvm ABI version! Please update your JNI bindings!");
2322
}
2423
}
2524

@@ -50,10 +49,10 @@ public static boolean isLoaded() {
5049

5150
public static final long DEFAULT_MEMBASE = 0x80000000L;
5251

53-
public static native int get_abi_version();
52+
public static native boolean check_abi(int abi);
5453

5554
// Common RVVM API functions
56-
public static native long create_machine(long mem_base, long mem_size, int smp, boolean rv64);
55+
public static native long create_machine(long mem_size, int smp, String isa);
5756
public static native ByteBuffer get_dma_buf(long machine, long addr, long size);
5857
public static native long get_plic(long machine);
5958
public static native void set_plic(long machine, long plic);

0 commit comments

Comments
 (0)