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