]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/opencsd/decoder/include/opencsd/stm/trc_pkt_decode_stm.h
Re-add opencsd as a vendor import from the dist directory
[FreeBSD/FreeBSD.git] / contrib / opencsd / decoder / include / opencsd / stm / trc_pkt_decode_stm.h
1 /*
2  * \file       trc_pkt_decode_stm.h
3  * \brief      OpenCSD : STM packet decoder 
4  *
5  *  Convert the incoming indidvidual STM packets to 
6  * 
7  * \copyright  Copyright (c) 2016, ARM Limited. All Rights Reserved.
8  */
9
10
11 /* 
12  * Redistribution and use in source and binary forms, with or without modification, 
13  * are permitted provided that the following conditions are met:
14  * 
15  * 1. Redistributions of source code must retain the above copyright notice, 
16  * this list of conditions and the following disclaimer.
17  * 
18  * 2. Redistributions in binary form must reproduce the above copyright notice, 
19  * this list of conditions and the following disclaimer in the documentation 
20  * and/or other materials provided with the distribution. 
21  * 
22  * 3. Neither the name of the copyright holder nor the names of its contributors 
23  * may be used to endorse or promote products derived from this software without 
24  * specific prior written permission. 
25  * 
26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND 
27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
28  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
29  * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
30  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
31  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
32  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 
33  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
35  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
36  */ 
37
38
39 #ifndef ARM_TRC_PKT_DECODE_STM_H_INCLUDED
40 #define ARM_TRC_PKT_DECODE_STM_H_INCLUDED
41
42
43 #include "common/trc_pkt_decode_base.h"
44 #include "opencsd/stm/trc_pkt_elem_stm.h"
45 #include "opencsd/stm/trc_cmp_cfg_stm.h"
46 #include "common/trc_gen_elem.h"
47
48 class TrcPktDecodeStm : public TrcPktDecodeBase<StmTrcPacket, STMConfig>
49 {
50 public:
51     TrcPktDecodeStm();
52     TrcPktDecodeStm(int instIDNum);
53     virtual ~TrcPktDecodeStm();
54     
55 protected:
56     /* implementation packet decoding interface */
57     virtual ocsd_datapath_resp_t processPacket();
58     virtual ocsd_datapath_resp_t onEOT();
59     virtual ocsd_datapath_resp_t onReset();
60     virtual ocsd_datapath_resp_t onFlush();
61     virtual ocsd_err_t onProtocolConfig();
62     virtual const uint8_t getCoreSightTraceID() { return m_CSID; };
63
64     /* local decode methods */
65
66 private:
67     void initDecoder();
68     void resetDecoder();
69     void initPayloadBuffer();
70     bool isInit() { return (bool)((m_config != 0) && (m_payload_buffer != 0)); };
71     ocsd_datapath_resp_t decodePacket(bool &bPktDone);  //!< decode the current incoming packet
72     void clearSWTPerPcktInfo();
73     void updatePayload(bool &bSendPacket);
74
75     typedef enum {
76         NO_SYNC,        //!< pre start trace - init state or after reset or overflow, loss of sync.
77         WAIT_SYNC,      //!< waiting for sync packet.
78         DECODE_PKTS     //!< processing input packet.  
79     } processor_state_t;
80
81     processor_state_t m_curr_state;  
82
83     ocsd_swt_info_t m_swt_packet_info;
84
85     uint8_t *m_payload_buffer;  //!< payload buffer - allocated for one or multiple packets according to config
86     int m_payload_size;         //!< payload buffer total size in bytes.
87     int m_payload_used;         //!< payload buffer used in bytes - current payload size.
88     bool m_payload_odd_nibble;  //!< last used byte in payload contains a single 4 bit packet.
89     int m_num_pkt_correlation;  //!< number of identical payload packets to buffer up before output. - fixed at 1 till later update
90
91     uint8_t m_CSID;             //!< Coresight trace ID for this decoder.
92
93     bool m_decode_pass1;        //!< flag to indicate 1st pass of packet decode.
94
95
96
97 //** output element
98     OcsdTraceElement m_output_elem; //!< output packet
99 };
100
101 #endif // ARM_TRC_PKT_DECODE_STM_H_INCLUDED
102
103 /* End of File trc_pkt_decode_stm.h */