FreeCalypso > hg > freecalypso-sw
annotate gsm-fw/comlib/cl_imei.c @ 876:c9f353b5d70c
rvinterf/asyncshell/rxctl.c: buglet in the implementation of dis/enable commands
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Sat, 30 May 2015 07:50:05 +0000 |
parents | b34e5351438e |
children | f3fba126778a |
rev | line source |
---|---|
664
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 +----------------------------------------------------------------------------- |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 | Project : COMLIB |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 | Modul : cl_imei.c |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 +----------------------------------------------------------------------------- |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 | Copyright 2002 Texas Instruments Berlin, AG |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 | All rights reserved. |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 | |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 | This file is confidential and a trade secret of Texas |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 | Instruments Berlin, AG |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 | The receipt of or possession of this file does not convey |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 | any rights to reproduce or disclose its contents or to |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 | manufacture, use, or sell anything it may describe, in |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 | whole, or in part, without the specific written consent of |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 | Texas Instruments Berlin, AG. |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 +----------------------------------------------------------------------------- |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 | Purpose : Definitions of common library functions: IMEI decryption with |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 DES algorithm |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 +----------------------------------------------------------------------------- |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 */ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 /* |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 * Version 1.0 |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 */ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 /**********************************************************************************/ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 /* |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 NOTE: |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 */ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 /**********************************************************************************/ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 #ifndef CL_IMEI_C |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 #define CL_IMEI_C |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 |
667
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
36 #include "config.h" |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
37 #include "fixedconf.h" |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
38 |
664
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 #include "typedefs.h" |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 #include "vsi.h" /* to get a lot of macros */ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 |
667
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
42 #include "../services/ffs/ffs.h" |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
43 #include "../bsp/mem.h" |
664
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 #include "pcm.h" |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 #include "cl_imei.h" |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 #include "cl_des.h" |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 #include <string.h> |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 static UBYTE stored_imei[CL_IMEI_SIZE]; /* when the imei is read once, the value |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 is stored in this buffer */ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 static UBYTE imei_flag = 0; /* this flag indicates, if IMEI was successful read |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 and is stored in the stored_imei buffer */ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 /* Default IMEISV for D-Sample 00440000-350-111-20 */ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 const UBYTE C_DEFAULT_IMEISV_DSAMPLE[CL_IMEI_SIZE] = |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 {0x00, 0x44, 0x00, 0x00, 0x35, 0x01, 0x11, 0x20}; |
667
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
58 #define CL_IMEI_FFS_PATH "/etc/IMEISV" |
664
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 /*==== FUNCTIONS ==================================================*/ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 |
667
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
62 #if CONFIG_TARGET_PIRELLI |
664
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 /* |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 +------------------------------------------------------------------------------ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 | Function : get_dieID |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 +------------------------------------------------------------------------------ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 | Description : the function reads the Die-ID from base band processor and |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 | extracts it from 4 BYTEs to 8 BYTEs. |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 | |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 | Parameters : inBufSize - size of buffer where to store Die ID, min.8 BYTE |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 | *outBufPtr - pointer to buffer where to store the Die ID |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 | Return : void |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 +------------------------------------------------------------------------------ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 */ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 LOCAL void get_dieID(USHORT inBufSize, UBYTE *outBufPtr) |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 { |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
77 int i; |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
78 USHORT *outBuf16 = (USHORT*)&outBufPtr[0]; |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
79 volatile USHORT *reg_p = (USHORT *) CL_IMEI_DIE_ID_REG; |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
80 |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
81 TRACE_FUNCTION("get_dieID()"); |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
82 |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
83 if(inBufSize < CL_IMEI_DIE_ID_SIZE){ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
84 TRACE_ERROR("CL IMEI ERROR: buffer size for Die ID to short!"); |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
85 } |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
86 #ifdef IMEI_DEBUG |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
87 TRACE_EVENT_P1("CL IMEI INFO: Die-ID address(0x%x)", CL_IMEI_DIE_ID_REG); |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
88 #endif |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
89 for (i = 0; i < CL_IMEI_DIE_ID_SIZE; i++) { |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
90 /* Die ID is 4 BYTE long, extract it to 8 BYTE. */ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
91 outBuf16[i] = (USHORT)(*(UINT8*)(reg_p)++); |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
92 } |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
93 } |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
94 |
667
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
95 #if 0 // function for reading from Pirelli's factory block not written yet |
664
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
96 /* |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
97 +------------------------------------------------------------------------------ |
667
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
98 | Function : pirelli_get_imeisv |
664
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
99 +------------------------------------------------------------------------------ |
667
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
100 | Description : This function attempts to read and decrypt a valid IMEISV |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
101 | record from Pirelli's factory data block. |
664
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
102 | |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
103 | Parameters : inBufSize - size of buffer where to store IMEI, min. 8 BYTE |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
104 | *outBufPtr - pointer to buffer where to store the IMEI |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
105 | Return : 0 - OK |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
106 | <0 - ERROR |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
107 +------------------------------------------------------------------------------ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
108 */ |
667
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
109 LOCAL BYTE pirelli_get_imeisv (USHORT inBufSize, UBYTE *outBufPtr) |
664
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
110 { |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
111 UBYTE isdid_buf[CL_IMEI_ISDID_SIZE]; |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
112 UBYTE r_dieId[CL_DES_KEY_SIZE]; /* read Die ID */ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
113 UBYTE d_dieId[CL_DES_KEY_SIZE]; /* deciphered Die ID */ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
114 SHORT ret; |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
115 |
667
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
116 TRACE_FUNCTION("pirelli_get_imeisv()"); |
664
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
117 |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
118 if(inBufSize < CL_IMEI_SIZE){ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
119 TRACE_ERROR("CL IMEI ERROR: buffer size for IMEI to short!"); |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
120 return CL_IMEI_ERROR; |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
121 } |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
122 |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
123 /* |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
124 * Read ISDID(enciphered IMEISV+DieID) from FFS. |
667
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
125 * TODO: change the code to read from Pirelli's factory data block instead |
664
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
126 */ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
127 if((ret = ffs_file_read(CL_IMEI_FFS_PATH, isdid_buf, CL_IMEI_ISDID_SIZE)) >= EFFS_OK) |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
128 { |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
129 /* |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
130 * Read Die ID for using as DES key |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
131 */ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
132 get_dieID(CL_DES_KEY_SIZE, r_dieId); |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
133 /* |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
134 * Call DES algorithm routine |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
135 */ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
136 /* decipher first 8 BYTEs */ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
137 cl_des(&isdid_buf[0], r_dieId, outBufPtr, CL_DES_DECRYPTION); |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
138 /* decipher the rest 8 BYTEs */ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
139 cl_des(&isdid_buf[CL_DES_BUFFER_SIZE], r_dieId, d_dieId, CL_DES_DECRYPTION); |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
140 if(!memcmp(d_dieId, r_dieId, CL_DES_KEY_SIZE)) |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
141 { |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
142 /* Die ID is valid */ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
143 ret = CL_IMEI_OK; |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
144 } else {/* Die ID is corrupted */ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
145 char pr_buf[126]; |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
146 TRACE_ERROR("CL IMEI ERROR: Die ID is corrupted"); |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
147 sprintf(pr_buf,"Read DieID: %02x %02x %02x %02x %02x %02x %02x %02x", |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
148 r_dieId[0], r_dieId[1], r_dieId[2], r_dieId[3], |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
149 r_dieId[4], r_dieId[5], r_dieId[6], r_dieId[7]); |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
150 TRACE_ERROR(pr_buf); |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
151 sprintf(pr_buf,"Deciphered DieID: %02x %02x %02x %02x %02x %02x %02x %02x", |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
152 d_dieId[0], d_dieId[1], d_dieId[2], d_dieId[3], |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
153 d_dieId[4], d_dieId[5], d_dieId[6], d_dieId[7]); |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
154 TRACE_ERROR(pr_buf); |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
155 |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
156 ret = CL_IMEI_INVALID_DIE_ID; |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
157 } |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
158 } else { |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
159 ret = CL_IMEI_READ_IMEI_FAILED; |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
160 } |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
161 |
667
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
162 return ret; |
664
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
163 |
667
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
164 }/* pirelli_get_imeisv() */ |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
165 #endif /* #if 0 */ |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
166 #endif /* CONFIG_TARGET_PIRELLI */ |
664
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
167 |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
168 |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
169 /* |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
170 +------------------------------------------------------------------------------ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
171 | Function : cl_get_imeisv |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
172 +------------------------------------------------------------------------------ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
173 | Description : Common IMEI getter function |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
174 | |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
175 | Parameters : imeiBufSize - size of buffer where to store IMEI, min 8 BYTEs |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
176 | *imeiBufPtr - pointer to buffer where to store the IMEI |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
177 | imeiType - indicates, if the IMEI should be read from |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
178 | FFS/Secure ROM (value=CL_IMEI_GET_SECURE_IMEI) or |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
179 | if the already read and stored IMEI (if available) |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
180 | should be delivered (value=CL_IMEI_GET_STORED_IMEI) |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
181 | The second option should be used only by ACI or |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
182 | BMI to show the IMEISV on mobile's display or |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
183 | in terminal window, e.g. if user calls *#06#. |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
184 | For IMEI Control reason (used by ACI), the value |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
185 | has to be CL_IMEI_CONTROL_IMEI |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
186 | Return : OK - 0 |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
187 | ERROR - negative values |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
188 +------------------------------------------------------------------------------ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
189 */ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
190 extern BYTE cl_get_imeisv(USHORT imeiBufSize, UBYTE *imeiBufPtr, UBYTE imeiType) |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
191 { |
667
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
192 USHORT ret; |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
193 #if CONFIG_MOKOFFS |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
194 UBYTE version; |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
195 UBYTE buf[SIZE_EF_IMEI]; |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
196 #endif |
664
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
197 |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
198 TRACE_FUNCTION("cl_get_imeisv()"); |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
199 |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
200 /* |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
201 * The user has required a stored IMEI. If it has been already read |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
202 * and stored, so return stored IMEI |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
203 */ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
204 if((imeiType == CL_IMEI_GET_STORED_IMEI) && (imei_flag == 1)){ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
205 memcpy(imeiBufPtr, stored_imei, CL_IMEI_SIZE); |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
206 return CL_IMEI_OK; |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
207 } |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
208 /* |
667
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
209 * The user has required a "secure" IMEI. How we get it depends on what |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
210 * platform we are running on. |
664
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
211 */ |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
212 |
667
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
213 #if CONFIG_MOKOFFS |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
214 /* |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
215 * Running on Openmoko GTA0x and using the original FFS. |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
216 * Get the nibble-swapped IMEI record from PCM. |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
217 */ |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
218 ret = pcm_ReadFile ((UBYTE *)EF_IMEI_ID, SIZE_EF_IMEI, buf, &version); |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
219 if(ret == PCM_OK){ |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
220 TRACE_EVENT("CL IMEI INFO: return IMEI-SV number from ffs:/pcm/IMEI"); |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
221 /* |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
222 * swap digits |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
223 */ |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
224 imeiBufPtr[0] = ((buf[0] & 0xf0) >> 4) | ((buf[0] & 0x0f) << 4); |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
225 imeiBufPtr[1] = ((buf[1] & 0xf0) >> 4) | ((buf[1] & 0x0f) << 4); |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
226 imeiBufPtr[2] = ((buf[2] & 0xf0) >> 4) | ((buf[2] & 0x0f) << 4); |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
227 imeiBufPtr[3] = ((buf[3] & 0xf0) >> 4) | ((buf[3] & 0x0f) << 4); |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
228 imeiBufPtr[4] = ((buf[4] & 0xf0) >> 4) | ((buf[4] & 0x0f) << 4); |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
229 imeiBufPtr[5] = ((buf[5] & 0xf0) >> 4) | ((buf[5] & 0x0f) << 4); |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
230 imeiBufPtr[6] = ((buf[6] & 0xf0) >> 4) | ((buf[6] & 0x0f) << 4); |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
231 imeiBufPtr[7] = ((buf[7] & 0xf0) >> 4) | ((buf[7] & 0x0f) << 4); |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
232 /* store IMEI */ |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
233 memcpy(stored_imei, imeiBufPtr, CL_IMEI_SIZE); |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
234 imei_flag = 1; |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
235 }else{ |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
236 /* |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
237 * pcm_ReadFile() can't really fail, as it merely reads out of a |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
238 * RAM buffer that was filled earlier, either from FFS or from |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
239 * compiled-in defaults. But TI's original code had the following |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
240 * error handling clause, so I kept it. |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
241 */ |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
242 TRACE_EVENT("CL IMEI INFO: return default IMEI-SV number"); |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
243 memcpy(imeiBufPtr, C_DEFAULT_IMEISV_DSAMPLE, CL_IMEI_SIZE); |
664
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
244 } |
667
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
245 return CL_IMEI_OK; |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
246 #else |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
247 |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
248 /* |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
249 * Regular FreeCalypso configuration, not MokoFFS. |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
250 * We try to get the IMEISV from the following sources, in this order: |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
251 * |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
252 * /etc/IMEISV (sensible nibble order, not encrypted) |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
253 * Pirelli's encrypted IMEI record (Pirelli target only) |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
254 * hard-coded fallback and error indication |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
255 */ |
664
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
256 |
667
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
257 ret = ffs_file_read(CL_IMEI_FFS_PATH, imeiBufPtr, CL_IMEI_SIZE); |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
258 if (ret >= EFFS_OK) { |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
259 memcpy(stored_imei, imeiBufPtr, CL_IMEI_SIZE); |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
260 imei_flag = 1; |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
261 return CL_IMEI_OK; |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
262 } |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
263 ret = CL_IMEI_READ_IMEI_FAILED; |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
264 #if CONFIG_TARGET_PIRELLI |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
265 /* not yet implemented */ |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
266 #endif |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
267 TRACE_ERROR("CL IMEI FATAL ERROR: IMEI not available!"); |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
268 memcpy(imeiBufPtr, C_DEFAULT_IMEISV_DSAMPLE, CL_IMEI_SIZE); |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
269 return ret; |
b34e5351438e
cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
664
diff
changeset
|
270 #endif /* CONFIG_MOKOFFS */ |
664
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
271 } |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
272 |
d36f647c2432
gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
273 #endif /* CL_IMEI_C */ |