comparison riviera/rvt/rvt_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 * rvt_env.c
4 *
5 * This module interfaces the environment and contains all start/init/stop...
6 * functions of the trace module.
7 *
8 * (C) Texas Instruments, all rights reserved
9 *
10 * Version number : 0.1
11 *
12 * History : 0.1 (7/4/2000) - Created
13 *
14 * Date : 7/4/2000
15 *
16 * Author : Cristian Livadiotti, c-livadiotti@ti.com
17 *
18 ********************************************************************************/
19
20 #include "../../include/config.h"
21
22 #include <string.h>
23
24 #include "../rvf/rvf_api.h"
25 #include "../rv/rv_general.h"
26 #include "../rvm/rvm_gen.h"
27 #include "../rvm/rvm_priorities.h"
28
29 #include "rvt_gen.h"
30 #include "rvt_def_i.h"
31 #include "rvt_env.h"
32 #include "rvt_env_i.h"
33
34 #include "../rvm/rvm_use_id_list.h"
35
36 #include "../../serial/serialswitch.h"
37
38 #include "../../nucleus/nucleus.h"
39
40 #define TI_RX_HISR_STACK_SIZE (1024)
41 static UINT8 TI_RX_HISR_stack[TI_RX_HISR_STACK_SIZE];
42
43 char *p_rvt_lost_msg = NULL;
44 char *p_rvt_sys_time = NULL;
45 NU_HISR TI_rcv_HISR;
46 T_RVF_MB_ID rvt_mb_id = 0;
47 T_RVT_STATE rvt_module_state = RVT_NOT_STARTED;
48 T_RVF_ADDR_ID rvt_addr_id = 0;
49
50
51 /********************************************************************************/
52 /* */
53 /* Function Name: rvt_get_info */
54 /* */
55 /* Purpose: This function is used to notify the RVM */
56 /* of the Trace's Memory Banks requirements. */
57 /* */
58 /* Input Parameters: */
59 /* &p_info_swe (refer to rvm_gen.h). */
60 /* */
61 /* Output Parameters: */
62 /* p_info_swe (refer to rvm_gen.h). */
63 /* */
64 /* Global Parameters: */
65 /* None. */
66 /* */
67 /* Note: */
68 /* None. */
69 /* */
70 /********************************************************************************/
71
72 T_RVM_RETURN
73 rvt_get_info (T_RVM_INFO_SWE *p_info_swe)
74 {
75 if (!p_info_swe)
76 return RVM_INVALID_PARAMETER;
77
78 p_info_swe->swe_type = RVM_SWE_TYPE_4;
79
80 p_info_swe->type_info.type4.swe_use_id = RVT_USE_ID;
81 p_info_swe->type_info.type4.version = 1;
82 memcpy (p_info_swe->type_info.type4.swe_name,
83 "TRACE",
84 sizeof ("TRACE"));
85
86 p_info_swe->type_info.type4.stack_size = TRACE_TASK_STACK_SIZE;
87 p_info_swe->type_info.type4.priority = RVM_TRACE_TASK_PRIORITY;
88
89 p_info_swe->type_info.type4.return_path.addr_id = 0;
90 p_info_swe->type_info.type4.return_path.callback_func = NULL;
91
92 // Memory banks definitions. For now, one memory bank is needed
93 p_info_swe->type_info.type4.nb_mem_bank = 1;
94 memcpy (p_info_swe->type_info.type4.mem_bank[0].bank_name,
95 "RV_TRACE",
96 RVM_NAME_MAX_LEN);
97 p_info_swe->type_info.type4.mem_bank[0].initial_params.size = TRACE_MB_SIZE;
98 p_info_swe->type_info.type4.mem_bank[0].initial_params.watermark = TRACE_MB_WATERMARK;
99
100 // Generic functions
101 p_info_swe->type_info.type4.init = rvt_init;
102 p_info_swe->type_info.type4.core = (T_RVM_SWE_CORE_FUNC)rvt_task_core;
103 p_info_swe->type_info.type4.stop = rvt_stop;
104 p_info_swe->type_info.type4.kill = rvt_kill;
105 p_info_swe->type_info.type4.set_info = rvt_set_info;
106
107 // Linked SW entities: none, except if Profiler or Nucleus Monitor are defined
108 #if (TI_PROFILER == 1) || (TI_NUC_MONITOR == 1)
109 p_info_swe->type_info.type4.nb_linked_swe = 1;
110 p_info_swe->type_info.type4.linked_swe_id[0] = TI_PRF_USE_ID;
111 #else
112 p_info_swe->type_info.type4.nb_linked_swe = 0;
113 #endif
114
115 return RVM_OK;
116 }
117
118
119 /********************************************************************************/
120 /* */
121 /* Function Name: rvt_set_info */
122 /* */
123 /* Purpose: This function is used to notify the Trace module */
124 /* about mb ids and task id. */
125 /* */
126 /* Input Parameters: */
127 /* bk_id[]: array of memory bank IDs. */
128 /* */
129 /* Output Parameters: */
130 /* None. */
131 /* */
132 /* Global Parameters: */
133 /* None. */
134 /* */
135 /* Note: */
136 /* None. */
137 /* */
138 /********************************************************************************/
139
140 T_RVM_RETURN
141 rvt_set_info (T_RVF_ADDR_ID addr_id,
142 T_RV_RETURN_PATH return_path[],
143 T_RVF_MB_ID bk_id[],
144 T_RVM_CB_FUNC rvm_error_ft)
145 {
146
147 // Save parameters given by the environment (Addr ID and MB ID respectively)
148 rvt_addr_id = addr_id;
149 rvt_mb_id = bk_id [0];
150
151 return RVM_OK;
152 }
153
154
155 /********************************************************************************/
156 /* */
157 /* Function Name: rvt_init */
158 /* */
159 /* Purpose: This is the initialization function. */
160 /* It is called by the RVM. */
161 /* */
162 /* Input Parameters: */
163 /* None. */
164 /* */
165 /* Output Parameters: */
166 /* None. */
167 /* */
168 /* Global Parameters: */
169 /* None. */
170 /* */
171 /* Note: */
172 /* None. */
173 /* */
174 /********************************************************************************/
175
176 T_RVM_RETURN
177 rvt_init (void)
178 {
179
180 if (rvt_module_state != RVT_NOT_STARTED)
181 return RVM_NOT_READY;
182
183 // The stack is entirely filled with the pattern 0xFE
184 memset (TI_RX_HISR_stack,
185 0xFE,
186 TI_RX_HISR_STACK_SIZE);
187
188 // Create the RX HISR
189 if (NU_Create_HISR (&TI_rcv_HISR, \
190 "TI_RCV_HISR", \
191 rvt_RX_process, \
192 2, \
193 TI_RX_HISR_stack, \
194 TI_RX_HISR_STACK_SIZE) != NU_SUCCESS)
195 return RVM_INTERNAL_ERR;
196
197 // Initialize the baud rate and the callback function for the RX HISR
198 SER_tr_Init (SER_LAYER_1,
199 TR_BAUD_CONFIG,
200 rvt_activate_RX_HISR);
201
202 #ifdef FRAMING_PROTOCOL
203
204 // Allocate a buffer that reports the system time (refer to rvf_trace_adapt.c):
205 // - 'User ID' (1 byte),
206 // - 'Trace Type' (4 bytes),
207 // - 'Trace Level' (1 byte),
208 // - 'System Time' (RVT_SYS_TIME_LENGTH bytes),
209 // - Hexadecimal value (RVT_HEX_VALUE_LENGTH bytes).
210 if (rvf_get_buf (rvt_mb_id, \
211 (RVT_HDR_LENGTH + RVT_SYS_TIME_LENGTH + RVT_HEX_VALUE_LENGTH), \
212 (T_RVF_BUFFER**)&p_rvt_sys_time) != RVF_RED)
213 {
214 UINT8 *header_p = NULL;
215
216 header_p = (UINT8*)p_rvt_sys_time;
217 *header_p++ = (UINT8)rv_trace_user_id;
218 *header_p++ = 0;
219 *header_p++ = 0;
220 *header_p++ = 0;
221 *header_p++ = 0;
222 *header_p++ = RV_TRACE_LEVEL_ERROR;
223 memcpy (header_p,
224 RVT_SYS_TIME,
225 RVT_SYS_TIME_LENGTH);
226 }
227
228 // Allocate a buffer that reports a lack of memory (refer to rvf_trace_adapt.c):
229 // - 'User ID' (1 byte),
230 // - 'Trace Type' (4 bytes),
231 // - 'Trace Level' (1 byte),
232 // - 'Lost Message' (RVT_LOST_MSG_LENGTH bytes),
233 // - Hexadecimal value (RVT_HEX_VALUE_LENGTH bytes).
234 if (rvf_get_buf (rvt_mb_id,
235 (RVT_HDR_LENGTH + RVT_LOST_MSG_LENGTH + RVT_HEX_VALUE_LENGTH), \
236 (T_RVF_BUFFER**)&p_rvt_lost_msg) != RVF_RED)
237 {
238 UINT8 *header_p = NULL;
239
240 header_p = (UINT8*)p_rvt_lost_msg;
241 *header_p++ = (UINT8)rv_trace_user_id;
242 *header_p++ = 0;
243 *header_p++ = 0;
244 *header_p++ = 0;
245 *header_p++ = 0;
246 *header_p++ = RV_TRACE_LEVEL_ERROR;
247 memcpy (header_p,
248 RVT_LOST_MSG,
249 RVT_LOST_MSG_LENGTH);
250 }
251 #else
252
253 // Allocate a buffer that reports the system time
254 if (rvf_get_buf (rvt_mb_id, \
255 (RVT_SYS_TIME_LENGTH + RVT_HEX_VALUE_LENGTH + RVT_HYPERTERM_LENGTH), \
256 (T_RVF_BUFFER**)&p_rvt_sys_time) != RVF_RED)
257 {
258 memcpy (p_rvt_sys_time,
259 RVT_SYS_TIME,
260 RVT_SYS_TIME_LENGTH);
261 }
262
263 // Allocate a buffer that reports a lack of memory
264 if (rvf_get_buf (rvt_mb_id, \
265 (RVT_LOST_MSG_LENGTH + RVT_HEX_VALUE_LENGTH + RVT_HYPERTERM_LENGTH), \
266 (T_RVF_BUFFER**)&p_rvt_lost_msg) != RVF_RED)
267 {
268 memcpy (p_rvt_lost_msg,
269 RVT_LOST_MSG,
270 RVT_LOST_MSG_LENGTH);
271 }
272 #endif
273
274 // State RVT as "STARTED"
275 rvt_module_state = RVT_STARTED;
276
277 return RVM_OK;
278 }
279
280
281 /********************************************************************************/
282 /* */
283 /* Function Name: rvt_stop */
284 /* */
285 /* Purpose: This function is defined for compilation only. */
286 /* */
287 /* Input Parameters: */
288 /* None. */
289 /* */
290 /* Output Parameters: */
291 /* None. */
292 /* */
293 /* Global Parameters: */
294 /* None. */
295 /* */
296 /* Note: */
297 /* None. */
298 /* */
299 /********************************************************************************/
300
301 T_RVM_RETURN
302 rvt_stop (void)
303 {
304 return RVM_OK;
305 }
306
307
308 /********************************************************************************/
309 /* */
310 /* Function Name: rvt_kill */
311 /* */
312 /* Purpose: This function is defined for compilation only. */
313 /* */
314 /* Input Parameters: */
315 /* None. */
316 /* */
317 /* Output Parameters: */
318 /* None. */
319 /* */
320 /* Global Parameters: */
321 /* None. */
322 /* */
323 /* Note: */
324 /* None. */
325 /* */
326 /********************************************************************************/
327
328 T_RVM_RETURN
329 rvt_kill (void)
330 {
331 return RVM_OK;
332 }