aboutsummaryrefslogtreecommitdiffstats
path: root/decoder/include/opencsd
diff options
context:
space:
mode:
authorRuslan Bukin <br@FreeBSD.org>2019-10-10 13:19:21 +0000
committerRuslan Bukin <br@FreeBSD.org>2019-10-10 13:19:21 +0000
commitcf98ba14dc260458f757fa46419575cf69f45a44 (patch)
tree1cafc844f372337d2a95c8a416b915d46bf4daf8 /decoder/include/opencsd
parenta6157d81121ac9559d806dafa346039199598442 (diff)
downloadsrc-cf98ba14dc260458f757fa46419575cf69f45a44.tar.gz
src-cf98ba14dc260458f757fa46419575cf69f45a44.zip
Import OpenCSD -- an ARM CoreSight Trace Decode library.vendor/opencsd/a1961c91b02a92f3c6ed8b145c636ac4c5565aca
Git ID a1961c91b02a92f3c6ed8b145c636ac4c5565aca Sponsored by: DARPA, AFRL
Notes
Notes: svn path=/vendor/opencsd/a1961c91b02a92f3c6ed8b145c636ac4c5565aca/; revision=353391 svn path=/vendor/opencsd/dist/; revision=353392; tag=vendor/opencsd/a1961c91b02a92f3c6ed8b145c636ac4c5565aca
Diffstat (limited to 'decoder/include/opencsd')
-rw-r--r--decoder/include/opencsd/c_api/ocsd_c_api_types.h1
-rw-r--r--decoder/include/opencsd/c_api/opencsd_c_api.h19
-rw-r--r--decoder/include/opencsd/etmv4/trc_cmp_cfg_etmv4.h20
-rw-r--r--decoder/include/opencsd/etmv4/trc_etmv4_stack_elem.h12
-rw-r--r--decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h13
-rw-r--r--decoder/include/opencsd/etmv4/trc_pkt_elem_etmv4i.h29
-rw-r--r--decoder/include/opencsd/etmv4/trc_pkt_types_etmv4.h137
-rw-r--r--decoder/include/opencsd/ocsd_if_types.h42
-rw-r--r--decoder/include/opencsd/ocsd_if_version.h65
-rw-r--r--decoder/include/opencsd/trc_gen_elem_types.h8
10 files changed, 260 insertions, 86 deletions
diff --git a/decoder/include/opencsd/c_api/ocsd_c_api_types.h b/decoder/include/opencsd/c_api/ocsd_c_api_types.h
index ca61e0aaed32..cde351fc525f 100644
--- a/decoder/include/opencsd/c_api/ocsd_c_api_types.h
+++ b/decoder/include/opencsd/c_api/ocsd_c_api_types.h
@@ -37,6 +37,7 @@
/* select the library types that are C compatible - the interface data types */
#include "opencsd/ocsd_if_types.h"
+#include "opencsd/ocsd_if_version.h"
#include "opencsd/trc_gen_elem_types.h"
#include "opencsd/trc_pkt_types.h"
diff --git a/decoder/include/opencsd/c_api/opencsd_c_api.h b/decoder/include/opencsd/c_api/opencsd_c_api.h
index f9f4ed4b8613..90201d436e08 100644
--- a/decoder/include/opencsd/c_api/opencsd_c_api.h
+++ b/decoder/include/opencsd/c_api/opencsd_c_api.h
@@ -84,7 +84,7 @@
/** @name Library Version API
@{*/
-/** Get Library version. Return a 32 bit version in form MMMMnnpp - MMMM = major verison, nn = minor version, pp = patch version */
+/** Get Library version. Return a 32 bit version in form MMMMnnpp - MMMM = major version, nn = minor version, pp = patch version */
OCSD_C_API uint32_t ocsd_get_version(void);
/** Get library version string */
@@ -286,6 +286,23 @@ OCSD_C_API ocsd_err_t ocsd_dt_add_buffer_mem_acc(const dcd_tree_handle_t handle,
*/
OCSD_C_API ocsd_err_t ocsd_dt_add_callback_mem_acc(const dcd_tree_handle_t handle, const ocsd_vaddr_t st_address, const ocsd_vaddr_t en_address, const ocsd_mem_space_acc_t mem_space, Fn_MemAcc_CB p_cb_func, const void *p_context);
+
+/*!
+ * Add a memory access callback function. The decoder will call the function for opcode addresses in the
+ * address range supplied for the memory spaces covered.
+ *
+ * @param handle : Handle to decode tree.
+ * @param st_address : Start address of memory area covered by the callback.
+ * @param en_address : End address of the memory area covered by the callback. (inclusive)
+ * @param mem_space : Memory space(s) covered by the callback.
+ * @param p_cb_func : Callback function - Signature for CB with Trace ID passed to client.
+ * @param p_context : opaque context pointer value used in callback function.
+ *
+ * @return OCSD_C_API ocsd_err_t : Library error code - RCDTL_OK if successful.
+ */
+OCSD_C_API ocsd_err_t ocsd_dt_add_callback_trcid_mem_acc(const dcd_tree_handle_t handle, const ocsd_vaddr_t st_address, const ocsd_vaddr_t en_address, const ocsd_mem_space_acc_t mem_space, Fn_MemAccID_CB p_cb_func, const void *p_context);
+
+
/*!
* Remove a memory accessor by address and memory space.
*
diff --git a/decoder/include/opencsd/etmv4/trc_cmp_cfg_etmv4.h b/decoder/include/opencsd/etmv4/trc_cmp_cfg_etmv4.h
index a3f883540a30..1d72d97afe59 100644
--- a/decoder/include/opencsd/etmv4/trc_cmp_cfg_etmv4.h
+++ b/decoder/include/opencsd/etmv4/trc_cmp_cfg_etmv4.h
@@ -108,6 +108,7 @@ public:
/* idr 1 */
const uint8_t MajVersion() const;
const uint8_t MinVersion() const;
+ const uint8_t FullVersion() const;
/* idr 2 */
const uint32_t iaSizeMax() const;
@@ -117,6 +118,7 @@ public:
const uint32_t dvSize() const;
const uint32_t ccSize() const;
const bool vmidOpt() const;
+ const bool wfiwfeBranch() const;
/* id regs 8-13*/
const uint32_t MaxSpecDepth() const;
@@ -180,7 +182,11 @@ private:
bool m_condTraceCalc;
CondITrace_t m_CondTrace;
+protected:
ocsd_etmv4_cfg m_cfg;
+ uint8_t m_MajVer;
+ uint8_t m_MinVer;
+
};
/* idr 0 */
@@ -265,14 +271,18 @@ inline const bool EtmV4Config::commitOpt1() const
/* idr 1 */
inline const uint8_t EtmV4Config::MajVersion() const
{
- return (uint8_t)((m_cfg.reg_idr1 >> 8) & 0xF);
+ return m_MajVer;
}
inline const uint8_t EtmV4Config::MinVersion() const
{
- return (uint8_t)((m_cfg.reg_idr1 >> 4) & 0xF);
+ return m_MinVer;
}
+inline const uint8_t EtmV4Config::FullVersion() const
+{
+ return (m_MajVer << 4) | m_MinVer;
+}
/* idr 2 */
inline const uint32_t EtmV4Config::iaSizeMax() const
@@ -320,6 +330,12 @@ inline const bool EtmV4Config::vmidOpt() const
return (bool)((m_cfg.reg_idr2 & 0x20000000) == 0x20000000) && (MinVersion() > 0);
}
+inline const bool EtmV4Config::wfiwfeBranch() const
+{
+ return (bool)((m_cfg.reg_idr2 & 0x80000000) && (FullVersion() >= 0x43));
+}
+
+
/* id regs 8-13*/
inline const uint32_t EtmV4Config::MaxSpecDepth() const
diff --git a/decoder/include/opencsd/etmv4/trc_etmv4_stack_elem.h b/decoder/include/opencsd/etmv4/trc_etmv4_stack_elem.h
index 8bf0fb0c0478..15996547163c 100644
--- a/decoder/include/opencsd/etmv4/trc_etmv4_stack_elem.h
+++ b/decoder/include/opencsd/etmv4/trc_etmv4_stack_elem.h
@@ -56,7 +56,8 @@ typedef enum _p0_elem_t
P0_TS,
P0_CC,
P0_TS_CC,
- P0_OVERFLOW
+ P0_OVERFLOW,
+ P0_FUNC_RET,
} p0_elem_t;
@@ -250,6 +251,7 @@ public:
~EtmV4P0Stack();
void push_front(TrcStackElem *pElem);
+ void push_back(TrcStackElem *pElem); // insert element when processing
void pop_back();
TrcStackElem *back();
size_t size();
@@ -260,7 +262,7 @@ public:
// creation functions - create and push if successful.
TrcStackElemParam *createParamElem(const p0_elem_t p0_type, const bool isP0, const ocsd_etmv4_i_pkt_type root_pkt, const ocsd_trc_index_t root_index, const std::vector<uint32_t> &params);
- TrcStackElemParam *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);
+ 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);
@@ -284,6 +286,12 @@ inline void EtmV4P0Stack::push_front(TrcStackElem *pElem)
m_P0_stack.push_front(pElem);
}
+// put an element on the back of the stack
+inline void EtmV4P0Stack::push_back(TrcStackElem *pElem)
+{
+ m_P0_stack.push_back(pElem);
+}
+
// pop last element pointer off the stack and stash it for later deletion
inline void EtmV4P0Stack::pop_back()
{
diff --git a/decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h b/decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h
index f27bb45d9fa8..1c06e5ddf03a 100644
--- a/decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h
+++ b/decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h
@@ -93,6 +93,8 @@ private:
ocsd_datapath_resp_t returnStackPop(); // pop return stack and update instruction address.
+ ocsd_datapath_resp_t outputTraceRange(const bool executed, ocsd_trc_index_t index);
+
//** intra packet state (see ETMv4 spec 6.2.1);
// timestamping
@@ -152,12 +154,17 @@ private:
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;
- excep_proc_state_t m_excep_proc; //!< state of exception processing
- etmv4_addr_val_t m_excep_addr; //!< excepiton return address.
- ocsd_trc_index_t m_excep_index; //!< trace index for exception element
+ 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
ocsd_instr_info m_instr_info; //!< instruction info for code follower - in address is the next to be decoded.
diff --git a/decoder/include/opencsd/etmv4/trc_pkt_elem_etmv4i.h b/decoder/include/opencsd/etmv4/trc_pkt_elem_etmv4i.h
index e0343c76260c..02adfc51aa75 100644
--- a/decoder/include/opencsd/etmv4/trc_pkt_elem_etmv4i.h
+++ b/decoder/include/opencsd/etmv4/trc_pkt_elem_etmv4i.h
@@ -115,7 +115,7 @@ public:
void initNextPacket(); //!< clear any single packet only flags / state.
void setType(const ocsd_etmv4_i_pkt_type pkt_type) { type = pkt_type; };
- void updateErrType(const ocsd_etmv4_i_pkt_type err_pkt_type);
+ void updateErrType(const ocsd_etmv4_i_pkt_type err_pkt_type, const uint8_t val = 0);
void clearTraceInfo(); //!< clear all the trace info data prior to setting for new trace info packet.
void setTraceInfo(const uint32_t infoVal);
@@ -208,11 +208,12 @@ private:
Etmv4PktAddrStack m_addr_stack;
};
-inline void EtmV4ITrcPacket::updateErrType(const ocsd_etmv4_i_pkt_type err_pkt_type)
+inline void EtmV4ITrcPacket::updateErrType(const ocsd_etmv4_i_pkt_type err_pkt_type, const uint8_t err_val /* = 0 */)
{
// set primary type to incoming error type, set packet err type to previous primary type.
err_type = type;
type = err_pkt_type;
+ err_hdr_val = err_val;
}
inline void EtmV4ITrcPacket::clearTraceInfo()
@@ -223,7 +224,9 @@ inline void EtmV4ITrcPacket::clearTraceInfo()
pkt_valid.bits.spec_depth_valid = 0;
pkt_valid.bits.cc_thresh_valid = 0;
- pkt_valid.bits.ts_valid = 0; // mark TS as invalid - must be re-updated after trace info.
+ // set these as defaults - if they don't appear in TINFO this is the state.
+ setTraceInfo(0);
+ setTraceInfoSpec(0);
}
inline void EtmV4ITrcPacket::setTraceInfo(const uint32_t infoVal)
@@ -444,18 +447,20 @@ inline void EtmV4ITrcPacket::set32BitAddress(const uint32_t addr, const uint8_t
uint64_t mask = OCSD_BIT_MASK(32);
v_addr.pkt_bits = 32;
- if (pkt_valid.bits.context_valid && context.SF)
- v_addr.size = VA_64BIT;
+ 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 &= 0xFFFFFFFF; // ensure vaddr is only 32 bits if not 64 bit
+ v_addr.val = addr;
v_addr.size = VA_32BIT;
- }
-
- if (v_addr.valid_bits < 32) // may be 64 bit address so only set 32 if less
- v_addr.valid_bits = 32;
-
- v_addr.val = (v_addr.val & ~mask) | (addr & mask);
+ v_addr.valid_bits = 32;
+ }
+
v_addr_ISA = IS;
push_vaddr();
}
diff --git a/decoder/include/opencsd/etmv4/trc_pkt_types_etmv4.h b/decoder/include/opencsd/etmv4/trc_pkt_types_etmv4.h
index b22a2b939719..dd69a4bf6778 100644
--- a/decoder/include/opencsd/etmv4/trc_pkt_types_etmv4.h
+++ b/decoder/include/opencsd/etmv4/trc_pkt_types_etmv4.h
@@ -1,8 +1,8 @@
/*
* \file trc_pkt_types_etmv4.h
- * \brief OpenCSD :
+ * \brief OpenCSD : ETMv4 packet info
*
- * \copyright Copyright (c) 2015, ARM Limited. All Rights Reserved.
+ * \copyright Copyright (c) 2015,2019 ARM Limited. All Rights Reserved.
*/
@@ -56,80 +56,95 @@ typedef enum _ocsd_etmv4_i_pkt_type
ETM4_PKT_I_BAD_SEQUENCE = 0x300, /*!< invalid sequence for packet type. */
ETM4_PKT_I_BAD_TRACEMODE, /*!< invalid packet type for this trace mode. */
ETM4_PKT_I_RESERVED, /*!< packet type reserved. */
+ ETM4_PKT_I_RESERVED_CFG, /*!< packet type reserved for current configuration */
/* I stream packet types. */
/* extension header. */
- ETM4_PKT_I_EXTENSION = 0x00, /*!< b00000000 */
+ ETM4_PKT_I_EXTENSION = 0x00, /*!< b00000000 */
+
+ /* sync */
+ ETM4_PKT_I_TRACE_INFO = 0x01, /*!< b00000001 */
+ // timestamp
+ ETM4_PKT_I_TIMESTAMP = 0x02, /*!< b0000001x */
+ ETM4_PKT_I_TRACE_ON = 0x04, /*!< b00000100 */
+ ETM4_PKT_I_FUNC_RET = 0x05, /*!< b00000101 (V8M only) */
+ // Exceptions
+ ETM4_PKT_I_EXCEPT = 0x06, /*!< b00000110 */
+ ETM4_PKT_I_EXCEPT_RTN = 0x07, /*!< b00000111 */
+
+ /* unused encodings 0x08-0xB b00001000 to b00001011 */
+
+ /* cycle count packets */
+ ETM4_PKT_I_CCNT_F2 = 0x0C, /*!< b0000110x */
+ ETM4_PKT_I_CCNT_F1 = 0x0E, /*!< b0000111x */
+ ETM4_PKT_I_CCNT_F3 = 0x10, /*!< b0001xxxx */
+
+ // data synchronisation markers
+ ETM4_PKT_I_NUM_DS_MKR = 0x20, /*!< b00100xxx */
+ ETM4_PKT_I_UNNUM_DS_MKR = 0x28, /*!< b00101000 to b00101100 0x2C */
+
+ // speculation
+ ETM4_PKT_I_COMMIT = 0x2D, /*!< b00101101 */
+ ETM4_PKT_I_CANCEL_F1 = 0x2E, /*!< b0010111x */
+ ETM4_PKT_I_MISPREDICT = 0x30, /*!< b001100xx */
+ ETM4_PKT_I_CANCEL_F2 = 0x34, /*!< b001101xx */
+ ETM4_PKT_I_CANCEL_F3 = 0x38, /*!< b00111xxx */
- /* address amd context */
- ETM4_PKT_I_ADDR_CTXT_L_32IS0 = 0x82, /*!< b10000010 */
+ /* conditional instruction tracing */
+ ETM4_PKT_I_COND_I_F2 = 0x40, /*!< b01000000 - b01000010 */
+ ETM4_PKT_I_COND_FLUSH = 0x43, /*!< b01000011 */
+ ETM4_PKT_I_COND_RES_F4 = 0x44, /*!< b0100010x, b01000110 */
+ /* unused encoding 0x47 b01000111 */
+ ETM4_PKT_I_COND_RES_F2 = 0x48, /*!< b0100100x, b01001010, b0100110x, b01001110 */
+ /* unused encodings 0x4B,0x4F b01001011, b01001111 */
+ ETM4_PKT_I_COND_RES_F3 = 0x50, /*!< b0101xxxx */
+ /* unused encodings 0x60-0x67 b01100xxx */
+ ETM4_PKT_I_COND_RES_F1 = 0x68, /*!< b011010xx, b0110111x 0x68-0x6B, 0x6e-0x6F */
+ ETM4_PKT_I_COND_I_F1 = 0x6C, /*!< b01101100 */
+ ETM4_PKT_I_COND_I_F3 = 0x6D, /*!< b01101101 */
+
+ // event trace
+ ETM4_PKT_I_IGNORE = 0x70, /*!< b01110000 */
+ ETM4_PKT_I_EVENT = 0x71, /*!< b01110001 to 0x01111111 0x7F */
+
+ /* address and context */
+ ETM4_PKT_I_CTXT = 0x80, /*!< b1000000x */
+ ETM4_PKT_I_ADDR_CTXT_L_32IS0 = 0x82, /*!< b10000010 */
ETM4_PKT_I_ADDR_CTXT_L_32IS1, /*!< b10000011 */
- /* unused encoding b10000100 */
- ETM4_PKT_I_ADDR_CTXT_L_64IS0 = 0x85, /*!< b10000101 */
+ /* unused encoding 0x84 b10000100 */
+ ETM4_PKT_I_ADDR_CTXT_L_64IS0 = 0x85, /*!< b10000101 */
ETM4_PKT_I_ADDR_CTXT_L_64IS1, /*!< b10000110 */
- /* unused encoding b10000111 */
- ETM4_PKT_I_CTXT = 0x80, /*!< b1000000x */
- ETM4_PKT_I_ADDR_MATCH = 0x90, /*!< b10010000 to b10010010 */
- ETM4_PKT_I_ADDR_L_32IS0 = 0x9A, /*!< b10011010 */
+ /* unused encoding 0x87 b10000111 */
+ /* unused encodings 0x88-0x8F b10001xxx */
+ ETM4_PKT_I_ADDR_MATCH = 0x90, /*!< b10010000 to b10010010 0x92 */
+ /* unused encodings 0x93-0x94 b10010011 to b10010010 */
+ ETM4_PKT_I_ADDR_S_IS0 = 0x95, /*!< b10010101 */
+ ETM4_PKT_I_ADDR_S_IS1, /*!< b10010110 */
+ /* unused encodings 0x97 b10010111 to b10011001 0x99 */
+ ETM4_PKT_I_ADDR_L_32IS0 = 0x9A, /*!< b10011010 */
ETM4_PKT_I_ADDR_L_32IS1, /*!< b10011011 */
- /* unused encoding b10011100 */
- ETM4_PKT_I_ADDR_L_64IS0 = 0x9D, /*!< b10011101 */
+ /* unused encoding 0x9C b10011100 */
+ ETM4_PKT_I_ADDR_L_64IS0 = 0x9D, /*!< b10011101 */
ETM4_PKT_I_ADDR_L_64IS1, /*!< b10011110 */
- /* unused encoding b10011111 */
- ETM4_PKT_I_ADDR_S_IS0 = 0x95, /*!< b10010101 */
- ETM4_PKT_I_ADDR_S_IS1, /*!< b10010110 */
- /* unused encoding b10010111
- unused encoding b10011000
- unused encoding b10011001 */
+ /* unused encoding 0x9F b10011111 */
/* Q packets */
ETM4_PKT_I_Q = 0xA0, /*!< b1010xxxx */
- /* Atom packets */
- ETM4_PKT_I_ATOM_F1 = 0xF6, /*!< b1111011x */
- ETM4_PKT_I_ATOM_F2 = 0xD8, /*!< b110110xx */
- ETM4_PKT_I_ATOM_F3 = 0xF8, //!< b11111xxx
- ETM4_PKT_I_ATOM_F4 = 0xDC, //!< b110111xx
- ETM4_PKT_I_ATOM_F5 = 0xD5, //!< b11010101 - b11010111, b11110101
- ETM4_PKT_I_ATOM_F6 = 0xC0, //!< b11000000 - b11010100, b11100000 - b11110100
+ /* unused encodings 0xB0-0xBF b1011xxxx */
- /* conditional instruction tracing */
- ETM4_PKT_I_COND_FLUSH = 0x43, //!< b01000011
- ETM4_PKT_I_COND_I_F1 = 0x6C, //!< b01101100
- ETM4_PKT_I_COND_I_F2 = 0x40, //!< b01000000 - b01000010
- ETM4_PKT_I_COND_I_F3 = 0x6D, //!< b01101101
- ETM4_PKT_I_COND_RES_F1 = 0x68, //!< b0110111x, b011010xx
- ETM4_PKT_I_COND_RES_F2 = 0x48, //!< b0100100x, b01001010, b0100110x, b01001110
- ETM4_PKT_I_COND_RES_F3 = 0x50, //!< b0101xxxx
- ETM4_PKT_I_COND_RES_F4 = 0x44, //!< b0100010x, b01000110
+ /* Atom packets */
+ ETM4_PKT_I_ATOM_F6 = 0xC0, /*!< b11000000 - b11010100 0xC0 - 0xD4, b11100000 - b11110100 0xE0 - 0xF4 */
+ ETM4_PKT_I_ATOM_F5 = 0xD5, /*!< b11010101 - b11010111 0xD5 - 0xD7, b11110101 0xF5 */
+ ETM4_PKT_I_ATOM_F2 = 0xD8, /*!< b110110xx to 0xDB */
+ ETM4_PKT_I_ATOM_F4 = 0xDC, /*!< b110111xx to 0xDF */
+ ETM4_PKT_I_ATOM_F1 = 0xF6, /*!< b1111011x to 0xF7 */
+ ETM4_PKT_I_ATOM_F3 = 0xF8, /*!< b11111xxx to 0xFF */
- /* cycle count packets */
- ETM4_PKT_I_CCNT_F1 = 0x0E, //!< b0000111x
- ETM4_PKT_I_CCNT_F2 = 0x0C, //!< b0000110x
- ETM4_PKT_I_CCNT_F3 = 0x10, //!< b0001xxxx
- // data synchronisation markers
- ETM4_PKT_I_NUM_DS_MKR = 0x20, //!< b00100xxx
- ETM4_PKT_I_UNNUM_DS_MKR = 0x28, //!< b00101000 - b00101100
- // event trace
- ETM4_PKT_I_EVENT = 0x70, //!< b0111xxxx
- // Exceptions
- ETM4_PKT_I_EXCEPT = 0x06, //!< b00000110
- ETM4_PKT_I_EXCEPT_RTN = 0x07, //!< b00000111
- // timestamp
- ETM4_PKT_I_TIMESTAMP = 0x02, //!< b0000001x
- // speculation
- ETM4_PKT_I_CANCEL_F1 = 0x2E, //!< b0010111x
- ETM4_PKT_I_CANCEL_F2 = 0x34, //!< b001101xx
- ETM4_PKT_I_CANCEL_F3 = 0x38, //!< b00111xxx
- ETM4_PKT_I_COMMIT = 0x2D, //!< b00101101
- ETM4_PKT_I_MISPREDICT = 0x30, //!< b001100xx
- // Sync
- ETM4_PKT_I_TRACE_INFO = 0x01, //!< b00000001
- ETM4_PKT_I_TRACE_ON = 0x04, //!< b00000100
// extension packets - follow 0x00 header
ETM4_PKT_I_ASYNC = 0x100, //!< b00000000
ETM4_PKT_I_DISCARD = 0x103, //!< b00000011
- ETM4_PKT_I_OVERFLOW = 0x105 //!< b00000101
+ ETM4_PKT_I_OVERFLOW = 0x105, //!< b00000101
} ocsd_etmv4_i_pkt_type;
@@ -139,7 +154,7 @@ typedef union _etmv4_trace_info_t {
uint32_t cc_enabled:1; //!< 1 if cycle count enabled
uint32_t cond_enabled:3; //!< conditional trace enabeld type
uint32_t p0_load:1; //!< 1 if tracing with P0 load elements (for data trace)
- uint32_t p0_store:1; //1< 1 if tracing with P0 store elements (for data trace)
+ uint32_t p0_store:1; //!< 1 if tracing with P0 store elements (for data trace)
} bits; //!< bitfields for trace info value.
} etmv4_trace_info_t;
@@ -259,6 +274,7 @@ typedef struct _ocsd_etmv4_i_pkt
// original header type when packet type changed to error on decode error.
ocsd_etmv4_i_pkt_type err_type;
+ uint8_t err_hdr_val;
} ocsd_etmv4_i_pkt;
@@ -342,6 +358,7 @@ typedef struct _ocsd_etmv4_cfg
ocsd_core_profile_t core_prof; /**< Core Profile */
} ocsd_etmv4_cfg;
+
/** @}*/
/** @}*/
#endif // ARM_TRC_PKT_TYPES_ETMV4_H_INCLUDED
diff --git a/decoder/include/opencsd/ocsd_if_types.h b/decoder/include/opencsd/ocsd_if_types.h
index def16575f2b2..7d74d77c240b 100644
--- a/decoder/include/opencsd/ocsd_if_types.h
+++ b/decoder/include/opencsd/ocsd_if_types.h
@@ -107,6 +107,7 @@ typedef enum _ocsd_err_t {
OCSD_ERR_DATA_DECODE_FATAL, /**< A decoder in the data path has returned a fatal error. */
/* frame deformatter errors */
OCSD_ERR_DFMTR_NOTCONTTRACE, /**< Trace input to deformatter none-continuous */
+ OCSD_ERR_DFMTR_BAD_FHSYNC, /**< Bad frame or half frame sync in trace deformatter */
/* packet processor errors - protocol issues etc */
OCSD_ERR_BAD_PACKET_SEQ, /**< Bad packet sequence */
OCSD_ERR_INVALID_PCKT_HDR, /**< Invalid packet header */
@@ -126,6 +127,7 @@ typedef enum _ocsd_err_t {
OCSD_ERR_MEM_ACC_FILE_NOT_FOUND, /**< Memory access file could not be opened */
OCSD_ERR_MEM_ACC_FILE_DIFF_RANGE, /**< Attempt to re-use the same memory access file for a different address range */
OCSD_ERR_MEM_ACC_RANGE_INVALID, /**< Address range in accessor set to invalid values */
+ OCSD_ERR_MEM_ACC_BAD_LEN, /**< Memory accessor returned a bad read length value (larger than requested */
/* test errors - errors generated only by the test code, not the library */
OCSD_ERR_TEST_SNAPSHOT_PARSE, /**< test snapshot file parse error */
OCSD_ERR_TEST_SNAPSHOT_PARSE_INFO, /**< test snapshot file parse information */
@@ -137,7 +139,7 @@ typedef enum _ocsd_err_t {
OCSD_ERR_DCDREG_TYPE_UNKNOWN, /**< attempted to find a decoder with a type that is not known in the library */
OCSD_ERR_DCDREG_TOOMANY, /**< attempted to register too many custom decoders */
/* decoder config */
- OCSD_ERR_DCD_INTERFACE_UNUSED, /**< Attempt to connect or use and inteface not supported by this decoder. */
+ OCSD_ERR_DCD_INTERFACE_UNUSED, /**< Attempt to connect or use and interface not supported by this decoder. */
/* end marker*/
OCSD_ERR_LAST
} ocsd_err_t;
@@ -272,11 +274,16 @@ 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_CUSTOM, /**< None ARM, custom architecture */
+ ARCH_V8r3, /**< V8.3 architecture */
} ocsd_arch_version_t;
+// macros for arch version comparisons.
+#define OCSD_IS_V8_ARCH(arch) ((arch >= ARCH_V8) && (arch <= ARCH_V8r3))
+#define OCSD_MIN_V8_ARCH(arch) (arch >= ARCH_V8)
+
/** Core Profile */
typedef enum _ocsd_core_profile {
profile_Unknown, /**< Unknown profile */
@@ -351,7 +358,8 @@ typedef enum _ocsd_instr_type {
OCSD_INSTR_BR, /**< Immediate Branch instruction */
OCSD_INSTR_BR_INDIRECT, /**< Indirect Branch instruction */
OCSD_INSTR_ISB, /**< Barrier : ISB instruction */
- OCSD_INSTR_DSB_DMB /**< Barrier : DSB or DMB instruction */
+ OCSD_INSTR_DSB_DMB, /**< Barrier : DSB or DMB instruction */
+ OCSD_INSTR_WFI_WFE, /**< WFI or WFE traced as direct branch */
} ocsd_instr_type;
/** instruction sub types - addiitonal information passed to the output packets
@@ -362,6 +370,7 @@ typedef enum _ocsd_instr_subtype {
OCSD_S_INSTR_BR_LINK, /**< branch with link */
OCSD_S_INSTR_V8_RET, /**< v8 ret instruction - subtype of BR_INDIRECT */
OCSD_S_INSTR_V8_ERET, /**< v8 eret instruction - subtype of BR_INDIRECT */
+ OCSD_S_INSTR_V7_IMPLIED_RET, /**< v7 instruction which could imply return e.g. MOV PC, LR; POP { ,pc} */
} ocsd_instr_subtype;
/** Instruction decode request structure.
@@ -377,6 +386,7 @@ typedef struct _ocsd_instr_info {
ocsd_vaddr_t instr_addr; /**< Input: Instruction address. */
uint32_t opcode; /**< Input: Opcode at address. 16 bit opcodes will use MS 16bits of parameter. */
uint8_t dsb_dmb_waypoints; /**< Input: DMB and DSB are waypoints */
+ uint8_t wfi_wfe_branch; /**< Input: WFI, WFE classed as direct branches */
/* instruction decode info */
ocsd_instr_type type; /**< Decoder: Current instruction type. */
@@ -446,7 +456,31 @@ typedef enum _ocsd_mem_space_acc_t {
*
* @return uint32_t : Number of bytes actually read, or 0 for access error.
*/
-typedef uint32_t (* Fn_MemAcc_CB)(const void *p_context, const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint32_t reqBytes, uint8_t *byteBuffer);
+typedef uint32_t (* Fn_MemAcc_CB)(const void *p_context, const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint32_t reqBytes, uint8_t *byteBuffer);
+
+/**
+* Callback function definition for callback function memory accessor type.
+*
+* When using callback memory accessor, the decoder will call this function to obtain the
+* memory at the address for the current opcodes. The memory space will represent the current
+* exception level and security context of the traced code.
+*
+* Return the number of bytes read, which can be less than the amount requested if this would take the
+* access address outside the range of addresses defined when this callback was registered with the decoder.
+*
+* Return 0 bytes if start address out of covered range, or memory space is not one of those defined as supported
+* when the callback was registered.
+*
+* @param p_context : opaque context pointer set by callback client.
+* @param address : start address of memory to be accessed
+* @param mem_space : memory space of accessed memory (current EL & security state)
+* @param trcID : Trace ID for source of trace - allow CB to client to associate mem req with source cpu.
+* @param reqBytes : number of bytes required
+* @param *byteBuffer : buffer for data.
+*
+* @return uint32_t : Number of bytes actually read, or 0 for access error.
+*/
+typedef uint32_t (* Fn_MemAccID_CB)(const void *p_context, const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint8_t trcID, const uint32_t reqBytes, uint8_t *byteBuffer);
/** memory region type for adding multi-region binary files to memory access interface */
diff --git a/decoder/include/opencsd/ocsd_if_version.h b/decoder/include/opencsd/ocsd_if_version.h
new file mode 100644
index 000000000000..70c8df41f52b
--- /dev/null
+++ b/decoder/include/opencsd/ocsd_if_version.h
@@ -0,0 +1,65 @@
+/*
+ * \file ocsd_if_version.h
+ * \brief OpenCSD : Library API versioning
+ *
+ * \copyright Copyright (c) 2016, 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_OCSD_IF_VERSION_H_INCLUDED
+#define ARM_OCSD_IF_VERSION_H_INCLUDED
+
+#include <stdint.h>
+
+/** @addtogroup ocsd_interfaces
+@{*/
+
+/** @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 */
+
+/** Library version number - MMMMnnpp format.
+ MMMM = major version,
+ nn = minor version,
+ pp = patch version
+*/
+#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_LIB_NAME "OpenCSD Library" /**< Library name string */
+#define OCSD_LIB_SHORT_NAME "OCSD" /**< Library Short name string */
+/** @}*/
+
+/** @}*/
+
+#endif // ARM_OCSD_IF_VERSION_H_INCLUDED
+
+/* End of File ocsd_if_version.h */
diff --git a/decoder/include/opencsd/trc_gen_elem_types.h b/decoder/include/opencsd/trc_gen_elem_types.h
index 3766785dbd6d..1d77b53cf8f9 100644
--- a/decoder/include/opencsd/trc_gen_elem_types.h
+++ b/decoder/include/opencsd/trc_gen_elem_types.h
@@ -58,7 +58,7 @@ typedef enum _ocsd_gen_trc_elem_t
OCSD_GEN_TRC_ELEM_EXCEPTION_RET, /*!< expection return */
OCSD_GEN_TRC_ELEM_TIMESTAMP, /*!< Timestamp - preceding elements happeded before this time. */
OCSD_GEN_TRC_ELEM_CYCLE_COUNT, /*!< Cycle count - cycles since last cycle count value - associated with a preceding instruction range. */
- OCSD_GEN_TRC_ELEM_EVENT, /*!< Event - trigger, (TBC - perhaps have a set of event types - cut down additional processing?) */
+ OCSD_GEN_TRC_ELEM_EVENT, /*!< Event - trigger or numbered event */
OCSD_GEN_TRC_ELEM_SWTRACE, /*!< Software trace packet - may contain data payload. */
OCSD_GEN_TRC_ELEM_CUSTOM, /*!< Fully custom packet type - used by none-ARM architecture decoders */
} ocsd_gen_trc_elem_t;
@@ -90,12 +90,15 @@ typedef struct _ocsd_generic_trace_elem {
union {
struct {
uint32_t last_instr_exec:1; /**< 1 if last instruction in range was executed; */
+ uint32_t last_instr_sz:3; /**< size of last instruction in bytes (2/4) */
uint32_t has_cc:1; /**< 1 if this packet has a valid cycle count included (e.g. cycle count included as part of instruction range packet, always 1 for pure cycle count packet.*/
uint32_t cpu_freq_change:1; /**< 1 if this packet indicates a change in CPU frequency */
uint32_t excep_ret_addr:1; /**< 1 if en_addr is the preferred exception return address on exception packet type */
uint32_t excep_data_marker:1; /**< 1 if the exception entry packet is a data push marker only, with no address information (used typically in v7M trace for marking data pushed onto stack) */
uint32_t extended_data:1; /**< 1 if the packet extended data pointer is valid. Allows packet extensions for custom decoders, or additional data payloads for data trace. */
uint32_t has_ts:1; /**< 1 if the packet has an associated timestamp - e.g. SW/STM trace TS+Payload as a single packet */
+ uint32_t last_instr_cond:1; /**< 1 if the last instruction was conditional */
+ uint32_t excep_ret_addr_br_tgt:1; /**< 1 if exception return address (en_addr) is also the target of a taken branch addr from the previous range. */
};
uint32_t flag_bits;
};
@@ -105,7 +108,8 @@ typedef struct _ocsd_generic_trace_elem {
uint32_t exception_number; /**< exception number for exception type packets */
trace_event_t trace_event; /**< Trace event - trigger etc */
trace_on_reason_t trace_on_reason; /**< reason for the trace on packet */
- ocsd_swt_info_t sw_trace_info; /**< software trace packet info */
+ 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) */
};
const void *ptr_extended_data; /**< pointer to extended data buffer (data trace, sw trace payload) / custom structure */