rust update uc_ctl_flush_tlb and add uc_ctl_tlb_mode

This commit is contained in:
Philipp Takacs 2023-04-05 12:35:05 +02:00 committed by Kevin Schneider
parent 5ff654c77b
commit 0729dc0312
2 changed files with 28 additions and 1 deletions

View File

@ -1189,7 +1189,7 @@ impl<'a, D> Unicorn<'a, D> {
}
}
pub fn ctl_flush_tlb(&self) -> Result<(), uc_error> {
pub fn ctl_flush_tb(&self) -> Result<(), uc_error> {
let err = unsafe { ffi::uc_ctl(self.get_handle(), UC_CTL_WRITE!(ControlType::UC_CTL_TB_FLUSH)) };
if err == uc_error::OK {
Ok(())
@ -1197,4 +1197,22 @@ impl<'a, D> Unicorn<'a, D> {
Err(err)
}
}
pub fn ctl_flush_tlb(&self) -> Result<(), uc_error> {
let err = unsafe { ffi::uc_ctl(self.get_handle(), UC_CTL_WRITE!(ControlType::UC_CTL_TLB_FLUSH)) };
if err == uc_error::OK {
Ok(())
} else {
Err(err)
}
}
pub fn ctl_tlb_type(&self, t: TlbType) -> Result<(), uc_error> {
let err = unsafe { ffi::uc_ctl(self.get_handle(), UC_CTL_WRITE!(ControlType::UC_CTL_TLB_TYPE), t as i32) };
if err == uc_error::OK {
Ok(())
} else {
Err(err)
}
}
}

View File

@ -53,6 +53,13 @@ pub enum MemType {
READ_AFTER = 25,
}
#[repr(C)]
#[derive(PartialEq, Debug, Clone, Copy)]
pub enum TlbType {
CPU = 0,
VIRTUAL = 1,
}
bitflags! {
#[repr(C)]
pub struct HookType: i32 {
@ -227,6 +234,8 @@ pub enum ControlType {
UC_CTL_TB_REQUEST_CACHE = 8,
UC_CTL_TB_REMOVE_CACHE = 9,
UC_CTL_TB_FLUSH = 10,
UC_CTL_TLB_FLUSH = 11,
UC_CTL_TLB_TYPE = 12,
UC_CTL_IO_READ = 1<<31,
UC_CTL_IO_WRITE = 1<<30,
}