AutosarOS
OS.h File Reference

Operating system control. More...

#include "Types.h"
#include "OCB.h"
#include <stdbool.h>
Include dependency graph for OS.h:
This graph shows which files directly or indirectly include this file:

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 OS_Schedule (void)
 Schedule task. More...
 
void __attribute__ ((naked)) OS_ScheduleC(void)
 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...
 
void PreTaskHook (void)
 PreTask hook function. More...
 
void PostTaskHook (void)
 PostTask hook function. More...
 
void ErrorHook (StatusType error)
 PostTask hook function. More...
 
ProtectionReturnType ProtectionHook (StatusType fatalError)
 ProtectionHook function. More...
 

Detailed Description

Operating system control.

Date
2019-09-02
Author
Pascal Romahn

Definition in file OS.h.

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:

◆ ErrorHook()

void ErrorHook ( StatusType  error)

PostTask hook function.

This hook function is called when a system service return StatusType not equal E_OK.

Warning
This function is executed with interrupts disabled and must not activate them!
Parameters
errorError that caused the ErrorHook to be called.

Definition at line 784 of file App.c.

◆ 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_Schedule()

void OS_Schedule ( void  )

Schedule task.

This function calls OS_ScheduleC() unless scheduling is currently blocked. This is basically the entry point to the scheduler and should be called if scheduling is required or wanted.

Here is the caller graph for this function:

◆ 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:

◆ PostTaskHook()

void PostTaskHook ( void  )

PostTask hook function.

This hook function is called before a task leaves the running state but before a new task is selected. The ID of the task can be evaluated using OS_GetTaskID().

Warning
This function is executed with interrupts disabled and must not activate them!

Definition at line 776 of file App.c.

Here is the caller graph for this function:

◆ PreTaskHook()

void PreTaskHook ( void  )

PreTask hook function.

This hook function is called after a new task has entered the running state but before it is executed. The ID of the task can be evaluated using OS_GetTaskID().

Warning
This function is executed with interrupts disabled and must not activate them!

Definition at line 768 of file App.c.

Here is the caller graph for this function:

◆ ProtectionHook()

ProtectionReturnType ProtectionHook ( StatusType  fatalError)

ProtectionHook function.

This hook function is called when an error is detected by the protection facilities (e.g. stack monitoring).

Warning
This function is executed with interrupts disabled and must not activate them!
Parameters
fatalErrorType of error that triggered the protection hook
Returns
Action the OS shall take after the protection hook

Definition at line 797 of file App.c.

Here is the caller graph for this function: