AutosarOS
OS.c File Reference

Implementation of operating system control functions. More...

#include "OS.h"
#include "assert.h"
#include "context.h"
#include "Task.h"
#include "Resource.h"
#include "ScheduleTables.h"
#include "Alarm.h"
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/atomic.h>
Include dependency graph for OS.c:

Go to the source code of this file.

Functions

void OS_StartOS (AppModeType mode)
 Start operating system. More...
 
void OS_ShutdownOS (StatusType error)
 Shutdown operating system. More...
 
void __attribute__ ((naked))
 Task switch. More...
 
void OS_Switch (void)
 Switch to new task. More...
 
void OS_EnableAllInterrupts (void)
 Enable all interrupts. More...
 
void OS_DisableAllInterrupts (void)
 Disable all interrupts. More...
 
void OS_ResumeAllInterrupts (void)
 Resume all interrupts. More...
 
void OS_SuspendAllInterrupts (void)
 Suspend all interrupts. More...
 
void OS_ResumeOSInterrupts (void)
 Resume OS interrupts. More...
 
void OS_SuspendOSInterrupts (void)
 Suspend OS interrupts. More...
 
AppModeType OS_GetActiveApplicationMode (void)
 Get currently active application mode. More...
 
void OS_ProtectionHookInternal (StatusType error)
 Internal function for protection hook handling. More...
 
void OS_ShutdownOSStackOverrun (void)
 Call OS_ShutdownOS() with E_OS_STACKFAULT. More...
 

Variables

uint8_t *volatile * ptrCurrentStack
 Stack-Pointer saved in current task control block. More...
 
pTaskFxn ptrCurrentFxnAddr
 Function pointer to current task function. More...
 

Detailed Description

Implementation of operating system control functions.

Date
2019-09-02
Author
Pascal Romahn

Definition in file OS.c.

Function Documentation

◆ __attribute__()

void __attribute__ ( (naked)  )

Task switch.

This function performs the actual scheduling. It selects a new task to be executed and switches the current context accordingly. It should not be called directly and instead be used with OS_Schedule().

Definition at line 143 of file OS.c.

Here is the call graph for this function:

◆ OS_DisableAllInterrupts()

void OS_DisableAllInterrupts ( void  )
inline

Disable all interrupts.

This service disables all interrupts. It is the counterpart to OS_EnableAllInterrupts().

Nesting is not supported by this call.

Definition at line 256 of file OS.c.

Here is the caller graph for this function:

◆ OS_EnableAllInterrupts()

void OS_EnableAllInterrupts ( void  )
inline

Enable all interrupts.

This service enables all interrupts. It is the counterpart to OS_DisableAllInterrupts().

Nesting is not supported by this call.

Definition at line 251 of file OS.c.

Here is the caller graph for this function:

◆ OS_GetActiveApplicationMode()

AppModeType OS_GetActiveApplicationMode ( void  )

Get currently active application mode.

Returns
Current application mode

Definition at line 303 of file OS.c.

◆ OS_ProtectionHookInternal()

void OS_ProtectionHookInternal ( StatusType  error)

Internal function for protection hook handling.

This function is called when a protection error is detected. It will call the configured protection hook if available and handle its return value.

Parameters
errorType of error that triggered the protection hook

Definition at line 310 of file OS.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OS_ResumeAllInterrupts()

void OS_ResumeAllInterrupts ( void  )

Resume all interrupts.

This service resumes all interrupts disabled by the previous call to OS_SuspendAllInterrupts().

Nesting is supported by this call.

Definition at line 261 of file OS.c.

◆ OS_ResumeOSInterrupts()

void OS_ResumeOSInterrupts ( void  )

Resume OS interrupts.

This service resumes OS interrupts disabled by the privious call to OS_SuspendOSInterrupts().

Nesting is supported by this call.

Note
Because of hardware limitations there is no difference between this function and OS_ResumeAllInterrupts(). However the correct counterpart must be used.
Warning
Nesting is only supported up to 8 levels!

Definition at line 282 of file OS.c.

◆ OS_ShutdownOS()

void OS_ShutdownOS ( StatusType  error)

Shutdown operating system.

This service shuts down the operating system and does not return. If a ShutdownHook is configured it will be called before the system is terminated.

Parameters
errorError occurred

Definition at line 128 of file OS.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OS_ShutdownOSStackOverrun()

void OS_ShutdownOSStackOverrun ( void  )

Call OS_ShutdownOS() with E_OS_STACKFAULT.

This function will simply call OS_ShutdownOS() with E_OS_STACKFAULT. This is mainly used to simplify the function call from the the sysTick timer ISR.

Definition at line 391 of file OS.c.

Here is the call graph for this function:

◆ OS_StartOS()

void OS_StartOS ( AppModeType  mode)

Start operating system.

This service starts the operating system in the specified application mode. The default application mode is OSDEFAULTAPPMODE.

Note
Calls to this functions are only allowed outside of the operating system. This call does not return.
This implementation only supports the default mode.
Parameters
modeApplication mode

Definition at line 91 of file OS.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OS_SuspendAllInterrupts()

void OS_SuspendAllInterrupts ( void  )

Suspend all interrupts.

This service suspends all interrupts. It is the counterpart to OS_ResumeAllInterrupts().

Nesting is supported by this call

Definition at line 273 of file OS.c.

◆ OS_SuspendOSInterrupts()

void OS_SuspendOSInterrupts ( void  )

Suspend OS interrupts.

This service suspends all OS interrupts. It is the counterpart to OS_ResumeOSInterrupts().

Nesting is supported by this call.

Note
Because of hardware limitation there is no difference between this function and OS_SuspendAllInterrupts(). However the correct counterpart must be used.
Warning
Nesting is only supported up to 8 levels!

Definition at line 294 of file OS.c.

◆ OS_Switch()

void OS_Switch ( void  )

Switch to new task.

Select the task with the highest priority that is ready and change the state for the context switch.

Definition at line 233 of file OS.c.

Here is the caller graph for this function:

Variable Documentation

◆ ptrCurrentFxnAddr

pTaskFxn ptrCurrentFxnAddr

Function pointer to current task function.

Definition at line 66 of file OS.c.

◆ ptrCurrentStack

uint8_t* volatile* ptrCurrentStack

Stack-Pointer saved in current task control block.

Definition at line 61 of file OS.c.