OpenCSD - CoreSight Trace Decode Library 1.1.1
Loading...
Searching...
No Matches
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
44class PtmTrcPacket;
45class PtmConfig;
46
52class TrcPktProcPtm : public TrcPktProcBase< PtmTrcPacket, ocsd_ptm_pkt_type, PtmConfig>
53{
54public:
56 TrcPktProcPtm(int instIDNum);
57 virtual ~TrcPktProcPtm();
58
59protected:
60 /* implementation packet processing interface */
62 const uint32_t dataBlockSize,
63 const uint8_t *pDataBlock,
64 uint32_t *numBytesProcessed);
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 {
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();
114 void pktIgnore();
115 void pktCtxtID();
116 void pktVMID();
117 void pktAtom();
122
123 // async finder
124 typedef enum _async_result {
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
183 } m_i_table[256];
184
186
187};
188
189inline const bool TrcPktProcPtm::isSync() const
190{
191 return (bool)(m_curr_packet.getType() == PTM_PKT_NOTSYNC);
192}
193
194inline void TrcPktProcPtm::throwMalformedPacketErr(const char *pszErrMsg)
195{
198}
199
200inline void TrcPktProcPtm::throwPacketHeaderErr(const char *pszErrMsg)
201{
203}
204
205inline 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 */
Interpreter class for PTM Hardware configuration.
Packet Processor base class. Provides common infrastructure and interconnections for packet processor...
int m_numExcepBytes
got 1st exception byte
ocsd_datapath_resp_t waitASync()
look for first synchronisation point in the packet stream
bool m_bOPNotSyncPkt
true if output not sync packet when waiting for ASYNC
bool m_gotExcepBytes
got all needed exception bytes
int extractTS(uint64_t &tsVal, uint8_t &tsUpdateBits)
async_result_t findAsync()
virtual const bool isBadPacket() const
check if the current packet is an error / bad packet
std::vector< uint8_t > m_currPacketData
uint32_t m_currPktIdx
TrcPktProcPtm(int instIDNum)
void extractCtxtID(int idx, uint32_t &ctxtID)
@ ASYNC_INCOMPLETE
not enough input data.
@ ASYNC
pattern confirmed async 0x00 x 5, 0x80
@ ASYNC_EXTRA_0
pattern confirmed 0x00 x N + ASYNC
@ THROW_0
long pattern of 0x00 - throw some away.
@ NOT_ASYNC
pattern confirmed not async
int m_numAddrBytes
number of address bytes
ocsd_isa m_addrPktIsa
ISA of the branch address packet.
uint32_t extractAddress(const int offset, uint8_t &total_bits)
virtual ocsd_datapath_resp_t onEOT()
Implementation function for the OCSD_OP_EOT operation.
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.
int m_tsByteMax
max size for TS portion of TS packet.
void pktTimeStamp()
void extractCycleCount(int idx, uint32_t &cycleCount)
int m_excepAltISA
Alt ISA bit iff exception bytes.
void unReadByte()
virtual ocsd_datapath_resp_t onFlush()
Implementation function for the OCSD_OP_FLUSH operation.
bool m_gotTSBytes
got all TS bytes
const uint8_t * m_pDataIn
void pktExceptionRet()
void pktTrigger()
void BuildIPacketTable()
enum TrcPktProcPtm::_async_result async_result_t
void pktBranchAddr()
virtual ~TrcPktProcPtm()
void InitProcessorState()
bool m_gotAddrBytes
got all Addr bytes in branch packet
process_state m_process_state
void(TrcPktProcPtm::* PPKTFN)(void)
enum TrcPktProcPtm::_process_state process_state
virtual ocsd_datapath_resp_t onReset()
Implementation function for the OCSD_OP_RESET operation.
void pktIgnore()
ocsd_trc_index_t m_block_idx
ocsd_trc_index_t m_curr_pkt_index
void InitPacketState()
ocsd_datapath_resp_t outputPacket()
virtual ocsd_err_t onProtocolConfig()
Called when the configuration object is passed to the decoder.
struct TrcPktProcPtm::_pkt_i_table_t m_i_table[256]
void pktReserved()
void pktCtxtID()
uint32_t m_dataInProcessed
const bool readByte(uint8_t &currByte)
PtmTrcPacket m_curr_packet
void pktWPointUpdate()
uint32_t ocsd_trc_index_t
enum _ocsd_datapath_resp_t ocsd_datapath_resp_t
enum _ocsd_err_t ocsd_err_t
enum _ocsd_isa ocsd_isa
@ OCSD_ERR_BAD_PACKET_SEQ
@ OCSD_ERR_INVALID_PCKT_HDR
@ OCSD_ERR_SEV_ERROR
const bool isSync() const
void throwPacketHeaderErr(const char *pszErrMsg)
const bool readByte()
void throwMalformedPacketErr(const char *pszErrMsg)
const ocsd_ptm_pkt_type getType() const
enum _ocsd_ptm_pkt_type ocsd_ptm_pkt_type
void SetErrType(const ocsd_ptm_pkt_type e_type)
@ PTM_PKT_BAD_SEQUENCE
invalid sequence for packet type
@ PTM_PKT_NOTSYNC
no sync found yet
OpenCSD : Trace packet processor base class.