comparison services/etm/etm_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 * Enhanced TestMode (ETM)
3 * @file etm_env.c
4 *
5 * @author Kim T. Peteren (ktp@ti.com)
6 * @version 0.1
7 *
8
9 *
10 * History:
11 *
12 * Date Modification
13 * ------------------------------------
14 * 16/06/2003 Creation
15 *
16 * (C) Copyright 2003 by Texas Instruments Incorporated, All Rights Reserved
17 *********************************************************************************/
18
19 #include "etm_config.h"
20 #include "etm_env.h"
21
22 #include "../../riviera/rvm/rvm_priorities.h"
23 #include "../../riviera/rvm/rvm_use_id_list.h"
24 #include "../../riviera/rv/rv_defined_swe.h"
25
26 #include <string.h>
27 /******************************************************************************
28 *
29 *****************************************************************************/
30
31 /* External declaration */
32 extern T_RV_RET etm_task(void);
33
34
35 /**
36 * Pointer on the structure gathering all the global variables
37 * used by ETM instance.
38 */
39 T_ETM_ENV_CTRL_BLK *etm_env_ctrl_blk = NULL;
40
41
42 /******************************************************************************
43 * Function : etm_get_info
44 *
45 * Description : This function is called by the RV manager to learn
46 * driver requirements in terms of memory, SWEs...
47 *
48 * Parameters : T_RVM_INFO_SWE * swe_info: pointer to the structure to fill
49 * containing infos related to the driver SWE.
50 *
51 * Return : T_RVM_RETURN
52 *
53 * History : 0.1
54 *
55 *
56 ******************************************************************************/
57 T_RVM_RETURN etm_get_info(T_RVM_INFO_SWE *swe_info)
58 {
59 /* SWE info */
60 swe_info->swe_type = RVM_SWE_TYPE_4;
61 swe_info->type_info.type4.swe_use_id = ETM_USE_ID;
62
63 memcpy(swe_info->type_info.type4.swe_name, "ETM", sizeof("ETM"));
64 swe_info->type_info.type4.stack_size = ETM_STACK_SIZE;
65 swe_info->type_info.type4.priority = RVM_ETM_TASK_PRIORITY;
66
67 /* Set the return path */
68 swe_info->type_info.type4.return_path.callback_func = NULL;
69 swe_info->type_info.type4.return_path.addr_id = 0;
70
71 /* memory bank info */
72 swe_info->type_info.type4.nb_mem_bank = 1;
73
74 memcpy (swe_info->type_info.type4.mem_bank[0].bank_name, "ETM_PRIM", 9);
75 swe_info->type_info.type4.mem_bank[0].initial_params.size = ETM_MB_PRIM_SIZE;
76 swe_info->type_info.type4.mem_bank[0].initial_params.watermark = ETM_MB_PRIM_WATERMARK;
77
78 /* linked SWE info */
79 /* this SWE requires the ATP SWE to run */
80 #if ETM_ATP_SUPPORT
81 swe_info->type_info.type4.nb_linked_swe = 1;
82 swe_info->type_info.type4.linked_swe_id[0] = ATP_USE_ID;
83 #else
84 swe_info->type_info.type4.nb_linked_swe = 0;
85 #endif
86
87 /* generic functions */
88 swe_info->type_info.type4.set_info = etm_set_info;
89 swe_info->type_info.type4.init = etm_init;
90 swe_info->type_info.type4.core = etm_start;
91 swe_info->type_info.type4.stop = etm_stop;
92 swe_info->type_info.type4.kill = etm_kill;
93
94 return RVM_OK;
95 }
96
97
98 /******************************************************************************
99 * Function : etm_set_info
100 *
101 * Description : This function is called by the RV manager to inform
102 * the driver SWE about task_id, mb_id and error function.
103 *
104 * Parameters : - T_RVF_ADDR_ID addr_id: unique path to the SWE.
105 * - T_RV_RETURN ReturnPath[], array of return path for linked SWE
106 * - T_RVF_MB_ID mbId[]: array of memory bank ids.
107 * - callback function to call in case of unrecoverable error.
108 *
109 * Return : T_RVM_RETURN
110 *
111 * History : 0.1
112 *
113 *
114 ******************************************************************************/
115
116 T_RVM_RETURN etm_set_info (T_RVF_ADDR_ID addr_id,
117 T_RV_RETURN return_path[],
118 T_RVF_MB_ID bk_id[],
119 T_RVM_RETURN (*rvm_error_ft)(T_RVM_NAME swe_name,
120 T_RVM_RETURN error_cause,
121 T_RVM_ERROR_TYPE error_type,
122 T_RVM_STRING error_msg))
123 {
124 /* Create instance gathering all the variable used by EXPL instance */
125 if (rvf_get_buf(bk_id[0],
126 sizeof(T_ETM_ENV_CTRL_BLK),
127 (T_RVF_BUFFER**)&etm_env_ctrl_blk) != RVF_GREEN)
128 {
129 /* The environemnt will cancel the ETM instance creation. */
130 return RVM_MEMORY_ERR;
131 }
132
133 /* Store the pointer to the error function */
134 etm_env_ctrl_blk->error_ft = rvm_error_ft ;
135 /* Store the mem bank id. */
136 etm_env_ctrl_blk->prim_id = bk_id[0];
137 /* Store the addr id */
138 etm_env_ctrl_blk->addr_id = addr_id;
139
140 /*
141 * Task ID (task_id) and Memory bank ID (mb_id) can be retrieved later
142 * using rvf_get_taskid and rvf_get_mb_id functions.
143 */
144
145 /* return_path of linked SWE -> not used */
146
147 return RVM_OK;
148 }
149
150
151 /******************************************************************************
152 * Function : etm_init
153 *
154 * Description : This function is called by the RV manager to initialize the
155 * etm SWE before creating the task and calling etm_start.
156 *
157 * Parameters : None
158 *
159 * Return : T_RVM_RETURN
160 *
161 * History : 0.1 (20-August-2000)
162 *
163 *
164 ******************************************************************************/
165
166 T_RVM_RETURN etm_init(void)
167 {
168 return RVM_OK;
169 }
170
171
172 /******************************************************************************
173 * Function : etm_start
174 *
175 * Description : This function is called by the RV manager to start the etm
176 * SWE, it is the body of the task.
177 *
178 * Parameters : None
179 *
180 * Return : T_RVM_RETURN
181 *
182 * History : 0.1
183 *
184 *
185 ******************************************************************************/
186
187 T_RVM_RETURN etm_start(void)
188 {
189 etm_task();
190 return RV_OK;
191 }
192
193
194 /******************************************************************************
195 * Function : etm_stop
196 *
197 * Description : This function is called by the RV manager to stop the etm SWE.
198 *
199 * Parameters : None
200 *
201 * Return : T_RVM_RETURN
202 *
203 * History : 0.1
204 *
205 ******************************************************************************/
206
207 T_RVM_RETURN etm_stop(void)
208 {
209 return RVM_OK;
210 }
211
212 /******************************************************************************
213 * Function : etm_kill
214 *
215 * Description : This function is called by the RV manager to kill the etm
216 * SWE, after the etm_stop function has been called.
217 *
218 * Parameters : None
219 *
220 * Return : T_RVM_RETURN
221 *
222 * History : 0.1
223 *
224 *
225 ******************************************************************************/
226
227 T_RVM_RETURN etm_kill (void)
228 {
229 rvf_free_buf(etm_env_ctrl_blk);
230 return RVM_OK;
231 }