2 * \file trc_pkt_elem_etmv3.h
5 * \copyright Copyright (c) 2015, ARM Limited. All Rights Reserved.
10 * Redistribution and use in source and binary forms, with or without modification,
11 * are permitted provided that the following conditions are met:
13 * 1. Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright notice,
17 * this list of conditions and the following disclaimer in the documentation
18 * and/or other materials provided with the distribution.
20 * 3. Neither the name of the copyright holder nor the names of its contributors
21 * may be used to endorse or promote products derived from this software without
22 * specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
28 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 #ifndef ARM_TRC_PKT_ELEM_ETMV3_H_INCLUDED
37 #define ARM_TRC_PKT_ELEM_ETMV3_H_INCLUDED
39 #include "trc_pkt_types_etmv3.h"
40 #include "common/trc_printable_elem.h"
41 #include "common/trc_pkt_elem_base.h"
43 /** @addtogroup trc_pkts
47 * @class EtmV3TrcPacket
48 * @brief ETMv3 Trace Protocol Packet.
50 * This class represents a single ETMv3 trace packet, along with intra packet state.
53 class EtmV3TrcPacket : public TrcPacketBase, public trcPrintableElem
59 // conversions between C-API struct and C++ object types
60 // assign from C-API struct
61 EtmV3TrcPacket &operator =(const ocsd_etmv3_pkt* p_pkt);
63 // allow const cast to C-API struct to pass C++ object
64 operator const ocsd_etmv3_pkt*() const { return &m_pkt_data; };
65 operator const ocsd_etmv3_pkt&() const { return m_pkt_data; };
67 // override c_pkt to pass out the packet data struct.
68 virtual const void *c_pkt() const { return &m_pkt_data; };
70 // update interface - set packet values
71 void Clear(); //!< clear update data in packet ready for new one.
72 void ResetState(); //!< reset intra packet state data -on full decoder reset.
74 void SetType(const ocsd_etmv3_pkt_type p_type);
75 void SetErrType(const ocsd_etmv3_pkt_type e_type);
76 void UpdateAddress(const ocsd_vaddr_t partAddrVal, const int updateBits);
77 void SetException( const ocsd_armv7_exception type,
78 const uint16_t number,
82 const int resume = 0);
83 void UpdateNS(const int NS);
84 void UpdateAltISA(const int AltISA);
85 void UpdateHyp(const int Hyp);
86 void UpdateISA(const ocsd_isa isa);
87 void UpdateContextID(const uint32_t contextID);
88 void UpdateVMID(const uint8_t VMID);
89 void UpdateTimestamp(const uint64_t tsVal, const uint8_t updateBits);
91 bool UpdateAtomFromPHdr(const uint8_t pHdr, const bool cycleAccurate); //!< Interpret P Hdr, return true if valid, false if not.
93 void SetDataOOOTag(const uint8_t tag);
94 void SetDataValue(const uint32_t value);
95 void UpdateDataAddress(const uint32_t value, const uint8_t valid_bits);
96 void UpdateDataEndian(const uint8_t BE_Val);
97 void SetCycleCount(const uint32_t cycleCount);
98 void SetISyncReason(const ocsd_iSync_reason reason);
100 void SetISyncIsLSiP();
101 void SetISyncNoAddr();
103 // packet status interface - get packet info.
104 const ocsd_etmv3_pkt_type getType() const { return m_pkt_data.type; };
105 const bool isBadPacket() const;
107 const int AltISA() const { return m_pkt_data.context.curr_alt_isa; };
108 const ocsd_isa ISA() const { return m_pkt_data.curr_isa; };
109 const bool changedISA() const { return m_pkt_data.curr_isa != m_pkt_data.prev_isa; };
111 // any of the context elements updated?
112 const bool isCtxtUpdated() const;
113 const bool isCtxtFlagsUpdated() const { return (m_pkt_data.context.updated == 1); };
114 const bool isNS() const { return m_pkt_data.context.curr_NS; };
115 const bool isHyp() const { return m_pkt_data.context.curr_Hyp; };
117 const bool isCtxtIDUpdated() const { return (m_pkt_data.context.updated_c == 1); }
118 const uint32_t getCtxtID() const { return m_pkt_data.context.ctxtID; };
119 const bool isVMIDUpdated() const { return (m_pkt_data.context.updated_v == 1); }
120 const uint32_t getVMID() const { return m_pkt_data.context.VMID; };
122 const uint32_t getCycleCount() const { return m_pkt_data.cycle_count; };
123 const uint64_t getTS() const { return m_pkt_data.timestamp; };
125 const bool isExcepPkt() const { return (m_pkt_data.exception.bits.present == 1); };
126 const ocsd_armv7_exception excepType() const { return m_pkt_data.exception.type; };
127 const uint16_t excepNum() const { return m_pkt_data.exception.number; };
128 const bool isExcepCancel() const { return (m_pkt_data.exception.bits.present == 1) && (m_pkt_data.exception.bits.cancel == 1); };
130 const ocsd_iSync_reason getISyncReason() const { return m_pkt_data.isync_info.reason; };
131 const bool getISyncHasCC() const { return m_pkt_data.isync_info.has_cycle_count; };
132 const bool getISyncIsLSiPAddr() const { return m_pkt_data.isync_info.has_LSipAddress; };
133 const bool getISyncNoAddr() const { return m_pkt_data.isync_info.no_address; };
135 const ocsd_vaddr_t getAddr() const { return m_pkt_data.addr.val; };
136 const ocsd_vaddr_t getDataAddr() const { return m_pkt_data.data.addr.val; };
138 const ocsd_pkt_atom &getAtom() const { return m_pkt_data.atom; };
139 const uint8_t getPHdrFmt() const { return m_pkt_data.p_hdr_fmt; };
143 virtual void toString(std::string &str) const;
144 virtual void toStringFmt(const uint32_t fmtFlags, std::string &str) const;
147 const char *packetTypeName(const ocsd_etmv3_pkt_type type, const char **ppDesc) const;
148 void getBranchAddressStr(std::string &valStr) const;
149 void getAtomStr(std::string &valStr) const;
150 void getISyncStr(std::string &valStr) const;
151 void getISAStr(std::string &isaStr) const;
152 void getExcepStr(std::string &excepStr) const;
154 ocsd_etmv3_pkt m_pkt_data;
157 inline void EtmV3TrcPacket::UpdateNS(const int NS)
159 m_pkt_data.context.curr_NS = NS;
160 m_pkt_data.context.updated = 1;
163 inline void EtmV3TrcPacket::UpdateAltISA(const int AltISA)
165 m_pkt_data.context.curr_alt_isa = AltISA;
166 m_pkt_data.context.updated = 1;
169 inline void EtmV3TrcPacket::UpdateHyp(const int Hyp)
171 m_pkt_data.context.curr_Hyp = Hyp;
172 m_pkt_data.context.updated = 1;
175 inline void EtmV3TrcPacket::UpdateISA(const ocsd_isa isa)
177 m_pkt_data.prev_isa = m_pkt_data.curr_isa;
178 m_pkt_data.curr_isa = isa;
181 inline void EtmV3TrcPacket::SetType(const ocsd_etmv3_pkt_type p_type)
183 m_pkt_data.type = p_type;
186 inline void EtmV3TrcPacket::SetErrType(const ocsd_etmv3_pkt_type e_type)
188 m_pkt_data.err_type = m_pkt_data.type;
189 m_pkt_data.type = e_type;
192 inline const bool EtmV3TrcPacket::isBadPacket() const
194 return (m_pkt_data.type >= ETM3_PKT_BAD_SEQUENCE);
197 inline void EtmV3TrcPacket::SetDataOOOTag(const uint8_t tag)
199 m_pkt_data.data.ooo_tag = tag;
202 inline void EtmV3TrcPacket::SetDataValue(const uint32_t value)
204 m_pkt_data.data.value = value;
205 m_pkt_data.data.update_dval = 1;
208 inline void EtmV3TrcPacket::UpdateContextID(const uint32_t contextID)
210 m_pkt_data.context.updated_c = 1;
211 m_pkt_data.context.ctxtID = contextID;
214 inline void EtmV3TrcPacket::UpdateVMID(const uint8_t VMID)
216 m_pkt_data.context.updated_v = 1;
217 m_pkt_data.context.VMID = VMID;
220 inline void EtmV3TrcPacket::UpdateDataEndian(const uint8_t BE_Val)
222 m_pkt_data.data.be = BE_Val;
223 m_pkt_data.data.update_be = 1;
226 inline void EtmV3TrcPacket::SetCycleCount(const uint32_t cycleCount)
228 m_pkt_data.cycle_count = cycleCount;
231 inline void EtmV3TrcPacket::SetISyncReason(const ocsd_iSync_reason reason)
233 m_pkt_data.isync_info.reason = reason;
236 inline void EtmV3TrcPacket::SetISyncHasCC()
238 m_pkt_data.isync_info.has_cycle_count = 1;
241 inline void EtmV3TrcPacket::SetISyncIsLSiP()
243 m_pkt_data.isync_info.has_LSipAddress = 1;
246 inline void EtmV3TrcPacket::SetISyncNoAddr()
248 m_pkt_data.isync_info.no_address = 1;
251 inline const bool EtmV3TrcPacket::isCtxtUpdated() const
253 return (m_pkt_data.context.updated_v == 1) ||
254 (m_pkt_data.context.updated == 1) ||
255 (m_pkt_data.context.updated_c == 1);
259 #endif // ARM_TRC_PKT_ELEM_ETMV3_H_INCLUDED
261 /* End of File trc_pkt_elem_etmv3.h */