annotate gsm-fw/comlib/cl_imei.c @ 1009:009d5bf2ff4c

rvinterf/lowlevel: formatting of FC-specific packet types split off into format_fc.c
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Sun, 20 Mar 2016 20:23:54 +0000
parents eed6dc6aca3c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
891
f3fba126778a gsm-fw/comlib/cl_imei.c: implemented reading of Pirelli's factory IMEI record
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 667
diff changeset
95 extern int pirelli_read_factory_record(uint32 offset, void *userbuf,
f3fba126778a gsm-fw/comlib/cl_imei.c: implemented reading of Pirelli's factory IMEI record
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 667
diff changeset
96 T_FFS_SIZE size, int has_chksum);
f3fba126778a gsm-fw/comlib/cl_imei.c: implemented reading of Pirelli's factory IMEI record
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 667
diff changeset
97
f3fba126778a gsm-fw/comlib/cl_imei.c: implemented reading of Pirelli's factory IMEI record
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 667
diff changeset
98 #define PIRELLI_IMEI_OFFSET 0x504
f3fba126778a gsm-fw/comlib/cl_imei.c: implemented reading of Pirelli's factory IMEI record
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 667
diff changeset
99
664
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
100 /*
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
101 +------------------------------------------------------------------------------
667
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
102 | Function : pirelli_get_imeisv
664
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
103 +------------------------------------------------------------------------------
667
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
104 | 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
105 | 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
106 |
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
107 | 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
108 | *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
109 | Return : 0 - OK
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
110 | <0 - ERROR
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
111 +------------------------------------------------------------------------------
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
112 */
667
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
113 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
114 {
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
115 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
116 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
117 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
118 SHORT ret;
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
119
667
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
120 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
121
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
122 if(inBufSize < CL_IMEI_SIZE){
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
123 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
124 return CL_IMEI_ERROR;
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
125 }
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 /*
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
128 * Read ISDID(enciphered IMEISV+DieID) from FFS.
891
f3fba126778a gsm-fw/comlib/cl_imei.c: implemented reading of Pirelli's factory IMEI record
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 667
diff changeset
129 * (changed 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
130 */
891
f3fba126778a gsm-fw/comlib/cl_imei.c: implemented reading of Pirelli's factory IMEI record
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 667
diff changeset
131 if((ret = pirelli_read_factory_record(PIRELLI_IMEI_OFFSET, isdid_buf,
f3fba126778a gsm-fw/comlib/cl_imei.c: implemented reading of Pirelli's factory IMEI record
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 667
diff changeset
132 CL_IMEI_ISDID_SIZE, 0)) >= EFFS_OK)
664
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 /*
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
135 * 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
136 */
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
137 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
138 /*
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
139 * Call DES algorithm routine
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
140 */
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
141 /* decipher first 8 BYTEs */
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
142 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
143 /* decipher the rest 8 BYTEs */
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
144 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
145 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
146 {
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
147 /* Die ID is valid */
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
148 ret = CL_IMEI_OK;
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
149 } else {/* Die ID is corrupted */
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
150 char pr_buf[126];
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
151 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
152 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
153 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
154 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
155 TRACE_ERROR(pr_buf);
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
156 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
157 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
158 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
159 TRACE_ERROR(pr_buf);
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 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
162 }
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
163 } else {
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
164 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
165 }
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
166
667
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
167 return ret;
664
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
168
667
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
169 }/* pirelli_get_imeisv() */
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
170 #endif /* CONFIG_TARGET_PIRELLI */
664
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
171
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 /*
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 | Function : cl_get_imeisv
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
176 +------------------------------------------------------------------------------
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
177 | Description : Common IMEI getter function
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
178 |
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
179 | 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
180 | *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
181 | 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
182 | 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
183 | 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
184 | 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
185 | 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
186 | 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
187 | 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
188 | 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
189 | 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
190 | Return : OK - 0
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
191 | ERROR - negative values
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
192 +------------------------------------------------------------------------------
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
193 */
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
194 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
195 {
892
eed6dc6aca3c gsm-fw/comlib/cl_imei.c: hell with TI's different return code types
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 891
diff changeset
196 #if CONFIG_MOKOFFS
667
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
197 USHORT ret;
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
198 UBYTE version;
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
199 UBYTE buf[SIZE_EF_IMEI];
892
eed6dc6aca3c gsm-fw/comlib/cl_imei.c: hell with TI's different return code types
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 891
diff changeset
200 #else
eed6dc6aca3c gsm-fw/comlib/cl_imei.c: hell with TI's different return code types
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 891
diff changeset
201 BYTE ret;
667
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
202 #endif
664
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 TRACE_FUNCTION("cl_get_imeisv()");
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
205
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
206 /*
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
207 * 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
208 * 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
209 */
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
210 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
211 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
212 return CL_IMEI_OK;
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
213 }
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
214 /*
667
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
215 * 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
216 * 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
217 */
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
218
667
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
219 #if CONFIG_MOKOFFS
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
220 /*
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
221 * 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
222 * 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
223 */
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
224 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
225 if(ret == PCM_OK){
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
226 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
227 /*
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
228 * swap digits
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
229 */
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
230 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
231 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
232 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
233 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
234 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
235 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
236 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
237 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
238 /* store IMEI */
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
239 memcpy(stored_imei, imeiBufPtr, CL_IMEI_SIZE);
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
240 imei_flag = 1;
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
241 }else{
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
242 /*
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
243 * 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
244 * 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
245 * 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
246 * error handling clause, so I kept it.
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 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
249 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
250 }
667
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
251 return CL_IMEI_OK;
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
252 #else
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
253
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
254 /*
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
255 * Regular FreeCalypso configuration, not MokoFFS.
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
256 * 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
257 *
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
258 * /etc/IMEISV (sensible nibble order, not encrypted)
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
259 * 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
260 * hard-coded fallback and error indication
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
261 */
664
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
262
892
eed6dc6aca3c gsm-fw/comlib/cl_imei.c: hell with TI's different return code types
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 891
diff changeset
263 if (ffs_file_read(CL_IMEI_FFS_PATH, imeiBufPtr, CL_IMEI_SIZE) >= EFFS_OK) {
667
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
264 memcpy(stored_imei, imeiBufPtr, CL_IMEI_SIZE);
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
265 imei_flag = 1;
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
266 return CL_IMEI_OK;
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
267 }
891
f3fba126778a gsm-fw/comlib/cl_imei.c: implemented reading of Pirelli's factory IMEI record
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 667
diff changeset
268 #if CONFIG_TARGET_PIRELLI
f3fba126778a gsm-fw/comlib/cl_imei.c: implemented reading of Pirelli's factory IMEI record
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 667
diff changeset
269 ret = pirelli_get_imeisv (imeiBufSize, imeiBufPtr);
f3fba126778a gsm-fw/comlib/cl_imei.c: implemented reading of Pirelli's factory IMEI record
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 667
diff changeset
270 if (ret == CL_IMEI_OK) {
f3fba126778a gsm-fw/comlib/cl_imei.c: implemented reading of Pirelli's factory IMEI record
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 667
diff changeset
271 imei_flag = 1;
f3fba126778a gsm-fw/comlib/cl_imei.c: implemented reading of Pirelli's factory IMEI record
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 667
diff changeset
272 return ret;
f3fba126778a gsm-fw/comlib/cl_imei.c: implemented reading of Pirelli's factory IMEI record
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 667
diff changeset
273 }
f3fba126778a gsm-fw/comlib/cl_imei.c: implemented reading of Pirelli's factory IMEI record
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 667
diff changeset
274 #else
667
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
275 ret = CL_IMEI_READ_IMEI_FAILED;
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
276 #endif
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
277 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
278 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
279 return ret;
b34e5351438e cl_imei.[ch]: revamped for FreeCalypso
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 664
diff changeset
280 #endif /* CONFIG_MOKOFFS */
664
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
281 }
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
282
d36f647c2432 gsm-fw/comlib: initial import of TI's source
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
283 #endif /* CL_IMEI_C */