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