GeMRTOS
monitor.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 
30 #include <grtos.h>
31 #include "gemrtos_core.h"
32 
34 
35 
41 void gk_MONITOR_FIFO_SAMPLE (int data)
42 {
43  IOWR(GRTOS_DRIVER_GRTOS_MONITOR_BASE, 0, data);
44 }
45 
46 /*****************************************************************************/
47 /*****************************************************************************/
50 /*****************************************************************************/
51 /*****************************************************************************/
52 
54 {
55 
56  GRTOS_CMD_RLS_NXT_PRC; // Enables the next processor to start
57  while(1)
58  {
59 
60  // FILE* fp; PRINT_DEBUG_LINE
61  // fp = fopen ("/dev/jtag_uart_1", "r+"); PRINT_DEBUG_LINE //Open file for reading and writing
62  // if (fp)
63  // {
64  // fprintf(fp, "Closing the JTAG UART file handle.\n"); PRINT_DEBUG_LINE
65  // fclose (fp); PRINT_DEBUG_LINE
66  // }
67  }
68 }
69 
70 
77 {
78  if (ptcb == (GS_TCB *) 0) return(G_FALSE);
79  if (ptcb->BLOCK_HASH == (unsigned int) ptcb + 1) return(G_TRUE);
80  return(G_FALSE);
81 }
82 
84 {
85  int processor;
86 
87  if (ppcb == (struct gs_pcb *) 0) return(G_FALSE);
88  /* Si apunta fuera del arreglo de TCBs retorno G_FALSE */
89  if (ppcb > g_kcb.G_PCBTbl + G_NUMBER_OF_PCB * sizeof(GS_PCB)) return(G_FALSE);
90  /* Si apunta a una direccion antes del arreglo TCBs retorno G_FALSE */
91  if (ppcb < g_kcb.G_PCBTbl) return(G_FALSE);
92 
93  /* Obtengo el indice de la tarea */
94  processor = (int) ppcb - (int) g_kcb.G_PCBTbl;
95  processor = (int) processor / sizeof(GS_PCB);
96  processor = (processor * sizeof(GS_PCB)) + (int) g_kcb.G_PCBTbl;
97  /* Si el indice apunta a un TCB retorno G_TRUE, si no G_FALSE */
98  if (processor != (int) ppcb) return(G_FALSE);
99  else return(G_TRUE);
100 }
101 
102 
110 {
111  if (pevent == (GS_ECB *) 0) return(G_FALSE);
112  if (pevent->BLOCK_HASH == (unsigned int) pevent + 2) return(G_TRUE);
113  return(G_FALSE);
114 }
115 
127 {
128  if (pscb == (GS_SCB *) 0) return(G_FALSE);
129  if (pscb->BLOCK_HASH == (unsigned int) pscb + 4) return(G_TRUE);
130  return(G_FALSE);
131 }
132 
133 
142 INT32 RCB_IsValid(void *prcb)
143 {
144  if (prcb == (void *) 0) return(G_FALSE);
145  if (((G_RCB *) prcb)->BLOCK_HASH == (unsigned int) prcb + 3) return(G_TRUE);
146  return(G_FALSE);
147 }
148 
149 
159 {
160  if (prrds == (GS_RRDS *) 0) return(G_FALSE);
161  if (prrds->BLOCK_HASH == (unsigned int) prrds + 5) return(G_TRUE);
162  return(G_FALSE);
163 }
164 
165 
166 
168 {
169  if (plcb == (GS_LCB *) 0) return(G_FALSE);
170  if (plcb->BLOCK_HASH == (unsigned int) plcb + 6) return(G_TRUE);
171  return(G_FALSE);
172 }
173 
175 {
176  /* si es puntero nulo retorno G_TRUE */
177  if (plcb == (struct gs_lcb *) 0) return(G_TRUE);
178  if (plcb->BLOCK_HASH == (unsigned int) plcb + 6) return(G_TRUE);
179  return(G_FALSE);
180 }
181 
182 INT32 TCBState_Valid(unsigned int tcbstate)
183 {
184  if (tcbstate == G_TCBState_WAITING_COMPLETED) return G_TRUE;
185  if (tcbstate == G_TCBState_READY) return G_TRUE;
186  if (tcbstate == G_TCBState_RUNNING) return G_TRUE;
187  if (tcbstate == G_TCBState_FREE) return G_TRUE;
188  if (tcbstate == G_TCBState_UNLINKED) return G_TRUE;
189  if (tcbstate == G_TCBState_WAITING) return G_TRUE;
190  return G_FALSE;
191 }
192 
193 INT32 TCBType_Valid(unsigned int tcbtype)
194 {
195  if (tcbtype == G_TCBType_UCOS) return G_TRUE;
196  if (tcbtype == G_TCBType_PERIODIC) return G_TRUE;
197  if (tcbtype == G_TCBType_ISR) return G_TRUE;
198  if (tcbtype == G_TCBType_IDLE) return G_TRUE;
199  if (tcbtype == G_TCBType_UNDEFINED) return G_TRUE;
200  return G_FALSE;
201 }
202 
203 INT32 ECBState_Valid(unsigned int ecbstate)
204 {
205  if (ecbstate == GS_ECBState_GRANTED_RESOURCE) return G_TRUE;
206  if (ecbstate == GS_ECBState_WAITING_RESOURCE) return G_TRUE;
207  if (ecbstate == GS_ECBState_FREE) return G_TRUE;
208  if (ecbstate == GS_ECBState_WAITING_TIME) return G_TRUE;
209  if (ecbstate == GS_ECBState_UNLINKED) return G_TRUE;
210  return G_FALSE;
211 }
212 
213 INT32 ECBType_Valid(unsigned int ecbtype)
214 {
215  if (ecbtype == G_ECBType_OSTimeDly) return G_TRUE;
216  if (ecbtype == G_ECBType_PERIODIC) return G_TRUE;
217  if (ecbtype == G_ECBType_LASTEST_TIME) return G_TRUE;
218  if (ecbtype == G_ECBType_TIMEOUT_SEM_GRANTED) return G_TRUE;
219  if (ecbtype == G_ECBType_TIMEOUT_SEM_WAITING) return G_TRUE;
220  if (ecbtype == G_ECBType_SEM_GRANTED) return G_TRUE;
221  if (ecbtype == G_ECBType_SEM_WAITING) return G_TRUE;
222  if (ecbtype == G_ECBType_NOT_SPECIFIED) return G_TRUE;
223  return G_FALSE;
224 }
225 
226 INT32 PCBID_Valid(int pcbid)
227 {
228  if ((pcbid <= G_NUMBER_OF_PCB) && (pcbid >= 0)) return G_TRUE;
229  return G_FALSE;
230 }
231 
232 INT32 PCBState_Valid(int pcbstate)
233 {
234  if (pcbstate == GS_PCBState_NOTRUNNING) return G_TRUE;
235  if (pcbstate == GS_PCBState_RUNNING) return G_TRUE;
236  if (pcbstate == GS_PCBState_FREE) return G_TRUE;
237  return G_FALSE;
238 }
239 
240 INT32 PCBType_Valid(int pcbtype)
241 {
242  return G_TRUE;
243 }
244 
245 
247 {
248  if (lcbstate == GS_LCBState_LINKED) return G_TRUE;
249  if (lcbstate == GS_LCBState_UNLINKED) return G_TRUE;
250  return G_FALSE;
251 }
252 
254 {
255  return G_TRUE;
256 }
257 
259 {
260  GS_TCB *root_block = g_kcb.KCB_ROOT_TCBs;
261  GS_ECB *element;
262  GS_ECB *previous_should;
263  int loops = 0;
264  while ((root_block != (GS_TCB *) 0) && (loops <= cycles)) {
265  if (TCB_IsValid(root_block) != G_TRUE) {
266  fprintf(fpuart[GRTOS_CMD_PRC_ID-1],"ERROR in for Proc %d in function %s, file = %s, line = %d \n",GRTOS_CMD_PRC_ID , __FUNCTION__,__FILE__,__LINE__);
267  return G_FALSE;
268  }
269  element = root_block->TCB_NextTCBAEL;
270  previous_should = (GS_ECB *) 0;
271  while ((element != (GS_ECB *) 0) && (loops <= cycles)) {
272  if (ECB_IsValid(element) != G_TRUE) {
273  fprintf(fpuart[GRTOS_CMD_PRC_ID-1],"ERROR in for Proc %d in function %s, file = %s, line = %d \n",GRTOS_CMD_PRC_ID , __FUNCTION__,__FILE__,__LINE__);
274  return G_FALSE;
275  }
276  if (element->ECB_NextTCBAEL != previous_should) {
277  fprintf(fpuart[GRTOS_CMD_PRC_ID-1],"ERROR in for Proc %d in function %s, file = %s, line = %d \n",GRTOS_CMD_PRC_ID , __FUNCTION__,__FILE__,__LINE__);
278  return G_FALSE;
279  }
280  previous_should = element;
281  element = element->ECB_NextTCBAEL;
282  // loops++;
283  }
284  // loops++;
285  root_block = root_block->TCB_NEXT_TCBs;
286  }
287  if (loops > cycles) {
288  fprintf(fpuart[GRTOS_CMD_PRC_ID-1],"ERROR in for Proc %d in function %s, file = %s, line = %d \n",GRTOS_CMD_PRC_ID , __FUNCTION__,__FILE__,__LINE__);
289  return G_FALSE;
290  }
291  // fprintf(fpuart[GRTOS_CMD_PRC_ID-1],"[ MESSAGE ] CHECK Check_list_TCBAEL_IsValid OK \n");
292  return G_TRUE;
293 }
294 
295 
296 OPTIMEZE_RESTORE
INT32
unsigned INT32
Definition: gemrtos_core.h:62
LCBState_IsValid
INT32 LCBState_IsValid(INT32 lcbstate)
Definition: monitor.c:246
GS_TCB
struct gs_tcb GS_TCB
Definition: gemrtos_core.h:50
ECBState_Valid
INT32 ECBState_Valid(unsigned int ecbstate)
Definition: monitor.c:203
gk_RST_MONITOR_HANDLER
void gk_RST_MONITOR_HANDLER(void)
Definition: monitor.c:53
Check_list_TCBAEL_IsValid
INT32 Check_list_TCBAEL_IsValid(int cycles)
Definition: monitor.c:258
Monitor::OPTIMEZE_CODE
OPTIMEZE_CODE(3)
This function stores the data in he monitor FIFO wth the time stamp.
Definition: monitor.c:33
RRDS::RRDS_IsValid
INT32 RRDS_IsValid(GS_RRDS *prrds)
Returns G_TRUE is pointer points to GS_RRDS.
Definition: monitor.c:158
gs_lcb
GS_LCB List Control Block.
Definition: gemrtos_core.h:203
IsAListorNull
INT32 IsAListorNull(GS_LCB *plcb)
Definition: monitor.c:174
Validation::SCB_IsValid
INT32 SCB_IsValid(GS_SCB *pscb)
Returns G_TRUE is pointer points to SCB.
Definition: monitor.c:126
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
LCB_IsValid
INT32 LCB_IsValid(GS_LCB *plcb)
Definition: monitor.c:167
GS_RRDS
struct gs_rrds GS_RRDS
Definition: gemrtos_core.h:53
grtos.h
Definition of GRTOS controller address.
g_kcb
GS_KCB g_kcb
GS_LCB
struct gs_lcb GS_LCB
Definition: gemrtos_core.h:49
ECBType_Valid
INT32 ECBType_Valid(unsigned int ecbtype)
Definition: monitor.c:213
PCB_IsValid
INT32 PCB_IsValid(GS_PCB *ppcb)
Definition: monitor.c:83
GS_ECB
struct gs_ecb GS_ECB
Definition: gemrtos_core.h:51
ECB_IsValid
INT32 ECB_IsValid(GS_ECB *pevent)
Returns G_TRUE is pointer points to ECB.
Definition: monitor.c:109
PCBID_Valid
INT32 PCBID_Valid(int pcbid)
Definition: monitor.c:226
TCBState_Valid
INT32 TCBState_Valid(unsigned int tcbstate)
Definition: monitor.c:182
PCBType_Valid
INT32 PCBType_Valid(int pcbtype)
Definition: monitor.c:240
gemrtos_core.h
GEmRTOS CORE definitions.
TCB_IsValid
INT32 TCB_IsValid(GS_TCB *ptcb)
Definition: monitor.c:76
G_RCB
struct g_rgb G_RCB
Definition: gemrtos_core.h:54
Resource::RCB_IsValid
INT32 RCB_IsValid(void *prcb)
Returns G_TRUE is pointer points to RCB.
Definition: monitor.c:142
gs_scb::BLOCK_HASH
unsigned int BLOCK_HASH
BLOCK_HASH of the SCB: (GS_SCB *) + 4.
Definition: gemrtos_core.h:394
fpuart
FILE* fpuart[G_NUMBER_OF_PCB]
TCBType_Valid
INT32 TCBType_Valid(unsigned int tcbtype)
Definition: monitor.c:193
PCBState_Valid
INT32 PCBState_Valid(int pcbstate)
Definition: monitor.c:232
gk_MONITOR_FIFO_SAMPLE
void gk_MONITOR_FIFO_SAMPLE(int data)
LCBType_IsValid
INT32 LCBType_IsValid(INT32 lcbtype)
Definition: monitor.c:253