comparison services/dar/dar_diagnose.c @ 0:75a11d740a02

initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 09 Jun 2016 00:02:41 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:75a11d740a02
1 /****************************************************************************/
2 /* */
3 /* File Name: dar_diagnose.c */
4 /* */
5 /* Purpose: This function contains the DAR diagnose functions */
6 /* */
7 /* */
8 /* Version 0.1 */
9 /* */
10 /* Date Modification */
11 /* ------------------------------------ */
12 /* 18 October 2001 Create */
13 /* */
14 /* Author Stephanie Gerthoux */
15 /* */
16 /* (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved*/
17 /****************************************************************************/
18
19 #include "../../riviera/rv/rv_defined_swe.h"
20 #ifdef RVM_DAR_SWE
21 #ifndef _WINDOWS
22 #include "../../bsp/timer.h"
23 #endif
24
25 #include "../../riviera/rv/rv_general.h"
26 #include "../../riviera/rvm/rvm_gen.h"
27 #include "../../riviera/rvm/rvm_priorities.h"
28 #include "dar_api.h"
29 #include "dar_structs_i.h"
30 #include "dar_env.h"
31 #include "../../riviera/rvf/rvf_target.h"
32 #include "dar_const_i.h"
33 #include "dar_macro_i.h"
34 #include "dar_messages_i.h"
35 #include "dar_error_hdlr_i.h"
36 //#include "rvf/rvf_i.h"
37
38 /**** Global variables ****/
39
40 /* Define a pointer to the Global Environment Control block */
41 extern T_DAR_ENV_CTRL_BLK *dar_gbl_var_p;
42
43
44
45 /***************************************************************************/
46 /* Function dar_search_group */
47 /* */
48 /* Description This function checks if the use_id group_nb exists: */
49 /* */
50 /***************************************************************************/
51 T_RV_RET dar_search_group(UINT16 group, UINT8 *index_p)
52 {
53 /* Declare local variables */
54 UINT8 i=0;
55
56 /* Check if the DAR entity is started */
57 if (dar_gbl_var_p != NULL )
58 {
59 /* Search in the dar_filter_array if the group exists */
60 for (i=0;i< DAR_MAX_GROUP_NB; i++)
61 {
62 if(dar_gbl_var_p->dar_filter_array[i].group_nb == group)
63 {
64 *index_p=i;
65 //DAR_SEND_TRACE_PARAM("dar filter_array index",*index_p,RV_TRACE_LEVEL_DEBUG_LOW);
66 return(RV_OK);
67 }
68 }
69 return(RV_NOT_SUPPORTED);
70 }
71 else
72 {
73 return(RV_NOT_READY);
74 }
75 }
76
77 /***************************************************************************/
78 /* Function dar_add_group */
79 /* */
80 /* Description This function research the index of the first free */
81 /* group */
82 /***************************************************************************/
83 T_RV_RET dar_add_group(UINT8 *index_p)
84 {
85 /* Declare local variables */
86 UINT8 i=0;
87
88 /* Check if the DAR entity is started */
89 if (dar_gbl_var_p == NULL )
90 {
91 dar_error_trace(DAR_ENTITY_NOT_START);
92 return(RV_NOT_READY);
93 }
94
95 /* Search in the dar_filter_array the first free group */
96 for (i=0;i< DAR_MAX_GROUP_NB; i++)
97 {
98 if(dar_gbl_var_p->dar_filter_array[i].group_nb == DAR_INITIALIZATION_VALUE)
99 {
100 *index_p=i;
101 return(RV_OK);
102 }
103 }
104 return(RV_NOT_SUPPORTED);
105 }
106
107
108 /***************************************************************************/
109 /* */
110 /* Function Name: dar_send_write_data */
111 /* */
112 /* Purpose: This function is called to send write data in the DAR */
113 /* mailbox. */
114 /* Input Parameters: */
115 /* Pointer to the message to store */
116 /* Data Format, */
117 /* Data level, */
118 /* Data Use Id, */
119 /* */
120 /* Output Parameters: */
121 /* Validation of the function execution. */
122 /* */
123 /* Note: */
124 /* None */
125 /* */
126 /***************************************************************************/
127
128 T_RV_RET dar_send_write_data ( T_DAR_INFO *buffer_p,
129 T_DAR_FORMAT format,
130 T_DAR_LEVEL diagnose_info_level,
131 T_RVM_USE_ID dar_use_id)
132 {
133 /* Declare local variables */
134 T_RVF_MB_STATUS mb_status = RVF_GREEN;
135 T_DAR_WRITE_START *write_data_p = NULL;
136
137 /************************** dar_send_write_data **********************/
138
139 if (dar_gbl_var_p != NULL )
140 {
141 /* allocate the memory for the message to send */
142 mb_status = rvf_get_buf (dar_gbl_var_p->mb_dar,
143 sizeof (T_DAR_WRITE_START),
144 (T_RVF_BUFFER **) (&write_data_p));
145
146 /* If insufficient resources, then report a memory error and abort.*/
147 if (mb_status == RVF_YELLOW)
148 {
149 /* deallocate the memory */
150 rvf_free_buf((T_RVF_BUFFER *)write_data_p);
151 dar_error_trace(DAR_ENTITY_NO_MEMORY);
152 return (RV_NOT_SUPPORTED);
153 }
154 else
155 if (mb_status == RVF_RED)
156 {
157 dar_error_trace(DAR_ENTITY_NO_MEMORY);
158 return (RV_MEMORY_ERR);
159 }
160
161 /* fill the message id */
162 write_data_p->os_hdr.msg_id = DAR_WRITE_REQ;
163
164 /* fill the addr source id */
165 write_data_p->os_hdr.src_addr_id = dar_gbl_var_p->addrId;
166
167 /* fill the message parameters */
168 write_data_p->data_write.char_p = buffer_p ;
169 write_data_p->data_write.data_format = format;
170 write_data_p->data_write.level = diagnose_info_level;
171 write_data_p->data_write.use_id.group_nb = (dar_use_id>>16)& 0x7FFF;
172 write_data_p->data_write.use_id.mask = (dar_use_id)&0xFFFF;
173
174 /* send the messsage to the DAR entity */
175 rvf_send_msg (dar_gbl_var_p->addrId,
176 write_data_p);
177
178 return (RV_OK);
179 }
180 else
181 {
182 return(RV_NOT_READY);
183 }
184
185
186 } /* dar_send_write_data */
187
188 /***************************************************************************/
189 /* Function dar_reset */
190 /* */
191 /* Description This function is used to reset the system */
192 /* */
193 /* Input Parameters: */
194 /* None */
195 /* */
196 /* Output Parameters: */
197 /* Validation of the function execution. */
198 /* */
199 /* Note: */
200 /* None */
201 /* */
202 /***************************************************************************/
203 T_RV_RET dar_reset(void)
204 {
205 #ifndef _WINDOWS
206 /* Declare global variable*/
207 volatile UINT16 *register_p;
208 volatile UINT8 i;
209
210
211 /* enable the Watchdog timer */
212 TM_EnableWatchdog();
213
214 /* Reset the system with the Watchdog */
215 /* initialize the adress of the watchdog timer pointer */
216 register_p = (volatile UINT16 *)WATCHDOG_TIM_MODE;
217
218 /* Write the 0xF5 value to the Watchdog timer mode register to disable
219 the Watchdog */
220 /* Note the bit 15 must be unchanged ( bit 15 = 1 -> 0x8000)*/
221 *register_p =0x80F5;
222
223 /* Wait a couple of time to be sure that this register has a new
224 value */
225 for (i=0;i<100;i++);
226
227 /*
228 * After having received 0xF5 in the Watchdog timer mode register,
229 * if the second write access is differennt from 0xA0, ARM core is
230 * reset.
231 *
232 * The ARM HW core is reset + branch to adress 0x0000 ( SW reset)
233 */
234 *register_p=0x80F5;
235
236 /* Wait until the ARM reset */
237 while(1);
238 #endif
239
240 return(RV_OK);
241 } /* dar_reset */
242
243
244 /***************************************************************************/
245 /* */
246 /* Function dar_read_mbox */
247 /* */
248 /* Description Called by the dar to read a buffer from its mailboxes. */
249 /* when the Operating System is out */
250 /* Input Parameters: */
251 /* None */
252 /* */
253 /* Output Parameters: */
254 /* NULL if the mailbox was empty, else the address of a buffer */
255 /* */
256 /***************************************************************************/
257
258 void * dar_read_mbox (UINT8 mbox)
259 {
260 // void * p_buf = NULL;
261 // T_RVF_INTERNAL_BUF * p_hdr;
262
263 /* Verify if DAR's global struct was set by RVM, then read the mailbox */
264 if (dar_gbl_var_p != NULL )
265 return rvf_read_addr_mbox (dar_gbl_var_p->addrId, mbox);
266
267 return NULL;
268
269 // Check if the DAR entity is started
270 /*if (dar_gbl_var_p != NULL )
271 {
272
273 if ( OSTaskQFirst[dar_gbl_var_p->addrId][mbox] )// if the chained list is not empty
274 {
275 p_hdr = OSTaskQFirst[dar_gbl_var_p->addrId][mbox];
276 OSTaskQFirst[dar_gbl_var_p->addrId][mbox] = p_hdr->p_next;
277
278 p_hdr->p_next = NULL;
279
280 #if RVF_ENABLE_BUF_LINKAGE_CHECK
281 RVF_SET_BUF_UNLINKED(p_hdr); // change buffer status
282 #endif
283
284 p_buf = (UINT8 *)p_hdr + sizeof(T_RVF_INTERNAL_BUF);
285 }
286 }
287 return (p_buf); */
288 } // dar_read_mbox
289
290 #else
291
292 /* ******************************************************* */
293 /* THE DAR ENTITY IS DISABLED */
294 /* ******************************************************* */
295 #ifndef _WINDOWS
296 #include "../../bsp/timer.h"
297 #endif
298
299 #include "../../riviera/rv/rv_general.h"
300 #include "../../riviera/rvm/rvm_gen.h"
301 #include "../../riviera/rvm/rvm_priorities.h"
302 #include "../../riviera/rvf/rvf_target.h"
303 //#include "rvf/rvf_i.h"
304
305 /* Define the Watchdog timer register mode */
306 #define WATCHDOG_TIM_MODE (0xFFFFF804)
307
308
309 /***************************************************************************/
310 /* Function dar_reset */
311 /* */
312 /* Description This function is used to reset the system */
313 /* */
314 /* Input Parameters: */
315 /* None */
316 /* */
317 /* Output Parameters: */
318 /* Validation of the function execution. */
319 /* */
320 /* Note: */
321 /* None */
322 /* */
323 /***************************************************************************/
324 T_RV_RET dar_reset(void)
325 {
326 #ifndef _WINDOWS
327 /* Declare global variable*/
328 volatile UINT16 *register_p;
329 volatile UINT8 i;
330
331
332 /* enable the Watchdog timer */
333 TM_EnableWatchdog();
334
335 /* Reset the system with the Watchdog */
336 /* initialize the adress of the watchdog timer pointer */
337 register_p = (volatile UINT16 *)WATCHDOG_TIM_MODE;
338
339 /* Write the 0xF5 value to the Watchdog timer mode register to disable
340 the Watchdog */
341 /* Note the bit 15 must be unchanged ( bit 15 = 1 -> 0x8000)*/
342 *register_p =0x80F5;
343
344 /* Wait a couple of time to be sure that this register has a new
345 value */
346 for (i=0;i<100;i++);
347
348 /*
349 * After having received 0xF5 in the Watchdog timer mode register,
350 * if the second write access is differennt from 0xA0, ARM core is
351 * reset.
352 *
353 * The ARM HW core is reset + branch to adress 0x0000 ( SW reset)
354 */
355 *register_p=0x80F5;
356
357 /* Wait until the ARM reset */
358 while(1);
359 #endif
360
361 return(RV_OK);
362 } /* dar_reset */
363
364 #endif /* #ifdef RVM_DAR_SWE */