FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/L1/dyn_dwl_cfile/l1_dyn_dwl_init.c @ 925:c56ba3363aa3
gsm-fw: l1_dyn_dwl code imported from tcs211-l1-reconst
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Thu, 22 Oct 2015 18:19:42 +0000 |
parents | |
children | 48969469d961 |
comparison
equal
deleted
inserted
replaced
924:aac4d4b15d2f | 925:c56ba3363aa3 |
---|---|
1 /************* Revision Controle System Header ************* | |
2 * GSM Layer 1 software | |
3 * L1_DYN_DWL_INIT.C | |
4 * | |
5 * Filename l1_dyn_dwl_init.c | |
6 * Copyright 2004 (C) Texas Instruments | |
7 * | |
8 ************* Revision Controle System Header *************/ | |
9 #include "nucleus.h" | |
10 #include "l1_confg.h" | |
11 #include "sys_types.h" | |
12 #include "l1_types.h" | |
13 #include "l1audio_const.h" | |
14 #include "l1audio_cust.h" | |
15 #include "l1audio_defty.h" | |
16 #include "l1_const.h" | |
17 #include "l1tm_defty.h" | |
18 | |
19 #if (L1_GTT == 1) | |
20 #include "l1gtt_const.h" | |
21 #include "l1gtt_defty.h" | |
22 #endif | |
23 #if (L1_DYN_DSP_DWNLD == 1) | |
24 #include "l1_dyn_dwl_const.h" | |
25 #include "l1_dyn_dwl_defty.h" | |
26 #include "l1_dyn_dwl_proto.h" | |
27 #endif | |
28 | |
29 #if (L1_MP3 == 1) | |
30 #include "l1mp3_defty.h" | |
31 #endif //L1_MP3 | |
32 #if (L1_MIDI == 1) | |
33 #include "l1midi_defty.h" | |
34 #endif | |
35 #if (L1_AAC == 1) | |
36 #include "l1aac_defty.h" | |
37 #endif //L1_AAC | |
38 | |
39 #include "l1_defty.h" | |
40 #include "cust_os.h" | |
41 /* #include "nu_main.h" */ | |
42 #include "l1audio_signa.h" | |
43 #include "l1_varex.h" | |
44 #include "l1_macro.h" | |
45 #include "l1_trace.h" | |
46 | |
47 #if (L1_DYN_DSP_DWNLD == 1) | |
48 extern T_DYN_DWNLD_MCU_DSP *dyn_dwl_ndb; | |
49 | |
50 /* reconstructing from disassembly of TCS211 binary object */ | |
51 | |
52 /* patch ID mapping: | |
53 0 = GPRS | |
54 1 = AMR_SCH | |
55 2 = TTY | |
56 3 = AMR_MMS | |
57 4 = E2 | |
58 */ | |
59 | |
60 const BOOL primitives_to_patch_matrix[NUM_OF_DYN_DWNLD_PRIMITIVES][MAX_NUM_OF_PATCH_IDS] = { | |
61 | |
62 /* L1C_STOP_DEDICATED_DONE */ {1, 0, 0, 0, 0}, | |
63 /* MMI_GTT_START_REQ (?) */ {0, 0, 1, 0, 0}, | |
64 /* MPHC_IMMED_ASSIGN_REQ */ {0, 1, 0, 0, 0}, | |
65 /* MMI_MELODY0_E2_START_REQ */ {0, 0, 0, 0, 1}, | |
66 /* MMI_MELODY1_E2_START_REQ */ {0, 0, 0, 0, 1}, | |
67 /* L1_BACK_MELODY_E2_UNLOAD_INSTRUMENT_CON */ {0, 0, 0, 1, 0} | |
68 | |
69 }; | |
70 | |
71 const BOOL incompatibility_matrix[MAX_NUM_OF_PATCH_IDS][MAX_NUM_OF_PATCH_IDS] ={ | |
72 {0, 1, 1, 0, 0}, | |
73 {1, 0, 0, 0, 0}, | |
74 {0, 0, 0, 1, 1}, | |
75 {0, 0, 1, 0, 1}, | |
76 {0, 0, 1, 1, 0}, | |
77 }; | |
78 | |
79 const BOOL semaphore_matrix[MAX_NUM_OF_PATCH_IDS][MAX_NUM_OF_SEMAPHORES] = { | |
80 {0, 0, 0, 0, 0, 1}, | |
81 {1, 0, 0, 0, 0, 1}, | |
82 {0, 1, 0, 0, 0, 1}, | |
83 {0, 0, 0, 1, 1, 1}, | |
84 {0, 0, 1, 0, 0, 1}, | |
85 }; | |
86 | |
87 UWORD32 dyn_dwnld_address_vect[MAX_NUM_OF_PATCH_IDS]; | |
88 UWORD16 dyn_dwnld_crc_vect[MAX_NUM_OF_PATCH_IDS]; | |
89 UWORD16 size_vect[MAX_NUM_OF_PATCH_IDS]; | |
90 | |
91 UWORD8 const *dyn_dwnld_copy_MCU_vect[MAX_NUM_OF_PATCH_IDS]; | |
92 | |
93 extern const UWORD8 amr_mms_patch_array[]; | |
94 extern const UWORD8 amr_sch_patch_array[]; | |
95 extern const UWORD8 e2_patch_array[]; | |
96 extern const UWORD8 gprs_patch_array[]; | |
97 extern const UWORD8 speech_acoustic_patch_array[]; | |
98 extern const UWORD8 tty_patch_array[]; | |
99 | |
100 /*-------------------------------------------------------*/ | |
101 /* l1_dyn_dwnld_initialize_var() */ | |
102 /*-------------------------------------------------------*/ | |
103 /* Parameters : none */ | |
104 /* Return : nothing */ | |
105 /* Functionality : Initialize Dynamic Download variables */ | |
106 /* */ | |
107 /*-------------------------------------------------------*/ | |
108 | |
109 void l1_dyn_dwnld_initialize_var() | |
110 { | |
111 UWORD16 i; | |
112 | |
113 | |
114 /* Init Dynamic Download NDB */ | |
115 dyn_dwl_ndb=(T_DYN_DWNLD_MCU_DSP *)API_address_dsp2mcu(C_DYN_DWNLD_API_BASE_ADDRESS); | |
116 #if (CODE_VERSION == SIMULATION) | |
117 { | |
118 extern T_DYN_DWNLD_MCU_DSP dyn_dwl_ndb_sim; | |
119 dyn_dwl_ndb=&dyn_dwl_ndb_sim; | |
120 } | |
121 #endif // CODE_VERSION == SIMULATION | |
122 | |
123 /* Init Dynamic Download DSP background */ | |
124 l1s_dsp_com.dsp_ndb_ptr->a_background_tasks[C_BGD_DSP_DYN_DWNLD] = (API)((C_BGD_DSP_DYN_DWNLD<<11) | 0); | |
125 l1s_dsp_com.dsp_ndb_ptr->d_background_enable&=(API)(~(1<<C_BGD_DSP_DYN_DWNLD)); | |
126 | |
127 if(l1s_dsp_com.dsp_ndb_ptr->d_max_background<(C_BGD_DSP_DYN_DWNLD+1)) | |
128 l1s_dsp_com.dsp_ndb_ptr->d_max_background=(API)(C_BGD_DSP_DYN_DWNLD+1); | |
129 | |
130 dyn_dwnld_copy_MCU_vect[0] = gprs_patch_array; | |
131 dyn_dwnld_copy_MCU_vect[1] = amr_sch_patch_array; | |
132 #if (L1_GTT == 1) | |
133 dyn_dwnld_copy_MCU_vect[2] = tty_patch_array; | |
134 #endif | |
135 #if (MELODY_E2 == 1) | |
136 dyn_dwnld_copy_MCU_vect[3] = amr_mms_patch_array; | |
137 dyn_dwnld_copy_MCU_vect[4] = e2_patch_array; | |
138 #endif | |
139 | |
140 for(i=0;i<MAX_NUM_OF_PATCH_IDS;i++) | |
141 { | |
142 if (dyn_dwnld_copy_MCU_vect[i] != 0) | |
143 { | |
144 l1_set_dyn_dwnld_install_vect(size_vect,dyn_dwnld_address_vect,dyn_dwnld_crc_vect,dyn_dwnld_copy_MCU_vect[i],i); | |
145 } | |
146 } | |
147 | |
148 /*---------- Set L1A globals at phone init ----------------------------*/ | |
149 l1a.dyn_dwnld.melody0_E2_flag_activated = FALSE; | |
150 l1a.dyn_dwnld.melody1_E2_flag_activated = FALSE; | |
151 l1a.dyn_dwnld.state = 0; | |
152 | |
153 | |
154 l1a.dyn_dwnld.num_patches_installed = 0; | |
155 | |
156 l1a.dyn_dwnld.patch_id[0] = 0xFFFF; //omaps00090550 | |
157 | |
158 /**************************************************/ | |
159 | |
160 // Compute number of current primitives defined via compilation switch | |
161 l1a.dyn_dwnld.num_of_primitives = 2; | |
162 #if (L1_GTT == 1) | |
163 l1a.dyn_dwnld.num_of_primitives++; | |
164 #endif // L1_GTT | |
165 #if (MELODY_E2 == 1) | |
166 // Two primitives for MELODY E2 | |
167 // FreeCalypso: apparently there are 3 in TCS211 | |
168 l1a.dyn_dwnld.num_of_primitives += 3; | |
169 #endif // MELODY_E2 | |
170 | |
171 for (i=l1a.dyn_dwnld.num_patches_installed;i<MAX_NUM_OF_PATCH_IDS;i++) | |
172 { | |
173 l1a.dyn_dwnld.patch_id[i] = 0xFFFF; //omaps00090550 ; | |
174 l1a.dyn_dwnld.next_patch_id[i] = 0xFFFF; //omaps00090550 ; | |
175 } | |
176 for (i=0;i<MAX_NUM_OF_SEMAPHORES;i++) | |
177 l1a.dyn_dwnld.semaphore_vect[i] = GREEN; | |
178 | |
179 | |
180 l1a.dyn_dwnld.waiting_patch_fifo.num_of_elem = 0; | |
181 for (i=0;i<MAX_NUM_OF_PATCH_IDS;i++) | |
182 l1a.dyn_dwnld.waiting_patch_fifo.signal_code_vect[i] = 0; | |
183 | |
184 /*---------------------------------------------------------------------*/ | |
185 | |
186 /*---------- Set L1S globals at phone init ----------------------------*/ | |
187 | |
188 l1s.dyn_dwnld_state=0; | |
189 | |
190 /*---------------------------------------------------------------------*/ | |
191 | |
192 | |
193 /* Set API ACCESS bit to 16 bits mode */ | |
194 /* Bit 5: 0 -> 32 bits mode */ | |
195 /* 1 -> 16 bits mode */ | |
196 | |
197 #if (CODE_VERSION != SIMULATION) | |
198 (*(volatile UWORD16 *) 0xFFFFFB0E) |= 0x0020; | |
199 #endif // CODE_VERSION != SIMULATION | |
200 } | |
201 | |
202 /*-------------------------------------------------------*/ | |
203 /* l1_dyn_dwl_reset() */ | |
204 /* */ | |
205 /*-------------------------------------------------------*/ | |
206 /* Parameters : none */ | |
207 /* Return : nothing */ | |
208 /* Functionality : Reset Dynamic Download variables */ | |
209 /* */ | |
210 /*-------------------------------------------------------*/ | |
211 | |
212 void l1_dyn_dwnld_reset() | |
213 { | |
214 UWORD8 indx_loop; | |
215 | |
216 /* Reset L1A-L1S commands */ | |
217 l1a_l1s_com.dyn_dwnld_task.start = FALSE; | |
218 l1a_l1s_com.dyn_dwnld_task.stop = FALSE; | |
219 | |
220 /* Reset L1A-API HISR commands */ | |
221 | |
222 l1a_apihisr_com.dyn_dwnld.command.restart = FALSE; | |
223 l1a_apihisr_com.dyn_dwnld.uninstall_parameters.num_of_elem = 0; | |
224 | |
225 for (indx_loop = 0 ; indx_loop < MAX_NUM_OF_PATCH_IDS ; indx_loop++ ) | |
226 { | |
227 l1a_apihisr_com.dyn_dwnld.uninstall_parameters.address[indx_loop] | |
228 = 0; | |
229 l1a_apihisr_com.dyn_dwnld.copy_parameters.start_MCU_copy_address[indx_loop] | |
230 = 0; | |
231 l1a_apihisr_com.dyn_dwnld.copy_parameters.address_to_install[indx_loop] | |
232 = 0; | |
233 l1a_apihisr_com.dyn_dwnld.copy_parameters.size_array[indx_loop] | |
234 = 0; | |
235 } | |
236 | |
237 l1a_apihisr_com.dyn_dwnld.copy_parameters.size_of_dwnld_area = 0; | |
238 l1a_apihisr_com.dyn_dwnld.copy_parameters.start_of_dwnld_area = 0; | |
239 l1a_apihisr_com.dyn_dwnld.copy_parameters.num_of_elem = 0; | |
240 | |
241 /* Reset global API HISR variable */ | |
242 l1_apihisr.dyn_dwnld.state = 0; | |
243 l1_apihisr.dyn_dwnld.running = FALSE; | |
244 l1_apihisr.dyn_dwnld.uninstall_counter = 0; | |
245 l1_apihisr.dyn_dwnld.patch_ids_counter = 0; | |
246 l1_apihisr.dyn_dwnld.running_source_pointer = 0; | |
247 l1_apihisr.dyn_dwnld.tmp_patch_size = 0; | |
248 | |
249 /* Reset L1A global FIFO for handling the DELAY (when two or more primitives fall within a dynamic download time frame)*/ | |
250 l1a.dyn_dwnld.waiting_patch_fifo.num_of_elem = 0; | |
251 for (indx_loop=0;indx_loop<MAX_NUM_OF_PATCH_IDS;indx_loop++) | |
252 { | |
253 l1a.dyn_dwnld.waiting_patch_fifo.signal_code_vect[indx_loop] = 0; | |
254 l1a.dyn_dwnld.next_patch_id[indx_loop] = 0xFFFF; //omaps00090550 ; | |
255 } | |
256 } | |
257 | |
258 /*---------------------------------------------------------------------*/ | |
259 /* l1_dyn_dwnld_reset_api() */ | |
260 /*---------------------------------------------------------------------*/ | |
261 /* Parameters : none */ | |
262 /* Return : nothing */ | |
263 /* Functionality : Reset Dynamic Download API variables */ | |
264 /* */ | |
265 /*---------------------------------------------------------------------*/ | |
266 void l1_dyn_dwnld_reset_api() | |
267 { | |
268 dyn_dwl_ndb->d_api_dwl_download_ctrl = (API) 0; | |
269 dyn_dwl_ndb->d_api_dwl_error_code = (API) 0; | |
270 dyn_dwl_ndb->d_api_dwl_function_address[0] = (API) 0; | |
271 dyn_dwl_ndb->d_api_dwl_function_address[1] = (API) 0; | |
272 dyn_dwl_ndb->d_api_dwl_crc = (API) 0; | |
273 dyn_dwl_ndb->d_api_dwl_size = (API) 0; | |
274 dyn_dwl_ndb->d_api_dwl_write_pointer = (API) 0; | |
275 } | |
276 | |
277 #endif // L1_DYN_DSP_DWNLD |