GeMRTOS
grtos_kernel.c
Go to the documentation of this file.
1 
21 /******************************************************************************
22 * *
23 * License Agreement *
24 * Copyright (c) Ricardo L. Cayssials *
25 * All rights reserved. *
26 * *
27 ******************************************************************************/
28 
29 #include <gemrtos_core.h>
30 #include <grtos.h>
31 
32 // #include "sys/alt_exceptions.h"
33 // #include "nios2.h"
34 // #include "alt_types.h"
35 
36 #include "priv/alt_irq_table.h"
37 
38 
40 
41 // #pragma GCC push
42 // #pragma GCC optimize('mbypass-cache')
43 // #pragma GCC optimize('mno-cache-volatile')
44 // #pragma GCC pop
45 
46 
47 // extern void _do_ctors(void); PRINT_DEBUG_LINE
48 // extern void _do_dtors(void); PRINT_DEBUG_LINE
49 // /*
50 // * Standard arguments for main. By default, no arguments are passed to main.
51 // * However a device driver may choose to configure these arguments by calling
52 // * alt_set_args(). The expectation is that this facility will only be used by
53 // * the iclient/ihost utility.
54 // */
55 //
56 // //int alt_argc = 0; PRINT_DEBUG_LINE
57 // //char** alt_argv = {NULL}; PRINT_DEBUG_LINE
58 // //char** alt_envp = {NULL}; PRINT_DEBUG_LINE
59 //
60 // /*
61 // * Prototype for the entry point to the users application.
62 // */
63 //
64 // extern int main (int, char **, char **); PRINT_DEBUG_LINE
65 
66 
67 /*****************************************************************************/
68 /*****************************************************************************/
70 /*****************************************************************************/
71 /*****************************************************************************/
72 
73 /* Data Structure */
74 GS_KCB g_kcb __attribute__((aligned(4)));
75 
76 
78 volatile GS_STK G_TCB_CURRENT __attribute__((aligned(4)));
79 volatile INT32 G_SCB_PENDING __attribute__((aligned(4)));
80 volatile INT32 G_SCB_CODE __attribute__((aligned(4)));
81 volatile INT32 G_SCB_ARG __attribute__((aligned(4)));
82 
83 
84 
87 // volatile int GRTOS_S_PROCESSOR1_IRQ_INTERRUPT_CONTROLLER_ID;
88 
91 volatile int GRTOS_S_PROCESSOR1_IRQ;
92 
93 /* Interrupt status before GRTOS start */
94 volatile int G_IRQ_ENABLED __attribute__((aligned(4)));
95 volatile int G_IRQ_PENDING __attribute__((aligned(4)));
96 
98 volatile INT32 GRTOS_MutexReleaseRegisterAddress __attribute__((aligned(4)));
99 volatile INT32 GRTOS_MutexRequestRegisterAddress __attribute__((aligned(4)));
100 volatile INT32 GRTOS_InterruptEnableRegisterAddress __attribute__((aligned(4)));
101 volatile INT32 GRTOS_InterruptDisableRegisterAddress __attribute__((aligned(4)));
102 
103 volatile INT32 G_Running __attribute__((aligned(4)));
104 volatile INT32 G_Running = G_FALSE;
105 
106 volatile INT32 gs_sizeof_G_PCBTbl __attribute__((aligned(4)));
107 volatile void *gs_addressof_G_PCBTbl __attribute__((aligned(4)));
108 volatile INT32 gs_offsetof_PCB_EXECTCB __attribute__((aligned(4)));
109 volatile INT32 gs_offsetof_TCB_StackPointer __attribute__((aligned(4)));
110 volatile INT32 gs_offsetof_PCB_IDLETCB __attribute__((aligned(4)));
111 
112 volatile int G_DEBUG_SAMPLE_BEGIN_ENABLE __attribute__((aligned(4)));
113 volatile int G_DEBUG_SAMPLE_END_ENABLE __attribute__((aligned(4)));
114 
115 
116 FILE* fpuart[G_NUMBER_OF_PCB];
117 
118 volatile INT32 G_TASK_TYPE_DEFAULT;
119 volatile GS_LCB *G_TASK_LCB_DEFAULT;
121 volatile INT64 G_TASK_PERIOD_DEFAULT;
122 
123 
124 /***********************************************************************************
125 *********************** *************
126 ***********************************************************************************/
127 
135 // void gk_ENTRY_RST_HANDLER (void) __attribute__ ((section ("rstaux")));
136 void gk_ENTRY_RST_HANDLER (void)
137 {
139 
141  NIOS2_WRITE_STATUS(0);
143  NIOS2_WRITE_IENABLE (0);
144 
145  SAMPLE_FUNCTION_BEGIN(1000);
146 
147  GRTOS_USER_CRITICAL_SECTION_GET;
148 
149 
150  #if G_DEBUG_WHILEFOREVER_ENABLE == 1
151  fprintf(stderr,"[ MESSAGE ] Executing %s, %d, Proc: %d\n",__FUNCTION__,__LINE__,GRTOS_CMD_PRC_ID);
152  #endif
153 
154  // G_NUMBER_OF_IDLE_PROCESSORS is the number of processors wanted to be in idle state forever
155  // They are sent to the gk_RST_MONITOR_HANDLER in order to left them out of the system runtime
156  if (GRTOS_CMD_PRC_ID > G_NUMBER_OF_PCB - G_NUMBER_OF_IDLE_PROCESSORS) gk_RST_MONITOR_HANDLER();
157 
158 
160  g_kcb.G_PCBTbl[GRTOS_CMD_PRC_ID -1].PCBState = GS_PCBState_RUNNING;
161  g_kcb.G_PCBTbl[GRTOS_CMD_PRC_ID -1].PCBID = GRTOS_CMD_PRC_ID ;
162  g_kcb.G_PCBTbl[GRTOS_CMD_PRC_ID -1].PCB_EXECTCB = g_kcb.G_PCBTbl[GRTOS_CMD_PRC_ID -1].PCB_IDLETCB;
163  gk_LCBFPL_Link(GRTOS_CMD_PRC_ID);
164 
165  SAMPLE_FUNCTION_END(1000);
166  gk_KERNEL_TASK_START(); // Start the GRTOS for this processor
167 
168  printf("******************************************** \n");
169  printf("ERROR Processor %d Init GRTOS \n", GRTOS_CMD_PRC_ID );
170  printf("******************************************** \n");
171 
172  while(1);
173  // ###########################################
174 
175 }
176 
177 
178 /***********************************************************************************
179 *********************** GRTOS INTERRUPT FUNCTIONS ********************************
180 ***********************************************************************************/
185 // void gk_ENTRY_IRQ_HANDLER (void) __attribute__ ((section (".exceptions")));
187 {
188  unsigned int event_code;
189  GS_ECB *pevent;
190  GS_TCB *ptcb;
191 
192 #if G_DEBUG_WHILEFOREVER_ENABLE == 1
193  if ((alt_irq_pending() != 1) && (alt_irq_pending() != 0)) G_DEBUG_WHILEFOREVER; // Only interrupt from GRTOS supported
194  if (G_Running == G_FALSE) G_DEBUG_WHILEFOREVER;
195 #endif
196 
197  // g_kcb.G_PCBTbl[GRTOS_CMD_PRC_ID -1].PCB_IDLETCB
198 
199  GRTOS_CMD_PRC_INT_DSB;
200  GRTOS_CMD_INT_PRC_PND_CLR;
201 
202  SAMPLE_FUNCTION_BEGIN(1001);
203 
204  // fprintf(fpuart[GRTOS_CMD_PRC_ID-1], "In %s, %d \n", __FUNCTION__, __LINE__);
205  GRTOS_CMD_CRITICAL_SECTION_GET;
206 
207 #if G_DEBUG_WHILEFOREVER_ENABLE == 1
208  void *StackPointer; // Check that SP is in the stack of the IDLE task of the processor
209  NIOS2_READ_SP(StackPointer);
210  if (((int) StackPointer > (int) g_kcb.G_PCBTbl[GRTOS_CMD_PRC_ID -1].PCB_IDLETCB->TCB_StackBottom) || ((int) StackPointer < (int) g_kcb.G_PCBTbl[GRTOS_CMD_PRC_ID -1].PCB_IDLETCB->TCB_StackTop - 300)) fprintf(stderr, "[ FAIL ] Processor %d error in SP for IDLE in %s, %d\n", GRTOS_CMD_PRC_ID, __FUNCTION__,__LINE__);;
211 #endif
212 
213  event_code = GRTOS_CMD_EVN_OCC;
214  while(event_code)
215  {
216  switch (event_code) {
217  case EVN_CODE_TIMED:
218  pevent = g_kcb.KCB_NextECBTL;
220  // gk_KERNEL_TIME_IRQ_HANDLER();
221  #if G_DEBUG_WHILEFOREVER_ENABLE == 1
222  ptcb = pevent->ECB_AssocTCB;
223  if ((ECB_IsValid(pevent) != G_TRUE) || (pevent == (struct gs_ecb *) 0)) G_DEBUG_WHILEFOREVER;
224  if ((TCB_IsValid(ptcb) != G_TRUE) || (ptcb == (struct gs_tcb *) 0)) G_DEBUG_WHILEFOREVER;
225  if (g_kcb.KCB_NextECBTL == (struct gs_ecb *) 0) G_DEBUG_WHILEFOREVER;
226  #endif
227 
228  gk_ECBTL_Unlink((GS_ECB *)pevent); /* Unlink the EVENT from Time Waiting Event List */
229 
230  // Call the TIME_CALLBACK funtion to resolve according to the event type
231  gk_TIME_CALLBACK((GS_ECB *) pevent);
232  break;
233  case EVN_CODE_FROZEN:
234  GRTOS_CMD_FRZ_EVN_CLR;
235  // fprintf(stderr,"[ MESSAGE ] FROZEN EVENT . Proc: %d\n", GRTOS_CMD_PRC_ID);
236  // Calls the gk_FROZEN_CALLBACK() routine in grtosfunctions.c file where
237  // user may inplement frozen mode strategy
239  // gk_KERNEL_FROZEN_IRQ_HANDLER(); /// Frozen Event happened
240  break;
241  default:
242  event_code--;
243  // fprintf(stderr, "In %s, %d: Interrupt event %d", __FUNCTION__, __LINE__, event_code);
244 
245 #if G_DEBUG_WHILEFOREVER_ENABLE == 1
246  if (g_kcb.KCB_ExtISR[event_code].G_TCB_ISR == (struct gs_tcb *) 0) G_DEBUG_WHILEFOREVER;
247  if (!GRTOS_TASK_STATE_WAITING(g_kcb.KCB_ExtISR[event_code].G_TCB_ISR)) G_DEBUG_WHILEFOREVER; // No re-entry for ISR
248 #endif
249  gk_ISR_RELEASE (event_code);
250  break;
251 
252  }
253  event_code = 0;
254  // event_code = GRTOS_CMD_EVN_OCC;
255  }
256 
257  // #####################################################
258  /* Check if Executing task is running or if it was desalocated */
259  GS_TCB *ptcbfrom = gk_PCB_GetCurrentTCB();
260  GS_TCB *ptcbto = gk_PCB_GetNextTCB();
261 
262 #if G_DEBUG_WHILEFOREVER_ENABLE == 1
263  if (TCB_IsValid(ptcbto) != G_TRUE) G_DEBUG_WHILEFOREVER;
264  if (TCB_IsValid(ptcbfrom) != G_TRUE && ptcbfrom != (struct gs_tcb *) 0) G_DEBUG_WHILEFOREVER;
265  if (ptcbto->TCBState != G_TCBState_READY && ptcbto->TCBState != G_TCBState_RUNNING) G_DEBUG_WHILEFOREVER;
266 #endif
267 
268  if (ptcbfrom != ptcbto) {
269  if (ptcbfrom->TCBState == G_TCBState_RUNNING){
270  gk_TCB_Unlink(ptcbfrom);
271  gk_TCBRDYL_Link(ptcbfrom);
272  }
273  gk_TCBRDYL_Unlink(ptcbto);
274  gk_TCBRUNL_Link(ptcbto);
275  }
276 
277  /* Set the GRTOS register for next interrupt */
281 
282  SAMPLE_FUNCTION_END(1001);
283 }
284 
285 /**********************************************************************************
286  * BAD RETURN FUNCTION IN TASK STACK
287  * THIS IS THE RETURN ADDRESS WHEN A BAD RETURN IS EXECUTED IN A TASK SWITCH
288  *********************************************************************************/
295 {
296  fprintf(fpuart[GRTOS_CMD_PRC_ID-1], "In %s, %d \n", __FUNCTION__, __LINE__);
297  while(1);
298 }
299 
300 /***********************************************************************************
301 ****Return from Signal: get critical section and return to ******
302 **** GRTOS_Return_from_Signal in grtos_switch.S file
303 ***********************************************************************************/
309 {
310  // fprintf(fpuart[GRTOS_CMD_PRC_ID-1], "Returning from Signal In %s, %d \n", __FUNCTION__, __LINE__);
311  GRTOS_CMD_CRITICAL_SECTION_GET;
312 }
313 
314 // /**gk_KERNEL_FROZEN_IRQ_HANDLER
315 // * \brief Frozen mode handler
316 // * \details Calls the gk_FROZEN_CALLBACK() routine in grtosfunctions.c file where
317 // * user may inplement frozen mode strategy
318 // * \relates Time
319 // */
320 // void gk_KERNEL_FROZEN_IRQ_HANDLER(void) {
321 // // GRTOS_CMD_FRZ_EVN_CLR; // The Frozen event should be cleared
322 // gk_FROZEN_CALLBACK();
323 // }
324 
325 // /**gk_KERNEL_TIME_IRQ_HANDLER
326 // * \brief Executes the ISR for timed events from GRTOS
327 // * \details Calls the gk_TIME_CALLBACK funtion to resolve according to the event type
328 // */
329 // // void gk_KERNEL_TIME_IRQ_HANDLER (void) __attribute__ ((section (".exceptions")));
330 // void gk_KERNEL_TIME_IRQ_HANDLER (void)
331 // {
332 // GS_ECB *pevent = g_kcb.KCB_NextECBTL;
333 //
334 // #if G_DEBUG_WHILEFOREVER_ENABLE == 1
335 // GS_TCB *ptcb;
336 // ptcb = pevent->ECB_AssocTCB;
337 // if ((ECB_IsValid(pevent) != G_TRUE) || (pevent == (struct gs_ecb *) 0)) G_DEBUG_WHILEFOREVER;
338 // if ((TCB_IsValid(ptcb) != G_TRUE) || (ptcb == (struct gs_tcb *) 0)) G_DEBUG_WHILEFOREVER;
339 // if (g_kcb.KCB_NextECBTL == (struct gs_ecb *) 0) G_DEBUG_WHILEFOREVER;
340 // #endif
341 //
342 // gk_ECBTL_Unlink((GS_ECB *)pevent); /* Delete the EVENT from Time Waiting Event List */
343 //
344 // // Call the TIME_CALLBACK funtion to resolve according to the event type
345 // gk_TIME_CALLBACK((GS_ECB *) pevent);
346 // }
347 
348 
353 {
354  GS_TCB *ptcbtostart = gk_PCB_GetNextTCB();
355 
356  SAMPLE_FUNCTION_BEGIN(1002);
357 
358  #if G_DEBUG_WHILEFOREVER_ENABLE == 1
359  fprintf(stderr,"[ MESSAGE ] Executing %s, %d, Proc: %d\n",__FUNCTION__,__LINE__,GRTOS_CMD_PRC_ID);
360  #endif
361 
362 #if G_DEBUG_WHILEFOREVER_ENABLE == 1
363  if (TCB_IsValid(ptcbtostart) != G_TRUE) G_DEBUG_WHILEFOREVER;
364  if (ptcbtostart->TCBState != G_TCBState_READY) G_DEBUG_WHILEFOREVER;
365 #endif
366 
368  gk_TCB_Unlink(ptcbtostart);
369  gk_TCBRUNL_Link(ptcbtostart);
370 
371  #if G_DEBUG_WHILEFOREVER_ENABLE == 1
372  fprintf(stderr,"[ MESSAGE ] Executing %s, %d, Proc: %d\n",__FUNCTION__,__LINE__,GRTOS_CMD_PRC_ID);
373  #endif
374 
378 
379  #if G_DEBUG_WHILEFOREVER_ENABLE == 1
380  fprintf(stderr,"[ MESSAGE ] Executing %s, %d, Proc: %d\n",__FUNCTION__,__LINE__,GRTOS_CMD_PRC_ID);
381  #endif
382 
384  NIOS2_WRITE_IENABLE (1);
385 
386  #if G_DEBUG_WHILEFOREVER_ENABLE == 1
387  fprintf(stderr,"[ MESSAGE ] Executing %s, %d, Proc: %d\n",__FUNCTION__,__LINE__,GRTOS_CMD_PRC_ID);
388  #endif
389 
390  GRTOS_CMD_RLS_NXT_PRC; // Enables the next processor to start
391 
392  #if G_DEBUG_WHILEFOREVER_ENABLE == 1
393  fprintf(stderr,"[ MESSAGE ] Executing %s, %d, Proc: %d\n",__FUNCTION__,__LINE__,GRTOS_CMD_PRC_ID);
394  #endif
395 
396  //Load the processor status and return to execute the task
397  SAMPLE_FUNCTION_END(1002);
398  GRTOS_Start_Task();
399 
400  /* Never should be executed this */
401  printf("Error in GRTOS_STart. Processor %d", GRTOS_CMD_PRC_ID );
402  G_DEBUG_WHILEFOREVER;
403 }
404 
405 /***********************************************************************************
406 *********************** GRTOS TASK FINISH FUNCTION *******************************
407 ***********************************************************************************/
412 {
413  SAMPLE_FUNCTION_BEGIN(1003);
414 
415  GRTOS_USER_CRITICAL_SECTION_GET;
416 
417  GS_TCB *ptcbtostart = gk_PCB_GetCurrentTCB();
418 
419 #if G_DEBUG_WHILEFOREVER_ENABLE == 1
420  if (TCB_IsValid(ptcbtostart) != G_TRUE) {PRINT_TO_DEBUG("ERROR TCB= %p\n",ptcbtostart); G_DEBUG_WHILEFOREVER;}
421  void *StackPointer;
422  NIOS2_READ_SP(StackPointer);
423  if ((int) StackPointer > (int) ptcbtostart->TCB_StackBottom) G_DEBUG_WHILEFOREVER;
424  if ((int) StackPointer < (int) ptcbtostart->TCB_StackTop - 300) G_DEBUG_WHILEFOREVER;
425  if (ptcbtostart->TCBState != G_TCBState_RUNNING) G_DEBUG_WHILEFOREVER; PRINT_DEBUG_LINE
426 #endif
427 
428  gk_TCB_Unlink(ptcbtostart);
429 
430  gk_TCBWL_Link(ptcbtostart, G_TCBState_WAITING_COMPLETED);
431 
433  if (ptcbtostart->TCBType == G_TCBType_ISR) {
434  gk_ISR_COMPLETE (ptcbtostart);
435  }
436 
438  ptcbtostart = gk_PCB_GetNextTCB();
439 
440 #if G_DEBUG_WHILEFOREVER_ENABLE == 1
441  if ((TCB_IsValid(ptcbtostart) != G_TRUE) || (ptcbtostart == (struct gs_tcb *) 0)) G_DEBUG_WHILEFOREVER;
442  if (ptcbtostart->TCBState != G_TCBState_READY) G_DEBUG_WHILEFOREVER;
443 #endif
444 
445  gk_TCBRDYL_Unlink(ptcbtostart);
446  gk_TCBRUNL_Link(ptcbtostart);
447 
451 
452  //Load the processor status and return to execute the HighRdy task
453  SAMPLE_FUNCTION_END(1003);
454  GRTOS_Start_Task();
455 
456  /* Never should be executed this */
457  printf("Error in gk_KERNEL_TASK_COMPLETE. Processor %d", GRTOS_CMD_PRC_ID );
458  G_DEBUG_WHILEFOREVER;
459 
460 }
461 
462 
463 /***********************************************************************************
464 *********************** GRTOS SUSPEND TASK FUNCTION *******************************
465 ***********************************************************************************/
471 {
472  SAMPLE_FUNCTION_BEGIN(1004);
473  /* if not running nor ready, then nothing to do */
474  if (ptcb->TCBState != G_TCBState_READY && ptcb->TCBState != G_TCBState_RUNNING)
475  {
476  if (ptcb != gk_PCB_GetCurrentTCB()) {
477  gk_KERNEL_TASK_SUSPEND_CURRENT(); /* Suspend the current task */
478  } else {
479  /* Check current task state */
480  if (ptcb->TCBState == G_TCBState_RUNNING){
481  /* task is running, interrupt processor */
482  // j = ptcb->TCB_AssocPCB;
483  // fprintf(stderr, "[ OK ] Processor %d trigger proc %d in %s, %d\n", GRTOS_CMD_PRC_ID, j, __FUNCTION__,__LINE__);
484  GRTOS_CMD_PRC_INT(ptcb->TCB_AssocPCB);
485  }
486  /* Unlink the task from ready or running */
487  gk_TCB_Unlink(ptcb);
488  /* Link the task to the waiting list */
489  gk_TCBWL_Link(ptcb, G_TCBState_WAITING);
490  }
491  }
492  SAMPLE_FUNCTION_END(1004);
493 }
494 
495 
503 {
504  /* Check if Executing task is running or if it was desalocated */
505  GS_TCB *ptcbfrom = gk_PCB_GetCurrentTCB();
506 
507  SAMPLE_FUNCTION_BEGIN(1005);
508 
509 #if G_DEBUG_WHILEFOREVER_ENABLE == 1
510  if (TCB_IsValid(ptcbfrom) != G_TRUE || ptcbfrom == (GS_TCB *) 0) G_DEBUG_WHILEFOREVER;
511  if (ptcbfrom->TCBState != G_TCBState_RUNNING) G_DEBUG_WHILEFOREVER;
512 #endif
513 
514  // Assembler code reads this variable to storage the sp register
515  G_TCB_CURRENT = (GS_STK) &g_kcb.G_PCBTbl[GRTOS_CMD_PRC_ID -1].PCB_EXECTCB->TCB_StackPointer;
516 
517  gk_TCBRUNL_Unlink(ptcbfrom);
518  gk_TCBWL_Link(ptcbfrom, G_TCBState_WAITING);
519 
520  SAMPLE_FUNCTION_END(1005);
521 
522  /* Suspend current task and execute next ready */
524 
525  // This code is out of the CRITICAL SECTION
526 }
527 
528 
529 
530 /***********************************************************************************
531 *********************** GRTOS INITIALISATION FUNCTIONS ****************************
532 ***********************************************************************************/
533 
549 // static void gk_Prologe (void) __attribute__ ((constructor));
550 // void gk_Prologe (void)
551 
552 void gk_INIT_KERNEL(void) __attribute__ ((constructor));
553 void gk_INIT_KERNEL(void)
554 {
555  int i,j;
556 
557 #if G_DEBUG_WHILEFOREVER_ENABLE == 1
558  if (GRTOS_CMD_PRC_ID != (int) 1) while(1);
559 #endif
560 
561 
562  GRTOS_CMD_RST_GRTOS; // Reset the rest of processor assigning 0 to R_PRC_RST register
563 
564  // Initialize run time
565  G_Running = G_FALSE;
568 
569 #if G_DEBUG_WHILEFOREVER_ENABLE == 1
570  fprintf(stderr,"[ MESSAGE ] INITIALIZE THE KCB STRUCTURE\n");
571 #endif
572 
573  GRTOS_CMD_SET_TIME_PRESCALE((int) GRTOS_DRIVER_PRESCALE);
574 
576  g_kcb.KCB_NextECBTL = (struct gs_ecb *) 0;
577  g_kcb.KCB_NextTCBWL = (struct gs_tcb *) 0; /* No task waiting */
578  g_kcb.KCB_NextLCBL = (struct gs_lcb *) 0;
579  g_kcb.KCB_NextKCBASL = (struct gs_scb *) 0;
580 
581  g_kcb.KCB_NUMBER_OF_TCBs = 0;
582  g_kcb.KCB_NUMBER_OF_PCBs = 0;
583  g_kcb.KCB_NUMBER_OF_ECBs = 0;
584  g_kcb.KCB_NUMBER_OF_RCBs = 0;
585  g_kcb.KCB_NUMBER_OF_LCBs = 0;
586  g_kcb.KCB_NUMBER_OF_SCBs = 0;
587  g_kcb.KCB_NUMBER_OF_RRDSs = 0;
588 
589  g_kcb.KCB_ROOT_TCBs = (struct gs_tcb *) 0;
590  g_kcb.KCB_ROOT_ECBs = (struct gs_ecb *) 0;
591  g_kcb.KCB_ROOT_RCBs = (struct g_rcb *) 0;
592  g_kcb.KCB_ROOT_LCBs = (struct gs_lcb *) 0;
593  g_kcb.KCB_ROOT_SCBs = (struct gs_scb *) 0;
594  g_kcb.KCB_ROOT_RRDSs = (struct gs_rrds *) 0;
595 
596 
597  // volatile INT32 G_ISR_STACK[ALT_NIRQ][G_ISR_STACKSIZE] __attribute__((aligned(4)));
598  void *mem1 = malloc(sizeof(INT32) * ALT_NIRQ * G_ISR_STACKSIZE + 31);
599  g_kcb.G_ISR_STACK = (INT32 *) (((uintptr_t)mem1+15) & ~ (uintptr_t)0x0F);
600 
601  // volatile GS_STK G_IDLE_STACK[G_NUMBER_OF_PCB][G_IDLE_STACKSIZE] __attribute__((aligned(4)));
602  void *mem2 = malloc(sizeof(GS_STK) * G_NUMBER_OF_PCB * G_IDLE_STACKSIZE + 31);
603  g_kcb.G_IDLE_STACK = (GS_STK *) (((uintptr_t)mem2+15) & ~ (uintptr_t)0x0F);
604 
605 
606  /*************************************************************************************/
607  /* Reserve system Conrol Blocks */
608  /*************************************************************************************/
609 #if G_DEBUG_WHILEFOREVER_ENABLE == 1
610  fprintf(stderr,"[ MESSAGE ] CREATING PCB STRUCTURES\n");
611 #endif
612  gk_Create_PCBs((int) G_NUMBER_OF_PCB);
613 
614 
615  /*************************************************************************************/
616  /* Assign default values */
617  /*************************************************************************************/
618  G_TASK_TYPE_DEFAULT = G_TCBType_UCOS;
620  G_TASK_PRIORITY_DEFAULT = (INT64) 0x7FFFFFFFFFFFFFF0LL;
621  G_TASK_PERIOD_DEFAULT = (INT64) 0x7FFFFFFFFFFFFFF0LL;
622 
623  /*************************************************************************************/
624  /* RTOS Variables and GRTOS Controller Initialization */
625  /*************************************************************************************/
627  GRTOS_MutexReleaseRegisterAddress = (INT32) (GRTOS_DRIVER_GRTOS_BASE + 4 * ADDR_MTX_RLS);
628  GRTOS_MutexRequestRegisterAddress = (INT32) (GRTOS_DRIVER_GRTOS_BASE + 4 * ADDR_MTX_GRN);
629  GRTOS_InterruptEnableRegisterAddress = (INT32) (GRTOS_DRIVER_GRTOS_BASE + 4 * ADDR_INT_ENB_SET);
630  GRTOS_InterruptDisableRegisterAddress = (INT32) (GRTOS_DRIVER_GRTOS_BASE + 4 * ADD_INT_ENB_CLR);
631  gs_sizeof_G_PCBTbl = sizeof(GS_PCB);
632  gs_addressof_G_PCBTbl = (void *) &g_kcb.G_PCBTbl[0];
633  gs_offsetof_PCB_IDLETCB = (INT32) (&((GS_PCB *) NULL)->PCB_IDLETCB);
634  gs_offsetof_PCB_EXECTCB = (INT32) (&((GS_PCB *) NULL)->PCB_EXECTCB);
635  gs_offsetof_TCB_StackPointer = (INT32) (&((GS_TCB *) NULL)->TCB_StackPointer);
636 
637 
638 #if G_DEBUG_WHILEFOREVER_ENABLE == 1
639  fprintf(stderr,"[ MESSAGE ] INITIALIZE THE LCB LIST\n");
640 #endif
641 
642 #if G_DEBUG_WHILEFOREVER_ENABLE == 1
643  fprintf(stderr,"[ MESSAGE ] INITIALIZE THE TIMED EVENT LIST\n");
644 #endif
645  g_kcb.KCB_NextECBTL = (struct gs_ecb *) gk_ECB_GetFree();
647 #if G_DEBUG_WHILEFOREVER_ENABLE == 1
648  if (ECB_IsValid(g_kcb.KCB_NextECBTL) != G_TRUE) G_DEBUG_WHILEFOREVER;
649 #endif
650  GRTOS_CMD_NXT_OCC_TM_EVN_SET(G_LATEST_TIME);
653  g_kcb.KCB_NextECBTL->ECBValue.i64 = (INT64) G_LATEST_TIME;
654  g_kcb.KCB_NextECBTL->ECB_AssocTCB = (struct gs_tcb *) 0;
655  g_kcb.KCB_NextECBTL->ECB_PrevTCBAEL = (struct gs_ecb *) 0;
656  g_kcb.KCB_NextECBTL->ECB_NextTCBAEL = (struct gs_ecb *) 0;
657  g_kcb.KCB_NextECBTL->ECB_PrevECB = (struct gs_ecb *) 0;
658  g_kcb.KCB_NextECBTL->ECB_NextECB = (struct gs_ecb *) 0;
659  g_kcb.KCB_NextECBTL->ECB_NextECBASL = (struct gs_scb *) 0;
660  g_kcb.KCB_NextECBTL->ECBType = (INT32) G_ECBType_LASTEST_TIME;
661  g_kcb.KCB_NextECBTL->ECBState = GS_ECBState_WAITING_TIME;
662 
664  for (i = 0; i < G_NUMBER_OF_PCB; i++) {
665 
666  // g_kcb.GRTOS_PROCESSOR_BASE[i+1] = GRTOS_DRIVER_GRTOS_PROCESSOR_BASE[i];
667  g_kcb.G_PCBTbl[i].GRTOS_PROCESSOR_BASE = (int *) GRTOS_DRIVER_GRTOS_PROCESSOR_BASE[i]; // Address to go to idle state
668 
669  g_kcb.G_PCBTbl[i].PCB_IDLETCB = (struct gs_tcb *) gk_TCB_GetFree();
670  if (g_kcb.G_PCBTbl[i].PCB_IDLETCB == (struct gs_tcb *) 0) G_DEBUG_WHILEFOREVER;
671 
672  g_kcb.G_PCBTbl[i].PCB_IDLETCB->TCBType = G_TCBType_IDLE;
673  // g_kcb.G_PCBTbl[i].PCB_IDLETCB->TCB_StackBottom = (GS_STK *) ((((INT32) &g_kcb.G_IDLE_STACK[i][G_IDLE_STACKSIZE-8])-8)& ~0x3);
674  g_kcb.G_PCBTbl[i].PCB_IDLETCB->TCB_StackBottom = (GS_STK *) ((((INT32) g_kcb.G_IDLE_STACK + (i * G_IDLE_STACKSIZE) + G_IDLE_STACKSIZE-8)-8)& ~0x3);
675 
676  g_kcb.G_PCBTbl[i].PCB_IDLETCB->TCB_StackTop = (GS_STK *)((INT32) g_kcb.G_PCBTbl[i].PCB_IDLETCB->TCB_StackBottom - ((INT32)(G_IDLE_STACKSIZE)& ~0x3));
677  g_kcb.G_PCBTbl[i].PCB_IDLETCB->TCB_TaskCode = gk_CODE_IDLE_TASK;
678  g_kcb.G_PCBTbl[i].PCB_IDLETCB->TCB_TaskArg = (void *) NULL;
679  g_kcb.G_PCBTbl[i].PCB_IDLETCB->TCBReadyPriority = G_IDLETASK_PRIORITY;
680  g_kcb.G_PCBTbl[i].PCB_IDLETCB->TCBRunPriority = G_IDLETASK_PRIORITY;
681  g_kcb.G_PCBTbl[i].PCB_IDLETCB->TCB_RDY_LCB_Index = (struct gs_lcb *) G_TASK_LCB_DEFAULT;
682 
683  gk_TASK_STK_Init(g_kcb.G_PCBTbl[i].PCB_IDLETCB);
684  gk_TCBRDYL_Link(g_kcb.G_PCBTbl[i].PCB_IDLETCB); /* Insert Task in Ready List */
685 
686  g_kcb.G_PCBTbl[i].PCBState = GS_PCBState_NOTRUNNING;
687 
688  g_kcb.G_PCBTbl[i].PCB_IDLETCB->TCB_AssocPCB = i + 1;
689  g_kcb.G_PCBTbl[i].PCB_EXECTCB = g_kcb.G_PCBTbl[i].PCB_IDLETCB;
690  for (j = 0; j < G_NUMBER_OF_LCBs_FOR_PCB; j++) {
691  g_kcb.G_PCBTbl[i].PCB_RDY_LCBL[j] = (struct gs_lcb *) G_TASK_LCB_DEFAULT;
692  }
693  g_kcb.G_PCBTbl[i].PCBID = (int) 0;
694  g_kcb.G_PCBTbl[i].PCBType = (int) GS_PCBType_UNSPECIFIED;
695  g_kcb.G_PCBTbl[i].PCB_NextPCB = (struct gs_pcb *) 0;
696  g_kcb.G_PCBTbl[i].PCB_PrevPCB = (struct gs_pcb *) 0;
697  }
698  // Initialize the External Interrupt structure
699  for (i=0 ; i<ALT_NIRQ ; i++)
700  {
701  g_kcb.KCB_ExtISR[i].G_TCB_ISR = (struct gs_tcb *) 0;
702  g_kcb.KCB_ExtISR[i].G_EXT_INT_Count = (int) 0;
703  GRTOS_CMD_IRQ_ENB_CLR(i);
704  }
705 
706  fprintf(stderr, "[ OK ] Finishing gk_INIT_KERNEL \n");
707 }
708 
709 /***********************************************************************************
710 *********************** GRTOS RESET FUNCTIONS FOR ID=1 PROCESSOR *************
711 ***********************************************************************************/
712 
720 static void gk_START_KERNEL (void) __attribute__ ((destructor));
721 void gk_START_KERNEL (void)
722 {
723  int i;
724  char filename[20];
725 
726  SAMPLE_FUNCTION_BEGIN(1006);
727 
728  #if G_DEBUG_WHILEFOREVER_ENABLE == 1
729  fprintf(stderr,"[ MESSAGE ] Executing %s, %d, Proc: %d\n",__FUNCTION__,__LINE__,GRTOS_CMD_PRC_ID);
730  #endif
731 
732  GRTOS_USER_CRITICAL_SECTION_GET;
733  GRTOS_USER_CRITICAL_SECTION_SET_RELEASE_TIME(200);
734 
735  #if G_DEBUG_WHILEFOREVER_ENABLE == 1
736  fprintf(stderr,"[ MESSAGE ] Executing %s, %d, Proc: %d\n",__FUNCTION__,__LINE__,GRTOS_CMD_PRC_ID);
737  #endif
738 
739  for (i=0; i<G_NUMBER_OF_PCB ; i++) {
740  // sprintf(filename, "/dev/jtag_uart_%d", i+2);
741  sprintf(filename, "/dev/%s_jtag_uart_%d", GRTOS_DRIVER_SYSTEM_NAME, i+2);
742  fpuart[i] = fopen (filename, "r+"); //Open file for reading and writing one for each processor starting in 2 (0 for stdio, 1 for stderr)
743  }
744 
745  #if G_DEBUG_WHILEFOREVER_ENABLE == 1
746  fprintf(stderr,"[ MESSAGE ] Executing %s, %d, Proc: %d\n",__FUNCTION__,__LINE__,GRTOS_CMD_PRC_ID);
747  #endif
748 
750  NIOS2_WRITE_STATUS(0);
752  NIOS2_READ_IPENDING(G_IRQ_PENDING);
753  NIOS2_READ_IENABLE(G_IRQ_ENABLED);
754 
755  #if G_DEBUG_WHILEFOREVER_ENABLE == 1
756  fprintf(stderr,"[ MESSAGE ] Executing %s, %d, Proc: %d\n",__FUNCTION__,__LINE__,GRTOS_CMD_PRC_ID);
757  #endif
758 
760  for (i=0; i<32 ; i++) {
761  alt_ic_irq_disable(0,i);
762  // fprintf(stderr, "[ OK ] Disabling interrupt device drivers\n");
763  }
764 
767  // fprintf(stderr, "[ OK ] Installing GRTOS Controller interrupt\n");
768  alt_ic_isr_register((alt_u32) GRTOS_DRIVER_GRTOS_S_PROCESSOR1_IRQ_INTERRUPT_CONTROLLER_ID,
769  (alt_u32) GRTOS_DRIVER_GRTOS_S_PROCESSOR1_IRQ,
770  // (alt_isr_func) gk_ENTRY_IRQ_HANDLER,
771  (alt_isr_func) grtos_irq_entry,
772  (void *) NULL,
773  (void *) NULL);
774 
775  // alt_instruction_exception_register((alt_exception_result *) handler, ((alt_exception_cause) cause, (alt_u32) addr, (alt_u32) bad_addr ));
776 
777  #if G_DEBUG_WHILEFOREVER_ENABLE == 1
778  fprintf(stderr,"[ MESSAGE ] Executing %s, %d, Proc: %d\n",__FUNCTION__,__LINE__,GRTOS_CMD_PRC_ID);
779  #endif
780 
781  NIOS2_WRITE_IENABLE (0);
782  NIOS2_WRITE_STATUS(0);
783 
785  #if G_GRTOS_PRESERVE_HAL_ISR == 1
786  gk_INIT_IRQ();
787  #endif
788 
789  #if G_DEBUG_WHILEFOREVER_ENABLE == 1
790  fprintf(stderr,"[ MESSAGE ] Executing %s, %d, Proc: %d\n",__FUNCTION__,__LINE__,GRTOS_CMD_PRC_ID);
791  #endif
792 
793  g_kcb.G_PCBTbl[GRTOS_CMD_PRC_ID -1].PCBState = GS_PCBState_RUNNING; // to set it to FREE
794  g_kcb.G_PCBTbl[GRTOS_CMD_PRC_ID -1].PCBID = GRTOS_CMD_PRC_ID ; PRINT_DEBUG_LINE
795  g_kcb.G_PCBTbl[GRTOS_CMD_PRC_ID -1].PCB_EXECTCB = g_kcb.G_PCBTbl[GRTOS_CMD_PRC_ID -1].PCB_IDLETCB;
796  gk_LCBFPL_Link(GRTOS_CMD_PRC_ID);
797 
798  #if G_DEBUG_WHILEFOREVER_ENABLE == 1
799  fprintf(stderr,"[ MESSAGE ] Executing %s, %d, Proc: %d\n",__FUNCTION__,__LINE__,GRTOS_CMD_PRC_ID);
800  #endif
801 
802  G_Running = G_TRUE; /* First processor is CPU 1 because G_Runninh flag is set to TRUE here */
803 
804  #if G_DEBUG_WHILEFOREVER_ENABLE == 1
805  fprintf(stderr,"[ MESSAGE ] Executing %s, %d, Proc: %d\n",__FUNCTION__,__LINE__,GRTOS_CMD_PRC_ID);
806  #endif
807 
808  #if G_DEBUG_WHILEFOREVER_ENABLE == 1
809  fprintf(stderr,"[ MESSAGE ] Executing %s, %d, Proc: %d\n",__FUNCTION__,__LINE__,GRTOS_CMD_PRC_ID);
810  #endif
811 
812  SAMPLE_FUNCTION_END(1006);
813 
814  gk_KERNEL_TASK_START(); // Start the GRTOS for processor 1
815 
816  printf("******************************************** \n");
817  printf("ERROR Processor %d Init GRTOS \n", GRTOS_CMD_PRC_ID );
818  printf("******************************************** \n");
819 
820  /****************************************************/
821  /****************************************************/
822  /* Code to produce assembler in objdump file */
823  /* IT IS NEVER EXECUTED */
824  /****************************************************/
825  /****************************************************/
826  while(1);
827 
828 }
829 
836 {
837  SAMPLE_FUNCTION_BEGIN(68)
838  GS_TCB *ptcb =gk_PCB_GetCurrentTCB(); /* Get Current Task */
839  GS_SCB *psignal = ptcb->TCB_NextTCBPSL; /* Get Next Pending Signal */
840 
841  G_SCB_PENDING = 0; /* Default is no pending SCB */
842 
843  if (psignal != (struct gs_scb *) 0) /* There is a pending SCB */
844  {
845  if (psignal->SCBState == G_SCBState_PENDING) { /* Signal is pending */
846  psignal->SCBState = G_SCBState_EXECUTING; /* Signal to execution */
847  G_SCB_CODE = (INT32) psignal->SCB_TaskCode + 4; /* Task Code */
848  G_SCB_ARG = (INT32) psignal->SCB_TaskArg; /* Task Argument */
849  gk_TCBPSL_Unlink(ptcb, psignal); /* Unlink SCB from TCB */
850  gk_SCBFL_Link(psignal); /* Link SCB to free list */
851  G_SCB_PENDING = 1; /* Set the Pending Signal status */
852  }
853  }
854  alt_dcache_flush_all();
855  SAMPLE_FUNCTION_END(68)
856 }
857 
858 /**********************************************************************************
859  * Exception handler
860  * from http://www-ug.eecg.toronto.edu/msl/manuals/n2sw_nii52006.pdf
861  *********************************************************************************/
862 
863 // alt_exception_result handler (alt_exception_cause cause,
864 // alt_u32 addr,
865 // alt_u32 bad_addr )
866 // {
867 // fprintf(stderr,"[ EXCEPTION ] cause= %d, address= 0x%x, bad_addr: 0x%x\n", (int) cause, (unsigned int) addr, (unsigned int) bad_addr);
868 // }
869 
870 /**********************************************************************************
871  * IDLE TASK DOING NOTHING
872  *********************************************************************************/
880 void gk_CODE_IDLE_TASK(void* pdata)
881 {
882  while(1)
883  {
884  #if G_DEBUG_PRINT_WHEN_PROCESSOR_GOES_IDLE == 1
885  fprintf(fpuart[GRTOS_CMD_PRC_ID-1], "I\n");
886  #endif
887  GRTOS_CMD_HALT_PROCESSOR; // Put the procesor in HALT mode
888  }
889 }
890 
891 
892 OPTIMEZE_RESTORE
INT32
unsigned INT32
Definition: gemrtos_core.h:62
ECB_IsValid
INT32 ECB_IsValid(GS_ECB *pevent)
Returns G_TRUE is pointer points to ECB.
Definition: monitor.c:109
gk_ENTRY_SIGNAL_RETURN
void gk_ENTRY_SIGNAL_RETURN(void)
Return from Signal:
Definition: grtos_kernel.c:308
GRTOS_MutexReleaseRegisterAddress
volatile INT32 GRTOS_MutexReleaseRegisterAddress
G_SCB_ARG
volatile INT32 G_SCB_ARG
Processor::gk_LCB_CheckInvertion
INT32 gk_LCB_CheckInvertion(void)
Checks if there is a processor that has to be interrupted to switch task and interruupt it all.
Definition: listfunctions.c:2496
G_DEBUG_SAMPLE_END_ENABLE
volatile int G_DEBUG_SAMPLE_END_ENABLE
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
G_TASK_PRIORITY_DEFAULT
volatile INT64 G_TASK_PRIORITY_DEFAULT
G_DEBUG_SAMPLE_BEGIN_ENABLE
volatile int G_DEBUG_SAMPLE_BEGIN_ENABLE
gs_sizeof_G_PCBTbl
volatile INT32 gs_sizeof_G_PCBTbl
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
gk_INIT_KERNEL
void gk_INIT_KERNEL(void)
Routine execute BEFORE the main() function, ONLY by PROCESSOR 1.
Definition: grtos_kernel.c:552
gk_KERNEL_TASK_COMPLETE
void gk_KERNEL_TASK_COMPLETE(void)
This function is executed when a task finishes its execution.
Definition: grtos_kernel.c:411
G_TASK_LCB_DEFAULT
volatile GS_LCB* G_TASK_LCB_DEFAULT
G_Running
volatile INT32 G_Running
GRTOS_InterruptEnableRegisterAddress
volatile INT32 GRTOS_InterruptEnableRegisterAddress
gs_addressof_G_PCBTbl
volatile void* gs_addressof_G_PCBTbl
gs_ecb
GS_ECB Event Control Block structure.
Definition: gemrtos_core.h:107
gk_KERNEL_TASK_START
void gk_KERNEL_TASK_START(void)
Start the execution of the tasks of the system.
Definition: grtos_kernel.c:352
gk_RST_MONITOR_HANDLER
void gk_RST_MONITOR_HANDLER(void)
Definition: monitor.c:53
grtos_irq_entry
void grtos_irq_entry(void)
gs_lcb
GS_LCB List Control Block.
Definition: gemrtos_core.h:203
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.
Definition: grtos_kernel.c:502
Task::GRTOS_Task_GetPendingSCB
void GRTOS_Task_GetPendingSCB(void)
Configures system to execute next pending signal. Call from switch routine.
Definition: grtos_kernel.c:835
Task::gk_CODE_IDLE_TASK
void gk_CODE_IDLE_TASK(void* pdata)
IDLE task. This code is executed when no task is ready. The processor is halted.
Definition: grtos_kernel.c:880
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
Processor::gk_PCB_GetNextTCB
GS_TCB* gk_PCB_GetNextTCB(void)
Returns the next TCB to be executed by the current processor. If no task is requesting for execution,...
Definition: listfunctions.c:2333
gs_tcb
gs_tcb Task Control Block (TCB) structure
Definition: gemrtos_core.h:439
Task::gk_TCBRDYL_Unlink
INT32 gk_TCBRDYL_Unlink(GS_TCB *ptcb)
Unlinks the TCB from the Ready Task List.
Definition: listfunctions.c:1740
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_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
Task::gk_TCBPSL_Unlink
INT32 gk_TCBPSL_Unlink(GS_TCB *ptcb, GS_SCB *psignal)
Unlinks SCB from TCB Pending Signal List.
Definition: listfunctions.c:1606
Time::gk_TIME_CALLBACK
void gk_TIME_CALLBACK(GS_ECB *pevent)
This function is called when a time event happened. It has to resolve according the event type.
Definition: grtosuserfunctions.c:829
GS_KCB
struct gs_kcb GS_KCB
Definition: gemrtos_core.h:47
G_TCB_CURRENT
volatile GS_STK G_TCB_CURRENT
G_TASK_PERIOD_DEFAULT
volatile INT64 G_TASK_PERIOD_DEFAULT
GRTOS_Suspend_Task
void GRTOS_Suspend_Task(void)
grtos.h
Definition of GRTOS controller address.
gk_TCB_GetFree
GS_TCB* gk_TCB_GetFree(void)
g_kcb
GS_KCB g_kcb
gk_ENTRY_IRQ_HANDLER
void gk_ENTRY_IRQ_HANDLER(void)
Executes the ISR of GRTOS.
Definition: grtos_kernel.c:186
G_TASK_TYPE_DEFAULT
volatile INT32 G_TASK_TYPE_DEFAULT
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_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
gk_ENTRY_BAD_TASK_RETURN
void gk_ENTRY_BAD_TASK_RETURN(void)
BAD RETURN FUNCTION IN TASK STACK.
Definition: grtos_kernel.c:294
GRTOS_InterruptDisableRegisterAddress
volatile INT32 GRTOS_InterruptDisableRegisterAddress
INT64
unsigned long long INT64
Definition: gemrtos_core.h:61
Processor::gk_LCBFPL_Link
INT32 gk_LCBFPL_Link(int processorID)
Links a PCB to the LCB Free Processor List of foreground list of the processor.
Definition: listfunctions.c:659
Task::gk_PCB_GetCurrentTCB
GS_TCB* gk_PCB_GetCurrentTCB(void)
Returns the task that the current processor was executing.
Definition: listfunctions.c:2262
gs_offsetof_PCB_IDLETCB
volatile INT32 gs_offsetof_PCB_IDLETCB
Core::gk_Get_LCB
GS_LCB* gk_Get_LCB(void)
Creates a LCB and returns its pointer.
Definition: gemrtos_core.c:264
gs_offsetof_PCB_EXECTCB
volatile INT32 gs_offsetof_PCB_EXECTCB
Processor::gk_SetLowestProcessor
INT32 gk_SetLowestProcessor(void)
Sets the Lowest Processor register in GRTOS Controller.
Definition: listfunctions.c:2386
GS_ECB
struct gs_ecb GS_ECB
Definition: gemrtos_core.h:51
Task::gk_TCBRUNL_Unlink
INT32 gk_TCBRUNL_Unlink(GS_TCB *ptcb)
Unlinks TCB from Running List.
Definition: listfunctions.c:1915
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
Time::gk_FROZEN_CALLBACK
void gk_FROZEN_CALLBACK(void)
This function is called when a frozzen event happened.
Definition: grtosuserfunctions.c:924
Processor::gk_SetNextTimeProcessor
INT32 gk_SetNextTimeProcessor(void)
Sets the Next Time Processor register in GRTOS Controller.
Definition: listfunctions.c:2408
gs_rrds
GS_RRDS Resource Request Data Structure.
Definition: gemrtos_core.h:357
gk_KERNEL_TASK_SUSPEND
void gk_KERNEL_TASK_SUSPEND(GS_TCB *ptcb)
Suspends the execution of the task pointed by ptcb.
Definition: grtos_kernel.c:470
GS_STK
unsigned int GS_STK
Definition: gemrtos_core.h:63
G_SCB_PENDING
volatile INT32 G_SCB_PENDING
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
G_SCB_CODE
volatile INT32 G_SCB_CODE
gemrtos_core.h
GEmRTOS CORE definitions.
GRTOS_MutexRequestRegisterAddress
volatile INT32 GRTOS_MutexRequestRegisterAddress
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
GRTOS_S_PROCESSOR1_IRQ
volatile int GRTOS_S_PROCESSOR1_IRQ
TCB_IsValid
INT32 TCB_IsValid(GS_TCB *ptcb)
Definition: monitor.c:76
GRTOS_Start_Task
void GRTOS_Start_Task(void)
fpuart
FILE* fpuart[G_NUMBER_OF_PCB]
Signal::gk_SCBFL_Link
INT32 gk_SCBFL_Link(GS_SCB *psignal)
Links a SCB to the Free List.
Definition: listfunctions.c:1173
Task::gk_TCBRUNL_Link
INT32 gk_TCBRUNL_Link(GS_TCB *ptcb)
Links the TCB to the Run Task List.
Definition: listfunctions.c:1786
G_IRQ_PENDING
volatile int G_IRQ_PENDING
Event::gk_ECBTL_Unlink
INT32 gk_ECBTL_Unlink(GS_ECB *pevent)
Unlinks the ECB from the Time Event List.
Definition: listfunctions.c:405
gs_offsetof_TCB_StackPointer
volatile INT32 gs_offsetof_TCB_StackPointer