FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/L1/glue/l1_isr_glue.c @ 599:a74230436958
gsm-fw/L1/glue/l1_isr_glue.c: initial version concocted
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 17 Aug 2014 20:44:25 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
598:d42b83dee819 | 599:a74230436958 |
---|---|
1 /* | |
2 * This module contains the LISR and HISR glue functions for L1 | |
3 * which used to be in the dl1_com module in the Leonardo version. | |
4 * The LoCosto source from which we got our L1 code no longer has a | |
5 * dl1_com.c module, and the ISR glue functions in question have been | |
6 * moved into csw-system/init_common/init.c - an incredibly messy C | |
7 * module that is mostly devoted to LoCosto BSP initialization. | |
8 * | |
9 * The present C code has been extracted from LoCosto's init.c, | |
10 * guided by the disassembly of dl1_com.obj from the Leonardo version. | |
11 */ | |
12 | |
13 #include "config.h" | |
14 #include "sys_types.h" | |
15 #include "../../nucleus/nucleus.h" | |
16 | |
17 /* Include Files */ | |
18 #include <ctype.h> | |
19 #include <stdarg.h> | |
20 #include <stdlib.h> | |
21 #include <string.h> | |
22 | |
23 #include "l1_types.h" | |
24 #include "l1_confg.h" | |
25 #include "l1_const.h" | |
26 | |
27 #if TESTMODE | |
28 #include "l1tm_defty.h" | |
29 #endif // TESTMODE | |
30 | |
31 #if (AUDIO_TASK == 1) | |
32 #include "l1audio_const.h" | |
33 #include "l1audio_cust.h" | |
34 #include "l1audio_defty.h" | |
35 #endif // AUDIO_TASK | |
36 | |
37 #if (L1_GTT == 1) | |
38 #include "l1gtt_const.h" | |
39 #include "l1gtt_defty.h" | |
40 #endif | |
41 | |
42 #if (L1_MP3 == 1) | |
43 #include "l1mp3_defty.h" | |
44 #endif | |
45 | |
46 #if (L1_MIDI == 1) | |
47 #include "l1midi_defty.h" | |
48 #endif | |
49 | |
50 #if (L1_AAC == 1) | |
51 #include "l1aac_defty.h" | |
52 #endif | |
53 #if (L1_DYN_DSP_DWNLD == 1) | |
54 #include "l1_dyn_dwl_defty.h" | |
55 #endif | |
56 | |
57 #if (TRACE_TYPE == 4) | |
58 #include "l1_defty.h" | |
59 #endif | |
60 | |
61 #include "../../bsp/armio.h" | |
62 #include "../../bsp/timer.h" | |
63 | |
64 #include "../../bsp/iq.h" | |
65 #include "../../bsp/mem.h" | |
66 #include "../../bsp/clkm.h" | |
67 #include "../../bsp/inth.h" | |
68 | |
69 /* | |
70 * The function that sets up the HISRs has an assert() macro call in it. | |
71 * The Leonardo version was built with the TMS470 compiler's C library | |
72 * version of assert() in it, which is not very useful. Here I am | |
73 * pulling in some GPF/VSI headers so we get the more useful GPF/VSI | |
74 * version of assert() instead. | |
75 */ | |
76 #include "../../gpf/inc/typedefs.h" | |
77 #include "../../gpf/inc/vsi.h" | |
78 #include "../../gpf/inc/cust_os.h" | |
79 | |
80 /* | |
81 * Timing monitor | |
82 */ | |
83 #if (TRACE_TYPE == 4) | |
84 extern T_L1A_L1S_COM l1a_l1s_com; | |
85 extern T_L1S_GLOBAL l1s; | |
86 UNSIGNED max_cpu, fn_max_cpu; | |
87 unsigned short layer_1_sync_end_time; | |
88 unsigned short max_cpu_flag; | |
89 #if (DSP >= 38) | |
90 // DSP CPU load measurement trace variables | |
91 UWORD32 dsp_max_cpu_load_trace_array[4]; | |
92 UWORD32 dsp_max_cpu_load_idle_frame; | |
93 unsigned short l1_dsp_cpu_load_trace_flag; | |
94 #endif | |
95 #endif | |
96 | |
97 #if (L1_EXT_AUDIO_MGT == 1) | |
98 NU_HISR EXT_AUDIO_MGT_hisr; | |
99 char FAR ext_audio_mgt_hisr_stack[500]; | |
100 extern void Cust_ext_audio_mgt_hisr(void); | |
101 #endif | |
102 | |
103 #if ( (L1_MP3 == 1) || (L1_MIDI == 1) || (L1_AAC == 1) || (L1_DYN_DSP_DWNLD == 1) ) // equivalent to an API_HISR flag | |
104 extern void api_hisr(void); | |
105 char FAR API_HISR_stack[0x400] __attribute__ ((section ("int.ram"))); | |
106 NU_HISR apiHISR; | |
107 #endif // (L1_MP3 == 1) || (L1_MIDI == 1) || (L1_DYN_DSP_DWNLD == 1) | |
108 | |
109 #if (FF_L1_IT_DSP_USF == 1) || (FF_L1_IT_DSP_DTX == 1) | |
110 char FAR API_MODEM_HISR_stack[0x400]; // stack size to be tuned | |
111 NU_HISR api_modemHISR; | |
112 #endif // FF_L1_IT_DSP_USF | |
113 | |
114 /* | |
115 * HISR stack and semaphore needed by L1 | |
116 */ | |
117 #if (OP_L1_STANDALONE == 0) | |
118 #define LAYER_1_SYNC_STACK_SIZE 4000 /* matching Leonardo version */ | |
119 unsigned char layer_1_sync_stack[LAYER_1_SYNC_STACK_SIZE]; | |
120 #else | |
121 #if TESTMODE | |
122 char FAR layer_1_sync_stack[2600 /*3600*/]; // Frame interrupt task stack for EVA3 | |
123 #else | |
124 char FAR layer_1_sync_stack[1600 /* 2600 */]; // Frame interrupt task stack for EVA3 | |
125 #endif | |
126 #endif /* OP_L1_STANDALONE */ | |
127 | |
128 NU_HISR layer_1_sync_HISR; // Frame interrupt task stack for EVA3 | |
129 | |
130 | |
131 /* | |
132 * l1_create_HISR | |
133 * | |
134 * Create L1 HISR. This function is called from l1_pei. | |
135 * | |
136 * Apparently this function was originally called l1_create_ISR(), | |
137 * as that is how it appears in the Leonardo dl1_com.obj module. | |
138 * The LoCosto version originally had an l1_create_ISR() wrapper | |
139 * that simply calls l1_create_HISR(), but I plan on changing | |
140 * l1_pei to call l1_create_HISR() instead. -- Space Falcon | |
141 */ | |
142 void l1_create_HISR (void) | |
143 { | |
144 STATUS status; | |
145 | |
146 #if (OP_L1_STANDALONE == 0) | |
147 // Fill the entire stack with the pattern 0xFE | |
148 memset (layer_1_sync_stack, 0xFE, LAYER_1_SYNC_STACK_SIZE); | |
149 #endif | |
150 | |
151 status = NU_Create_HISR (&layer_1_sync_HISR, | |
152 "L1_HISR", | |
153 layer_1_sync_HISR_entry, | |
154 #if (OP_L1_STANDALONE == 0) | |
155 1, | |
156 layer_1_sync_stack, | |
157 LAYER_1_SYNC_STACK_SIZE); | |
158 #else | |
159 1, | |
160 layer_1_sync_stack, | |
161 sizeof(layer_1_sync_stack)); | |
162 #endif | |
163 | |
164 #if (L1_EXT_AUDIO_MGT) | |
165 // Create HISR for Ext MIDI activity | |
166 //================================== | |
167 status += NU_Create_HISR(&EXT_AUDIO_MGT_hisr, | |
168 "H_EXT_AUDIO_MGT", | |
169 Cust_ext_audio_mgt_hisr, | |
170 2, | |
171 ext_audio_mgt_hisr_stack, | |
172 sizeof(ext_audio_mgt_hisr_stack)); | |
173 #endif | |
174 | |
175 #if ( (L1_MP3 == 1) || (L1_MIDI == 1) || (L1_AAC == 1) || (L1_DYN_DSP_DWNLD == 1) ) // equivalent to an API_HISR flag | |
176 status += NU_Create_HISR(&apiHISR, | |
177 "API_HISR", | |
178 api_hisr, | |
179 2, | |
180 API_HISR_stack, | |
181 sizeof(API_HISR_stack)); | |
182 #endif // (L1_MP3 == 1) || (L1_MIDI == 1) || (L1_AAC == 1) || (L1_DYN_DSP_DWNLD == 1) | |
183 | |
184 #if (FF_L1_IT_DSP_USF == 1) || (FF_L1_IT_DSP_DTX == 1) // equivalent to an API_MODEM_HISR flag | |
185 // Create HISR for USF DSP interrupt !!!!. This HISR needs | |
186 // to have the highest priority since the USF status needs | |
187 // to be known before the next block starts. | |
188 //======================================================== | |
189 status += NU_Create_HISR(&api_modemHISR, | |
190 "MODEM", | |
191 api_modem_hisr, | |
192 1, | |
193 API_MODEM_HISR_stack, | |
194 sizeof(API_MODEM_HISR_stack)); | |
195 #endif | |
196 | |
197 assert (status == 0); | |
198 } | |
199 | |
200 /* | |
201 * The versions of TP_FrameIntHandler() and layer_1_sync_HISR_entry() | |
202 * in the Leonardo dl1_com.obj module contain CPU load measurement | |
203 * code, but in the LoCosto version of L1 which we are using this | |
204 * functionality has been moved into L1S proper, i.e., inside the | |
205 * hisr() function. | |
206 */ | |
207 | |
208 /*-------------------------------------------------------*/ | |
209 /* TP_FrameIntHandler() Low Interrupt service routine */ | |
210 /*-------------------------------------------------------*/ | |
211 /* Parameters : */ | |
212 /* Return : */ | |
213 /* Functionality : activate Hisr on each frame interrupt*/ | |
214 /*-------------------------------------------------------*/ | |
215 void TP_FrameIntHandler(void) | |
216 { | |
217 | |
218 #if (OP_L1_STANDALONE == 1) | |
219 | |
220 #if (TRACE_TYPE==1) | |
221 if (trace_info.current_config->l1_dyn_trace & 1<<L1_DYN_TRACE_L1S_CPU_LOAD) | |
222 { | |
223 TM_ResetTimer (2, 0xFFFF, 1, 0); | |
224 TM_StartTimer (2); | |
225 } | |
226 #endif | |
227 | |
228 #if (TRACE_TYPE==6) | |
229 TM_ResetTimer (2, 0xFFFF, 1, 0); | |
230 TM_StartTimer (2); | |
231 #endif | |
232 | |
233 #if (TRACE_TYPE==7) /* CPU_LOAD */ | |
234 l1_cpu_load_start(); | |
235 #endif | |
236 | |
237 #else | |
238 | |
239 #if (TRACE_TYPE == 4) && (TI_NUC_MONITOR != 1) && (WCP_PROF == 1) | |
240 TM_ResetTimer (2, TIMER_RESET_VALUE, 1, 0); | |
241 TM_StartTimer (2); | |
242 #endif | |
243 | |
244 #if (TI_NUC_MONITOR == 1) | |
245 /* Copy LISR buffer in Log buffer each end of HISR */ | |
246 ti_nuc_monitor_tdma_action(); | |
247 #endif | |
248 | |
249 #if WCP_PROF == 1 | |
250 prf_LogFNSwitch(l1s.actual_time.fn_mod42432); | |
251 #endif | |
252 | |
253 #endif /* OP_L1_STANDALONE */ | |
254 | |
255 NU_Activate_HISR(&layer_1_sync_HISR); /* Activate HISR interrupt */ | |
256 | |
257 #if (OP_L1_STANDALONE == 0) | |
258 #if (WCP_PROF == 1) | |
259 #if (PRF_CALIBRATION == 1) | |
260 NU_Activate_HISR(&prf_CalibrationHISR); | |
261 #endif | |
262 #endif | |
263 #endif | |
264 | |
265 } | |
266 | |
267 /* | |
268 * layer_1_sync_HISR_entry | |
269 * | |
270 * HISR associated to layer 1 sync. | |
271 */ | |
272 | |
273 void layer_1_sync_HISR_entry (void) | |
274 { | |
275 // Call Synchronous Layer1 | |
276 hisr(); | |
277 } |