Skip to content

Commit 3a10757

Browse files
committed
bump rvm version and modify ffi
1 parent b7dc9b0 commit 3a10757

File tree

3 files changed

+21
-33
lines changed

3 files changed

+21
-33
lines changed

kernel/Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

kernel/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ virtio-drivers = { git = "https://github.com/rcore-riscv-hypervisor-dev/virtio-d
7777
volatile = "0.2"
7878
woke = "0.0.2"
7979
xmas-elf = "0.7"
80-
rvm = { git = "https://github.com/rcore-riscv-hypervisor-dev/RVM", rev = "5ccac8b", optional = true }
80+
rvm = { git = "https://github.com/rcore-riscv-hypervisor-dev/RVM", rev = "2867e78", optional = true }
8181

8282
[target.'cfg(target_arch = "x86_64")'.dependencies]
8383
apic = { git = "https://github.com/rcore-os/apic-rs", rev = "fb86bd7" }

kernel/src/rvm/mod.rs

+18-30
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,20 @@ fn into_fs_error(e: RvmError) -> FsError {
2828
}
2929

3030
mod rvm_extern_fn {
31-
use crate::memory::{alloc_frame, dealloc_frame, phys_to_virt};
32-
#[rvm::extern_fn(alloc_frame)]
33-
fn rvm_alloc_frame() -> Option<usize> {
34-
alloc_frame()
31+
use crate::memory::{alloc_frame_contiguous, dealloc_frame, phys_to_virt};
32+
use rvm::PAGE_SIZE;
33+
#[rvm::extern_fn(alloc_frames)]
34+
fn rvm_alloc_frames(n: usize, align_log2: usize) -> Option<usize> {
35+
alloc_frame_contiguous(n, align_log2)
3536
}
3637

37-
#[rvm::extern_fn(dealloc_frame)]
38-
fn rvm_dealloc_frame(paddr: usize) {
39-
dealloc_frame(paddr)
40-
}
41-
#[rvm::extern_fn(alloc_frame_x4)]
42-
fn rvm_alloc_frame_x4() -> Option<usize> {
43-
use crate::memory::alloc_frame_contiguous;
44-
alloc_frame_contiguous(4, 2)
45-
}
46-
47-
#[rvm::extern_fn(dealloc_frame_x4)]
48-
fn rvm_dealloc_frame_x4(paddr: usize) {
49-
dealloc_frame(paddr)
38+
#[rvm::extern_fn(dealloc_frames)]
39+
fn rvm_dealloc_frames(paddr: usize, n: usize, _align_log2: usize) {
40+
for i in 0..n {
41+
dealloc_frame(paddr + i * PAGE_SIZE)
42+
}
43+
//use crate::memory::dealloc_frame_contiguous;
44+
//dealloc_frame_contiguous(paddr, n, align_log2)
5045
}
5146

5247
#[rvm::extern_fn(phys_to_virt)]
@@ -73,20 +68,13 @@ mod rvm_extern_fn {
7368
crate::arch::interrupt::trap_handler_no_frame(sepc);
7469
}
7570

76-
#[cfg(all(
77-
any(target_arch = "riscv64", target_arch = "riscv32"),
78-
feature = "hypervisor"
79-
))]
80-
#[rvm::extern_fn(riscv_check_hypervisor_extension)]
81-
fn rvm_riscv_check_hypervisor_extension() -> bool {
82-
return true;
83-
}
84-
#[cfg(all(
85-
any(target_arch = "riscv64", target_arch = "riscv32"),
86-
not(feature = "hypervisor")
87-
))]
71+
#[cfg(any(target_arch = "riscv64", target_arch = "riscv32"))]
8872
#[rvm::extern_fn(riscv_check_hypervisor_extension)]
8973
fn rvm_riscv_check_hypervisor_extension() -> bool {
90-
return false;
74+
if cfg!(feature = "hypervisor") {
75+
true
76+
} else {
77+
false
78+
}
9179
}
9280
}

0 commit comments

Comments
 (0)