use enum_iterator::IntoEnumIterator;
use std::error::Error;
use events::{Event, EventReplyType, InterceptType};
use registers::Registers;
pub mod events;
pub mod params;
pub mod registers;
#[allow(clippy::bad_bit_mask)]
mod flags {
bitflags! {
pub struct Access: u32 {
const NIL=0b00000000;
const R=0b00000001;
const W=0b00000010;
const X=0b00000100;
const RW=Self::R.bits | Self::W.bits;
const WX=Self::W.bits | Self::X.bits;
const RX=Self::R.bits | Self::X.bits;
const RWX=Self::R.bits | Self::W.bits | Self::X.bits;
}
}
}
pub use flags::Access;
#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, IntoEnumIterator)]
pub enum DriverType {
KVM,
Memflow,
VirtualBox,
Xen,
}
pub const PAGE_SHIFT: u32 = 12;
pub const PAGE_SIZE: u32 = 4096;
pub trait Introspectable {
fn get_vcpu_count(&self) -> Result<u16, Box<dyn Error>> {
unimplemented!();
}
fn read_physical(
&self,
_paddr: u64,
_buf: &mut [u8],
_bytes_read: &mut u64,
) -> Result<(), Box<dyn Error>> {
unimplemented!();
}
fn write_physical(&self, _paddr: u64, _buf: &[u8]) -> Result<(), Box<dyn Error>> {
unimplemented!();
}
fn get_max_physical_addr(&self) -> Result<u64, Box<dyn Error>> {
unimplemented!();
}
fn read_registers(&self, _vcpu: u16) -> Result<Registers, Box<dyn Error>> {
unimplemented!();
}
fn get_page_access(&self, _paddr: u64) -> Result<Access, Box<dyn Error>> {
unimplemented!();
}
fn set_page_access(&self, _paddr: u64, _access: Access) -> Result<(), Box<dyn Error>> {
unimplemented!();
}
fn write_registers(&self, _vcpu: u16, _reg: Registers) -> Result<(), Box<dyn Error>> {
unimplemented!();
}
fn pause(&mut self) -> Result<(), Box<dyn Error>> {
unimplemented!();
}
fn resume(&mut self) -> Result<(), Box<dyn Error>> {
unimplemented!();
}
fn toggle_intercept(
&mut self,
_vcpu: u16,
_intercept_type: InterceptType,
_enabled: bool,
) -> Result<(), Box<dyn Error>> {
unimplemented!();
}
fn listen(&mut self, _timeout: u32) -> Result<Option<Event>, Box<dyn Error>> {
unimplemented!();
}
fn reply_event(
&mut self,
_event: Event,
_reply_type: EventReplyType,
) -> Result<(), Box<dyn Error>> {
unimplemented!();
}
fn get_driver_type(&self) -> DriverType;
}