comparison chipsetsw/layer1/dl1/dl1_com.c @ 164:10fc1fb079d7

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