comparison src/g23m-fad/l2r/tra_upf.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 : CSD (8411)
4 | Modul : tra_upf.c
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 procedures and functions for
18 | the component TRA
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef TRA_UPF_C
23 #define TRA_UPF_C
24 #endif
25
26 #define ENTITY_L2R
27
28 /*==== INCLUDES ===================================================*/
29
30 #include <string.h>
31 #include "typedefs.h"
32 #include "pconst.cdg"
33 #include "vsi.h"
34 #include "macdef.h"
35 #include "custom.h"
36 #include "gsm.h"
37 #include "prim.h"
38 #include "pei.h"
39 #include "tok.h"
40 #include "dti.h"
41
42 #include "cl_ribu.h"
43 #include "tra_pei.h"
44 #include "tra.h"
45
46 #ifdef _TARGET_
47 #include "ra_l1int.h"
48 #endif
49
50 /*==== CONST =======================================================*/
51
52 /*==== TYPES =======================================================*/
53
54 /*==== VAR EXPORT ==================================================*/
55
56 /*==== VAR LOCAL ===================================================*/
57
58 /*==== FUNCTIONS ===================================================*/
59
60 /*
61 +------------------------------------------------------------------------------
62 | Function : up_init
63 +------------------------------------------------------------------------------
64 | Description : initialise the tra data for the uplink process
65 |
66 | Parameters : -
67 |
68 |
69 | Return : -
70 +------------------------------------------------------------------------------
71 */
72
73 GLOBAL void ul_init(T_TRA_UP *dul)
74 {
75 TRACE_FUNCTION ("ul_init()");
76
77 dul->sa = FL_INACTIVE;
78 dul->sb = FL_INACTIVE;
79 dul->x = FL_INACTIVE;
80 dul->List_off = 0;
81
82 INIT_STATE (UP, UP_INACTIVE);
83 }
84
85 /*
86 +------------------------------------------------------------------------------
87 | Function : snd_break_to_RA
88 +------------------------------------------------------------------------------
89 | Description :
90 |
91 | Parameters : -
92 |
93 |
94 | Return :
95 +------------------------------------------------------------------------------
96 */
97
98 GLOBAL void snd_break_to_RA(USHORT break_len)
99 {
100 #ifndef _SIMULATION_
101
102 T_RA_BREAK_REQ RA_break_req;
103 RA_break_req.break_len = break_len;
104
105 #endif
106
107 TRACE_FUNCTION ("snd_break_to_RA()");
108
109 #ifndef _SIMULATION_
110
111 l1i_ra_break_req (&RA_break_req);
112
113 #else
114 {
115 PALLOC (ra_break_req, RA_BREAK_REQ);
116 ra_break_req->break_len = break_len;
117 PSENDX (RA, ra_break_req);
118 }
119 #endif
120 }
121
122 /*
123 +------------------------------------------------------------------------------
124 | Function : snd_data_to_RA
125 +------------------------------------------------------------------------------
126 | Description :
127 |
128 | Parameters : -
129 |
130 |
131 | Return :
132 +------------------------------------------------------------------------------
133 */
134
135 GLOBAL void snd_data_to_RA(void)
136 {
137 T_TRA_UP *dul = &tra_data->up;
138 T_FD *pFD = &dul->fd;
139
140 T_desc2 *desc = (T_desc2*)dul->Prim->desc_list2.first;
141
142 USHORT data_off = dul->List_off; /* offset within current data block */
143 USHORT data_len = dul->Prim->desc_list2.list_len; /* local mark for overall data size to be copied */
144
145 TRACE_FUNCTION ("snd_data_to_RA()");
146
147 pFD->type = FR_TRANS;
148 pFD->status = 0;
149 pFD->len = 0; /* to mark current sdu fill status */
150
151 if (dul->req_frames)
152 {
153 while (desc)
154 {
155 if (desc->len <= (dul->req_frames - pFD->len)) /* DTI data size less than SDU space*/
156 {
157 T_desc2 *desc_im = (T_desc2*)desc->next;
158 memcpy(&dul->to_ra[pFD->len], desc->buffer + data_off, desc->len);
159 pFD->len += desc->len;
160 data_len -= desc->len;
161 data_off = 0; /* list is copied completely! */
162 MFREE (desc);
163 desc = (T_desc2*) desc_im;
164 }
165 else /* more DTI data than SDU space*/
166 {
167 memcpy(&dul->to_ra[pFD->len], desc->buffer + data_off, dul->req_frames - pFD->len);
168 data_off += (dul->req_frames - pFD->len); /* remember for next copying! */
169 desc->len -= (dul->req_frames - pFD->len);
170 desc->size = desc->len;
171 data_len -= (dul->req_frames - pFD->len);
172 pFD->len = dul->req_frames; /* the SDU is full */
173 break;
174 }
175 }
176 /*
177 * write back current standings
178 */
179 dul->Prim->desc_list2.first = (ULONG)desc;
180 dul->Prim->desc_list2.list_len = data_len;
181 dul->List_off = data_off;
182 }
183
184 if (dul->sa EQ DTI_SA_OFF)
185 pFD->status |= ST_SA;
186 if (dul->sb EQ DTI_SB_OFF)
187 pFD->status |= ST_SB;
188 if (dul->x EQ DTI_FLOW_OFF)
189 pFD->status |= ST_X;
190
191 #ifdef _TARGET_
192
193 l1i_ra_data_req_new(pFD);
194
195 #else
196 {
197 PALLOC_SDU (ra_data_req, RA_DATA_REQ, (USHORT)(dul->req_frames<<3));
198
199 if (hCommRA < VSI_OK)
200 {
201 hCommRA = vsi_c_open (VSI_CALLER RA_NAME);
202 }
203 ra_data_req->fr_type = pFD->type;
204 ra_data_req->status = pFD->status;
205 ra_data_req->dtx_flg = DTX_DIS;
206 ra_data_req->sdu.l_buf = pFD->len << 3;
207 ra_data_req->sdu.o_buf = 0;
208 memcpy(&ra_data_req->sdu.buf[0], &dul->to_ra[0], pFD->len);
209 PSENDX (RA, ra_data_req);
210 }
211 #endif
212 }
213
214 /*
215 +------------------------------------------------------------------------------
216 | Function : up_start_dti_flow
217 +------------------------------------------------------------------------------
218 | Description :
219 |
220 | Parameters : -
221 |
222 |
223 | Return : -
224 +------------------------------------------------------------------------------
225 */
226
227 GLOBAL void up_start_dti_flow(void)
228 {
229 TRACE_FUNCTION ("up_start_dti_flow()");
230
231 dti_start(l2r_hDTI, TRA_DTI_UP_INSTANCE, TRA_DTI_UP_INTERFACE, TRA_DTI_UP_CHANNEL);
232 }