2 * \file trc_pkt_elem_ptm.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.
37 #ifndef ARM_TRC_PKT_ELEM_PTM_H_INCLUDED
38 #define ARM_TRC_PKT_ELEM_PTM_H_INCLUDED
40 #include "trc_pkt_types_ptm.h"
41 #include "common/trc_printable_elem.h"
42 #include "common/trc_pkt_elem_base.h"
44 /** @addtogroup trc_pkts
48 class PtmTrcPacket : public TrcPacketBase, public ocsd_ptm_pkt, trcPrintableElem
54 PtmTrcPacket &operator =(const ocsd_ptm_pkt* p_pkt);
56 virtual const void *c_pkt() const { return (const ocsd_ptm_pkt *)this; };
58 // update interface - set packet values
60 void Clear(); //!< clear update data in packet ready for new one.
61 void ResetState(); //!< reset intra packet state data - on full decoder reset.
63 void SetType(const ocsd_ptm_pkt_type p_type);
64 void SetErrType(const ocsd_ptm_pkt_type e_type);
66 void SetException( const ocsd_armv7_exception type,
67 const uint16_t number);
68 void SetISyncReason(const ocsd_iSync_reason reason);
69 void SetCycleCount(const uint32_t cycleCount);
70 void SetAtomFromPHdr(const uint8_t pHdr);
71 void SetCycleAccAtomFromPHdr(const uint8_t pHdr);
73 void UpdateAddress(const ocsd_vaddr_t partAddrVal, const int updateBits);
74 void UpdateNS(const int NS);
75 void UpdateAltISA(const int AltISA);
76 void UpdateHyp(const int Hyp);
77 void UpdateISA(const ocsd_isa isa);
78 void UpdateContextID(const uint32_t contextID);
79 void UpdateVMID(const uint8_t VMID);
80 void UpdateTimestamp(const uint64_t tsVal, const uint8_t updateBits);
82 // packet status interface
85 const bool isBadPacket() const;
86 const ocsd_ptm_pkt_type getType() const;
89 const ocsd_isa getISA() const;
90 const bool ISAChanged() const { return (bool)(curr_isa != prev_isa); };
91 const uint8_t getAltISA() const { return context.curr_alt_isa; };
92 const uint8_t getNS() const { return context.curr_NS; };
93 const uint8_t getHyp() const { return context.curr_Hyp; };
96 const ocsd_vaddr_t getAddrVal() const { return addr.val; };
98 // pe context information
99 const bool CtxtIDUpdated() const { return (bool)(context.updated_c == 1); };
100 const bool VMIDUpdated() const { return (bool)(context.updated_v == 1); };
101 const uint32_t getCtxtID() const { return context.ctxtID; };
102 const uint8_t getVMID() const { return context.VMID; };
103 const bool PEContextUpdated() const { return context.updated; };
106 const ocsd_pkt_atom &getAtom() const { return atom; };
108 // branch address info
109 const bool isBranchExcepPacket() const { return (exception.bits.present == 1); };
110 const ocsd_armv7_exception excepType() const { return exception.type; };
111 const uint16_t excepNum() const { return exception.number; };
114 const ocsd_iSync_reason iSyncReason() const { return i_sync_reason; };
117 const bool hasCC() const { return (cc_valid == 1); };
118 const uint32_t getCCVal() const { return cycle_count; };
121 virtual void toString(std::string &str) const;
122 virtual void toStringFmt(const uint32_t fmtFlags, std::string &str) const;
125 void packetTypeName(const ocsd_ptm_pkt_type pkt_type, std::string &name, std::string &desc) const;
126 void getAtomStr(std::string &valStr) const;
127 void getBranchAddressStr(std::string &valStr) const;
128 void getExcepStr(std::string &excepStr) const;
129 void getISAStr(std::string &isaStr) const;
130 void getCycleCountStr(std::string &subStr) const;
131 void getISyncStr(std::string &valStr) const;
132 void getTSStr(std::string &valStr) const;
136 //*** update interface - set packet values
137 inline void PtmTrcPacket::SetType(const ocsd_ptm_pkt_type p_type)
142 inline void PtmTrcPacket::SetErrType(const ocsd_ptm_pkt_type e_type)
148 inline void PtmTrcPacket::UpdateNS(const int NS)
150 context.curr_NS = NS;
154 inline void PtmTrcPacket::UpdateAltISA(const int AltISA)
156 context.curr_alt_isa = AltISA;
160 inline void PtmTrcPacket::UpdateHyp(const int Hyp)
162 context.curr_Hyp = Hyp;
166 inline void PtmTrcPacket::UpdateISA(const ocsd_isa isa)
172 inline void PtmTrcPacket::UpdateContextID(const uint32_t contextID)
174 context.ctxtID = contextID;
175 context.updated_c = 1;
178 inline void PtmTrcPacket::UpdateVMID(const uint8_t VMID)
181 context.updated_v = 1;
184 inline void PtmTrcPacket::SetException( const ocsd_armv7_exception type, const uint16_t number)
186 exception.bits.present = 1;
187 exception.number = number;
188 exception.type = type;
191 inline void PtmTrcPacket::SetISyncReason(const ocsd_iSync_reason reason)
193 i_sync_reason = reason;
196 inline void PtmTrcPacket::SetCycleCount(const uint32_t cycleCount)
198 cycle_count = cycleCount;
202 //*** packet status interface - get packet info.
203 inline const bool PtmTrcPacket::isBadPacket() const
205 return (bool)(type >= PTM_PKT_BAD_SEQUENCE);
208 inline const ocsd_ptm_pkt_type PtmTrcPacket::getType() const
213 inline const ocsd_isa PtmTrcPacket::getISA() const
219 #endif // ARM_TRC_PKT_ELEM_PTM_H_INCLUDED
221 /* End of File trc_pkt_elem_ptm.h */