comparison src/cs/layer1/dyn_dwl_cfile/l1_dyn_dwl_init.c @ 0:b6a5e36de839

src/cs: initial import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 15 Jul 2018 04:39:26 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:b6a5e36de839
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 /* Init Dynamic Download NDB */
114 dyn_dwl_ndb=(T_DYN_DWNLD_MCU_DSP *)API_address_dsp2mcu(C_DYN_DWNLD_API_BASE_ADDRESS);
115 #if (CODE_VERSION == SIMULATION)
116 {
117 extern T_DYN_DWNLD_MCU_DSP dyn_dwl_ndb_sim;
118 dyn_dwl_ndb=&dyn_dwl_ndb_sim;
119 }
120 #endif // CODE_VERSION == SIMULATION
121
122 /* Init Dynamic Download DSP background */
123 l1s_dsp_com.dsp_ndb_ptr->a_background_tasks[C_BGD_DSP_DYN_DWNLD] = (API)((C_BGD_DSP_DYN_DWNLD<<11) | 0);
124 l1s_dsp_com.dsp_ndb_ptr->d_background_enable&=(API)(~(1<<C_BGD_DSP_DYN_DWNLD));
125
126 if(l1s_dsp_com.dsp_ndb_ptr->d_max_background<(C_BGD_DSP_DYN_DWNLD+1))
127 l1s_dsp_com.dsp_ndb_ptr->d_max_background=(API)(C_BGD_DSP_DYN_DWNLD+1);
128
129 dyn_dwnld_copy_MCU_vect[0] = gprs_patch_array;
130 l1_set_dyn_dwnld_install_vect(size_vect,dyn_dwnld_address_vect,dyn_dwnld_crc_vect, gprs_patch_array, 0);
131
132 dyn_dwnld_copy_MCU_vect[1] = amr_sch_patch_array;
133 l1_set_dyn_dwnld_install_vect(size_vect,dyn_dwnld_address_vect,dyn_dwnld_crc_vect, amr_sch_patch_array, 1);
134
135 #if (L1_GTT == 1)
136 dyn_dwnld_copy_MCU_vect[2] = tty_patch_array;
137 l1_set_dyn_dwnld_install_vect(size_vect,dyn_dwnld_address_vect,dyn_dwnld_crc_vect, tty_patch_array, 2);
138 #endif
139
140 #if (MELODY_E2 == 1)
141 dyn_dwnld_copy_MCU_vect[3] = amr_mms_patch_array;
142 l1_set_dyn_dwnld_install_vect(size_vect,dyn_dwnld_address_vect,dyn_dwnld_crc_vect, amr_mms_patch_array, 3);
143 dyn_dwnld_copy_MCU_vect[4] = e2_patch_array;
144 l1_set_dyn_dwnld_install_vect(size_vect,dyn_dwnld_address_vect,dyn_dwnld_crc_vect, e2_patch_array, 4);
145 #endif
146
147 /*---------- Set L1A globals at phone init ----------------------------*/
148 l1a.dyn_dwnld.melody0_E2_flag_activated = FALSE;
149 l1a.dyn_dwnld.melody1_E2_flag_activated = FALSE;
150 l1a.dyn_dwnld.dedicated_stop_flag = FALSE;
151
152 l1a.dyn_dwnld.num_patches_installed = 2;
153 l1a.dyn_dwnld.state = 0;
154 l1a.dyn_dwnld.dsp_trace_level_copy = 0;
155
156 l1a.dyn_dwnld.patch_id[0] = GPRS_PATCH;
157 l1a.dyn_dwnld.patch_id[1] = AMR_MMS_PATCH;
158
159 for (i=l1a.dyn_dwnld.num_patches_installed;i<MAX_NUM_OF_PATCH_IDS;i++)
160 {
161 l1a.dyn_dwnld.patch_id[i] = 0xFFFF; //omaps00090550 ;
162 l1a.dyn_dwnld.next_patch_id[i] = 0xFFFF; //omaps00090550 ;
163 }
164 for (i=0;i<MAX_NUM_OF_SEMAPHORES;i++)
165 l1a.dyn_dwnld.semaphore_vect[i] = GREEN;
166
167 l1a.dyn_dwnld.trace_flag_blocked = FALSE;
168
169 l1a.dyn_dwnld.waiting_patch_fifo.num_of_elem = 0;
170 for (i=0;i<MAX_NUM_OF_PATCH_IDS;i++)
171 l1a.dyn_dwnld.waiting_patch_fifo.signal_code_vect[i] = 0;
172
173 /**************************************************/
174
175 // Compute number of current primitives defined via compilation switch
176 l1a.dyn_dwnld.num_of_primitives = 2;
177 #if (L1_GTT == 1)
178 l1a.dyn_dwnld.num_of_primitives++;
179 #endif // L1_GTT
180 #if (MELODY_E2 == 1)
181 // Two primitives for MELODY E2
182 // FreeCalypso: apparently there are 3 in TCS211
183 l1a.dyn_dwnld.num_of_primitives += 3;
184 #endif // MELODY_E2
185
186
187 /*---------------------------------------------------------------------*/
188
189 /*---------- Set L1S globals at phone init ----------------------------*/
190
191 l1s.dyn_dwnld_state=0;
192
193 /*---------------------------------------------------------------------*/
194
195
196 /* Set API ACCESS bit to 16 bits mode */
197 /* Bit 5: 0 -> 32 bits mode */
198 /* 1 -> 16 bits mode */
199
200 #if (CODE_VERSION != SIMULATION)
201 (*(volatile UWORD16 *) 0xFFFFFB0E) |= 0x0020;
202 #endif // CODE_VERSION != SIMULATION
203 }
204
205 /*-------------------------------------------------------*/
206 /* l1_dyn_dwl_reset() */
207 /* */
208 /*-------------------------------------------------------*/
209 /* Parameters : none */
210 /* Return : nothing */
211 /* Functionality : Reset Dynamic Download variables */
212 /* */
213 /*-------------------------------------------------------*/
214
215 void l1_dyn_dwnld_reset()
216 {
217 UWORD8 indx_loop;
218
219 /* Reset L1A-L1S commands */
220 l1a_l1s_com.dyn_dwnld_task.start = FALSE;
221 l1a_l1s_com.dyn_dwnld_task.stop = FALSE;
222
223 /* Reset L1A-API HISR commands */
224
225 l1a_apihisr_com.dyn_dwnld.command.restart = FALSE;
226 l1a_apihisr_com.dyn_dwnld.uninstall_parameters.num_of_elem = 0;
227
228 for (indx_loop = 0 ; indx_loop < MAX_NUM_OF_PATCH_IDS ; indx_loop++ )
229 {
230 l1a_apihisr_com.dyn_dwnld.uninstall_parameters.address[indx_loop]
231 = 0;
232 l1a_apihisr_com.dyn_dwnld.copy_parameters.start_MCU_copy_address[indx_loop]
233 = 0;
234 l1a_apihisr_com.dyn_dwnld.copy_parameters.address_to_install[indx_loop]
235 = 0;
236 l1a_apihisr_com.dyn_dwnld.copy_parameters.size_array[indx_loop]
237 = 0;
238 }
239
240 l1a_apihisr_com.dyn_dwnld.copy_parameters.size_of_dwnld_area = 0;
241 l1a_apihisr_com.dyn_dwnld.copy_parameters.start_of_dwnld_area = 0;
242 l1a_apihisr_com.dyn_dwnld.copy_parameters.num_of_elem = 0;
243
244 /* Reset global API HISR variable */
245 l1_apihisr.dyn_dwnld.state = 0;
246 l1_apihisr.dyn_dwnld.running = FALSE;
247 l1_apihisr.dyn_dwnld.uninstall_counter = 0;
248 l1_apihisr.dyn_dwnld.patch_ids_counter = 0;
249 l1_apihisr.dyn_dwnld.running_source_pointer = 0;
250 l1_apihisr.dyn_dwnld.tmp_patch_size = 0;
251
252 /* Reset L1A global FIFO for handling the DELAY (when two or more primitives fall within a dynamic download time frame)*/
253 l1a.dyn_dwnld.waiting_patch_fifo.num_of_elem = 0;
254 for (indx_loop=0;indx_loop<MAX_NUM_OF_PATCH_IDS;indx_loop++)
255 {
256 l1a.dyn_dwnld.waiting_patch_fifo.signal_code_vect[indx_loop] = 0;
257 l1a.dyn_dwnld.next_patch_id[indx_loop] = 0xFFFF; //omaps00090550 ;
258 }
259 }
260
261 /*---------------------------------------------------------------------*/
262 /* l1_dyn_dwnld_reset_api() */
263 /*---------------------------------------------------------------------*/
264 /* Parameters : none */
265 /* Return : nothing */
266 /* Functionality : Reset Dynamic Download API variables */
267 /* */
268 /*---------------------------------------------------------------------*/
269 void l1_dyn_dwnld_reset_api()
270 {
271 dyn_dwl_ndb->d_api_dwl_download_ctrl = (API) 0;
272 dyn_dwl_ndb->d_api_dwl_error_code = (API) 0;
273 dyn_dwl_ndb->d_api_dwl_function_address[0] = (API) 0;
274 dyn_dwl_ndb->d_api_dwl_function_address[1] = (API) 0;
275 dyn_dwl_ndb->d_api_dwl_crc = (API) 0;
276 dyn_dwl_ndb->d_api_dwl_size = (API) 0;
277 dyn_dwl_ndb->d_api_dwl_write_pointer = (API) 0;
278 }
279
280 #endif // L1_DYN_DSP_DWNLD