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
11 changes: 7 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repository = "https://github.com/arceos-hypervisor/axvisor_api"

[package]
name = "axvisor_api"
version = "0.2.0"
version = "0.3.0"
description = "Basic API for components of the Hypervisor on ArceOS"
documentation = "https://docs.rs/axvisor_api"
readme = "README.md"
Expand All @@ -24,15 +24,18 @@ repository.workspace = true
[dependencies]
# === Core Components ===
# Procedural macro definitions
axvisor_api_proc = { path = "axvisor_api_proc", version = "0.2.0" }
axvisor_api_proc = { path = "axvisor_api_proc", version = "0.3.0"}

# === Third-party Libraries ===
# Address space abstraction
axaddrspace = "0.1.0"
axaddrspace = "0.3"
# Interface definition tools
crate_interface = "0.2"
crate_interface = "0.3"
# Physical/virtual address types
memory_addr = "0.4"
# CPU mask
cpumask = "0.1.0"


[package.metadata.docs.rs]
all-features = true
Expand Down
2 changes: 1 addition & 1 deletion axvisor_api_proc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "axvisor_api_proc"
version = "0.2.0"
version = "0.3.0"
description = "Procedural macros for the `axvisor_api` crate"
documentation = "https://docs.rs/axvisor_api_proc"
readme = "README.md"
Expand Down
12 changes: 12 additions & 0 deletions src/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,16 @@ pub trait ArchIf {
/// later.
#[cfg(target_arch = "aarch64")]
fn get_host_gicr_base() -> PhysAddr;

/// Retrieve the current pending interrupt for the CPU from the physical hardware.
#[cfg(target_arch = "aarch64")]
fn fetch_irq() -> u64;
/// Calls the IRQ handler of the underlying OS to handle a pending interrupt.
///
/// TODO: Determine if this function should be exposed in other architectures (and moved to
/// `host` module) or remain architecture-specific.
///
/// TODO: Consider whether this function should replace `AxVCpuExitReason::ExternalInterrupt`.
#[cfg(target_arch = "aarch64")]
fn handle_irq();
}
1 change: 1 addition & 0 deletions src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ pub trait MemoryIf {
/// This struct provides an implementation of the `AxMmHal` trait from the
/// `axaddrspace` crate, delegating to the axvisor_api memory functions.
#[doc(hidden)]
#[derive(Debug)]
pub struct AxMmHalApiImpl;

impl axaddrspace::AxMmHal for AxMmHalApiImpl {
Expand Down
16 changes: 14 additions & 2 deletions src/vmm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,20 @@ pub type VCpuId = usize;
/// Represents the interrupt vector number to be injected into a guest.
pub type InterruptVector = u8;

/// The maximum number of virtual CPUs supported in a virtual machine.
pub const MAX_VCPU_NUM: usize = 64;

/// A set of virtual CPUs.
pub type VCpuSet = cpumask::CpuMask<MAX_VCPU_NUM>;

/// The API trait for virtual machine management functionalities.
///
/// This trait defines the core VM management interface required by the
/// hypervisor components. Implementations should be provided by the VMM
/// layer.
#[crate::api_def]
pub trait VmmIf {
/// Notify that a virtual CPU timer has expired.
/// Get the identifier of the current virtual machine.
///
/// This function returns the VM ID of the VM that the calling context
Expand Down Expand Up @@ -145,6 +152,9 @@ pub trait VmmIf {
/// ```
fn inject_interrupt(vm_id: VMId, vcpu_id: VCpuId, vector: InterruptVector);

/// Inject an interrupt to a set of virtual CPUs.
fn inject_interrupt_to_cpus(vm_id: VMId, vcpu_set: VCpuSet, vector: InterruptVector);

/// Notify that a virtual CPU's timer has expired.
///
/// This function is called when a vCPU's virtual timer expires and needs
Expand All @@ -162,7 +172,8 @@ pub trait VmmIf {
fn notify_vcpu_timer_expired(vm_id: VMId, vcpu_id: VCpuId);
}

/// Get the number of virtual CPUs in the current virtual machine.
/// Get the number of virtual CPUs in the current virtual machine executing on
/// the current physical CPU.
///
/// This is a convenience function that combines [`current_vm_id`] and
/// [`vcpu_num`].
Expand All @@ -179,7 +190,8 @@ pub fn current_vm_vcpu_num() -> usize {
vcpu_num(current_vm_id()).unwrap()
}

/// Get the bitmask of active virtual CPUs in the current virtual machine.
/// Get the bitmask of active virtual CPUs in the current virtual machine
/// executing on the current physical CPU.
///
/// This is a convenience function that combines [`current_vm_id`] and
/// [`active_vcpus`].
Expand Down