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