Loading...
Searching...
No Matches
trc_pkt_decode_ptm.h
Go to the documentation of this file.
/*
* \file trc_pkt_decode_ptm.h
* \brief OpenCSD : PTM packet decoder.
*
* \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_TRC_PKT_DECODE_PTM_H_INCLUDED
#define ARM_TRC_PKT_DECODE_PTM_H_INCLUDED
#include "common/trc_pkt_decode_base.h"
#include "opencsd/ptm/trc_pkt_elem_ptm.h"
#include "opencsd/ptm/trc_cmp_cfg_ptm.h"
#include "common/trc_gen_elem.h"
#include "common/trc_ret_stack.h"
/**************** Atom handling class **************************************/
class PtmAtoms
{
public:
PtmAtoms() {};
~PtmAtoms() {};
void initAtomPkt(const ocsd_pkt_atom &atom, const ocsd_trc_index_t &root_index);
const ocsd_atm_val getCurrAtomVal() const;
const int numAtoms() const;
const ocsd_trc_index_t pktIndex() const;
void clearAtom();
void clearAll();
private:
ocsd_pkt_atom m_atom;
ocsd_trc_index_t m_root_index;
};
inline void PtmAtoms::initAtomPkt(const ocsd_pkt_atom &atom, const ocsd_trc_index_t &root_index)
{
m_atom = atom;
m_root_index = root_index;
}
inline const ocsd_atm_val PtmAtoms::getCurrAtomVal() const
{
return (m_atom.En_bits & 0x1) ? ATOM_E : ATOM_N;
}
inline const int PtmAtoms::numAtoms() const
{
return m_atom.num;
}
inline const ocsd_trc_index_t PtmAtoms::pktIndex() const
{
return m_root_index;
}
inline void PtmAtoms::clearAtom()
{
if(m_atom.num)
{
m_atom.num--;
m_atom.En_bits >>=1;
}
}
inline void PtmAtoms::clearAll()
{
m_atom.num = 0;
}
/********** Main decode class ****************************************************/
class TrcPktDecodePtm : public TrcPktDecodeBase<PtmTrcPacket, PtmConfig>
{
public:
TrcPktDecodePtm();
TrcPktDecodePtm(int instIDNum);
virtual ~TrcPktDecodePtm();
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 */
private:
typedef enum {
TRACE_WAYPOINT,
TRACE_TO_ADDR_EXCL,
TRACE_TO_ADDR_INCL
} waypoint_trace_t;
void initDecoder();
void resetDecoder();
ocsd_datapath_resp_t decodePacket();
ocsd_datapath_resp_t contProcess();
ocsd_datapath_resp_t processIsync();
ocsd_datapath_resp_t processBranch();
ocsd_datapath_resp_t processWPUpdate();
ocsd_datapath_resp_t processAtom();
ocsd_err_t traceInstrToWP(bool &bWPFound, const waypoint_trace_t traceWPOp = TRACE_WAYPOINT, const ocsd_vaddr_t nextAddrMatch = 0);
ocsd_datapath_resp_t processAtomRange(const ocsd_atm_val A, const char *pkt_msg, const waypoint_trace_t traceWPOp = TRACE_WAYPOINT, const ocsd_vaddr_t nextAddrMatch = 0);
void checkPendingNacc(ocsd_datapath_resp_t &resp);
uint8_t m_CSID;
//** Other processor state;
// trace decode FSM
typedef enum {
NO_SYNC,
WAIT_SYNC,
WAIT_ISYNC,
DECODE_PKTS,
CONT_ISYNC,
CONT_ATOM,
CONT_WPUP,
CONT_BRANCH,
} processor_state_t;
processor_state_t m_curr_state;
unsync_info_t m_unsync_info;
const bool processStateIsCont() const;
// PE decode state - address and isa
typedef struct _ptm_pe_addr_state {
ocsd_isa isa;
ocsd_vaddr_t instr_addr;
bool valid;
} ptm_pe_addr_state;
ptm_pe_addr_state m_curr_pe_state;
ocsd_pe_context m_pe_context;
// packet decode state
bool m_need_isync;
ocsd_instr_info m_instr_info;
bool m_mem_nacc_pending;
ocsd_vaddr_t m_nacc_addr;
bool m_i_sync_pe_ctxt;
PtmAtoms m_atoms;
TrcAddrReturnStack m_return_stack;
//** output element
OcsdTraceElement m_output_elem;
};
inline const bool TrcPktDecodePtm::processStateIsCont() const
{
return (bool)(m_curr_state >= CONT_ISYNC);
}
#endif // ARM_TRC_PKT_DECODE_PTM_H_INCLUDED
/* End of File trc_pkt_decode_ptm.h */
OcsdTraceElement
Generic trace element class.
Definition trc_gen_elem.h:50
PtmAtoms
Definition trc_pkt_decode_ptm.h:45
PtmAtoms::getCurrAtomVal
const ocsd_atm_val getCurrAtomVal() const
Definition trc_pkt_decode_ptm.h:71
PtmAtoms::PtmAtoms
PtmAtoms()
Definition trc_pkt_decode_ptm.h:47
PtmAtoms::clearAll
void clearAll()
clear all
Definition trc_pkt_decode_ptm.h:95
PtmAtoms::numAtoms
const int numAtoms() const
number of atoms
Definition trc_pkt_decode_ptm.h:76
PtmAtoms::initAtomPkt
void initAtomPkt(const ocsd_pkt_atom &atom, const ocsd_trc_index_t &root_index)
initialise the atom and index values
Definition trc_pkt_decode_ptm.h:65
PtmAtoms::pktIndex
const ocsd_trc_index_t pktIndex() const
originating packet index
Definition trc_pkt_decode_ptm.h:81
PtmAtoms::~PtmAtoms
~PtmAtoms()
Definition trc_pkt_decode_ptm.h:48
PtmAtoms::clearAtom
void clearAtom()
clear the current atom, set the next.
Definition trc_pkt_decode_ptm.h:86
TrcAddrReturnStack
Definition trc_ret_stack.h:54
TrcPktDecodeBase
Definition trc_pkt_decode_base.h:195
TrcPktDecodePtm
Definition trc_pkt_decode_ptm.h:102
TrcPktDecodePtm::getCoreSightTraceID
virtual const uint8_t getCoreSightTraceID()
Definition trc_pkt_decode_ptm.h:115
TrcPktDecodePtm::onReset
virtual ocsd_datapath_resp_t onReset()
TrcPktDecodePtm::onEOT
virtual ocsd_datapath_resp_t onEOT()
TrcPktDecodePtm::TrcPktDecodePtm
TrcPktDecodePtm()
TrcPktDecodePtm::onProtocolConfig
virtual ocsd_err_t onProtocolConfig()
TrcPktDecodePtm::TrcPktDecodePtm
TrcPktDecodePtm(int instIDNum)
TrcPktDecodePtm::onFlush
virtual ocsd_datapath_resp_t onFlush()
TrcPktDecodePtm::~TrcPktDecodePtm
virtual ~TrcPktDecodePtm()
TrcPktDecodePtm::processPacket
virtual ocsd_datapath_resp_t processPacket()
unsync_info_t
enum _unsync_info_t unsync_info_t
ocsd_trc_index_t
uint32_t ocsd_trc_index_t
Definition ocsd_if_types.h:59
ocsd_datapath_resp_t
enum _ocsd_datapath_resp_t ocsd_datapath_resp_t
ocsd_err_t
enum _ocsd_err_t ocsd_err_t
ocsd_isa
enum _ocsd_isa ocsd_isa
ocsd_vaddr_t
uint64_t ocsd_vaddr_t
Definition ocsd_if_types.h:306
ocsd_atm_val
enum _ocsd_atm_val ocsd_atm_val
ATOM_N
@ ATOM_N
Definition trc_pkt_types.h:80
ATOM_E
@ ATOM_E
Definition trc_pkt_types.h:81
_ocsd_instr_info
Definition ocsd_if_types.h:383
_ocsd_pe_context
Definition ocsd_if_types.h:407
_ocsd_pkt_atom
Definition trc_pkt_types.h:85
_ocsd_pkt_atom::num
uint8_t num
Definition trc_pkt_types.h:91
_ocsd_pkt_atom::En_bits
uint32_t En_bits
Definition trc_pkt_types.h:90
trc_cmp_cfg_ptm.h
trc_gen_elem.h
OpenCSD : Decoder Generic trace element output class.
trc_pkt_decode_base.h
OpenCSD : Trace Packet decoder base class.
trc_pkt_elem_ptm.h
trc_ret_stack.h