Go to the documentation of this file.
31 #ifndef GEMRTOS_CORE_H_
32 #define GEMRTOS_CORE_H_
61 typedef unsigned long long INT64;
129 #define GS_ECBState_GRANTED_RESOURCE 1u
130 #define GS_ECBState_WAITING_RESOURCE 2u
131 #define GS_ECBState_FREE 3u
132 #define GS_ECBState_WAITING_TIME 4u
133 #define GS_ECBState_UNLINKED 5u
135 #define G_ECBType_OSTimeDly 21u
137 #define G_ECBType_PERIODIC 22u
138 #define G_ECBType_LASTEST_TIME 23u
139 #define G_ECBType_TIMEOUT_SEM_GRANTED 24u
140 #define G_ECBType_TIMEOUT_SEM_WAITING 25u
141 #define G_ECBType_SEM_GRANTED 28u
142 #define G_ECBType_SEM_WAITING 29u
143 #define G_ECBType_NOT_SPECIFIED 30u
144 #define G_ECBType_QUEUE_CONSUME 31u
145 #define G_ECBType_MESSAGE_CONSUME_WAIT 33u
146 #define G_ECBType_MESSAGE_CONSUME_EXPIRED 34u
147 #define G_ECBType_MESSAGE_SEND_EXPIRED 35u
148 #define G_ECBType_MESSAGE_SEND_WAIT 36u
223 #define GS_LCBState_LINKED 1u
224 #define GS_LCBState_UNLINKED 2u
226 #define GS_LCBType_UNSPECIFIED 2u
227 //*************************************************************************************************
251 #define GS_PCBState_NOTRUNNING 1u
252 #define GS_PCBState_RUNNING 2u
253 #define GS_PCBState_FREE 3u
255 #define GS_PCBType_UNSPECIFIED 1u
288 #define GK_MCBState_UNLINKED 2u
289 #define GK_MCBState_FREE 3u
290 #define GK_MCBState_LINKED 4u
334 #define GK_RCBState_SEM 3u
335 #define GK_RCBState_MQ 4u
336 #define GK_RCBState_UNDEFINED 5u
337 #define GK_RCBState_QUEUE 6u
339 #define GK_RCBType_UNUSED 1u
341 #define GK_RCBType_FREE 2u
342 #define GK_RCBType_SEM 3u
343 #define GK_RCBType_MQ 4u
344 #define GK_RCBType_QUEUE 5u
412 #define G_SCBState_FREE 1u
413 #define G_SCBState_IN_KCB 2u
414 #define G_SCBState_IN_ECB 3u
415 #define G_SCBState_IN_TCB 4u
416 #define G_SCBState_IN_RCB 5u
417 #define G_SCBState_IN_PCB 6u
418 #define G_SCBState_IN_LCB 7u
419 #define G_SCBState_UNLINKED 8u
420 #define G_SCBState_PENDING 9u
421 #define G_SCBState_EXECUTING 10u
426 #define G_SCBType_TCB_ABORTED 1000u
475 #define GRTOS_TASK_STATE_WAITING(ptcb) ((ptcb->TCBState >> 1) & 1)
477 #define G_TCBState_WAITING_COMPLETED 2u
478 #define G_TCBState_WAITING 258u
479 #define G_TCBState_READY 4u
480 #define G_TCBState_RUNNING 8u
481 #define G_TCBState_FREE 16u
482 #define G_TCBState_UNLINKED 32u
486 #define G_TCBType_UCOS 1u
487 #define G_TCBType_PERIODIC 2u
488 #define G_TCBType_ISR 4u
489 #define G_TCBType_IDLE 5u
490 #define G_TCBType_UNDEFINED 7u
529 extern FILE*
fpuart[G_NUMBER_OF_PCB];
637 INT64 waiting_priority,
638 INT64 RCBGrantedPriority,
639 INT64 RCBWaitingTimeout,
640 INT64 RCBGrantedTimeout);
723 unsigned int StkSize,
791 unsigned int StkSize);
struct gs_pcb* PCB_PrevPCB
Pointer to the previous free processor.
struct gs_ecb* ECB_NextECBAEL
Pointer to the event associated with this (ie timeout)
INT32 ECB_IsValid(GS_ECB *pevent)
Returns G_TRUE is pointer points to ECB.
INT32 gu_TASK_Sleep(INT32 hours, INT32 minutes, INT32 seconds, INT32 ms)
Sleeps the current task the interval specified.
GS_TCB* gk_CreateTask(void *TaskCode, void *p_arg, void *StkBotton, unsigned int StkSize, unsigned int TCBType, INT64 TCBReadyPriority, INT64 TCBRunPriority, INT64 TCBDeadline, INT64 TCBPeriod, GS_LCB *TCB_RDY_LCB_Index, int TCB_Abort_w_Deadline, INT64 TCBInherPriority, int TCB_INTNumber)
Kernel Function: creates a new task initializing TCB features.
INT64 i64 __attribute__((aligned(4)))
struct gs_pcb* PCB_NextPCB
Pointer to the next free processor.
INT32 ECBState
Granted, Waiting, Free.
void* SCB_TaskCode
Pointer to the code of the signal.
struct gs_rrds* RRDS_NextRRDS
Pointer to the next RRDS structure
GS_RRDS* gk_RRDS_GetFree(void)
Gets the pointer of a free RRDS from the free list.
INT32 gk_TASK_RESOURCE_UNWAIT(G_RCB *presource, GS_ECB *pevent)
Unlinks the ECB waiting and timed set for waiting a semaphore.
INT32 gu_TASK_SUSPEND(GS_TCB *ptcb)
Change to waiting the state of a task.
INT32 gu_SetTaskType(struct gs_tcb *ptcb, unsigned int type)
Set the type of a task.
volatile INT32 GRTOS_MutexReleaseRegisterAddress
INT32 gk_LCB_CheckInvertion(void)
Checks if there is a processor that has to be interrupted to switch task and interruupt it all.
struct gs_lcb* LCB_PrevLCBL
Pointer to the next list ordered by priority.
volatile int G_DEBUG_SAMPLE_END_ENABLE
INT32 gk_Create_PCBs(int Nmbr_PCB)
Reservs system memory to store the Processor Control Blocks of the system (PCB)
INT32 gk_TCBASL_Link(GS_TCB *ptcb, GS_SCB *psignal)
Links SCB to TCB Associated Signal List.
GS_SCB* gk_TCBPSL_GetSCB(GS_TCB *ptcb, INT32 SignalType)
Returns pointer to the SCB in te TCBPSL.
struct gs_tcb* TCB_PrevTCB
Pointer to previous TCB in the TCB list.
void gk_KERNEL_TASK_SUSPEND(GS_TCB *ptcb)
Suspends the execution of the task pointed by ptcb.
INT32 gk_TCB_Unlink(GS_TCB *ptcb)
Unlinks the TCB according to the list it is linked.
GRTOS Message queue definitions.
volatile INT64 G_TASK_PRIORITY_DEFAULT
INT32 gu_get_irq_status(void)
Return the status of the system IRQs.
INT32 SCBState
STATE of the signal.
volatile int G_DEBUG_SAMPLE_BEGIN_ENABLE
volatile INT32 gs_sizeof_G_PCBTbl
INT32 gk_TCBAEL_Link(GS_ECB *pevent, GS_TCB *ptcb)
Links an ECB to the associated ECB list of TCB.
struct gs_tcb* PCB_EXECTCB
Current task assigned to processor.
TIMEPRIORITY RCBGrantedPriority
Lowest Priority of Current Granted Task.
struct gs_pcb* LCB_NextLCBFPL
Next free processor for this list.
unsigned int BLOCK_HASH
BLOCK_HASH of the TCB: (GS_TCB *) + 1.
INT32 ECBType
Type of event control block.
INT32 gu_SetTaskAbortwhenDeadline(struct gs_tcb *ptcb, unsigned int abort_when_deadline)
Set if task should be aborted when misses a deadline.
struct gs_lcb* KCB_ROOT_LCBs
pointer to the first LCB structure. Used for debugging purposes.
INT32 IsAListorNull(GS_LCB *plcb)
INT32 gu_Set_Default_Task_List(GS_LCB *list)
Set the default list number for task created afterwards.
INT32 gu_TASK_Kill(GS_TCB *ptcb)
The task is eliminated and all the structures involved are return to the free lists.
struct gs_lcb* TCB_RDY_LCB_Index
pointer to the ready list that should be inserted
unsigned long long gt_time
INT32 gk_TASK_RESOURCE_GRANT(G_RCB *presource, GS_ECB *pevent)
Sets the granted and timed events when a semaphore is granted to a TCB.
INT32 gu_TASK_IS_BLOCKED(GS_TCB *ptcb)
Return G_TRUE if task is waiting for a resource, G_FALSE otherwise.
volatile GS_LCB* G_TASK_LCB_DEFAULT
struct T_QUEUE_RESOURCE queue
is the queue resource, defined in mq.h
void gk_ECBASL_Link(GS_ECB *pevent, GS_SCB *psignal)
Links a SCB to the ECB Associated Signal List.
INT32 gk_RCBASL_Link(G_RCB *presource, GS_SCB *psignal)
Links a signal SCB to the resource RCB Associated Signal List.
G_RCB* gk_RCB_GetFree(void)
Unlinks an RCB from the RCBFL list and returns its pointer or NULL if no free RCB is available.
struct gs_rrds* RRDS_NEXT_RRDSs
Fields for debugging.
INT32 gu_Set_Default_Task_Type(unsigned int type)
gu_Set_Default_Task_Type(unsigned int type) Set the default type of the task created.
INT32 gu_get_reserved_mutex_processor(void)
INT32 gk_TCBAEL_Unlink(GS_ECB *pevent)
Unlinks the ECB from the associated TCB.
void gk_KERNEL_TASK_START(void)
Start the execution of the tasks of the system.
INT32 gu_TASK_RESUME(GS_TCB *ptcb)
Resume a task that it is in waiting state.
gt_time gu_Convert_Time(INT32 days, INT32 hours, INT32 minutes, INT32 seconds, INT32 ms)
Convert days,hours, minutes, seconds and miliseconds to system time unit.
INT32 LCB_IsValid(GS_LCB *plcb)
GRTOS Semaphore definitions.
INT32 gk_KCBASL_Unlink(GS_SCB *psignal)
Unlinks a SCG from the Associated Signal list of KCB.
BUFFER CONTROL BLOCK FOR UNION WITH RRDS STRUCT.
unsigned long long gt_priority
GS_SCB* gk_SCB_GetFree(void)
Unlinks a SCB from free list and return its pointer.
INT32 gk_TCBLowerPriorityThanTCB(GS_TCB *ptcb1, GS_TCB *ptcb2)
Return G_TRUE if current priority of ptct1 is greater than the current priority of ptcb2,...
INT32 gk_LCBLowerPriorityThanLCB(GS_LCB *plcb1, GS_LCB *plcb2)
Return G_TRUE if plct1 is greater than plcb2, otherwise returns G_FALSE.
INT32 SCBPriority
Priority of the SCB when it is linked.
void* TCB_TaskCode
Pointer to the Task Code.
INT32 LCBState
State of the List Control Block.
INT64 TCBInherPriority
Priority Inhered by granted resource.
INT32 RCBState
State of the Resource.
void gk_KERNEL_TASK_SUSPEND_CURRENT(void)
Suspends the execution of the current task and switch to Highest Priority Task.
GS_SCB* gk_RCBASL_GetSCB(G_RCB *prcb, INT32 SignalType)
Returns the pointer to the SCB of a resource or NULL otherwise.
INT32 gk_LCBFPL_Unlink(int processorID)
Unlinks a PCB from the LCB Free Processor List.
GS_ECB* gk_TCB_in_RCBGEL(G_RCB *presource, GS_TCB *ptcb)
Returns the event of the TCB that grants the resource.
struct gs_ecb* KCB_NextECBTL
Pointer to EVENT LIST of the Next Absolute Time.
gt_time gu_get_mutex_time(void)
Return the time the mutex is granted in system time units.
GS_STK* TCB_StackTop
Botton Stack of the Task.
struct gs_rrds* KCB_ROOT_RRDSs
pointer to the first RRDS structure. Used for debugging purposes.
unsigned int BLOCK_HASH
BLOCK_HASH of the RRDS: (GS_RRDS *) + 5.
volatile INT32 GRTOS_InterruptEnableRegisterAddress
GS_ECB* gk_Get_ECB(void)
Core functions definitions.
void gk_RCBWEL_Unlink(GS_ECB *pevent)
Unlinks ECB from RCB waiting list.
volatile void* gs_addressof_G_PCBTbl
struct gs_scb* SCB_NextSCB
Pointer to the next SCB linked.
struct gs_scb* SCB_NEXT_SCBs
Fields for debugging.
struct gs_tcb* LCB_NextTCBRUNL
Pointer to the TCB list of running tasks.
INT32 gk_TASK_PRIORITY_SET(GS_TCB *ptcb, INT32 task_state)
Computes the current priority of the task.
INT32 gk_LCBL_Link(GS_LCB *plcb)
Inserts a RunList in LCB Runining list ordered by background list and then priority.
INT32 gk_ECBAEL_Link(GS_ECB *pevent1, GS_ECB *pevent2)
struct gs_lcb* LCB_NEXT_LCBs
Fields for debugging.
void gu_Set_Default_Task_Period(INT32 hours, INT32 minutes, INT32 seconds, INT32 ms)
Set the default periodo for task created afterwards.
struct gs_tcb* KCB_ROOT_TCBs
roots for linked list of data structures
GS_ECB Event Control Block structure.
INT32 KCB_NUMBER_OF_PCBs
Number of PCB in the system.
INT32 KCB_NUMBER_OF_RCBs
Number of RCB in the system.
struct gs_scb* KCB_NextKCBASL
Pointer to Signal Associated List for KCB.
struct gs_mcb* MCB_PrevMCB
void* malloc_address
Pointer memory address of the malloc block
INT32 ECBState_Valid(unsigned int ecbstate)
void gk_RST_MONITOR_HANDLER(void)
struct gs_lcb* LCB_PREV_LCBs
Pointer to previous LCB structure. Used for debugging purposes.
INT32 RRDS_IsValid(GS_RRDS *prrds)
Returns G_TRUE is pointer points to GS_RRDS.
void grtos_irq_entry(void)
INT32 gu_StartTaskwithOffset(struct gs_tcb *ptcb, unsigned int hours, unsigned int minutes, unsigned int seconds, unsigned int ms)
Activates the execution of a task. An offset can be configured.
GS_LCB List Control Block.
GS_KCB Kernel Control Block structure.
void* TCB_TaskArg
Pointer to the argument of the first call.
volatile INT32* G_ISR_STACK
IDLE and ISR tasks.
void GRTOS_Task_GetPendingSCB(void)
Configures system to execute next pending signal. Call from switch routine.
int gu_Get_CPU_ID(void)
Returns the ID of the current processor.
INT32 gu_SetTaskReadyPriority(struct gs_tcb *ptcb, long long priority)
Set the ready priority of a task.
INT32 SCB_IsValid(GS_SCB *pscb)
Returns G_TRUE is pointer points to SCB.
INT32 gu_SetTaskISR(struct gs_tcb *ptcb, unsigned int irq_nbr)
Convert a task to a ISR associated to a Interrupt Number.
struct g_rgb t_message_resource
void gk_CODE_IDLE_TASK(void* pdata)
IDLE task. This code is executed when no task is ready. The processor is halted.
INT32 gk_TCBWL_Link(GS_TCB *ptcb, unsigned int state)
Links a TCB in the waiting list.
GS_SCB* gk_SCB_Copy(GS_SCB *psignal)
Returns a pointer to a SCB with same values that psignal. Used when an associated signal has to be co...
int PCBType
Type of the processor.
unsigned int BLOCK_HASH
BLOCK_HASH of the ECB: (GS_ECB *) + 2.
GS_TCB* gk_PCB_GetNextTCB(void)
Returns the next TCB to be executed by the current processor. If no task is requesting for execution,...
INT32 gk_TCBFL_Link(GS_TCB *ptcb)
Links a TCB to the Free TCB List removing associated and pending SCBs and ECBs.
INT32 gk_RRDSFL_Link(GS_RRDS *prrds)
Links a RRDS to the Free List.
gs_tcb Task Control Block (TCB) structure
INT32 gk_TCBRDYL_Unlink(GS_TCB *ptcb)
Unlinks the TCB from the Ready Task List.
GS_SCB Signal Control Block structure.
struct gs_ecb* TCB_NextTCBAEL
Pointer to linked list of waiting events of this task.
GS_PCB Processor Control Block.
unsigned int BLOCK_HASH
BLOCK_HASH of the LCB: (GS_LCB *) + 6.
INT32 gk_ISR_COMPLETE(GS_TCB *ptcb)
Executed when Task finishes as ISR. If remains ready, then it will be not released next Interrupt eve...
TIMEPRIORITY ECBValue
Occurrence Time of the event or Priority
INT32 gk_ECBASL_Unlink(GS_ECB *pevent, GS_SCB *psignal)
Unlinks a signal SCB from the ECB Associated Signal List of and event.
struct gs_scb* ECB_NextECBASL
Pointer to the Linked list of signals.
INT32 gk_SetTaskISR(struct gs_tcb *ptcb, unsigned int irq_nbr)
Convert a task to a ISR associated to a Interrupt Number in Kernal mode.
INT32 gk_TCBPSL_Unlink(GS_TCB *ptcb, GS_SCB *psignal)
Unlinks SCB from TCB Pending Signal List.
volatile GS_STK* G_IDLE_STACK
void gk_TIME_CALLBACK(GS_ECB *pevent)
This function is called when a time event happened. It has to resolve according the event type.
struct gs_ext_isr KCB_ExtISR [ALT_NIRQ] __attribute__((aligned(4)))
Pointers to ISR TCBs for each interrupt number.
INT64 LCBRunPriority
Current Priority (-1 PRIORITY THERE IS NO TASK RUNNING.
int* GRTOS_PROCESSOR_BASE __attribute__((aligned(4)))
INT32 gk_RCBASL_Unlink(G_RCB *presource, GS_SCB *psignal)
Unlinks a SCB of a signal from the RCB Associated Signal List of a resource.
struct gs_ecb* ECB_PrevECB
Pointer to linked list of waiting events of this event.
struct gs_ecb* ECB_NextECB
Pointer to linked list of waiting events of this event.
INT32 TCBState_Valid(unsigned int tcbstate)
INT32 KCB_NUMBER_OF_RRDSs
Number of RRDS in the system.
gt_priority G_EXT_ISR_Timeout
TIMEPRIORITY RCBWaitingTimeout
Default waiting timeout.
volatile GS_STK G_TCB_CURRENT
INT32 KCB_NUMBER_OF_ECBs
Number of ECB in the system.
INT32 gk_TCBWL_Unlink(GS_TCB *ptcb)
Unlinks the TCB from the waiting list.
TIMEPRIORITY RRDSGrantedTimeout
Timeout for granting the resource
struct g_rgb* RCB_NEXT_RCBs
Fields for debugging.
INT32 TCBType_Valid(unsigned int tcbtype)
volatile INT64 G_TASK_PERIOD_DEFAULT
unsigned int TCBState
STATE of the task.
INT32 gu_SetTaskDeadline(struct gs_tcb *ptcb, unsigned int hours, unsigned int minutes, unsigned int seconds, unsigned int ms)
Set the deadline of the task for the next invocation.
void GRTOS_Suspend_Task(void)
INT32 gk_TCBPSL_Link(GS_TCB *ptcb, GS_SCB *psignal)
Link a SCB to TCB Pending Signal List.
TIMEPRIORITY RRDSGrantedPriority
Priority for granting the resource
struct gs_scb* RRDS_NextSCB
Pointer to the Linked list of signals.
gt_time gu_Get_Next_Occurrence_Time(void)
Returns the Next Occurrence Time.
struct gs_ecb* ECB_PrevTCBAEL
Pointer to the previous event of the same task
INT64 TCBDeadline
Deadline of the task.
INT32 gk_TASK_IS_BLOCKED(GS_TCB *ptcb)
Returns G_TRUE when TCB is blocked waiting for a resource.
struct g_rcb* ECB_AssocRCB
Pointer to the resource associated with the event
INT32 gk_SCBAPSL_UnLink(GS_SCB *pscb_root, GS_SCB *pscb_pending)
Unlinks a pending signal from the root signal.
GS_TCB* gk_TCB_GetFree(void)
GS_ECB* gk_RCBWEL_Link(G_RCB *presource, GS_ECB *pevent)
Links an event ECB to the resource waiting list of RCB. If no ECB is given then a new ECB is obtained...
unsigned int TCB_AssocPCB
Processor assigned this task (0 is no assigned)
void* malloc_address
Pointer memory address of the malloc block
union timepriority TIMEPRIORITY
struct g_rgb* RCB_PREV_RCBs
Pointer to previous RCB structure. Used for debugging purposes.
INT32 RRDS_State
STATE of the RRDS.
INT32 gk_RRDSASL_UnLink(GS_RRDS *prrds, GS_SCB *psignal)
Unlinks SCB from RRDS Associated Signal List.
volatile INT32 G_TASK_TYPE_DEFAULT
volatile int G_IRQ_ENABLED
INT32 Check_list_TCBAEL_IsValid(int cycles)
GS_STK* TCB_StackBottom
Botton Stack of the Task.
void gk_ISR_RELEASE(int irq_nbr)
Executed when an interrupt is triggered. It is called from gk_ENTRY_IRQ_HANDLER()
struct gs_tcb* TCB_NEXT_TCBs
Fields for debugging.
TIMEPRIORITY RCBGrantedTimeout
Default granted timeout.
INT32 gk_TCBASL_Unlink(GS_TCB *ptcb, GS_SCB *psignal)
Unlinks SCB from a TCB Associated Signal List.
int TCB_INTNumber
IRQ number if it is a ISR TCB.
INT32 gk_ECB_List_Unlink(GS_ECB *pevent)
Unlinks all the structures linked to a ECB.
INT64 TCBCurrentPriority
Current priority of the task according it is ready or running.
void gk_INIT_IRQ(void)
Initializes the ISRs according the ISRs set by Nios HAL. It creates a TCB for each ISR and link it to...
struct gs_tcb* TCB_PrevISRTCB
Pointer to the previous TCB for the same ISR (when task is a ISR)
INT32 gu_SetTaskRunPriority(struct gs_tcb *ptcb, long long priority)
Set the run priority of a task.
struct g_rgb t_semaphore_resource
GS_SCB* gk_RRDSASL_GetSCB(GS_RRDS *prrds, INT32 SignalType)
Returns pointer to the SCB linked in the RRDSASL list.
volatile INT32 GRTOS_InterruptDisableRegisterAddress
gt_tm gu_Clock(gt_time ticks)
Convert to gt_tm structure a time in gt_time format (time in system time units)
INT32 gk_ECBTL_Link(GS_ECB *pevent)
Links the ECB from the Time Event List.
struct gs_mcb* MCB_NextMCB
TIMEPRIORITY RRDSWaitingTimeout
Timeout for waiting the resource
INT32 gu_SetTaskPeriod(struct gs_tcb *ptcb, unsigned int hours, unsigned int minutes, unsigned int seconds, unsigned int ms)
Set the task period for the next invocation.
INT32 gu_TASK_Sleep_Time(gt_time ticks)
Set event to sleep the current task for a certain number of clock ticks.
INT32 gk_TASK_RESOURCE_UNGRANT(G_RCB *presource, GS_ECB *pevent)
Unlinks the granted and timed events of a granted task.
INT32 gu_Get_Default_Task_List(void)
Return the current default list number.
INT32 SCBType
TYPE of the signal.
void* malloc_address
Pointer memory address of the malloc block
struct gs_tcb* TCB_PREV_TCBs
Pointer to previous TCB structure. Used for debugging purposes.
struct gs_ecb* KCB_ROOT_ECBs
pointer to the first ECB structure. Used for debugging purposes.
void gk_ENTRY_IRQ_HANDLER(void)
Executes the ISR of GRTOS.
struct T_QUEUE_RESOURCE queue
struct gs_mcb* MES_FirstMCB
INT32 gk_LCBFPL_Link(int processorID)
Links a PCB to the LCB Free Processor List of foreground list of the processor.
GS_TCB* gk_PCB_GetCurrentTCB(void)
Returns the task that the current processor was executing.
struct T_MESSAGE_RESOURCE message
is the message resource structure
GS_SCB* gk_KCBASL_GetSCB(INT32 SignalType)
Returns a pointer to the SCB linked to the KCBASL with the same SignalType.
struct g_rcb* KCB_ROOT_RCBs
pointer to the first RCB structure. Used for debugging purposes.
volatile INT32 gs_offsetof_PCB_IDLETCB
GS_LCB* gk_Get_LCB(void)
Creates a LCB and returns its pointer.
INT32 gu_SetTaskList(struct gs_tcb *ptcb, struct gs_lcb *plcb)
Set the list of a task.
TIMEPRIORITY RRDSWaitingPriority
Priority for waiting the resource
struct gs_tcb* LCB_NextTCBRDYL
Pointer to the TCB of the Highest Priority Task.
volatile INT32 gs_offsetof_PCB_EXECTCB
INT32 KCB_NUMBER_OF_TCBs
Pointer to PCBs dynamic array.
void* malloc_address
Pointer memory address of the malloc block
INT64 TCBReadyPriority
Priority of the Task when Ready.
INT32 gk_SetLowestProcessor(void)
Sets the Lowest Processor register in GRTOS Controller.
struct g_rcb* RCB_NextRCB
Pointer to link resources in free list.
struct gs_tcb* ECB_AssocTCB
Pointer to the task associated with the event
INT32 gk_TCBRUNL_Unlink(GS_TCB *ptcb)
Unlinks TCB from Running List.
void gu_Set_Default_Task_Priority(INT32 level, INT32 priority)
Set the default priority for task created afterwards. Priority is assigned with an INT32 level and an...
INT32 gk_TASK_RESOURCE_WAIT(G_RCB *presource, GS_ECB *pevent)
Sets the waiting and timed event for waiting the semaphore.
TIMEPRIORITY RCBPriority
Priority of the resource.
INT32 gk_TCBRDYL_Link(GS_TCB *ptcb)
Links the TCB in the Ready Task List sorted by its priority.
void gk_FROZEN_CALLBACK(void)
This function is called when a frozzen event happened.
struct gs_tcb* KCB_NextTCBWL
Pointer to the linked list of the TCB of Waiting Tasks.
int PCBState
State of the PCB : GS_FREE_PROCESSOR, GS_RUNNING_PROCESSOR.
INT32 gk_SetNextTimeProcessor(void)
Sets the Next Time Processor register in GRTOS Controller.
void* SCB_TaskArg
Pointer to the argument of the signal.
void* malloc_address
Pointer memory address of the malloc block
G_RCB Resource Request Data Structure.
struct gs_ecb* ECB_NEXT_ECBs
Fields for debugging.
int TCB_Abort_w_Deadline
True if task should be aborted when deadline, false otherwise.
INT32 gk_KCBASL_Link(GS_SCB *psignal)
Links a SCG to the Associated Signal list of KCB.
struct gs_tcb* TCB_NextISRTCB
Pointer to the next TCB for the same ISR (when task is a ISR)
GS_RRDS Resource Request Data Structure.
struct gs_ecb* ECB_NextTCBAEL
Pointer to the next event of the same task
struct gs_ecb* RCB_NextRCBWEL
Pointer to linked list of waiting events of this event.
INT32 gk_TASK_Kill(GS_TCB *ptcb)
Destroys a task and return the data structure to the TCB free list.
void gk_KERNEL_TASK_COMPLETE(void)
This function is executed when a task finishes its execution.
gt_time gu_get_frozen_threshold(void)
Returns the value in the frozen threshold register (R_FRZ_TM_THR)
struct gs_lcb* KCB_NextLCBL
Pointer to the lowest priority run list.
struct gs_mcb* MES_LastMCB
INT32 gk_TCB_List_Unlink(GS_TCB *ptcb)
Unlinks the TCB from events and signals and links them to the free lists respectively.
INT32 PCB_IsValid(GS_PCB *ppcb)
void gk_INIT_KERNEL(void)
Routine execute BEFORE the main() function, ONLY by PROCESSOR 1.
volatile INT32 G_SCB_PENDING
INT32 ECBType_Valid(unsigned int ecbtype)
INT32 gu_Get_Default_Task_Type(void)
Return the default type assigned to new tasks.
GS_SCB* gk_TCBASL_GetSCB(GS_TCB *ptcb, INT32 SignalType)
Returns the pointer to the SCB associated to a task, NULL otherwise.
INT64 gk_TASK_GRANTED_PRIORITY_GET(GS_TCB *ptcb)
Determine the priority of a taks according to the resources granted.
INT32 KCB_NUMBER_OF_LCBs
Number of LCB in the system.
volatile struct gs_tcb* TCB_NextTCB
Pointer to next TCB in the TCB list.
INT32 RCBCount
Counter for RCB.
void gk_RCBGEL_Unlink(GS_ECB *pevent)
Unlinks ECB from RCB granted list.
INT32 gk_TASK_STK_Init(GS_TCB *ptcb)
Initializes the Task Stack acording to the TCB parameters.
volatile INT32 G_SCB_CODE
struct gs_ecb* RCB_NextRCBGEL
Pointer to the linked highest priority event.
GS_ECB* gk_TASK_RESOURCE_CREATE(G_RCB *presource, GS_TCB *ptcb, INT64 waiting_priority, INT64 RCBGrantedPriority, INT64 RCBWaitingTimeout, INT64 RCBGrantedTimeout)
Creates the structure to sopport a resource from a task.
volatile INT32 GRTOS_MutexRequestRegisterAddress
INT32 gk_RCBFL_Link(G_RCB *presource)
Links the RCB of a resource to Free List.
unsigned int TCBType
TYPE of the task.
struct gs_lcb* LCB_NextLCBL
Pointer to the next list ordered by priority.
struct gs_ecb* ECB_PREV_ECBs
Pointer to previous TCB structure. Used for debugging purposes.
struct gs_scb* TCB_NextTCBPSL
Pointer to signals waiting to execute.
INT32 gk_ECBFL_Link(GS_ECB *pevent)
Link ECB to Free List. Removes the signals from ECB.
GS_STK* TCB_StackPointer
Pointer to current top of stack.
struct gs_rrds* ECB_RRDS
Pointer to the resource request structure or MCB.
void* gu_GetTask(void *TaskCode, void *p_arg, void *StkBotton, unsigned int StkSize)
Return a pointer to a TCB for a new task.
GS_SCB* gu_signal_create(INT32 Type, INT32 Priority, void *pxcb, void *Signal_Code, void *Signal_Arg)
Creates an associated SCB to a structure according to the Type.
INT32 KCB_NUMBER_OF_SCBs
Number of SCB in the system.
GS_RRDS* gk_Get_RRDS(void)
GS_ECB* gk_RCBGEL_Link(G_RCB *presource, GS_ECB *pevent)
Links ECB to RCB granted list and return pointer to the ECB linked.
struct gs_scb* SCB_NextSCBAPSL
Pointer to the next pending SCB lined.
INT32 gk_TASK_INHERENCE_PRIORITY_SET(GS_TCB *ptcb)
Sets the inherence priority of TCB according the priority of granted resources.
unsigned int BLOCK_HASH
BLOCK_HASH of the RCB: (GS_RCB *) + 3.
INT64 TCBPeriod
Period of the task.
GS_ECB* gk_ECB_GetFree(void)
Returns a pointer to a Free ECB, NULL if there is not ECB available.
void gk_ENTRY_SIGNAL_RETURN(void)
Return from Signal:
INT64 TCBRunPriority
Priority when it is executed.
void* malloc_address
Pointer memory address of the malloc block
volatile int GRTOS_S_PROCESSOR1_IRQ
INT32 TCB_IsValid(GS_TCB *ptcb)
gt_time gu_get_now(void)
Return the system time in system time units.
struct gs_scb* RCB_NextRCBASL
Pointer to the Linked list of signals.
INT32 gk_TASK_RELEASE(GS_TCB *ptcb)
Release a new invocation of the task. Preserves the Associated signal list. If task is not completed,...
struct gs_scb* TCB_NextTCBASL
Pointer to the Linked list of signals.
INT32 RCB_IsValid(void *prcb)
Returns G_TRUE is pointer points to RCB.
INT32 gk_TASK_RESOURCE_DESTROY(GS_ECB *pevent)
Destroy the events associated to a task and semaphore and returns them to the free lists.
void GRTOS_Start_Task(void)
unsigned int BLOCK_HASH
BLOCK_HASH of the SCB: (GS_SCB *) + 4.
FILE* fpuart[G_NUMBER_OF_PCB]
INT32 RRDS_Type
TYPE of the RRDS.
struct T_SEMAPHORE_RESOURCE semaphore
is the semaphore resource structure
INT32 gk_RRDSASL_Link(GS_RRDS *prrds, GS_SCB *psignal)
Links SCB to RRDS Associated Signal List.
INT32 gk_SCBFL_Link(GS_SCB *psignal)
Links a SCB to the Free List.
struct gs_scb* SCB_PREV_SCBs
Pointer to previous SCB structure. Used for debugging purposes.
INT32 LCBType
Type of the List Control Block.
INT32 gk_TCBRUNL_Link(GS_TCB *ptcb)
Links the TCB to the Run Task List.
volatile int G_IRQ_PENDING
INT32 gk_ECBAEL_Remove(GS_ECB *pevent)
Unlinks the pevent from the associated ECB list.
INT32 gk_ECBTL_Unlink(GS_ECB *pevent)
Unlinks the ECB from the Time Event List.
INT32 gk_LCBL_UnLink(GS_LCB *plcb)
Unlinks the LCB from the LCB List.
void* SCB_AssocXCB
Pointer to the data structure root of the SCBASL.
GS_SCB* gk_ECBASL_GetSCB(GS_ECB *pecb, INT32 SignalType)
Returns a pointer to the GS_SCB in the associated GS_SCBs of an event or NULL if any.
struct gs_ecb* RRDS_AsocECB
Pointer to ECB the RRDS is linked to.
GRTOS general definition.
struct gs_tcb* PCB_IDLETCB
Pointer to the TCB of the IDLE Task.
void gk_RESOURCE_ECB_KILL_CALLBACK(GS_ECB *pevent)
This function is called when a resource event is kill. It has to resolve according the event type.
struct gs_rrds* RRDS_PREV_RRDSs
Pointer to previous RRDS structure. Used for debugging purposes.
void gk_SCBAPSL_Link(GS_SCB *pscb_root, GS_SCB *pscb_pending)
Links a pending signal to the root signal to create a signal list.
volatile INT32 gs_offsetof_TCB_StackPointer
INT32 RCBType
Type of resource control block.
INT32 gu_signal_destroy(GS_SCB *pscb)
Unlink the signal associated to a control block.
INT32 LCBExclusion
Maximum number of running task (0 for no limit)
struct gs_scb* KCB_ROOT_SCBs
pointer to the first SCB structure. Used for debugging purposes.
INT32 LCBCurrentRunning
Current number of running tasks.
void gk_MONITOR_FIFO_SAMPLE(int data)