FreeCalypso > hg > fc-magnetite
comparison src/cs/services/dar/dar_msg_ft.c @ 0:945cf7f506b2
src/cs: chipsetsw import from tcs211-fcmodem
binary blobs and LCD demo files have been excluded,
all line endings are LF only
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 25 Sep 2016 22:50:11 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:945cf7f506b2 |
---|---|
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 "rv/rv_defined_swe.h" | |
21 #ifdef RVM_DAR_SWE | |
22 #ifndef _WINDOWS | |
23 #include "config/swconfig.cfg" | |
24 #include "config/sys.cfg" | |
25 #include "config/chipset.cfg" | |
26 #endif | |
27 | |
28 #include <string.h> | |
29 #include "rvm/rvm_gen.h" | |
30 #include "dar/dar_api.h" | |
31 #include "dar/dar_macro_i.h" | |
32 #include "dar/dar_messages_i.h" | |
33 #include "dar/dar_const_i.h" | |
34 #include "dar/dar_diagnose_i.h" | |
35 #include "dar/dar_error_hdlr_i.h" | |
36 | |
37 #ifndef _WINDOWS | |
38 #include "timer/timer.h" | |
39 #endif | |
40 | |
41 /**** Global variable ****/ | |
42 /* index used in the circular buffer*/ | |
43 UINT16 dar_current_index = 0; | |
44 /* Write buffer*/ | |
45 extern char dar_write_buffer[DAR_MAX_BUFFER_SIZE]; | |
46 | |
47 /* Get the dar_current status */ | |
48 extern T_DAR_RECOVERY_STATUS dar_current_status; | |
49 | |
50 /* Define a pointer to the Global Environment Control block */ | |
51 extern T_DAR_ENV_CTRL_BLK *dar_gbl_var_p; | |
52 | |
53 /* Define the recovery buffer */ | |
54 extern UINT8 dar_recovery_buffer[DAR_RECOVERY_DATA_MAX_BUFFER_SIZE]; | |
55 | |
56 /**** Extern functions ****/ | |
57 extern void * dar_read_mbox (UINT8 mbox); | |
58 | |
59 extern void exception(void); | |
60 | |
61 /********************************************************************************/ | |
62 /* Function dar_filter_request */ | |
63 /* */ | |
64 /* Description This function checks if the use_id group_nb exists: */ | |
65 /* - if the group_nb exists, it adds the warning and debug */ | |
66 /* masks in the dar_array_filter */ | |
67 /* - otherwise, this function add the new group_nb and the */ | |
68 /* masks in the dar_array_filter */ | |
69 /* */ | |
70 /********************************************************************************/ | |
71 | |
72 T_RV_RET dar_filter_request (T_DAR_FILTER_START *msg_p) | |
73 { | |
74 /* Declare local variables*/ | |
75 UINT8 index = 0; | |
76 | |
77 /* check if the DAR entity is started */ | |
78 if (dar_gbl_var_p == NULL ) | |
79 { | |
80 dar_error_trace(DAR_ENTITY_NOT_START); | |
81 return(RV_NOT_READY); | |
82 } | |
83 | |
84 /*** check if the group exists ****/ | |
85 /* If the group exists... */ | |
86 if(dar_search_group(msg_p->use_msg_parameter.group_nb,&index)== RV_OK) | |
87 { | |
88 /* Check the Dar level */ | |
89 switch(msg_p->use_msg_parameter.level) | |
90 { | |
91 case DAR_WARNING: | |
92 { /* The DAR entity wants to process Warning messages */ | |
93 /* add the mask_warning in the dar_filter array */ | |
94 dar_gbl_var_p ->dar_filter_array[index].mask_warning |= | |
95 msg_p->use_msg_parameter.mask; | |
96 dar_gbl_var_p ->dar_filter_array[index].mask_debug = 0x00; | |
97 | |
98 break; | |
99 } | |
100 | |
101 case DAR_DEBUG: | |
102 { | |
103 /* The DAR entity wants to process Debug messages */ | |
104 /* As the Warning messages are more important than debug messages, */ | |
105 /* it processes warning message too */ | |
106 | |
107 /* add the mask_debug in the dar_filter array */ | |
108 dar_gbl_var_p ->dar_filter_array[index].mask_debug |= | |
109 msg_p->use_msg_parameter.mask; | |
110 | |
111 /* add the mask_warning in the dar_filter array */ | |
112 dar_gbl_var_p ->dar_filter_array[index].mask_warning |= | |
113 msg_p->use_msg_parameter.mask; | |
114 break; | |
115 } | |
116 | |
117 case DAR_NO_DIAGNOSE: | |
118 { | |
119 /* The DAR entity doesn't want to process Diagnose messages */ | |
120 | |
121 /* delete the mask_debug in the dar_filter array */ | |
122 dar_gbl_var_p ->dar_filter_array[index].mask_debug = 0x00; | |
123 | |
124 /* delete the mask_warning in the dar_filter array */ | |
125 dar_gbl_var_p ->dar_filter_array[index].mask_warning = 0x00; | |
126 break; | |
127 } | |
128 | |
129 default: | |
130 { | |
131 /* Unknow level has been received */ | |
132 DAR_TRACE_WARNING("A DAR unknow level has been received "); | |
133 break; | |
134 } | |
135 } /* switch(msg_p->use_msg_parameter.level) */ | |
136 } /* if (search_group(msg_p->use_msg_parameter.group_nb,*index_gbl_p)== RV_OK) */ | |
137 | |
138 else | |
139 { | |
140 /* if the group doesn't exist and if there is enough space in the dar_filter_array */ | |
141 if ( dar_add_group(&index)== RV_OK) | |
142 { | |
143 /* ... add the group in the dar_array_filter */ | |
144 dar_gbl_var_p ->dar_filter_array[index].group_nb |= msg_p->use_msg_parameter.group_nb; | |
145 /* Check the Dar level */ | |
146 switch(msg_p->use_msg_parameter.level) | |
147 { | |
148 case DAR_WARNING: | |
149 { /* The DAR entity wants to process Warning messages */ | |
150 /* add the mask_warning in the dar_filter array */ | |
151 dar_gbl_var_p ->dar_filter_array[index].mask_warning |= | |
152 msg_p->use_msg_parameter.mask; | |
153 break; | |
154 } | |
155 | |
156 case DAR_DEBUG: | |
157 { | |
158 /* The DAR entity wants to process Debug messages */ | |
159 /* As the Warning messages are more important than debug messages, */ | |
160 /* it processes warning message too */ | |
161 | |
162 /* add the mask_debug in the dar_filter array */ | |
163 dar_gbl_var_p ->dar_filter_array[index].mask_debug |= | |
164 msg_p->use_msg_parameter.mask; | |
165 | |
166 /* add the mask_warning in the dar_filter array */ | |
167 dar_gbl_var_p ->dar_filter_array[index].mask_warning |= | |
168 msg_p->use_msg_parameter.mask; | |
169 break; | |
170 } | |
171 | |
172 default: | |
173 { | |
174 /* Unknow level has been received */ | |
175 DAR_TRACE_WARNING("A DAR unknow level has been received "); | |
176 break; | |
177 }; | |
178 } /* switch */ | |
179 }/* if ( add_group(msg_p->use_msg_parameter.group_nb,*index_gbl_p)== RV_OK)) */ | |
180 | |
181 else | |
182 { | |
183 /* There is not enough space in the dar_array_filter */ | |
184 DAR_TRACE_WARNING("Not enough space in the dar_array_filter for adding a new group "); | |
185 } | |
186 } | |
187 return(RV_OK); | |
188 }/* dar_filter_request */ | |
189 | |
190 | |
191 /********************************************************************************/ | |
192 /* */ | |
193 /* Function Name: dar_write_data_in_buffer */ | |
194 /* */ | |
195 /* Purpose: This function is called to store diagnose data in RAM buffer */ | |
196 /* */ | |
197 /* note: In order to separate the different string, the data are */ | |
198 /* ---- stored as follows: */ | |
199 /* */ | |
200 /* Input Parameters: */ | |
201 /* Pointer to the message to store */ | |
202 /* Data Format, */ | |
203 /* Data level, */ | |
204 /* Data Use Id, */ | |
205 /* */ | |
206 /* Output Parameters: */ | |
207 /* Validation of the diagnose execution. */ | |
208 /* */ | |
209 /* */ | |
210 /* */ | |
211 /* Revision History: */ | |
212 /* None. */ | |
213 /* */ | |
214 /********************************************************************************/ | |
215 T_RV_RET dar_write_data_in_buffer( T_DAR_WRITE_START *msg_p) | |
216 { | |
217 /* Local variables */ | |
218 UINT8 i = 0; | |
219 UINT8 length = 0; | |
220 | |
221 /* Diagnose string length */ | |
222 length = (UINT16) strlen(msg_p->data_write.char_p); | |
223 | |
224 /*** Circular buffer to store data ***/ | |
225 /* Add 0xFF to separate 2 strings */ | |
226 dar_write_buffer[dar_current_index] = 0xF; | |
227 DAR_PLUS_PLUS(dar_current_index); /* to detected if it is the end of the buffer */ | |
228 dar_write_buffer[dar_current_index] = 0xF; | |
229 DAR_PLUS_PLUS(dar_current_index); /* to detected if it is the end of the buffer */ | |
230 | |
231 | |
232 /* The group_nb is 16 bit length, and the buffer is an UINT8 length */ | |
233 /* So the group_nb must be stocked by dividing it in 2 parts */ | |
234 dar_write_buffer[dar_current_index] = (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 data in */ | |
276 /* 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); /* to detected if it is the end of the buffer */ | |
320 dar_write_buffer[dar_current_index] = 0xF; | |
321 DAR_PLUS_PLUS(dar_current_index); /* to detected if it is the end of the buffer */ | |
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 } |