FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/riviera/rvm/rvm_api.c @ 143:afceeeb2cba1
Our nuc-fw is destined to become gsm-fw, so I went ahead and did the big hg mv
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Tue, 12 Nov 2013 05:35:48 +0000 |
parents | nuc-fw/riviera/rvm/rvm_api.c@15e972110527 |
children |
comparison
equal
deleted
inserted
replaced
142:15d5977390c2 | 143:afceeeb2cba1 |
---|---|
1 /** | |
2 * | |
3 * @file rvm_api.c | |
4 * | |
5 * This file contains interface functions. | |
6 * | |
7 * @author Cristian Livadiotti (c-livadiotti@ti.com) | |
8 * @version 0.2 | |
9 * | |
10 */ | |
11 | |
12 /* | |
13 * Revision History: | |
14 * | |
15 * 06/04/2000 Cristian Livadiotti Create. | |
16 * 10/22/2001 David Lamy-Charrier Update for new Riviera 1.6. | |
17 * | |
18 * (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved | |
19 */ | |
20 | |
21 | |
22 #include "../../include/config.h" | |
23 | |
24 #include "../rvf/rvf_env.h" | |
25 | |
26 #include "rvm_gen.h" | |
27 #include "rvm_api.h" | |
28 #include "rvm_i.h" | |
29 #include "rvm_use_id_list.h" | |
30 | |
31 #include <string.h> | |
32 | |
33 extern T_RVM_KNOWN_SWE * rvm_swe_array; | |
34 | |
35 | |
36 /******************************************************************************* | |
37 ** Function rvm_start_environment | |
38 ** | |
39 ** Description Start the RV manager. | |
40 ** | |
41 *******************************************************************************/ | |
42 T_RVM_RETURN rvm_start_environment() | |
43 { T_RVF_BUFFER * rvm_stack; | |
44 | |
45 /* initialize the RVM */ | |
46 if ( rvm_init() == FALSE) | |
47 { return RVM_INTERNAL_ERR; | |
48 } | |
49 | |
50 /* start the RV manager task */ | |
51 | |
52 if ( rvf_get_buf( rvm_stack_mem_bank, RVM_STACK_SIZE, &rvm_stack) == RVF_RED ) | |
53 { return RVM_MEMORY_ERR; | |
54 } | |
55 | |
56 if ( rvf_create_task( rvm_task, RVM_TASK_ID, "RVM", rvm_stack, RVM_STACK_SIZE, RVM_PRIORITY, RVM_TASK, DEFAULT_TIME_SLICING, RUNNING) | |
57 != RVF_OK ) | |
58 { return RVM_INTERNAL_ERR; | |
59 } | |
60 | |
61 return RVM_OK; | |
62 } | |
63 | |
64 | |
65 /******************************************************************************* | |
66 ** | |
67 ** Function rvm_start_swe | |
68 ** | |
69 ** Description Called by an application to start the specified SWE | |
70 ** | |
71 ** Parameters: USE_ID of the SWE to start. | |
72 ** return path for asynchronous response | |
73 ** | |
74 ** Returns T_RVM_RETURN: RVM_OK if everything is ok, | |
75 ** RVM_INVALID_PARAMETER if the SWE USE_ID is unknown | |
76 ** RVM_NOT_READY if the get_info function has not been specified in the database | |
77 ** or the SWE has been already started. | |
78 ** RVM_MEMORY_ERR if there is not enough memory in the RVM memory bank. | |
79 ** RVM_INTERNAL_ERR if the RVM task has not been created. | |
80 ** | |
81 *******************************************************************************/ | |
82 T_RVM_RETURN rvm_start_swe (T_RVM_USE_ID swe_use_id, T_RV_RETURN_PATH return_path) | |
83 { | |
84 T_RVM_MSG *msg; | |
85 T_RVM_RETURN rvm_status; | |
86 UINT8 num_swe; | |
87 | |
88 /* Check Application is "startable" */ | |
89 if ((rvm_status = rvm_check_application (swe_use_id, &num_swe, RVM_START_APPLI)) != RVM_OK) | |
90 { | |
91 rvf_send_trace("RVM_task: rvm_start_swe() this appli cannot be started", 54, (UINT32)rvm_status, RV_TRACE_LEVEL_WARNING, RVM_USE_ID ); | |
92 return rvm_status; | |
93 } | |
94 | |
95 /* build a msg */ | |
96 if (rvf_get_buf( rvm_mem_bank, sizeof(T_RVM_MSG), (void **)&msg) == RVF_RED ) | |
97 { | |
98 rvf_send_trace("RVM_task: No memory", 19, NULL_PARAM, RV_TRACE_LEVEL_WARNING, RVM_USE_ID ); | |
99 return RVM_MEMORY_ERR; | |
100 } | |
101 | |
102 msg->header.msg_id = RVM_START_APPLI; | |
103 msg->header.src_addr_id = return_path.addr_id; | |
104 // msg->header.callback_func = return_path.callback_func; | |
105 msg->rp.callback_func = return_path.callback_func; | |
106 msg->swe_num = num_swe; | |
107 | |
108 rvf_send_trace("RVM: SWE START REQUEST", 22, rvm_swe_array[num_swe].swe_use_id, RV_TRACE_LEVEL_DEBUG_LOW, RVM_USE_ID ); | |
109 | |
110 /* and send it to the RVM task to be treated by the RVM task */ | |
111 /* Note: task_id is used as the destination addr_id. This is only */ | |
112 /* true in the case of mailbox zero. Then task_id==addr_id */ | |
113 if ( rvf_send_msg( RVM_TASK_ID, msg) != RVF_OK) | |
114 { rvf_free_buf( msg); | |
115 return RVM_INTERNAL_ERR; | |
116 } | |
117 | |
118 return RVM_OK; | |
119 } | |
120 | |
121 /******************************************************************************* | |
122 ** | |
123 ** Function rvm_stop_swe | |
124 ** | |
125 ** Description Called by an application to stop the specified SWE. | |
126 ** | |
127 ** Parameters: USE_ID of the SWE to start. | |
128 ** return path for asynchronous response | |
129 ** | |
130 ** Returns T_RVM_RETURN: RVM_OK if everything is ok, | |
131 ** RVM_INVALID_PARAMETER if the USE_ID is unknown | |
132 ** RVM_NOT_READY if the get_info function has not been specified in the database | |
133 ** or the SWE is not running. | |
134 ** RVM_MEMORY_ERR if there is not enough memory in the RVM memory bank. | |
135 ** RVM_INTERNAL_ERR if the RVM task has not been created. | |
136 ** | |
137 ** RV2 ADDITIONAL NOTES: This now creates a RVM_STOP_MSG instead of a RVM_STOP_APPLI message. | |
138 ** both are supported in the RVM-FSM, hence the legacy concept may be reverted to easily | |
139 *******************************************************************************/ | |
140 T_RVM_RETURN rvm_stop_swe (T_RVM_USE_ID swe_use_id, T_RV_RETURN_PATH return_path) | |
141 { | |
142 T_RVM_STOP_MSG *msg; | |
143 T_RVM_RETURN rvm_status; | |
144 UINT8 num_swe; | |
145 | |
146 /* | |
147 ** Check Application is "stopable" | |
148 */ | |
149 if ((rvm_status = rvm_check_application (swe_use_id, &num_swe, RVM_STOP_APPLI)) != RVM_OK) | |
150 return rvm_status; | |
151 | |
152 /* build a msg */ | |
153 if (rvf_get_buf( rvm_mem_bank, sizeof(T_RVM_STOP_MSG), (void **)&msg) == RVF_RED ) | |
154 { return RVM_MEMORY_ERR; | |
155 } | |
156 | |
157 msg->header.msg_id = RVM_STOP_MSG; | |
158 msg->header.src_addr_id = return_path.addr_id; | |
159 // msg->header.callback_func = return_path.callback_func; | |
160 msg->rp.callback_func = return_path.callback_func; | |
161 msg->swe_num = num_swe; | |
162 msg->status = SWE_RUNNING; | |
163 | |
164 /* and send it to the rve mailbox to be treated by the RVM task */ | |
165 if ( rvf_send_msg( RVM_TASK_ID, msg) != RVF_OK) | |
166 { rvf_free_buf( msg); | |
167 return RVM_INTERNAL_ERR; | |
168 } | |
169 | |
170 return RVM_OK; | |
171 } | |
172 | |
173 // NOTE: this may be used to enable the terminator to uncondionally | |
174 // kill the Entity. Mainly, spoofing RVM. | |
175 T_RVM_RETURN rvm_kill_immediate (T_RVM_USE_ID swe_use_id, T_RV_RETURN_PATH return_path){ | |
176 T_RVM_STOP_MSG *msg; | |
177 T_RVM_RETURN rvm_status; | |
178 UINT8 num_swe; | |
179 | |
180 /* | |
181 ** Check Application is "stopable" | |
182 */ | |
183 if ((rvm_status = rvm_check_application (swe_use_id, &num_swe, RVM_STOP_APPLI)) != RVM_OK) | |
184 return rvm_status; | |
185 | |
186 /* build a msg */ | |
187 if (rvf_get_buf( rvm_mem_bank, sizeof(T_RVM_STOP_MSG), (void **)&msg) == RVF_RED ) | |
188 { return RVM_MEMORY_ERR; | |
189 } | |
190 | |
191 msg->header.msg_id = RVM_STOP_MSG; | |
192 msg->header.src_addr_id = return_path.addr_id; | |
193 // msg->header.callback_func = return_path.callback_func; | |
194 msg->rp.callback_func = return_path.callback_func; | |
195 msg->swe_num = num_swe; | |
196 msg->status = SWE_STOPPING; | |
197 | |
198 /* and send it to the rve mailbox to be treated by the RVM task */ | |
199 if ( rvf_send_msg( RVM_TASK_ID, msg) != RVF_OK) | |
200 { rvf_free_buf( msg); | |
201 return RVM_INTERNAL_ERR; | |
202 } | |
203 | |
204 return RVM_OK; | |
205 } | |
206 | |
207 T_RVM_RETURN rvm_swe_stopped(T_RV_HDR* p_msg) { | |
208 T_RVM_STOP_MSG *msg=(T_RVM_STOP_MSG*)p_msg; | |
209 | |
210 msg->status = SWE_STOPPING; | |
211 | |
212 if ( rvf_send_msg( RVM_TASK_ID, msg) != RVF_OK) { | |
213 rvf_free_buf( msg); | |
214 return RVM_INTERNAL_ERR; | |
215 } | |
216 return RVM_OK; | |
217 } | |
218 | |
219 /******************************************************************************* | |
220 ** | |
221 ** Function rvm_snd_msg_to_upper | |
222 ** | |
223 ** Description Called during processing to report to MMI the result of an | |
224 ** action. | |
225 ** | |
226 ** Parameters: name of the application to start. | |
227 ** return path for asynchronous response | |
228 ** | |
229 ** Returns T_RVM_RETURN: RVM_OK if everything is ok, | |
230 ** RVM_INVALID_PARAMETER if the appli name is unknown | |
231 ** RVM_NOT_READY if the get_info function has not been specified in the database | |
232 ** or the application has been already started. | |
233 ** RVM_MEMORY_ERR if there is not enough memory in the RVM memory bank. | |
234 ** RVM_INTERNAL_ERR if the RVM task has not been created. | |
235 ** | |
236 *******************************************************************************/ | |
237 T_RVM_RETURN rvm_snd_msg_to_upper (T_RVM_APPLI_ACTION action, | |
238 T_RVM_RETURN result, | |
239 UINT8 swe_num, | |
240 T_RV_RETURN_PATH return_path) | |
241 { | |
242 T_RVM_APPLI_RESULT *msg; | |
243 | |
244 | |
245 /* build a msg */ | |
246 if (rvf_get_buf( rvm_mem_bank, sizeof(T_RVM_APPLI_RESULT), (void **)&msg) == RVF_RED ) | |
247 { return RVM_MEMORY_ERR; | |
248 } | |
249 | |
250 msg->header.msg_id = RVM_EVT_TO_APPLI; | |
251 msg->header.src_addr_id = RVM_TASK_ID; | |
252 // msg->header.callback_func = return_path.callback_func; | |
253 msg->rp.callback_func = return_path.callback_func; | |
254 msg->result = result; | |
255 msg->action = action; | |
256 msg->swe_index = swe_num; | |
257 | |
258 memcpy(msg->swe_name, rvm_swe_array[swe_num].swe_name, RVM_NAME_MAX_LEN); | |
259 | |
260 /* and send it to the rve mailbox to be treated by the RVM task */ | |
261 if (return_path.callback_func) | |
262 { | |
263 return_path.callback_func ((void*) msg); | |
264 } | |
265 else | |
266 { | |
267 if ( rvf_send_msg(return_path.addr_id, (void*)msg) != RVF_OK) | |
268 { rvf_free_buf( msg); | |
269 return RVM_INTERNAL_ERR; | |
270 } | |
271 } | |
272 | |
273 return RVM_OK; | |
274 } | |
275 | |
276 | |
277 | |
278 /******************************************************************************* | |
279 ** | |
280 ** Function rvm_get_swe_information | |
281 ** | |
282 ** Description Called by a SWE to know information about another SWE. | |
283 ** | |
284 ** Parameters In: name of the swe we want to get information about. | |
285 ** | |
286 ** Parameters Out: State of the SWE. | |
287 ** | |
288 ** Returns T_RVM_RETURN: RVM_OK if everything is ok, | |
289 ** RVM_INVALID_PARAMETER if the SWE use_id is unknown | |
290 ** RVM_NOT_READY if the | |
291 ** RVM_MEMORY_ERR if there is not enough memory in the RVM memory bank. | |
292 ** RVM_INTERNAL_ERR if the RVM task has not been created. | |
293 ** | |
294 *******************************************************************************/ | |
295 T_RVM_RETURN rvm_get_swe_information (T_RVM_USE_ID swe_id, | |
296 T_RV_RETURN_PATH * return_path) | |
297 { | |
298 UINT8 swe_index; | |
299 | |
300 if (rvm_get_swe_index(&swe_index, swe_id) != RVM_OK) | |
301 { | |
302 | |
303 RVM_TRACE_WARNING_PARAM("RVM API: Get SWE Information of an unknown SWE, use_id:", swe_id); | |
304 return RVM_INVALID_PARAMETER; | |
305 } | |
306 | |
307 if (return_path != NULL) | |
308 { | |
309 (*return_path).callback_func = rvm_swe_array[swe_index].swe_return_path.callback_func; | |
310 (*return_path).addr_id = rvm_swe_array[swe_index].swe_addr_id; | |
311 } | |
312 | |
313 return RVM_OK; | |
314 } |