comparison services/dar/dar_msg_ft.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_msg_ft.c */
4 /* */
5 /* Purpose: This function is called when the DAR entity receives a new */
6 /* message in its mailbox and wants to process the message. */
7 /* */
8 /* */
9 /* Version 0.1 */
10 /* */
11 /* Date Modification */
12 /* ------------------------------------ */
13 /* 17 October 2001 Create */
14 /* */
15 /* Author Stephanie Gerthoux */
16 /* */
17 /* (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved*/
18 /****************************************************************************/
19
20 #include "../../riviera/rv/rv_defined_swe.h"
21 #ifdef RVM_DAR_SWE
22 #ifndef _WINDOWS
23 #include "../../include/config.h"
24 #endif
25
26 #include <string.h>
27 #include "../../riviera/rvm/rvm_gen.h"
28 #include "dar_api.h"
29 #include "dar_macro_i.h"
30 #include "dar_messages_i.h"
31 #include "dar_const_i.h"
32 #include "dar_diagnose_i.h"
33 #include "dar_error_hdlr_i.h"
34
35 #ifndef _WINDOWS
36 #include "../../bsp/timer.h"
37 #endif
38
39 /**** Global variable ****/
40 /* index used in the circular buffer*/
41 UINT16 dar_current_index = 0;
42 /* Write buffer*/
43 extern char dar_write_buffer[DAR_MAX_BUFFER_SIZE];
44
45 /* Get the dar_current status */
46 extern T_DAR_RECOVERY_STATUS dar_current_status;
47
48 /* Define a pointer to the Global Environment Control block */
49 extern T_DAR_ENV_CTRL_BLK *dar_gbl_var_p;
50
51 /* Define the recovery buffer */
52 extern UINT8 dar_recovery_buffer[DAR_RECOVERY_DATA_MAX_BUFFER_SIZE];
53
54 /**** Extern functions ****/
55 extern void * dar_read_mbox (UINT8 mbox);
56
57 /***************************************************************************/
58 /* Function dar_filter_request */
59 /* */
60 /* Description This function checks if the use_id group_nb exists: */
61 /* - if the group_nb exists, it adds the warning and */
62 /* debug masks in the dar_array_filter */
63 /* - otherwise, this function add the new group_nb and*/
64 /* the masks in the dar_array_filter */
65 /* */
66 /***************************************************************************/
67
68 T_RV_RET dar_filter_request (T_DAR_FILTER_START *msg_p)
69 {
70 /* Declare local variables*/
71 UINT8 index = 0;
72
73 /* check if the DAR entity is started */
74 if (dar_gbl_var_p == NULL )
75 {
76 dar_error_trace(DAR_ENTITY_NOT_START);
77 return(RV_NOT_READY);
78 }
79
80 /*** check if the group exists ****/
81 /* If the group exists... */
82 if(dar_search_group(msg_p->use_msg_parameter.group_nb,&index)== RV_OK)
83 {
84 /* Check the Dar level */
85 switch(msg_p->use_msg_parameter.level)
86 {
87 case DAR_WARNING:
88 { /* The DAR entity wants to process Warning messages */
89 /* add the mask_warning in the dar_filter array */
90 dar_gbl_var_p ->dar_filter_array[index].mask_warning |=
91 msg_p->use_msg_parameter.mask;
92 dar_gbl_var_p ->dar_filter_array[index].mask_debug = 0x00;
93
94 break;
95 }
96
97 case DAR_DEBUG:
98 {
99 /* The DAR entity wants to process Debug messages */
100 /* As the Warning messages are more important than debug */
101 /* messages, it processes warning message too */
102
103 /* add the mask_debug in the dar_filter array */
104 dar_gbl_var_p ->dar_filter_array[index].mask_debug |=
105 msg_p->use_msg_parameter.mask;
106
107 /* add the mask_warning in the dar_filter array */
108 dar_gbl_var_p ->dar_filter_array[index].mask_warning |=
109 msg_p->use_msg_parameter.mask;
110 break;
111 }
112
113 case DAR_NO_DIAGNOSE:
114 {
115 /* The DAR entity doesn't want to process Diagnose messages */
116
117 /* delete the mask_debug in the dar_filter array */
118 dar_gbl_var_p ->dar_filter_array[index].mask_debug = 0x00;
119
120 /* delete the mask_warning in the dar_filter array */
121 dar_gbl_var_p ->dar_filter_array[index].mask_warning = 0x00;
122 break;
123 }
124
125 default:
126 {
127 /* Unknow level has been received */
128 DAR_TRACE_WARNING("A DAR unknow level has been received ");
129 break;
130 }
131 } /* switch(msg_p->use_msg_parameter.level) */
132 } /* if (search_group(msg_p->use_msg_parameter.group_nb,*index_gbl_p)== RV_OK) */
133
134 else
135 {
136 /* if the group doesn't exist and if there is enough space in the
137 dar_filter_array */
138 if ( dar_add_group(&index)== RV_OK)
139 {
140 /* ... add the group in the dar_array_filter */
141 dar_gbl_var_p ->dar_filter_array[index].group_nb |=
142 msg_p->use_msg_parameter.group_nb;
143 /* Check the Dar level */
144 switch(msg_p->use_msg_parameter.level)
145 {
146 case DAR_WARNING:
147 { /* The DAR entity wants to process Warning messages */
148 /* add the mask_warning in the dar_filter array */
149 dar_gbl_var_p ->dar_filter_array[index].mask_warning |=
150 msg_p->use_msg_parameter.mask;
151 break;
152 }
153
154 case DAR_DEBUG:
155 {
156 /* The DAR entity wants to process Debug messages */
157 /* As the Warning messages are more important than debug */
158 /* messages, it processes warning message too */
159
160 /* add the mask_debug in the dar_filter array */
161 dar_gbl_var_p ->dar_filter_array[index].mask_debug |=
162 msg_p->use_msg_parameter.mask;
163
164 /* add the mask_warning in the dar_filter array */
165 dar_gbl_var_p ->dar_filter_array[index].mask_warning |=
166 msg_p->use_msg_parameter.mask;
167 break;
168 }
169
170 default:
171 {
172 /* Unknow level has been received */
173 DAR_TRACE_WARNING("A DAR unknow level has been received ");
174 break;
175 };
176 } /* switch */
177 }/* if ( add_group(msg_p->use_msg_parameter.group_nb,*index_gbl_p)== RV_OK)) */
178
179 else
180 {
181 /* There is not enough space in the dar_array_filter */
182 DAR_TRACE_WARNING("Not enough space in the dar_array_filter for adding a new group ");
183 }
184 }
185 return(RV_OK);
186 }/* dar_filter_request */
187
188
189 /***************************************************************************/
190 /* */
191 /* Function Name: dar_write_data_in_buffer */
192 /* */
193 /* Purpose: This function is called to store diagnose data in RAM */
194 /* buffer. */
195 /* */
196 /* note: In order to separate the different string, the data */
197 /* are stored as follows: */
198 /* */
199 /* Input Parameters: */
200 /* Pointer to the message to store */
201 /* Data Format, */
202 /* Data level, */
203 /* Data Use Id, */
204 /* */
205 /* Output Parameters: */
206 /* Validation of the diagnose execution. */
207 /* */
208 /* */
209 /* */
210 /* Revision History: */
211 /* None. */
212 /* */
213 /***************************************************************************/
214 T_RV_RET dar_write_data_in_buffer( T_DAR_WRITE_START *msg_p)
215 {
216 /* Local variables */
217 UINT8 i = 0;
218 UINT8 length = 0;
219
220 /* Diagnose string length */
221 length = (UINT16) strlen(msg_p->data_write.char_p);
222
223 /*** Circular buffer to store data ***/
224 /* Add 0xFF to separate 2 strings */
225 dar_write_buffer[dar_current_index] = 0xF;
226 DAR_PLUS_PLUS(dar_current_index); /* increment with wraparound */
227 dar_write_buffer[dar_current_index] = 0xF;
228 DAR_PLUS_PLUS(dar_current_index); /* increment with wraparound */
229
230
231 /* The group_nb is 16 bit length, and the buffer is an UINT8 length */
232 /* So the group_nb must be stocked by dividing it in 2 parts */
233 dar_write_buffer[dar_current_index] =
234 (msg_p->data_write.use_id.group_nb)>>8;
235 /*add the 8 first bits of the Use id group*/
236 DAR_PLUS_PLUS(dar_current_index);
237 dar_write_buffer[dar_current_index] = msg_p->data_write.use_id.group_nb;
238 /*add the 8 last bits of the Use id group*/
239 DAR_PLUS_PLUS(dar_current_index);
240 /* The mask is 16 bit length, and the buffer is an UINT8 length */
241 /* So the mask must be stocked by dividing it in 2 parts */
242 dar_write_buffer[dar_current_index] = (msg_p->data_write.use_id.mask)>>8;
243 /* add the 8 first bits of the Use id mask */
244 DAR_PLUS_PLUS(dar_current_index);
245 dar_write_buffer[dar_current_index] = msg_p->data_write.use_id.mask;
246 /* add the 8 last bits of the Use id mask */
247 DAR_PLUS_PLUS(dar_current_index);
248
249 /* Add the dar_level data */
250 dar_write_buffer[dar_current_index] = msg_p->data_write.level;
251 DAR_PLUS_PLUS(dar_current_index);
252
253 /* circular buffer to store diagnose data in RAM buffer */
254 for (i=0; i < length; i++ )
255 {
256 /* copy string in the RAM char by char*/
257 dar_write_buffer[dar_current_index]=msg_p->data_write.char_p[i];
258
259 /* detection of the end of the buffer */
260 /* When current = DAR_MAX_BUFFER_SIZE , current = 0 */
261 DAR_PLUS_PLUS(dar_current_index);
262 }
263
264 /* DAR information is redirected to standard trace */
265 //DAR_SEND_TRACE("circular buffer : ",RV_TRACE_LEVEL_DEBUG_HIGH);
266 //rvf_send_trace(msg_p->data_write.char_p, length, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH, DAR_USE_ID);
267
268 return(RV_OK);
269
270 } /* dar_send_write_data */
271
272 /***************************************************************************/
273 /* Function dar_empty_mb_and_save_data */
274 /* */
275 /* Description This function is used to empty the mailbox and save */
276 /* data in the RAM buffer. */
277 /* */
278 /* Input Parameters: */
279 /* Pointer to the message to store */
280 /* */
281 /* Output Parameters: */
282 /* Validation of the function execution. */
283 /* */
284 /* Note: */
285 /* None */
286 /* */
287 /***************************************************************************/
288 T_RV_RET dar_empty_mb_and_save_data( T_DAR_INFO *buffer_p)
289 {
290 /* Declare local variables */
291 UINT8 i = 0;
292 UINT16 length = 0;
293 T_RV_HDR *msg_p = ( T_RV_HDR*) dar_read_mbox(DAR_MBOX);
294
295 /**** Empty the mail box ****/
296 while(msg_p != NULL)
297 {
298 /* If it's a Write message, store it in the Ram */
299 /* ( it is not interesting to store filter message ) */
300 if ((msg_p->msg_id) == DAR_WRITE_REQ)
301 {
302 /* store themessage in the RAM*/
303 dar_write_data_in_buffer((T_DAR_WRITE_START *)msg_p);
304 }
305 /* free the Header of the message */
306 rvf_free_buf((T_RVF_BUFFER *) msg_p);
307
308 /* Read the next message */
309 msg_p = ( T_RV_HDR*) dar_read_mbox(DAR_MBOX);
310 } /* while (msg_p != NULL) */
311
312 /**** Store data in RAM buffer ****/
313 /* Diagnose string length */
314 length = (UINT16) strlen(buffer_p);
315
316 /** Circular buffer to store data **/
317 /* Add 0xFF to separate 2 strings */
318 dar_write_buffer[dar_current_index] = 0xF;
319 DAR_PLUS_PLUS(dar_current_index); /* increment with wraparound */
320 dar_write_buffer[dar_current_index] = 0xF;
321 DAR_PLUS_PLUS(dar_current_index); /* increment with wraparound */
322
323 /* Add the dar_level data */
324 dar_write_buffer[dar_current_index] = DAR_EXCEPTION;
325 DAR_PLUS_PLUS(dar_current_index);
326 /* circular buffer to store diagnose data in RAM buffer */
327 for (i=0; i < length; i++ )
328 {
329 /* copy string in the RAM char by char*/
330 dar_write_buffer[dar_current_index]=buffer_p[i];
331
332 /* detection of the end of the buffer */
333 /* When current = DAR_MAX_BUFFER_SIZE , current = 0 */
334 DAR_PLUS_PLUS(dar_current_index);
335 }
336
337 return(RV_OK);
338
339 }/* dar_empty_mb_and_save_data*/
340
341
342 #endif /* #ifdef RVM_DAR_SWE */
343
344
345
346 /******************************************************************************/
347 /* */
348 /* ------------------------------------------------ */
349 /* | WARNING - IMPORTANT | */
350 /* ------------------------------------------------ */
351 /* */
352 /* */
353 /* Function Name: dar_lib */
354 /* */
355 /* Purpose: This function is only used in order to have a function in the */
356 /* dar_lib when the DAR is NOT_COMPILED */
357 /* */
358 /* Input Parameters: */
359 /* None */
360 /* */
361 /* Output Parameters: */
362 /* NONE */
363 /* */
364 /******************************************************************************/
365 void dar_lib(void)
366 {
367 }