OpenCSD - CoreSight Trace Decode Library  0.14.0
trc_pkt_proc_ptm.h
Go to the documentation of this file.
1 /*
2  * \file trc_pkt_proc_ptm.h
3  * \brief OpenCSD :
4  *
5  * \copyright Copyright (c) 2015, ARM Limited. All Rights Reserved.
6  */
7 
8 
9 /*
10  * Redistribution and use in source and binary forms, with or without modification,
11  * are permitted provided that the following conditions are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright notice,
14  * this list of conditions and the following disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above copyright notice,
17  * this list of conditions and the following disclaimer in the documentation
18  * and/or other materials provided with the distribution.
19  *
20  * 3. Neither the name of the copyright holder nor the names of its contributors
21  * may be used to endorse or promote products derived from this software without
22  * specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27  * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
28  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 #ifndef ARM_TRC_PKT_PROC_PTM_H_INCLUDED
37 #define ARM_TRC_PKT_PROC_PTM_H_INCLUDED
38 
39 #include "trc_pkt_types_ptm.h"
41 #include "trc_pkt_elem_ptm.h"
42 #include "trc_cmp_cfg_ptm.h"
43 
44 class PtmTrcPacket;
45 class PtmConfig;
46 
52 class TrcPktProcPtm : public TrcPktProcBase< PtmTrcPacket, ocsd_ptm_pkt_type, PtmConfig>
53 {
54 public:
55  TrcPktProcPtm();
56  TrcPktProcPtm(int instIDNum);
57  virtual ~TrcPktProcPtm();
58 
59 protected:
60  /* implementation packet processing interface */
62  const uint32_t dataBlockSize,
63  const uint8_t *pDataBlock,
64  uint32_t *numBytesProcessed);
65  virtual ocsd_datapath_resp_t onEOT();
66  virtual ocsd_datapath_resp_t onReset();
67  virtual ocsd_datapath_resp_t onFlush();
68  virtual ocsd_err_t onProtocolConfig();
69  virtual const bool isBadPacket() const;
70 
71  void InitPacketState(); // clear current packet state.
72  void InitProcessorState(); // clear all previous process state
73 
75 
76  typedef enum _process_state {
81  } process_state;
82 
83  process_state m_process_state; // process algorithm state.
84 
85  std::vector<uint8_t> m_currPacketData; // raw data
86  uint32_t m_currPktIdx; // index into packet when expanding
87  PtmTrcPacket m_curr_packet; // expanded packet
88  ocsd_trc_index_t m_curr_pkt_index; // trace index at start of packet.
89 
90  const bool readByte(uint8_t &currByte);
91  const bool readByte(); // just read into buffer, don't need the value
92  void unReadByte(); // remove last byte from the buffer.
93 
94  uint8_t m_chanIDCopy;
95 
96  // current data block being processed.
97  const uint8_t *m_pDataIn;
98  uint32_t m_dataInLen;
100  ocsd_trc_index_t m_block_idx; // index start for current block
101 
102  // processor synchronisation
103  const bool isSync() const;
108 
109  // ** packet processing functions.
110  void pktASync();
111  void pktISync();
112  void pktTrigger();
113  void pktWPointUpdate();
114  void pktIgnore();
115  void pktCtxtID();
116  void pktVMID();
117  void pktAtom();
118  void pktTimeStamp();
119  void pktExceptionRet();
120  void pktBranchAddr();
121  void pktReserved();
122 
123  // async finder
124  typedef enum _async_result {
130  } async_result_t;
131 
133 
134  int m_async_0; // number of current consecutive async 0s
135 
137 
138  // number of extra 0s before we throw 0 on async detect.
139  #define ASYNC_PAD_0_LIMIT 11
140  // number of 0s minimum to form an async
141  #define ASYNC_REQ_0 5
142 
143  // extraction sub-routines
144  void extractCtxtID(int idx, uint32_t &ctxtID);
145  void extractCycleCount(int idx, uint32_t &cycleCount);
146  int extractTS(uint64_t &tsVal, uint8_t &tsUpdateBits);
147  uint32_t extractAddress(const int offset,uint8_t &total_bits);
148 
149  // number of bytes required for a complete packet - used in some multi byte packets
151 
152  // packet processing state
155  int m_gotCCBytes; // number of CC bytes read so far
156 
159 
162 
163  // branch address state
170 
171  // bad packets
172  void throwMalformedPacketErr(const char *pszErrMsg);
173  void throwPacketHeaderErr(const char *pszErrMsg);
174 
175 
176  // packet processing function table
177  typedef void (TrcPktProcPtm::*PPKTFN)(void);
179 
180  struct _pkt_i_table_t {
183  } m_i_table[256];
184 
185  void BuildIPacketTable();
186 
187 };
188 
189 inline const bool TrcPktProcPtm::isSync() const
190 {
191  return (bool)(m_curr_packet.getType() == PTM_PKT_NOTSYNC);
192 }
193 
194 inline void TrcPktProcPtm::throwMalformedPacketErr(const char *pszErrMsg)
195 {
198 }
199 
200 inline void TrcPktProcPtm::throwPacketHeaderErr(const char *pszErrMsg)
201 {
203 }
204 
205 inline const bool TrcPktProcPtm::readByte()
206 {
207  uint8_t currByte;
208  return readByte(currByte);
209 }
210 
213 #endif // ARM_TRC_PKT_PROC_PTM_H_INCLUDED
214 
215 /* 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
@ 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
ocsd_datapath_resp_t
enum _ocsd_datapath_resp_t ocsd_datapath_resp_t
TrcPktProcPtm::process_state
enum TrcPktProcPtm::_process_state process_state
TrcPktProcPtm::WAIT_SYNC
@ 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
@ 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
@ ASYNC
pattern confirmed async 0x00 x 5, 0x80
Definition: trc_pkt_proc_ptm.h:125
TrcPktProcPtm::m_i_table
struct TrcPktProcPtm::_pkt_i_table_t m_i_table[256]
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
@ 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
@ SEND_PKT
Definition: trc_pkt_proc_ptm.h:80
OCSD_ERR_INVALID_PCKT_HDR
@ OCSD_ERR_INVALID_PCKT_HDR
Definition: ocsd_if_types.h:113
TrcPktProcPtm::async_result_t
enum TrcPktProcPtm::_async_result async_result_t
TrcPktProcPtm::pktIgnore
void pktIgnore()
TrcPktProcPtm::PROC_DATA
@ 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
@ 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_t
enum _ocsd_err_t ocsd_err_t
OCSD_ERR_BAD_PACKET_SEQ
@ 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
ocsd_ptm_pkt_type
enum _ocsd_ptm_pkt_type ocsd_ptm_pkt_type
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
@ PROC_HDR
Definition: trc_pkt_proc_ptm.h:78
TrcPktProcPtm::pktISync
void pktISync()
TrcPktProcPtm::InitProcessorState
void InitProcessorState()
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
@ 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::pktTrigger
void pktTrigger()
TrcPktProcPtm::NOT_ASYNC
@ 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
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_isa
enum _ocsd_isa ocsd_isa
OCSD_ERR_SEV_ERROR
@ OCSD_ERR_SEV_ERROR
Definition: ocsd_if_types.h:168