OpenCSD - CoreSight Trace Decode Library  1.3.3
trc_pkt_elem_stm.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_ELEM_STM_H_INCLUDED
36 #define ARM_TRC_PKT_ELEM_STM_H_INCLUDED
37 
38 #include "trc_pkt_types_stm.h"
41 
54 {
55 public:
58 
60 
61  virtual const void *c_pkt() const { return (const ocsd_stm_pkt *)this; };
62 
63  void initStartState();
64  void initNextPacket();
65 
66  void setPacketType(const ocsd_stm_pkt_type type, const bool bMarker);
68  void setMaster(const uint8_t master);
69  void setChannel(const uint16_t channel, const bool b8Bit);
70  void setTS(const uint64_t ts_val, const uint8_t updatedBits);
72 
73  void setD4Payload(const uint8_t value);
74  void setD8Payload(const uint8_t value);
75  void setD16Payload(const uint16_t value);
76  void setD32Payload(const uint32_t value);
77  void setD64Payload(const uint64_t value);
78 
79  const bool isMarkerPkt() const;
80  const bool isTSPkt() const;
81 
82  const ocsd_stm_pkt_type getPktType() const;
83  const ocsd_stm_pkt_type getPktErrType() const;
84  const uint8_t getMaster() const;
85  const uint16_t getChannel() const;
86  const ocsd_stm_ts_type getTSType() const;
87  const uint64_t getTSVal() const;
88 
89  const uint8_t getD4Val() const;
90  const uint8_t getD8Val() const;
91  const uint16_t getD16Val() const;
92  const uint32_t getD32Val() const;
93  const uint64_t getD64Val() const;
94 
95  const bool isBadPacket() const;
96 
97  // printing
98  virtual void toString(std::string &str) const;
99  virtual void toStringFmt(const uint32_t fmtFlags, std::string &str) const;
100 
101 
102 private:
103  void pktTypeName(const ocsd_stm_pkt_type pkt_type, std::string &name, std::string &desc) const;
104 };
105 
106 inline void StmTrcPacket::setPacketType(const ocsd_stm_pkt_type type, const bool bMarker)
107 {
108  this->type = type;
109  if(bMarker)
110  pkt_has_marker = 1;
111 }
112 
114 {
115  this->err_type = this->type; // original type is the err type;
116  this->type = err_type; // mark main type as an error.
117 }
118 
119 inline void StmTrcPacket::setMaster(const uint8_t master)
120 {
121  this->master = master;
122  channel = 0; // M8 forces current channel to 0.
123 }
124 
125 inline void StmTrcPacket::setChannel(const uint16_t channel, const bool b8Bit)
126 {
127  if(b8Bit)
128  this->channel = (this->channel & 0xFF00) | (channel & 0xFF);
129  else
130  this->channel = channel;
131 }
132 
134 {
135  this->ts_type = type;
136  master = 0;
137  channel = 0;
138 }
139 
140 inline void StmTrcPacket::setD4Payload(const uint8_t value)
141 {
142  payload.D8 = value & 0xF;
143 }
144 
145 inline void StmTrcPacket::setD8Payload(const uint8_t value)
146 {
147  payload.D8 = value;
148 }
149 
150 inline void StmTrcPacket::setD16Payload(const uint16_t value)
151 {
152  payload.D16 = value;
153 }
154 
155 inline void StmTrcPacket::setD32Payload(const uint32_t value)
156 {
157  payload.D32 = value;
158 }
159 
160 inline void StmTrcPacket::setD64Payload(const uint64_t value)
161 {
162  payload.D64 = value;
163 }
164 
165 inline const bool StmTrcPacket::isMarkerPkt() const
166 {
167  return (pkt_has_marker != 0);
168 }
169 
170 inline const bool StmTrcPacket::isTSPkt() const
171 {
172  return (pkt_has_ts != 0);
173 }
174 
176 {
177  return type;
178 }
179 
181 {
182  return err_type;
183 }
184 
185 inline const uint8_t StmTrcPacket::getMaster() const
186 {
187  return master;
188 }
189 
190 inline const uint16_t StmTrcPacket::getChannel() const
191 {
192  return channel;
193 }
194 
196 {
197  return ts_type;
198 }
199 
200 inline const uint64_t StmTrcPacket::getTSVal() const
201 {
202  return timestamp;
203 }
204 
205 inline const uint8_t StmTrcPacket::getD4Val() const
206 {
207  return payload.D8;
208 }
209 
210 inline const uint8_t StmTrcPacket::getD8Val() const
211 {
212  return payload.D8;
213 }
214 
215 inline const uint16_t StmTrcPacket::getD16Val() const
216 {
217  return payload.D16;
218 }
219 
220 inline const uint32_t StmTrcPacket::getD32Val() const
221 {
222  return payload.D32;
223 }
224 
225 inline const uint64_t StmTrcPacket::getD64Val() const
226 {
227  return payload.D64;
228 }
229 
230 inline const bool StmTrcPacket::isBadPacket() const
231 {
232  return (bool)(type >= STM_PKT_BAD_SEQUENCE);
233 }
234 
235 
236 #endif // ARM_TRC_PKT_ELEM_STM_H_INCLUDED
237 
238 /* End of File trc_pkt_elem_stm.h */
STM trace packet with packet printing functionality.
const ocsd_stm_pkt_type getPktType() const
const bool isTSPkt() const
void setD16Payload(const uint16_t value)
void onVersionPkt(const ocsd_stm_ts_type type)
void setMaster(const uint8_t master)
const bool isMarkerPkt() const
virtual void toString(std::string &str) const
virtual const void * c_pkt() const
return the underlying C API packet structure
const uint16_t getChannel() const
void setD32Payload(const uint32_t value)
const uint32_t getD32Val() const
const uint16_t getD16Val() const
void setTS(const uint64_t ts_val, const uint8_t updatedBits)
void updateErrType(const ocsd_stm_pkt_type err_type)
void setD4Payload(const uint8_t value)
void setChannel(const uint16_t channel, const bool b8Bit)
void setD64Payload(const uint64_t value)
StmTrcPacket & operator=(const ocsd_stm_pkt *p_pkt)
const uint8_t getMaster() const
const uint64_t getTSVal() const
const ocsd_stm_pkt_type getPktErrType() const
void initNextPacket()
Initialise state for next packet.
void setPacketType(const ocsd_stm_pkt_type type, const bool bMarker)
const uint64_t getD64Val() const
const bool isBadPacket() const
const ocsd_stm_ts_type getTSType() const
const uint8_t getD4Val() const
const uint8_t getD8Val() const
virtual void toStringFmt(const uint32_t fmtFlags, std::string &str) const
void setD8Payload(const uint8_t value)
void initStartState()
Initialise packet state at start of decoder.
Class to provide trace element strings for printing.
enum _ocsd_stm_ts_type ocsd_stm_ts_type
enum _ocsd_stm_pkt_type ocsd_stm_pkt_type
@ STM_PKT_BAD_SEQUENCE
ocsd_stm_pkt_type err_type
ocsd_stm_pkt_type type
ocsd_stm_ts_type ts_type
union _ocsd_stm_pkt::@28 payload
OpenCSD : Standard printable element base class.