// NEW endpoints on the separately named actual WaitSet. Frozen Core methods // and its private nonclone Retained/Prepared/Wait slots remain unchanged. use crate::runtime::{wait_bridge as k1080_bridge, wait_queue as k1080_queue}; /// Inert old lookup evidence. It cannot depart, cancel, retire or own a pin. #[derive(Clone, Copy)] #[repr(C)] pub struct K1080OldWaitLookup { set: u64, slot: usize, generation: u64, } impl WaitSet, 3> { pub fn os_k1080_inert_lookup(&self, actual: &WaitToken) -> Result { self.gate(Operation::Cancel)?; self.checked(actual)?; Ok(K1080OldWaitLookup { set: actual.set, slot: actual.slot, generation: actual.generation, }) } pub fn os_k1080_check_old_lookup(&self, old: &K1080OldWaitLookup) -> Result<(), Error> { self.gate(Operation::Cancel)?; // This temporary value goes only to frozen checked(). It never escapes // or enters a mutation. A consumed actual nonclone token stays consumed. let inert = WaitToken { set: old.set, slot: old.slot, generation: old.generation, }; self.checked(&inert).map(|_| ()) } pub const fn os_k1080_backend_offset() -> u64 { core::mem::offset_of!(Self, backend) as u64 } pub fn os_k1080_cleanup_ready(&self) -> Result<(), Error> { self.os_k1080_ordinary()?; if self .slots .iter() .any(|s| s.owned.is_some() || s.record.phase != Phase::Empty) { return Err(Error::Pending); } self.backend.os_k1080_cleanup_ready() } fn os_k1080_ordinary(&self) -> Result<(), Error> { self.gate(Operation::Service)?; if self.slots.iter().any(|s| { matches!( s.record.phase, Phase::Armed | Phase::Staged | Phase::Departed | Phase::Quarantined ) }) { return Err(Error::Pending); } Ok(()) } pub fn os_k1080_thread(&self, ordinal: usize) -> Result { self.gate(Operation::Service)?; self.backend.os_k1080_thread(ordinal) } pub fn os_k1080_physical_execution(&self) -> Result { // execution() performs the independently measured landing callback // when Queue.depart is retained. It cannot alias a desired current. let e = self.gate(Operation::Land)?; if e.current.is_none() { return Err(Error::Context); } Ok(e) } pub fn os_k1080_landing_bounds( &self, ) -> Result { context( self.cpu, self.backend.os_k1080_raw_execution(), Operation::Service, )?; self.backend.os_k1080_landing_bounds() } pub fn os_k1080_main_select(&mut self) -> Result { self.os_k1080_ordinary()?; self.backend.os_k1080_main_select() } pub fn os_k1080_main_depart( &mut self, actual: k1080_queue::OwnedSelection, ) -> Result< ( k1080_queue::OwnedSelection, crate::runtime::wait_context::Image, u64, ), k1080_queue::HandoffSelectionError, > { if self.os_k1080_ordinary().is_err() { return Err(k1080_queue::HandoffSelectionError::Before( k1080_queue::Error::Context, actual, )); } self.backend.os_k1080_main_depart(actual) } pub fn os_k1080_main_landed( &mut self, actual: k1080_queue::OwnedSelection, ) -> Result { if self.os_k1080_ordinary().is_err() { return Err(k1080_queue::HandoffSelectionError::Before( k1080_queue::Error::Context, actual, )); } self.backend.os_k1080_main_landed(actual) } pub fn os_k1080_wait_wire( &self, transfer: &WaitTransfer, ) -> Result<(crate::runtime::wait_context::Image, u64), Error> { context(self.cpu, self.backend.execution(), Operation::Service)?; let slot = self.checked(&transfer.token)?; if self.slots[slot].record.phase != Phase::Departed { return Err(Error::State); } self.backend.os_k1080_retained_wire() } pub fn os_k1080_main_return( &mut self, capture: crate::runtime::wait_context::Capture, ) -> Result { self.os_k1080_ordinary()?; // No source pin or actual Wait may be hidden by a bootstrap return. if self.slots.iter().any(|s| s.owned.is_some()) || self.backend.retained_claims() != 0 { return Err(Error::Pending); } self.backend.os_k1080_main_return(capture) } pub fn os_k1080_main_return_depart( &mut self, actual: k1080_queue::OwnedQueueReturn, ) -> Result< ( k1080_queue::OwnedQueueReturn, crate::runtime::wait_context::Cooperative, ), k1080_bridge::K1080MainReturnFailure, > { if self.os_k1080_ordinary().is_err() { return Err(k1080_bridge::K1080MainReturnFailure::Before( Error::Context, actual, )); } self.backend.os_k1080_main_return_depart(actual) } pub fn os_k1080_main_return_landed( &mut self, actual: k1080_queue::OwnedQueueReturn, ) -> Result<(), k1080_bridge::K1080MainReturnFailure> { if self.os_k1080_ordinary().is_err() { return Err(k1080_bridge::K1080MainReturnFailure::Before( Error::Context, actual, )); } self.backend.os_k1080_main_return_landed(actual) } } impl< B: k1080_bridge::K1080MainBackend + k1080_queue::QueueRetirementBackend, A: k1080_bridge::WaitAuthority, > WaitSet, 3> { pub fn os_k1080_main_retire( &mut self, ordinal: usize, ) -> Result<(), (Error, Option)> { self.os_k1080_ordinary().map_err(|e| (e, None))?; if self .slots .iter() .any(|s| s.owned.is_some() || s.record.phase != Phase::Empty) { return Err((Error::Pending, None)); } self.backend.os_k1080_main_retire(ordinal) } }