//! Shared constants and progress stages for concurrent kernel checks.

/// Pages in the allocation interrupted by the cancellation checker.
export constant ALLOCATION_PAGES: u32 = 4096;
/// Completed allocation transactions per user context.
export constant TRANSACTIONS: u32 = 16;
/// Physical interrupt source injected by the machine runner.
export constant IRQ_SOURCE: u32 = 7;
/// Token delivered by the remote wakeup check.
export constant WAKE_TOKEN: u32 = 0x55;
/// Token delivered by the remote timeout check.
export constant TIMEOUT_TOKEN: u32 = 0x66;
/// Token delivered while a level interrupt remains asserted.
export constant STORM_TOKEN: u32 = 0x77;

/// Handshake between the idle user context and the machine checker.
export union WakeStage: Copy {
    /// User is about to wait for an explicit wakeup.
    BeforeWakeWait = 2,
    /// User resumed after its explicit wakeup.
    WakeResumed = 3,
    /// Checker permits the user to start its timeout wait.
    AllowTimeout = 4,
    /// User is about to wait for the timeout.
    BeforeTimeoutWait = 5,
    /// User resumed after its timeout.
    TimeoutResumed = 6,
    /// Checker permits the user to wait for terminal events.
    AllowTerminalWait = 7,
    /// User is about to wait for terminal events.
    BeforeTerminalWait = 8,
    /// User resumed after a terminal event.
    TerminalResumed = 9,
    /// Checker permits the user to start its large allocation.
    AllowAllocation = 10,
    /// User is about to allocate pages.
    BeforeAllocation = 11,
    /// Allocation completed without interruption.
    AllocationComplete = 12,
}
