[][src]Trait kernel::Chip

pub trait Chip {
    type MPU: MPU;
    type UserspaceKernelBoundary: UserspaceKernelBoundary;
    type SysTick: SysTick;
    fn service_pending_interrupts(&self);
fn has_pending_interrupts(&self) -> bool;
fn mpu(&self) -> &Self::MPU;
fn systick(&self) -> &Self::SysTick;
fn userspace_kernel_boundary(&self) -> &Self::UserspaceKernelBoundary;
fn sleep(&self);
unsafe fn atomic<F, R>(&self, f: F) -> R
    where
        F: FnOnce() -> R
; }

Interface for individual MCUs.

The trait defines chip-specific properties of Tock's operation. These include whether and which memory protection mechanism and systick to use, how to switch between the kernel and userland applications, and how to handle hardware events.

Each microcontroller should define a struct and implement this trait.

Associated Types

type MPU: MPU

The particular Memory Protection Unit (MPU) for this chip.

type UserspaceKernelBoundary: UserspaceKernelBoundary

The implementation of the interface between userspace and the kernel for this specific chip. Likely this is architecture specific, but individual chips may have various custom requirements.

type SysTick: SysTick

The implementation of the timer used to create the timeslices provided to applications.

Loading content...

Required methods

fn service_pending_interrupts(&self)

The kernel calls this function to tell the chip to check for all pending interrupts and to correctly dispatch them to the peripheral drivers for the chip.

This function should loop internally until all interrupts have been handled. It is ok, however, if an interrupt occurs after the last check but before this function returns. The kernel will handle this edge case.

fn has_pending_interrupts(&self) -> bool

Ask the chip to check if there are any pending interrupts.

fn mpu(&self) -> &Self::MPU

Returns a reference to the implementation for the MPU on this chip.

fn systick(&self) -> &Self::SysTick

Returns a reference to the implementation of the systick timer for this chip.

fn userspace_kernel_boundary(&self) -> &Self::UserspaceKernelBoundary

Returns a reference to the implementation for the interface between userspace and kernelspace.

fn sleep(&self)

Called when there is nothing left for the chip to do and it should enter a low power sleep state. This low power sleep state should allow interrupts to still be active so that the next interrupt event wakes the chip and resumes the scheduler.

unsafe fn atomic<F, R>(&self, f: F) -> R where
    F: FnOnce() -> R, 

Run a function in an atomic state, which means that interrupts are disabled so that an interrupt will not fire during the passed in function's execution.

Loading content...

Implementors

Loading content...