[][src]Trait r3::kernel::PortTimer

pub trait PortTimer {
    const MAX_TICK_COUNT: UTicks;
    const MAX_TIMEOUT: UTicks;

    unsafe fn tick_count() -> UTicks;

    unsafe fn pend_tick_after(tick_count_delta: UTicks) { ... }
unsafe fn pend_tick() { ... } }

Implemented by a port. This trait contains items related to controlling a system timer.

Safety

These methods are only meant to be called by the kernel.

Associated Constants

const MAX_TICK_COUNT: UTicks

The maximum value that tick_count can return. Must be greater than zero.

const MAX_TIMEOUT: UTicks

The maximum value that can be passed to pend_tick_after. Must be greater than zero.

This value should be somewhat smaller than MAX_TICK_COUNT. The difference determines the kernel's resilience against overdue timer interrupts.

This is ignored and can take any value if pend_tick_after is implemented as no-op.

Loading content...

Required methods

unsafe fn tick_count() -> UTicks

Read the current tick count (timer value).

This value steadily increases over time. When it goes past MAX_TICK_COUNT, it “wraps around” to 0.

The returned value must be in range 0..=MAX_TICK_COUNT.

Precondition: CPU Lock active

Loading content...

Provided methods

unsafe fn pend_tick_after(tick_count_delta: UTicks)

Indicate that tick_count_delta ticks may elapse before the kernel should receive a call to PortToKernel::timer_tick.

tick_count_delta ticks” include the current (ongoing) tick. For example, tick_count_delta == 1 means timer_tick should be preferably called right after the next tick boundary.

The driver might track time in a coarser granularity than microseconds. In this case, the driver should wait until the earliest moment when tick_count() >= current_tick_count + tick_count_delta (where current_tick_count is the current value of tick_count(); not taking the wrap-around behavior into account) is fulfilled and call timer_tick.

It's legal to ignore the calls to this method entirely and call timer_tick at a steady rate, resulting in something similar to a “tickful” kernel. The default implementation does nothing assuming that the port driver is implemented in this way.

tick_count_delta must be in range 1..=MAX_TIMEOUT.

Precondition: CPU Lock active

unsafe fn pend_tick()

Pend a call to PortToKernel::timer_tick as soon as possible.

The default implementation calls pend_tick_after(1).

Precondition: CPU Lock active

Loading content...

Implementors

Loading content...