GeMRTOS
Functions
grtos_kernel.c File Reference

GRTOS Kernal functions. More...

Go to the source code of this file.

Detailed Description

GRTOS Kernal functions.

Author
Ricardo Cayssials

This file contains the Kernal functions.

Version
0.9a
Date
2015-2020
Bug:
None known
Warning
This product was produced by Ricardo Cayssials in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
DISCLAIMER OF WARRANTY. THIS PRODUCT IS LICENSED "AS IS." YOU BEAR THE RISK OF USING IT.
RICARDO CAYSSIALS GIVES NO EXPRESS WARRANTIES, GUARANTEES, OR CONDITIONS. TO THE EXTENT PERMITTED UNDER APPLICABLE LAWS, RICARDO CAYSSIALS EXCLUDES ALL IMPLIED WARRANTIES, INCLUDING MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.

Definition in file grtos_kernel.c.

Function Documentation

◆ gk_ENTRY_BAD_TASK_RETURN()

void gk_ENTRY_BAD_TASK_RETURN ( void  )

BAD RETURN FUNCTION IN TASK STACK.

gk_ENTRY_BAD_TASK_RETURN

THIS IS THE RETURN ADDRESS WHEN A BAD RETURN IS EXECUTED IN A TASK SWITCH

Todo:
implement a safe rescate of the system

Definition at line 294 of file grtos_kernel.c.

◆ gk_ENTRY_IRQ_HANDLER()

void gk_ENTRY_IRQ_HANDLER ( void  )

Executes the ISR of GRTOS.

gk_ENTRY_IRQ_HANDLER

This routine is executed each time processor is interrupted

Disable processor interrupt

Remove pending interrupt of current processor

Get into critical section

Time Event happened

An External IRQ happened: IRQ = event_code, IRQ index = event_code - 1

Definition at line 186 of file grtos_kernel.c.

◆ gk_ENTRY_SIGNAL_RETURN()

void gk_ENTRY_SIGNAL_RETURN ( void  )

Return from Signal:

gk_ENTRY_SIGNAL_RETURN

Get critical section and return to GRTOS_Return_from_Signal in grtos_switch.S file

Get into critical section

Definition at line 308 of file grtos_kernel.c.

◆ gk_INIT_KERNEL()

void gk_INIT_KERNEL ( void  )

Routine execute BEFORE the main() function, ONLY by PROCESSOR 1.

gk_INIT_KERNEL

Processors with ID different from 1 start in different reset vector. The gk_START_KERNEL() function is executed AFTER the main() function Initialises all the structures to start the GRTOS

Todo:

Modify to allow executing with normal drivers instead of reduced ones

use alt_dcache_flush_all(); after mutex to flush cache

See also
gk_START_KERNEL

INITIALIZE THE KCB STRUCTURE

Init GLOBAL VARIABLES (used in grtos_switch.S code)

INITIALIZE THE TIMED EVENT LIST

Set the Next Occurence time equal to G_LATEST_TIME (is g_kcb.KCB_NextECBTL->ECBValue.i64)

Link an ECB with the latest time

Initialize Processor Structures creating IDLE TCBs

!!! Set error NO_FREE_GS_TCB

Definition at line 552 of file grtos_kernel.c.

◆ gk_KERNEL_TASK_COMPLETE()

void gk_KERNEL_TASK_COMPLETE ( void  )

This function is executed when a task finishes its execution.

gk_KERNEL_TASK_COMPLETE

Enter in Critial Section

Restore TCB to waiting list

If task is an ISR, then enable it for next request

Todo:
Check if IRQ is enabled when all ISR are complete

Get the Next Priority to run in the current processor

Definition at line 411 of file grtos_kernel.c.

◆ gk_KERNEL_TASK_START()

void gk_KERNEL_TASK_START ( void  )

Start the execution of the tasks of the system.

gk_KERNEL_TASK_START

Get the Next TCB to run in the current processor

Change State to Running

Enable Processor Interrupt

Definition at line 352 of file grtos_kernel.c.

◆ gk_KERNEL_TASK_SUSPEND()

void gk_KERNEL_TASK_SUSPEND ( GS_TCB ptcb)

Suspends the execution of the task pointed by ptcb.

gk_KERNEL_TASK_SUSPEND

Parameters
[in]ptcbPOinter to the TCB of the task to suspend

Stop the processor triggering its interrupt

Definition at line 470 of file grtos_kernel.c.

◆ gk_KERNEL_TASK_SUSPEND_CURRENT()

void gk_KERNEL_TASK_SUSPEND_CURRENT ( void  )

Suspends the execution of the current task and switch to Highest Priority Task.

gk_KERNEL_TASK_SUSPEND_CURRENT

Definition at line 502 of file grtos_kernel.c.

◆ OPTIMEZE_CODE()

OPTIMEZE_CODE ( )
related

GRTOS RESET FUNCTIONS FOR NOT ID=1 PROCESSORS.

gk_ENTRY_RST_HANDLER

This is executed when processor with ID != 1 are reset. A different stack is assigned to each processor in the grtos_start_rest_of_processors function in the rstaux section

Called from grtos_start_rest_of_processors

Disable processor interrupt

Disable the interrupts

Enter in Critial Section

Include the processor in the GRTOS

Definition at line 39 of file grtos_kernel.c.