diff options
author | Andrew Turner <andrew@FreeBSD.org> | 2020-06-15 11:30:04 +0000 |
---|---|---|
committer | Andrew Turner <andrew@FreeBSD.org> | 2020-06-15 11:30:04 +0000 |
commit | d7aa8d0a1f110421252d79f5acfb72d89187ad1f (patch) | |
tree | 8b0efac880d3949a9d25ab9bb34792eac605eee6 /decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h | |
parent | cf98ba14dc260458f757fa46419575cf69f45a44 (diff) | |
download | src-d7aa8d0a1f110421252d79f5acfb72d89187ad1f.tar.gz src-d7aa8d0a1f110421252d79f5acfb72d89187ad1f.zip |
Import OpenCSD v0.14.2vendor/opencsd/v0.14.2vendor/opencsd
Sponsored by: Innovate UK
Notes
Notes:
svn path=/vendor/opencsd/dist/; revision=362193
svn path=/vendor/opencsd/v0.14.2/; revision=362194; tag=vendor/opencsd/v0.14.2
Diffstat (limited to 'decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h')
-rw-r--r-- | decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h | 131 |
1 files changed, 84 insertions, 47 deletions
diff --git a/decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h b/decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h index 1c06e5ddf03a..419cd828928c 100644 --- a/decoder/include/opencsd/etmv4/trc_pkt_decode_etmv4i.h +++ b/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 |