#![no_std]
extern crate alloc;
#[macro_use]
extern crate log;
mod arch;
pub mod boot;
mod host;
pub mod irq;
pub mod layout;
pub mod lifecycle;
mod manager;
mod percpu;
mod runtime;
mod task;
mod timer;
mod vcpu;
mod vm;
use crate::arch::ArchOps;
pub mod config;
pub use ax_cpumask::CpuMask;
pub use axvm_types::VmExit;
pub use axvm_types::{
AccessWidth, GuestPhysAddr, HostPhysAddr, InterruptTriggerMode, MappingFlags, Port, SysRegAddr,
VMId, VmVcpuState,
};
pub(crate) use host::{
paging::HostPagingHandler,
task::{AxTaskExt, AxTaskRef, TaskInner, WaitQueue, WaitQueueHandle as HostWaitQueueHandle},
};
pub use irq::InterruptFabric;
pub use lifecycle::{StopReason, VmLifecycleError, VmStatus};
pub use manager::{
AxvmRuntime, current_vcpu_id, current_vm_id, get_vm_by_id, get_vm_list,
inject_current_vcpu_interrupt, register_vm,
};
#[cfg(target_arch = "loongarch64")]
pub use runtime::loongarch_irq::{
register_guest_irq_route as register_loongarch_guest_irq_route,
unregister_guest_irq_routes as unregister_loongarch_guest_irq_routes,
};
pub(crate) use task::{AsVCpuTask, VCpuTask};
pub use vm::{
AxVM, AxVMRef, FwCfgDeviceConfig, PreparedMemoryLayout, VMMemoryRegion, VcpuSnapshot,
};
pub(crate) type AxVMPerCpu = vcpu::AxPerCpu<arch::ArchPerCpu>;
pub fn check_timer_events() {
timer::check_events();
}
pub fn clean_dcache_range(addr: ax_memory_addr::VirtAddr, size: usize) {
arch::CurrentArch::clean_dcache_range(addr, size);
}
#[cfg(any(
target_arch = "aarch64",
target_arch = "loongarch64",
target_arch = "riscv64"
))]
pub fn host_fdt_bootarg() -> usize {
host::arceos::host_fdt_bootarg()
}
#[cfg(any(
target_arch = "aarch64",
target_arch = "loongarch64",
target_arch = "riscv64"
))]
pub fn host_phys_to_virt(paddr: ax_memory_addr::PhysAddr) -> ax_memory_addr::VirtAddr {
host::arceos::phys_to_virt(paddr)
}
#[cfg(all(
any(feature = "fs", feature = "host-fs"),
any(target_arch = "x86_64", target_arch = "loongarch64")
))]
pub fn shutdown_host_filesystems() -> ax_errno::AxResult {
host::arceos::shutdown_host_filesystems()
}
#[cfg(target_arch = "x86_64")]
pub fn register_x86_ioapic_irq_forwarding_route(guest_gsi: usize, host_irq: irq_framework::IrqId) {
runtime::register_x86_ioapic_irq_forwarding_route(guest_gsi, host_irq);
}
#[cfg(target_arch = "x86_64")]
pub fn register_x86_ioapic_irq_forwarding_route_with_trigger(
guest_gsi: usize,
host_irq: irq_framework::IrqId,
trigger: InterruptTriggerMode,
) {
runtime::register_x86_ioapic_irq_forwarding_route_with_trigger(guest_gsi, host_irq, trigger);
}
#[cfg(target_arch = "x86_64")]
pub fn register_x86_ioapic_irq_forwarding_activator(guest_gsi: usize, activator: fn()) {
runtime::register_x86_ioapic_irq_forwarding_activator(guest_gsi, activator);
}