[][src]Trait kernel::Chip

pub trait Chip {
    type MPU: MPU;
    type UserspaceKernelBoundary: UserspaceKernelBoundary;
    type SchedulerTimer: SchedulerTimer;
    type WatchDog: WatchDog;
    fn service_pending_interrupts(&self);
fn has_pending_interrupts(&self) -> bool;
fn mpu(&self) -> &Self::MPU;
fn scheduler_timer(&self) -> &Self::SchedulerTimer;
fn watchdog(&self) -> &Self::WatchDog;
fn userspace_kernel_boundary(&self) -> &Self::UserspaceKernelBoundary;
fn sleep(&self);
unsafe fn atomic<F, R>(&self, f: F) -> R
    where
        F: FnOnce() -> R
;
unsafe fn print_state(&self, writer: &mut dyn Write); }

Interface for individual MCUs.

The trait defines chip-specific properties of Tock's operation. These include whether and which memory protection mechanism and scheduler_timer 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 SchedulerTimer: SchedulerTimer

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

type WatchDog: WatchDog

The implementation of the WatchDog timer used to monitor the running of the kernel.

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 scheduler_timer(&self) -> &Self::SchedulerTimer

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

fn watchdog(&self) -> &Self::WatchDog

Returns a reference to the implementation for the WatchDog on 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.

unsafe fn print_state(&self, writer: &mut dyn Write)

Print out chip state (system registers) to a supplied writer. This does not print out the execution context (data registers), as this depends on how they are stored; that is implemented by syscall::UserspaceKernelBoundary::print_context. This also does not print out a process memory state, that is implemented by process::Process::print_memory_map. The MPU state is printed by the MPU's implementation of the Display trait. Used by panic.

Loading content...

Implementors

Loading content...