annotate gsm-fw/services/etm/etm_tmcore.c @ 183:85222710dc92

rvinterf/etm: implemented everything except the packet sending command
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 24 Nov 2013 08:03:27 +0000
parents 13af69b6a3dc
children f9ac53d8e999
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
164
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /********************************************************************************
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * Enhanced TestMode (ETM)
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 * @file tmcore.c
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 *
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 * @author Kim T. Peteren (ktp@ti.com)
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 * @version 0.1
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 *
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 *
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 * History:
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 *
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 * Date Modification
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 * ------------------------------------
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 * 16/06/2003 Creation
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 * 02/07/2003 Removed l1_config.TestMode check from CODEC Write
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 * 17/03/2004 Updated etm_version
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 * 30/03/2004 Updated etm_dieID_read() func. regarding get die id for 16 bits
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 * instead of 8 bits.
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 *
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 * (C) Copyright 2003 by Texas Instruments Incorporated, All Rights Reserved
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 *********************************************************************************/
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22
166
13af69b6a3dc ETM core compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 164
diff changeset
23 #include "../../riviera/rv/rv_defined_swe.h"
13af69b6a3dc ETM core compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 164
diff changeset
24 #include "../../riviera/rv/rv_general.h"
164
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25
166
13af69b6a3dc ETM core compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 164
diff changeset
26 #include "etm.h"
13af69b6a3dc ETM core compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 164
diff changeset
27 #include "etm_config.h"
13af69b6a3dc ETM core compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 164
diff changeset
28 #include "etm_api.h"
13af69b6a3dc ETM core compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 164
diff changeset
29 #include "etm_trace.h"
13af69b6a3dc ETM core compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 164
diff changeset
30 #include "etm_version.h"
164
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31
166
13af69b6a3dc ETM core compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 164
diff changeset
32 #include "../../bsp/abb+spi/abb.h"
13af69b6a3dc ETM core compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 164
diff changeset
33 #include "../../bsp/abb+spi/spi_drv.h"
164
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 extern void tr_etm_init(unsigned int mask);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 // Version of the ETM CORE module
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 // See the file etm_version.h
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 /******************************************************************************
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 * DIE ID settings
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 *****************************************************************************/
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 #define BE_STREAM_TO_ARRAY(a, p, l) {register INT32 i; for (i = 0; i < l; i++) a[i] = *(UINT8*)(p)++;}
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 /* DIE ID register */
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 #if ((CHIPSET == 8) || (CHIPSET == 10) || (CHIPSET == 11)) //For D-Sample: $CHIPSET = 8 (=10 for D-sample AMR, 11 for GSMLITE).
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 #define DIE_ID_REG (MEM_DEV_ID0 | 0xF010) //+ 0xFFFEF010 for Calypso
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 #else
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 #if (CHIPSET == 12) //For E-Sample: $CHIPSET = 12.
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 #define DIE_ID_REG (0xFFFE0000 | 0xF004) //+ 0xFFFEF004 for Calypso Plus
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52 #endif
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 #endif
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 /* DIE ID SIZE is 4 words (16 bits)long */
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 #define DIE_ID_SIZE 4
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58 //Copied from rv_general.h:
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 //#define BE_STREAM_TO_ARRAY(a, p, l) {register INT32 i; for (i = 0; i < l; i++) a[i] = *(UINT16*)(p)++;}
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 /******************************************************************************
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 * Internal prototypes
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64 *****************************************************************************/
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 T_ETM_PKT *etm_core_setup(uint8 fid);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67 int etm_core(uint8 *buf, int size);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
68
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
69 /******************************************************************************
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
70 * Register the Core Module to the ETM database
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
71 *****************************************************************************/
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
72
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73 int etm_core_init(void)
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
74 {
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
75 int result;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
76
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
77 result = etm_register("CORE", ETM_CORE, 0, 0, etm_core);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
78 return result;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
79 }
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
80
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
81
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
82 /******************************************************************************
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
83 * Memory read/write Functions
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
84 *****************************************************************************/
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
85
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
86 // Describe the payload of the mem protocol !!!!!!
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
87 // |--type(1)-|--partnum(1)-|--addr(4)-|--data(?)-|
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
88
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
89 int etm_mem(T_ETM_PKT *pkt, uint8 *buf)
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
90 {
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
91 int num, unitsize, error;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
92 uint8 type, param;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
93 uint8 *mem8;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
94 uint16 *mem16;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
95 uint32 *mem32;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
96 uint32 addr, tmp;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
97
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
98 param = unitsize = *buf & 0x3;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
99 if (unitsize == 0)
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
100 unitsize = 4;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
101
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
102 type = *buf & 0x10;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
103 buf++;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
104
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
105 num = *buf++;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
106 addr = etm_get32(buf);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
107 buf += 4;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
108
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
109 tr_etm(TgTrCore, "ETM CORE: _mem: type(0x%x) addr(0x%x) partnum(%d)", type, addr, num);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
110
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
111 // Put 'parameter' in return packet
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
112 if ((error = etm_pkt_put8(pkt, param)) < 0) {
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
113 return error;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
114 }
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
115
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
116 switch (type) {
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
117 case 0: // READ(0x00)
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
118 switch (unitsize) {
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
119 case 1:
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
120 mem8 = (uint8 *) addr;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
121 while (num--) {
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
122 if ((error = etm_pkt_put8(pkt, *mem8++)) < 0)
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
123 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
124 }
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
125 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
126 case 2:
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
127 mem16 = (uint16 *) addr;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
128 while (num--) {
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
129 if ((error = etm_pkt_put16(pkt, *mem16++)) < 0)
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
130 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
131 }
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
132 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
133 case 4:
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
134 mem32 = (uint32 *) addr;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
135 while (num--) {
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
136 if ((error = etm_pkt_put32(pkt, *mem32++)) < 0)
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
137 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
138 }
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
139 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
140 }
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
141 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
142
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
143 case 16: // WRITE(0x10)
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
144 switch (unitsize) {
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
145 case 1:
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
146 mem8 = (uint8 *) addr;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
147 while (num--) {
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
148 *mem8++ = etm_get8(buf);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
149 buf += 1;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
150 }
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
151 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
152 case 2:
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
153 mem16 = (uint16 *) addr;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
154 while (num--) {
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
155 *mem16++ = tmp = etm_get16(buf);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
156 buf += 2;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
157 }
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
158 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
159 case 4:
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
160 mem32 = (uint32 *) addr;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
161 while (num--) {
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
162 *mem32++ = etm_get32(buf);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
163 buf += 4;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
164 }
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
165 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
166 }
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
167 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
168 default:
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
169 return ETM_NOSYS;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
170 }
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
171
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
172 if (error < 0)
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
173 return error;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
174
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
175 return ETM_OK;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
176 }
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
177
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
178
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
179 /******************************************************************************
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
180 * CODEC Functions
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
181 *****************************************************************************/
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
182
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
183 // ETM sends both page value and register address in one byte.
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
184 // Bit field is: PPPR RRRR
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
185 // where P = page bit, R = register address bits and X = don't care bits.
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
186
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
187 int etm_codec_write(T_ETM_PKT *pkt, uint8 *buf)
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
188 {
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
189 uint16 page, reg, data;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
190 int result, reg_data;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
191
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
192 reg_data = *buf++;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
193 if ((result = etm_pkt_put8(pkt, reg_data)) < 0)
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
194 return result;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
195
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
196 page = (reg_data >> 5) & 0x3;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
197 reg = reg_data & 0x1F;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
198 data = etm_get16(buf);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
199
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
200 tr_etm(TgTrCore, "ETM CORE: _codec_write: page(%d) reg(%d) data(0x%x)",
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
201 page, reg, (data & 0x3ff));
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
202
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
203 if (page > 7 && reg > 32)
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
204 return ETM_INVAL;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
205 else {
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
206 // The function below expects a 1 for page 0 and a 2 for page 1.
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
207 // The register address value is left-shifted by 1 since LSB is read/write command bit.
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
208 // The value is written in the 10 MSB's of register.
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
209 ABB_Write_Register_on_page(page + 1, reg << 1, (data & 0x3ff));
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
210 }
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
211
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
212 return ETM_OK;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
213 }
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
214
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
215
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
216 int etm_codec_read(T_ETM_PKT *pkt, uint8 *buf)
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
217 {
166
13af69b6a3dc ETM core compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 164
diff changeset
218 uint16 value;
164
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
219 uint16 page, reg;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
220 int result, reg_data;
166
13af69b6a3dc ETM core compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 164
diff changeset
221
164
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
222 reg_data = *buf;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
223 if ((result = etm_pkt_put8(pkt, reg_data)) < 0)
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
224 return result;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
225
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
226 page = (reg_data >> 5) & 0x3;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
227 reg = reg_data & 0x1F;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
228
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
229 if (page > 7 && reg > 32)
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
230 return ETM_INVAL;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
231
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
232 // The function below expects a 1 for page 0 and a 2 for page 1.
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
233 // The register value is left-shifted by 1 since LSB is read/write command bit.
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
234 value = ABB_Read_Register_on_page(page + 1, (reg << 1));
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
235
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
236 tr_etm(TgTrCore, "ETM CORE: _codec_read: page(%d) reg(%d) value(0x%x)", page, reg, value);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
237
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
238 result = etm_pkt_put16(pkt, value);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
239 return result;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
240 }
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
241
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
242
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
243 /******************************************************************************
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
244 * Echo and Reset Functions
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
245 *****************************************************************************/
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
246
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
247 //structur of data dl: |delay|recvsize|num| = 3x2 bytes
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
248 int etm_echo(T_ETM_PKT *pkt, uint8 *data)
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
249 {
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
250 int delay, sendsize, i, num, count;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
251
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
252 tr_etm(TgTrCore, "etm_echo:");
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
253
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
254 delay = etm_get16(data);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
255 data += 2;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
256
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
257 sendsize = etm_get16(data);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
258 if (sendsize > 240)
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
259 return ETM_INVAL;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
260
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
261 data += 2;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
262 num = etm_get16(data);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
263
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
264 tr_etm(TgTrCore, "ETM CORE: _echo: delay(%d) sendsize(%d) num(%d)",
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
265 delay, sendsize, num);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
266
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
267 if (delay > 0) {
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
268 rvf_delay((delay + 32) * 14 / 64);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
269 }
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
270
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
271 for (i = 0; i < sendsize; i++) {
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
272 pkt->data[i+1] = i; // data[0] = fid
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
273 }
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
274
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
275 pkt->size = sendsize;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
276
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
277 return ETM_OK;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
278 }
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
279
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
280
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
281 int etm_reset(void)
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
282 {
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
283 // The reset code is taken form Fluid->cmd.c
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
284 int i;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
285
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
286 tr_etm(TgTrCore, "ETM CORE: _reset: Target is Reset");
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
287
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
288 // Setup watchdog timer and let it timeout to make a reset
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
289 *(volatile uint16*) 0xfffff804 = 0xFFFF; // Timer to watchdog
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
290 *(volatile uint16*) 0xfffff800 = 0x0080; // Start timer
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
291 // Apparently works it only if we read this register?
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
292 i = *(volatile uint16*) 0xfffff802;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
293 *(volatile uint16*) 0xfffff802 = 0x0001; // Load timer
166
13af69b6a3dc ETM core compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 164
diff changeset
294
164
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
295 return ETM_OK;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
296 }
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
297
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
298
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
299 /******************************************************************************
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
300 * Set Test Controls
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
301 *****************************************************************************/
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
302
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
303 int etm_debug(T_ETM_PKT *pkt, uint8 *buf)
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
304 {
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
305 int type, error, data;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
306
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
307 static char *p;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
308
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
309 type = *buf & 0x0F;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
310 buf++;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
311
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
312 data = etm_get32(buf);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
313
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
314 tr_etm(TgTrCore, "ETM CORE: _debug: type(%d) data(0x%x)", type, data);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
315
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
316 switch (type) {
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
317 case 0: // (0x00) Allocate Test Buffer
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
318 if ((p = etm_malloc(data)) == NULL)
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
319 error = ETM_NOMEM;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
320 error = etm_pkt_put32(pkt, (int) p);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
321 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
322 case 1: // (0x01) Free Test Buffer.
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
323 p = (char *) data;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
324 etm_free(p);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
325 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
326 case 2: // (0x02) Set ETM Trace mask
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
327 tr_etm_init(data);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
328 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
329 case 3: // (0x03) Set read all mem banks stat
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
330 rvf_dump_mem();
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
331 rvf_dump_pool();
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
332 rvf_dump_tasks();
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
333 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
334 default:
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
335 error = ETM_NOSYS;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
336 }
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
337
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
338 if (error < 0)
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
339 return error;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
340
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
341 return ETM_OK;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
342 }
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
343
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
344 /******************************************************************************
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
345 * Get Version of ...
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
346 *****************************************************************************/
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
347 // This is in development ...
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
348
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
349 int etm_version(T_ETM_PKT *pkt, uint8 *buf)
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
350 {
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
351 extern uint16 etm_audio_revision;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
352 extern uint16 etm_task_revision;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
353 int error, fid, ffs_tm_version;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
354 volatile int revision = 0;
166
13af69b6a3dc ETM core compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 164
diff changeset
355 #if 0
164
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
356 T_VERSION *l1s_version;
166
13af69b6a3dc ETM core compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 164
diff changeset
357 #endif
164
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
358
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
359 fid = etm_get32(buf);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
360
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
361 tr_etm(TgTrCore, "ETM CORE: _version: fid(0x%x)", fid);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
362
166
13af69b6a3dc ETM core compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 164
diff changeset
363 #if 0
164
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
364 l1s_version = (T_VERSION*) l1s_get_version();
166
13af69b6a3dc ETM core compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 164
diff changeset
365 #endif
164
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
366
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
367 switch (fid) {
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
368 // Code Versions related to ETM modules
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
369 case SW_REV_ETM_CORE:
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
370 error = etm_pkt_put32(pkt, ETM_CORE_VERSION);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
371 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
372 case SW_REV_ETM_AUDIO:
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
373 error = etm_pkt_put32(pkt, ETM_AUDIO_VERSION);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
374 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
375 // case SW_REV_ETM_FFS:
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
376 // ffs_query(Q_FFS_TM_VERSION, &ffs_tm_version);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
377 // error = etm_pkt_put32(pkt, ffs_tm_version);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
378 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
379 // case SW_REV_ETM_RF: // Layer1 Testmode Version
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
380 // error = etm_pkt_put32(pkt, TESTMODEVERSION);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
381 // break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
382 case SW_REV_ETM_PWR:
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
383 error = etm_pkt_put32(pkt, ETM_PWR_VERSION);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
384 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
385 case SW_REV_ETM_BT:
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
386 error = ETM_NOSYS;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
387 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
388 case SW_REV_ETM_TASK:
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
389 error = etm_pkt_put32(pkt, ETM_VERSION);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
390 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
391 case SW_REV_ETM_API:
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
392 error = etm_pkt_put32(pkt, ETM_API_VERSION);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
393 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
394 // Code Versions related to L1, see in l1_defty.h
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
395 // Get the version on this way "revision = l1s.version.dsp_code_version;"
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
396 // doesn't work because of struct aligment -> compile flag -mw !!!!
166
13af69b6a3dc ETM core compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 164
diff changeset
397 #if 0
164
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
398 case SW_DSP_CODE_VERSION:
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
399 revision = ((T_VERSION*) l1s_version)->dsp_code_version;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
400 error = etm_pkt_put32(pkt, revision);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
401 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
402 case SW_DSP_PATCH_VERSION:
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
403 revision = ((T_VERSION*) l1s_version)->dsp_patch_version;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
404 error = etm_pkt_put32(pkt, revision);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
405 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
406 case SW_MCU_TCS_PROGRAM_RELEASE:
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
407 revision = ((T_VERSION*) l1s_version)->mcu_tcs_program_release;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
408 error = etm_pkt_put32(pkt, revision);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
409 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
410 case SW_MCU_TCS_OFFICIAL: // This version allso identify version of Layer1
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
411 revision = ((T_VERSION*) l1s_version)->mcu_tcs_official;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
412 error = etm_pkt_put32(pkt, revision);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
413 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
414 case SW_MCU_TCS_INTERNAL:
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
415 revision = ((T_VERSION*) l1s_version)->mcu_tcs_internal;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
416 error = etm_pkt_put32(pkt, revision);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
417 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
418 case SW_MCU_TM_VERSION:
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
419 revision = ((T_VERSION*) l1s_version)->mcu_tm_version;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
420 error = etm_pkt_put32(pkt, revision);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
421 break;
166
13af69b6a3dc ETM core compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 164
diff changeset
422 #endif
164
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
423 default:
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
424 error = ETM_NOSYS;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
425 }
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
426
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
427 tr_etm(TgTrCore, "ETM CORE: _version: version(%d)", revision);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
428
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
429 if (error < 0)
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
430 return error;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
431
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
432 return ETM_OK;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
433 }
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
434
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
435
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
436 /******************************************************************************
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
437 * Function for reading the Die-ID from base band processor.
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
438 *****************************************************************************/
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
439
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
440 int etm_dieID_read(T_ETM_PKT *pkt, uint8 *inbuf)
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
441 {
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
442 T_RV_RET result;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
443 int8 byteCount;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
444 UINT16 dieID[DIE_ID_SIZE];
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
445 int16 index;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
446 volatile UINT16 *reg_p = (UINT16 *) DIE_ID_REG;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
447
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
448 tr_etm(TgTrCore, "ETM CORE: _dieID_read: started - Die-ID address(0x%x)", DIE_ID_REG);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
449
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
450 BE_STREAM_TO_ARRAY(dieID, reg_p, DIE_ID_SIZE);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
451
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
452 for (byteCount = 0; byteCount < DIE_ID_SIZE; byteCount++) {
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
453
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
454 tr_etm(TgTrCore, "ETM CORE: Die-ID[%i] Byte Read(0x%x)", byteCount, (UINT16)dieID[byteCount]);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
455 result = etm_pkt_put16(pkt, (UINT8)(((dieID[byteCount]) & 0xFFFF)));
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
456 if (result < 0)
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
457 return result;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
458 }
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
459
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
460
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
461 return ETM_OK;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
462 }
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
463
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
464
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
465 /******************************************************************************
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
466 * ETM CORE Main Function - Module
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
467 *****************************************************************************/
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
468
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
469 int etm_core(uint8 *buf, int size)
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
470 {
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
471 // Structur of protocol data dl-link: |fid|index|data|
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
472
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
473 uint8 mid;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
474 uint8 fid;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
475 int error = 0;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
476 T_ETM_PKT *pkt = NULL;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
477
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
478 fid = *buf++;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
479
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
480 tr_etm(TgTrCore, "ETM CORE: _core: fid(%c):", fid);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
481
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
482 /* Create TestMode return Packet */
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
483 if ((pkt = (T_ETM_PKT *) etm_malloc(sizeof(T_ETM_PKT))) == NULL) {
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
484 return ETM_NOMEM;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
485 }
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
486
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
487 // Init. of return packet
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
488 pkt->mid = ETM_CORE;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
489 pkt->status = ETM_OK;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
490 pkt->size = 0;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
491 pkt->index = 0;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
492 etm_pkt_put8(pkt, fid);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
493
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
494 switch (fid) {
166
13af69b6a3dc ETM core compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 164
diff changeset
495 #if ETM_ATP_SUPPORT
164
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
496 case 0x60: // old 'G'
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
497 error = etm_at(pkt, (char *) buf);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
498 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
499 #endif
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
500 case 0x61: // old 'M'
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
501 error = etm_mem(pkt, buf);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
502 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
503 case 0x62: // old 'E'
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
504 error = etm_echo(pkt, buf);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
505 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
506 case 0x63: // old 'R'
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
507 error = etm_reset();
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
508 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
509 case 0x64: // old 'T'
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
510 error = etm_debug(pkt, buf);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
511 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
512 case 0x65: // old 'V'
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
513 error = etm_version(pkt, buf);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
514 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
515 case 0x66: // old 'C'
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
516 error = etm_codec_read(pkt, buf);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
517 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
518 case 0x67: // old 'D'
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
519 error = etm_codec_write(pkt, buf);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
520 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
521 case 0x68: // old 'd'
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
522 error = etm_dieID_read(pkt, buf);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
523 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
524 default:
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
525 tr_etm(TgTrCore,"ETM CORE: _core: fid ERROR");
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
526 error = ETM_NOSYS;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
527 break;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
528 }
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
529
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
530 if (error < 0) {
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
531 tr_etm(TgTrCore,"ETM CORE: _core: FAILED");
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
532 pkt->status = -error;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
533 }
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
534
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
535 // etm_at(): send func. is controlled by primitive
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
536 if (fid == 'G' && error >= RV_OK) {}
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
537 else
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
538 etm_pkt_send(pkt);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
539
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
540 etm_free(pkt);
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
541 return ETM_OK;
d78219c43fbf gsm-fw/services/etm: initial import from the Leonardo semi-src
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
542 }