Loading...
Searching...
No Matches
trc_pkt_proc_etmv4i.h
Go to the documentation of this file.
/*
* \file trc_pkt_proc_etmv4i.h
* \brief OpenCSD : Implementation of ETMv4 packet processing
*
* \copyright Copyright (c) 2015, 2019 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_ETMV4I_IMPL_H_INCLUDED
#define ARM_TRC_PKT_PROC_ETMV4I_IMPL_H_INCLUDED
#include "trc_pkt_types_etmv4.h"
#include "opencsd/etmv4/trc_pkt_proc_etmv4.h"
#include "opencsd/etmv4/trc_cmp_cfg_etmv4.h"
#include "opencsd/etmv4/trc_pkt_elem_etmv4i.h"
#include "common/trc_raw_buffer.h"
#include "common/trc_pkt_proc_base.h"
class EtmV4ITrcPacket;
class EtmV4Config;
class TrcPktProcEtmV4I : public TrcPktProcBase< EtmV4ITrcPacket, ocsd_etmv4_i_pkt_type, EtmV4Config>
{
public:
TrcPktProcEtmV4I();
TrcPktProcEtmV4I(int instIDNum);
virtual ~TrcPktProcEtmV4I();
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;
protected:
typedef enum _process_state {
PROC_HDR,
PROC_DATA,
SEND_PKT,
SEND_UNSYNCED,
PROC_ERR,
} process_state;
process_state m_process_state;
void InitPacketState(); // clear current packet state.
void InitProcessorState(); // clear all previous process state
bool m_isInit;
// etmv4 hardware configuration
EtmV4Config m_config;
TraceRawBuffer m_trcIn; // trace data in buffer
std::vector<uint8_t> m_currPacketData; // raw data packet
int m_currPktIdx; // index into raw packet when expanding
EtmV4ITrcPacket m_curr_packet; // expanded packet
ocsd_trc_index_t m_packet_index; // index of the start of the current packet
ocsd_trc_index_t m_blockIndex; // index at the start of the current data block being processed
// searching for sync
bool m_is_sync;
bool m_first_trace_info;
bool m_sent_notsync_packet;
unsigned m_dump_unsynced_bytes;
ocsd_trc_index_t m_update_on_unsync_packet_index;
private:
// current processing state data - counts and flags to determine if a packet is complete.
// TraceInfo Packet
// flags to indicate processing progress for these sections is complete.
struct _t_info_pkt_prog {
uint8_t sectFlags;
uint8_t ctrlBytes;
} m_tinfo_sections;
#define TINFO_INFO_SECT 0x01
#define TINFO_KEY_SECT 0x02
#define TINFO_SPEC_SECT 0x04
#define TINFO_CYCT_SECT 0x08
#define TINFO_WNDW_SECT 0x10
#define TINFO_CTRL 0x20
#define TINFO_ALL_SECT 0x1F
#define TINFO_ALL 0x3F
// address and context packets
int m_addrBytes;
uint8_t m_addrIS;
bool m_bAddr64bit;
int m_vmidBytes; // bytes still to find
int m_ctxtidBytes; // bytes still to find
bool m_bCtxtInfoDone;
bool m_addr_done;
// timestamp
bool m_ccount_done; // done or not needed
bool m_ts_done;
int m_ts_bytes;
// exception
int m_excep_size;
// cycle count
bool m_has_count;
bool m_count_done;
bool m_commit_done;
// cond result
bool m_F1P1_done; // F1 payload 1 done
bool m_F1P2_done; // F1 payload 2 done
bool m_F1has_P2; // F1 has a payload 2
// Q packets (use some from above too)
bool m_has_addr;
bool m_addr_short;
bool m_addr_match;
uint8_t m_Q_type;
uint8_t m_QE;
ocsd_datapath_resp_t outputPacket();
ocsd_datapath_resp_t outputUnsyncedRawPacket();
void iNotSync(const uint8_t lastByte); // not synced yet
void iPktNoPayload(const uint8_t lastByte); // process a single byte packet
void iPktReserved(const uint8_t lastByte); // deal with reserved header value
void iPktExtension(const uint8_t lastByte);
void iPktASync(const uint8_t lastByte);
void iPktTraceInfo(const uint8_t lastByte);
void iPktTimestamp(const uint8_t lastByte);
void iPktException(const uint8_t lastByte);
void iPktCycleCntF123(const uint8_t lastByte);
void iPktSpeclRes(const uint8_t lastByte);
void iPktCondInstr(const uint8_t lastByte);
void iPktCondResult(const uint8_t lastByte);
void iPktContext(const uint8_t lastByte);
void iPktAddrCtxt(const uint8_t lastByte);
void iPktShortAddr(const uint8_t lastByte);
void iPktLongAddr(const uint8_t lastByte);
void iPktQ(const uint8_t lastByte);
void iAtom(const uint8_t lastByte);
void iPktInvalidCfg(const uint8_t lastByte); // packet invalid in current config.
void iPktITE(const uint8_t lastByte);
unsigned extractContField(const std::vector<uint8_t> &buffer, const unsigned st_idx, uint32_t &value, const unsigned byte_limit = 5);
unsigned extractTSField64(const std::vector<uint8_t> &buffer, const unsigned st_idx, uint64_t &value);
unsigned extractCondResult(const std::vector<uint8_t> &buffer, const unsigned st_idx, uint32_t& key, uint8_t &result);
void extractAndSetContextInfo(const std::vector<uint8_t> &buffer, const int st_idx);
int extract64BitLongAddr(const std::vector<uint8_t> &buffer, const int st_idx, const uint8_t IS, uint64_t &value);
int extract32BitLongAddr(const std::vector<uint8_t> &buffer, const int st_idx, const uint8_t IS, uint32_t &value);
int extractShortAddr(const std::vector<uint8_t> &buffer, const int st_idx, const uint8_t IS, uint32_t &value, int &bits);
// packet processing is table driven.
typedef void (TrcPktProcEtmV4I::*PPKTFN)(uint8_t);
PPKTFN m_pIPktFn;
struct _pkt_i_table_t {
ocsd_etmv4_i_pkt_type pkt_type;
PPKTFN pptkFn;
} m_i_table[256];
void BuildIPacketTable();
void throwBadSequenceError(const char *pszExtMsg);
};
inline const bool TrcPktProcEtmV4I::isBadPacket() const
{
return m_curr_packet.isBadPacket();
}
#endif // ARM_TRC_PKT_PROC_ETMV4I_IMPL_H_INCLUDED
/* End of File trc_pkt_proc_etmv4i_impl.h */
EtmV4Config
Interpreter class for etm v4 config structure.
Definition trc_cmp_cfg_etmv4.h:57
EtmV4ITrcPacket
ETMv4 Instuction Trace Protocol Packet.
Definition trc_pkt_elem_etmv4i.h:111
TraceRawBuffer
Definition trc_raw_buffer.h:41
TrcPktProcBase
Packet Processor base class. Provides common infrastructure and interconnections for packet processor...
Definition trc_pkt_proc_base.h:127
TrcPktProcEtmV4I
Definition trc_pkt_proc_etmv4i.h:52
TrcPktProcEtmV4I::m_dump_unsynced_bytes
unsigned m_dump_unsynced_bytes
number of unsynced bytes to send
Definition trc_pkt_proc_etmv4i.h:102
TrcPktProcEtmV4I::m_process_state
process_state m_process_state
Definition trc_pkt_proc_etmv4i.h:79
TrcPktProcEtmV4I::~TrcPktProcEtmV4I
virtual ~TrcPktProcEtmV4I()
TrcPktProcEtmV4I::m_first_trace_info
bool m_first_trace_info
seen first trace info packet after sync
Definition trc_pkt_proc_etmv4i.h:100
TrcPktProcEtmV4I::TrcPktProcEtmV4I
TrcPktProcEtmV4I()
TrcPktProcEtmV4I::m_sent_notsync_packet
bool m_sent_notsync_packet
send one not sync packet if we see any unsynced data on the channel
Definition trc_pkt_proc_etmv4i.h:101
TrcPktProcEtmV4I::_process_state
_process_state
Definition trc_pkt_proc_etmv4i.h:71
TrcPktProcEtmV4I::PROC_HDR
@ PROC_HDR
Definition trc_pkt_proc_etmv4i.h:72
TrcPktProcEtmV4I::PROC_ERR
@ PROC_ERR
Definition trc_pkt_proc_etmv4i.h:76
TrcPktProcEtmV4I::SEND_PKT
@ SEND_PKT
Definition trc_pkt_proc_etmv4i.h:74
TrcPktProcEtmV4I::SEND_UNSYNCED
@ SEND_UNSYNCED
Definition trc_pkt_proc_etmv4i.h:75
TrcPktProcEtmV4I::PROC_DATA
@ PROC_DATA
Definition trc_pkt_proc_etmv4i.h:73
TrcPktProcEtmV4I::InitProcessorState
void InitProcessorState()
TrcPktProcEtmV4I::m_config
EtmV4Config m_config
Definition trc_pkt_proc_etmv4i.h:88
TrcPktProcEtmV4I::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.
TrcPktProcEtmV4I::InitPacketState
void InitPacketState()
TrcPktProcEtmV4I::onFlush
virtual ocsd_datapath_resp_t onFlush()
Implementation function for the OCSD_OP_FLUSH operation.
TrcPktProcEtmV4I::m_currPktIdx
int m_currPktIdx
Definition trc_pkt_proc_etmv4i.h:93
TrcPktProcEtmV4I::m_update_on_unsync_packet_index
ocsd_trc_index_t m_update_on_unsync_packet_index
Definition trc_pkt_proc_etmv4i.h:103
TrcPktProcEtmV4I::m_curr_packet
EtmV4ITrcPacket m_curr_packet
Definition trc_pkt_proc_etmv4i.h:94
TrcPktProcEtmV4I::m_isInit
bool m_isInit
Definition trc_pkt_proc_etmv4i.h:85
TrcPktProcEtmV4I::onReset
virtual ocsd_datapath_resp_t onReset()
Implementation function for the OCSD_OP_RESET operation.
TrcPktProcEtmV4I::m_packet_index
ocsd_trc_index_t m_packet_index
Definition trc_pkt_proc_etmv4i.h:95
TrcPktProcEtmV4I::process_state
enum TrcPktProcEtmV4I::_process_state process_state
TrcPktProcEtmV4I::m_is_sync
bool m_is_sync
seen first sync packet
Definition trc_pkt_proc_etmv4i.h:99
TrcPktProcEtmV4I::m_trcIn
TraceRawBuffer m_trcIn
Definition trc_pkt_proc_etmv4i.h:91
TrcPktProcEtmV4I::onEOT
virtual ocsd_datapath_resp_t onEOT()
Implementation function for the OCSD_OP_EOT operation.
TrcPktProcEtmV4I::TrcPktProcEtmV4I
TrcPktProcEtmV4I(int instIDNum)
TrcPktProcEtmV4I::m_currPacketData
std::vector< uint8_t > m_currPacketData
Definition trc_pkt_proc_etmv4i.h:92
TrcPktProcEtmV4I::onProtocolConfig
virtual ocsd_err_t onProtocolConfig()
Called when the configuration object is passed to the decoder.
TrcPktProcEtmV4I::m_blockIndex
ocsd_trc_index_t m_blockIndex
Definition trc_pkt_proc_etmv4i.h:96
ocsd_trc_index_t
uint32_t ocsd_trc_index_t
Definition ocsd_if_types.h:67
ocsd_datapath_resp_t
enum _ocsd_datapath_resp_t ocsd_datapath_resp_t
ocsd_err_t
enum _ocsd_err_t ocsd_err_t
TrcPktProcEtmV4I::isBadPacket
virtual const bool isBadPacket() const
check if the current packet is an error / bad packet
Definition trc_pkt_proc_etmv4i.h:207
EtmV4ITrcPacket::isBadPacket
const bool isBadPacket() const
Definition trc_pkt_elem_etmv4i.h:532
ocsd_etmv4_i_pkt_type
enum _ocsd_etmv4_i_pkt_type ocsd_etmv4_i_pkt_type
trc_cmp_cfg_etmv4.h
trc_pkt_elem_etmv4i.h
trc_pkt_proc_base.h
OpenCSD : Trace packet processor base class.
trc_pkt_proc_etmv4.h
trc_pkt_types_etmv4.h
trc_raw_buffer.h