OpenCSD - CoreSight Trace Decode Library 1.4.0
trc_pkt_decode_etmv3.h
Go to the documentation of this file.
1
8/*
9 * Redistribution and use in source and binary forms, with or without modification,
10 * are permitted provided that the following conditions are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 *
19 * 3. Neither the name of the copyright holder nor the names of its contributors
20 * may be used to endorse or promote products derived from this software without
21 * specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35#ifndef ARM_TRC_PKT_DECODE_ETMV3_H_INCLUDED
36#define ARM_TRC_PKT_DECODE_ETMV3_H_INCLUDED
37
39#include "common/trc_gen_elem.h"
43
46
47/**************** Atom handling class **************************************/
49{
50public:
51 Etmv3Atoms(const bool isCycleAcc);
53
55 void initAtomPkt(const EtmV3TrcPacket *in_pkt, const ocsd_trc_index_t &root_index);
56
57 const ocsd_atm_val getCurrAtomVal() const;
58 const int numAtoms() const;
59 const ocsd_trc_index_t pktIndex() const;
60
61 const bool hasAtomCC() const;
62 const uint32_t getAtomCC() const;
63 const uint32_t getRemainCC() const;
64
65 void clearAtom();
66 void clearAll();
67
68private:
69
70 // Atom PHDR packet formats from ETMv3 spec - defines content of header.
71 enum {
72 ATOM_PHDR_FMT_1 = 1,
73 ATOM_PHDR_FMT_2,
74 ATOM_PHDR_FMT_3,
75 ATOM_PHDR_FMT_4,
76 };
77
78
79
80 ocsd_pkt_atom m_atom;
81 uint8_t m_p_hdr_fmt;
82 uint32_t m_cycle_count;
83 ocsd_trc_index_t m_root_index;
84 bool m_isCCPacket;
85};
86
87
88inline Etmv3Atoms::Etmv3Atoms(const bool isCycleAcc)
89{
90 m_isCCPacket = isCycleAcc;
91}
92
94inline void Etmv3Atoms::initAtomPkt(const EtmV3TrcPacket *in_pkt, const ocsd_trc_index_t &root_index)
95{
96 m_atom = in_pkt->getAtom();
97 m_p_hdr_fmt = in_pkt->getPHdrFmt();
98 m_cycle_count = in_pkt->getCycleCount();
99}
100
102{
103 return (m_atom.En_bits & 0x1) ? ATOM_E : ATOM_N;
104}
105
106inline const int Etmv3Atoms::numAtoms() const
107{
108 return m_atom.num;
109}
110
112{
113 return m_root_index;
114}
115
116inline const bool Etmv3Atoms::hasAtomCC() const
117{
118 bool hasCC = false;
119 if(!m_isCCPacket)
120 return hasCC;
121
122 switch(m_p_hdr_fmt)
123 {
124 case ATOM_PHDR_FMT_4:
125 default:
126 break;
127
128 case ATOM_PHDR_FMT_3:
129 case ATOM_PHDR_FMT_1:
130 hasCC = true;
131 break;
132
133 case ATOM_PHDR_FMT_2:
134 hasCC = (m_atom.num > 1); // first of 2 has W state
135 break;
136 }
137 return hasCC;
138}
139
140inline const uint32_t Etmv3Atoms::getAtomCC() const
141{
142 uint32_t CC = 0;
143 if(!m_isCCPacket)
144 return CC;
145
146 switch(m_p_hdr_fmt)
147 {
148 case ATOM_PHDR_FMT_4: // no CC in format 4
149 default:
150 break;
151
152 case ATOM_PHDR_FMT_3: // single CC with optional E atom
153 CC = m_cycle_count;
154 break;
155
156 case ATOM_PHDR_FMT_2: // single W on first of 2 atoms
157 CC = (m_atom.num > 1) ? 1: 0;
158 break;
159
160 case ATOM_PHDR_FMT_1: // each atom has 1 CC.
161 CC = 1;
162 break;
163 }
164 return CC;
165}
166
167inline const uint32_t Etmv3Atoms::getRemainCC() const
168{
169 uint32_t CC = 0;
170 if(!m_isCCPacket)
171 return CC;
172
173 switch(m_p_hdr_fmt)
174 {
175 case ATOM_PHDR_FMT_4: // no CC in format 4
176 default:
177 break;
178
179 case ATOM_PHDR_FMT_3:
180 CC = m_cycle_count;
181 break;
182
183 case ATOM_PHDR_FMT_2:
184 CC = (m_atom.num > 1) ? 1: 0;
185 break;
186
187 case ATOM_PHDR_FMT_1:
188 CC = m_atom.num;
189 break;
190 }
191 return CC;
192}
193
195{
196 m_atom.En_bits >>=1;
197 if(m_atom.num)
198 m_atom.num--;
199}
200
202{
203 m_atom.num = 0;
204}
205
206/********** Main decode class ****************************************************/
207class TrcPktDecodeEtmV3 : public TrcPktDecodeBase<EtmV3TrcPacket, EtmV3Config>
208{
209public:
211 TrcPktDecodeEtmV3(int instIDNum);
213
214protected:
215 /* implementation packet decoding interface */
221 virtual const uint8_t getCoreSightTraceID() { return m_CSID; };
222
223 /* local decode methods */
224 void initDecoder();
226
228
229 ocsd_datapath_resp_t processISync(const bool withCC, const bool firstSync = false);
232
234
236
237private:
238 void setNeedAddr(bool bNeedAddr);
239 void pendExceptionReturn();
240 bool preISyncValid(ocsd_etmv3_pkt_type pkt_type);
241//** intra packet state;
242
243 OcsdCodeFollower m_code_follower;
244
245 ocsd_vaddr_t m_IAddr;
246 bool m_bNeedAddr;
247 bool m_bSentUnknown;
248 bool m_bWaitISync;
249
250 OcsdPeContext m_PeContext;
251
252 OcsdGenElemList m_outputElemList;
253
254
255//** Other packet decoder state;
256
257 // trace decode FSM
258 typedef enum {
259 NO_SYNC,
260 WAIT_ASYNC,
261 WAIT_ISYNC,
262 DECODE_PKTS,
263 SEND_PKTS,
264 } processor_state_t;
265
266 processor_state_t m_curr_state;
267 unsync_info_t m_unsync_info;
268
269 uint8_t m_CSID;
270};
271
272
273#endif // ARM_TRC_PKT_DECODE_ETMV3_H_INCLUDED
274
275/* End of File trc_pkt_decode_etmv3.h */
ETMv3 Trace Protocol Packet.
const uint8_t getPHdrFmt() const
const uint32_t getCycleCount() const
const ocsd_pkt_atom & getAtom() const
void initAtomPkt(const EtmV3TrcPacket *in_pkt, const ocsd_trc_index_t &root_index)
initialise the atom and index values
const uint32_t getRemainCC() const
get residual cycle count for remaining atoms
void clearAtom()
clear the current atom, set the next.
Etmv3Atoms(const bool isCycleAcc)
void clearAll()
clear all
const uint32_t getAtomCC() const
cycle count for current atom
const int numAtoms() const
number of atoms
const ocsd_atm_val getCurrAtomVal() const
const ocsd_trc_index_t pktIndex() const
originating packet index
const bool hasAtomCC() const
cycle count for current atom?
The code follower looks for waypoints or addresses.
Maintain a list of elements to be output.
Handler for the ocsd_pe_context structure.
Generic trace element class.
Definition: trc_gen_elem.h:50
virtual ocsd_err_t onProtocolConfig()
void resetDecoder()
reset state to start of decode. (moves state, retains config)
void initDecoder()
initial state on creation (zeros all config)
virtual ocsd_datapath_resp_t processPacket()
virtual ~TrcPktDecodeEtmV3()
ocsd_datapath_resp_t processPHdr()
ocsd_datapath_resp_t sendUnsyncPacket()
send an initial unsync packet when decoder starts
virtual ocsd_datapath_resp_t onReset()
OcsdTraceElement * GetNextOpElem(ocsd_datapath_resp_t &resp)
get the next element from the element list.
virtual ocsd_datapath_resp_t onEOT()
ocsd_datapath_resp_t decodePacket(bool &pktDone)
decode a packet
virtual ocsd_datapath_resp_t onFlush()
ocsd_datapath_resp_t processBranchAddr()
TrcPktDecodeEtmV3(int instIDNum)
virtual const uint8_t getCoreSightTraceID()
ocsd_datapath_resp_t processISync(const bool withCC, const bool firstSync=false)
enum _unsync_info_t unsync_info_t
uint32_t ocsd_trc_index_t
Definition: ocsd_if_types.h:67
enum _ocsd_datapath_resp_t ocsd_datapath_resp_t
enum _ocsd_err_t ocsd_err_t
uint64_t ocsd_vaddr_t
enum _ocsd_etmv3_pkt_type ocsd_etmv3_pkt_type
enum _ocsd_atm_val ocsd_atm_val
@ ATOM_N
Definition: trc_pkt_types.h:80
@ ATOM_E
Definition: trc_pkt_types.h:81
uint32_t En_bits
Definition: trc_pkt_types.h:90
OpenCSD : Decoder Generic trace element output class.
OpenCSD : Trace Packet decoder base class.