FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/comlib/cl_imei.c @ 891:f3fba126778a
gsm-fw/comlib/cl_imei.c: implemented reading of Pirelli's factory IMEI record
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 29 Jun 2015 21:58:15 +0000 |
parents | b34e5351438e |
children | eed6dc6aca3c |
comparison
equal
deleted
inserted
replaced
890:452a4aea3fc5 | 891:f3fba126778a |
---|---|
90 /* Die ID is 4 BYTE long, extract it to 8 BYTE. */ | 90 /* Die ID is 4 BYTE long, extract it to 8 BYTE. */ |
91 outBuf16[i] = (USHORT)(*(UINT8*)(reg_p)++); | 91 outBuf16[i] = (USHORT)(*(UINT8*)(reg_p)++); |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 #if 0 // function for reading from Pirelli's factory block not written yet | 95 extern int pirelli_read_factory_record(uint32 offset, void *userbuf, |
96 T_FFS_SIZE size, int has_chksum); | |
97 | |
98 #define PIRELLI_IMEI_OFFSET 0x504 | |
99 | |
96 /* | 100 /* |
97 +------------------------------------------------------------------------------ | 101 +------------------------------------------------------------------------------ |
98 | Function : pirelli_get_imeisv | 102 | Function : pirelli_get_imeisv |
99 +------------------------------------------------------------------------------ | 103 +------------------------------------------------------------------------------ |
100 | Description : This function attempts to read and decrypt a valid IMEISV | 104 | Description : This function attempts to read and decrypt a valid IMEISV |
120 return CL_IMEI_ERROR; | 124 return CL_IMEI_ERROR; |
121 } | 125 } |
122 | 126 |
123 /* | 127 /* |
124 * Read ISDID(enciphered IMEISV+DieID) from FFS. | 128 * Read ISDID(enciphered IMEISV+DieID) from FFS. |
125 * TODO: change the code to read from Pirelli's factory data block instead | 129 * (changed to read from Pirelli's factory data block instead) |
126 */ | 130 */ |
127 if((ret = ffs_file_read(CL_IMEI_FFS_PATH, isdid_buf, CL_IMEI_ISDID_SIZE)) >= EFFS_OK) | 131 if((ret = pirelli_read_factory_record(PIRELLI_IMEI_OFFSET, isdid_buf, |
132 CL_IMEI_ISDID_SIZE, 0)) >= EFFS_OK) | |
128 { | 133 { |
129 /* | 134 /* |
130 * Read Die ID for using as DES key | 135 * Read Die ID for using as DES key |
131 */ | 136 */ |
132 get_dieID(CL_DES_KEY_SIZE, r_dieId); | 137 get_dieID(CL_DES_KEY_SIZE, r_dieId); |
160 } | 165 } |
161 | 166 |
162 return ret; | 167 return ret; |
163 | 168 |
164 }/* pirelli_get_imeisv() */ | 169 }/* pirelli_get_imeisv() */ |
165 #endif /* #if 0 */ | |
166 #endif /* CONFIG_TARGET_PIRELLI */ | 170 #endif /* CONFIG_TARGET_PIRELLI */ |
167 | 171 |
168 | 172 |
169 /* | 173 /* |
170 +------------------------------------------------------------------------------ | 174 +------------------------------------------------------------------------------ |
258 if (ret >= EFFS_OK) { | 262 if (ret >= EFFS_OK) { |
259 memcpy(stored_imei, imeiBufPtr, CL_IMEI_SIZE); | 263 memcpy(stored_imei, imeiBufPtr, CL_IMEI_SIZE); |
260 imei_flag = 1; | 264 imei_flag = 1; |
261 return CL_IMEI_OK; | 265 return CL_IMEI_OK; |
262 } | 266 } |
267 #if CONFIG_TARGET_PIRELLI | |
268 ret = pirelli_get_imeisv (imeiBufSize, imeiBufPtr); | |
269 if (ret == CL_IMEI_OK) { | |
270 imei_flag = 1; | |
271 return ret; | |
272 } | |
273 #else | |
263 ret = CL_IMEI_READ_IMEI_FAILED; | 274 ret = CL_IMEI_READ_IMEI_FAILED; |
264 #if CONFIG_TARGET_PIRELLI | |
265 /* not yet implemented */ | |
266 #endif | 275 #endif |
267 TRACE_ERROR("CL IMEI FATAL ERROR: IMEI not available!"); | 276 TRACE_ERROR("CL IMEI FATAL ERROR: IMEI not available!"); |
268 memcpy(imeiBufPtr, C_DEFAULT_IMEISV_DSAMPLE, CL_IMEI_SIZE); | 277 memcpy(imeiBufPtr, C_DEFAULT_IMEISV_DSAMPLE, CL_IMEI_SIZE); |
269 return ret; | 278 return ret; |
270 #endif /* CONFIG_MOKOFFS */ | 279 #endif /* CONFIG_MOKOFFS */ |