FreeCalypso > hg > fc-selenite
comparison src/g23m-fad/ra/ra_rlp.c @ 1:d393cd9bb723
src/g23m-*: initial import from Magnetite
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 15 Jul 2018 04:40:46 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:b6a5e36de839 | 1:d393cd9bb723 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : GSM-F&D (8411) | |
4 | Modul : RA_RLP | |
5 +----------------------------------------------------------------------------- | |
6 | Copyright 2002 Texas Instruments Berlin, AG | |
7 | All rights reserved. | |
8 | | |
9 | This file is confidential and a trade secret of Texas | |
10 | Instruments Berlin, AG | |
11 | The receipt of or possession of this file does not convey | |
12 | any rights to reproduce or disclose its contents or to | |
13 | manufacture, use, or sell anything it may describe, in | |
14 | whole, or in part, without the specific written consent of | |
15 | Texas Instruments Berlin, AG. | |
16 +----------------------------------------------------------------------------- | |
17 | Purpose : This Modul defines the functions for the non-transparent | |
18 | data model (RLP) for the component RA of the mobile | |
19 | station | |
20 +----------------------------------------------------------------------------- | |
21 */ | |
22 | |
23 #ifndef RA_RLP_C | |
24 #define RA_RLP_C | |
25 #endif | |
26 | |
27 #define ENTITY_RA | |
28 | |
29 /*==== INCLUDES ===================================================*/ | |
30 | |
31 #include <string.h> | |
32 #include "typedefs.h" | |
33 #include "vsi.h" | |
34 #include "macdef.h" | |
35 #include "pconst.cdg" | |
36 #include "custom.h" | |
37 #include "gsm.h" | |
38 #include "cnf_ra.h" | |
39 #include "prim.h" | |
40 #include "pei.h" | |
41 #include "tok.h" | |
42 #include "ccdapi.h" | |
43 #include "ra.h" | |
44 | |
45 /*==== CONST ======================================================*/ | |
46 /*==== TYPES ======================================================*/ | |
47 /*==== VARIABLES ==================================================*/ | |
48 /*==== FUNCTIONS ==================================================*/ | |
49 | |
50 /* | |
51 +--------------------------------------------------------------------+ | |
52 | PROJECT : GSM-F&D (8411) MODULE : RA_RLP | | |
53 | STATE : code ROUTINE : rlp_init | | |
54 +--------------------------------------------------------------------+ | |
55 | |
56 PURPOSE : | |
57 | |
58 */ | |
59 | |
60 GLOBAL void rlp_init(void) | |
61 { | |
62 TRACE_FUNCTION("rlp_init()"); | |
63 | |
64 memset(ra_data->rlp, 0, sizeof(T_RLP)); | |
65 hCommRLP = vsi_c_open ( VSI_CALLER RLP_NAME ); | |
66 hCommMMI = vsi_c_open ( VSI_CALLER ACI_NAME ); | |
67 } | |
68 | |
69 /* | |
70 +--------------------------------------------------------------------+ | |
71 | PROJECT : GSM-F&D (8411) MODULE : RA_RLP | | |
72 | STATE : code ROUTINE : rlp_idle | | |
73 +--------------------------------------------------------------------+ | |
74 | |
75 PURPOSE : IDLE processing fpr uplink and downlink non-transparent mode | |
76 */ | |
77 | |
78 GLOBAL void rlp_idle(void) | |
79 { | |
80 TRACE_FUNCTION("rlp_idle()"); | |
81 } | |
82 | |
83 /* | |
84 +--------------------------------------------------------------------+ | |
85 | PROJECT : GSM-F&D (8411) MODULE : RA_RLP | | |
86 | STATE : code ROUTINE : rlp_ul_null | | |
87 +--------------------------------------------------------------------+ | |
88 | |
89 PURPOSE : | |
90 */ | |
91 | |
92 GLOBAL void rlp_ul_null(void) | |
93 { | |
94 T_RLP *drlp = ra_data->rlp; | |
95 UBYTE i; | |
96 | |
97 TRACE_FUNCTION("rlp_ul_null()"); | |
98 | |
99 if (ra_data->activated) | |
100 { | |
101 #ifdef TRACE_RA_RLP | |
102 drlp->fcs_error = 0L; | |
103 #endif | |
104 /* | |
105 * setup the communication parameters | |
106 */ | |
107 shm_set_dsp_value (conf_b_itc, V_ITC_DATA); | |
108 shm_set_dsp_value (conf_b_ce, V_CE_NON_TRANSP); | |
109 | |
110 switch (ra_data->tra_rate) | |
111 { | |
112 case TRA_FULLRATE_14400: | |
113 shm_set_dsp_value (conf_b_ur, V_UR_14400); | |
114 shm_set_dsp_value (conf_b_ct, V_CT_FR); | |
115 break; | |
116 | |
117 case TRA_FULLRATE_9600: | |
118 shm_set_dsp_value (conf_b_ur, V_UR_9600); | |
119 shm_set_dsp_value (conf_b_ct, V_CT_FR); | |
120 break; | |
121 | |
122 case TRA_FULLRATE_4800: | |
123 shm_set_dsp_value (conf_b_ur, V_UR_4800); | |
124 shm_set_dsp_value (conf_b_ct, V_CT_FR); | |
125 break; | |
126 | |
127 case TRA_HALFRATE_4800: | |
128 shm_set_dsp_value (conf_b_ur, V_UR_4800); | |
129 shm_set_dsp_value (conf_b_ct, V_CT_HR); | |
130 break; | |
131 | |
132 default: | |
133 break; | |
134 } | |
135 | |
136 shm_set_dsp_value (ntu_M1, 0); | |
137 shm_set_dsp_value (ntu_M2, 0); | |
138 shm_set_dsp_value (ntu_empty, 1); | |
139 shm_set_dsp_value (ntu_byte_cnt, 2); | |
140 | |
141 /* | |
142 * initialize the non-transparent mode data | |
143 */ | |
144 drlp->ul_data_pending = FALSE; | |
145 drlp->m1 = 0; | |
146 | |
147 ra_data->ra_data_ind.fr_type = FR_RLP; | |
148 ra_data->ra_data_ind.sdu.o_buf = 0; | |
149 ra_data->ra_data_ind.sdu.l_buf = 0; | |
150 | |
151 ra_data->ra_ready_ind[0].req_frames = 1; | |
152 | |
153 cl_ribu_init(&drlp->ulq, RLP_UL_QSIZE); | |
154 | |
155 for (i = 0; i < drlp->ulq.depth; i++) | |
156 { | |
157 cl_set_frame_desc_0(&drlp->ul_frame_desc[i], NULL, 0); | |
158 } | |
159 | |
160 cl_set_frame_desc_0(&ra_data->rlp->dl_frame_desc, NULL, 0); | |
161 shm_set_dsp_value (act_b_init, 1); | |
162 | |
163 INIT_STATE (KER, RLP_INIT_L1); | |
164 | |
165 #ifdef HO_WORKAROUND /* rlp_ul_null */ | |
166 _act_d_ra_conf = *ra_data->shm.shm_addr[d_ra_conf]; | |
167 TRACE_EVENT("d_ra_conf saved"); | |
168 #endif | |
169 | |
170 } | |
171 } | |
172 | |
173 /* | |
174 +--------------------------------------------------------------------+ | |
175 | PROJECT : GSM-F&D (8411) MODULE : RA_RLP | | |
176 | STATE : code ROUTINE : rlp_ul_init_l1 | | |
177 +--------------------------------------------------------------------+ | |
178 | |
179 PURPOSE : | |
180 | |
181 */ | |
182 | |
183 GLOBAL void rlp_ul_init_l1(void) | |
184 { | |
185 TRACE_FUNCTION("rlp_ul_init_l1()"); | |
186 | |
187 if (shm_get_dsp_value (act_b_init) EQ 0) | |
188 { | |
189 /* | |
190 * initialisation finished -> enter the data transmission state | |
191 */ | |
192 l1i_ra_activate_cnf(); | |
193 SET_STATE (KER, RLP_DATA_TRANS); | |
194 } | |
195 } | |
196 | |
197 /* | |
198 +--------------------------------------------------------------------+ | |
199 | PROJECT : GSM-F&D (8411) MODULE : RA_RLP | | |
200 | STATE : code ROUTINE : rlp_ul_data_trans | | |
201 +--------------------------------------------------------------------+ | |
202 | |
203 PURPOSE : | |
204 */ | |
205 | |
206 GLOBAL void rlp_ul_data_trans(void) | |
207 { | |
208 T_RLP *drlp = ra_data->rlp; | |
209 | |
210 TRACE_FUNCTION("rlp_ul_data_trans()"); | |
211 | |
212 if (drlp->ul_data_pending) /* a frame is ready to be sent */ | |
213 { | |
214 USHORT len = 0; | |
215 | |
216 switch (ra_data->tra_rate) | |
217 { | |
218 case TRA_FULLRATE_9600: | |
219 case TRA_HALFRATE_4800: | |
220 len = NT_DATA_SIZE; | |
221 drlp->ul_data_pending = FALSE; | |
222 break; | |
223 | |
224 case TRA_FULLRATE_4800: | |
225 /* S844: 1=1st half, 0=2nd half */ | |
226 if (shm_get_dsp_value (act_b_f48blk_ul) EQ 1) | |
227 { | |
228 TRACE_FUNCTION("send 4800 first half"); | |
229 len = NT_DATA_SIZE_4800_FR_A; | |
230 drlp->ul_48_first_half_sent = TRUE; | |
231 } | |
232 else | |
233 { | |
234 if (drlp->ul_48_first_half_sent) | |
235 { | |
236 TRACE_FUNCTION("send 4800 second half"); | |
237 len = NT_DATA_SIZE_4800_FR_B; | |
238 drlp->ul_data_pending = FALSE; | |
239 drlp->ul_frame_desc[drlp->ulq.ri].Adr[0] += NT_DATA_SIZE_4800_FR_A; | |
240 } | |
241 else | |
242 { | |
243 TRACE_FUNCTION("wait for 4800 first half"); | |
244 len = 0; | |
245 } | |
246 } | |
247 break; | |
248 | |
249 case TRA_FULLRATE_14400: | |
250 shm_set_dsp_value (ntu_M1, drlp->m1); | |
251 /* S844: 0 = first half, 1 = second half */ | |
252 if (drlp->m1 EQ 0) | |
253 { | |
254 len = NT_DATA_SIZE_14400_A; | |
255 drlp->m1 = 1; | |
256 } | |
257 else | |
258 { | |
259 len = NT_DATA_SIZE_14400_B; | |
260 drlp->ul_data_pending = FALSE; | |
261 drlp->ul_frame_desc[drlp->ulq.ri].Adr[0] += NT_DATA_SIZE_14400_A; | |
262 } | |
263 break; | |
264 } | |
265 if (len > 0) | |
266 { | |
267 shm_set_dsp_buffer(&drlp->ul_frame_desc[drlp->ulq.ri], | |
268 ra_data->shm.shm_addr[adr_ntu_data]+wof_ntu_data, 0, len); | |
269 shm_set_dsp_value (ntu_empty, 0); | |
270 shm_set_dsp_value (ntu_byte_cnt, (len+2)); | |
271 if (!drlp->ul_data_pending) | |
272 { | |
273 cl_ribu_read_index(&drlp->ulq); | |
274 /* PZ 22.7.99 */ | |
275 drlp->ul_data_pending = (drlp->ulq.ri NEQ drlp->ulq.wi); | |
276 /* PZ 22.7.99 */ | |
277 } | |
278 } | |
279 else | |
280 { | |
281 shm_set_dsp_value (ntu_M1, 0); | |
282 shm_set_dsp_value (ntu_empty, 1); | |
283 shm_set_dsp_value (ntu_byte_cnt, 2); | |
284 } | |
285 } | |
286 else | |
287 { | |
288 /* no frame is ready to be sent */ | |
289 shm_set_dsp_value (ntu_M1, 0); | |
290 shm_set_dsp_value (ntu_empty, 1); | |
291 shm_set_dsp_value (ntu_byte_cnt, 2); | |
292 } | |
293 | |
294 if (!drlp->ul_data_pending) | |
295 { | |
296 l1i_ra_ready_ind(hCommRLP, 0); | |
297 } | |
298 } | |
299 | |
300 /* | |
301 +--------------------------------------------------------------------+ | |
302 | PROJECT : GSM-F&D (8411) MODULE : RA_RLP | | |
303 | STATE : code ROUTINE : rlp_dl_data_trans | | |
304 +--------------------------------------------------------------------+ | |
305 | |
306 PURPOSE : | |
307 */ | |
308 | |
309 GLOBAL void rlp_dl_data_trans(void) | |
310 { | |
311 BOOL frame_complete = FALSE; | |
312 | |
313 TRACE_FUNCTION("rlp_dl_data_trans()"); | |
314 | |
315 #ifdef HO_WORKAROUND /* rlp_dl_data_trans */ | |
316 if (*ra_data->shm.shm_addr[d_ra_conf] NEQ _act_d_ra_conf) | |
317 { | |
318 *ra_data->shm.shm_addr[d_ra_conf] = _act_d_ra_conf; /* rlp_dl_data_trans */ | |
319 TRACE_EVENT("HO_REFRESH rlp_dl_data_trans"); | |
320 } | |
321 #endif | |
322 | |
323 /* | |
324 * read out the received downlink data | |
325 */ | |
326 if (shm_get_dsp_value (ntd_byte_cnt) > 0) | |
327 { | |
328 USHORT len = 0; | |
329 | |
330 switch (ra_data->tra_rate) | |
331 { | |
332 case TRA_FULLRATE_9600: | |
333 case TRA_HALFRATE_4800: | |
334 if (shm_get_dsp_value (ntd_fcs_ok) EQ 0) | |
335 { | |
336 frame_complete = TRUE; | |
337 len = NT_DATA_SIZE; | |
338 | |
339 #ifdef _SIMULATION_ | |
340 cl_set_frame_desc_0(&ra_data->rlp->dl_frame_desc, ra_data->rlp->dl_buf, NT_DATA_SIZE); | |
341 ra_data->ra_data_ind.sdu.l_buf = NT_DATA_SIZE << 3; | |
342 #else | |
343 rlp_rbm_get_next_buffer(&ra_data->rlp->dl_frame_desc); | |
344 #endif | |
345 } | |
346 else | |
347 { | |
348 #ifdef TRACE_RA_RLP | |
349 TRACE_EVENT("FCS-Error"); | |
350 ra_data->rlp->fcs_error++; | |
351 #endif | |
352 frame_complete = FALSE; | |
353 len = 0; | |
354 } | |
355 break; | |
356 | |
357 case TRA_FULLRATE_4800: | |
358 /* S844: 0=1st half, 1=2nd half */ | |
359 if (shm_get_dsp_value (act_b_f48blk_dl) EQ 0) | |
360 { | |
361 len = NT_DATA_SIZE_4800_FR_A; | |
362 frame_complete = FALSE; | |
363 #ifdef _SIMULATION_ | |
364 cl_set_frame_desc_0(&ra_data->rlp->dl_frame_desc, ra_data->rlp->dl_buf, NT_DATA_SIZE_4800_FR_A+NT_DATA_SIZE_4800_FR_B); | |
365 ra_data->ra_data_ind.sdu.l_buf = (NT_DATA_SIZE_4800_FR_A+NT_DATA_SIZE_4800_FR_B) << 3; | |
366 #else | |
367 rlp_rbm_get_next_buffer(&ra_data->rlp->dl_frame_desc); | |
368 #endif | |
369 } | |
370 else if (shm_get_dsp_value (ntd_fcs_ok) EQ 0) | |
371 { | |
372 frame_complete = TRUE; | |
373 len = NT_DATA_SIZE_4800_FR_B; | |
374 ra_data->rlp->dl_frame_desc.Adr[0] += NT_DATA_SIZE_4800_FR_A; | |
375 } | |
376 else | |
377 { | |
378 #ifdef TRACE_RA_RLP | |
379 TRACE_EVENT("FCS-Error"); | |
380 ra_data->rlp->fcs_error++; | |
381 #endif | |
382 frame_complete = FALSE; | |
383 len = 0; | |
384 } | |
385 break; | |
386 | |
387 case TRA_FULLRATE_14400: | |
388 /* S844: 0 = first half, 1 = second half */ | |
389 if (shm_get_dsp_value (ntd_M1) EQ 0) | |
390 { | |
391 frame_complete = FALSE; | |
392 len = NT_DATA_SIZE_14400_A; | |
393 #ifdef _SIMULATION_ | |
394 cl_set_frame_desc_0(&ra_data->rlp->dl_frame_desc, ra_data->rlp->dl_buf, NT_DATA_SIZE_14400_A + NT_DATA_SIZE_14400_B); | |
395 ra_data->ra_data_ind.sdu.l_buf = (NT_DATA_SIZE_14400_A + NT_DATA_SIZE_14400_B) << 3; | |
396 #else | |
397 rlp_rbm_get_next_buffer(&ra_data->rlp->dl_frame_desc); | |
398 #endif | |
399 } | |
400 else if (shm_get_dsp_value (ntd_fcs_ok) EQ 0) | |
401 { | |
402 frame_complete = TRUE; | |
403 len = NT_DATA_SIZE_14400_B; | |
404 ra_data->rlp->dl_frame_desc.Adr[0] += NT_DATA_SIZE_14400_A; | |
405 } | |
406 else | |
407 { | |
408 #ifdef TRACE_RA_RLP | |
409 TRACE_EVENT("FCS-Error"); | |
410 ra_data->rlp->fcs_error++; | |
411 #endif | |
412 frame_complete = FALSE; | |
413 len = 0; | |
414 } | |
415 break; | |
416 } | |
417 if (len > 0) | |
418 { | |
419 shm_get_dsp_buffer(&ra_data->rlp->dl_frame_desc, ra_data->shm.shm_addr[adr_ntd_data]+wof_ntd_data, len); | |
420 shm_set_dsp_value (ntd_byte_cnt, 0); | |
421 | |
422 if (frame_complete) | |
423 { | |
424 l1i_ra_data_ind(hCommRLP); | |
425 } | |
426 } | |
427 } | |
428 } | |
429 |