Mark3 Realtime Kernel
Mark3::Kernel Class Reference

The Kernel Class encapsulates all of the kernel startup, configuration and management functions. More...

#include <kernel.h>

Static Public Member Functions

static void Init ()
 Kernel Initialization Function, call before any other OS function. More...
 
static void Start ()
 Start the operating system kernel - the current execution context is cancelled, all kernel services are started, and the processor resumes execution at the entrypoint for the highest-priority thread. More...
 
static void CompleteStart ()
 CompleteStart Call this from the thread initialization code at the point that the scheduler is to be run for the first time. More...
 
static bool IsStarted ()
 IsStarted. More...
 
static void SetPanic (PanicFunc pfPanic_)
 SetPanic Set a function to be called when a kernel panic occurs, giving the user to determine the behavior when a catastrophic failure is observed. More...
 
static bool IsPanic ()
 IsPanic Returns whether or not the kernel is in a panic state. More...
 
static void Panic (uint16_t u16Cause_)
 Panic Cause the kernel to enter its panic state. More...
 
static void SetThreadCreateCallout (ThreadCreateCallout pfCreate_)
 SetThreadCreateCallout Set a function to be called on creation of a new thread. This callout is executed on the successful completion of a Thread::Init() call. A callout is only executed if this method has been called to set a valid handler function. More...
 
static void SetThreadExitCallout (ThreadExitCallout pfExit_)
 SetThreadExitCallout Set a function to be called on thread exit. This callout is executed from the beginning of Thread::Exit(). More...
 
static void SetThreadContextSwitchCallout (ThreadContextCallout pfContext_)
 SetThreadContextSwitchCallout Set a function to be called on each context switch. More...
 
static void SetDebugPrintFunction (DebugPrintFunction pfPrintFunction_)
 SetDebugPrintFunction Set the function to be used when printing kernel debug information. More...
 
static void DebugPrint (const char *szString_)
 DebugPrint Print a string to the configured output interface. Has no effect if Kernel::SetDebugPrintFunction() has not been called with a valid print handler. More...
 
static ThreadCreateCallout GetThreadCreateCallout ()
 GetThreadCreateCallout Return the current function called on every Thread::Init();. More...
 
static ThreadExitCallout GetThreadExitCallout ()
 GetThreadExitCallout Return the current function called on every Thread::Exit();. More...
 
static ThreadContextCallout GetThreadContextSwitchCallout ()
 GetThreadContextSwitchCallout Return the current function called on every Thread::ContextSwitchSWI() More...
 
static void SetStackGuardThreshold (uint16_t u16Threshold_)
 
static uint16_t GetStackGuardThreshold ()
 
static void Tick ()
 
static uint32_t GetTicks ()
 

Static Private Attributes

static bool m_bIsStarted
 true if kernel is running, false otherwise More...
 
static bool m_bIsPanic
 true if kernel is in panic state, false otherwise More...
 
static PanicFunc m_pfPanic
 set panic function More...
 
static ThreadCreateCallout m_pfThreadCreateCallout
 Function to call on thread creation. More...
 
static ThreadExitCallout m_pfThreadExitCallout
 Function to call on thread exit. More...
 
static ThreadContextCallout m_pfThreadContextCallout
 Function to call on context switch. More...
 
static DebugPrintFunction m_pfDebugPrintFunction
 Function to call to print debug info. More...
 
static uint16_t m_u16GuardThreshold
 
static uint32_t m_u32Ticks
 

Detailed Description

The Kernel Class encapsulates all of the kernel startup, configuration and management functions.

Definition at line 48 of file kernel.h.

Member Function Documentation

◆ CompleteStart()

void Mark3::Kernel::CompleteStart ( )
static

CompleteStart Call this from the thread initialization code at the point that the scheduler is to be run for the first time.

Definition at line 64 of file kernel.cpp.

◆ DebugPrint()

void Mark3::Kernel::DebugPrint ( const char *  szString_)
static

DebugPrint Print a string to the configured output interface. Has no effect if Kernel::SetDebugPrintFunction() has not been called with a valid print handler.

Parameters
szString_string to print
Examples:
lab10_notifications/main.cpp, lab11_mailboxes/main.cpp, lab1_kernel_setup/main.cpp, lab2_coroutines/main.cpp, lab3_round_robin/main.cpp, lab4_semaphores/main.cpp, lab5_mutexes/main.cpp, lab6_timers/main.cpp, lab7_events/main.cpp, lab8_messages/main.cpp, and lab9_dynamic_threads/main.cpp.

Definition at line 81 of file kernel.cpp.

◆ GetStackGuardThreshold()

static uint16_t Mark3::Kernel::GetStackGuardThreshold ( )
inlinestatic

Definition at line 202 of file kernel.h.

◆ GetThreadContextSwitchCallout()

static ThreadContextCallout Mark3::Kernel::GetThreadContextSwitchCallout ( )
inlinestatic

GetThreadContextSwitchCallout Return the current function called on every Thread::ContextSwitchSWI()

Returns
Pointer to the currently-installed callout function, or nullptr if not set.

Definition at line 198 of file kernel.h.

◆ GetThreadCreateCallout()

static ThreadCreateCallout Mark3::Kernel::GetThreadCreateCallout ( )
inlinestatic

GetThreadCreateCallout Return the current function called on every Thread::Init();.

Returns
Pointer to the currently-installed callout function, or nullptr if not set.

Definition at line 178 of file kernel.h.

◆ GetThreadExitCallout()

static ThreadExitCallout Mark3::Kernel::GetThreadExitCallout ( )
inlinestatic

GetThreadExitCallout Return the current function called on every Thread::Exit();.

Returns
Pointer to the currently-installed callout function, or nullptr if not set.

Definition at line 188 of file kernel.h.

◆ GetTicks()

uint32_t Mark3::Kernel::GetTicks ( )
static
Examples:
lab9_dynamic_threads/main.cpp.

Definition at line 90 of file kernel.cpp.

◆ Init()

void Mark3::Kernel::Init ( void  )
static

Kernel Initialization Function, call before any other OS function.

Initializes all global resources used by the operating system. This must be called before any other kernel function is invoked.

Examples:
lab10_notifications/main.cpp, lab11_mailboxes/main.cpp, lab1_kernel_setup/main.cpp, lab2_coroutines/main.cpp, lab3_round_robin/main.cpp, lab4_semaphores/main.cpp, lab5_mutexes/main.cpp, lab6_timers/main.cpp, lab7_events/main.cpp, lab8_messages/main.cpp, and lab9_dynamic_threads/main.cpp.

Definition at line 44 of file kernel.cpp.

◆ IsPanic()

static bool Mark3::Kernel::IsPanic ( )
inlinestatic

IsPanic Returns whether or not the kernel is in a panic state.

Returns
Whether or not the kernel is in a panic state

Definition at line 99 of file kernel.h.

◆ IsStarted()

static bool Mark3::Kernel::IsStarted ( )
inlinestatic

IsStarted.

Returns
Whether or not the kernel has started - true = running, false = not started

Definition at line 86 of file kernel.h.

◆ Panic()

void Mark3::Kernel::Panic ( uint16_t  u16Cause_)
static

Panic Cause the kernel to enter its panic state.

Parameters
u16Cause_Reason for the kernel panic

Definition at line 70 of file kernel.cpp.

◆ SetDebugPrintFunction()

static void Mark3::Kernel::SetDebugPrintFunction ( DebugPrintFunction  pfPrintFunction_)
inlinestatic

SetDebugPrintFunction Set the function to be used when printing kernel debug information.

Parameters
pfPrintFunction_Function used to print kernel debug message strings
Examples:
lab10_notifications/main.cpp, lab11_mailboxes/main.cpp, lab1_kernel_setup/main.cpp, lab2_coroutines/main.cpp, lab3_round_robin/main.cpp, lab4_semaphores/main.cpp, lab5_mutexes/main.cpp, lab6_timers/main.cpp, lab7_events/main.cpp, lab8_messages/main.cpp, and lab9_dynamic_threads/main.cpp.

Definition at line 155 of file kernel.h.

◆ SetPanic()

static void Mark3::Kernel::SetPanic ( PanicFunc  pfPanic_)
inlinestatic

SetPanic Set a function to be called when a kernel panic occurs, giving the user to determine the behavior when a catastrophic failure is observed.

Parameters
pfPanic_Panic function pointer

Definition at line 94 of file kernel.h.

◆ SetStackGuardThreshold()

static void Mark3::Kernel::SetStackGuardThreshold ( uint16_t  u16Threshold_)
inlinestatic

Definition at line 201 of file kernel.h.

◆ SetThreadContextSwitchCallout()

static void Mark3::Kernel::SetThreadContextSwitchCallout ( ThreadContextCallout  pfContext_)
inlinestatic

SetThreadContextSwitchCallout Set a function to be called on each context switch.

A callout is only executed if this method has been called to set a valid handler function.

Parameters
pfContext_Pointer to a function to call on context switch
Examples:
lab9_dynamic_threads/main.cpp.

Definition at line 143 of file kernel.h.

◆ SetThreadCreateCallout()

static void Mark3::Kernel::SetThreadCreateCallout ( ThreadCreateCallout  pfCreate_)
inlinestatic

SetThreadCreateCallout Set a function to be called on creation of a new thread. This callout is executed on the successful completion of a Thread::Init() call. A callout is only executed if this method has been called to set a valid handler function.

Parameters
pfCreate_Pointer to a function to call on thread creation
Examples:
lab9_dynamic_threads/main.cpp.

Definition at line 116 of file kernel.h.

◆ SetThreadExitCallout()

static void Mark3::Kernel::SetThreadExitCallout ( ThreadExitCallout  pfExit_)
inlinestatic

SetThreadExitCallout Set a function to be called on thread exit. This callout is executed from the beginning of Thread::Exit().

A callout is only executed if this method has been called to set a valid handler function.

Parameters
pfExit_Pointer to a function to call on thread exit
Examples:
lab9_dynamic_threads/main.cpp.

Definition at line 130 of file kernel.h.

◆ Start()

void Mark3::Kernel::Start ( )
static

Start the operating system kernel - the current execution context is cancelled, all kernel services are started, and the processor resumes execution at the entrypoint for the highest-priority thread.

You must have at least one thread added to the kernel before calling this function, otherwise the behavior is undefined. The exception to this is if the system is configured to use the threadless idle hook, in which case the kernel is allowed to run without any ready threads.

Examples:
lab10_notifications/main.cpp, lab11_mailboxes/main.cpp, lab1_kernel_setup/main.cpp, lab2_coroutines/main.cpp, lab3_round_robin/main.cpp, lab4_semaphores/main.cpp, lab5_mutexes/main.cpp, lab6_timers/main.cpp, lab7_events/main.cpp, lab8_messages/main.cpp, and lab9_dynamic_threads/main.cpp.

Definition at line 58 of file kernel.cpp.

◆ Tick()

static void Mark3::Kernel::Tick ( )
inlinestatic

Definition at line 205 of file kernel.h.

Member Data Documentation

◆ m_bIsPanic

bool Mark3::Kernel::m_bIsPanic
staticprivate

true if kernel is in panic state, false otherwise

Definition at line 210 of file kernel.h.

◆ m_bIsStarted

bool Mark3::Kernel::m_bIsStarted
staticprivate

true if kernel is running, false otherwise

Definition at line 209 of file kernel.h.

◆ m_pfDebugPrintFunction

DebugPrintFunction Mark3::Kernel::m_pfDebugPrintFunction
staticprivate

Function to call to print debug info.

Function to call when printing debug info.

Definition at line 222 of file kernel.h.

◆ m_pfPanic

PanicFunc Mark3::Kernel::m_pfPanic
staticprivate

set panic function

Definition at line 211 of file kernel.h.

◆ m_pfThreadContextCallout

ThreadContextCallout Mark3::Kernel::m_pfThreadContextCallout
staticprivate

Function to call on context switch.

Definition at line 220 of file kernel.h.

◆ m_pfThreadCreateCallout

ThreadCreateCallout Mark3::Kernel::m_pfThreadCreateCallout
staticprivate

Function to call on thread creation.

Definition at line 214 of file kernel.h.

◆ m_pfThreadExitCallout

ThreadExitCallout Mark3::Kernel::m_pfThreadExitCallout
staticprivate

Function to call on thread exit.

Definition at line 217 of file kernel.h.

◆ m_u16GuardThreshold

uint16_t Mark3::Kernel::m_u16GuardThreshold
staticprivate

Definition at line 224 of file kernel.h.

◆ m_u32Ticks

uint32_t Mark3::Kernel::m_u32Ticks
staticprivate

Definition at line 226 of file kernel.h.


The documentation for this class was generated from the following files: