annotate g23m/condat/com/src/comlib/cl_imei.c @ 48:616f63f3e501 default tip

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