comparison services/dar/dar_env.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_env.c */
4 /* */
5 /* Purpose: This file contains routines that will be called in order to: */
6 /* - notify the Environment of the diagnose's Memory Banks */
7 /* requirements, */
8 /* - set diagnose's addr and memory banks IDs */
9 /* - initialize all the diagnose's data structures, */
10 /* - start the diagnose's task */
11 /* - stop the diagnose's task */
12 /* - kill the diagnose's task */
13 /* */
14 /* Version 0.1 */
15 /* */
16 /* Date Modification */
17 /* ------------------------------------ */
18 /* 26 September 2001 Create */
19 /* */
20 /* Author Stephanie Gerthoux */
21 /* */
22 /* (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved*/
23 /****************************************************************************/
24
25 #include "../../riviera/rv/rv_defined_swe.h"
26 #ifdef RVM_DAR_SWE
27 #include "../../riviera/rv/rv_general.h"
28 #include "../../riviera/rvm/rvm_gen.h"
29 #include "../../riviera/rvm/rvm_priorities.h"
30 #include "../../riviera/rvm/rvm_use_id_list.h"
31 #include "dar_api.h"
32 #include "dar_env.h"
33 #include "dar_macro_i.h"
34
35 #include <string.h>
36
37 extern T_RV_RET dar_core(void);
38
39 /* Initialisation of the pointer to the Global Environment Control block */
40 T_DAR_ENV_CTRL_BLK *dar_gbl_var_p = NULL;
41
42 /**** Define extern variables ****/
43 /* Get the last status of the system */
44 extern T_DAR_RECOVERY_STATUS dar_current_status;
45
46 /* Get the last exception of the system */
47 extern UINT8 dar_exception_status;
48
49 /* Define the recovery buffer */
50 extern UINT32 dar_recovery_buffer;
51
52 /* DAR previous status */
53 extern T_DAR_RECOVERY_STATUS dar_previous_status;
54
55 /* DAR previous status */
56 extern UINT8 dar_previous_exception;
57
58 /***************************************************************************/
59 /* Function : dar_get_info */
60 /* */
61 /* Description : This function is called by the RV Environment to learn */
62 /* diagnose requirements in terms of memory, SWEs... */
63 /* */
64 /* Parameters : T_RVM_INFO_SWE * swe_info: pointer to the structure to */
65 /* fill containing infos related to the diagnose SWE. */
66 /* */
67 /* Return : T_RV_RETURN */
68 /* */
69 /* History : 0.1 (26-September-2001) */
70 /* */
71 /* */
72 /***************************************************************************/
73 T_RVM_RETURN dar_get_info(T_RVM_INFO_SWE *infoSWEnt)
74 {
75 /* SWE info */
76 infoSWEnt->swe_type = RVM_SWE_TYPE_4;
77 infoSWEnt->type_info.type4.swe_use_id = DAR_USE_ID;
78
79 memcpy( infoSWEnt->type_info.type4.swe_name, "DAR", sizeof("DAR") );
80
81 infoSWEnt->type_info.type4.stack_size = DAR_STACK_SIZE;
82 infoSWEnt->type_info.type4.priority = RVM_DAR_TASK_PRIORITY;
83
84
85 /* Set the return path */
86 infoSWEnt->type_info.type4.return_path.callback_func = NULL;
87 infoSWEnt->type_info.type4.return_path.addr_id = 0;
88
89
90 /* memory bank info */
91 infoSWEnt->type_info.type4.nb_mem_bank = 0x01;
92
93 /* Memory bank used to receive/send the message to/from the entity */
94 memcpy ((UINT8 *) infoSWEnt->type_info.type4.mem_bank[0].bank_name, "DAR_MB", sizeof("DAR_MB"));
95 infoSWEnt->type_info.type4.mem_bank[0].initial_params.size = DAR_MB_SIZE;
96 infoSWEnt->type_info.type4.mem_bank[0].initial_params.watermark = DAR_MB_WATERMARK;
97
98 /* linked SWE info */
99 /* this SWE requires the FFS SWE to run */
100
101 infoSWEnt->type_info.type4.nb_linked_swe = 0x01;
102 infoSWEnt->type_info.type4.linked_swe_id[0]= FFS_USE_ID;
103
104 /* generic functions */
105 infoSWEnt->type_info.type4.set_info = dar_set_info;
106 infoSWEnt->type_info.type4.init = dar_init;
107 infoSWEnt->type_info.type4.core = dar_core;
108 infoSWEnt->type_info.type4.stop = dar_stop;
109 infoSWEnt->type_info.type4.kill = dar_kill;
110
111 return RVM_OK;
112 }
113
114 /**************** End of dar_get_info function *****************************/
115
116 /***************************************************************************/
117 /* Function : dar_set_info */
118 /* */
119 /* Description : This function is called by the RV Environment to inform */
120 /* the diagnose SWE about addr_id, mb_id and error function. */
121 /* */
122 /* Parameters : - T_RVF_ADDR_ID addrId: address Id */
123 /* - T_RVF_MB_ID mb_id[]: array of memory bank ids. */
124 /* - callback function to call in case of unrecoverable error*/
125 /* */
126 /* Return : T_RVM_RETURN */
127 /* */
128 /* History : 0.1 (27-September-2001 ) */
129 /* */
130 /* */
131 /***************************************************************************/
132 T_RVM_RETURN dar_set_info(T_RVF_ADDR_ID addrId,
133 T_RV_RETURN return_path[],
134 T_RVF_MB_ID mbId[],
135 T_RVM_RETURN (*callBackFctError) ( T_RVM_NAME SWEntName,
136 T_RVM_RETURN errorCause,
137 T_RVM_ERROR_TYPE errorType,
138 T_RVM_STRING errorMsg) )
139 {
140
141 /* Declare local variable.*/
142 T_RVF_MB_STATUS mb_status = RVF_GREEN;
143
144 /* Allocate memory required to store the Global Environment control
145 Block. */
146 mb_status = rvf_get_buf(mbId[0],
147 sizeof(T_DAR_ENV_CTRL_BLK),
148 (T_RVF_BUFFER **) & dar_gbl_var_p);
149
150 /* If insufficient resources to properly run the DAR's task,
151 then abort. */
152 switch (mb_status)
153 {
154 case RVF_GREEN:
155 {
156 /* Initialize the Global Environment Control Block */
157 memset((UINT8 *) dar_gbl_var_p,
158 0x00,
159 sizeof (T_DAR_ENV_CTRL_BLK));
160
161 /* Store the memory bank IDs assigned to the DAR */
162 dar_gbl_var_p->mb_dar = mbId[0];
163
164 /* Store the addr ID assigned to the DAR */
165 dar_gbl_var_p->addrId = addrId;
166
167 /* Store the function to be called whenever any unrecoverable */
168 /* error occurs. */
169 dar_gbl_var_p->callBackFctError = callBackFctError;
170 DAR_SEND_TRACE(" Diagnose And Recovery (env). DAR's information set ",
171 RV_TRACE_LEVEL_DEBUG_LOW);
172 break;
173 }
174 case RVF_YELLOW:
175 {
176 rvf_free_buf((T_RVF_BUFFER *) dar_gbl_var_p);
177 DAR_TRACE_WARNING(" DAR memory warning (orange memory)");
178 return (RV_MEMORY_ERR);
179 }
180 default:
181 {
182 DAR_TRACE_WARNING(" DAR memory warning (red memory)");
183 return (RV_MEMORY_ERR);
184 }
185 } /* switch (mb_status) */
186
187 return (RV_OK);
188 } /*************** End of dar_set_info function ****************************/
189
190
191
192 /***************************************************************************/
193 /* Function : dar_init */
194 /* */
195 /* Description : This function is called by the RV Environment to init the */
196 /* diagnose SWE before creating the task and calling */
197 /* dar_start. */
198 /* */
199 /* Parameters : None */
200 /* */
201 /* Return : T_RVM_RETURN */
202 /* */
203 /* History : 0.1 (27-September-2001) */
204 /* */
205 /* */
206 /***************************************************************************/
207 T_RVM_RETURN dar_init(void)
208 {
209 /*** Declare local variables ***/
210 UINT16 i = 0;
211
212 /*** Initialization of the DAR global structure ***/
213
214 /* Initialization of the dar_filter_array */
215 for (i=0;i<DAR_MAX_GROUP_NB;i++)
216 {
217 dar_gbl_var_p ->dar_filter_array[i].group_nb = DAR_INITIALIZATION_VALUE;
218 dar_gbl_var_p ->dar_filter_array[i].mask_warning = DAR_INITIALIZATION_VALUE;
219 dar_gbl_var_p ->dar_filter_array[i].mask_debug = DAR_INITIALIZATION_VALUE;
220 }
221
222 /*Initialization of the index and the free index */
223 dar_gbl_var_p ->index = DAR_INVALID_VALUE;
224 dar_gbl_var_p ->free_index = DAR_INVALID_VALUE;
225
226 /*** Value of the DAR recovery status ***/
227 dar_previous_status = dar_current_status;
228
229 /* erase the dar_current_status value */
230 dar_current_status = DAR_POWER_ON_OFF;
231
232 /*** Value of the DAR exception status ***/
233 dar_previous_exception = dar_exception_status;
234
235 /* erase the dar_exception_status value */
236 dar_exception_status = DAR_NO_ABORT_EXCEPTION;
237
238 return RV_OK;
239 }
240
241
242 /***************************************************************************/
243 /* Function : dar_stop */
244 /* */
245 /* Description : This function is called by the RV Environment to stop the */
246 /* diagnose SWE. */
247 /* */
248 /* Parameters : None */
249 /* */
250 /* Return : T_RVM_RETURN */
251 /* */
252 /* History : 0.1 (27-September-2001) */
253 /* */
254 /* */
255 /***************************************************************************/
256 T_RVM_RETURN dar_stop(void)
257 {
258 /* other SWEs have not been killed yet, DAR can send messages to other
259 SWEs */
260
261 return RV_OK;
262 }
263
264
265 /***************************************************************************/
266 /* Function : dar_kill */
267 /* */
268 /* Description : This function is called by the RV Environment to kill the */
269 /* diagnose SWE, after the diagnose_stop function has been */
270 /* called. */
271 /* */
272 /* Parameters : None */
273 /* */
274 /* Return : T_RVM_RETURN */
275 /* */
276 /* History : 0.1 (27-September-2001) */
277 /* */
278 /* */
279 /***************************************************************************/
280 T_RVM_RETURN dar_kill (void)
281 {
282 /* free all memory buffer previously allocated */
283 rvf_free_buf ((T_RVF_BUFFER *) dar_gbl_var_p);
284 return RV_OK;
285 }
286
287 #endif /* #ifdef RVM_DAR_SWE */