/// This is invoked through the kernel whenever we get an
/// upcall (trap happened or interrupt came in) we resume
/// exection here so we can handle it accordingly.
///
/// # XXX verify if this is true:
/// When we resume from here we can assume the following:
///
/// * The `enabled` area of [kpi::arch::VirtualCpuState] contains
///   where we left off before we got interrupted.
/// * The [kpi::arch::VirtualCpu] `disabled` flag was set to true and
///   needs to be cleared again.
This is invoked through the kernel whenever we get an
upcall (trap happened or interrupt came in) we resume
exection here so we can handle it accordingly.
This is invoked through the kernel whenever we get an upcall ( trap happened or interrupt came in ) we resume exection here so we can handle it accordingly .
pub fn upcall_while_enabled(control: &mut kpi::arch::VirtualCpu, cmd: u64, arg: u64) -> ! {
    trace!(
        "upcall_while_enabled {:?} vec={:#x} err={}",
        control,
        cmd,
        arg
    );
    let sched = &PROCESS_SCHEDULER;
    if cmd == kpi::upcall::NEW_CORE {
        use lineup::tls2::SchedulerControlBlock;
        let core_id = arg;
        log::info!("Got a new core ({}) assigned to us.", core_id);
        CORES_ONLINE.fetch_add(1, Ordering::SeqCst);
        #[cfg(feature = "rumprt")]
        {
            use crate::rumprt::crt::READY_TO_RUMBLE;
            while READY_TO_RUMBLE.load(Ordering::SeqCst) == false {
                core::hint::spin_loop();
            }
        }
        let scb: SchedulerControlBlock = SchedulerControlBlock::new(core_id as usize);
        loop {
            sched.run(&scb);
        }
    }
    if cmd == 0x2a || cmd == 0x24 {
        // TODO(correctness): this will use `gs` to access the SchedulerControlBlock
        // that assumes that we have already called scheduler.run() and we preserve
        // the SchedulerControlBlock register even if we return from run()
        let scheduler = lineup::tls2::Environment::scheduler();
        log::info!("got interrupt cmd={} arg={}", cmd, arg);
        assert!(scheduler.pending_irqs.push(cmd).is_ok());
    } else {
        log::error!("got unknown interrupt... {}", cmd);
    }
    trace!("upcall_while_enabled: renable and resume...");
    unsafe { resume(control) }
}
pub fn upcall_while_enabled ( control : & mut kpi :: arch :: VirtualCpu , cmd : u64 , arg : u64 ) -> ! { trace ! ( " " control cmd arg ) ; let sched = & PROCESS_SCHEDULER ; if cmd == kpi :: upcall :: NEW_CORE { use lineup :: tls2 :: SchedulerControlBlock ; let core_id = arg ; log :: info ! ( " " core_id ) ; CORES_ONLINE . fetch_add ( 1 , Ordering :: SeqCst ) ; # [ cfg ( feature " " ) ] { use crate :: rumprt :: crt :: READY_TO_RUMBLE ; while READY_TO_RUMBLE . load ( Ordering :: SeqCst ) == false { core :: hint :: spin_loop ( ) ; } } let scb : SchedulerControlBlock = SchedulerControlBlock :: new ( core_id as usize ) ; loop { sched . run ( & scb ) ; } } if cmd == 0x2a || cmd == 0x24 { // TODO(correctness): this will use `gs` to access the SchedulerControlBlock // that assumes that we have already called scheduler.run() and we preserve // the SchedulerControlBlock register even if we return from run() let scheduler = lineup :: tls2 :: Environment :: scheduler ( ) ; log :: info ! ( " " cmd arg ) ; assert ! ( scheduler pending_irqs push ( cmd ) is_ok ( ) ) ; } else { log :: error ! ( " " cmd ) ; } trace ! ( " " ) ; unsafe { resume ( control ) } }
This is invoked through the kernel whenever we get an
upcall (trap happened or interrupt came in) we resume
exection here so we can handle it accordingly.
This is invoked through the kernel whenever we get an upcall ( trap happened or interrupt came in ) we resume exection here so we can handle it accordingly .
control
&mut kpi::arch::VirtualCpu
cmd
u64
arg
u64
xxx verify if this is true:
When we resume from here we can assume the following.

The `enabled` area of [kpi::arch::VirtualCpuState] contains
where we left off before we got interrupted.
The [kpi::arch::VirtualCpu] `disabled` flag was set to true and
needs to be cleared again.
When we resume from here we can assume the following . The ` enabled ` area of [ kpi :: arch :: VirtualCpuState ] contains where we left off before we got interrupted . The [ kpi :: arch :: VirtualCpu ] ` disabled ` flag was set to true and needs to be cleared again .