Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,15 @@ range-alloc-arceos = "0.1.4-pre.1"
[target.'cfg(target_arch = "aarch64")'.dependencies]
arm_vgic = { version = "0.1", features = ["vgicv3"] }

[target.'cfg(target_arch = "riscv64")'.dependencies]
riscv_vplic = { git = "https://github.com/arceos-hypervisor/riscv_vplic.git", rev = "8bc5213" }

[dev-dependencies]
axdevice_base = "0.1"
axaddrspace = "0.1"
memory_addr = "0.4"
axerrno = "0.1"
axvmconfig = "0.1"

[patch.crates-io]
axvmconfig = { git = "https://github.com/arceos-hypervisor/axvmconfig.git", branch = "next" }
30 changes: 30 additions & 0 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ use crate::AxVmDeviceConfig;
#[cfg(target_arch = "aarch64")]
use arm_vgic::Vgic;

#[cfg(target_arch = "riscv64")]
use riscv_vplic::VPlicGlobal;

/// A set of emulated device types that can be accessed by a specific address range type.
pub struct AxEmuDevices<R: DeviceAddrRange> {
emu_devices: Vec<Arc<dyn BaseDeviceOps<R>>>,
Expand Down Expand Up @@ -234,6 +237,33 @@ impl AxVmDevices {
);
}
}
EmulatedDeviceType::PPPTGlobal => {
#[cfg(target_arch = "riscv64")]
{
let context_num = config
.cfg_list
.first()
.copied()
.expect("expect 1 arg for pppt global (context_num)");
this.add_mmio_dev(Arc::new(VPlicGlobal::new(
config.base_gpa.into(),
Some(config.length),
context_num, // Here only 1 core and should be cpu0
)));
// PLIC Partial Passthrough Global.
info!(
"Partial PLIC Passthrough Global initialized with base GPA {:#x} and length {:#x}",
config.base_gpa, config.length
);
}
#[cfg(not(target_arch = "riscv64"))]
{
warn!(
"emu type: {} is not supported on this platform",
config.emu_type
);
}
}
EmulatedDeviceType::IVCChannel => {
if this.ivc_channel.is_none() {
// Initialize the IVC channel range allocator
Expand Down