use crate::{
simics_exception,
sys::{
SIM_add_module_dir, SIM_get_all_failed_modules, SIM_get_all_modules, SIM_load_module,
SIM_module_list_refresh,
},
AttrValue, Result,
};
use raw_cstr::raw_cstr;
use std::path::Path;
#[simics_exception]
pub fn get_all_modules() -> AttrValue {
unsafe { SIM_get_all_modules() }.into()
}
#[simics_exception]
pub fn get_all_failed_modules() -> AttrValue {
unsafe { SIM_get_all_failed_modules() }.into()
}
#[simics_exception]
pub fn add_module_dir<P>(path: P) -> Result<()>
where
P: AsRef<Path>,
{
unsafe { SIM_add_module_dir(raw_cstr(path.as_ref().to_string_lossy())?) }
Ok(())
}
#[simics_exception]
pub fn module_list_refresh() {
unsafe { SIM_module_list_refresh() };
}
#[simics_exception]
pub fn load_module<S>(module: S) -> Result<()>
where
S: AsRef<str>,
{
unsafe { SIM_load_module(raw_cstr(module)?) }
Ok(())
}