Loading...
Searching...
No Matches
trc_pkt_decode_etmv3.h
Go to the documentation of this file.
/*
* 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_ETMV3_H_INCLUDED
#define ARM_TRC_PKT_DECODE_ETMV3_H_INCLUDED
#include "common/trc_pkt_decode_base.h"
#include "common/trc_gen_elem.h"
#include "common/ocsd_pe_context.h"
#include "common/ocsd_code_follower.h"
#include "common/ocsd_gen_elem_list.h"
#include "opencsd/etmv3/trc_pkt_elem_etmv3.h"
#include "opencsd/etmv3/trc_cmp_cfg_etmv3.h"
/**************** Atom handling class **************************************/
class Etmv3Atoms
{
public:
Etmv3Atoms(const bool isCycleAcc);
~Etmv3Atoms() {};
void initAtomPkt(const EtmV3TrcPacket *in_pkt, const ocsd_trc_index_t &root_index);
const ocsd_atm_val getCurrAtomVal() const;
const int numAtoms() const;
const ocsd_trc_index_t pktIndex() const;
const bool hasAtomCC() const;
const uint32_t getAtomCC() const;
const uint32_t getRemainCC() const;
void clearAtom();
void clearAll();
private:
// Atom PHDR packet formats from ETMv3 spec - defines content of header.
enum {
ATOM_PHDR_FMT_1 = 1,
ATOM_PHDR_FMT_2,
ATOM_PHDR_FMT_3,
ATOM_PHDR_FMT_4,
};
ocsd_pkt_atom m_atom;
uint8_t m_p_hdr_fmt;
uint32_t m_cycle_count;
ocsd_trc_index_t m_root_index;
bool m_isCCPacket;
};
inline Etmv3Atoms::Etmv3Atoms(const bool isCycleAcc)
{
m_isCCPacket = isCycleAcc;
}
inline void Etmv3Atoms::initAtomPkt(const EtmV3TrcPacket *in_pkt, const ocsd_trc_index_t &root_index)
{
m_atom = in_pkt->getAtom();
m_p_hdr_fmt = in_pkt->getPHdrFmt();
m_cycle_count = in_pkt->getCycleCount();
}
inline const ocsd_atm_val Etmv3Atoms::getCurrAtomVal() const
{
return (m_atom.En_bits & 0x1) ? ATOM_E : ATOM_N;
}
inline const int Etmv3Atoms::numAtoms() const
{
return m_atom.num;
}
inline const ocsd_trc_index_t Etmv3Atoms::pktIndex() const
{
return m_root_index;
}
inline const bool Etmv3Atoms::hasAtomCC() const
{
bool hasCC = false;
if(!m_isCCPacket)
return hasCC;
switch(m_p_hdr_fmt)
{
case ATOM_PHDR_FMT_4:
default:
break;
case ATOM_PHDR_FMT_3:
case ATOM_PHDR_FMT_1:
hasCC = true;
break;
case ATOM_PHDR_FMT_2:
hasCC = (m_atom.num > 1); // first of 2 has W state
break;
}
return hasCC;
}
inline const uint32_t Etmv3Atoms::getAtomCC() const
{
uint32_t CC = 0;
if(!m_isCCPacket)
return CC;
switch(m_p_hdr_fmt)
{
case ATOM_PHDR_FMT_4: // no CC in format 4
default:
break;
case ATOM_PHDR_FMT_3: // single CC with optional E atom
CC = m_cycle_count;
break;
case ATOM_PHDR_FMT_2: // single W on first of 2 atoms
CC = (m_atom.num > 1) ? 1: 0;
break;
case ATOM_PHDR_FMT_1: // each atom has 1 CC.
CC = 1;
break;
}
return CC;
}
inline const uint32_t Etmv3Atoms::getRemainCC() const
{
uint32_t CC = 0;
if(!m_isCCPacket)
return CC;
switch(m_p_hdr_fmt)
{
case ATOM_PHDR_FMT_4: // no CC in format 4
default:
break;
case ATOM_PHDR_FMT_3:
CC = m_cycle_count;
break;
case ATOM_PHDR_FMT_2:
CC = (m_atom.num > 1) ? 1: 0;
break;
case ATOM_PHDR_FMT_1:
CC = m_atom.num;
break;
}
return CC;
}
inline void Etmv3Atoms::clearAtom()
{
m_atom.En_bits >>=1;
if(m_atom.num)
m_atom.num--;
}
inline void Etmv3Atoms::clearAll()
{
m_atom.num = 0;
}
/********** Main decode class ****************************************************/
class TrcPktDecodeEtmV3 : public TrcPktDecodeBase<EtmV3TrcPacket, EtmV3Config>
{
public:
TrcPktDecodeEtmV3();
TrcPktDecodeEtmV3(int instIDNum);
virtual ~TrcPktDecodeEtmV3();
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();
void resetDecoder();
ocsd_datapath_resp_t decodePacket(bool &pktDone);
ocsd_datapath_resp_t processISync(const bool withCC, const bool firstSync = false);
ocsd_datapath_resp_t processBranchAddr();
ocsd_datapath_resp_t processPHdr();
ocsd_datapath_resp_t sendUnsyncPacket();
OcsdTraceElement *GetNextOpElem(ocsd_datapath_resp_t &resp);
private:
void setNeedAddr(bool bNeedAddr);
void pendExceptionReturn();
bool preISyncValid(ocsd_etmv3_pkt_type pkt_type);
//** intra packet state;
OcsdCodeFollower m_code_follower;
ocsd_vaddr_t m_IAddr;
bool m_bNeedAddr;
bool m_bSentUnknown;
bool m_bWaitISync;
OcsdPeContext m_PeContext;
OcsdGenElemList m_outputElemList;
//** Other packet decoder state;
// trace decode FSM
typedef enum {
NO_SYNC,
WAIT_ASYNC,
WAIT_ISYNC,
DECODE_PKTS,
SEND_PKTS,
} processor_state_t;
processor_state_t m_curr_state;
unsync_info_t m_unsync_info;
uint8_t m_CSID;
};
#endif // ARM_TRC_PKT_DECODE_ETMV3_H_INCLUDED
/* End of File trc_pkt_decode_etmv3.h */
EtmV3TrcPacket
ETMv3 Trace Protocol Packet.
Definition trc_pkt_elem_etmv3.h:54
EtmV3TrcPacket::getPHdrFmt
const uint8_t getPHdrFmt() const
Definition trc_pkt_elem_etmv3.h:139
EtmV3TrcPacket::getCycleCount
const uint32_t getCycleCount() const
Definition trc_pkt_elem_etmv3.h:122
EtmV3TrcPacket::getAtom
const ocsd_pkt_atom & getAtom() const
Definition trc_pkt_elem_etmv3.h:138
Etmv3Atoms::initAtomPkt
void initAtomPkt(const EtmV3TrcPacket *in_pkt, const ocsd_trc_index_t &root_index)
initialise the atom and index values
Definition trc_pkt_decode_etmv3.h:94
Etmv3Atoms::getRemainCC
const uint32_t getRemainCC() const
get residual cycle count for remaining atoms
Definition trc_pkt_decode_etmv3.h:167
Etmv3Atoms::clearAtom
void clearAtom()
clear the current atom, set the next.
Definition trc_pkt_decode_etmv3.h:194
Etmv3Atoms::Etmv3Atoms
Etmv3Atoms(const bool isCycleAcc)
Definition trc_pkt_decode_etmv3.h:88
Etmv3Atoms::clearAll
void clearAll()
clear all
Definition trc_pkt_decode_etmv3.h:201
Etmv3Atoms::getAtomCC
const uint32_t getAtomCC() const
cycle count for current atom
Definition trc_pkt_decode_etmv3.h:140
Etmv3Atoms::numAtoms
const int numAtoms() const
number of atoms
Definition trc_pkt_decode_etmv3.h:106
Etmv3Atoms::getCurrAtomVal
const ocsd_atm_val getCurrAtomVal() const
Definition trc_pkt_decode_etmv3.h:101
Etmv3Atoms::pktIndex
const ocsd_trc_index_t pktIndex() const
originating packet index
Definition trc_pkt_decode_etmv3.h:111
Etmv3Atoms::hasAtomCC
const bool hasAtomCC() const
cycle count for current atom?
Definition trc_pkt_decode_etmv3.h:116
Etmv3Atoms::~Etmv3Atoms
~Etmv3Atoms()
Definition trc_pkt_decode_etmv3.h:52
OcsdCodeFollower
The code follower looks for waypoints or addresses.
Definition ocsd_code_follower.h:53
OcsdGenElemList
Maintain a list of elements to be output.
Definition ocsd_gen_elem_list.h:57
OcsdPeContext
Handler for the ocsd_pe_context structure.
Definition ocsd_pe_context.h:46
OcsdTraceElement
Generic trace element class.
Definition trc_gen_elem.h:50
TrcPktDecodeEtmV3::onProtocolConfig
virtual ocsd_err_t onProtocolConfig()
TrcPktDecodeEtmV3::TrcPktDecodeEtmV3
TrcPktDecodeEtmV3()
TrcPktDecodeEtmV3::resetDecoder
void resetDecoder()
reset state to start of decode. (moves state, retains config)
TrcPktDecodeEtmV3::initDecoder
void initDecoder()
initial state on creation (zeros all config)
TrcPktDecodeEtmV3::processPacket
virtual ocsd_datapath_resp_t processPacket()
TrcPktDecodeEtmV3::~TrcPktDecodeEtmV3
virtual ~TrcPktDecodeEtmV3()
TrcPktDecodeEtmV3::processPHdr
ocsd_datapath_resp_t processPHdr()
TrcPktDecodeEtmV3::sendUnsyncPacket
ocsd_datapath_resp_t sendUnsyncPacket()
send an initial unsync packet when decoder starts
TrcPktDecodeEtmV3::onReset
virtual ocsd_datapath_resp_t onReset()
TrcPktDecodeEtmV3::GetNextOpElem
OcsdTraceElement * GetNextOpElem(ocsd_datapath_resp_t &resp)
get the next element from the element list.
TrcPktDecodeEtmV3::onEOT
virtual ocsd_datapath_resp_t onEOT()
TrcPktDecodeEtmV3::decodePacket
ocsd_datapath_resp_t decodePacket(bool &pktDone)
decode a packet
TrcPktDecodeEtmV3::onFlush
virtual ocsd_datapath_resp_t onFlush()
TrcPktDecodeEtmV3::processBranchAddr
ocsd_datapath_resp_t processBranchAddr()
TrcPktDecodeEtmV3::TrcPktDecodeEtmV3
TrcPktDecodeEtmV3(int instIDNum)
TrcPktDecodeEtmV3::getCoreSightTraceID
virtual const uint8_t getCoreSightTraceID()
Definition trc_pkt_decode_etmv3.h:221
TrcPktDecodeEtmV3::processISync
ocsd_datapath_resp_t processISync(const bool withCC, const bool firstSync=false)
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_vaddr_t
uint64_t ocsd_vaddr_t
Definition ocsd_if_types.h:306
TrcPktDecodeBase< EtmV3TrcPacket, EtmV3Config >::TrcPktDecodeBase
TrcPktDecodeBase(const char *component_name)
Definition trc_pkt_decode_base.h:221
ocsd_etmv3_pkt_type
enum _ocsd_etmv3_pkt_type ocsd_etmv3_pkt_type
ocsd_atm_val
enum _ocsd_atm_val ocsd_atm_val
ocsd_pkt_atom
struct _ocsd_pkt_atom ocsd_pkt_atom
ATOM_N
@ ATOM_N
Definition trc_pkt_types.h:80
ATOM_E
@ ATOM_E
Definition trc_pkt_types.h:81
ocsd_code_follower.h
ocsd_gen_elem_list.h
ocsd_pe_context.h
trc_cmp_cfg_etmv3.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_etmv3.h