FreeCalypso > hg > freecalypso-citrine
comparison L1/cfile/l1_mfmgr.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 | b36540edb046 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:75a11d740a02 |
---|---|
1 | |
2 /************* Revision Controle System Header ************* | |
3 * GSM Layer 1 software | |
4 * L1_MFMGR.C | |
5 * | |
6 * Filename l1_mfmgr.c | |
7 * Copyright 2003 (C) Texas Instruments | |
8 * | |
9 ************* Revision Controle System Header *************/ | |
10 | |
11 #define L1_MFMGR_C | |
12 | |
13 #include "config.h" | |
14 #include "l1_confg.h" | |
15 #include "l1_macro.h" | |
16 | |
17 #if (CODE_VERSION == SIMULATION) | |
18 #include <string.h> | |
19 #include "l1_types.h" | |
20 #include "sys_types.h" | |
21 #include "l1_const.h" | |
22 #if TESTMODE | |
23 #include "l1tm_defty.h" | |
24 #endif | |
25 #if (AUDIO_TASK == 1) | |
26 #include "l1audio_const.h" | |
27 #include "l1audio_cust.h" | |
28 #include "l1audio_defty.h" | |
29 #endif | |
30 #if (L1_GTT == 1) | |
31 #include "l1gtt_const.h" | |
32 #include "l1gtt_defty.h" | |
33 #endif | |
34 #if (L1_MP3 == 1) | |
35 #include "l1mp3_defty.h" | |
36 #endif | |
37 #if (L1_MIDI == 1) | |
38 #include "l1midi_defty.h" | |
39 #endif | |
40 #if (L1_AAC == 1) | |
41 #include "l1aac_defty.h" | |
42 #endif | |
43 #include "l1_defty.h" | |
44 #include "cust_os.h" | |
45 #include "l1_msgty.h" | |
46 #include "l1_varex.h" | |
47 #include "l1_proto.h" | |
48 #else | |
49 #include <string.h> | |
50 #include "l1_types.h" | |
51 #include "sys_types.h" | |
52 #include "l1_const.h" | |
53 | |
54 #if TESTMODE | |
55 #include "l1tm_defty.h" | |
56 #endif | |
57 #if (AUDIO_TASK == 1) | |
58 #include "l1audio_const.h" | |
59 #include "l1audio_cust.h" | |
60 #include "l1audio_defty.h" | |
61 #endif | |
62 #if (L1_GTT == 1) | |
63 #include "l1gtt_const.h" | |
64 #include "l1gtt_defty.h" | |
65 #endif | |
66 #if (L1_MP3 == 1) | |
67 #include "l1mp3_defty.h" | |
68 #endif | |
69 #if (L1_MIDI == 1) | |
70 #include "l1midi_defty.h" | |
71 #endif | |
72 #if (L1_AAC == 1) | |
73 #include "l1aac_defty.h" | |
74 #endif | |
75 #include "l1_defty.h" | |
76 #include "../../gpf/inc/cust_os.h" | |
77 #include "l1_msgty.h" | |
78 #include "l1_varex.h" | |
79 #include "l1_proto.h" | |
80 #endif | |
81 #include "l1_tabs.h" | |
82 | |
83 /*-------------------------------------------------------*/ | |
84 /* l1s_clear_mftab() */ | |
85 /*-------------------------------------------------------*/ | |
86 /* Parameters : */ | |
87 /* Return : */ | |
88 /* Functionality : */ | |
89 /*-------------------------------------------------------*/ | |
90 void l1s_clear_mftab(T_FRM *frmlst) | |
91 { | |
92 WORD32 j,k; | |
93 | |
94 #if (TRACE_TYPE==5) | |
95 trace_mft("l1s_clear_mftab()", -1); | |
96 #endif | |
97 | |
98 // Clear MFTAB. | |
99 for (j=0; j<MFTAB_SIZE; j++) | |
100 { | |
101 for (k=0; k<L1_MAX_FCT; k++) | |
102 { | |
103 frmlst[j].fct[k].fct_ptr = NULL; // Enough to clear the MFTAB. | |
104 } | |
105 } | |
106 } | |
107 | |
108 /*-------------------------------------------------------*/ | |
109 /* l1s_load_mftab() */ | |
110 /*-------------------------------------------------------*/ | |
111 /* Parameters : */ | |
112 /* Return : */ | |
113 /* Functionality : */ | |
114 /*-------------------------------------------------------*/ | |
115 void l1s_load_mftab(const T_FCT *fct, const UWORD8 size, UWORD8 frame, T_FRM *frmlst) | |
116 { | |
117 UWORD8 i; | |
118 UWORD8 frame_count; | |
119 T_FRM *current_frm; | |
120 | |
121 #if (TRACE_TYPE==5) | |
122 trace_mft("l1s_load_mftab()", frame); | |
123 #endif | |
124 | |
125 if(fct != NULL) | |
126 // there is a Rom block available. | |
127 { | |
128 frame_count = 0; | |
129 | |
130 do | |
131 { | |
132 i=0; | |
133 current_frm = &(frmlst[frame]); | |
134 | |
135 while (fct->fct_ptr != NULL) | |
136 { | |
137 // ROM block is downloaded to RAM, it is added to current block contents in MFTAB. | |
138 // we have to look for a free place in the OPTIONAL struct. for current frame. | |
139 while (current_frm->fct[i].fct_ptr != NULL) i++; | |
140 | |
141 current_frm->fct[i] = *fct++; | |
142 i++; | |
143 } | |
144 | |
145 // increment "fct" to skip the NULL function... | |
146 fct++; | |
147 | |
148 // increment frame counter... | |
149 frame_count++; | |
150 | |
151 // increment frame counter with round up... | |
152 if(++frame >= MFTAB_SIZE) frame = 0; | |
153 } | |
154 while (frame_count < size); | |
155 // end of permanent table when all frame read from ROM block. | |
156 } | |
157 } | |
158 | |
159 /*-------------------------------------------------------*/ | |
160 /* l1s_exec_mftab() */ | |
161 /*-------------------------------------------------------*/ | |
162 /* Parameters : */ | |
163 /* Return : */ | |
164 /* Functionality : */ | |
165 /*-------------------------------------------------------*/ | |
166 void l1s_exec_mftab() | |
167 { | |
168 UWORD8 i=0; | |
169 T_FCT *current_fct; | |
170 | |
171 // Point to the first function for current frame. | |
172 current_fct = &(l1s.mftab.frmlst[l1s.afrm].fct[0]); | |
173 | |
174 do | |
175 /********************************************/ | |
176 /*** look at all fcts until L1_MAX_FCT ***/ | |
177 /********************************************/ | |
178 { | |
179 if (current_fct->fct_ptr != NULL) | |
180 /****************************************************/ | |
181 /* Check function is not NULL */ | |
182 /* -> execute functions and reset fct field */ | |
183 /****************************************************/ | |
184 { | |
185 UWORD8 param1 = current_fct->param1; | |
186 UWORD8 param2 = current_fct->param2; | |
187 | |
188 (*current_fct->fct_ptr)(param1,param2); // execute fction. | |
189 current_fct->fct_ptr = NULL; // clear executed fction. | |
190 current_fct->param1 = NO_PAR; // clear complexe function parameter. | |
191 current_fct->param2 = NO_PAR; // clear complexe function parameter. | |
192 } | |
193 | |
194 // Increment "i" and function pointer. | |
195 current_fct++; // point to next fction. | |
196 i++; // increment fction counter. | |
197 | |
198 } // end do. | |
199 while (i < L1_MAX_FCT); | |
200 } | |
201 | |
202 #if (FF_L1_FAST_DECODING == 1 ) | |
203 /*------------------------------------------------------- | |
204 l1s_clean_mftab() | |
205 ------------------------------------------------------- | |
206 Parameters :-current task in MFTAB | |
207 -current_tsk_frm : frame of current task | |
208 from which functions should be erase | |
209 Return : | |
210 Functionality : Clean a task being execute | |
211 first step of function is to look for the frame | |
212 from which we want to erase functions of the task. | |
213 Second step is to identify function to clean up : we | |
214 want clean up only functions of current task starting | |
215 from current_tsk_frm.Hence, a test is done to identify | |
216 function from TASK_ROM_MFTAB inside MFTAB by checking | |
217 fct pointer amd the two parameters param1 and param2. | |
218 If test is true (i.e parameters and function pointer | |
219 are used for the current task executuion ) , a clean | |
220 is done by setfct pointer to NULL | |
221 in order to erase this function of MFTAB .The clean up | |
222 is applied until the last frame used by current task | |
223 (number of frames used by a task is defined by size | |
224 variable). | |
225 When clean up is done , reset active frame if current | |
226 frame is the last frame of MFTAB. | |
227 This function allow to pipeline fast signaling blocks | |
228 with non fast signaling blocks without lose blocks. | |
229 -------------------------------------------------------*/ | |
230 void l1s_clean_mftab(UWORD8 task, UWORD8 current_tsk_frm) | |
231 { | |
232 T_FRM *p_current_frm; | |
233 const T_FCT *fct; | |
234 UWORD8 size; | |
235 UWORD8 frame; | |
236 UWORD8 i = 1;/*i refers to l1_mftab.h where we have frame 1,frame2,frame3... so i starts to 1*/ | |
237 UWORD8 j; | |
238 UWORD8 k; | |
239 | |
240 #if (TRACE_TYPE==5) | |
241 trace_mft("l1s_clean_mftab()", -1); | |
242 #endif | |
243 | |
244 fct = TASK_ROM_MFTAB[task].address; | |
245 size = TASK_ROM_MFTAB[task].size; | |
246 frame = l1s.afrm; | |
247 | |
248 /* Get the good frame in function block */ | |
249 while(i < current_tsk_frm) | |
250 { | |
251 while(fct->fct_ptr != NULL) | |
252 { | |
253 fct++;/* Skip non-nulll functions */ | |
254 } | |
255 fct++;/*Skip null function */ | |
256 i++; | |
257 } | |
258 | |
259 /* Search in MFTAB all functions relative to the block we want to erase*/ | |
260 while(i <= size) | |
261 { | |
262 p_current_frm = &(l1s.mftab.frmlst[frame]); | |
263 | |
264 while(fct->fct_ptr != NULL) | |
265 { | |
266 for(j = 0; j < L1_MAX_FCT; j++) | |
267 { | |
268 if(((p_current_frm->fct[j].param1 == task) && (p_current_frm->fct[j].param2 == fct->param2)) | |
269 && ( p_current_frm->fct[j].fct_ptr == fct->fct_ptr)) | |
270 { | |
271 p_current_frm->fct[j].fct_ptr = NULL; | |
272 | |
273 /*l1s_load_mftab function inserts a block just by looking if the function pointer is null : to avoid this issue, a remove dowwn */ | |
274 /*of all functions pointers of the frme is done so there is no hole and hence no possible block insertion*/ | |
275 if(frame != l1s.afrm) /* condition for shifting*/ | |
276 { | |
277 for( k = j; k < L1_MAX_FCT - 1; k ++) | |
278 { | |
279 p_current_frm->fct[k] = p_current_frm->fct[k + 1];/* alls pointers are going up of one position in the frame*/ | |
280 } | |
281 p_current_frm->fct[L1_MAX_FCT-1].fct_ptr = NULL; /*last pointer is setting to NULL to avoid to remove the last function fct[L1_MAX_FCT] */ | |
282 } | |
283 j = L1_MAX_FCT;/* Function found, exit to save time */ | |
284 } | |
285 } | |
286 fct++; | |
287 } | |
288 fct++; | |
289 i++; | |
290 if(++ frame >= MFTAB_SIZE) | |
291 { | |
292 frame = 0; | |
293 } | |
294 } | |
295 } | |
296 #endif /* if (FF_L1_FAST_DECODING == 1) */ | |
297 | |
298 | |
299 |