aboutsummaryrefslogtreecommitdiffstats
path: root/decoder/include/common
diff options
context:
space:
mode:
Diffstat (limited to 'decoder/include/common')
-rw-r--r--decoder/include/common/ocsd_dcd_mngr.h6
-rw-r--r--decoder/include/common/ocsd_gen_elem_list.h8
-rw-r--r--decoder/include/common/ocsd_gen_elem_stack.h109
-rw-r--r--decoder/include/common/trc_core_arch_map.h34
-rw-r--r--decoder/include/common/trc_gen_elem.h19
-rw-r--r--decoder/include/common/trc_pkt_decode_base.h5
-rw-r--r--decoder/include/common/trc_raw_buffer.h96
7 files changed, 269 insertions, 8 deletions
diff --git a/decoder/include/common/ocsd_dcd_mngr.h b/decoder/include/common/ocsd_dcd_mngr.h
index ba7d8a89c46f..3342eacb24ca 100644
--- a/decoder/include/common/ocsd_dcd_mngr.h
+++ b/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/decoder/include/common/ocsd_gen_elem_list.h b/decoder/include/common/ocsd_gen_elem_list.h
index 0ff1bd59cbbe..2dab240140bf 100644
--- a/decoder/include/common/ocsd_gen_elem_list.h
+++ b/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/decoder/include/common/ocsd_gen_elem_stack.h b/decoder/include/common/ocsd_gen_elem_stack.h
new file mode 100644
index 000000000000..64c525df4270
--- /dev/null
+++ b/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/decoder/include/common/trc_core_arch_map.h b/decoder/include/common/trc_core_arch_map.h
index 5a24149180fc..b72b4b411fa4 100644
--- a/decoder/include/common/trc_core_arch_map.h
+++ b/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/decoder/include/common/trc_gen_elem.h b/decoder/include/common/trc_gen_elem.h
index 1c4a47b3aa0a..5d8983a8c274 100644
--- a/decoder/include/common/trc_gen_elem.h
+++ b/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/decoder/include/common/trc_pkt_decode_base.h b/decoder/include/common/trc_pkt_decode_base.h
index 2bbf5e51d878..da702068f372 100644
--- a/decoder/include/common/trc_pkt_decode_base.h
+++ b/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/decoder/include/common/trc_raw_buffer.h b/decoder/include/common/trc_raw_buffer.h
new file mode 100644
index 000000000000..67b8d2403457
--- /dev/null
+++ b/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
+