comparison chipsetsw/services/dar/dar_env.c @ 0:509db1a7b7b8

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
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 "rv/rv_defined_swe.h"
26 #ifdef RVM_DAR_SWE
27 #include "rv/rv_general.h"
28 #include "rvm/rvm_gen.h"
29 #include "rvm/rvm_priorities.h"
30 #include "rvm/rvm_use_id_list.h"
31 #include "dar/dar_api.h"
32 #include "dar/dar_env.h"
33 #include "dar/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 fill */
65 /* 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 Block. */
145 mb_status = rvf_get_buf(mbId[0],
146 sizeof(T_DAR_ENV_CTRL_BLK),
147 (T_RVF_BUFFER **) & dar_gbl_var_p);
148
149 /* If insufficient resources to properly run the DAR's task, then abort. */
150 switch (mb_status)
151 {
152 case RVF_GREEN:
153 {
154 /* Initialize the Global Environment Control Block */
155 memset((UINT8 *) dar_gbl_var_p,
156 0x00,
157 sizeof (T_DAR_ENV_CTRL_BLK));
158
159 /* Store the memory bank IDs assigned to the DAR */
160 dar_gbl_var_p->mb_dar = mbId[0];
161
162 /* Store the addr ID assigned to the DAR */
163 dar_gbl_var_p->addrId = addrId;
164
165 /* Store the function to be called whenever any unrecoverable */
166 /* error occurs. */
167 dar_gbl_var_p->callBackFctError = callBackFctError;
168 DAR_SEND_TRACE(" Diagnose And Recovery (env). DAR's information set ",
169 RV_TRACE_LEVEL_DEBUG_LOW);
170 break;
171 }
172 case RVF_YELLOW:
173 {
174 rvf_free_buf((T_RVF_BUFFER *) dar_gbl_var_p);
175 DAR_TRACE_WARNING(" DAR memory warning (orange memory)");
176 return (RV_MEMORY_ERR);
177 }
178 default:
179 {
180 DAR_TRACE_WARNING(" DAR memory warning (red memory)");
181 return (RV_MEMORY_ERR);
182 }
183 } /* switch (mb_status) */
184
185 return (RV_OK);
186 } /*************** End of dar_set_info function ********************************/
187
188
189
190 /********************************************************************************/
191 /* Function : dar_init */
192 /* */
193 /* Description : This function is called by the RV Environment to initialize the*/
194 /* diagnose SWE before creating the task and calling dar_start. */
195 /* */
196 /* Parameters : None */
197 /* */
198 /* Return : T_RVM_RETURN */
199 /* */
200 /* History : 0.1 (27-September-2001) */
201 /* */
202 /* */
203 /********************************************************************************/
204 T_RVM_RETURN dar_init(void)
205 {
206 /*** Declare local variables ***/
207 UINT16 i = 0;
208
209 /*** Initialization of the DAR global structure ***/
210
211 /* Initialization of the dar_filter_array */
212 for (i=0;i<DAR_MAX_GROUP_NB;i++)
213 {
214 dar_gbl_var_p ->dar_filter_array[i].group_nb = DAR_INITIALIZATION_VALUE;
215 dar_gbl_var_p ->dar_filter_array[i].mask_warning = DAR_INITIALIZATION_VALUE;
216 dar_gbl_var_p ->dar_filter_array[i].mask_debug = DAR_INITIALIZATION_VALUE;
217 }
218
219 /*Initialization of the index and the free index */
220 dar_gbl_var_p ->index = DAR_INVALID_VALUE;
221 dar_gbl_var_p ->free_index = DAR_INVALID_VALUE;
222
223 /*** Value of the DAR recovery status ***/
224 dar_previous_status = dar_current_status;
225
226 /* erase the dar_current_status value */
227 dar_current_status = DAR_POWER_ON_OFF;
228
229 /*** Value of the DAR exception status ***/
230 dar_previous_exception = dar_exception_status;
231
232 /* erase the dar_exception_status value */
233 dar_exception_status = DAR_NO_ABORT_EXCEPTION;
234
235 return RV_OK;
236 }
237
238
239 /*************************************************************************************/
240 /* Function : dar_stop */
241 /* */
242 /* Description : This function is called by the RV Environment to stop the diagnose */
243 /* SWE. */
244 /* */
245 /* Parameters : None */
246 /* */
247 /* Return : T_RVM_RETURN */
248 /* */
249 /* History : 0.1 (27-September-2001) */
250 /* */
251 /* */
252 /*************************************************************************************/
253 T_RVM_RETURN dar_stop(void)
254 {
255 /* other SWEs have not been killed yet, DAR can send messages to other SWEs */
256
257 return RV_OK;
258 }
259
260
261 /*************************************************************************************/
262 /* Function : dar_kill */
263 /* */
264 /* Description : This function is called by the RV Environment to kill the diagnose */
265 /* SWE, after the diagnose_stop function has been called. */
266 /* */
267 /* Parameters : None */
268 /* */
269 /* Return : T_RVM_RETURN */
270 /* */
271 /* History : 0.1 (27-September-2001) */
272 /* */
273 /* */
274 /*************************************************************************************/
275 T_RVM_RETURN dar_kill (void)
276 {
277 /* free all memory buffer previously allocated */
278 rvf_free_buf ((T_RVF_BUFFER *) dar_gbl_var_p);
279 return RV_OK;
280 }
281
282 #endif /* #ifdef RVM_DAR_SWE */