2 * Copyright (C) 2013 Freescale Semiconductor, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
26 #include "NxPacketSet.h"
27 #include "NxMessageVisitor.h"
28 #include "SizedAddress.h"
35 Base class for all types of Nexus Message structures. Type is based on a TCODE value.
42 @param tcode Set the TCODE value. Default 0x3f which is an unused (unlikely) code value.
44 NxMessage(uint32_t tcode
) :
45 tcode_(tcode
), source_id_(0), timestamp_(0)
52 // NxMessage implements the standard visitor pattern.
53 virtual void accept(NxMessageVisitor
&v
) = 0;
56 @abstract Returns the TCODE value
57 @return the tcode for this message
59 uint32_t tcode() const
65 @abstract Returns the TCODE string
66 @return the tcode as a string
68 virtual string
tcodeString() const;
71 @abstract Returns the SRC_ID value
72 @return the source_id for this message
74 uint32_t sourceId() const
80 @abstract Annotates the SRC_ID as string
81 @return the SRC_ID as a string
83 const char * sourceIdString() const;
86 @abstract Returns the TIMESTAMP value
87 @return the timestamp for this message
89 uint32_t timestamp() const
95 @abstract Determines if the TIMESTAMP value needs correction
96 @return True if the timestamp needs correction
98 bool timestampNeedsCorrection() const;
101 @abstract Returns the corrected TIMESTAMP value
102 @return the corrected timestamp for this message
104 uint32_t correctedTimestamp() const;
107 @abstract Output timestamp information as a string
108 @return a string representing the timestamp
110 string
timestampAsString() const;
113 @abstract Decode Nexus message info from the packet set
114 @param pkt_set Reference to a NxPackageSet containing the data to be decoded
115 @return True if no error
117 virtual bool decode(NxPacketSet
&pkt_set
) = 0;
120 @abstract Output message information as a string
121 @return a string representing the Nexus message content
123 virtual string
asString() const;
128 @abstract Decode the SRC ID from the packet set
129 @param pkt_set Reference to a NxPackageSet containing the data to be decoded
130 @return the SRC ID value
132 uint32_t decodeSourceId(NxPacketSet
&pkt_set
);
135 @abstract Decode the TIMESTAMP value from the packet set at index
136 @param pkt_set Reference to a NxPackageSet containing the data to be decoded
137 @param index The index of the NxPacket in the NxPacketSet collection
138 @return the TIMESTAMP value
140 uint32_t decodeTimestamp(NxPacketSet
&pkt_set
, uint32_t index
);
142 /*! @var tcode_ contains the TCODE value which determines the type of NxMessage */
145 /*! @var source_id_ contains the SRC ID value */
148 /*! @var timestamp_ contains the optional TIMESTAMP value */
152 // This type is the default for all unknown message types
153 class NxDefaultMessage
: public NxMessage
156 NxDefaultMessage(uint32_t tcode
) :
164 // NxMessage implements the standard visitor pattern.
165 virtual void accept(NxMessageVisitor
&v
)
170 // decode message info from the packet set
171 virtual bool decode(NxPacketSet
&pkt_set
)
177 class NxDebugStatusMessage
: public NxMessage
180 NxDebugStatusMessage() :
181 NxMessage(0), status_(0)
184 ~NxDebugStatusMessage()
188 // NxMessage implements the standard visitor pattern.
189 virtual void accept(NxMessageVisitor
&v
)
195 @abstract Returns the TCODE string
196 @return the tcode as a string
198 virtual string
tcodeString() const
200 return "Debug Status Message";
203 // decode message info from the packet set
204 virtual bool decode(NxPacketSet
&pkt_set
);
206 // output message information as a string
207 virtual string
asString() const;
215 class NxDeviceIDMessage
: public NxMessage
218 NxDeviceIDMessage() :
226 // NxMessage implements the standard visitor pattern.
227 virtual void accept(NxMessageVisitor
&v
)
233 @abstract Returns the TCODE string
234 @return the tcode as a string
236 virtual string
tcodeString() const
238 return "Device ID Message";
241 // decode message info from the packet set
242 virtual bool decode(NxPacketSet
&pkt_set
);
244 // output message information as a string
245 virtual string
asString() const;
251 class NxOwnershipTraceMessage
: public NxMessage
254 NxOwnershipTraceMessage() :
255 NxMessage(2), pid_index_(0), pid_value_(0)
258 ~NxOwnershipTraceMessage()
262 // NxMessage implements the standard visitor pattern.
263 virtual void accept(NxMessageVisitor
&v
)
269 @abstract Returns the TCODE string
270 @return the tcode as a string
272 virtual string
tcodeString() const
274 return "Ownership Trace Message";
277 // decode message info from the packet set
278 virtual bool decode(NxPacketSet
&pkt_set
);
280 // output message information as a string
281 virtual string
asString() const;
283 // decode the data as a string
284 const char * pidIndexString() const;
286 // decode the data as a string
287 const char * pidValueString() const;
297 class NxDataAcquisitionMessage
: public NxMessage
300 NxDataAcquisitionMessage() :
301 NxMessage(7), idtag_(0), dqdata_(0)
304 ~NxDataAcquisitionMessage()
308 // NxMessage implements the standard visitor pattern.
309 virtual void accept(NxMessageVisitor
&v
)
315 @abstract Returns the TCODE string
316 @return the tcode as a string
318 virtual string
tcodeString() const
320 return "Data Acquisition Message";
323 // decode message info from the packet set
324 virtual bool decode(NxPacketSet
&pkt_set
);
326 // output message information as a string
327 virtual string
asString() const;
329 // decode the data as a string
330 const char * idtagString() const;
332 // decode the data as a string
333 string
dqdataString() const;
344 class NxErrorMessage
: public NxMessage
348 NxMessage(8), etype_(0), ecode_(0)
355 // NxMessage implements the standard visitor pattern.
356 virtual void accept(NxMessageVisitor
&v
)
362 @abstract Returns the TCODE string
363 @return the tcode as a string
365 virtual string
tcodeString() const
367 return "Error Message";
370 // decode message info from the packet set
371 virtual bool decode(NxPacketSet
&pkt_set
);
373 // output message information as a string
374 virtual string
asString() const;
376 // decode the data as a string
377 const char * etypeString() const;
379 // decode the data as a string
380 string
ecodeString() const;
391 // NxProgramTraceSync
392 class NxProgramTraceSync
: public NxMessage
395 NxProgramTraceSync() :
396 NxMessage(9), map_(0), icnt_(0), hist_(0)
399 ~NxProgramTraceSync()
403 // NxMessage implements the standard visitor pattern.
404 virtual void accept(NxMessageVisitor
&v
)
410 @abstract Returns the TCODE string
411 @return the tcode as a string
413 virtual string
tcodeString() const
415 return "Program Trace Synchronization";
418 // decode message info from the packet set
419 virtual bool decode(NxPacketSet
&pkt_set
);
421 // output message information as a string
422 virtual string
asString() const;
424 // get the address value
425 const SizedAddress
& address() const
445 // NxDataTrace Base class
446 class NxDataTraceBase
: public NxMessage
449 NxDataTraceBase(uint32_t tcode
) :
456 virtual ~NxDataTraceBase()
462 // decode the data as a string
463 const char * dszString() const;
477 class NxDataTraceWrite
: public NxDataTraceBase
488 // NxMessage implements the standard visitor pattern.
489 virtual void accept(NxMessageVisitor
&v
)
495 @abstract Returns the TCODE string
496 @return the tcode as a string
498 virtual string
tcodeString() const
500 return "Data Trace - Data Write";
503 // decode message info from the packet set
504 virtual bool decode(NxPacketSet
&pkt_set
);
506 // output message information as a string
507 virtual string
asString() const;
514 class NxDataTraceRead
: public NxDataTraceBase
525 // NxMessage implements the standard visitor pattern.
526 virtual void accept(NxMessageVisitor
&v
)
532 @abstract Returns the TCODE string
533 @return the tcode as a string
535 virtual string
tcodeString() const
537 return "Data Trace - Data Read";
540 // decode message info from the packet set
541 virtual bool decode(NxPacketSet
&pkt_set
);
543 // output message information as a string
544 virtual string
asString() const;
550 // NxDataTraceWriteSync
551 class NxDataTraceWriteSync
: public NxDataTraceBase
554 NxDataTraceWriteSync() :
558 ~NxDataTraceWriteSync()
562 // NxMessage implements the standard visitor pattern.
563 virtual void accept(NxMessageVisitor
&v
)
569 @abstract Returns the TCODE string
570 @return the tcode as a string
572 virtual string
tcodeString() const
574 return "Data Trace - Data Write w/sync";
577 // decode message info from the packet set
578 virtual bool decode(NxPacketSet
&pkt_set
);
580 // output message information as a string
581 virtual string
asString() const;
587 // NxDataTraceReadSync
588 class NxDataTraceReadSync
: public NxDataTraceBase
591 NxDataTraceReadSync() :
595 ~NxDataTraceReadSync()
599 // NxMessage implements the standard visitor pattern.
600 virtual void accept(NxMessageVisitor
&v
)
606 @abstract Returns the TCODE string
607 @return the tcode as a string
609 virtual string
tcodeString() const
611 return "Data Trace - Data Read w/sync";
614 // decode message info from the packet set
615 virtual bool decode(NxPacketSet
&pkt_set
);
617 // output message information as a string
618 virtual string
asString() const;
624 // NxWatchpointMessage
625 class NxWatchpointMessage
: public NxMessage
628 NxWatchpointMessage() :
629 NxMessage(15), wphit_(0), wphit_size_(16)
632 ~NxWatchpointMessage()
636 // NxMessage implements the standard visitor pattern.
637 virtual void accept(NxMessageVisitor
&v
)
643 @abstract Returns the TCODE string
644 @return the tcode as a string
646 virtual string
tcodeString() const
648 return "Watchpoint Message";
651 // decode message info from the packet set
652 virtual bool decode(NxPacketSet
&pkt_set
);
654 // output message information as a string
655 virtual string
asString() const;
657 // decode the data as a string
658 string
wphitString() const;
665 // Watchpoint Hit bit size
666 uint32_t wphit_size_
;
669 class NxResourceFullMessage
: public NxMessage
672 NxResourceFullMessage() :
673 NxMessage(27), rcode_(0), rdata_(0)
676 ~NxResourceFullMessage()
680 // NxMessage implements the standard visitor pattern.
681 virtual void accept(NxMessageVisitor
&v
)
687 @abstract Returns the TCODE string
688 @return the tcode as a string
690 virtual string
tcodeString() const
692 return "Resource Full Message";
695 // decode message info from the packet set
696 virtual bool decode(NxPacketSet
&pkt_set
);
698 // output message information as a string
699 virtual string
asString() const;
701 // decode the data as a string
702 const char * rcodeString() const;
714 class NxProgramTraceIndirectBranch
: public NxMessage
717 NxProgramTraceIndirectBranch() :
718 NxMessage(28), btype_(0), icnt_(0), hist_(0)
721 ~NxProgramTraceIndirectBranch()
725 // NxMessage implements the standard visitor pattern.
726 virtual void accept(NxMessageVisitor
&v
)
732 @abstract Returns the TCODE string
733 @return the tcode as a string
735 virtual string
tcodeString() const
737 return "Program Trace - Indirect Branch History";
740 // decode message info from the packet set
741 virtual bool decode(NxPacketSet
&pkt_set
);
743 // output message information as a string
744 virtual string
asString() const;
746 // decode the data as a string
747 const char * btypeString() const;
749 // get the address value
750 const SizedAddress
& address() const
770 class NxProgramTraceIndirectBranchSync
: public NxMessage
773 NxProgramTraceIndirectBranchSync() :
774 NxMessage(29), btype_(0), icnt_(0), hist_(0)
777 ~NxProgramTraceIndirectBranchSync()
781 // NxMessage implements the standard visitor pattern.
782 virtual void accept(NxMessageVisitor
&v
)
788 @abstract Returns the TCODE string
789 @return the tcode as a string
791 virtual string
tcodeString() const
793 return "Program Trace - Indirect Branch History w/sync";
796 // decode message info from the packet set
797 virtual bool decode(NxPacketSet
&pkt_set
);
799 // output message information as a string
800 virtual string
asString() const;
802 // decode the data as a string
803 const char * btypeString() const;
805 // get the address value
806 const SizedAddress
& address() const
826 class NxProgramTraceCorrelation
: public NxMessage
829 NxProgramTraceCorrelation() :
830 NxMessage(33), evcode_(0), icnt_(0), cdata_(0)
833 ~NxProgramTraceCorrelation()
837 // NxMessage implements the standard visitor pattern.
838 virtual void accept(NxMessageVisitor
&v
)
844 @abstract Returns the TCODE string
845 @return the tcode as a string
847 virtual string
tcodeString() const
849 return "Program Trace - Program Correlation";
852 // decode message info from the packet set
853 virtual bool decode(NxPacketSet
&pkt_set
);
855 // output message information as a string
856 virtual string
asString() const;
858 // decode the data as a string
859 const char * evcodeString() const;
873 // Abstract base class for all ICT types
874 class NxInCircuitTraceBase
: public NxMessage
877 NxInCircuitTraceBase(uint32_t tcode
) :
881 virtual ~NxInCircuitTraceBase()
886 @abstract Returns the TCODE string
887 @return the tcode as a string
889 virtual string
tcodeString() const;
891 // return true if this ICT Message has a "Sync" tcode
892 virtual bool isSyncMessage() const
894 return (tcode_
== 35);
898 class NxDAMInCircuitTraceMessage
: public NxInCircuitTraceBase
901 NxDAMInCircuitTraceMessage(uint32_t tcode
) :
902 NxInCircuitTraceBase(tcode
),
911 ~NxDAMInCircuitTraceMessage()
915 // NxMessage implements the standard visitor pattern.
916 virtual void accept(NxMessageVisitor
&v
)
922 @abstract Returns the ICT Message Type detail
923 @return the ICT Message type
925 virtual const char * ICTMessageType() const
927 return "DDR Terse/Verbose Message (DAM)";
930 // decode message info from the packet set
931 virtual bool decode(NxPacketSet
&pkt_set
);
933 // output message information as a string
934 virtual string
asString() const;
936 // decode the type data as a string
937 const char * ddrttString() const;
939 // decode the size data as a string
940 string
ddrszString() const;
951 // DataPath Queuing Message (DPQM) In Circuit Trace
952 class NxDPQMInCircuitTraceMessage
: public NxInCircuitTraceBase
955 NxDPQMInCircuitTraceMessage(uint32_t tcode
) :
956 NxInCircuitTraceBase(tcode
),
975 ~NxDPQMInCircuitTraceMessage()
979 // NxMessage implements the standard visitor pattern.
980 virtual void accept(NxMessageVisitor
&v
)
985 // returns the ICT Message type
986 virtual const char * ICTMessageType() const
988 return "DataPath Queuing Message (DPQM)";
991 // decode the queue event type as a string
992 const char * queueEventTypeString() const;
994 // decode the enqueue rejection response code as a string
995 const char * enqueueRejectionString() const;
997 // decode message info from the packet set
998 virtual bool decode(NxPacketSet
&pkt_set
);
1000 // output message information as a string
1001 virtual string
asString() const;
1015 // additional verbose fields
1024 // DataPath Frame Message (DPFM) In Circuit Trace
1025 class NxDPFMInCircuitTraceMessage
: public NxInCircuitTraceBase
1028 NxDPFMInCircuitTraceMessage(uint32_t tcode
) :
1029 NxInCircuitTraceBase(tcode
),
1034 for (int i
= 0; i
< 4; i
++ )
1038 ~NxDPFMInCircuitTraceMessage()
1042 // NxMessage implements the standard visitor pattern.
1043 virtual void accept(NxMessageVisitor
&v
)
1048 // returns the ICT Message type
1049 virtual const char * ICTMessageType() const
1051 return "DataPath Frame Message (DPFM)";
1054 // decode message info from the packet set
1055 virtual bool decode(NxPacketSet
&pkt_set
);
1057 // output message information as a string
1058 virtual string
asString() const;
1061 uint32_t getFmsel() const
1065 uint32_t getLbeat() const
1069 uint32_t getBtcnt() const
1073 const uint32_t * getContext() const
1082 uint32_t context_
[4]; // 128 bits of context
1086 // Core Performance Profile Message
1087 class NxCoreInCircuitTraceMessage
: public NxInCircuitTraceBase
1090 NxCoreInCircuitTraceMessage(uint32_t tcode
) :
1091 NxInCircuitTraceBase(tcode
),
1099 ~NxCoreInCircuitTraceMessage()
1103 // NxMessage implements the standard visitor pattern.
1104 virtual void accept(NxMessageVisitor
&v
)
1109 // returns the ICT Message type
1110 virtual const char * ICTMessageType() const
1112 return "Core Performance Profile Message (ICT)";
1115 // decode message info from the packet set
1116 virtual bool decode(NxPacketSet
&pkt_set
);
1118 // output message information as a string
1119 virtual string
asString() const;
1121 // decode the sync code as a string
1122 const char * syncString() const;
1124 // decode the cksrc code as a string
1125 const char * cksrcString() const;
1135 // Prototype for a ICT message type. Also a default for an
1137 class NxInCircuitTraceMessage
: public NxInCircuitTraceBase
1140 NxInCircuitTraceMessage(uint32_t tcode
) :
1141 NxInCircuitTraceBase(tcode
)
1144 ~NxInCircuitTraceMessage()
1148 // NxMessage implements the standard visitor pattern.
1149 virtual void accept(NxMessageVisitor
&v
)
1155 @abstract Returns the ICT Message Type detail
1156 @return the ICT Message type
1158 virtual const char * ICTMessageType() const
1160 return "Generic In-Circuit Trace Message";
1163 // decode message info from the packet set
1164 virtual bool decode(NxPacketSet
&pkt_set
);
1166 // output message information as a string
1167 virtual string
asString() const;
1173 class NxTimeStampCorrelation
: public NxMessage
1176 NxTimeStampCorrelation() :
1177 NxMessage(56), tcorr_(0), ttype_(0)
1180 ~NxTimeStampCorrelation()
1184 // NxMessage implements the standard visitor pattern.
1185 virtual void accept(NxMessageVisitor
&v
)
1191 @abstract Returns the TCODE string
1192 @return the tcode as a string
1194 virtual string
tcodeString() const
1196 return "Time Stamp Correlation";
1199 // decode message info from the packet set
1200 virtual bool decode(NxPacketSet
&pkt_set
);
1202 // output message information as a string
1203 virtual string
asString() const;
1205 // decode the data as a string
1206 const char * ttypeString() const;
1213 #endif // NXMESSAGE_H