summaryrefslogtreecommitdiff
path: root/contrib/opencsd/decoder/include
diff options
context:
space:
mode:
authorAndrew Turner <andrew@FreeBSD.org>2020-06-17 10:42:20 +0000
committerAndrew Turner <andrew@FreeBSD.org>2020-06-17 10:42:20 +0000
commitb6aadd183a8fc19317f893a41f252b32a87759af (patch)
tree32a547ff3fb019bf8f2f78a97886f1c803a31d0d /contrib/opencsd/decoder/include
parentc98740b5e252d1cefd6d33d93fc1015d16afc1b8 (diff)
parentd7aa8d0a1f110421252d79f5acfb72d89187ad1f (diff)
downloadsrc-test2-b6aadd183a8fc19317f893a41f252b32a87759af.tar.gz
src-test2-b6aadd183a8fc19317f893a41f252b32a87759af.zip
Notes
Diffstat (limited to 'contrib/opencsd/decoder/include')
-rw-r--r--contrib/opencsd/decoder/include/common/ocsd_dcd_mngr.h6
-rw-r--r--contrib/opencsd/decoder/include/common/ocsd_gen_elem_list.h8
-rw-r--r--contrib/opencsd/decoder/include/common/ocsd_gen_elem_stack.h109
-rw-r--r--contrib/opencsd/decoder/include/common/trc_core_arch_map.h34
-rw-r--r--contrib/opencsd/decoder/include/common/trc_gen_elem.h19
-rw-r--r--contrib/opencsd/decoder/include/common/trc_pkt_decode_base.h5
-rw-r--r--contrib/opencsd/decoder/include/common/trc_raw_buffer.h96
-rw-r--r--contrib/opencsd/decoder/include/i_dec/trc_i_decode.h7
-rw-r--r--contrib/opencsd/decoder/include/i_dec/trc_idec_arminst.h44
-rw-r--r--contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_bufptr.h1
-rw-r--r--contrib/opencsd/decoder/include/opencsd/etmv3/trc_pkt_decode_etmv3.h1
-rw-r--r--contrib/opencsd/decoder/include/opencsd/etmv4/etmv4_decoder.h1
-rw-r--r--contrib/opencsd/decoder/include/opencsd/etmv4/trc_etmv4_stack_elem.h99
-rw-r--r--contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h131
-rw-r--r--contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_elem_etmv4d.h73
-rw-r--r--contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_elem_etmv4i.h40
-rw-r--r--contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_proc_etmv4.h63
-rw-r--r--contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_proc_etmv4i.h214
-rw-r--r--contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_types_etmv4.h3
-rw-r--r--contrib/opencsd/decoder/include/opencsd/ocsd_if_types.h39
-rw-r--r--contrib/opencsd/decoder/include/opencsd/ocsd_if_version.h6
-rw-r--r--contrib/opencsd/decoder/include/opencsd/ptm/trc_pkt_decode_ptm.h1
-rw-r--r--contrib/opencsd/decoder/include/opencsd/stm/trc_pkt_decode_stm.h1
-rw-r--r--contrib/opencsd/decoder/include/opencsd/trc_gen_elem_types.h12
-rw-r--r--contrib/opencsd/decoder/include/pkt_printers/pkt_printer_t.h2
25 files changed, 759 insertions, 256 deletions
diff --git a/contrib/opencsd/decoder/include/common/ocsd_dcd_mngr.h b/contrib/opencsd/decoder/include/common/ocsd_dcd_mngr.h
index ba7d8a89c46f..3342eacb24ca 100644
--- a/contrib/opencsd/decoder/include/common/ocsd_dcd_mngr.h
+++ b/contrib/opencsd/decoder/include/common/ocsd_dcd_mngr.h
@@ -115,6 +115,9 @@ ocsd_err_t DecoderMngrBase<P,Pt,Pc>::createDecoder(const int create_flags, cons
if(!pkt_proc)
return OCSD_ERR_MEM;
+ // set the op mode flags
+ pkt_proc->setComponentOpMode(create_flags & (OCSD_OPFLG_COMP_MODE_MASK | OCSD_OPFLG_PKTPROC_COMMON));
+
// set the configuration
TrcPktProcBase<P,Pt,Pc> *pProcBase = dynamic_cast< TrcPktProcBase<P,Pt,Pc> *>(pkt_proc);
if(pProcBase == 0)
@@ -133,6 +136,9 @@ ocsd_err_t DecoderMngrBase<P,Pt,Pc>::createDecoder(const int create_flags, cons
if(!pkt_dcd)
return OCSD_ERR_MEM;
+ // set the op mode flags
+ pkt_dcd->setComponentOpMode(create_flags & (OCSD_OPFLG_COMP_MODE_MASK | OCSD_OPFLG_PKTDEC_COMMON));
+
// get the decoder base
TrcPktDecodeBase<P,Pc> *pBase = dynamic_cast< TrcPktDecodeBase<P,Pc> *>(pkt_dcd);
if(pBase == 0)
diff --git a/contrib/opencsd/decoder/include/common/ocsd_gen_elem_list.h b/contrib/opencsd/decoder/include/common/ocsd_gen_elem_list.h
index 0ff1bd59cbbe..2dab240140bf 100644
--- a/contrib/opencsd/decoder/include/common/ocsd_gen_elem_list.h
+++ b/contrib/opencsd/decoder/include/common/ocsd_gen_elem_list.h
@@ -1,6 +1,6 @@
/*
- * \file ocsd_gen_elem_stack.h
- * \brief OpenCSD : Generic element output stack.
+ * \file ocsd_gen_elem_list.h
+ * \brief OpenCSD : Generic element output list.
*
* \copyright Copyright (c) 2016, ARM Limited. All Rights Reserved.
*/
@@ -47,7 +47,7 @@
* This should remove some of the requirement on the packet processing to be re-enterant,
* simplifying this code.
*
- * Last element(s) on this stack can be marked pending to allow for later cancellation.
+ * Last element(s) on this list can be marked pending to allow for later cancellation.
* (This required for cancel element in ETMv3 exeception branch).
*
* The "list" is actually a ring buffer - maintaining pointers to indicate current valid elements.
@@ -150,4 +150,4 @@ inline void OcsdGenElemList::initSendIf(componentAttachPt<ITrcGenElemIn> *pGenEl
m_sendIf = pGenElemIf;
}
-/* End of File ocsd_gen_elem_stack.h */
+/* End of File ocsd_gen_elem_list.h */
diff --git a/contrib/opencsd/decoder/include/common/ocsd_gen_elem_stack.h b/contrib/opencsd/decoder/include/common/ocsd_gen_elem_stack.h
new file mode 100644
index 000000000000..64c525df4270
--- /dev/null
+++ b/contrib/opencsd/decoder/include/common/ocsd_gen_elem_stack.h
@@ -0,0 +1,109 @@
+/*
+* \file ocsd_gen_elem_stack.h
+* \brief OpenCSD : Generic element output stack.
+*
+* \copyright Copyright (c) 2020, ARM Limited. All Rights Reserved.
+*/
+
+/*
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice,
+* this list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software without
+* specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
+* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "trc_gen_elem.h"
+#include "comp_attach_pt_t.h"
+#include "interfaces/trc_gen_elem_in_i.h"
+
+/* element stack to handle cases where a trace element can generate multiple output packets
+
+ maintains the "current" element, which might be sent independently of this stack, and also
+ ensures that persistent data in the output elements is maintained between elements.
+*/
+class OcsdGenElemStack
+{
+public:
+ OcsdGenElemStack();
+ ~OcsdGenElemStack();
+
+ void initSendIf(componentAttachPt<ITrcGenElemIn> *pGenElemIf);
+ void initCSID(const uint8_t CSID) { m_CSID = CSID; };
+
+ OcsdTraceElement &getCurrElem(); //!< get the current element.
+ ocsd_err_t resetElemStack(); //!< set pointers to base of stack
+ ocsd_err_t addElem(const ocsd_trc_index_t trc_pkt_idx); //!< add elem to stack and set current.
+ void setCurrElemIdx(const ocsd_trc_index_t trc_pkt_idx); //!< packet index for this element
+ ocsd_err_t addElemType(const ocsd_trc_index_t trc_pkt_idx, ocsd_gen_trc_elem_t elem_type);
+
+ ocsd_datapath_resp_t sendElements(); //!< send elements on the stack
+ const int numElemToSend() const;
+
+private:
+ typedef struct _elemPtr {
+ OcsdTraceElement *pElem; //!< pointer to the listed trace element
+ ocsd_trc_index_t trc_pkt_idx; //!< packet index in the trace stream
+ } elemPtr_t;
+
+ const bool isInit(); //!< check correctly initialised.
+
+ ocsd_err_t growArray();
+ void copyPersistentData(int src, int dst); //!< copy across persistent state data between elements
+ void resetIndexes(); //!< clear down all indexes - reset or send complete.
+
+ elemPtr_t *m_pElemArray; //!< an array of pointers to elements.
+ int m_elemArraySize; //!< number of element pointers in the array
+
+ int m_elem_to_send; //!< number of live elements in the stack - init to 1.
+ int m_curr_elem_idx; //!< index into the element array.
+ int m_send_elem_idx; //!< next element to send.
+
+ //!< send packet info
+ uint8_t m_CSID;
+ componentAttachPt<ITrcGenElemIn> *m_sendIf; //!< element send interface.
+
+ bool m_is_init;
+};
+
+inline const int OcsdGenElemStack::numElemToSend() const
+{
+ return m_elem_to_send;
+}
+
+inline void OcsdGenElemStack::initSendIf(componentAttachPt<ITrcGenElemIn> *pGenElemIf)
+{
+ m_sendIf = pGenElemIf;
+}
+
+inline void OcsdGenElemStack::setCurrElemIdx(const ocsd_trc_index_t trc_pkt_idx)
+{
+ m_pElemArray[m_curr_elem_idx].trc_pkt_idx = trc_pkt_idx;
+}
+
+inline OcsdTraceElement &OcsdGenElemStack::getCurrElem()
+{
+ return *(m_pElemArray[m_curr_elem_idx].pElem);
+}
+
+
+/* End of File ocsd_gen_elem_stack.h */
diff --git a/contrib/opencsd/decoder/include/common/trc_core_arch_map.h b/contrib/opencsd/decoder/include/common/trc_core_arch_map.h
index 5a24149180fc..b72b4b411fa4 100644
--- a/contrib/opencsd/decoder/include/common/trc_core_arch_map.h
+++ b/contrib/opencsd/decoder/include/common/trc_core_arch_map.h
@@ -39,6 +39,23 @@
#include <string>
#include "opencsd/ocsd_if_types.h"
+/** @class CoreArchProfileMap
+ *
+ * @brief Map core / arch name to profile for decoder.
+ *
+ * Helper class for library clients to map core or architecture version names onto
+ * a profile / arch version pair suitable for use with the decode library.
+ *
+ * Valid core names are:-
+ * - Cortex-Axx : where xx = 5,7,12,15,17,32,35,53,55,57,65,72,73,75,76,77;
+ * - Cortex-Rxx : where xx = 5,7,8,52;
+ * - Cortex-Mxx : where xx = 0,0+,3,4,23,33;
+ *
+ * Valid architecture profile names are:-
+ * - ARMv7-A, ARMv7-R, ARMv7-M;
+ * - ARMv8-A, ARMv8.3A, ARMv8-R, ARMv8-M;
+ *
+ */
class CoreArchProfileMap
{
public:
@@ -50,16 +67,31 @@ public:
private:
std::map<std::string, ocsd_arch_profile_t> core_profiles;
+ std::map<std::string, ocsd_arch_profile_t> arch_profiles;
};
inline ocsd_arch_profile_t CoreArchProfileMap::getArchProfile(const std::string &coreName)
{
ocsd_arch_profile_t ap = { ARCH_UNKNOWN, profile_Unknown };
+ bool bFound = false;
std::map<std::string, ocsd_arch_profile_t>::const_iterator it;
+
+ /* match against the core name map. */
it = core_profiles.find(coreName);
- if(it != core_profiles.end())
+ if (it != core_profiles.end())
+ {
ap = it->second;
+ bFound = true;
+ }
+
+ /* scan architecture profiles on no core name match */
+ if (!bFound)
+ {
+ it = arch_profiles.find(coreName);
+ if (it != arch_profiles.end())
+ ap = it->second;
+ }
return ap;
}
diff --git a/contrib/opencsd/decoder/include/common/trc_gen_elem.h b/contrib/opencsd/decoder/include/common/trc_gen_elem.h
index 1c4a47b3aa0a..5d8983a8c274 100644
--- a/contrib/opencsd/decoder/include/common/trc_gen_elem.h
+++ b/contrib/opencsd/decoder/include/common/trc_gen_elem.h
@@ -72,6 +72,7 @@ public:
void setTraceOnReason(const trace_on_reason_t reason);
+ void setUnSyncEOTReason(const unsync_info_t reason);
void setAddrRange(const ocsd_vaddr_t st_addr, const ocsd_vaddr_t en_addr, const int num_instr = 1);
void setLastInstrInfo(const bool exec, const ocsd_instr_type last_i_type, const ocsd_instr_subtype last_i_subtype, const uint8_t size);
@@ -94,7 +95,8 @@ public:
// return current context
const ocsd_pe_context &getContext() const { return context; };
-
+ void copyPersistentData(const OcsdTraceElement &src);
+
private:
void printSWInfoPkt(std::ostringstream &oss) const;
void clearPerPktData(); //!< clear flags that indicate validity / have values on a per packet basis
@@ -171,8 +173,8 @@ inline void OcsdTraceElement::init()
inline void OcsdTraceElement::clearPerPktData()
{
- flag_bits = 0; // union with trace_on_reason / trace_event
-
+ flag_bits = 0; // bit-field with various flags.
+ exception_number = 0; // union with trace_on_reason / trace_event
ptr_extended_data = 0; // extended data pointer
}
@@ -181,6 +183,11 @@ inline void OcsdTraceElement::setTraceOnReason(const trace_on_reason_t reason)
trace_on_reason = reason;
}
+inline void OcsdTraceElement::setUnSyncEOTReason(const unsync_info_t reason)
+{
+ unsync_eot_info = reason;
+}
+
inline void OcsdTraceElement::setISA(const ocsd_isa isa_update)
{
isa = isa_update;
@@ -201,6 +208,12 @@ inline void OcsdTraceElement::setExtendedDataPtr(const void *data_ptr)
ptr_extended_data = data_ptr;
}
+// set persistent data between output packets.
+inline void OcsdTraceElement::copyPersistentData(const OcsdTraceElement &src)
+{
+ isa = src.isa;
+ context = src.context;
+}
/** @}*/
diff --git a/contrib/opencsd/decoder/include/common/trc_pkt_decode_base.h b/contrib/opencsd/decoder/include/common/trc_pkt_decode_base.h
index 2bbf5e51d878..da702068f372 100644
--- a/contrib/opencsd/decoder/include/common/trc_pkt_decode_base.h
+++ b/contrib/opencsd/decoder/include/common/trc_pkt_decode_base.h
@@ -85,7 +85,10 @@ protected:
virtual ocsd_err_t onProtocolConfig() = 0;
virtual const uint8_t getCoreSightTraceID() = 0;
+ /* init handling */
const bool checkInit();
+ /* Called on first init confirmation */
+ virtual void onFirstInitOK() {};
/* data output */
ocsd_datapath_resp_t outputTraceElement(const OcsdTraceElement &elem); // use current index
@@ -147,6 +150,8 @@ inline const bool TrcPktDecodeI::checkInit()
init_err_msg = "No instruction decoder interface attached and enabled";
else
m_decode_init_ok = true;
+ if (m_decode_init_ok)
+ onFirstInitOK();
}
return m_decode_init_ok;
}
diff --git a/contrib/opencsd/decoder/include/common/trc_raw_buffer.h b/contrib/opencsd/decoder/include/common/trc_raw_buffer.h
new file mode 100644
index 000000000000..67b8d2403457
--- /dev/null
+++ b/contrib/opencsd/decoder/include/common/trc_raw_buffer.h
@@ -0,0 +1,96 @@
+/*
+* \file trc_raw_buffer.h
+* \brief OpenCSD : Trace raw data byte buffer
+*
+* \copyright Copyright (c) 2019, ARM Limited. All Rights Reserved.
+*/
+
+/*
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice,
+* this list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software without
+* specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
+* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef ARM_TRC_RAW_BUFFER_H_INCLUDED
+#define ARM_TRC_RAW_BUFFER_H_INCLUDED
+
+#include <vector>
+
+class TraceRawBuffer
+{
+public:
+ TraceRawBuffer() :
+ m_bufSize(0),
+ m_bufProcessed(0),
+ m_pBuffer(0),
+ pkt(0)
+ {};
+ ~TraceRawBuffer() {};
+
+ // init the buffer
+ void init(const uint32_t size, const uint8_t *rawtrace, std::vector<uint8_t> *out_packet);
+ void copyByteToPkt(); // move a byte to the packet buffer
+ uint8_t peekNextByte(); // value of next byte in buffer.
+
+ bool empty() { return m_bufProcessed == m_bufSize; };
+ // bytes processed.
+ uint32_t processed() { return m_bufProcessed; };
+ // buffer size;
+ uint32_t size() { return m_bufSize; }
+
+private:
+ uint32_t m_bufSize;
+ uint32_t m_bufProcessed;
+ const uint8_t *m_pBuffer;
+ std::vector<uint8_t> *pkt;
+
+};
+
+// init the buffer
+inline void TraceRawBuffer::init(const uint32_t size, const uint8_t *rawtrace, std::vector<uint8_t> *out_packet)
+{
+ m_bufSize = size;
+ m_bufProcessed = 0;
+ m_pBuffer = rawtrace;
+ pkt = out_packet;
+}
+
+inline void TraceRawBuffer::copyByteToPkt()
+{
+ if (!empty()) {
+ pkt->push_back(m_pBuffer[m_bufProcessed]);
+ m_bufProcessed++;
+ }
+}
+
+inline uint8_t TraceRawBuffer::peekNextByte()
+{
+ uint8_t val = 0;
+ if (!empty())
+ val = m_pBuffer[m_bufProcessed];
+ return val;
+}
+
+#endif // ARM_TRC_RAW_BUFFER_H_INCLUDED
+
diff --git a/contrib/opencsd/decoder/include/i_dec/trc_i_decode.h b/contrib/opencsd/decoder/include/i_dec/trc_i_decode.h
index 0285f4182523..d519a3aca7be 100644
--- a/contrib/opencsd/decoder/include/i_dec/trc_i_decode.h
+++ b/contrib/opencsd/decoder/include/i_dec/trc_i_decode.h
@@ -46,10 +46,9 @@ public:
virtual ocsd_err_t DecodeInstruction(ocsd_instr_info *instr_info);
private:
- ocsd_err_t DecodeA32(ocsd_instr_info *instr_info);
- ocsd_err_t DecodeA64(ocsd_instr_info *instr_info);
- ocsd_err_t DecodeT32(ocsd_instr_info *instr_info);
- void SetArchVersion(ocsd_instr_info *instr_info);
+ ocsd_err_t DecodeA32(ocsd_instr_info *instr_info, struct decode_info *info);
+ ocsd_err_t DecodeA64(ocsd_instr_info *instr_info, struct decode_info *info);
+ ocsd_err_t DecodeT32(ocsd_instr_info *instr_info, struct decode_info *info);
};
#endif // ARM_TRC_I_DECODE_H_INCLUDED
diff --git a/contrib/opencsd/decoder/include/i_dec/trc_idec_arminst.h b/contrib/opencsd/decoder/include/i_dec/trc_idec_arminst.h
index 8697f68d676c..911b0cf7db95 100644
--- a/contrib/opencsd/decoder/include/i_dec/trc_idec_arminst.h
+++ b/contrib/opencsd/decoder/include/i_dec/trc_idec_arminst.h
@@ -42,6 +42,12 @@
#include "opencsd/ocsd_if_types.h"
#include <cstdint>
+/* supplementary decode information */
+struct decode_info {
+ uint16_t arch_version;
+ ocsd_instr_subtype instr_sub_type;
+};
+
/*
For Thumb2, test if a halfword is the first half of a 32-bit instruction,
as opposed to a complete 16-bit instruction.
@@ -63,19 +69,19 @@ instructions that write to the PC. It does not include exception
instructions such as SVC, HVC and SMC.
(Performance event 0x0C includes these.)
*/
-int inst_ARM_is_branch(uint32_t inst);
-int inst_Thumb_is_branch(uint32_t inst);
-int inst_A64_is_branch(uint32_t inst);
+int inst_ARM_is_branch(uint32_t inst, struct decode_info *info);
+int inst_Thumb_is_branch(uint32_t inst, struct decode_info *info);
+int inst_A64_is_branch(uint32_t inst, struct decode_info *info);
/*
Test whether an instruction is a direct (aka immediate) branch.
Performance event 0x0D counts these.
*/
int inst_ARM_is_direct_branch(uint32_t inst);
-int inst_Thumb_is_direct_branch(uint32_t inst);
-int inst_Thumb_is_direct_branch_link(uint32_t inst, uint8_t *is_link, uint8_t *is_cond);
-int inst_A64_is_direct_branch(uint32_t inst);
-int inst_A64_is_direct_branch_link(uint32_t inst, uint8_t *is_link);
+int inst_Thumb_is_direct_branch(uint32_t inst, struct decode_info *info);
+int inst_Thumb_is_direct_branch_link(uint32_t inst, uint8_t *is_link, uint8_t *is_cond, struct decode_info *info);
+int inst_A64_is_direct_branch(uint32_t inst, struct decode_info *info);
+int inst_A64_is_direct_branch_link(uint32_t inst, uint8_t *is_link, struct decode_info *info);
/*
Get branch destination for a direct branch.
@@ -84,15 +90,15 @@ int inst_ARM_branch_destination(uint32_t addr, uint32_t inst, uint32_t *pnpc);
int inst_Thumb_branch_destination(uint32_t addr, uint32_t inst, uint32_t *pnpc);
int inst_A64_branch_destination(uint64_t addr, uint32_t inst, uint64_t *pnpc);
-int inst_ARM_is_indirect_branch(uint32_t inst);
-int inst_Thumb_is_indirect_branch_link(uint32_t inst, uint8_t *is_link);
-int inst_Thumb_is_indirect_branch(uint32_t inst);
-int inst_A64_is_indirect_branch_link(uint32_t inst, uint8_t *is_link);
-int inst_A64_is_indirect_branch(uint32_t inst);
+int inst_ARM_is_indirect_branch(uint32_t inst, struct decode_info *info);
+int inst_Thumb_is_indirect_branch_link(uint32_t inst, uint8_t *is_link, struct decode_info *info);
+int inst_Thumb_is_indirect_branch(uint32_t inst, struct decode_info *info);
+int inst_A64_is_indirect_branch_link(uint32_t inst, uint8_t *is_link, struct decode_info *info);
+int inst_A64_is_indirect_branch(uint32_t inst, struct decode_info *info);
-int inst_ARM_is_branch_and_link(uint32_t inst);
-int inst_Thumb_is_branch_and_link(uint32_t inst);
-int inst_A64_is_branch_and_link(uint32_t inst);
+int inst_ARM_is_branch_and_link(uint32_t inst, struct decode_info *info);
+int inst_Thumb_is_branch_and_link(uint32_t inst, struct decode_info *info);
+int inst_A64_is_branch_and_link(uint32_t inst, struct decode_info *info);
int inst_ARM_is_conditional(uint32_t inst);
int inst_Thumb_is_conditional(uint32_t inst);
@@ -128,14 +134,6 @@ int inst_ARM_is_UDF(uint32_t inst);
int inst_Thumb_is_UDF(uint32_t inst);
int inst_A64_is_UDF(uint32_t inst);
-
-/* access sub-type information */
-ocsd_instr_subtype get_instr_subtype();
-void clear_instr_subtype();
-
-/* set arch version info. */
-void set_arch_version(uint16_t version);
-
#endif // ARM_TRC_IDEC_ARMINST_H_INCLUDED
/* End of File trc_idec_arminst.h */
diff --git a/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_bufptr.h b/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_bufptr.h
index bd9ea8ee1e5d..b6208a7d8a13 100644
--- a/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_bufptr.h
+++ b/contrib/opencsd/decoder/include/mem_acc/trc_mem_acc_bufptr.h
@@ -68,7 +68,6 @@ public:
private:
const uint8_t *m_p_buffer; /**< pointer to the memory buffer */
- const uint32_t m_size; /**< size of the memory buffer. */
};
#endif // ARM_TRC_MEM_ACC_BUFPTR_H_INCLUDED
diff --git a/contrib/opencsd/decoder/include/opencsd/etmv3/trc_pkt_decode_etmv3.h b/contrib/opencsd/decoder/include/opencsd/etmv3/trc_pkt_decode_etmv3.h
index b2139c0d9e68..902770655a53 100644
--- a/contrib/opencsd/decoder/include/opencsd/etmv3/trc_pkt_decode_etmv3.h
+++ b/contrib/opencsd/decoder/include/opencsd/etmv3/trc_pkt_decode_etmv3.h
@@ -264,6 +264,7 @@ private:
} processor_state_t;
processor_state_t m_curr_state;
+ unsync_info_t m_unsync_info; //!< additional state for unsync
uint8_t m_CSID; //!< Coresight trace ID for this decoder.
};
diff --git a/contrib/opencsd/decoder/include/opencsd/etmv4/etmv4_decoder.h b/contrib/opencsd/decoder/include/opencsd/etmv4/etmv4_decoder.h
index 05bdd44d683e..5d183631a721 100644
--- a/contrib/opencsd/decoder/include/opencsd/etmv4/etmv4_decoder.h
+++ b/contrib/opencsd/decoder/include/opencsd/etmv4/etmv4_decoder.h
@@ -38,7 +38,6 @@
#include "trc_cmp_cfg_etmv4.h"
#include "trc_pkt_elem_etmv4i.h"
-#include "trc_pkt_elem_etmv4d.h"
#include "trc_pkt_proc_etmv4.h"
#include "trc_pkt_types_etmv4.h"
#include "trc_pkt_decode_etmv4i.h"
diff --git a/contrib/opencsd/decoder/include/opencsd/etmv4/trc_etmv4_stack_elem.h b/contrib/opencsd/decoder/include/opencsd/etmv4/trc_etmv4_stack_elem.h
index 15996547163c..5a283c541f3e 100644
--- a/contrib/opencsd/decoder/include/opencsd/etmv4/trc_etmv4_stack_elem.h
+++ b/contrib/opencsd/decoder/include/opencsd/etmv4/trc_etmv4_stack_elem.h
@@ -56,6 +56,7 @@ typedef enum _p0_elem_t
P0_TS,
P0_CC,
P0_TS_CC,
+ P0_Q,
P0_OVERFLOW,
P0_FUNC_RET,
} p0_elem_t;
@@ -120,6 +121,44 @@ inline TrcStackElemAddr::TrcStackElemAddr(const ocsd_etmv4_i_pkt_type root_pkt,
}
/************************************************************/
+/** Q element */
+class TrcStackQElem : public TrcStackElem
+{
+protected:
+ TrcStackQElem(const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index);
+ virtual ~TrcStackQElem() {};
+
+ friend class EtmV4P0Stack;
+
+public:
+ void setInstrCount(const int instr_count) { m_instr_count = instr_count; };
+ const int getInstrCount() const { return m_instr_count; }
+
+ void setAddr(const etmv4_addr_val_t &addr_val)
+ {
+ m_addr_val = addr_val;
+ m_has_addr = true;
+ };
+ const etmv4_addr_val_t &getAddr() const { return m_addr_val; };
+ const bool hasAddr() const { return m_has_addr; };
+
+private:
+ bool m_has_addr;
+ etmv4_addr_val_t m_addr_val;
+ int m_instr_count;
+
+};
+
+inline TrcStackQElem::TrcStackQElem(const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index) :
+ TrcStackElem(P0_Q , true, root_pkt, root_index)
+{
+ m_addr_val.val = 0;
+ m_addr_val.isa = 0;
+ m_has_addr = false;
+ m_instr_count = 0;
+}
+
+/************************************************************/
/** Context element */
class TrcStackElemCtxt : public TrcStackElem
@@ -133,9 +172,12 @@ protected:
public:
void setContext(const etmv4_context_t &ctxt) { m_context = ctxt; };
const etmv4_context_t &getContext() const { return m_context; };
+ void setIS(const uint8_t IS) { m_IS = IS; };
+ const uint8_t getIS() const { return m_IS; };
private:
etmv4_context_t m_context;
+ uint8_t m_IS; //!< IS value at time of generation of packet.
};
inline TrcStackElemCtxt::TrcStackElemCtxt(const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index) :
@@ -188,6 +230,7 @@ public:
const ocsd_atm_val commitOldest();
int cancelNewest(const int nCancel);
+ void mispredictNewest();
const bool isEmpty() const { return (m_atom.num == 0); };
private:
@@ -217,6 +260,16 @@ inline int TrcStackElemAtom::cancelNewest(const int nCancel)
return nRemove;
}
+// mispredict newest - flip the bit of the newest atom
+inline void TrcStackElemAtom::mispredictNewest()
+{
+ uint32_t mask = 0x1 << (m_atom.num - 1);
+ if (m_atom.En_bits & mask)
+ m_atom.En_bits &= ~mask;
+ else
+ m_atom.En_bits |= mask;
+}
+
/************************************************************/
/** Generic param element */
@@ -252,12 +305,20 @@ public:
void push_front(TrcStackElem *pElem);
void push_back(TrcStackElem *pElem); // insert element when processing
- void pop_back();
+ void pop_back(bool pend_delete = true);
+ void pop_front(bool pend_delete = true);
TrcStackElem *back();
+ TrcStackElem *front();
size_t size();
+ // iterate through stack from front
+ void from_front_init();
+ TrcStackElem *from_front_next();
+ void erase_curr_from_front(); // erase the element last returned
+
void delete_all();
void delete_back();
+ void delete_front();
void delete_popped();
// creation functions - create and push if successful.
@@ -265,13 +326,13 @@ public:
TrcStackElem *createParamElemNoParam(const p0_elem_t p0_type, const bool isP0, const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index, bool back = false);
TrcStackElemAtom *createAtomElem (const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index, const ocsd_pkt_atom &atom);
TrcStackElemExcept *createExceptElem(const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index, const bool bSame, const uint16_t excepNum);
- TrcStackElemCtxt *createContextElem(const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index, const etmv4_context_t &context);
+ TrcStackElemCtxt *createContextElem(const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index, const etmv4_context_t &context, const uint8_t IS, const bool back = false);
TrcStackElemAddr *createAddrElem(const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index, const etmv4_addr_val_t &addr_val);
-
+ TrcStackQElem *createQElem(const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index, const int count);
private:
std::deque<TrcStackElem *> m_P0_stack; //!< P0 decode element stack
std::vector<TrcStackElem *> m_popped_elem; //!< save list of popped but not deleted elements.
-
+ std::deque<TrcStackElem *>::iterator m_iter; //!< iterate across the list w/o removing stuff
};
inline EtmV4P0Stack::~EtmV4P0Stack()
@@ -293,12 +354,20 @@ inline void EtmV4P0Stack::push_back(TrcStackElem *pElem)
}
// pop last element pointer off the stack and stash it for later deletion
-inline void EtmV4P0Stack::pop_back()
+inline void EtmV4P0Stack::pop_back(bool pend_delete /* = true */)
{
- m_popped_elem.push_back(m_P0_stack.back());
+ if (pend_delete)
+ m_popped_elem.push_back(m_P0_stack.back());
m_P0_stack.pop_back();
}
+inline void EtmV4P0Stack::pop_front(bool pend_delete /* = true */)
+{
+ if (pend_delete)
+ m_popped_elem.push_back(m_P0_stack.front());
+ m_P0_stack.pop_front();
+}
+
// pop last element pointer off the stack and delete immediately
inline void EtmV4P0Stack::delete_back()
{
@@ -310,12 +379,30 @@ inline void EtmV4P0Stack::delete_back()
}
}
+// pop first element pointer off the stack and delete immediately
+inline void EtmV4P0Stack::delete_front()
+{
+ if (m_P0_stack.size() > 0)
+ {
+ TrcStackElem* pElem = m_P0_stack.front();
+ delete pElem;
+ m_P0_stack.pop_front();
+ }
+}
+
+
+
// get a pointer to the last element on the stack
inline TrcStackElem *EtmV4P0Stack::back()
{
return m_P0_stack.back();
}
+inline TrcStackElem *EtmV4P0Stack::front()
+{
+ return m_P0_stack.front();
+}
+
// remove and delete all the elements left on the stack
inline void EtmV4P0Stack::delete_all()
{
diff --git a/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h b/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h
index 1c06e5ddf03a..419cd828928c 100644
--- a/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h
+++ b/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h
@@ -40,6 +40,7 @@
#include "opencsd/etmv4/trc_cmp_cfg_etmv4.h"
#include "common/trc_gen_elem.h"
#include "common/trc_ret_stack.h"
+#include "common/ocsd_gen_elem_stack.h"
#include "opencsd/etmv4/trc_etmv4_stack_elem.h"
class TrcStackElem;
@@ -65,35 +66,69 @@ protected:
/* local decode methods */
void initDecoder(); // initial state on creation (zeros all config)
void resetDecoder(); // reset state to start of decode. (moves state, retains config)
+ virtual void onFirstInitOK(); // override to set init related info.
- ocsd_datapath_resp_t decodePacket(bool &Complete); // return true to indicate decode complete - can change FSM to commit state - return is false.
- ocsd_datapath_resp_t commitElements(bool &Complete); // commit elements - may get wait response, or flag completion.
- ocsd_datapath_resp_t flushEOT();
+ ocsd_err_t decodePacket(); // decode packet into trace elements. return true to indicate decode complete - can change FSM to commit state - return is false.
+ ocsd_datapath_resp_t resolveElements(); // commit/cancel trace elements generated from latest / prior packets & send to output - may get wait response, or flag completion.
+ ocsd_err_t commitElements(); // commit elements - process element stack to generate output packets.
+ ocsd_err_t commitElemOnEOT();
+ ocsd_err_t cancelElements(); // cancel elements. These not output
+ ocsd_err_t mispredictAtom(); // mispredict an atom
+ ocsd_err_t discardElements(); // discard elements and flush
void doTraceInfoPacket();
- void updateContext(TrcStackElemCtxt *pCtxtElem);
+ void updateContext(TrcStackElemCtxt *pCtxtElem, OcsdTraceElement &elem);
- // process atom will output instruction trace, or no memory access trace elements.
- ocsd_datapath_resp_t processAtom(const ocsd_atm_val, bool &bCont);
+ // process atom will create instruction trace, or no memory access trace output elements.
+ ocsd_err_t processAtom(const ocsd_atm_val atom);
// process an exception element - output instruction trace + exception generic type.
- ocsd_datapath_resp_t processException();
+ ocsd_err_t processException();
+
+ // process Q element
+ ocsd_err_t processQElement();
+
+ // process an element that cannot be cancelled / discarded
+ ocsd_err_t processTS_CC_EventElem(TrcStackElem *pElem);
// process a bad packet
- ocsd_datapath_resp_t handleBadPacket(const char *reason);
+ ocsd_err_t handleBadPacket(const char *reason);
- ocsd_datapath_resp_t outputCC(TrcStackElemParam *pParamElem);
- ocsd_datapath_resp_t outputTS(TrcStackElemParam *pParamElem, bool withCC);
- ocsd_datapath_resp_t outputEvent(TrcStackElemParam *pParamElem);
+ ocsd_err_t addElemCC(TrcStackElemParam *pParamElem);
+ ocsd_err_t addElemTS(TrcStackElemParam *pParamElem, bool withCC);
+ ocsd_err_t addElemEvent(TrcStackElemParam *pParamElem);
private:
void SetInstrInfoInAddrISA(const ocsd_vaddr_t addr_val, const uint8_t isa);
+ const ocsd_isa calcISA(const bool SF, const uint8_t IS) const
+ {
+ if (SF)
+ return ocsd_isa_aarch64;
+ return (IS == 0) ? ocsd_isa_arm : ocsd_isa_thumb2;
+ }
+ typedef enum {
+ WP_NOT_FOUND,
+ WP_FOUND,
+ WP_NACC
+ } WP_res_t;
+
+ typedef struct {
+ ocsd_vaddr_t st_addr;
+ ocsd_vaddr_t en_addr;
+ uint32_t num_instr;
+ } instr_range_t;
- ocsd_err_t traceInstrToWP(bool &bWPFound, const bool traceToAddrNext = false, const ocsd_vaddr_t nextAddrMatch = 0); //!< follow instructions from the current address to a WP. true if good, false if memory cannot be accessed.
+ //!< follow instructions from the current address to a WP. true if good, false if memory cannot be accessed.
+ ocsd_err_t traceInstrToWP(instr_range_t &instr_range, WP_res_t &WPRes, const bool traceToAddrNext = false, const ocsd_vaddr_t nextAddrMatch = 0);
- ocsd_datapath_resp_t returnStackPop(); // pop return stack and update instruction address.
+ inline const bool WPFound(WP_res_t res) const { return (res == WP_FOUND); };
+ inline const bool WPNacc(WP_res_t res) const { return (res == WP_NACC); };
+
+ ocsd_err_t returnStackPop(); // pop return stack and update instruction address.
- ocsd_datapath_resp_t outputTraceRange(const bool executed, ocsd_trc_index_t index);
+ void setElemTraceRange(OcsdTraceElement &elemIn, const instr_range_t &addr_range, const bool executed, ocsd_trc_index_t index);
+
+ ocsd_mem_space_acc_t getCurrMemSpace();
//** intra packet state (see ETMv4 spec 6.2.1);
@@ -105,14 +140,18 @@ private:
uint32_t m_vmid_id; // most recent VMID
bool m_is_secure; // true if Secure
bool m_is_64bit; // true if 64 bit
+ uint8_t m_last_IS; // last instruction set value from address packet.
// cycle counts
int m_cc_threshold;
- // speculative trace (unsupported at present in the decoder).
+ // speculative trace
int m_curr_spec_depth;
- int m_max_spec_depth;
-
+ int m_max_spec_depth; // nax depth - from ID reg, beyond which auto-commit occurs
+ int m_unseen_spec_elem; // speculative elements at decode start
+
+/** Remove elements that are associated with data trace */
+#ifdef DATA_TRACE_SUPPORTED
// data trace associative elements (unsupported at present in the decoder).
int m_p0_key;
int m_p0_key_max;
@@ -121,6 +160,7 @@ private:
int m_cond_c_key;
int m_cond_r_key;
int m_cond_key_max_incr;
+#endif
uint8_t m_CSID; //!< Coresight trace ID for this decoder.
@@ -134,55 +174,52 @@ private:
WAIT_SYNC, //!< waiting for sync packet.
WAIT_TINFO, //!< waiting for trace info packet.
DECODE_PKTS, //!< processing packets - creating decode elements on stack
- COMMIT_ELEM, //!< commit elements for execution - create generic trace elements and pass on.
+ RESOLVE_ELEM, //!< analyze / resolve decode elements - create generic trace elements and pass on.
} processor_state_t;
processor_state_t m_curr_state;
+ unsync_info_t m_unsync_eot_info; //!< addition info when / why unsync / eot
//** P0 element stack
EtmV4P0Stack m_P0_stack; //!< P0 decode element stack
- int m_P0_commit; //!< number of elements to commit
+ // element resolution
+ struct {
+ int P0_commit; //!< number of elements to commit
+ int P0_cancel; //!< elements to cancel
+ bool mispredict; //!< mispredict latest atom
+ bool discard; //!< discard elements
+ } m_elem_res;
+
+ //! true if any of the element resolution fields are non-zero
+ const bool isElemForRes() const {
+ return (m_elem_res.P0_commit || m_elem_res.P0_cancel ||
+ m_elem_res.mispredict || m_elem_res.discard);
+ }
+
+ void clearElemRes() {
+ m_elem_res.P0_commit = 0;
+ m_elem_res.P0_cancel = 0;
+ m_elem_res.mispredict = false;
+ m_elem_res.discard = false;
+ }
// packet decode state
bool m_need_ctxt; //!< need context to continue
bool m_need_addr; //!< need an address to continue
- bool m_except_pending_addr; //!< next address packet is part of exception.
-
- // exception packet processing state (may need excep elem only, range+excep, range+
- typedef enum {
- EXCEP_POP, // start of processing read exception packets off the stack and analyze
- EXCEP_RANGE, // output a range element
- EXCEP_NACC, // output a nacc element
- EXCEP_CTXT, // output a ctxt element
- EXCEP_EXCEP, // output an ecxeption element.
- } excep_proc_state_t;
-
- struct {
- excep_proc_state_t proc; //!< state of exception processing
- etmv4_addr_val_t addr; //!< excetion return address.
- uint32_t number; //!< exception number.
- ocsd_trc_index_t index; //!< trace index for exception element
- bool addr_b_tgt; //!< return address is also branch tgt address.
- } m_excep_info; //!< exception info when processing exception packets
+ bool m_elem_pending_addr; //!< next address packet is needed for prev element.
ocsd_instr_info m_instr_info; //!< instruction info for code follower - in address is the next to be decoded.
- bool m_mem_nacc_pending; //!< need to output a memory access failure packet
- ocsd_vaddr_t m_nacc_addr; //!< record unaccessible address
-
- ocsd_pe_context m_pe_context; //!< current context information
etmv4_trace_info_t m_trace_info; //!< trace info for this trace run.
bool m_prev_overflow;
- bool m_flush_EOT; //!< true if doing an end of trace flush - cleans up lingering events / TS / CC
-
- TrcAddrReturnStack m_return_stack;
-
-//** output element
- OcsdTraceElement m_output_elem;
+ TrcAddrReturnStack m_return_stack; //!< the address return stack.
+//** output element handling
+ OcsdGenElemStack m_out_elem; //!< output element stack.
+ OcsdTraceElement &outElem() { return m_out_elem.getCurrElem(); }; //!< current out element
};
#endif // ARM_TRC_PKT_DECODE_ETMV4I_H_INCLUDED
diff --git a/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_elem_etmv4d.h b/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_elem_etmv4d.h
deleted file mode 100644
index bb6a0029c0c0..000000000000
--- a/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_elem_etmv4d.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * \file trc_pkt_elem_etmv4d.h
- * \brief OpenCSD :
- *
- * \copyright Copyright (c) 2015, ARM Limited. All Rights Reserved.
- */
-
-/*
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors
- * may be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ARM_TRC_PKT_ELEM_ETMV4D_H_INCLUDED
-#define ARM_TRC_PKT_ELEM_ETMV4D_H_INCLUDED
-
-#include "trc_pkt_types_etmv4.h"
-#include "common/trc_printable_elem.h"
-#include "common/trc_pkt_elem_base.h"
-
-/** @addtogroup trc_pkts
-@{*/
-/*!
- * @class EtmV4DTrcPacket
- * @brief ETMv4 Data Trace Protocol Packet .
- *
- * This class represents a single ETMv4 instruction trace packet, along with intra packet state.
- *
- */
-class EtmV4DTrcPacket : public TrcPacketBase, public ocsd_etmv4_d_pkt, trcPrintableElem
-{
-public:
- EtmV4DTrcPacket();
- ~EtmV4DTrcPacket();
-
- // update interface - set packet values
-
-
-
- // packet status interface - get packet info.
-
-
- // printing
- virtual void toString(std::string &str) const;
- virtual void toStringFmt(const uint32_t fmtFlags, std::string &str) const;
-};
-
-/** @}*/
-
-#endif // ARM_TRC_PKT_ELEM_ETMV4D_H_INCLUDED
-
-/* End of File trc_pkt_elem_etmv4d.h */
diff --git a/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_elem_etmv4i.h b/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_elem_etmv4i.h
index 02adfc51aa75..8ccf36b373db 100644
--- a/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_elem_etmv4i.h
+++ b/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_elem_etmv4i.h
@@ -57,14 +57,7 @@ class Etmv4PktAddrStack
public:
Etmv4PktAddrStack()
{
- for (int i = 0; i < 3; i++)
- {
- m_v_addr[i].pkt_bits = 0;
- m_v_addr[i].size = VA_64BIT;
- m_v_addr[i].val = 0;
- m_v_addr[i].valid_bits = 0;
- m_v_addr_ISA[i] = 0;
- }
+ reset_stack();
}
~Etmv4PktAddrStack() {};
@@ -87,6 +80,20 @@ public:
}
}
+ // explicit reset for TInfo.
+ void reset_stack()
+ {
+ for (int i = 0; i < 3; i++)
+ {
+ m_v_addr[i].pkt_bits = 0;
+ m_v_addr[i].size = OCSD_MAX_VA_BITSIZE == 64 ? VA_64BIT : VA_32BIT;
+ m_v_addr[i].val = 0;
+ m_v_addr[i].valid_bits = OCSD_MAX_VA_BITSIZE;
+ m_v_addr_ISA[i] = 0;
+ }
+
+ }
+
private:
ocsd_pkt_vaddr m_v_addr[3]; //!< most recently broadcast address packet
uint8_t m_v_addr_ISA[3];
@@ -172,6 +179,7 @@ public:
// atom
const ocsd_pkt_atom &getAtom() const { return atom; };
+ const int getNumAtoms() const { return atom.num; };
// context
const etmv4_context_t &getContext() const { return context; };
@@ -188,6 +196,10 @@ public:
// cc
const uint32_t getCC() const { return pkt_valid.bits.cc_valid ? cycle_count : 0; };
+ // speculation
+ const int getCommitElem() const { return commit_elements; };
+ const int getCancelElem() const { return cancel_elements; };
+
// packet type
const bool isBadPacket() const;
@@ -227,6 +239,10 @@ inline void EtmV4ITrcPacket::clearTraceInfo()
// set these as defaults - if they don't appear in TINFO this is the state.
setTraceInfo(0);
setTraceInfoSpec(0);
+
+ // explicitly reset the stack & zero the current address.
+ m_addr_stack.reset_stack();
+ m_addr_stack.get_idx(0, v_addr, v_addr_ISA);
}
inline void EtmV4ITrcPacket::setTraceInfo(const uint32_t infoVal)
@@ -450,17 +466,17 @@ inline void EtmV4ITrcPacket::set32BitAddress(const uint32_t addr, const uint8_t
if (pkt_valid.bits.context_valid && context.SF)
{
v_addr.size = VA_64BIT;
- if (v_addr.valid_bits < 32) // may be updating a 64 bit address so only set 32 if currently less.
- v_addr.valid_bits = 32;
v_addr.val = (v_addr.val & ~mask) | (addr & mask);
}
else
{
v_addr.val = addr;
v_addr.size = VA_32BIT;
- v_addr.valid_bits = 32;
}
-
+
+ if (v_addr.valid_bits < 32) // may be updating a 64 bit address so only set 32 if currently less.
+ v_addr.valid_bits = 32;
+
v_addr_ISA = IS;
push_vaddr();
}
diff --git a/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_proc_etmv4.h b/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_proc_etmv4.h
index 0d9ccea2be54..25bdf5109558 100644
--- a/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_proc_etmv4.h
+++ b/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_proc_etmv4.h
@@ -35,70 +35,13 @@
#ifndef ARM_TRC_PKT_PROC_ETMV4_H_INCLUDED
#define ARM_TRC_PKT_PROC_ETMV4_H_INCLUDED
+// split I & D into separate files, retain this header for backward compatibility
+// for now just include the I packet processor as that is the only one implemented.
#include "trc_pkt_types_etmv4.h"
+#include "trc_pkt_proc_etmv4i.h"
#include "common/trc_pkt_proc_base.h"
-class EtmV4IPktProcImpl; /**< ETMv4 I channel packet processor */
-class EtmV4DPktProcImpl; /**< ETMv4 D channel packet processor */
-class EtmV4ITrcPacket;
-class EtmV4DTrcPacket;
-class EtmV4Config;
-
-/** @addtogroup ocsd_pkt_proc
-@{*/
-
-class TrcPktProcEtmV4I : public TrcPktProcBase< EtmV4ITrcPacket, ocsd_etmv4_i_pkt_type, EtmV4Config>
-{
-public:
- TrcPktProcEtmV4I();
- TrcPktProcEtmV4I(int instIDNum);
- virtual ~TrcPktProcEtmV4I();
-
-protected:
- /* implementation packet processing interface */
- virtual ocsd_datapath_resp_t processData( const ocsd_trc_index_t index,
- const uint32_t dataBlockSize,
- const uint8_t *pDataBlock,
- uint32_t *numBytesProcessed);
- virtual ocsd_datapath_resp_t onEOT();
- virtual ocsd_datapath_resp_t onReset();
- virtual ocsd_datapath_resp_t onFlush();
- virtual ocsd_err_t onProtocolConfig();
- virtual const bool isBadPacket() const;
-
- friend class EtmV4IPktProcImpl;
-
- EtmV4IPktProcImpl *m_pProcessor;
-};
-
-
-class TrcPktProcEtmV4D : public TrcPktProcBase< EtmV4DTrcPacket, ocsd_etmv4_d_pkt_type, EtmV4Config>
-{
-public:
- TrcPktProcEtmV4D();
- TrcPktProcEtmV4D(int instIDNum);
- virtual ~TrcPktProcEtmV4D();
-
-protected:
- /* implementation packet processing interface */
- virtual ocsd_datapath_resp_t processData( const ocsd_trc_index_t index,
- const uint32_t dataBlockSize,
- const uint8_t *pDataBlock,
- uint32_t *numBytesProcessed);
- virtual ocsd_datapath_resp_t onEOT();
- virtual ocsd_datapath_resp_t onReset();
- virtual ocsd_datapath_resp_t onFlush();
- virtual ocsd_err_t onProtocolConfig();
- virtual const bool isBadPacket() const;
-
- friend class EtmV4DPktProcImpl;
-
- EtmV4DPktProcImpl *m_pProcessor;
-};
-
-/** @}*/
-
#endif // ARM_TRC_PKT_PROC_ETMV4_H_INCLUDED
/* End of File trc_pkt_proc_etmv4.h */
diff --git a/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_proc_etmv4i.h b/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_proc_etmv4i.h
new file mode 100644
index 000000000000..abc322654b8d
--- /dev/null
+++ b/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_proc_etmv4i.h
@@ -0,0 +1,214 @@
+/*
+ * \file trc_pkt_proc_etmv4i.h
+ * \brief OpenCSD : Implementation of ETMv4 packet processing
+ *
+ * \copyright Copyright (c) 2015, 2019 ARM Limited. All Rights Reserved.
+ */
+
+/*
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ARM_TRC_PKT_PROC_ETMV4I_IMPL_H_INCLUDED
+#define ARM_TRC_PKT_PROC_ETMV4I_IMPL_H_INCLUDED
+
+#include "trc_pkt_types_etmv4.h"
+#include "opencsd/etmv4/trc_pkt_proc_etmv4.h"
+#include "opencsd/etmv4/trc_cmp_cfg_etmv4.h"
+#include "opencsd/etmv4/trc_pkt_elem_etmv4i.h"
+#include "common/trc_raw_buffer.h"
+#include "common/trc_pkt_proc_base.h"
+
+class EtmV4ITrcPacket;
+class EtmV4Config;
+
+/** @addtogroup ocsd_pkt_proc
+@{*/
+
+class TrcPktProcEtmV4I : public TrcPktProcBase< EtmV4ITrcPacket, ocsd_etmv4_i_pkt_type, EtmV4Config>
+{
+public:
+ TrcPktProcEtmV4I();
+ TrcPktProcEtmV4I(int instIDNum);
+ virtual ~TrcPktProcEtmV4I();
+
+protected:
+ /* implementation packet processing interface */
+ virtual ocsd_datapath_resp_t processData( const ocsd_trc_index_t index,
+ const uint32_t dataBlockSize,
+ const uint8_t *pDataBlock,
+ uint32_t *numBytesProcessed);
+ virtual ocsd_datapath_resp_t onEOT();
+ virtual ocsd_datapath_resp_t onReset();
+ virtual ocsd_datapath_resp_t onFlush();
+ virtual ocsd_err_t onProtocolConfig();
+ virtual const bool isBadPacket() const;
+
+protected:
+ typedef enum _process_state {
+ PROC_HDR,
+ PROC_DATA,
+ SEND_PKT,
+ SEND_UNSYNCED,
+ PROC_ERR,
+ } process_state;
+
+ process_state m_process_state;
+
+ void InitPacketState(); // clear current packet state.
+ void InitProcessorState(); // clear all previous process state
+
+ /** packet processor configuration **/
+ bool m_isInit;
+
+ // etmv4 hardware configuration
+ EtmV4Config m_config;
+
+ /** packet data **/
+ TraceRawBuffer m_trcIn; // trace data in buffer
+ std::vector<uint8_t> m_currPacketData; // raw data packet
+ int m_currPktIdx; // index into raw packet when expanding
+ EtmV4ITrcPacket m_curr_packet; // expanded packet
+ ocsd_trc_index_t m_packet_index; // index of the start of the current packet
+ ocsd_trc_index_t m_blockIndex; // index at the start of the current data block being processed
+
+ // searching for sync
+ bool m_is_sync; //!< seen first sync packet
+ bool m_first_trace_info; //!< seen first trace info packet after sync
+ bool m_sent_notsync_packet; //!< send one not sync packet if we see any unsynced data on the channel
+ unsigned m_dump_unsynced_bytes; //!< number of unsynced bytes to send
+ ocsd_trc_index_t m_update_on_unsync_packet_index;
+
+
+private:
+ // current processing state data - counts and flags to determine if a packet is complete.
+
+ // TraceInfo Packet
+ // flags to indicate processing progress for these sections is complete.
+ struct _t_info_pkt_prog {
+ uint8_t sectFlags;
+ uint8_t ctrlBytes;
+ } m_tinfo_sections;
+
+ #define TINFO_INFO_SECT 0x01
+ #define TINFO_KEY_SECT 0x02
+ #define TINFO_SPEC_SECT 0x04
+ #define TINFO_CYCT_SECT 0x08
+ #define TINFO_CTRL 0x20
+ #define TINFO_ALL_SECT 0x1F
+ #define TINFO_ALL 0x3F
+
+
+ // address and context packets
+ int m_addrBytes;
+ uint8_t m_addrIS;
+ bool m_bAddr64bit;
+ int m_vmidBytes; // bytes still to find
+ int m_ctxtidBytes; // bytes still to find
+ bool m_bCtxtInfoDone;
+ bool m_addr_done;
+
+ // timestamp
+ bool m_ccount_done; // done or not needed
+ bool m_ts_done;
+ int m_ts_bytes;
+
+ // exception
+ int m_excep_size;
+
+ // cycle count
+ bool m_has_count;
+ bool m_count_done;
+ bool m_commit_done;
+
+ // cond result
+ bool m_F1P1_done; // F1 payload 1 done
+ bool m_F1P2_done; // F1 payload 2 done
+ bool m_F1has_P2; // F1 has a payload 2
+
+ // Q packets (use some from above too)
+ bool m_has_addr;
+ bool m_addr_short;
+ bool m_addr_match;
+ uint8_t m_Q_type;
+ uint8_t m_QE;
+
+ ocsd_datapath_resp_t outputPacket();
+ ocsd_datapath_resp_t outputUnsyncedRawPacket();
+
+ void iNotSync(const uint8_t lastByte); // not synced yet
+ void iPktNoPayload(const uint8_t lastByte); // process a single byte packet
+ void iPktReserved(const uint8_t lastByte); // deal with reserved header value
+ void iPktExtension(const uint8_t lastByte);
+ void iPktASync(const uint8_t lastByte);
+ void iPktTraceInfo(const uint8_t lastByte);
+ void iPktTimestamp(const uint8_t lastByte);
+ void iPktException(const uint8_t lastByte);
+ void iPktCycleCntF123(const uint8_t lastByte);
+ void iPktSpeclRes(const uint8_t lastByte);
+ void iPktCondInstr(const uint8_t lastByte);
+ void iPktCondResult(const uint8_t lastByte);
+ void iPktContext(const uint8_t lastByte);
+ void iPktAddrCtxt(const uint8_t lastByte);
+ void iPktShortAddr(const uint8_t lastByte);
+ void iPktLongAddr(const uint8_t lastByte);
+ void iPktQ(const uint8_t lastByte);
+ void iAtom(const uint8_t lastByte);
+ void iPktInvalidCfg(const uint8_t lastByte); // packet invalid in current config.
+
+ unsigned extractContField(const std::vector<uint8_t> &buffer, const unsigned st_idx, uint32_t &value, const unsigned byte_limit = 5);
+ unsigned extractContField64(const std::vector<uint8_t> &buffer, const unsigned st_idx, uint64_t &value, const unsigned byte_limit = 9);
+ unsigned extractCondResult(const std::vector<uint8_t> &buffer, const unsigned st_idx, uint32_t& key, uint8_t &result);
+ void extractAndSetContextInfo(const std::vector<uint8_t> &buffer, const int st_idx);
+ int extract64BitLongAddr(const std::vector<uint8_t> &buffer, const int st_idx, const uint8_t IS, uint64_t &value);
+ int extract32BitLongAddr(const std::vector<uint8_t> &buffer, const int st_idx, const uint8_t IS, uint32_t &value);
+ int extractShortAddr(const std::vector<uint8_t> &buffer, const int st_idx, const uint8_t IS, uint32_t &value, int &bits);
+
+ // packet processing is table driven.
+ typedef void (TrcPktProcEtmV4I::*PPKTFN)(uint8_t);
+ PPKTFN m_pIPktFn;
+
+ struct _pkt_i_table_t {
+ ocsd_etmv4_i_pkt_type pkt_type;
+ PPKTFN pptkFn;
+ } m_i_table[256];
+
+ void BuildIPacketTable();
+
+ void throwBadSequenceError(const char *pszExtMsg);
+};
+
+
+inline const bool TrcPktProcEtmV4I::isBadPacket() const
+{
+ return m_curr_packet.isBadPacket();
+}
+
+/** @}*/
+
+#endif // ARM_TRC_PKT_PROC_ETMV4I_IMPL_H_INCLUDED
+
+/* End of File trc_pkt_proc_etmv4i_impl.h */
diff --git a/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_types_etmv4.h b/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_types_etmv4.h
index dd69a4bf6778..7e98050c77c4 100644
--- a/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_types_etmv4.h
+++ b/contrib/opencsd/decoder/include/opencsd/etmv4/trc_pkt_types_etmv4.h
@@ -85,7 +85,8 @@ typedef enum _ocsd_etmv4_i_pkt_type
// speculation
ETM4_PKT_I_COMMIT = 0x2D, /*!< b00101101 */
- ETM4_PKT_I_CANCEL_F1 = 0x2E, /*!< b0010111x */
+ ETM4_PKT_I_CANCEL_F1 = 0x2E, /*!< b00101110 */
+ ETM4_PKT_I_CANCEL_F1_MISPRED = 0x2F, /*!< b00101111 */
ETM4_PKT_I_MISPREDICT = 0x30, /*!< b001100xx */
ETM4_PKT_I_CANCEL_F2 = 0x34, /*!< b001101xx */
ETM4_PKT_I_CANCEL_F3 = 0x38, /*!< b00111xxx */
diff --git a/contrib/opencsd/decoder/include/opencsd/ocsd_if_types.h b/contrib/opencsd/decoder/include/opencsd/ocsd_if_types.h
index 7d74d77c240b..23087ee694b1 100644
--- a/contrib/opencsd/decoder/include/opencsd/ocsd_if_types.h
+++ b/contrib/opencsd/decoder/include/opencsd/ocsd_if_types.h
@@ -273,11 +273,11 @@ typedef enum _ocsd_dcd_tree_src_t {
/** Core Architecture Version */
typedef enum _ocsd_arch_version {
- ARCH_UNKNOWN, /**< unknown architecture */
- ARCH_CUSTOM, /**< None ARM, custom architecture */
- ARCH_V7, /**< V7 architecture */
- ARCH_V8, /**< V8 architecture */
- ARCH_V8r3, /**< V8.3 architecture */
+ ARCH_UNKNOWN = 0x0000, /**< unknown architecture */
+ ARCH_CUSTOM = 0x0001, /**< None ARM, custom architecture */
+ ARCH_V7 = 0x0700, /**< V7 architecture */
+ ARCH_V8 = 0x0800, /**< V8 architecture */
+ ARCH_V8r3 = 0x0803, /**< V8.3 architecture */
} ocsd_arch_version_t;
// macros for arch version comparisons.
@@ -430,9 +430,10 @@ typedef enum _ocsd_mem_space_acc_t {
OCSD_MEM_SPACE_EL1N = 0x2, /**< NS EL1/0 */
OCSD_MEM_SPACE_EL2 = 0x4, /**< NS EL2 */
OCSD_MEM_SPACE_EL3 = 0x8, /**< S EL3 */
- OCSD_MEM_SPACE_S = 0x9, /**< Any S */
+ OCSD_MEM_SPACE_EL2S = 0x10, /**< S EL2 */
+ OCSD_MEM_SPACE_S = 0x19, /**< Any S */
OCSD_MEM_SPACE_N = 0x6, /**< Any NS */
- OCSD_MEM_SPACE_ANY = 0xF, /**< Any sec level / EL - live system use current EL + sec state */
+ OCSD_MEM_SPACE_ANY = 0x1F, /**< Any sec level / EL - live system use current EL + sec state */
} ocsd_mem_space_acc_t;
/**
@@ -494,13 +495,14 @@ typedef struct _ocsd_file_mem_region {
/** @name Packet Processor Operation Control Flags
common operational flags - bottom 16 bits,
- component specific - top 16 bits.
+ protocol component specific - top 16 bits.
+ (common flags share bitfield with pkt decoder common flags and create flags)
@{*/
-#define OCSD_OPFLG_PKTPROC_NOFWD_BAD_PKTS 0x00000001 /**< don't forward bad packets up data path */
-#define OCSD_OPFLG_PKTPROC_NOMON_BAD_PKTS 0x00000002 /**< don't forward bad packets to monitor interface */
-#define OCSD_OPFLG_PKTPROC_ERR_BAD_PKTS 0x00000004 /**< throw error for bad packets - halt decoding. */
-#define OCSD_OPFLG_PKTPROC_UNSYNC_ON_BAD_PKTS 0x00000008 /**< switch to unsynced state on bad packets - wait for next sync point */
+#define OCSD_OPFLG_PKTPROC_NOFWD_BAD_PKTS 0x00000010 /**< don't forward bad packets up data path */
+#define OCSD_OPFLG_PKTPROC_NOMON_BAD_PKTS 0x00000020 /**< don't forward bad packets to monitor interface */
+#define OCSD_OPFLG_PKTPROC_ERR_BAD_PKTS 0x00000040 /**< throw error for bad packets - halt decoding. */
+#define OCSD_OPFLG_PKTPROC_UNSYNC_ON_BAD_PKTS 0x00000080 /**< switch to unsynced state on bad packets - wait for next sync point */
/** mask to combine all common packet processor operational control flags */
#define OCSD_OPFLG_PKTPROC_COMMON (OCSD_OPFLG_PKTPROC_NOFWD_BAD_PKTS | \
@@ -508,14 +510,18 @@ typedef struct _ocsd_file_mem_region {
OCSD_OPFLG_PKTPROC_ERR_BAD_PKTS | \
OCSD_OPFLG_PKTPROC_UNSYNC_ON_BAD_PKTS )
+/** mask for the component spcific flags */
+#define OCSD_OPFLG_COMP_MODE_MASK 0xFFFF0000
+
/** @}*/
/** @name Packet Decoder Operation Control Flags
common operational flags - bottom 16 bits,
- component specific - top 16 bits.
-@{*/
+ protcol component specific - top 16 bits.
+ (common flags share bitfield with pkt processor common flags and create flags)
+ @{*/
-#define OCSD_OPFLG_PKTDEC_ERROR_BAD_PKTS 0x00000001 /**< throw error on bad packets input (default is to unsync and wait) */
+#define OCSD_OPFLG_PKTDEC_ERROR_BAD_PKTS 0x00000100 /**< throw error on bad packets input (default is to unsync and wait) */
/** mask to combine all common packet processor operational control flags */
#define OCSD_OPFLG_PKTDEC_COMMON (OCSD_OPFLG_PKTDEC_ERROR_BAD_PKTS)
@@ -524,7 +530,8 @@ typedef struct _ocsd_file_mem_region {
/** @name Decoder creation information
- Flags to use when creating decoders by name
+ Flags to use when creating decoders by name.
+ - share bitfield with pkt processor flags and packet decoder common flags.
Builtin decoder names.
diff --git a/contrib/opencsd/decoder/include/opencsd/ocsd_if_version.h b/contrib/opencsd/decoder/include/opencsd/ocsd_if_version.h
index 70c8df41f52b..38baa02e8b48 100644
--- a/contrib/opencsd/decoder/include/opencsd/ocsd_if_version.h
+++ b/contrib/opencsd/decoder/include/opencsd/ocsd_if_version.h
@@ -43,8 +43,8 @@
/** @name Library Versioning
@{*/
#define OCSD_VER_MAJOR 0x0 /**< Library Major Version */
-#define OCSD_VER_MINOR 0xC /**< Library Minor Version */
-#define OCSD_VER_PATCH 0x0 /**< Library Patch Version */
+#define OCSD_VER_MINOR 0xE /**< Library Minor Version */
+#define OCSD_VER_PATCH 0x2 /**< Library Patch Version */
/** Library version number - MMMMnnpp format.
MMMM = major version,
@@ -53,7 +53,7 @@
*/
#define OCSD_VER_NUM ((OCSD_VER_MAJOR << 16) | (OCSD_VER_MINOR << 8) | OCSD_VER_PATCH)
-#define OCSD_VER_STRING "0.12.0" /**< Library Version string */
+#define OCSD_VER_STRING "0.14.2" /**< Library Version string */
#define OCSD_LIB_NAME "OpenCSD Library" /**< Library name string */
#define OCSD_LIB_SHORT_NAME "OCSD" /**< Library Short name string */
/** @}*/
diff --git a/contrib/opencsd/decoder/include/opencsd/ptm/trc_pkt_decode_ptm.h b/contrib/opencsd/decoder/include/opencsd/ptm/trc_pkt_decode_ptm.h
index 395b316cda06..f9e1abe4ebc3 100644
--- a/contrib/opencsd/decoder/include/opencsd/ptm/trc_pkt_decode_ptm.h
+++ b/contrib/opencsd/decoder/include/opencsd/ptm/trc_pkt_decode_ptm.h
@@ -154,6 +154,7 @@ private:
} processor_state_t;
processor_state_t m_curr_state;
+ unsync_info_t m_unsync_info;
const bool processStateIsCont() const;
diff --git a/contrib/opencsd/decoder/include/opencsd/stm/trc_pkt_decode_stm.h b/contrib/opencsd/decoder/include/opencsd/stm/trc_pkt_decode_stm.h
index a4807207eb1e..bd29cafa799f 100644
--- a/contrib/opencsd/decoder/include/opencsd/stm/trc_pkt_decode_stm.h
+++ b/contrib/opencsd/decoder/include/opencsd/stm/trc_pkt_decode_stm.h
@@ -79,6 +79,7 @@ private:
} processor_state_t;
processor_state_t m_curr_state;
+ unsync_info_t m_unsync_info;
ocsd_swt_info_t m_swt_packet_info;
diff --git a/contrib/opencsd/decoder/include/opencsd/trc_gen_elem_types.h b/contrib/opencsd/decoder/include/opencsd/trc_gen_elem_types.h
index 1d77b53cf8f9..1a285a064b63 100644
--- a/contrib/opencsd/decoder/include/opencsd/trc_gen_elem_types.h
+++ b/contrib/opencsd/decoder/include/opencsd/trc_gen_elem_types.h
@@ -52,6 +52,7 @@ typedef enum _ocsd_gen_trc_elem_t
OCSD_GEN_TRC_ELEM_EO_TRACE, /*!< end of the available trace in the buffer. */
OCSD_GEN_TRC_ELEM_PE_CONTEXT, /*!< PE status update / change (arch, ctxtid, vmid etc). */
OCSD_GEN_TRC_ELEM_INSTR_RANGE, /*!< traced N consecutive instructions from addr (no intervening events or data elements), may have data assoc key */
+ OCSD_GEN_TRC_ELEM_I_RANGE_NOPATH, /*!< traced N instructions in a range, but incomplete information as to program execution path from start to end of range */
OCSD_GEN_TRC_ELEM_ADDR_NACC, /*!< tracing in inaccessible memory area */
OCSD_GEN_TRC_ELEM_ADDR_UNKNOWN, /*!< address currently unknown - need address packet update */
OCSD_GEN_TRC_ELEM_EXCEPTION, /*!< exception - start address may be exception target, end address may be preferred ret addr. */
@@ -75,6 +76,16 @@ typedef struct _trace_event_t {
uint16_t ev_number; /**< event number if numbered event type */
} trace_event_t;
+typedef enum _unsync_info_t {
+ UNSYNC_UNKNOWN, /**< unknown /undefined */
+ UNSYNC_INIT_DECODER, /**< decoder intialisation - start of trace. */
+ UNSYNC_RESET_DECODER, /**< decoder reset. */
+ UNSYNC_OVERFLOW, /**< overflow packet - need to re-sync / end of trace after overflow. */
+ UNSYNC_DISCARD, /**< specl trace discard - need to re-sync. */
+ UNSYNC_BAD_PACKET, /**< bad packet at input - resync to restart. */
+ UNSYNC_EOT, /**< end of trace - no additional info */
+} unsync_info_t;
+
typedef struct _ocsd_generic_trace_elem {
ocsd_gen_trc_elem_t elem_type; /**< Element type - remaining data interpreted according to this value */
ocsd_isa isa; /**< instruction set for executed instructions */
@@ -110,6 +121,7 @@ typedef struct _ocsd_generic_trace_elem {
trace_on_reason_t trace_on_reason; /**< reason for the trace on packet */
ocsd_swt_info_t sw_trace_info; /**< software trace packet info */
uint32_t num_instr_range; /**< number of instructions covered by range packet (for T32 this cannot be calculated from en-st/i_size) */
+ unsync_info_t unsync_eot_info; /**< additional information for unsync / end-of-trace packets. */
};
const void *ptr_extended_data; /**< pointer to extended data buffer (data trace, sw trace payload) / custom structure */
diff --git a/contrib/opencsd/decoder/include/pkt_printers/pkt_printer_t.h b/contrib/opencsd/decoder/include/pkt_printers/pkt_printer_t.h
index 9eb37f4e2833..c00daa1f64d3 100644
--- a/contrib/opencsd/decoder/include/pkt_printers/pkt_printer_t.h
+++ b/contrib/opencsd/decoder/include/pkt_printers/pkt_printer_t.h
@@ -102,7 +102,7 @@ template<class P> ocsd_datapath_resp_t PacketPrinter<P>::PacketDataIn( const ocs
if(!m_bRawPrint && (m_last_resp == OCSD_RESP_WAIT))
{
// expect a flush or a complete reset after a wait.
- if((op != OCSD_OP_FLUSH) || (op != OCSD_OP_RESET))
+ if((op != OCSD_OP_FLUSH) && (op != OCSD_OP_RESET))
{
m_oss <<"ID:"<< std::hex << (uint32_t)m_trcID << "\tERROR: FLUSH operation expected after wait on trace decode path\n";
itemPrintLine(m_oss.str());