FreeCalypso > hg > freecalypso-citrine
changeset 34:2fc925048350
comlib/cl_imei.c: new universal FreeCalypso IMEI finding scheme
consistent across all targets and all fw versions
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 15 Oct 2016 04:43:35 +0000 |
parents | 6a2b09d3b1b4 |
children | 23dbd942aa56 |
files | comlib/cl_imei.c |
diffstat | 1 files changed, 13 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/comlib/cl_imei.c Sat Oct 15 04:23:58 2016 +0000 +++ b/comlib/cl_imei.c Sat Oct 15 04:43:35 2016 +0000 @@ -193,13 +193,8 @@ */ extern BYTE cl_get_imeisv(USHORT imeiBufSize, UBYTE *imeiBufPtr, UBYTE imeiType) { -#if CONFIG_MOKOFFS - USHORT ret; - UBYTE version; UBYTE buf[SIZE_EF_IMEI]; -#else BYTE ret; -#endif TRACE_FUNCTION("cl_get_imeisv()"); @@ -211,18 +206,21 @@ memcpy(imeiBufPtr, stored_imei, CL_IMEI_SIZE); return CL_IMEI_OK; } + /* - * The user has required a "secure" IMEI. How we get it depends on what - * platform we are running on. + * The user has required a "secure" IMEI. Look in /etc/IMEISV first, + * then in /pcm/IMEI. And if we are running on the Pirelli target, + * try their factory IMEI record last. */ -#if CONFIG_MOKOFFS - /* - * Running on Openmoko GTA0x and using the original FFS. - * Get the nibble-swapped IMEI record from PCM. - */ - ret = pcm_ReadFile ((UBYTE *)EF_IMEI_ID, SIZE_EF_IMEI, buf, &version); - if(ret == PCM_OK){ + if (ffs_file_read(CL_IMEI_FFS_PATH, imeiBufPtr, CL_IMEI_SIZE) >= EFFS_OK) { + TRACE_EVENT("CL IMEI INFO: return IMEI-SV number from ffs:/etc/IMEISV"); + memcpy(stored_imei, imeiBufPtr, CL_IMEI_SIZE); + imei_flag = 1; + return CL_IMEI_OK; + } + + if (ffs_file_read("/pcm/IMEI", buf, CL_IMEI_SIZE) >= EFFS_OK) { TRACE_EVENT("CL IMEI INFO: return IMEI-SV number from ffs:/pcm/IMEI"); /* * swap digits @@ -238,33 +236,9 @@ /* store IMEI */ memcpy(stored_imei, imeiBufPtr, CL_IMEI_SIZE); imei_flag = 1; - }else{ - /* - * pcm_ReadFile() can't really fail, as it merely reads out of a - * RAM buffer that was filled earlier, either from FFS or from - * compiled-in defaults. But TI's original code had the following - * error handling clause, so I kept it. - */ - TRACE_EVENT("CL IMEI INFO: return default IMEI-SV number"); - memcpy(imeiBufPtr, C_DEFAULT_IMEISV_DSAMPLE, CL_IMEI_SIZE); - } - return CL_IMEI_OK; -#else - - /* - * Regular FreeCalypso configuration, not MokoFFS. - * We try to get the IMEISV from the following sources, in this order: - * - * /etc/IMEISV (sensible nibble order, not encrypted) - * Pirelli's encrypted IMEI record (Pirelli target only) - * hard-coded fallback and error indication - */ - - if (ffs_file_read(CL_IMEI_FFS_PATH, imeiBufPtr, CL_IMEI_SIZE) >= EFFS_OK) { - memcpy(stored_imei, imeiBufPtr, CL_IMEI_SIZE); - imei_flag = 1; return CL_IMEI_OK; } + #if CONFIG_TARGET_PIRELLI ret = pirelli_get_imeisv (imeiBufSize, imeiBufPtr); if (ret == CL_IMEI_OK) { @@ -278,7 +252,6 @@ TRACE_ERROR("CL IMEI FATAL ERROR: IMEI not available!"); memcpy(imeiBufPtr, C_DEFAULT_IMEISV_DSAMPLE, CL_IMEI_SIZE); return ret; -#endif /* CONFIG_MOKOFFS */ } #endif /* CL_IMEI_C */