fn run_emulation(&mut self, hvf_vcpu: &mut HvfVcpu) -> Result<VcpuEmulation> {
        let vcpuid = hvf_vcpu.id();
        let pending_irq = self
            .intc
            .lock()
            .unwrap()
            .vcpu_has_pending_irq(hvf_vcpu.id());

        match hvf_vcpu.run(pending_irq) {
            Ok(exit) => match exit {
                VcpuExit::Breakpoint => {
                    debug!("vCPU {} breakpoint", vcpuid);
                    Ok(VcpuEmulation::Interrupted)
                }
                VcpuExit::Canceled => {
                    debug!("vCPU {} canceled", vcpuid);
                    Ok(VcpuEmulation::Handled)
                }
                VcpuExit::CpuOn(mpidr, entry, context_id) => {
                    debug!(
                        "CpuOn: mpidr=0x{:x} entry=0x{:x} context_id={}",
                        mpidr, entry, context_id
                    );
                    let cpuid: usize = (mpidr >> 8) as usize;
                    if let Some(boot_senders) = &self.boot_senders {
                        if let Some(sender) = boot_senders.get(cpuid - 1) {
                            sender.send(entry).unwrap()
                        }
                    }
                    Ok(VcpuEmulation::Handled)
                }
                VcpuExit::HypervisorCall => {
                    debug!("vCPU {} HVC", vcpuid);
                    Ok(VcpuEmulation::Handled)
                }
                VcpuExit::MmioRead(addr, data) => {
                    if let Some(ref mmio_bus) = self.mmio_bus {
                        mmio_bus.read(vcpuid, addr, data);
                    }
                    Ok(VcpuEmulation::Handled)
                }
                VcpuExit::MmioWrite(addr, data) => {
                    if let Some(ref mmio_bus) = self.mmio_bus {
                        mmio_bus.write(vcpuid, addr, data);
                    }
                    Ok(VcpuEmulation::Handled)
                }
                VcpuExit::SecureMonitorCall => {
                    debug!("vCPU {} SMC", vcpuid);
                    Ok(VcpuEmulation::Handled)
                }
                VcpuExit::Shutdown => {
                    info!("vCPU {} received shutdown signal", vcpuid);
                    Ok(VcpuEmulation::Stopped)
                }
                VcpuExit::SystemRegister => {
                    debug!("vCPU {} accessed a system register", vcpuid);
                    Ok(VcpuEmulation::Handled)
                }
                VcpuExit::VtimerActivated => {
                    debug!("vCPU {} VtimerActivated", vcpuid);
                    self.intc.lock().unwrap().set_vtimer_irq(vcpuid);
                    Ok(VcpuEmulation::Handled)
                }
                VcpuExit::WaitForEvent => {
                    debug!("vCPU {} WaitForEvent", vcpuid);
                    Ok(VcpuEmulation::WaitForEvent)
                }
                VcpuExit::WaitForEventExpired => {
                    debug!("vCPU {} WaitForEventExpired", vcpuid);
                    Ok(VcpuEmulation::WaitForEventExpired)
                }
                VcpuExit::WaitForEventTimeout(duration) => {
                    debug!("vCPU {} WaitForEventTimeout timeout={:?}", vcpuid, duration);
                    Ok(VcpuEmulation::WaitForEventTimeout(duration))
                }
            },
            Err(e) => {
                panic!("Error running HVF vCPU: {:?}", e);
            }
        }
    }
/// Returns error or enum specifying whether emulation was handled or interrupted.
Returns error or enum specifying whether emulation was handled or interrupted.
Returns error or enum specifying whether emulation was handled or interrupted .
fn run_emulation(&mut self, hvf_vcpu: &mut HvfVcpu) -> Result<VcpuEmulation> {
        let vcpuid = hvf_vcpu.id();
        let pending_irq = self
            .intc
            .lock()
            .unwrap()
            .vcpu_has_pending_irq(hvf_vcpu.id());
        match hvf_vcpu.run(pending_irq) {
            Ok(exit) => match exit {
                VcpuExit::Breakpoint => {
                    debug!("vCPU {} breakpoint", vcpuid);
                    Ok(VcpuEmulation::Interrupted)
                }
                VcpuExit::Canceled => {
                    debug!("vCPU {} canceled", vcpuid);
                    Ok(VcpuEmulation::Handled)
                }
                VcpuExit::CpuOn(mpidr, entry, context_id) => {
                    debug!(
                        "CpuOn: mpidr=0x{:x} entry=0x{:x} context_id={}",
                        mpidr, entry, context_id
                    );
                    let cpuid: usize = (mpidr >> 8) as usize;
                    if let Some(boot_senders) = &self.boot_senders {
                        if let Some(sender) = boot_senders.get(cpuid - 1) {
                            sender.send(entry).unwrap()
                        }
                    }
                    Ok(VcpuEmulation::Handled)
                }
                VcpuExit::HypervisorCall => {
                    debug!("vCPU {} HVC", vcpuid);
                    Ok(VcpuEmulation::Handled)
                }
                VcpuExit::MmioRead(addr, data) => {
                    if let Some(ref mmio_bus) = self.mmio_bus {
                        mmio_bus.read(vcpuid, addr, data);
                    }
                    Ok(VcpuEmulation::Handled)
                }
                VcpuExit::MmioWrite(addr, data) => {
                    if let Some(ref mmio_bus) = self.mmio_bus {
                        mmio_bus.write(vcpuid, addr, data);
                    }
                    Ok(VcpuEmulation::Handled)
                }
                VcpuExit::SecureMonitorCall => {
                    debug!("vCPU {} SMC", vcpuid);
                    Ok(VcpuEmulation::Handled)
                }
                VcpuExit::Shutdown => {
                    info!("vCPU {} received shutdown signal", vcpuid);
                    Ok(VcpuEmulation::Stopped)
                }
                VcpuExit::SystemRegister => {
                    debug!("vCPU {} accessed a system register", vcpuid);
                    Ok(VcpuEmulation::Handled)
                }
                VcpuExit::VtimerActivated => {
                    debug!("vCPU {} VtimerActivated", vcpuid);
                    self.intc.lock().unwrap().set_vtimer_irq(vcpuid);
                    Ok(VcpuEmulation::Handled)
                }
                VcpuExit::WaitForEvent => {
                    debug!("vCPU {} WaitForEvent", vcpuid);
                    Ok(VcpuEmulation::WaitForEvent)
                }
                VcpuExit::WaitForEventExpired => {
                    debug!("vCPU {} WaitForEventExpired", vcpuid);
                    Ok(VcpuEmulation::WaitForEventExpired)
                }
                VcpuExit::WaitForEventTimeout(duration) => {
                    debug!("vCPU {} WaitForEventTimeout timeout={:?}", vcpuid, duration);
                    Ok(VcpuEmulation::WaitForEventTimeout(duration))
                }
            },
            Err(e) => {
                panic!("Error running HVF vCPU: {:?}", e);
            }
        }
    }
fn run_emulation ( & mut self , hvf_vcpu : & mut HvfVcpu ) -> Result < VcpuEmulation > { let vcpuid = hvf_vcpu . id ( ) ; let pending_irq = self . intc . lock ( ) . unwrap ( ) . vcpu_has_pending_irq ( hvf_vcpu . id ( ) ) ; match hvf_vcpu . run ( pending_irq ) { Ok ( exit ) => match exit { VcpuExit :: Breakpoint => { debug ! ( " " vcpuid ) ; Ok ( VcpuEmulation :: Interrupted ) } VcpuExit :: Canceled => { debug ! ( " " vcpuid ) ; Ok ( VcpuEmulation :: Handled ) } VcpuExit :: CpuOn ( mpidr , entry , context_id ) => { debug ! ( " " mpidr entry context_id ) ; let cpuid : usize = ( mpidr >> 8 ) as usize ; if let Some ( boot_senders ) = & self . boot_senders { if let Some ( sender ) = boot_senders . get ( cpuid - 1 ) { sender . send ( entry ) . unwrap ( ) } } Ok ( VcpuEmulation :: Handled ) } VcpuExit :: HypervisorCall => { debug ! ( " " vcpuid ) ; Ok ( VcpuEmulation :: Handled ) } VcpuExit :: MmioRead ( addr , data ) => { if let Some ( ref mmio_bus ) = self . mmio_bus { mmio_bus . read ( vcpuid , addr , data ) ; } Ok ( VcpuEmulation :: Handled ) } VcpuExit :: MmioWrite ( addr , data ) => { if let Some ( ref mmio_bus ) = self . mmio_bus { mmio_bus . write ( vcpuid , addr , data ) ; } Ok ( VcpuEmulation :: Handled ) } VcpuExit :: SecureMonitorCall => { debug ! ( " " vcpuid ) ; Ok ( VcpuEmulation :: Handled ) } VcpuExit :: Shutdown => { info ! ( " " vcpuid ) ; Ok ( VcpuEmulation :: Stopped ) } VcpuExit :: SystemRegister => { debug ! ( " " vcpuid ) ; Ok ( VcpuEmulation :: Handled ) } VcpuExit :: VtimerActivated => { debug ! ( " " vcpuid ) ; self . intc . lock ( ) . unwrap ( ) . set_vtimer_irq ( vcpuid ) ; Ok ( VcpuEmulation :: Handled ) } VcpuExit :: WaitForEvent => { debug ! ( " " vcpuid ) ; Ok ( VcpuEmulation :: WaitForEvent ) } VcpuExit :: WaitForEventExpired => { debug ! ( " " vcpuid ) ; Ok ( VcpuEmulation :: WaitForEventExpired ) } VcpuExit :: WaitForEventTimeout ( duration ) => { debug ! ( " " vcpuid duration ) ; Ok ( VcpuEmulation :: WaitForEventTimeout ( duration ) ) } } , Err ( e ) => { panic ! ( " " e ) ; } } }
Returns error or enum specifying whether emulation was handled or interrupted.
Returns error or enum specifying whether emulation was handled or interrupted .
&mut self
hvf_vcpu
&mut HvfVcpu