trc_pkt_decode_etmv4i.h
Go to the documentation of this file.
/*
* \file trc_pkt_decode_etmv4i.h
* \brief OpenCSD : ETMv4 instruction decoder
*
* \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_DECODE_ETMV4I_H_INCLUDED
#define ARM_TRC_PKT_DECODE_ETMV4I_H_INCLUDED
#include "common/trc_pkt_decode_base.h"
#include "opencsd/etmv4/trc_pkt_elem_etmv4i.h"
#include "opencsd/etmv4/trc_cmp_cfg_etmv4.h"
#include "common/trc_gen_elem.h"
#include "common/trc_ret_stack.h"
#include "opencsd/etmv4/trc_etmv4_stack_elem.h"
class TrcStackElem;
class TrcStackElemParam;
class TrcStackElemCtxt;
class TrcPktDecodeEtmV4I : public TrcPktDecodeBase<EtmV4ITrcPacket, EtmV4Config>
{
public:
TrcPktDecodeEtmV4I();
TrcPktDecodeEtmV4I(int instIDNum);
virtual ~TrcPktDecodeEtmV4I();
protected:
/* implementation packet decoding interface */
virtual ocsd_datapath_resp_t processPacket();
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 uint8_t getCoreSightTraceID() { return m_CSID; };
/* local decode methods */
void initDecoder(); // initial state on creation (zeros all config)
void resetDecoder(); // reset state to start of decode. (moves state, retains config)
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();
void doTraceInfoPacket();
void updateContext(TrcStackElemCtxt *pCtxtElem);
// process atom will output instruction trace, or no memory access trace elements.
ocsd_datapath_resp_t processAtom(const ocsd_atm_val, bool &bCont);
// process an exception element - output instruction trace + exception generic type.
ocsd_datapath_resp_t processException();
// process a bad packet
ocsd_datapath_resp_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);
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;
}
ocsd_err_t traceInstrToWP(bool &bWPFound, const bool traceToAddrNext = false, const ocsd_vaddr_t nextAddrMatch = 0);
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
uint64_t m_timestamp; // last broadcast global Timestamp.
// state and context
uint32_t m_context_id; // most recent context ID
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).
int m_curr_spec_depth;
int m_max_spec_depth;
// data trace associative elements (unsupported at present in the decoder).
int m_p0_key;
int m_p0_key_max;
// conditional non-branch trace - when data trace active (unsupported at present in the decoder)
int m_cond_c_key;
int m_cond_r_key;
int m_cond_key_max_incr;
uint8_t m_CSID;
bool m_IASize64;
//** Other processor state;
// trace decode FSM
typedef enum {
NO_SYNC,
WAIT_SYNC,
WAIT_TINFO,
DECODE_PKTS,
COMMIT_ELEM,
} processor_state_t;
processor_state_t m_curr_state;
//** P0 element stack
EtmV4P0Stack m_P0_stack;
int m_P0_commit;
// packet decode state
bool m_need_ctxt;
bool m_need_addr;
bool m_except_pending_addr;
// 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;
etmv4_addr_val_t addr;
uint32_t number;
ocsd_trc_index_t index;
bool addr_b_tgt;
} m_excep_info;
ocsd_instr_info m_instr_info;
bool m_mem_nacc_pending;
ocsd_vaddr_t m_nacc_addr;
ocsd_pe_context m_pe_context;
etmv4_trace_info_t m_trace_info;
bool m_prev_overflow;
bool m_flush_EOT;
TrcAddrReturnStack m_return_stack;
//** output element
OcsdTraceElement m_output_elem;
};
#endif // ARM_TRC_PKT_DECODE_ETMV4I_H_INCLUDED
/* End of File trc_pkt_decode_etmv4i.h */
_ocsd_instr_info
Definition: ocsd_if_types.h:382
ocsd_err_t
enum _ocsd_err_t ocsd_err_t
TrcPktDecodeEtmV4I::doTraceInfoPacket
void doTraceInfoPacket()
OcsdTraceElement
Generic trace element class.
Definition: trc_gen_elem.h:49
TrcPktDecodeEtmV4I::outputEvent
ocsd_datapath_resp_t outputEvent(TrcStackElemParam *pParamElem)
TrcStackElemParam
Definition: trc_etmv4_stack_elem.h:226
_etmv4_trace_info_t
Definition: trc_pkt_types_etmv4.h:151
TrcPktDecodeEtmV4I::getCoreSightTraceID
virtual const uint8_t getCoreSightTraceID()
Definition: trc_pkt_decode_etmv4i.h:63
TrcPktDecodeEtmV4I::processPacket
virtual ocsd_datapath_resp_t processPacket()
TrcStackElemCtxt
Definition: trc_etmv4_stack_elem.h:125
TrcPktDecodeEtmV4I::onReset
virtual ocsd_datapath_resp_t onReset()
TrcPktDecodeEtmV4I::outputCC
ocsd_datapath_resp_t outputCC(TrcStackElemParam *pParamElem)
TrcPktDecodeEtmV4I::decodePacket
ocsd_datapath_resp_t decodePacket(bool &Complete)
TrcPktDecodeEtmV4I::onFlush
virtual ocsd_datapath_resp_t onFlush()
TrcPktDecodeBase
Definition: trc_pkt_decode_base.h:180
_etmv4_addr_val_t
Definition: trc_pkt_types_etmv4.h:175
TrcPktDecodeEtmV4I::processException
ocsd_datapath_resp_t processException()
TrcPktDecodeEtmV4I::processAtom
ocsd_datapath_resp_t processAtom(const ocsd_atm_val, bool &bCont)
TrcPktDecodeEtmV4I::resetDecoder
void resetDecoder()
TrcPktDecodeEtmV4I::updateContext
void updateContext(TrcStackElemCtxt *pCtxtElem)
ocsd_vaddr_t
uint64_t ocsd_vaddr_t
Definition: ocsd_if_types.h:308
TrcPktDecodeEtmV4I::addr
etmv4_addr_val_t addr
excetion return address.
Definition: trc_pkt_decode_etmv4i.h:170
TrcPktDecodeEtmV4I::initDecoder
void initDecoder()
TrcPktDecodeEtmV4I
Definition: trc_pkt_decode_etmv4i.h:49
trc_gen_elem.h
OpenCSD : Decoder Generic trace element output class.
ocsd_atm_val
enum _ocsd_atm_val ocsd_atm_val
ocsd_isa_thumb2
Definition: ocsd_if_types.h:327
EtmV4P0Stack
Definition: trc_etmv4_stack_elem.h:250
TrcAddrReturnStack
Definition: trc_ret_stack.h:53
ocsd_isa_aarch64
Definition: ocsd_if_types.h:328
TrcPktDecodeEtmV4I::outputTS
ocsd_datapath_resp_t outputTS(TrcStackElemParam *pParamElem, bool withCC)
TrcPktDecodeEtmV4I::~TrcPktDecodeEtmV4I
virtual ~TrcPktDecodeEtmV4I()
_ocsd_pe_context
Definition: ocsd_if_types.h:406
trc_ret_stack.h
TrcPktDecodeEtmV4I::commitElements
ocsd_datapath_resp_t commitElements(bool &Complete)
trc_cmp_cfg_etmv4.h
ocsd_trc_index_t
uint32_t ocsd_trc_index_t
Definition: ocsd_if_types.h:67
TrcStackElem
Definition: trc_etmv4_stack_elem.h:68
TrcPktDecodeEtmV4I::proc
excep_proc_state_t proc
state of exception processing
Definition: trc_pkt_decode_etmv4i.h:169
trc_pkt_decode_base.h
OpenCSD : Trace Packet decoder base class.
TrcPktDecodeEtmV4I::index
ocsd_trc_index_t index
trace index for exception element
Definition: trc_pkt_decode_etmv4i.h:172
TrcPktDecodeEtmV4I::onProtocolConfig
virtual ocsd_err_t onProtocolConfig()
TrcPktDecodeEtmV4I::flushEOT
ocsd_datapath_resp_t flushEOT()
ocsd_isa_arm
Definition: ocsd_if_types.h:326
ocsd_isa
enum _ocsd_isa ocsd_isa
ocsd_datapath_resp_t
enum _ocsd_datapath_resp_t ocsd_datapath_resp_t
TrcPktDecodeEtmV4I::handleBadPacket
ocsd_datapath_resp_t handleBadPacket(const char *reason)
TrcPktDecodeEtmV4I::number
uint32_t number
exception number.
Definition: trc_pkt_decode_etmv4i.h:171
TrcPktDecodeEtmV4I::TrcPktDecodeEtmV4I
TrcPktDecodeEtmV4I()
TrcPktDecodeEtmV4I::addr_b_tgt
bool addr_b_tgt
return address is also branch tgt address.
Definition: trc_pkt_decode_etmv4i.h:173
trc_pkt_elem_etmv4i.h
trc_etmv4_stack_elem.h
TrcPktDecodeEtmV4I::onEOT
virtual ocsd_datapath_resp_t onEOT()