comparison src/cs/services/etm/etm_env.c @ 0:92470e5d0b9e

src: partial import from FC Selenite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 15 May 2020 01:28:16 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:92470e5d0b9e
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
20 #include "etm/etm_env.h"
21
22 #include "rvm/rvm_priorities.h"
23 #include "rvm/rvm_use_id_list.h"
24 #include "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 /* FreeCalypso addition */
42 int etm_is_running;
43
44
45 /******************************************************************************
46 * Function : etm_get_info
47 *
48 * Description : This function is called by the RV manager to learn
49 * driver requirements in terms of memory, SWEs...
50 *
51 * Parameters : T_RVM_INFO_SWE * swe_info: pointer to the structure to fill
52 * containing infos related to the driver SWE.
53 *
54 * Return : T_RVM_RETURN
55 *
56 * History : 0.1
57 *
58 *
59 ******************************************************************************/
60 T_RVM_RETURN etm_get_info(T_RVM_INFO_SWE *swe_info)
61 {
62 /* SWE info */
63 swe_info->swe_type = RVM_SWE_TYPE_4;
64 swe_info->type_info.type4.swe_use_id = ETM_USE_ID;
65
66 memcpy(swe_info->type_info.type4.swe_name, "ETM", sizeof("ETM"));
67 swe_info->type_info.type4.stack_size = ETM_STACK_SIZE;
68 swe_info->type_info.type4.priority = RVM_ETM_TASK_PRIORITY;
69
70 /* Set the return path */
71 swe_info->type_info.type4.return_path.callback_func = NULL;
72 swe_info->type_info.type4.return_path.addr_id = 0;
73
74 /* memory bank info */
75 swe_info->type_info.type4.nb_mem_bank = 1;
76
77 memcpy (swe_info->type_info.type4.mem_bank[0].bank_name, "ETM_PRIM", 9);
78 swe_info->type_info.type4.mem_bank[0].initial_params.size = ETM_MB_PRIM_SIZE;
79 swe_info->type_info.type4.mem_bank[0].initial_params.watermark = ETM_MB_PRIM_WATERMARK;
80
81 /* linked SWE info */
82 /* this SWE requires the ATP SWE to run */
83 #ifdef RVM_ATP_SWE
84 swe_info->type_info.type4.nb_linked_swe = 1;
85 swe_info->type_info.type4.linked_swe_id[0] = ATP_USE_ID;
86 #else
87 swe_info->type_info.type4.nb_linked_swe = 0;
88 #endif
89
90 /* generic functions */
91 swe_info->type_info.type4.set_info = etm_set_info;
92 swe_info->type_info.type4.init = etm_init;
93 swe_info->type_info.type4.core = etm_start;
94 swe_info->type_info.type4.stop = etm_stop;
95 swe_info->type_info.type4.kill = etm_kill;
96
97 return RVM_OK;
98 }
99
100
101 /******************************************************************************
102 * Function : etm_set_info
103 *
104 * Description : This function is called by the RV manager to inform
105 * the driver SWE about task_id, mb_id and error function.
106 *
107 * Parameters : - T_RVF_ADDR_ID addr_id: unique path to the SWE.
108 * - T_RV_RETURN ReturnPath[], array of return path for linked SWE
109 * - T_RVF_MB_ID mbId[]: array of memory bank ids.
110 * - callback function to call in case of unrecoverable error.
111 *
112 * Return : T_RVM_RETURN
113 *
114 * History : 0.1
115 *
116 *
117 ******************************************************************************/
118
119 T_RVM_RETURN etm_set_info (T_RVF_ADDR_ID addr_id,
120 T_RV_RETURN return_path[],
121 T_RVF_MB_ID bk_id[],
122 T_RVM_RETURN (*rvm_error_ft)(T_RVM_NAME swe_name,
123 T_RVM_RETURN error_cause,
124 T_RVM_ERROR_TYPE error_type,
125 T_RVM_STRING error_msg))
126 {
127 /* Create instance gathering all the variable used by EXPL instance */
128 if (rvf_get_buf(bk_id[0],
129 sizeof(T_ETM_ENV_CTRL_BLK),
130 (T_RVF_BUFFER**)&etm_env_ctrl_blk) != RVF_GREEN)
131 {
132 /* The environemnt will cancel the ETM instance creation. */
133 return RVM_MEMORY_ERR;
134 }
135
136
137 /* Store the pointer to the error function */
138 etm_env_ctrl_blk->error_ft = rvm_error_ft ;
139 /* Store the mem bank id. */
140 etm_env_ctrl_blk->prim_id = bk_id[0];
141 /* Store the addr id */
142 etm_env_ctrl_blk->addr_id = addr_id;
143
144 /*
145 * Task ID (task_id) and Memory bank ID (mb_id) can be retrieved later
146 * using rvf_get_taskid and rvf_get_mb_id functions.
147 */
148
149 /* return_path of linked SWE -> not used */
150
151 return RVM_OK;
152 }
153
154
155 /******************************************************************************
156 * Function : etm_init
157 *
158 * Description : This function is called by the RV manager to initialize the
159 * etm SWE before creating the task and calling etm_start.
160 *
161 * Parameters : None
162 *
163 * Return : T_RVM_RETURN
164 *
165 * History : 0.1 (20-August-2000)
166 *
167 *
168 ******************************************************************************/
169
170 T_RVM_RETURN etm_init(void)
171 {
172 etm_is_running = 1; /* FreeCalypso addition */
173 return RVM_OK;
174 }
175
176
177 /******************************************************************************
178 * Function : etm_start
179 *
180 * Description : This function is called by the RV manager to start the etm
181 * SWE, it is the body of the task.
182 *
183 * Parameters : None
184 *
185 * Return : T_RVM_RETURN
186 *
187 * History : 0.1
188 *
189 *
190 ******************************************************************************/
191
192 T_RVM_RETURN etm_start(void)
193 {
194 etm_task();
195 return RV_OK;
196 }
197
198
199 /******************************************************************************
200 * Function : etm_stop
201 *
202 * Description : This function is called by the RV manager to stop the etm SWE.
203 *
204 * Parameters : None
205 *
206 * Return : T_RVM_RETURN
207 *
208 * History : 0.1
209 *
210 ******************************************************************************/
211
212 T_RVM_RETURN etm_stop(void)
213 {
214 etm_is_running = 0; /* FreeCalypso addition */
215 return RVM_OK;
216 }
217
218 /******************************************************************************
219 * Function : etm_kill
220 *
221 * Description : This function is called by the RV manager to kill the etm
222 * SWE, after the etm_stop function has been called.
223 *
224 * Parameters : None
225 *
226 * Return : T_RVM_RETURN
227 *
228 * History : 0.1
229 *
230 *
231 ******************************************************************************/
232
233 T_RVM_RETURN etm_kill (void)
234 {
235 rvf_free_buf(etm_env_ctrl_blk);
236 return RVM_OK;
237 }