aboutsummaryrefslogtreecommitdiffstats
path: root/decoder/include/opencsd/etmv4
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/etmv4
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/etmv4')
-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
5 files changed, 132 insertions, 79 deletions
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