comparison g23m-gsm/cc/cc_em.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
comparison
equal deleted inserted replaced
-1:000000000000 0:75a11d740a02
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 Module defines the engineering mode (EM) device driver for the
18 | G23 protocol stack. This driver is used to control all engineering
19 | mode related functions.
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef CC_EM_C
24 #define CC_EM_C
25
26 #include "config.h"
27 #include "fixedconf.h"
28 #include "condat-features.h"
29
30 #define ENTITY_CC
31
32 /*==== INCLUDES ===================================================*/
33
34 #include <string.h>
35 #include "typedefs.h"
36 #include "pcm.h"
37 #include "vsi.h"
38 #include "custom.h"
39 #include "gsm.h"
40 #include "message.h"
41 #include "ccdapi.h"
42 #include "prim.h"
43 #include "cnf_cc.h"
44 #include "mon_cc.h"
45 #include "pei.h"
46 #include "tok.h"
47 #include "cc.h"
48 #include "cc_em.h"
49
50 /*==== EXPORT =====================================================*/
51
52 /*==== PRIVAT =====================================================*/
53
54 /*==== VARIABLES ==================================================*/
55
56 #ifdef FF_EM_MODE
57 GLOBAL UBYTE em_cc_event_buffer[EM_CC_BUFFER_SIZE];
58 GLOBAL UBYTE em_cc_buffer_write;
59
60 /* Event tracing flags for EM */
61 GLOBAL BOOL cc_v[EM_MAX_CC_EVENTS];
62
63 static UBYTE em_cc_trace_occured;
64 #endif /* FF_EM_MODE */
65
66 /*==== FUNCTIONS ==================================================*/
67
68 #ifdef FF_EM_MODE
69
70 /*
71 +------------------------------------------------------------------------------
72 | Function : em_write_buffer_2
73 +------------------------------------------------------------------------------
74 | Description : Perform buffer check and store corresponding data in it.
75 |
76 | Parameters : Event number
77 |
78 | Return : TRUE/FALSE
79 |
80 +------------------------------------------------------------------------------
81 */
82
83 GLOBAL UBYTE em_write_buffer_2 (UBYTE event_no)
84 {
85 TRACE_FUNCTION ("cc_em_write_buffer_2()");
86 if (check_write_index(2))
87 {
88 em_cc_event_buffer[em_cc_buffer_write++] = event_no; /* Tag: Event number */
89 em_cc_event_buffer[em_cc_buffer_write++] = 0; /* Length: 0 means no value */
90 return FALSE; /* Data is stored inside buffer, reset flag */
91 }
92 else
93 return TRUE; /* No more space inside buffer, serve flag next time */
94 }
95
96 /*
97 +------------------------------------------------------------------------------
98 | Function : em_write_buffer_3
99 +------------------------------------------------------------------------------
100 | Description : Perform buffer check and store corresponding data in it.
101 |
102 | Parameters : Event number, data value
103 |
104 | Return : TRUE/FALSE
105 |
106 +------------------------------------------------------------------------------
107 */
108
109 GLOBAL UBYTE em_write_buffer_3 (UBYTE event_no, UBYTE value)
110 {
111 TRACE_FUNCTION ("cc_em_write_buffer_3()");
112
113 if (check_write_index(3))
114 {
115 em_cc_event_buffer[em_cc_buffer_write++] = event_no; /* Tag: Event number */
116 em_cc_event_buffer[em_cc_buffer_write++] = 1; /* Length: 0 means no value */
117 em_cc_event_buffer[em_cc_buffer_write++] = value; /* Data to be stored */
118 return FALSE; /* Data is stored inside buffer, reset flag */
119 }
120 else
121 return TRUE; /* No more space inside buffer, serve flag next time */
122 }
123
124 /*
125 +------------------------------------------------------------------------------
126 | Function : em_write_buffer_3a
127 +------------------------------------------------------------------------------
128 | Description : Perform buffer check and store corresponding data in it.
129 |
130 | Parameters : Event number, data value (USHORT)
131 |
132 | Return : TRUE/FALSE
133 |
134 +------------------------------------------------------------------------------
135 */
136
137 GLOBAL UBYTE em_write_buffer_3a (UBYTE event_no, USHORT value)
138 {
139 TRACE_FUNCTION ("cc_em_write_buffer_3a()");
140
141 if (check_write_index(4))
142 {
143 em_cc_event_buffer[em_cc_buffer_write++] = event_no; /* Tag: Event number */
144 em_cc_event_buffer[em_cc_buffer_write++] = 2; /* Length: 0 means no value */
145
146 /* Value: Data to be stored. MSB first, LSB second */
147 em_cc_event_buffer[em_cc_buffer_write++] = (UBYTE)(value >> 8);
148 em_cc_event_buffer[em_cc_buffer_write++] = (UBYTE)(value);
149 return FALSE; /* Data is stored inside buffer, reset flag */
150 }
151 else
152 return TRUE; /* No more space inside buffer, serve flag next time */
153 }
154
155 /*
156 +------------------------------------------------------------------------------
157 | Function : em_write_buffer_4
158 +------------------------------------------------------------------------------
159 | Description : Perform buffer check and store corresponding data in it.
160 |
161 | Parameters : Event number, data value1, data value2
162 |
163 | Return : TRUE/FALSE
164 |
165 +------------------------------------------------------------------------------
166 */
167
168 GLOBAL UBYTE em_write_buffer_4 (UBYTE event_no, UBYTE value1, UBYTE value2)
169 {
170 TRACE_FUNCTION ("cc_em_write_buffer_4()");
171
172 if (check_write_index(4))
173 {
174 em_cc_event_buffer[em_cc_buffer_write++] = event_no; /* Tag: Event number */
175 em_cc_event_buffer[em_cc_buffer_write++] = 2; /* Length: 0 means no value */
176 em_cc_event_buffer[em_cc_buffer_write++] = value1; /* Data to be stored, first */
177 em_cc_event_buffer[em_cc_buffer_write++] = value2; /* Data to be stored, second */
178 return FALSE; /* Data is stored inside buffer, reset flag */
179 }
180 else
181 return TRUE; /* No more space inside buffer, serve flag next time */
182 }
183
184
185 /*
186 +------------------------------------------------------------------------------
187 | Function : em_write_buffer_4a
188 +------------------------------------------------------------------------------
189 | Description : Perform buffer check and store corresponding data in it.
190 |
191 | Parameters : Event number, data value1 (UBYTE *), data value2
192 |
193 | Return : TRUE/FALSE
194 |
195 | Purpose : Stores Bearer Capabilitys
196 +------------------------------------------------------------------------------
197 */
198
199 GLOBAL UBYTE em_write_buffer_4a (UBYTE event_no, UBYTE *ptr1, UBYTE value2)
200 {
201
202 UBYTE bc_len;
203 UBYTE i, em_report_len = 3; /* Initial 2 + TI */
204
205 TRACE_FUNCTION ("cc_em_write_buffer_4a()");
206
207 ptr1++; /* Skip message type --> ptr1 shows now to BC-Tag*/
208 if (*ptr1++ EQ 0x04) /* BC tag (0x04) --> ptr1 shows now to length field*/
209 {
210 TRACE_FUNCTION ("EM_CC: BC tag found (0x04)");
211 if(*ptr1 > MNCC_MAX_BC_LEN) /* Field length exceeded */
212 {
213 ; /*better to insert some kind of trace here*/
214 bc_len = MNCC_MAX_BC_LEN; /*Just trace the maximum of BC's - skip the rest*/
215 }
216 else /* Field length not exceeded */
217 {
218 bc_len = *ptr1; /*trace all BC's possible */
219 }
220
221 ptr1++; /* ptr1 shows now the first BC */
222
223 em_report_len += bc_len; /* Length of encoded bearer caps */
224
225 if(check_write_index((UBYTE)(em_report_len))) /* just to ensure no buffer overflow */
226 {
227 em_cc_event_buffer[em_cc_buffer_write++] = event_no;
228 em_cc_event_buffer[em_cc_buffer_write++] = (em_report_len - 2);
229 for (i=0; i<(bc_len); i++) /* Starting with the bearercap IEI */
230 {
231 em_cc_event_buffer[em_cc_buffer_write++] = *ptr1++; /* Bearer caps encoded */
232 }
233 /* Only bearer caps should be recorded, therefore decrement em_cc_buffer_write */
234 em_cc_event_buffer[em_cc_buffer_write++] = value2; /* TI */
235
236 return FALSE; /* Data is stored inside buffer, reset flag */
237 } /* check_write_index */
238 } /* BC tag 0x04*/
239 else
240 {
241 TRACE_FUNCTION ("EM_CC: No BC tag found");
242 }/* no BC tag 0x04*/
243 return TRUE; /* No more space inside buffer or no BC tag, serve flag next time */
244 }
245
246
247 /*
248 +------------------------------------------------------------------------------
249 | Function : check_write_index
250 +------------------------------------------------------------------------------
251 | Description : Checks the write index inside the buffer. No reset when
252 | buffer is full.
253 |
254 | Parameters : Number of bytes to be stored in buffer
255 |
256 | Return : TRUE/FALSE
257 |
258 +------------------------------------------------------------------------------
259 */
260
261 GLOBAL UBYTE check_write_index (UBYTE n)
262 {
263 TRACE_FUNCTION ("cc_check_write_index()");
264
265 if (em_cc_buffer_write + n < EM_CC_BUFFER_SIZE)
266 {
267 /*
268 * ACI is informed about the first event trace,
269 * used for later data processing.
270 */
271 if (em_cc_trace_occured == 0)
272 {
273 PALLOC(data, EM_DATA_IND);
274 data->entity = EM_CC;
275 PSENDX(MMI, data);
276 em_cc_trace_occured++;
277 }
278 return TRUE;
279 }
280 else
281 {
282 TRACE_ERROR("EM_CC: buffer overflow");
283 return FALSE;
284 }
285 }
286
287
288 /*
289 +------------------------------------------------------------------------------
290 | Function : em_init_cc_event_trace
291 +------------------------------------------------------------------------------
292 | Description : Initialize the event tracing flags for SMS
293 |
294 | Parameters :
295 |
296 | Return :
297 |
298 +------------------------------------------------------------------------------
299 */
300
301 GLOBAL void em_init_cc_event_trace(void)
302 {
303 UBYTE i;
304
305 TRACE_FUNCTION ("em_init_cc_event_trace()");
306
307 for (i = 1; i < EM_MAX_CC_EVENTS; i++)
308 cc_v[i] = 0;
309
310 em_cc_buffer_write = 0;
311 }
312
313
314 /*
315 +------------------------------------------------------------------------------
316 | Function : cc_em_cc_event_req
317 +------------------------------------------------------------------------------
318 | Description : Set the event tracing flags according the bitmask
319 |
320 | Parameters : Primitive - Bitmask
321 |
322 | Return :
323 |
324 +------------------------------------------------------------------------------
325 */
326
327 GLOBAL void cc_em_cc_event_req (T_EM_CC_EVENT_REQ *em_cc_event_req)
328 {
329 UBYTE i;
330
331 TRACE_FUNCTION ("cc_em_cc_event_req()");
332
333 /*
334 * The event tracing flags are set according the bitmask. cc_v[i] are
335 * the flags belonging to the event number described in 8443.601
336 */
337 for(i = 1; i < 33; i++)
338 cc_v[i] = ((em_cc_event_req->bitmask_cc_l & (0x01<<(i-1))) > 0) ? TRUE : FALSE;
339
340 for(i = 33; i < EM_MAX_CC_EVENTS; i++)
341 cc_v[i] = ((em_cc_event_req->bitmask_cc_h & (0x01<<(i-1))) > 0) ? TRUE : FALSE;
342
343 /*
344 * A new event trace is generated therefor the flag is reset.
345 */
346 em_cc_trace_occured = 0;
347
348 PFREE(em_cc_event_req);
349 }
350
351 #endif /* FF_EM_MODE */
352
353 #endif /* CC_EM_C */