# HG changeset patch # User Michael Spacefalcon # Date 1385359939 0 # Node ID f9ac53d8e99911bfc07cbae66a9c2c8fca6af625 # Parent 707aa640b2dce0abd8a4887583b262d7c1261149 gsm-fw/services/etm: etm_get16(): fix for bad C (sequence points violation) while at it, fixed echo and dieid as well diff -r 707aa640b2dc -r f9ac53d8e999 gsm-fw/services/etm/etm_api.c --- a/gsm-fw/services/etm/etm_api.c Mon Nov 25 05:37:46 2013 +0000 +++ b/gsm-fw/services/etm/etm_api.c Mon Nov 25 06:12:19 2013 +0000 @@ -145,8 +145,7 @@ { unsigned char *p = buf; - int value = - (*p++ | (*p << 8)); + int value = (p[0] | (p[1] << 8)); tr_etm(TgTrEtmLow, "ETM API: _get16(%d)", value); diff -r 707aa640b2dc -r f9ac53d8e999 gsm-fw/services/etm/etm_tmcore.c --- a/gsm-fw/services/etm/etm_tmcore.c Mon Nov 25 05:37:46 2013 +0000 +++ b/gsm-fw/services/etm/etm_tmcore.c Mon Nov 25 06:12:19 2013 +0000 @@ -41,8 +41,6 @@ * DIE ID settings *****************************************************************************/ -#define BE_STREAM_TO_ARRAY(a, p, l) {register INT32 i; for (i = 0; i < l; i++) a[i] = *(UINT8*)(p)++;} - /* DIE ID register */ #if ((CHIPSET == 8) || (CHIPSET == 10) || (CHIPSET == 11)) //For D-Sample: $CHIPSET = 8 (=10 for D-sample AMR, 11 for GSMLITE). #define DIE_ID_REG (MEM_DEV_ID0 | 0xF010) //+ 0xFFFEF010 for Calypso @@ -55,9 +53,6 @@ /* DIE ID SIZE is 4 words (16 bits)long */ #define DIE_ID_SIZE 4 -//Copied from rv_general.h: -//#define BE_STREAM_TO_ARRAY(a, p, l) {register INT32 i; for (i = 0; i < l; i++) a[i] = *(UINT16*)(p)++;} - /****************************************************************************** * Internal prototypes @@ -247,7 +242,7 @@ //structur of data dl: |delay|recvsize|num| = 3x2 bytes int etm_echo(T_ETM_PKT *pkt, uint8 *data) { - int delay, sendsize, i, num, count; + int delay, sendsize, i; tr_etm(TgTrCore, "etm_echo:"); @@ -258,21 +253,18 @@ if (sendsize > 240) return ETM_INVAL; - data += 2; - num = etm_get16(data); - - tr_etm(TgTrCore, "ETM CORE: _echo: delay(%d) sendsize(%d) num(%d)", - delay, sendsize, num); + tr_etm(TgTrCore, "ETM CORE: _echo: delay(%d) sendsize(%d)", + delay, sendsize); if (delay > 0) { rvf_delay((delay + 32) * 14 / 64); } - + for (i = 0; i < sendsize; i++) { pkt->data[i+1] = i; // data[0] = fid } - pkt->size = sendsize; + pkt->size = sendsize + 1; return ETM_OK; } @@ -440,24 +432,19 @@ int etm_dieID_read(T_ETM_PKT *pkt, uint8 *inbuf) { T_RV_RET result; - int8 byteCount; - UINT16 dieID[DIE_ID_SIZE]; - int16 index; + int8 i; + UINT16 val; volatile UINT16 *reg_p = (UINT16 *) DIE_ID_REG; - + tr_etm(TgTrCore, "ETM CORE: _dieID_read: started - Die-ID address(0x%x)", DIE_ID_REG); - - BE_STREAM_TO_ARRAY(dieID, reg_p, DIE_ID_SIZE); - - for (byteCount = 0; byteCount < DIE_ID_SIZE; byteCount++) { - tr_etm(TgTrCore, "ETM CORE: Die-ID[%i] Byte Read(0x%x)", byteCount, (UINT16)dieID[byteCount]); - result = etm_pkt_put16(pkt, (UINT8)(((dieID[byteCount]) & 0xFFFF))); + for (i = 0; i < DIE_ID_SIZE; i++) { + val = *reg_p++; + result = etm_pkt_put16(pkt, val); if (result < 0) return result; } - return ETM_OK; } @@ -470,6 +457,18 @@ { // Structur of protocol data dl-link: |fid|index|data| +/* + * As the comments below imply, the opcodes for tmcore commands used + * to be mnemonic ASCII letters, but then at some point for some + * non-understood reason TI decided to change them to the current set. + * + * I thought about changing back to the old opcodes for FreeCalypso, + * but given that all of the available existing firmwares (mokoN, the + * already-released leo2moko-r1, and Pirelli's fw) use the "new" opcodes, + * I've decided to stick with the same for consistency, and let our + * fc-tmsh work with both our own fw and the available pre-existing ones. + */ + uint8 mid; uint8 fid; int error = 0;