FreeCalypso > hg > tcs211-l1-reconst
comparison g23m/condat/com/src/driver/em.c @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : GSM-PS | |
4 | Modul : DRV_RX | |
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 | |
18 | device driver for the G23 protocol stack. | |
19 | | |
20 | This driver is used to control all engineering mode related | |
21 | functions. | |
22 +----------------------------------------------------------------------------- | |
23 */ | |
24 | |
25 #ifndef DRV_EM_C | |
26 #define DRV_EM_C | |
27 #define ENTITY_CST | |
28 /*==== INCLUDES ===================================================*/ | |
29 #if defined (NEW_FRAME) | |
30 | |
31 #include <string.h> | |
32 #include "typedefs.h" | |
33 #include "vsi.h" | |
34 #include "custom.h" | |
35 #include "gsm.h" | |
36 #include "prim.h" | |
37 #include "gdi.h" | |
38 #include "em.h" | |
39 | |
40 #else | |
41 | |
42 #include <string.h> | |
43 #include "stddefs.h" | |
44 #include "custom.h" | |
45 #include "gsm.h" | |
46 #include "prim.h" | |
47 #include "vsi.h" | |
48 #include "gdi.h" | |
49 #include "em.h" | |
50 | |
51 #endif | |
52 | |
53 /*==== EXPORT =====================================================*/ | |
54 | |
55 /*==== VARIABLES ==================================================*/ | |
56 #define EV_BUFFER_SIZE 512 | |
57 | |
58 #if defined (NEW_FRAME) | |
59 EXTERN USHORT cst_handle; | |
60 #endif | |
61 | |
62 UBYTE ev_enabled = FALSE; | |
63 USHORT ev_first_read; | |
64 USHORT ev_first_write; | |
65 USHORT ev_size; | |
66 UBYTE ev_buffer [EV_BUFFER_SIZE]; | |
67 /*==== FUNCTIONS ==================================================*/ | |
68 LOCAL void em_get_size (UBYTE size); | |
69 LOCAL UBYTE em_check_em_class_infra_data (UBYTE em_subclass, | |
70 UBYTE em_type, | |
71 em_data_type * out_em_data); | |
72 LOCAL UBYTE em_check_em_subclass_sc_info (UBYTE em_type, | |
73 em_data_type * out_em_data); | |
74 LOCAL UBYTE em_check_em_subclass_nc_info (UBYTE em_type, | |
75 em_data_type * out_em_data); | |
76 LOCAL UBYTE em_check_em_subclass_lup_and_pag (UBYTE em_type, | |
77 em_data_type * out_em_data); | |
78 | |
79 /*==== CONSTANTS ==================================================*/ | |
80 #ifndef FF_EM_MODE | |
81 /* | |
82 +--------------------------------------------------------------------+ | |
83 | PROJECT : GSM-PS (6103) MODULE : DRV_EM | | |
84 | STATE : code ROUTINE : em_Init | | |
85 +--------------------------------------------------------------------+ | |
86 | |
87 PURPOSE : The function initializes the driverīs internal data. | |
88 The function returns DRV_OK in case of a successful | |
89 completition. The function returns DRV_INITIALIZED if | |
90 the driver has already been initialized and is ready to | |
91 be used or is already in use. In case of an initialization | |
92 failure, which means the that the driver cannot be used, | |
93 the function returns DRV_INITFAILURE. | |
94 | |
95 */ | |
96 | |
97 GLOBAL UBYTE em_Init (void) | |
98 { | |
99 ev_enabled = FALSE; | |
100 | |
101 return DRV_OK; | |
102 } | |
103 #endif /* FF_EM_MODE */ | |
104 | |
105 #ifndef FF_EM_MODE | |
106 /* | |
107 +--------------------------------------------------------------------+ | |
108 | PROJECT : GSM-PS (6103) MODULE : DRV_EM | | |
109 | STATE : code ROUTINE : em_Exit | | |
110 +--------------------------------------------------------------------+ | |
111 | |
112 PURPOSE : The function is used to indicate that the driver | |
113 and its functionality isnīt needed anymore. | |
114 | |
115 */ | |
116 | |
117 GLOBAL void em_Exit (void) | |
118 { | |
119 } | |
120 #endif /* FF_EM_MODE */ | |
121 | |
122 /* | |
123 +--------------------------------------------------------------------+ | |
124 | PROJECT : GSM-PS (6103) MODULE : DRV_EM | | |
125 | STATE : code ROUTINE : em_Read_Parameter | | |
126 +--------------------------------------------------------------------+ | |
127 | |
128 PURPOSE : This function is used to read a parameter of the mobile. | |
129 | |
130 */ | |
131 | |
132 GLOBAL UBYTE em_Read_Parameter (UBYTE em_class, | |
133 UBYTE em_subclass, | |
134 UBYTE em_type, | |
135 em_data_type * out_em_data) | |
136 { | |
137 switch (em_class) | |
138 { | |
139 case EM_CLASS_INFRA_DATA: | |
140 return (em_check_em_class_infra_data (em_subclass, em_type, out_em_data)); | |
141 default: | |
142 return EM_INVALID_CLASS; | |
143 } | |
144 } | |
145 | |
146 /* | |
147 +--------------------------------------------------------------------+ | |
148 | PROJECT : GSM-PS (6103) MODULE : DRV_EM | | |
149 | STATE : code ROUTINE : em_Enable_Post_Mortem | | |
150 +--------------------------------------------------------------------+ | |
151 | |
152 PURPOSE : This function enables recording of event data in the | |
153 post mortem memory. | |
154 | |
155 */ | |
156 | |
157 GLOBAL UBYTE em_Enable_Post_Mortem () | |
158 { | |
159 ev_first_read = 0; | |
160 ev_first_write = 0; | |
161 ev_size = EV_BUFFER_SIZE; | |
162 ev_enabled = TRUE; | |
163 return DRV_OK; | |
164 } | |
165 | |
166 /* | |
167 +--------------------------------------------------------------------+ | |
168 | PROJECT : GSM-PS (6103) MODULE : DRV_EM | | |
169 | STATE : code ROUTINE : em_Disable_Post_Mortem | | |
170 +--------------------------------------------------------------------+ | |
171 | |
172 PURPOSE : This function disables recording of event data in the | |
173 post mortem memory and allows reading of the data. | |
174 | |
175 */ | |
176 | |
177 GLOBAL UBYTE em_Disable_Post_Mortem () | |
178 { | |
179 ev_enabled = FALSE; | |
180 return DRV_OK; | |
181 } | |
182 | |
183 | |
184 /* | |
185 +--------------------------------------------------------------------+ | |
186 | PROJECT : GSM-PS (6103) MODULE : DRV_EM | | |
187 | STATE : code ROUTINE : em_Read_Post_Mortem | | |
188 +--------------------------------------------------------------------+ | |
189 | |
190 PURPOSE : This function is used to read a parameter of the | |
191 post mortem memory. | |
192 | |
193 */ | |
194 | |
195 GLOBAL UBYTE em_Read_Post_Mortem (em_data_type * out_em_data) | |
196 { | |
197 UBYTE subclass; | |
198 UBYTE i; | |
199 #if defined (WIN32) | |
200 char buf[60]; | |
201 sprintf (buf, "before %d %d read", ev_first_read, ev_first_write); | |
202 TRACE_EVENT (buf); | |
203 #endif | |
204 if (ev_enabled EQ FALSE) | |
205 { | |
206 if (ev_size EQ EV_BUFFER_SIZE) | |
207 return EM_NO_MORE_DATA; | |
208 | |
209 out_em_data->em_class = EM_CLASS_EVENT_TRACE; | |
210 subclass = ev_buffer [ev_first_read++]; | |
211 out_em_data->em_subclass = subclass & 0x3F; | |
212 if (ev_first_read >= EV_BUFFER_SIZE) | |
213 ev_first_read -= EV_BUFFER_SIZE; | |
214 out_em_data->em_type = ev_buffer [ev_first_read++]; | |
215 if (ev_first_read >= EV_BUFFER_SIZE) | |
216 ev_first_read -= EV_BUFFER_SIZE; | |
217 #if defined (WIN32) | |
218 sprintf (buf, "subclass %x read", subclass); | |
219 TRACE_EVENT (buf); | |
220 #endif | |
221 switch (subclass & 0xC0) | |
222 { | |
223 case 0x00: | |
224 // single entry | |
225 ev_size += 2; | |
226 out_em_data->em_length = 0; | |
227 break; | |
228 case 0x40: | |
229 // ubyte entry | |
230 ev_size += 3; | |
231 out_em_data->em_length = 1; | |
232 out_em_data->em_parameter[0] = ev_buffer [ev_first_read++]; | |
233 if (ev_first_read >= EV_BUFFER_SIZE) | |
234 ev_first_read -= EV_BUFFER_SIZE; | |
235 break; | |
236 case 0x80: | |
237 // ushort entry | |
238 ev_size += 4; | |
239 out_em_data->em_length = 2; | |
240 out_em_data->em_parameter[0] = ev_buffer [ev_first_read++]; | |
241 if (ev_first_read >= EV_BUFFER_SIZE) | |
242 ev_first_read -= EV_BUFFER_SIZE; | |
243 out_em_data->em_parameter[1] = ev_buffer [ev_first_read++]; | |
244 if (ev_first_read >= EV_BUFFER_SIZE) | |
245 ev_first_read -= EV_BUFFER_SIZE; | |
246 break; | |
247 case 0xC0: | |
248 // array entry | |
249 // skip to length | |
250 out_em_data->em_length = ev_buffer [ev_first_read++]; | |
251 if (ev_first_read >= EV_BUFFER_SIZE) | |
252 ev_first_read -= EV_BUFFER_SIZE; | |
253 for (i=0;i<out_em_data->em_length;i++) | |
254 { | |
255 out_em_data->em_parameter[i] = ev_buffer[ev_first_read++]; | |
256 if (ev_first_read >= EV_BUFFER_SIZE) | |
257 ev_first_read -= EV_BUFFER_SIZE; | |
258 } | |
259 ev_size += (out_em_data->em_length+3); | |
260 break; | |
261 } | |
262 #if defined (WIN32) | |
263 sprintf (buf, "after %d %d read", ev_first_read, ev_first_write); | |
264 TRACE_EVENT (buf); | |
265 #endif | |
266 return DRV_OK; | |
267 } | |
268 else | |
269 { | |
270 return EM_INVALID_ACCESS; | |
271 } | |
272 } | |
273 | |
274 | |
275 /* | |
276 ************************************************************************************* | |
277 * | |
278 * Internal Functions | |
279 * | |
280 ************************************************************************************* | |
281 */ | |
282 | |
283 /* | |
284 * the internal event buffer is organised as a ring buffer. Using different | |
285 * access functions the data is stored in one of the four following ways: | |
286 * | |
287 * SINGLE TRACE (no parameter) | |
288 * | |
289 * Byte 1: 00 xxxxxx subclass | |
290 * Byte 2: yyyyyyyyy type | |
291 * | |
292 * UBYTE TRACE (one byte parameter) | |
293 * | |
294 * Byte 1: 01 xxxxxx subclass | |
295 * Byte 2: yyyyyyyyy type | |
296 * Byte 3: zzzzzzzzz parameter | |
297 * | |
298 * USHORT TRACE (two bytes parameter) | |
299 * | |
300 * Byte 1: 10 xxxxxx subclass | |
301 * Byte 2: yyyyyyyyy type | |
302 * Byte 3: zzzzzzzzz parameter | |
303 * Byte 4: zzzzzzzzz parameter | |
304 * | |
305 * ARRAY TRACE (n bytes parameter) | |
306 * | |
307 * Byte 1: 11 xxxxxx subclass | |
308 * Byte 2: yyyyyyyyy type | |
309 * Byte 3: aaaaaaaaa len | |
310 * Byte 4-n+3: zzzzzzzzz parameter | |
311 * | |
312 * The parameter ev_enabled defines whether recording is enabled or not. | |
313 * after power on it is disabled. | |
314 * | |
315 * The parameter ev_first_read indicates the first position in the ev_buffer | |
316 * which shall be read. | |
317 * | |
318 * The parameter ev_first_write indicates the first position in the ev_buffer | |
319 * which shall be used for the next recorded event. | |
320 * | |
321 * The parameter ev_size defines the free memory in the ev_buffer. If the next | |
322 * write event is greater than the free memory the ev_first_read is changed to | |
323 * have enough memory. | |
324 * | |
325 */ | |
326 | |
327 GLOBAL void em_trace_single (UBYTE class, | |
328 UBYTE subclass, | |
329 UBYTE type) | |
330 { | |
331 #if defined (WIN32) | |
332 char buf[60]; | |
333 #endif | |
334 TRACE_FUNCTION ("em_trace_single"); | |
335 | |
336 #if defined (WIN32) | |
337 sprintf (buf, "before %d %d Single", ev_first_read, ev_first_write); | |
338 TRACE_EVENT (buf); | |
339 #endif | |
340 if (ev_enabled) | |
341 { | |
342 // get memory if needed | |
343 em_get_size (2); | |
344 // write subclass | |
345 ev_buffer[ev_first_write++] = subclass; | |
346 if (ev_first_write >= EV_BUFFER_SIZE) | |
347 ev_first_write -= EV_BUFFER_SIZE; | |
348 // write type | |
349 ev_buffer[ev_first_write++] = type; | |
350 if (ev_first_write >= EV_BUFFER_SIZE) | |
351 ev_first_write -= EV_BUFFER_SIZE; | |
352 ev_size -= 2; | |
353 } | |
354 #if defined (WIN32) | |
355 sprintf (buf, "after %d %d Single", ev_first_read, ev_first_write); | |
356 TRACE_EVENT (buf); | |
357 #endif | |
358 } | |
359 | |
360 GLOBAL void em_trace_ubyte (UBYTE class, | |
361 UBYTE subclass, | |
362 UBYTE type, | |
363 UBYTE para_ubyte) | |
364 { | |
365 #if defined (WIN32) | |
366 char buf[60]; | |
367 | |
368 TRACE_FUNCTION ("em_trace_ubyte"); | |
369 | |
370 sprintf (buf, "before %d %d ubyte", ev_first_read, ev_first_write); | |
371 TRACE_EVENT (buf); | |
372 #endif | |
373 | |
374 if (ev_enabled) | |
375 { | |
376 // get memory if needed | |
377 em_get_size (3); | |
378 // write subclass | |
379 ev_buffer[ev_first_write++] = subclass + 0x40; | |
380 if (ev_first_write >= EV_BUFFER_SIZE) | |
381 ev_first_write -= EV_BUFFER_SIZE; | |
382 // write type | |
383 ev_buffer[ev_first_write++] = type; | |
384 if (ev_first_write >= EV_BUFFER_SIZE) | |
385 ev_first_write -= EV_BUFFER_SIZE; | |
386 // write parameter | |
387 ev_buffer[ev_first_write++] = para_ubyte; | |
388 if (ev_first_write >= EV_BUFFER_SIZE) | |
389 ev_first_write -= EV_BUFFER_SIZE; | |
390 ev_size -= 3; | |
391 } | |
392 #if defined (WIN32) | |
393 sprintf (buf, "after %d %d ubyte", ev_first_read, ev_first_write); | |
394 TRACE_EVENT (buf); | |
395 #endif | |
396 } | |
397 | |
398 GLOBAL void em_trace_ushort (UBYTE class, | |
399 UBYTE subclass, | |
400 UBYTE type, | |
401 USHORT para_ushort) | |
402 { | |
403 #if defined (WIN32) | |
404 char buf[60]; | |
405 | |
406 TRACE_FUNCTION ("em_trace_ushort"); | |
407 | |
408 sprintf (buf, "before %d %d ushort", ev_first_read, ev_first_write); | |
409 TRACE_EVENT (buf); | |
410 #endif | |
411 | |
412 if (ev_enabled) | |
413 { | |
414 // get memory if needed | |
415 em_get_size (4); | |
416 // write subclass | |
417 ev_buffer[ev_first_write++] = subclass + 0x80; | |
418 if (ev_first_write >= EV_BUFFER_SIZE) | |
419 ev_first_write -= EV_BUFFER_SIZE; | |
420 // write type | |
421 ev_buffer[ev_first_write++] = type; | |
422 if (ev_first_write >= EV_BUFFER_SIZE) | |
423 ev_first_write -= EV_BUFFER_SIZE; | |
424 // write parameter | |
425 ev_buffer[ev_first_write++] = para_ushort >> 8; | |
426 if (ev_first_write >= EV_BUFFER_SIZE) | |
427 ev_first_write -= EV_BUFFER_SIZE; | |
428 // write parameter | |
429 ev_buffer[ev_first_write++] = para_ushort & 8; | |
430 if (ev_first_write >= EV_BUFFER_SIZE) | |
431 ev_first_write -= EV_BUFFER_SIZE; | |
432 ev_size -= 4; | |
433 } | |
434 #if defined (WIN32) | |
435 sprintf (buf, "after %d %d ushort", ev_first_read, ev_first_write); | |
436 TRACE_EVENT (buf); | |
437 #endif | |
438 } | |
439 | |
440 | |
441 GLOBAL void em_trace_array (UBYTE class, | |
442 UBYTE subclass, | |
443 UBYTE type, | |
444 UBYTE * array, | |
445 UBYTE length) | |
446 { | |
447 UBYTE i; | |
448 #if defined (WIN32) | |
449 char buf[60]; | |
450 | |
451 TRACE_FUNCTION ("em_trace_array"); | |
452 | |
453 sprintf (buf, "before %d %d array", ev_first_read, ev_first_write); | |
454 TRACE_EVENT (buf); | |
455 #endif | |
456 | |
457 if (ev_enabled) | |
458 { | |
459 // get memory if needed | |
460 em_get_size ((UBYTE)(length+3)); | |
461 // write subclass | |
462 ev_buffer[ev_first_write++] = subclass + 0xC0; | |
463 if (ev_first_write >= EV_BUFFER_SIZE) | |
464 ev_first_write -= EV_BUFFER_SIZE; | |
465 // write type | |
466 ev_buffer[ev_first_write++] = type; | |
467 if (ev_first_write >= EV_BUFFER_SIZE) | |
468 ev_first_write -= EV_BUFFER_SIZE; | |
469 // write length | |
470 ev_buffer[ev_first_write++] = length; | |
471 if (ev_first_write >= EV_BUFFER_SIZE) | |
472 ev_first_write -= EV_BUFFER_SIZE; | |
473 // write parameter | |
474 for (i=0;i<length;i++) | |
475 { | |
476 ev_buffer[ev_first_write++] = array[i]; | |
477 if (ev_first_write >= EV_BUFFER_SIZE) | |
478 ev_first_write -= EV_BUFFER_SIZE; | |
479 } | |
480 ev_size -= (length+3); | |
481 } | |
482 #if defined (WIN32) | |
483 sprintf (buf, "after %d %d array", ev_first_read, ev_first_write); | |
484 TRACE_EVENT (buf); | |
485 sprintf (buf, "%x %x %x %x %x", | |
486 ev_buffer[0], | |
487 ev_buffer[1], | |
488 ev_buffer[2], | |
489 ev_buffer[3], | |
490 ev_buffer[4]); | |
491 TRACE_EVENT (buf); | |
492 #endif | |
493 } | |
494 | |
495 | |
496 LOCAL void em_get_size (UBYTE size) | |
497 { | |
498 while (ev_size < size) | |
499 { | |
500 /* | |
501 * increase ev_first_read to get memory | |
502 */ | |
503 switch (ev_buffer [ev_first_read & 0xC0]) | |
504 { | |
505 case 0x00: | |
506 // single entry | |
507 ev_size += 2; | |
508 ev_first_read += 2; | |
509 break; | |
510 case 0x40: | |
511 // ubyte entry | |
512 ev_size += 3; | |
513 ev_first_read += 3; | |
514 break; | |
515 case 0x80: | |
516 // ushort entry | |
517 ev_size += 3; | |
518 ev_first_read += 3; | |
519 break; | |
520 case 0xC0: | |
521 // array entry | |
522 // skip to length | |
523 ev_first_read += 2; | |
524 if (ev_first_read >= EV_BUFFER_SIZE) | |
525 ev_first_read -= EV_BUFFER_SIZE; | |
526 ev_first_read += (1+ev_buffer[ev_first_read]); | |
527 break; | |
528 } | |
529 // align if at the end of the buffer | |
530 if (ev_first_read >= EV_BUFFER_SIZE) | |
531 ev_first_read -= EV_BUFFER_SIZE; | |
532 } | |
533 } | |
534 | |
535 LOCAL UBYTE em_check_em_class_infra_data (UBYTE em_subclass, | |
536 UBYTE em_type, | |
537 em_data_type * out_em_data) | |
538 { | |
539 switch (em_subclass) | |
540 { | |
541 case EM_SUBCLASS_SC_INFO: | |
542 return (em_check_em_subclass_sc_info (em_type, out_em_data)); | |
543 case EM_SUBCLASS_NC_INFO: | |
544 return (em_check_em_subclass_nc_info (em_type, out_em_data)); | |
545 case EM_SUBCLASS_LUP_AND_PAG: | |
546 return (em_check_em_subclass_lup_and_pag (em_type, out_em_data)); | |
547 default: | |
548 return EM_INVALID_SUBCLASS; | |
549 } | |
550 } | |
551 | |
552 LOCAL UBYTE em_check_em_subclass_sc_info (UBYTE em_type, | |
553 em_data_type * out_em_data) | |
554 { | |
555 T_EM_NC_DATA em_nc_data; | |
556 /* | |
557 * ret 0 not available | |
558 * 1 idle mode | |
559 * 2 dedicated mode | |
560 */ | |
561 UBYTE ret; | |
562 | |
563 out_em_data->em_class = EM_CLASS_INFRA_DATA; | |
564 out_em_data->em_subclass = EM_SUBCLASS_SC_INFO; | |
565 out_em_data->em_type = em_type; | |
566 | |
567 ret = em_get_nc_data (&em_nc_data, 6); // serving cell data | |
568 | |
569 switch (em_type) | |
570 { | |
571 case EM_IN_SC_BCCH_ARFCN: | |
572 if (ret EQ 1) | |
573 { | |
574 sprintf ((char *)out_em_data->em_parameter,"%3x",em_nc_data.arfcn); | |
575 out_em_data->em_length = strlen ((char *)out_em_data->em_parameter); | |
576 return DRV_OK; | |
577 } | |
578 else | |
579 return EM_DATA_NOT_AVAIL; | |
580 break; | |
581 | |
582 case EM_IN_SC_C1: | |
583 if (ret EQ 1) | |
584 { | |
585 sprintf ((char *)out_em_data->em_parameter,"%3d",em_nc_data.c1); | |
586 out_em_data->em_length = strlen ((char *)out_em_data->em_parameter); | |
587 return DRV_OK; | |
588 } | |
589 else | |
590 return EM_DATA_NOT_AVAIL; | |
591 break; | |
592 | |
593 case EM_IN_SC_C2: | |
594 if (ret EQ 1) | |
595 { | |
596 sprintf ((char *)out_em_data->em_parameter,"%3d",em_nc_data.c2); | |
597 out_em_data->em_length = strlen ((char *)out_em_data->em_parameter); | |
598 return DRV_OK; | |
599 } | |
600 else | |
601 return EM_DATA_NOT_AVAIL; | |
602 break; | |
603 | |
604 case EM_IN_SC_BSIC: | |
605 if (ret EQ 1) | |
606 { | |
607 sprintf ((char *)out_em_data->em_parameter,"%3x",em_nc_data.bsic); | |
608 out_em_data->em_length = strlen ((char *)out_em_data->em_parameter); | |
609 return DRV_OK; | |
610 } | |
611 else | |
612 return EM_DATA_NOT_AVAIL; | |
613 break; | |
614 | |
615 case EM_IN_SC_LAC: | |
616 if (ret EQ 1) | |
617 { | |
618 sprintf ((char *)out_em_data->em_parameter,"%3x",em_nc_data.lac); | |
619 out_em_data->em_length = strlen ((char *)out_em_data->em_parameter); | |
620 return DRV_OK; | |
621 } | |
622 else | |
623 return EM_DATA_NOT_AVAIL; | |
624 break; | |
625 | |
626 case EM_IN_SC_BA: | |
627 if (ret EQ 1) | |
628 { | |
629 sprintf ((char *)out_em_data->em_parameter,"%3d",em_nc_data.cba); | |
630 out_em_data->em_length = strlen ((char *)out_em_data->em_parameter); | |
631 return DRV_OK; | |
632 } | |
633 else | |
634 return EM_DATA_NOT_AVAIL; | |
635 break; | |
636 | |
637 case EM_IN_SC_BQ: | |
638 if (ret EQ 1) | |
639 { | |
640 sprintf ((char *)out_em_data->em_parameter,"%3d",em_nc_data.cbq); | |
641 out_em_data->em_length = strlen ((char *)out_em_data->em_parameter); | |
642 return DRV_OK; | |
643 } | |
644 else | |
645 return EM_DATA_NOT_AVAIL; | |
646 break; | |
647 | |
648 case EM_IN_SC_TIL_STATE: | |
649 #if !defined(FF_GTI) | |
650 if (ret EQ 1) | |
651 { | |
652 sprintf ((char *)out_em_data->em_parameter,"%3d",em_nc_data.til_state); | |
653 out_em_data->em_length = strlen ((char *)out_em_data->em_parameter); | |
654 return DRV_OK; | |
655 } | |
656 else | |
657 #endif /* !FF_GTI */ | |
658 return EM_DATA_NOT_AVAIL; | |
659 break; | |
660 | |
661 case EM_IN_SC_RX: | |
662 if (ret EQ 1) | |
663 { | |
664 sprintf ((char *)out_em_data->em_parameter,"%3d",em_nc_data.rxlev); | |
665 out_em_data->em_length = strlen ((char *)out_em_data->em_parameter); | |
666 return DRV_OK; | |
667 } | |
668 else | |
669 return EM_DATA_NOT_AVAIL; | |
670 break; | |
671 | |
672 case EM_IN_SC_NMR_RAW: | |
673 if (em_get_network_meas (out_em_data->em_parameter) EQ 1) | |
674 { | |
675 out_em_data->em_length = 16; | |
676 return DRV_OK; | |
677 } | |
678 else | |
679 return EM_DATA_NOT_AVAIL; | |
680 break; | |
681 | |
682 case EM_IN_SC_BCCH_LIST_RAW: | |
683 if (em_get_bcch_chan_list (out_em_data) NEQ 1) | |
684 return DRV_OK; | |
685 else | |
686 return EM_DATA_NOT_AVAIL; | |
687 break; | |
688 | |
689 default: | |
690 return EM_INVALID_TYPE; | |
691 } | |
692 } | |
693 | |
694 LOCAL UBYTE em_check_em_subclass_nc_info (UBYTE em_type, | |
695 em_data_type * out_em_data) | |
696 { | |
697 T_EM_NC_DATA em_nc_data; | |
698 /* | |
699 * ret 0 not available | |
700 * 1 idle mode | |
701 * 2 dedicated mode | |
702 */ | |
703 UBYTE ret; | |
704 UBYTE cell_id; | |
705 | |
706 out_em_data->em_class = EM_CLASS_INFRA_DATA; | |
707 out_em_data->em_subclass = EM_SUBCLASS_NC_INFO; | |
708 out_em_data->em_type = em_type; | |
709 | |
710 switch( em_type ) | |
711 { | |
712 case EM_IN_NC_BCCH_1: | |
713 case EM_IN_NC_RX_1: | |
714 case EM_IN_NC_C1_1: | |
715 case EM_IN_NC_C2_1: | |
716 case EM_IN_NC_BSIC_1: | |
717 case EM_IN_NC_CID_1: | |
718 case EM_IN_NC_FN_OFFSET_1: | |
719 case EM_IN_NC_TA_OFFSET_1: | |
720 case EM_IN_NC_LAC_1: | |
721 case EM_IN_NC_BA_1: | |
722 case EM_IN_NC_BQ_1: | |
723 case EM_IN_NC_TIL_STATE_1: | |
724 cell_id = 0; | |
725 break; | |
726 | |
727 case EM_IN_NC_BCCH_2: | |
728 case EM_IN_NC_RX_2: | |
729 case EM_IN_NC_C1_2: | |
730 case EM_IN_NC_C2_2: | |
731 case EM_IN_NC_BSIC_2: | |
732 case EM_IN_NC_CID_2: | |
733 case EM_IN_NC_FN_OFFSET_2: | |
734 case EM_IN_NC_TA_OFFSET_2: | |
735 case EM_IN_NC_LAC_2: | |
736 case EM_IN_NC_BA_2: | |
737 case EM_IN_NC_BQ_2: | |
738 case EM_IN_NC_TIL_STATE_2: | |
739 cell_id = 1; | |
740 break; | |
741 | |
742 case EM_IN_NC_BCCH_3: | |
743 case EM_IN_NC_RX_3: | |
744 case EM_IN_NC_C1_3: | |
745 case EM_IN_NC_C2_3: | |
746 case EM_IN_NC_BSIC_3: | |
747 case EM_IN_NC_CID_3: | |
748 case EM_IN_NC_FN_OFFSET_3: | |
749 case EM_IN_NC_TA_OFFSET_3: | |
750 case EM_IN_NC_LAC_3: | |
751 case EM_IN_NC_BA_3: | |
752 case EM_IN_NC_BQ_3: | |
753 case EM_IN_NC_TIL_STATE_3: | |
754 cell_id = 2; | |
755 break; | |
756 | |
757 case EM_IN_NC_BCCH_4: | |
758 case EM_IN_NC_RX_4: | |
759 case EM_IN_NC_C1_4: | |
760 case EM_IN_NC_C2_4: | |
761 case EM_IN_NC_BSIC_4: | |
762 case EM_IN_NC_CID_4: | |
763 case EM_IN_NC_FN_OFFSET_4: | |
764 case EM_IN_NC_TA_OFFSET_4: | |
765 case EM_IN_NC_LAC_4: | |
766 case EM_IN_NC_BA_4: | |
767 case EM_IN_NC_BQ_4: | |
768 case EM_IN_NC_TIL_STATE_4: | |
769 cell_id = 3; | |
770 break; | |
771 | |
772 case EM_IN_NC_BCCH_5: | |
773 case EM_IN_NC_RX_5: | |
774 case EM_IN_NC_C1_5: | |
775 case EM_IN_NC_C2_5: | |
776 case EM_IN_NC_BSIC_5: | |
777 case EM_IN_NC_CID_5: | |
778 case EM_IN_NC_FN_OFFSET_5: | |
779 case EM_IN_NC_TA_OFFSET_5: | |
780 case EM_IN_NC_LAC_5: | |
781 case EM_IN_NC_BA_5: | |
782 case EM_IN_NC_BQ_5: | |
783 case EM_IN_NC_TIL_STATE_5: | |
784 cell_id = 4; | |
785 break; | |
786 | |
787 case EM_IN_NC_BCCH_6: | |
788 case EM_IN_NC_RX_6: | |
789 case EM_IN_NC_C1_6: | |
790 case EM_IN_NC_C2_6: | |
791 case EM_IN_NC_BSIC_6: | |
792 case EM_IN_NC_CID_6: | |
793 case EM_IN_NC_FN_OFFSET_6: | |
794 case EM_IN_NC_TA_OFFSET_6: | |
795 case EM_IN_NC_LAC_6: | |
796 case EM_IN_NC_BA_6: | |
797 case EM_IN_NC_BQ_6: | |
798 case EM_IN_NC_TIL_STATE_6: | |
799 cell_id = 5; | |
800 break; | |
801 | |
802 case EM_IN_NC_TIL_SYNC_CNT: | |
803 case EM_IN_NC_TIL_BCCH_CNT: | |
804 cell_id = 6; // Serving cell | |
805 break; | |
806 | |
807 default: | |
808 return EM_DATA_NOT_AVAIL; | |
809 } | |
810 | |
811 | |
812 ret = em_get_nc_data (&em_nc_data, cell_id); // ncell data | |
813 | |
814 switch (em_type) | |
815 { | |
816 case EM_IN_NC_BCCH_1: | |
817 case EM_IN_NC_BCCH_2: | |
818 case EM_IN_NC_BCCH_3: | |
819 case EM_IN_NC_BCCH_4: | |
820 case EM_IN_NC_BCCH_5: | |
821 case EM_IN_NC_BCCH_6: | |
822 if (ret NEQ 0) | |
823 { | |
824 sprintf ((char *)out_em_data->em_parameter,"%3x",em_nc_data.arfcn); | |
825 out_em_data->em_length = strlen ((char *)out_em_data->em_parameter); | |
826 return DRV_OK; | |
827 } | |
828 else | |
829 return EM_DATA_NOT_AVAIL; | |
830 break; | |
831 | |
832 case EM_IN_NC_RX_1: | |
833 case EM_IN_NC_RX_2: | |
834 case EM_IN_NC_RX_3: | |
835 case EM_IN_NC_RX_4: | |
836 case EM_IN_NC_RX_5: | |
837 case EM_IN_NC_RX_6: | |
838 if (ret NEQ 0) | |
839 { | |
840 sprintf ((char *)out_em_data->em_parameter,"%3d",em_nc_data.rxlev); | |
841 out_em_data->em_length = strlen ((char *)out_em_data->em_parameter); | |
842 return DRV_OK; | |
843 } | |
844 else | |
845 return EM_DATA_NOT_AVAIL; | |
846 break; | |
847 | |
848 case EM_IN_NC_BSIC_1: | |
849 case EM_IN_NC_BSIC_2: | |
850 case EM_IN_NC_BSIC_3: | |
851 case EM_IN_NC_BSIC_4: | |
852 case EM_IN_NC_BSIC_5: | |
853 case EM_IN_NC_BSIC_6: | |
854 if (ret NEQ 0) | |
855 { | |
856 sprintf ((char *)out_em_data->em_parameter,"%3x",em_nc_data.bsic); | |
857 out_em_data->em_length = strlen ((char *)out_em_data->em_parameter); | |
858 return DRV_OK; | |
859 } | |
860 else | |
861 return EM_DATA_NOT_AVAIL; | |
862 break; | |
863 | |
864 case EM_IN_NC_C1_1: | |
865 case EM_IN_NC_C1_2: | |
866 case EM_IN_NC_C1_3: | |
867 case EM_IN_NC_C1_4: | |
868 case EM_IN_NC_C1_5: | |
869 case EM_IN_NC_C1_6: | |
870 if (ret EQ 1) | |
871 { | |
872 sprintf ((char *)out_em_data->em_parameter,"%3d",em_nc_data.c1); | |
873 out_em_data->em_length = strlen ((char *)out_em_data->em_parameter); | |
874 return DRV_OK; | |
875 } | |
876 else | |
877 return EM_DATA_NOT_AVAIL; | |
878 break; | |
879 | |
880 case EM_IN_NC_C2_1: | |
881 case EM_IN_NC_C2_2: | |
882 case EM_IN_NC_C2_3: | |
883 case EM_IN_NC_C2_4: | |
884 case EM_IN_NC_C2_5: | |
885 case EM_IN_NC_C2_6: | |
886 if (ret EQ 1) | |
887 { | |
888 sprintf ((char *)out_em_data->em_parameter,"%3d",em_nc_data.c2); | |
889 out_em_data->em_length = strlen ((char *)out_em_data->em_parameter); | |
890 return DRV_OK; | |
891 } | |
892 else | |
893 return EM_DATA_NOT_AVAIL; | |
894 break; | |
895 | |
896 case EM_IN_NC_LAC_1: | |
897 case EM_IN_NC_LAC_2: | |
898 case EM_IN_NC_LAC_3: | |
899 case EM_IN_NC_LAC_4: | |
900 case EM_IN_NC_LAC_5: | |
901 case EM_IN_NC_LAC_6: | |
902 if (ret EQ 1) | |
903 { | |
904 sprintf ((char *)out_em_data->em_parameter,"%3x",em_nc_data.lac); | |
905 out_em_data->em_length = strlen ((char *)out_em_data->em_parameter); | |
906 return DRV_OK; | |
907 } | |
908 else | |
909 return EM_DATA_NOT_AVAIL; | |
910 break; | |
911 | |
912 case EM_IN_NC_BA_1: | |
913 case EM_IN_NC_BA_2: | |
914 case EM_IN_NC_BA_3: | |
915 case EM_IN_NC_BA_4: | |
916 case EM_IN_NC_BA_5: | |
917 case EM_IN_NC_BA_6: | |
918 if (ret EQ 1) | |
919 { | |
920 sprintf ((char *)out_em_data->em_parameter,"%3x",em_nc_data.cba); | |
921 out_em_data->em_length = strlen ((char *)out_em_data->em_parameter); | |
922 return DRV_OK; | |
923 } | |
924 else | |
925 return EM_DATA_NOT_AVAIL; | |
926 break; | |
927 | |
928 case EM_IN_NC_BQ_1: | |
929 case EM_IN_NC_BQ_2: | |
930 case EM_IN_NC_BQ_3: | |
931 case EM_IN_NC_BQ_4: | |
932 case EM_IN_NC_BQ_5: | |
933 case EM_IN_NC_BQ_6: | |
934 if (ret EQ 1) | |
935 { | |
936 sprintf ((char *)out_em_data->em_parameter,"%3x",em_nc_data.cbq); | |
937 out_em_data->em_length = strlen ((char *)out_em_data->em_parameter); | |
938 return DRV_OK; | |
939 } | |
940 else | |
941 return EM_DATA_NOT_AVAIL; | |
942 break; | |
943 | |
944 case EM_IN_NC_TIL_STATE_1: | |
945 case EM_IN_NC_TIL_STATE_2: | |
946 case EM_IN_NC_TIL_STATE_3: | |
947 case EM_IN_NC_TIL_STATE_4: | |
948 case EM_IN_NC_TIL_STATE_5: | |
949 case EM_IN_NC_TIL_STATE_6: | |
950 #if !defined(FF_GTI) | |
951 if (ret NEQ 0) | |
952 { | |
953 sprintf ((char *)out_em_data->em_parameter,"%3d",em_nc_data.til_state); | |
954 out_em_data->em_length = strlen ((char *)out_em_data->em_parameter); | |
955 return DRV_OK; | |
956 } | |
957 else | |
958 #endif /* !FF_GTI */ | |
959 return EM_DATA_NOT_AVAIL; | |
960 break; | |
961 | |
962 case EM_IN_NC_TIL_SYNC_CNT: | |
963 #if !defined(FF_GTI) | |
964 if ( (ret EQ 1) && (em_nc_data.sync_cnt NEQ 0xFF) ) | |
965 { | |
966 sprintf ((char *)out_em_data->em_parameter,"%3d",em_nc_data.sync_cnt); | |
967 out_em_data->em_length = strlen ((char *)out_em_data->em_parameter); | |
968 return DRV_OK; | |
969 } | |
970 else | |
971 #endif /* !FF_GTI */ | |
972 return EM_DATA_NOT_AVAIL; | |
973 break; | |
974 | |
975 case EM_IN_NC_TIL_BCCH_CNT: | |
976 #if !defined(FF_GTI) | |
977 if ( (ret EQ 1) && (em_nc_data.bcch_cnt NEQ 0xFF) ) | |
978 { | |
979 sprintf ((char *)out_em_data->em_parameter,"%3d",em_nc_data.bcch_cnt); | |
980 out_em_data->em_length = strlen ((char *)out_em_data->em_parameter); | |
981 return DRV_OK; | |
982 } | |
983 else | |
984 #endif /* !FF_GTI */ | |
985 return EM_DATA_NOT_AVAIL; | |
986 break; | |
987 | |
988 default: | |
989 return EM_INVALID_TYPE; | |
990 break; | |
991 | |
992 } | |
993 } | |
994 | |
995 LOCAL UBYTE em_check_em_subclass_lup_and_pag (UBYTE em_type, | |
996 em_data_type * out_em_data) | |
997 { | |
998 UBYTE * sys_info_3 = NULL; | |
999 | |
1000 out_em_data->em_class = EM_CLASS_INFRA_DATA; | |
1001 out_em_data->em_subclass = EM_SUBCLASS_LUP_AND_PAG; | |
1002 out_em_data->em_type = em_type; | |
1003 | |
1004 #if defined(FF_GTI) | |
1005 sys_info_3 = em_get_sysinfo_type3 (); // sys info 3 | |
1006 #else | |
1007 sys_info_3 = em_get_sys_info (0x1B); // sys info 3 | |
1008 #endif /* FF_GTI */ | |
1009 | |
1010 switch (em_type) | |
1011 { | |
1012 case EM_IN_LP_BS_PA_MFRMS: | |
1013 if (sys_info_3 EQ NULL) | |
1014 return EM_DATA_NOT_AVAIL; | |
1015 else | |
1016 { | |
1017 sprintf ((char *)out_em_data->em_parameter,"%d",(sys_info_3[10]&7)+2); | |
1018 out_em_data->em_length = strlen ((char *)out_em_data->em_parameter); | |
1019 return DRV_OK; | |
1020 } | |
1021 case EM_IN_LP_T3212: | |
1022 if (sys_info_3 EQ NULL) | |
1023 return EM_DATA_NOT_AVAIL; | |
1024 else | |
1025 { | |
1026 sprintf ((char *)out_em_data->em_parameter,"%d",sys_info_3[11]); | |
1027 out_em_data->em_length = strlen ((char *)out_em_data->em_parameter); | |
1028 return DRV_OK; | |
1029 } | |
1030 case EM_IN_LP_MCC: | |
1031 if (sys_info_3 EQ NULL) | |
1032 return EM_DATA_NOT_AVAIL; | |
1033 else | |
1034 { | |
1035 USHORT mcc; | |
1036 | |
1037 mcc = (sys_info_3[4] & 0x0F)*100 + | |
1038 ((sys_info_3[4] & 0xF0)>>4)*10 + | |
1039 (sys_info_3[5] & 0x0F); | |
1040 sprintf ((char *)out_em_data->em_parameter,"%d",mcc); | |
1041 out_em_data->em_length = strlen ((char *)out_em_data->em_parameter); | |
1042 return DRV_OK; | |
1043 } | |
1044 case EM_IN_LP_MNC: | |
1045 if (sys_info_3 EQ NULL) | |
1046 return EM_DATA_NOT_AVAIL; | |
1047 else | |
1048 { | |
1049 USHORT mnc; | |
1050 | |
1051 mnc = (sys_info_3[6] & 0x0F)*10 + | |
1052 ((sys_info_3[6] & 0xF0)>>4); | |
1053 sprintf ((char *)out_em_data->em_parameter,"%d",mnc); | |
1054 out_em_data->em_length = strlen ((char *)out_em_data->em_parameter); | |
1055 return DRV_OK; | |
1056 } | |
1057 case EM_IN_LP_LAC: | |
1058 case EM_IN_LP_LAC_RAW: | |
1059 if (sys_info_3 EQ NULL) | |
1060 return EM_DATA_NOT_AVAIL; | |
1061 else | |
1062 { | |
1063 USHORT lac; | |
1064 | |
1065 lac = (sys_info_3[7] << 8) + | |
1066 sys_info_3[8]; | |
1067 if (em_type EQ EM_IN_LP_LAC) | |
1068 { | |
1069 sprintf ((char *)out_em_data->em_parameter,"%d",lac); | |
1070 out_em_data->em_length = strlen ((char *)out_em_data->em_parameter); | |
1071 } | |
1072 else | |
1073 { | |
1074 out_em_data->em_parameter[0] = sys_info_3[7]; | |
1075 out_em_data->em_parameter[1] = sys_info_3[8]; | |
1076 out_em_data->em_length = 2; | |
1077 } | |
1078 return DRV_OK; | |
1079 } | |
1080 case EM_IN_LP_CI_RAW: | |
1081 if (sys_info_3 EQ NULL) | |
1082 return EM_DATA_NOT_AVAIL; | |
1083 else | |
1084 { | |
1085 out_em_data->em_parameter[0] = sys_info_3[2]; | |
1086 out_em_data->em_parameter[1] = sys_info_3[3]; | |
1087 out_em_data->em_length = 2; | |
1088 } | |
1089 return DRV_OK; | |
1090 | |
1091 default: | |
1092 return EM_INVALID_TYPE; | |
1093 } | |
1094 } | |
1095 | |
1096 #endif |