Skip to content

Commit

Permalink
refactor(device): add vcpu_id parameter to MMIO handler functions
Browse files Browse the repository at this point in the history
- Update handle_mmio_read and handle_mmio_write functions to include vcpu_id parameter
- Pass vcpu_id to emu_dev.handle_read and emu_dev.handle_write
- This change prepares
  • Loading branch information
luodeb committed Nov 28, 2024
1 parent 51bf078 commit 56c7ec2
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,32 @@ impl AxVmDevices {
}

/// Handle the MMIO read by GuestPhysAddr and data width, return the value of the guest want to read
pub fn handle_mmio_read(&self, addr: GuestPhysAddr, width: usize) -> AxResult<usize> {
pub fn handle_mmio_read(
&self,
addr: GuestPhysAddr,
width: usize,
vcpu_id: usize,
) -> AxResult<usize> {
if let Some(emu_dev) = self.find_dev(addr) {
info!(
"emu: {:?} handler read ipa {:#x}",
emu_dev.address_range(),
addr
);
return emu_dev.handle_read(addr, width);
return emu_dev.handle_read(addr, width, vcpu_id);
}
panic!("emu_handle: no emul handler for data abort ipa {:#x}", addr);
}

/// Handle the MMIO write by GuestPhysAddr, data width and the value need to write, call specific device to write the value
pub fn handle_mmio_write(&self, addr: GuestPhysAddr, width: usize, val: usize) {
pub fn handle_mmio_write(&self, addr: GuestPhysAddr, width: usize, val: usize, vcpu_id: usize) {
if let Some(emu_dev) = self.find_dev(addr) {
info!(
"emu: {:?} handler write ipa {:#x}",
emu_dev.address_range(),
addr
);
emu_dev.handle_write(addr, width, val);
emu_dev.handle_write(addr, width, val, vcpu_id);
return;
}
panic!(
Expand Down

0 comments on commit 56c7ec2

Please sign in to comment.