comparison src/g23m-gprs/llc/llc_t200f.c @ 183:219afcfc6250

src/g23m-gprs: initial import from TCS3.2/LoCosto
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 13 Oct 2016 04:24:13 +0000
parents
children
comparison
equal deleted inserted replaced
182:f02d0a0e1849 183:219afcfc6250
1 /*
2 +-----------------------------------------------------------------------------
3 | Project :
4 | Modul :
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 is part of the entity LLC and implements all
18 | procedures and functions as described in the
19 | SDL-documentation (T200-statemachine)
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef LLC_T200F_C
24 #define LLC_T200F_C
25 #endif
26
27 #define ENTITY_LLC
28
29 /*==== INCLUDES =============================================================*/
30
31 #include <string.h> /* to get memcpy() */
32
33 #include "typedefs.h" /* to get Condat data types */
34 #include "vsi.h" /* to get a lot of macros */
35 #include "macdef.h"
36 #include "gprs.h"
37 #include "gsm.h" /* to get a lot of macros */
38 #include "cnf_llc.h" /* to get cnf-definitions */
39 #include "mon_llc.h" /* to get mon-definitions */
40 #include "prim.h" /* to get the definitions of used SAP and directions */
41 #include "llc.h" /* to get the global entity definitions */
42 #include "llc_f.h" /* to get the global function */
43 #include "llc_t200f.h" /* to get local typedef's and defines */
44
45 /*==== CONST ================================================================*/
46
47 /*==== LOCAL VARS ===========================================================*/
48
49 /*==== PRIVATE FUNCTIONS ====================================================*/
50
51 /*==== PUBLIC FUNCTIONS =====================================================*/
52
53
54 /*
55 +------------------------------------------------------------------------------
56 | Function : t200_init
57 +------------------------------------------------------------------------------
58 | Description : This procedure initialises all necessary variables of
59 | timer_t200 for all SAPIs.
60 |
61 | Parameters :
62 |
63 +------------------------------------------------------------------------------
64 */
65 GLOBAL void t200_init (void)
66 {
67 UBYTE inc;
68
69
70 TRACE_FUNCTION( "t200_init" );
71
72 /*
73 * Initialise timer data structures and initial state of every incarnation.
74 * The timer length is not set in this procedure, it is instead initialised
75 * by llc_init_parameters().
76 */
77 for (inc = 0; inc < T200_NUM_INC; inc++)
78 {
79 SWITCH_SERVICE (llc, t200, inc);
80
81 /*
82 * Free old used resources (in case of an LLC restart):
83 * memory, stored primitives, running timer.
84 */
85 t200_stop();
86
87 }
88
89 SWITCH_SERVICE (llc, t200, 0);
90 INIT_STATE (T200_0, T200_TLLI_UNASSIGNED);
91
92 SWITCH_SERVICE (llc, t200, 1);
93 INIT_STATE (T200_1, T200_TLLI_UNASSIGNED);
94
95 SWITCH_SERVICE (llc, t200, 2);
96 INIT_STATE (T200_2, T200_TLLI_UNASSIGNED);
97
98 SWITCH_SERVICE (llc, t200, 3);
99 INIT_STATE (T200_3, T200_TLLI_UNASSIGNED);
100
101 SWITCH_SERVICE (llc, t200, 4);
102 INIT_STATE (T200_4, T200_TLLI_UNASSIGNED);
103
104 SWITCH_SERVICE (llc, t200, 5);
105 INIT_STATE (T200_5, T200_TLLI_UNASSIGNED);
106
107 return;
108 } /* t200_init() */
109
110
111 /*
112 +------------------------------------------------------------------------------
113 | Function : t200_start
114 +------------------------------------------------------------------------------
115 | Description : This procedure starts timer T200 for the current sapi and
116 | stores a copy of the given frame and the originator. The
117 | frame address is a pointer to a LL_UNITDATA_REQ primitive
118 | which is associated with T200 and will be freed by the lower
119 | layers after transmission. Therefore a copy has to be stored.
120 | cause is the associated GRLC_DATA_REQ!cause for the frame.
121 | originator is an identifier of the service who started the
122 | timer. The frame is returned to the service (originator)
123 | which started T200 with the corresponding EXPIRED signal.
124 |
125 | Parameters : frame - a pointer to the frame that shall be associated
126 | with the timer
127 | cause - RLC/MAC cause of frame
128 | originator - the service which started the timer, must not be
129 | NO_SERVICE
130 |
131 +------------------------------------------------------------------------------
132 */
133 GLOBAL void t200_start
134 (
135 #ifdef LL_DESC
136 T_LL_UNITDESC_REQ *frame,
137 #else
138 T_LL_UNITDATA_REQ *frame,
139 #endif
140 UBYTE cause,
141 T_SERVICE originator
142 )
143 {
144 #ifdef LL_DESC
145 USHORT frame_len, frame_offset;
146 UBYTE *prim_buf, *frame_buf;
147 T_desc3 *desc3, *frame_desc3;
148 #endif /* LL_DESC */
149
150 TRACE_FUNCTION( "t200_start" );
151
152 #ifdef LL_DESC
153 /*
154 * Start timer T200 for the current SAPI.
155 */
156 #ifdef _SIMULATION_
157 /*
158 * In simulation mode, use always a timer value of 5 seconds.
159 */
160 vsi_t_start (VSI_CALLER
161 (USHORT)(TIMER_T200_BASE + UIMAP(llc_data->current_sapi)),
162 5000);
163 #else
164 vsi_t_start (VSI_CALLER
165 (USHORT)(TIMER_T200_BASE + UIMAP(llc_data->current_sapi)),
166 llc_data->t200->length);
167 #endif /* _SIMULATION_ */
168
169 {
170 /*
171 * Allocate copy of frame which shall be stored. Because an exact copy
172 * of frame shall be stored, the SDU offset must be added to the used
173 * SDU length.
174 */
175 frame_desc3 = (T_desc3*)frame->desc_list3.first;
176 frame_len = frame->desc_list3.list_len;
177 frame_offset = frame_desc3->offset;
178 {
179 PALLOC(ll_unitdesc_req, LL_UNITDESC_REQ);
180 desc3 = llc_palloc_desc(frame_len, frame_offset);/* Only one desc3 and buffer are allocated */
181
182 /*
183 * Copy primitive contents to newly allocated primitive. SDU contents
184 * have to be copied separately, because they are allocated dynamically
185 * and not of known size in the primitve structure:
186 * First copy primitive with SDU, but only sdu.l_buf/o_buf and first octet
187 * of sdu.buf.
188 * Then memcpy actual SDU content with size defined in sdu.l_buf.
189 */
190 *ll_unitdesc_req = *frame;
191 ll_unitdesc_req->desc_list3.first = (ULONG)desc3;
192
193 prim_buf = (UBYTE*)desc3->buffer;
194 frame_buf = (UBYTE*)frame_desc3->buffer;
195
196 memcpy (&(prim_buf[desc3->offset]),
197 &(frame_buf[frame_offset]), frame_len);
198
199 /*
200 * Store the given frame address, RLC/MAC cause, and the originator
201 * for this timer.
202 */
203 llc_data->t200->frame = ll_unitdesc_req;
204 llc_data->t200->cause = cause;
205 llc_data->t200->originator = originator;
206 }
207 }
208
209 return;
210
211 #else /* LL_DESC */
212 /*
213 * Start timer T200 for the current SAPI.
214 */
215 #ifdef _SIMULATION_
216 /*
217 * In simulation mode, use always a timer value of 5 seconds.
218 */
219 vsi_t_start (VSI_CALLER
220 (USHORT)(TIMER_T200_BASE + UIMAP(llc_data->current_sapi)),
221 5000);
222 #else
223 vsi_t_start (VSI_CALLER
224 (USHORT)(TIMER_T200_BASE + UIMAP(llc_data->current_sapi)),
225 llc_data->t200->length);
226 #endif /* _SIMULATION_ */
227
228 {
229 /*
230 * Allocate copy of frame which shall be stored. Because an exact copy
231 * of frame shall be stored, the SDU offset must be added to the used
232 * SDU length.
233 */
234 PALLOC_SDU (ll_unitdata_req, LL_UNITDATA_REQ,
235 (USHORT)(frame->sdu.o_buf + frame->sdu.l_buf));
236
237 /*
238 * Copy primitive contents to newly allocated primitive. SDU contents
239 * have to be copied separately, because they are allocated dynamically
240 * and not of known size in the primitve structure:
241 * First copy primitive with SDU, but only sdu.l_buf/o_buf and first octet
242 * of sdu.buf.
243 * Then memcpy actual SDU content with size defined in sdu.l_buf.
244 */
245 *ll_unitdata_req = *frame;
246 memcpy (&(ll_unitdata_req->sdu.buf[ll_unitdata_req->sdu.o_buf/8]),
247 &(frame->sdu.buf[frame->sdu.o_buf/8]), frame->sdu.l_buf/8);
248
249 /*
250 * Store the given frame address, RLC/MAC cause, and the originator
251 * for this timer.
252 */
253 llc_data->t200->frame = ll_unitdata_req;
254 llc_data->t200->cause = cause;
255 llc_data->t200->originator = originator;
256 }
257
258 return;
259 #endif /* LL_DESC */
260 } /* t200_start() */
261
262
263 /*
264 +------------------------------------------------------------------------------
265 | Function : t200_stop
266 +------------------------------------------------------------------------------
267 | Description : This procedure stops (resets) timer T200 for the current sapi.
268 | The associated frame address and the originator of T200 are
269 | discarded (i.e. the allocated primitive of the frame is freed).
270 |
271 | Parameters :
272 |
273 +------------------------------------------------------------------------------
274 */
275 GLOBAL void t200_stop (void)
276 {
277 TRACE_FUNCTION( "t200_stop" );
278
279 /*
280 * Stop timer T200 for the current SAPI.
281 */
282 vsi_t_stop (VSI_CALLER
283 (USHORT)(TIMER_T200_BASE + UIMAP(llc_data->current_sapi)));
284
285 /*
286 * Free stored primitive.
287 */
288 if (llc_data->t200->frame)
289 {
290 #ifdef LL_DESC
291 /*
292 * The descriptor contents of the primitive structure
293 * must be freed as well.
294 */
295 llc_cl_desc3_free((T_desc3*)llc_data->t200->frame->desc_list3.first);
296 #endif /* LL_DESC */
297 PFREE (llc_data->t200->frame);
298 }
299
300 /*
301 * Delete timer data of the timer for the given SAPI.
302 */
303 llc_data->t200->frame = NULL;
304 llc_data->t200->originator = NO_SERVICE;
305 llc_data->t200->cause = 0;
306
307 return;
308 } /* t200_stop() */
309
310
311 /*
312 +------------------------------------------------------------------------------
313 | Function : t200_get_timer_data
314 +------------------------------------------------------------------------------
315 | Description : This procedure returns frame address, frame cause, and the
316 | originator identifier for timer T200 of the current sapi.
317 | (see procedure t200_start)
318 |
319 | Parameters : frame - will be set to the frame pointer which is stored
320 | for the timer, must be a valid pointer
321 | cause - will be set to the RLC/MAC frame cause
322 | originator - will be set to the originating service for the
323 | timer, must be a valid pointer
324 |
325 +------------------------------------------------------------------------------
326 */
327 GLOBAL void t200_get_timer_data
328 (
329 #ifdef LL_DESC
330 T_LL_UNITDESC_REQ **frame,
331 #else
332 T_LL_UNITDATA_REQ **frame,
333 #endif
334 UBYTE *cause,
335 T_SERVICE *originator)
336 {
337 TRACE_FUNCTION( "t200_get_timer_data" );
338
339 /*
340 * Get timer data of the timer for the given SAPI.
341 */
342 *frame = llc_data->t200->frame;
343 *cause = llc_data->t200->cause;
344 *originator = llc_data->t200->originator;
345
346 return;
347 } /* t200_get_timer_data() */