mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
hypervisor: x86: use a macro to generate emulate function for movs
No functional change. Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
@@ -15,8 +15,8 @@ use crate::arch::x86::emulator::instructions::*;
|
|||||||
use crate::arch::x86::regs::DF;
|
use crate::arch::x86::regs::DF;
|
||||||
use crate::arch::x86::Exception;
|
use crate::arch::x86::Exception;
|
||||||
|
|
||||||
pub struct Movsd_m32_m32;
|
macro_rules! movs {
|
||||||
impl<T: CpuStateManager> InstructionHandler<T> for Movsd_m32_m32 {
|
($bound:ty) => {
|
||||||
fn emulate(
|
fn emulate(
|
||||||
&self,
|
&self,
|
||||||
insn: &Instruction,
|
insn: &Instruction,
|
||||||
@@ -39,7 +39,7 @@ impl<T: CpuStateManager> InstructionHandler<T> for Movsd_m32_m32 {
|
|||||||
.map_err(|e| EmulationError::InvalidOperand(anyhow!(e)))?;
|
.map_err(|e| EmulationError::InvalidOperand(anyhow!(e)))?;
|
||||||
|
|
||||||
let df = (state.flags() & DF) != 0;
|
let df = (state.flags() & DF) != 0;
|
||||||
let len = std::mem::size_of::<u32>();
|
let len = std::mem::size_of::<$bound>();
|
||||||
|
|
||||||
while count > 0 {
|
while count > 0 {
|
||||||
let mut memory: [u8; 4] = [0; 4];
|
let mut memory: [u8; 4] = [0; 4];
|
||||||
@@ -82,6 +82,12 @@ impl<T: CpuStateManager> InstructionHandler<T> for Movsd_m32_m32 {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Movsd_m32_m32;
|
||||||
|
impl<T: CpuStateManager> InstructionHandler<T> for Movsd_m32_m32 {
|
||||||
|
movs!(u32);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
Reference in New Issue
Block a user