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