@@ -4,16 +4,16 @@ use alloc::sync::Arc;
44use alloc:: vec:: Vec ;
55use core:: sync:: atomic:: { AtomicBool , Ordering } ;
66
7- use axerrno:: { AxResult , ax_err, ax_err_type} ;
7+ use axerrno:: { ax_err, ax_err_type, AxResult } ;
88use spin:: Mutex ;
99
1010use axaddrspace:: { AddrSpace , GuestPhysAddr , HostPhysAddr , MappingFlags } ;
1111use axdevice:: { AxVmDeviceConfig , AxVmDevices } ;
1212use axvcpu:: { AxArchVCpu , AxVCpu , AxVCpuExitReason , AxVCpuHal } ;
1313
1414use crate :: config:: { AxVMConfig , VmMemMappingType } ;
15- use crate :: vcpu:: { AxArchVCpuImpl , AxVCpuCreateConfig } ;
16- use crate :: { AxVMHal , has_hardware_support } ;
15+ use crate :: vcpu:: { AxArchEmuRegs , AxArchVCpuImpl , AxVCpuCreateConfig } ;
16+ use crate :: { has_hardware_support , AxVMHal } ;
1717
1818const VM_ASPACE_BASE : usize = 0x0 ;
1919const VM_ASPACE_SIZE : usize = 0x7fff_ffff_f000 ;
@@ -168,7 +168,7 @@ impl<H: AxVMHal, U: AxVCpuHal> AxVM<H, U> {
168168 MappingFlags :: DEVICE | MappingFlags :: READ | MappingFlags :: WRITE ,
169169 ) ?;
170170 }
171-
171+ info ! ( "skedfghkshdgfkd" ) ;
172172 let devices = axdevice:: AxVmDevices :: new ( AxVmDeviceConfig {
173173 emu_configs : config. emu_devices ( ) . to_vec ( ) ,
174174 } ) ;
@@ -306,15 +306,21 @@ impl<H: AxVMHal, U: AxVCpuHal> AxVM<H, U> {
306306 reg,
307307 reg_width : _,
308308 } => {
309- let val = self
310- . get_devices ( )
311- . handle_mmio_read ( * addr, ( * width) . into ( ) ) ?;
309+ let val = self . get_devices ( ) . handle_mmio_read (
310+ * addr,
311+ ( * width) . into ( ) ,
312+ vcpu. as_ref ( ) ,
313+ ) ?;
312314 vcpu. set_gpr ( * reg, val) ;
313315 true
314316 }
315317 AxVCpuExitReason :: MmioWrite { addr, width, data } => {
316- self . get_devices ( )
317- . handle_mmio_write ( * addr, ( * width) . into ( ) , * data as usize ) ;
318+ self . get_devices ( ) . handle_mmio_write (
319+ * addr,
320+ ( * width) . into ( ) ,
321+ * data as usize ,
322+ vcpu. as_ref ( ) ,
323+ ) ;
318324 true
319325 }
320326 AxVCpuExitReason :: IoRead { port : _, width : _ } => true ,
@@ -323,6 +329,22 @@ impl<H: AxVMHal, U: AxVCpuHal> AxVM<H, U> {
323329 width : _,
324330 data : _,
325331 } => true ,
332+ AxVCpuExitReason :: SysRegRead { addr, reg } => {
333+ AxArchEmuRegs :: < U > :: emu_register_handle_read (
334+ ( * addr) . into ( ) ,
335+ * reg,
336+ vcpu. clone ( ) ,
337+ ) ;
338+ true
339+ }
340+ AxVCpuExitReason :: SysRegWrite { addr, value } => {
341+ AxArchEmuRegs :: < U > :: emu_register_handle_write (
342+ ( * addr) . into ( ) ,
343+ * value,
344+ vcpu. clone ( ) ,
345+ ) ;
346+ true
347+ }
326348 AxVCpuExitReason :: NestedPageFault { addr, access_flags } => self
327349 . inner_mut
328350 . address_space
0 commit comments