GeMRTOS
gemrtos_core.c
Go to the documentation of this file.
1 
22 /******************************************************************************
23 * *
24 * License Agreement *
25 * Copyright (c) Ricardo L. Cayssials *
26 * All rights reserved. *
27 * *
28 ******************************************************************************/
29 
30 #include <gemrtos_core.h>
31 
33 
34 // Check https://stackoverflow.com/questions/1154709/how-can-i-hide-the-declaration-of-a-struct-in-c
35 // https://gcc.gnu.org/onlinedocs/gcc/Nios-II-Options.html#index-mno-bypass-cache
36 // #pragma GCC optimize('mno-cache-volatile')
37 
38 #include <inttypes.h>
39 
47 {
48  SAMPLE_FUNCTION_BEGIN(36)
49 
50  g_kcb.KCB_NUMBER_OF_TCBs++;
51  // from https://stackoverflow.com/questions/227897/how-to-allocate-aligned-memory-only-using-the-standard-library/3430102#3430102
52  void *mem = malloc(sizeof(GS_TCB) + 15); // Adding 15 to make sure there exist an address module 16 to align the block
53  GS_TCB *ptcb = (GS_TCB *) (((uintptr_t)mem+15) & ~ (uintptr_t)0x0F);
54 
56  ptcb->BLOCK_HASH = (unsigned int) ptcb + 1;
57  ptcb->malloc_address = mem;
58  // ptcb->TCBState = G_TCBState_FREE;
59  ptcb->TCB_NextTCBAEL = (struct gs_ecb *) 0;
60  ptcb->TCB_NextTCBASL = (struct gs_scb *) 0;
61  ptcb->TCB_NextTCBPSL = (struct gs_scb *) 0;
62  ptcb->TCBType = G_TCBType_UNDEFINED;
63  ptcb->TCBReadyPriority = G_LOWEST_PRIORITY -1;
64  ptcb->TCBInherPriority = G_LOWEST_PRIORITY -1;
65  ptcb->TCBRunPriority = G_LOWEST_PRIORITY -1;
66  ptcb->TCBCurrentPriority = G_LOWEST_PRIORITY -1;
67  ptcb->TCBPeriod = 0x7FFFFFFFFFFFFFFFLL -1;
68  ptcb->TCBDeadline = 0x7FFFFFFFFFFFFFFFLL -1;
69  ptcb->TCB_StackPointer = (GS_STK *) 0;
70  ptcb->TCB_StackBottom = (GS_STK *) 0;
71  ptcb->TCB_StackTop = (GS_STK *) 0;
72  ptcb->TCB_TaskCode = (void *) 0;
73  ptcb->TCB_TaskArg = (void *) 0;
74  ptcb->TCB_NextTCB = (struct gs_tcb *) 0;
75  ptcb->TCB_PrevTCB = (struct gs_tcb *) 0;
76  ptcb->TCB_AssocPCB = 0;
77  ptcb->TCB_INTNumber = -1;
78  ptcb->TCB_RDY_LCB_Index = (GS_LCB *) G_TASK_LCB_DEFAULT;
79  ptcb->TCB_Abort_w_Deadline = G_FALSE;
80  ptcb->TCBState = G_TCBState_UNLINKED;
81  ptcb->TCB_NextISRTCB = (struct gs_tcb *) 0;
82  ptcb->TCB_PrevISRTCB = (struct gs_tcb *) 0;
83 
84 
86  ptcb->TCB_NEXT_TCBs = g_kcb.KCB_ROOT_TCBs;
87  if (g_kcb.KCB_ROOT_TCBs != (struct gs_tcb *) 0) g_kcb.KCB_ROOT_TCBs->TCB_PREV_TCBs = ptcb;
88  ptcb->TCB_PREV_TCBs = (struct gs_tcb *) 0;
89  g_kcb.KCB_ROOT_TCBs = (struct gs_tcb *) ptcb;
90 
91 
92 #if G_DEBUG_WHILEFOREVER_ENABLE == 1
93  if (TCB_IsValid(ptcb) != G_TRUE) G_DEBUG_WHILEFOREVER;
94 #endif
95 
96  SAMPLE_FUNCTION_END(36)
97  return ptcb;
98 }
99 
100 
108 {
109  SAMPLE_FUNCTION_BEGIN(1)
110 
111  g_kcb.KCB_NUMBER_OF_ECBs++;;
112  // from https://stackoverflow.com/questions/227897/how-to-allocate-aligned-memory-only-using-the-standard-library/3430102#3430102
113  void *mem = malloc(sizeof(GS_ECB) + 15); // Adding 15 to make sure there exist an address module 16 to align the block
114  GS_ECB *pecb = (GS_ECB *) (((uintptr_t)mem+15) & ~ (uintptr_t)0x0F);
115 
116  pecb->BLOCK_HASH = (unsigned int) pecb + 2;
117  pecb->malloc_address = mem;
118  // pecb->ECBState = GS_ECBState_FREE;
119  pecb->ECB_NextECBAEL = (struct gs_ecb *) 0;
120  pecb->ECB_NextECBASL = (struct gs_scb *) 0;
121  pecb->ECBType = G_ECBType_NOT_SPECIFIED;
122  // pecb->ECBValue.i64 = G_LOWEST_PRIORITY -1;
123  pecb->ECB_NextECB = (struct gs_ecb *) 0;
124  pecb->ECB_PrevECB = (struct gs_ecb *) 0;
125  pecb->ECB_AssocTCB = (struct gs_tcb *) 0;
126  pecb->ECB_AssocRCB = (struct g_rcb *) 0;
127  pecb->ECB_NextTCBAEL = (struct gs_ecb *) 0;
128  pecb->ECB_PrevTCBAEL = (struct gs_ecb *) 0;
129  pecb->ECB_RRDS = (struct gs_rrds *) 0;
130  pecb->ECBValue.i64 = G_LOWEST_PRIORITY;
131  pecb->ECBState = GS_ECBState_UNLINKED;
132 
134  pecb->ECB_NEXT_ECBs = g_kcb.KCB_ROOT_ECBs;
135  if (g_kcb.KCB_ROOT_ECBs != (struct gs_ecb *) 0) g_kcb.KCB_ROOT_ECBs->ECB_PREV_ECBs = pecb;
136  pecb->ECB_PREV_ECBs = (struct gs_ecb *) 0;
137  g_kcb.KCB_ROOT_ECBs = (struct gs_ecb *) pecb;
138 
139  SAMPLE_FUNCTION_END(1)
140 
141 #if G_DEBUG_WHILEFOREVER_ENABLE == 1
142  if (pecb == (struct gs_ecb *) 0) G_DEBUG_WHILEFOREVER;
143 #endif
144 
145  return pecb;
146 }
147 
156 {
157  SAMPLE_FUNCTION_BEGIN(19)
158 
159  g_kcb.KCB_NUMBER_OF_RCBs++;;
160  void *mem = malloc(sizeof(G_RCB) + 15); // Adding 15 to make sure there exist an address module 16 to align the block
161  G_RCB *prcb = (G_RCB *) (((uintptr_t)mem+15) & ~ (uintptr_t)0x0F);
162  // from https://stackoverflow.com/questions/227897/how-to-allocate-aligned-memory-only-using-the-standard-library/3430102#3430102
163 
164  prcb->BLOCK_HASH = (unsigned int) prcb + 3;
165  prcb->malloc_address = mem;
166  // prcb->RCBType = GK_RCBType_FREE;
167  prcb->RCBState = GK_RCBState_UNDEFINED;
168  prcb->RCBCount = (INT32) 0;
169  prcb->RCB_NextRCBASL = (struct gs_scb *) 0;
170  prcb->RCB_NextRCBGEL = (struct gs_ecb *) 0;
171  prcb->RCB_NextRCBWEL = (struct gs_ecb *) 0;
172  prcb->RCBType = GK_RCBType_UNUSED;
173 
175  prcb->RCB_NEXT_RCBs = (G_RCB *) g_kcb.KCB_ROOT_RCBs;
176  if (g_kcb.KCB_ROOT_RCBs != (struct g_rcb *) 0) {
177  G_RCB *presource = (G_RCB *) g_kcb.KCB_ROOT_RCBs;
178  presource->RCB_PREV_RCBs = (G_RCB *) prcb;
179  }
180  prcb->RCB_PREV_RCBs = (G_RCB *) 0;
181  g_kcb.KCB_ROOT_RCBs = (struct g_rcb *) prcb;
182 
183  SAMPLE_FUNCTION_END(19)
184 
185  return prcb;
186 }
187 
195 {
196  SAMPLE_FUNCTION_BEGIN(26)
197  g_kcb.KCB_NUMBER_OF_SCBs++;
198 
199  void *mem = malloc(sizeof(GS_SCB) + 15); // Adding 15 to make sure there exist an address module 16 to align the block
200  GS_SCB *pscb = (GS_SCB *) (((uintptr_t)mem+15) & ~ (uintptr_t)0x0F);
201 
202  pscb->BLOCK_HASH = (unsigned int) pscb + 4;
203  pscb->malloc_address = mem;
204  pscb->SCBState = G_SCBState_FREE;
205  pscb->SCBState = G_SCBState_UNLINKED;
206 
208  pscb->SCB_NEXT_SCBs = g_kcb.KCB_ROOT_SCBs;
209  if (g_kcb.KCB_ROOT_SCBs != (struct gs_scb *) 0) g_kcb.KCB_ROOT_SCBs->SCB_PREV_SCBs = pscb;
210  pscb->SCB_PREV_SCBs = (struct gs_scb *) 0;
211  g_kcb.KCB_ROOT_SCBs = (struct gs_scb *) pscb;
212 
213 
214  SAMPLE_FUNCTION_END(26)
215 
216 #if G_DEBUG_WHILEFOREVER_ENABLE == 1
217  if (pscb == (struct gs_scb *) 0) G_DEBUG_WHILEFOREVER;
218 #endif
219 
220  return pscb;
221 }
222 
231 {
232  SAMPLE_FUNCTION_BEGIN(48)
233  g_kcb.KCB_NUMBER_OF_RRDSs++;
234  void *mem = malloc(sizeof(GS_RRDS) + 15); // Adding 15 to make sure there exist an address module 16 to align the block
235  GS_RRDS *prrds = (GS_RRDS *) (((uintptr_t)mem+15) & ~ (uintptr_t)0x0F);
236 
237  prrds->BLOCK_HASH = (unsigned int) prrds + 5;
238  prrds->malloc_address = mem;
239 
240  prrds->RRDS_State = 0;
241  prrds->RRDS_Type = 0;
242  prrds->RRDS_NextRRDS = (struct gs_rrds *) 0;
243  prrds->RRDS_NextSCB = (struct gs_scb *) 0;
244  prrds->RRDS_AsocECB = (struct gs_ecb *) 0;
245 
247  prrds->RRDS_NEXT_RRDSs = g_kcb.KCB_ROOT_RRDSs;
248  if (g_kcb.KCB_ROOT_RRDSs != (struct gs_rrds *) 0) g_kcb.KCB_ROOT_RRDSs->RRDS_PREV_RRDSs = prrds;
249  prrds->RRDS_PREV_RRDSs = (struct gs_rrds *) 0;
250  g_kcb.KCB_ROOT_RRDSs = (struct gs_rrds *) prrds;
251 
252  SAMPLE_FUNCTION_END(48)
253  return prrds;
254 }
255 
265 {
266  g_kcb.KCB_NUMBER_OF_LCBs++;
267  void *mem = malloc(sizeof(GS_LCB) + 15); // Adding 15 to make sure there exist an address module 16 to align the block
268  GS_LCB *plcb = (GS_LCB *) (((uintptr_t)mem+15) & ~ (uintptr_t)0x0F);
269 
270  plcb->BLOCK_HASH = (unsigned int) plcb + 6;
271  plcb->malloc_address = mem;
272 
273  plcb->LCB_NextTCBRUNL = (struct gs_tcb *) 0; /* Pointer to the TCB list of running tasks */
274  plcb->LCBRunPriority = (INT64) G_LOWEST_PRIORITY; /* It is because it is empty*/
275  plcb->LCB_NextTCBRDYL = (struct gs_tcb *) 0; /* Pointer to the TCB of the Highest Priority Task */
276  plcb->LCB_NextLCBFPL = (struct gs_pcb *) 0;
277  plcb->LCBState = GS_LCBState_UNLINKED;
278  plcb->LCBType = GS_LCBType_UNSPECIFIED;
279 
281  plcb->LCB_NEXT_LCBs = g_kcb.KCB_ROOT_LCBs;
282  if (g_kcb.KCB_ROOT_LCBs != (struct gs_lcb *) 0) g_kcb.KCB_ROOT_LCBs->LCB_PREV_LCBs = plcb;
283  plcb->LCB_PREV_LCBs = (struct gs_lcb *) 0;
284  g_kcb.KCB_ROOT_LCBs = (struct gs_lcb *) plcb;
285 
286 
287  // Link to the LCBL linked list
288  gk_LCBL_Link((GS_LCB *) plcb);
289 
290  return plcb;
291 }
292 
293 
302 INT32 gk_Create_PCBs(int Nmbr_PCB)
303 {
304  g_kcb.KCB_NUMBER_OF_PCBs = Nmbr_PCB;
305  // from https://stackoverflow.com/questions/227897/how-to-allocate-aligned-memory-only-using-the-standard-library/3430102#3430102
306  void *mem = malloc((Nmbr_PCB) * sizeof(GS_PCB) + 15); // Adding 15 to make sure there exist an address module 16 to align the block
307  g_kcb.G_PCBTbl = (GS_PCB *) (((uintptr_t)mem+15) & ~ (uintptr_t)0x0F);
308 #if G_DEBUG_WHILEFOREVER_ENABLE == 1
309  fprintf(stderr,"[ MESSAGE ] mem = %p, g_kcb.G_PCBTbl = %p, size = %d\n", (void *) mem, (void *) g_kcb.G_PCBTbl, (int) G_NUMBER_OF_PCB * sizeof(GS_PCB));
310 #endif
311  return G_TRUE;
312 }
313 
334 GS_TCB *gk_CreateTask(void *TaskCode,
335  void *p_arg,
336  void *StkBotton,
337  unsigned int StkSize,
338  unsigned int TCBType,
339  INT64 TCBReadyPriority,
340  INT64 TCBRunPriority,
341  INT64 TCBDeadline,
342  INT64 TCBPeriod,
343  GS_LCB *TCB_RDY_LCB_Index,
344  int TCB_Abort_w_Deadline,
345  INT64 TCBInherPriority,
346  int TCB_INTNumber)
347 {
348  GS_TCB *ptcb;
349 
350  ptcb = gk_TCB_GetFree();
351  // Initialize the gs_tcb structure of the task
352  if (ptcb != (struct gs_tcb *) 0) {
353  ptcb->TCB_StackBottom = (GS_STK *) ((((INT32) StkBotton)-8)& ~0x3);
354  ptcb->TCB_StackTop = (GS_STK *)((INT32) ptcb->TCB_StackBottom - ((INT32)(StkSize)& ~0x3));
355  ptcb->TCB_TaskCode = TaskCode;
356  ptcb->TCB_TaskArg = p_arg;
357 
358  ptcb->TCBType = TCBType;
359  ptcb->TCBReadyPriority = TCBReadyPriority;
360  ptcb->TCBRunPriority = TCBRunPriority;
361  ptcb->TCBDeadline = TCBDeadline;
362  ptcb->TCBPeriod = TCBPeriod;
363  ptcb->TCB_RDY_LCB_Index = TCB_RDY_LCB_Index;
364  ptcb->TCB_Abort_w_Deadline = TCB_Abort_w_Deadline;
365  ptcb->TCBInherPriority = TCBInherPriority; /* Load task priority into TCB */
366 
367  // Initilize the stack of the task
368  gk_TASK_STK_Init(ptcb);
369 
370  // Set the number of associated interrupt (valid only when TCBType == G_TCBType_ISR)
371  // and link to the ISR linked list
372  ptcb->TCB_INTNumber = TCB_INTNumber;
373  ptcb->TCB_PrevISRTCB = (struct gs_tcb *) 0;
374  if (TCBType == G_TCBType_ISR) {
375  ptcb->TCB_NextISRTCB = g_kcb.KCB_ExtISR[TCB_INTNumber].G_TCB_ISR;
376  if (g_kcb.KCB_ExtISR[TCB_INTNumber].G_TCB_ISR != (struct gs_tcb *) 0) {
377  g_kcb.KCB_ExtISR[TCB_INTNumber].G_TCB_ISR->TCB_PrevISRTCB = (struct gs_tcb *) ptcb;
378  }
379  g_kcb.KCB_ExtISR[TCB_INTNumber].G_TCB_ISR = (struct gs_tcb *) ptcb;
380  } else {
381  ptcb->TCB_NextISRTCB = (struct gs_tcb *) 0;
382  }
383  }
384 
385  return (ptcb);
386 }
387 
388 
399 void gk_INIT_IRQ (void)
400 {
401  int i; PRINT_DEBUG_LINE
402  G_DEBUG_VERBOSE; PRINT_DEBUG_LINE // Print Debug information
403  for (i=0 ; i<ALT_NIRQ ; i++)
404  {
406  if ((G_IRQ_ENABLED >> i) & 1) {
407 
408  g_kcb.KCB_ExtISR[i].G_TCB_ISR = gk_CreateTask((void *) alt_irq[i].handler,
409  (void *) alt_irq[i].context,
410  // (void *) &g_kcb.G_ISR_STACK[i][G_ISR_STACKSIZE-4], ///< Botton of the Stack of the Task
411  (void *) g_kcb.G_ISR_STACK + (i * G_ISR_STACKSIZE) + G_ISR_STACKSIZE-4,
412  (unsigned int) G_ISR_STACKSIZE,
413  (unsigned int) G_TCBType_ISR,
414  (INT64) G_ISR_PRIORITY,
415  (INT64) G_ISR_PRIORITY,
419  (int) G_TRUE,
420  (INT64) G_ISR_PRIORITY,
421  (int) i);
422 
423  // g_kcb.KCB_ExtISR[i].G_TCB_ISR->TCB_INTNumber = i;
424 
425  if ((G_IRQ_PENDING >> i) & 1) {
426  /* The interrupt was pending then insert in ready list and disable it */
427  GRTOS_CMD_IRQ_ENB_CLR(i);
428  g_kcb.KCB_ExtISR[i].G_EXT_INT_Count++; // = (int) 1;
429  gk_TCBRDYL_Link(g_kcb.KCB_ExtISR[i].G_TCB_ISR); /* Insert Task in Ready List */
430  } else {
431  gk_TCBWL_Link(g_kcb.KCB_ExtISR[i].G_TCB_ISR, G_TCBState_WAITING_COMPLETED);
432  // g_kcb.KCB_ExtISR[i].G_EXT_INT_Count = (int) 0;
433  GRTOS_CMD_IRQ_ENB_SET(i);
434  }
435  }
436  }
437 }
438 
448 
449  int irq_nbr = ptcb->TCB_INTNumber;
450 
451 #if G_DEBUG_WHILEFOREVER_ENABLE == 1
452  if (g_kcb.KCB_ExtISR[irq_nbr].G_EXT_INT_Count == (int) 0) G_DEBUG_WHILEFOREVER; PRINT_DEBUG_LINE
453 #endif
454 
455  if (ptcb->TCBType == G_TCBType_ISR) g_kcb.KCB_ExtISR[irq_nbr].G_EXT_INT_Count--;
456  if (g_kcb.KCB_ExtISR[irq_nbr].G_EXT_INT_Count == (INT32) 0) {
457  GRTOS_CMD_IRQ_ENB_SET(irq_nbr);
458  }
459 
460  return G_TRUE;
461 }
462 
470 void gk_ISR_RELEASE (int irq_nbr) {
471 
472  GS_TCB *ptcb = g_kcb.KCB_ExtISR[irq_nbr].G_TCB_ISR;
473 
474  GRTOS_CMD_IRQ_ENB_CLR(irq_nbr); PRINT_DEBUG_LINE
475 
476  while (ptcb != (GS_TCB *) 0) {
477  // !!!! verificar si esta en estado waiting
478  /* Limpio el registro de interrupcion porque ya fue activada */
479  if (ptcb->TCBType == G_TCBType_ISR) {
480  if (ptcb->TCBState == G_TCBState_WAITING_COMPLETED) { // if task is waiting
481  /* Insert Task in Ready List */
482  gk_TCB_Unlink((GS_TCB *) ptcb);
483  gk_TASK_STK_Init((GS_TCB *) ptcb);
484  gk_TCBRDYL_Link((GS_TCB *) ptcb);
485 
486  g_kcb.KCB_ExtISR[irq_nbr].G_EXT_INT_Count++;
487  }
488  }
489  ptcb = (GS_TCB *) ptcb->TCB_NextISRTCB;
490  }
491 
492 }
493 
504 INT32 gu_SetTaskISR(struct gs_tcb *ptcb, unsigned int irq_nbr)
505 {
506  if (G_Running == G_TRUE) GRTOS_USER_CRITICAL_SECTION_GET;
507  gk_SetTaskISR(ptcb, irq_nbr);
508  if (G_Running == G_TRUE) GRTOS_USER_CRITICAL_SECTION_RELEASE;
509  return G_TRUE;
510 }
511 
522 INT32 gk_SetTaskISR(struct gs_tcb *ptcb, unsigned int irq_nbr)
523 {
524  // Set the number of associated interrupt (valid only when TCBType == G_TCBType_ISR)
525  // and link to the ISR linked list !!! check if task is running for consistency of Count
526  ptcb->TCBType = G_TCBType_ISR;
527  ptcb->TCB_INTNumber = irq_nbr;
528  ptcb->TCB_PrevISRTCB = (struct gs_tcb *) 0;
529  ptcb->TCB_NextISRTCB = g_kcb.KCB_ExtISR[irq_nbr].G_TCB_ISR;
530  if (g_kcb.KCB_ExtISR[irq_nbr].G_TCB_ISR != (struct gs_tcb *) 0) {
531  g_kcb.KCB_ExtISR[irq_nbr].G_TCB_ISR->TCB_PrevISRTCB = (struct gs_tcb *) ptcb;
532  }
533  g_kcb.KCB_ExtISR[irq_nbr].G_TCB_ISR = (struct gs_tcb *) ptcb;
534 
535  if (ptcb->TCBState != G_TCBState_WAITING_COMPLETED) {
536  g_kcb.KCB_ExtISR[irq_nbr].G_EXT_INT_Count++;
537  }
538 
539  return G_TRUE;
540 }
541 
542 
543 OPTIMEZE_RESTORE
544 
INT32
unsigned INT32
Definition: gemrtos_core.h:62
Task::gk_CreateTask
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.
Definition: gemrtos_core.c:334
RRDS::gk_RRDS_GetFree
GS_RRDS* gk_RRDS_GetFree(void)
Gets the pointer of a free RRDS from the free list.
Definition: gemrtos_core.c:230
Core::gk_Create_PCBs
INT32 gk_Create_PCBs(int Nmbr_PCB)
Reservs system memory to store the Processor Control Blocks of the system (PCB)
Definition: gemrtos_core.c:302
GS_TCB
struct gs_tcb GS_TCB
Definition: gemrtos_core.h:50
Task::gk_TCB_Unlink
INT32 gk_TCB_Unlink(GS_TCB *ptcb)
Unlinks the TCB according to the list it is linked.
Definition: listfunctions.c:2550
gs_tcb::BLOCK_HASH
unsigned int BLOCK_HASH
BLOCK_HASH of the TCB: (GS_TCB *) + 1.
Definition: gemrtos_core.h:441
Task::OPTIMEZE_CODE
OPTIMEZE_CODE(3)
Creates a TCB and returns its pointer Returns a pointer to a Free TCB, NULL if it is not a TCB availa...
Definition: gemrtos_core.c:32
G_TASK_LCB_DEFAULT
volatile GS_LCB* G_TASK_LCB_DEFAULT
Resource::gk_RCB_GetFree
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.
Definition: gemrtos_core.c:155
Signal::gk_SCB_GetFree
GS_SCB* gk_SCB_GetFree(void)
Unlinks a SCB from free list and return its pointer.
Definition: gemrtos_core.c:194
G_Running
volatile INT32 G_Running
gs_rrds::BLOCK_HASH
unsigned int BLOCK_HASH
BLOCK_HASH of the RRDS: (GS_RRDS *) + 5.
Definition: gemrtos_core.h:359
List::gk_LCBL_Link
INT32 gk_LCBL_Link(GS_LCB *plcb)
Inserts a RunList in LCB Runining list ordered by background list and then priority.
Definition: listfunctions.c:553
gs_ecb
GS_ECB Event Control Block structure.
Definition: gemrtos_core.h:107
gs_lcb
GS_LCB List Control Block.
Definition: gemrtos_core.h:203
Interrupt::gu_SetTaskISR
INT32 gu_SetTaskISR(struct gs_tcb *ptcb, unsigned int irq_nbr)
Convert a task to a ISR associated to a Interrupt Number.
Definition: gemrtos_core.c:504
Task::gk_TCBWL_Link
INT32 gk_TCBWL_Link(GS_TCB *ptcb, unsigned int state)
Links a TCB in the waiting list.
Definition: listfunctions.c:1990
gs_ecb::BLOCK_HASH
unsigned int BLOCK_HASH
BLOCK_HASH of the ECB: (GS_ECB *) + 2.
Definition: gemrtos_core.h:108
gs_tcb
gs_tcb Task Control Block (TCB) structure
Definition: gemrtos_core.h:439
gs_scb
GS_SCB Signal Control Block structure.
Definition: gemrtos_core.h:393
GS_PCB
struct gs_pcb GS_PCB
Definition: gemrtos_core.h:48
gs_pcb
GS_PCB Processor Control Block.
Definition: gemrtos_core.h:238
gs_lcb::BLOCK_HASH
unsigned int BLOCK_HASH
BLOCK_HASH of the LCB: (GS_LCB *) + 6.
Definition: gemrtos_core.h:204
GS_SCB
struct gs_scb GS_SCB
Definition: gemrtos_core.h:52
Interrupt::gk_ISR_COMPLETE
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...
Definition: gemrtos_core.c:447
Interrupt::gk_SetTaskISR
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.
Definition: gemrtos_core.c:522
G_TASK_PERIOD_DEFAULT
volatile INT64 G_TASK_PERIOD_DEFAULT
GS_RRDS
struct gs_rrds GS_RRDS
Definition: gemrtos_core.h:53
gs_tcb::TCBState
unsigned int TCBState
STATE of the task.
Definition: gemrtos_core.h:442
gk_TCB_GetFree
GS_TCB* gk_TCB_GetFree(void)
g_kcb
GS_KCB g_kcb
G_IRQ_ENABLED
volatile int G_IRQ_ENABLED
Interrupt::gk_ISR_RELEASE
void gk_ISR_RELEASE(int irq_nbr)
Executed when an interrupt is triggered. It is called from gk_ENTRY_IRQ_HANDLER()
Definition: gemrtos_core.c:470
gs_tcb::TCB_INTNumber
int TCB_INTNumber
IRQ number if it is a ISR TCB.
Definition: gemrtos_core.h:462
GS_LCB
struct gs_lcb GS_LCB
Definition: gemrtos_core.h:49
Interrupt::gk_INIT_IRQ
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...
Definition: gemrtos_core.c:399
gs_tcb::TCB_PrevISRTCB
struct gs_tcb* TCB_PrevISRTCB
Pointer to the previous TCB for the same ISR (when task is a ISR)
Definition: gemrtos_core.h:466
INT64
unsigned long long INT64
Definition: gemrtos_core.h:61
Core::gk_Get_LCB
GS_LCB* gk_Get_LCB(void)
Creates a LCB and returns its pointer.
Definition: gemrtos_core.c:264
GS_ECB
struct gs_ecb GS_ECB
Definition: gemrtos_core.h:51
Task::gk_TCBRDYL_Link
INT32 gk_TCBRDYL_Link(GS_TCB *ptcb)
Links the TCB in the Ready Task List sorted by its priority.
Definition: listfunctions.c:1653
gs_tcb::TCB_NextISRTCB
struct gs_tcb* TCB_NextISRTCB
Pointer to the next TCB for the same ISR (when task is a ISR)
Definition: gemrtos_core.h:465
gs_rrds
GS_RRDS Resource Request Data Structure.
Definition: gemrtos_core.h:357
GS_STK
unsigned int GS_STK
Definition: gemrtos_core.h:63
Task::gk_TASK_STK_Init
INT32 gk_TASK_STK_Init(GS_TCB *ptcb)
Initializes the Task Stack acording to the TCB parameters.
Definition: listfunctions.c:2805
gemrtos_core.h
GEmRTOS CORE definitions.
gs_tcb::TCBType
unsigned int TCBType
TYPE of the task.
Definition: gemrtos_core.h:443
g_rgb::BLOCK_HASH
unsigned int BLOCK_HASH
BLOCK_HASH of the RCB: (GS_RCB *) + 3.
Definition: gemrtos_core.h:308
Event::gk_ECB_GetFree
GS_ECB* gk_ECB_GetFree(void)
Returns a pointer to a Free ECB, NULL if there is not ECB available.
Definition: gemrtos_core.c:107
TCB_IsValid
INT32 TCB_IsValid(GS_TCB *ptcb)
Definition: monitor.c:76
G_RCB
struct g_rgb G_RCB
Definition: gemrtos_core.h:54
gs_scb::BLOCK_HASH
unsigned int BLOCK_HASH
BLOCK_HASH of the SCB: (GS_SCB *) + 4.
Definition: gemrtos_core.h:394
G_IRQ_PENDING
volatile int G_IRQ_PENDING