trc_pkt_proc_ptm.h
Go to the documentation of this file.
/*
* \file trc_pkt_proc_ptm.h
* \brief OpenCSD :
*
* \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_PROC_PTM_H_INCLUDED
#define ARM_TRC_PKT_PROC_PTM_H_INCLUDED
#include "trc_pkt_types_ptm.h"
#include "common/trc_pkt_proc_base.h"
#include "trc_pkt_elem_ptm.h"
#include "trc_cmp_cfg_ptm.h"
class PtmTrcPacket;
class PtmConfig;
class TrcPktProcPtm : public TrcPktProcBase< PtmTrcPacket, ocsd_ptm_pkt_type, PtmConfig>
{
public:
TrcPktProcPtm();
TrcPktProcPtm(int instIDNum);
virtual ~TrcPktProcPtm();
protected:
/* implementation packet processing interface */
virtual ocsd_datapath_resp_t processData( const ocsd_trc_index_t index,
const uint32_t dataBlockSize,
const uint8_t *pDataBlock,
uint32_t *numBytesProcessed);
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 bool isBadPacket() const;
void InitPacketState(); // clear current packet state.
void InitProcessorState(); // clear all previous process state
ocsd_datapath_resp_t outputPacket();
typedef enum _process_state {
WAIT_SYNC,
PROC_HDR,
PROC_DATA,
SEND_PKT,
} process_state;
process_state m_process_state; // process algorithm state.
std::vector<uint8_t> m_currPacketData; // raw data
uint32_t m_currPktIdx; // index into packet when expanding
PtmTrcPacket m_curr_packet; // expanded packet
ocsd_trc_index_t m_curr_pkt_index; // trace index at start of packet.
const bool readByte(uint8_t &currByte);
const bool readByte(); // just read into buffer, don't need the value
void unReadByte(); // remove last byte from the buffer.
uint8_t m_chanIDCopy;
// current data block being processed.
const uint8_t *m_pDataIn;
uint32_t m_dataInLen;
uint32_t m_dataInProcessed;
ocsd_trc_index_t m_block_idx; // index start for current block
// processor synchronisation
const bool isSync() const;
ocsd_datapath_resp_t waitASync();
bool m_waitASyncSOPkt;
bool m_bAsyncRawOp;
bool m_bOPNotSyncPkt;
// ** packet processing functions.
void pktASync();
void pktISync();
void pktTrigger();
void pktWPointUpdate();
void pktIgnore();
void pktCtxtID();
void pktVMID();
void pktAtom();
void pktTimeStamp();
void pktExceptionRet();
void pktBranchAddr();
void pktReserved();
// async finder
typedef enum _async_result {
ASYNC,
NOT_ASYNC,
ASYNC_EXTRA_0,
THROW_0,
ASYNC_INCOMPLETE,
} async_result_t;
async_result_t findAsync();
int m_async_0; // number of current consecutive async 0s
bool m_part_async;
// number of extra 0s before we throw 0 on async detect.
#define ASYNC_PAD_0_LIMIT 11
// number of 0s minimum to form an async
#define ASYNC_REQ_0 5
// extraction sub-routines
void extractCtxtID(int idx, uint32_t &ctxtID);
void extractCycleCount(int idx, uint32_t &cycleCount);
int extractTS(uint64_t &tsVal, uint8_t &tsUpdateBits);
uint32_t extractAddress(const int offset,uint8_t &total_bits);
// number of bytes required for a complete packet - used in some multi byte packets
int m_numPktBytesReq;
// packet processing state
bool m_needCycleCount;
bool m_gotCycleCount;
int m_gotCCBytes; // number of CC bytes read so far
int m_numCtxtIDBytes;
int m_gotCtxtIDBytes;
bool m_gotTSBytes;
int m_tsByteMax;
// branch address state
bool m_gotAddrBytes;
int m_numAddrBytes;
bool m_gotExcepBytes;
int m_numExcepBytes;
ocsd_isa m_addrPktIsa;
int m_excepAltISA;
// bad packets
void throwMalformedPacketErr(const char *pszErrMsg);
void throwPacketHeaderErr(const char *pszErrMsg);
// packet processing function table
typedef void (TrcPktProcPtm::*PPKTFN)(void);
PPKTFN m_pIPktFn;
struct _pkt_i_table_t {
ocsd_ptm_pkt_type pkt_type;
PPKTFN pptkFn;
} m_i_table[256];
void BuildIPacketTable();
};
inline const bool TrcPktProcPtm::isSync() const
{
return (bool)(m_curr_packet.getType() == PTM_PKT_NOTSYNC);
}
inline void TrcPktProcPtm::throwMalformedPacketErr(const char *pszErrMsg)
{
m_curr_packet.SetErrType(PTM_PKT_BAD_SEQUENCE);
throw ocsdError(OCSD_ERR_SEV_ERROR,OCSD_ERR_BAD_PACKET_SEQ,m_curr_pkt_index,m_chanIDCopy,pszErrMsg);
}
inline void TrcPktProcPtm::throwPacketHeaderErr(const char *pszErrMsg)
{
throw ocsdError(OCSD_ERR_SEV_ERROR,OCSD_ERR_INVALID_PCKT_HDR,m_curr_pkt_index,m_chanIDCopy,pszErrMsg);
}
inline const bool TrcPktProcPtm::readByte()
{
uint8_t currByte;
return readByte(currByte);
}
#endif // ARM_TRC_PKT_PROC_PTM_H_INCLUDED
/* End of File trc_pkt_proc_ptm.h */
TrcPktProcPtm::m_chanIDCopy
uint8_t m_chanIDCopy
Definition: trc_pkt_proc_ptm.h:94
PTM_PKT_NOTSYNC
no sync found yet
Definition: trc_pkt_types_ptm.h:49
TrcPktProcPtm::PPKTFN
void(TrcPktProcPtm::* PPKTFN)(void)
Definition: trc_pkt_proc_ptm.h:177
TrcPktProcPtm::m_process_state
process_state m_process_state
Definition: trc_pkt_proc_ptm.h:83
TrcPktProcPtm::m_i_table
struct TrcPktProcPtm::_pkt_i_table_t m_i_table[256]
ocsd_err_t
enum _ocsd_err_t ocsd_err_t
TrcPktProcPtm::WAIT_SYNC
Definition: trc_pkt_proc_ptm.h:77
TrcPktProcPtm::onReset
virtual ocsd_datapath_resp_t onReset()
Implementation function for the OCSD_OP_RESET operation.
TrcPktProcPtm::m_needCycleCount
bool m_needCycleCount
Definition: trc_pkt_proc_ptm.h:153
PtmTrcPacket
Definition: trc_pkt_elem_ptm.h:48
TrcPktProcPtm::ASYNC_INCOMPLETE
not enough input data.
Definition: trc_pkt_proc_ptm.h:129
TrcPktProcPtm::pktCtxtID
void pktCtxtID()
ocsdError
Definition: ocsd_error.h:58
TrcPktProcPtm::onProtocolConfig
virtual ocsd_err_t onProtocolConfig()
Called when the configuration object is passed to the decoder.
TrcPktProcPtm::m_async_0
int m_async_0
Definition: trc_pkt_proc_ptm.h:134
TrcPktProcPtm::pktReserved
void pktReserved()
TrcPktProcPtm::ASYNC
pattern confirmed async 0x00 x 5, 0x80
Definition: trc_pkt_proc_ptm.h:125
TrcPktProcPtm::pktVMID
void pktVMID()
TrcPktProcPtm::m_numCtxtIDBytes
int m_numCtxtIDBytes
Definition: trc_pkt_proc_ptm.h:157
TrcPktProcPtm::_pkt_i_table_t::pkt_type
ocsd_ptm_pkt_type pkt_type
Definition: trc_pkt_proc_ptm.h:181
TrcPktProcPtm::throwMalformedPacketErr
void throwMalformedPacketErr(const char *pszErrMsg)
Definition: trc_pkt_proc_ptm.h:194
TrcPktProcPtm::m_currPacketData
std::vector< uint8_t > m_currPacketData
Definition: trc_pkt_proc_ptm.h:85
TrcPktProcPtm::readByte
const bool readByte()
Definition: trc_pkt_proc_ptm.h:205
TrcPktProcPtm::pktTimeStamp
void pktTimeStamp()
TrcPktProcPtm::THROW_0
long pattern of 0x00 - throw some away.
Definition: trc_pkt_proc_ptm.h:128
TrcPktProcPtm
Definition: trc_pkt_proc_ptm.h:52
TrcPktProcPtm::isBadPacket
virtual const bool isBadPacket() const
check if the current packet is an error / bad packet
TrcPktProcPtm::TrcPktProcPtm
TrcPktProcPtm()
TrcPktProcPtm::SEND_PKT
Definition: trc_pkt_proc_ptm.h:80
OCSD_ERR_INVALID_PCKT_HDR
Definition: ocsd_if_types.h:113
TrcPktProcPtm::pktIgnore
void pktIgnore()
TrcPktProcPtm::PROC_DATA
Definition: trc_pkt_proc_ptm.h:79
TrcPktProcPtm::m_numPktBytesReq
int m_numPktBytesReq
Definition: trc_pkt_proc_ptm.h:150
TrcPktProcPtm::m_part_async
bool m_part_async
Definition: trc_pkt_proc_ptm.h:136
TrcPktProcPtm::ASYNC_EXTRA_0
pattern confirmed 0x00 x N + ASYNC
Definition: trc_pkt_proc_ptm.h:127
TrcPktProcPtm::findAsync
async_result_t findAsync()
TrcPktProcPtm::m_gotCCBytes
int m_gotCCBytes
Definition: trc_pkt_proc_ptm.h:155
TrcPktProcPtm::unReadByte
void unReadByte()
TrcPktProcPtm::m_excepAltISA
int m_excepAltISA
Alt ISA bit iff exception bytes.
Definition: trc_pkt_proc_ptm.h:169
TrcPktProcPtm::~TrcPktProcPtm
virtual ~TrcPktProcPtm()
PtmTrcPacket::SetErrType
void SetErrType(const ocsd_ptm_pkt_type e_type)
Definition: trc_pkt_elem_ptm.h:142
TrcPktProcPtm::m_currPktIdx
uint32_t m_currPktIdx
Definition: trc_pkt_proc_ptm.h:86
TrcPktProcPtm::m_curr_pkt_index
ocsd_trc_index_t m_curr_pkt_index
Definition: trc_pkt_proc_ptm.h:88
TrcPktProcPtm::m_curr_packet
PtmTrcPacket m_curr_packet
Definition: trc_pkt_proc_ptm.h:87
TrcPktProcPtm::_process_state
_process_state
Definition: trc_pkt_proc_ptm.h:76
OCSD_ERR_BAD_PACKET_SEQ
Definition: ocsd_if_types.h:112
trc_cmp_cfg_ptm.h
TrcPktProcPtm::m_gotCtxtIDBytes
int m_gotCtxtIDBytes
Definition: trc_pkt_proc_ptm.h:158
TrcPktProcPtm::extractCycleCount
void extractCycleCount(int idx, uint32_t &cycleCount)
TrcPktProcPtm::processData
virtual ocsd_datapath_resp_t processData(const ocsd_trc_index_t index, const uint32_t dataBlockSize, const uint8_t *pDataBlock, uint32_t *numBytesProcessed)
Implementation function for the OCSD_OP_DATA operation.
TrcPktProcPtm::onEOT
virtual ocsd_datapath_resp_t onEOT()
Implementation function for the OCSD_OP_EOT operation.
PtmTrcPacket::getType
const ocsd_ptm_pkt_type getType() const
Definition: trc_pkt_elem_ptm.h:208
TrcPktProcPtm::m_addrPktIsa
ocsd_isa m_addrPktIsa
ISA of the branch address packet.
Definition: trc_pkt_proc_ptm.h:168
TrcPktProcPtm::pktAtom
void pktAtom()
TrcPktProcPtm::m_pDataIn
const uint8_t * m_pDataIn
Definition: trc_pkt_proc_ptm.h:97
TrcPktProcPtm::m_tsByteMax
int m_tsByteMax
max size for TS portion of TS packet.
Definition: trc_pkt_proc_ptm.h:161
TrcPktProcPtm::_async_result
_async_result
Definition: trc_pkt_proc_ptm.h:124
TrcPktProcPtm::_pkt_i_table_t::pptkFn
PPKTFN pptkFn
Definition: trc_pkt_proc_ptm.h:182
TrcPktProcPtm::m_gotTSBytes
bool m_gotTSBytes
got all TS bytes
Definition: trc_pkt_proc_ptm.h:160
trc_pkt_types_ptm.h
TrcPktProcPtm::m_numExcepBytes
int m_numExcepBytes
got 1st exception byte
Definition: trc_pkt_proc_ptm.h:167
TrcPktProcPtm::m_gotCycleCount
bool m_gotCycleCount
Definition: trc_pkt_proc_ptm.h:154
TrcPktProcPtm::PROC_HDR
Definition: trc_pkt_proc_ptm.h:78
TrcPktProcPtm::pktISync
void pktISync()
TrcPktProcPtm::InitProcessorState
void InitProcessorState()
ocsd_ptm_pkt_type
enum _ocsd_ptm_pkt_type ocsd_ptm_pkt_type
ocsd_trc_index_t
uint32_t ocsd_trc_index_t
Definition: ocsd_if_types.h:67
TrcPktProcPtm::isSync
const bool isSync() const
Definition: trc_pkt_proc_ptm.h:189
PtmConfig
Interpreter class for PTM Hardware configuration.
Definition: trc_cmp_cfg_ptm.h:62
TrcPktProcPtm::m_bAsyncRawOp
bool m_bAsyncRawOp
Definition: trc_pkt_proc_ptm.h:106
TrcPktProcPtm::waitASync
ocsd_datapath_resp_t waitASync()
look for first synchronisation point in the packet stream
TrcPktProcPtm::m_dataInProcessed
uint32_t m_dataInProcessed
Definition: trc_pkt_proc_ptm.h:99
TrcPktProcPtm::_pkt_i_table_t
Definition: trc_pkt_proc_ptm.h:180
TrcPktProcPtm::m_bOPNotSyncPkt
bool m_bOPNotSyncPkt
true if output not sync packet when waiting for ASYNC
Definition: trc_pkt_proc_ptm.h:107
TrcPktProcPtm::m_waitASyncSOPkt
bool m_waitASyncSOPkt
Definition: trc_pkt_proc_ptm.h:105
TrcPktProcPtm::InitPacketState
void InitPacketState()
TrcPktProcPtm::m_numAddrBytes
int m_numAddrBytes
number of address bytes
Definition: trc_pkt_proc_ptm.h:165
TrcPktProcPtm::pktWPointUpdate
void pktWPointUpdate()
TrcPktProcPtm::m_pIPktFn
PPKTFN m_pIPktFn
Definition: trc_pkt_proc_ptm.h:178
TrcPktProcPtm::m_block_idx
ocsd_trc_index_t m_block_idx
Definition: trc_pkt_proc_ptm.h:100
TrcPktProcPtm::pktBranchAddr
void pktBranchAddr()
PTM_PKT_BAD_SEQUENCE
invalid sequence for packet type
Definition: trc_pkt_types_ptm.h:69
TrcPktProcPtm::BuildIPacketTable
void BuildIPacketTable()
TrcPktProcPtm::extractCtxtID
void extractCtxtID(int idx, uint32_t &ctxtID)
TrcPktProcPtm::m_gotAddrBytes
bool m_gotAddrBytes
got all Addr bytes in branch packet
Definition: trc_pkt_proc_ptm.h:164
TrcPktProcPtm::throwPacketHeaderErr
void throwPacketHeaderErr(const char *pszErrMsg)
Definition: trc_pkt_proc_ptm.h:200
TrcPktProcPtm::outputPacket
ocsd_datapath_resp_t outputPacket()
trc_pkt_proc_base.h
OpenCSD : Trace packet processor base class.
TrcPktProcPtm::m_dataInLen
uint32_t m_dataInLen
Definition: trc_pkt_proc_ptm.h:98
TrcPktProcPtm::process_state
enum TrcPktProcPtm::_process_state process_state
TrcPktProcPtm::pktTrigger
void pktTrigger()
TrcPktProcPtm::NOT_ASYNC
pattern confirmed not async
Definition: trc_pkt_proc_ptm.h:126
TrcPktProcPtm::extractAddress
uint32_t extractAddress(const int offset, uint8_t &total_bits)
TrcPktProcBase
Packet Processor base class. Provides common infrastructure and interconnections for packet processor...
Definition: trc_pkt_proc_base.h:123
TrcPktProcPtm::m_gotExcepBytes
bool m_gotExcepBytes
got all needed exception bytes
Definition: trc_pkt_proc_ptm.h:166
ocsd_isa
enum _ocsd_isa ocsd_isa
ocsd_datapath_resp_t
enum _ocsd_datapath_resp_t ocsd_datapath_resp_t
TrcPktProcPtm::async_result_t
enum TrcPktProcPtm::_async_result async_result_t
TrcPktProcPtm::extractTS
int extractTS(uint64_t &tsVal, uint8_t &tsUpdateBits)
trc_pkt_elem_ptm.h
TrcPktProcPtm::onFlush
virtual ocsd_datapath_resp_t onFlush()
Implementation function for the OCSD_OP_FLUSH operation.
TrcPktProcPtm::pktASync
void pktASync()
TrcPktProcPtm::pktExceptionRet
void pktExceptionRet()
OCSD_ERR_SEV_ERROR
Definition: ocsd_if_types.h:168