1 /*
2  * \file       trc_pkt_ptm_types.h
3  * \brief      OpenCSD : PTM specific types
4  *
5  * \copyright  Copyright (c) 2015, ARM Limited. All Rights Reserved.
6  */
7 
8 /*
9  * Redistribution and use in source and binary forms, with or without modification,
10  * are permitted provided that the following conditions are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  *
19  * 3. Neither the name of the copyright holder nor the names of its contributors
20  * may be used to endorse or promote products derived from this software without
21  * specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26  * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 #ifndef ARM_TRC_PKT_PTM_TYPES_H_INCLUDED
36 #define ARM_TRC_PKT_PTM_TYPES_H_INCLUDED
37 
38 #include "opencsd/trc_pkt_types.h"
39 
40 /** @addtogroup trc_pkts
41 @{*/
42 
43 /** @name PTM Packet Types
44 @{*/
45 
46 typedef enum _ocsd_ptm_pkt_type
47 {
48 // markers for unknown packets
49 	PTM_PKT_NOTSYNC,        //!< no sync found yet
50     PTM_PKT_INCOMPLETE_EOT, //!< flushing incomplete packet at end of trace.
51     PTM_PKT_NOERROR,        //!< no error base type packet.
52 
53 // markers for valid packets
54     PTM_PKT_BRANCH_ADDRESS, //!< Branch address with optional exception.
55     PTM_PKT_A_SYNC,			//!< Alignment Synchronisation.
56 	PTM_PKT_I_SYNC,			//!< Instruction sync with address.
57 	PTM_PKT_TRIGGER,		//!< trigger packet
58 	PTM_PKT_WPOINT_UPDATE,  //!< Waypoint update.
59 	PTM_PKT_IGNORE,			//!< ignore packet.
60 	PTM_PKT_CONTEXT_ID,		//!< context id packet.
61     PTM_PKT_VMID,           //!< VMID packet
62 	PTM_PKT_ATOM,			//!< atom waypoint packet.
63 	PTM_PKT_TIMESTAMP,		//!< timestamp packet.
64 	PTM_PKT_EXCEPTION_RET,	//!< exception return.
65 	PTM_PKT_BRANCH_OR_BYPASS_EOT, // interpreter FSM 'state' : unsure if branch 0 packet or bypass flush end of trace
66     PTM_PKT_TPIU_PAD_EOB,   // pad end of a buffer - no valid trace at this point
67 
68 // markers for bad packets
69    	PTM_PKT_BAD_SEQUENCE,   //!< invalid sequence for packet type
70 	PTM_PKT_RESERVED,		//!< Reserved packet encoding
71 
72 } ocsd_ptm_pkt_type;
73 
74 typedef struct _ptm_context_t {
75     struct {
76         uint32_t curr_alt_isa:1;     /**< current Alt ISA flag for Tee / T32 (used if not in present packet) */
77         uint32_t curr_NS:1;          /**< current NS flag  (used if not in present packet) */
78         uint32_t curr_Hyp:1;         /**< current Hyp flag  (used if not in present packet) */
79         uint32_t updated:1;          /**< context updated */
80         uint32_t updated_c:1;        /**< updated CtxtID */
81         uint32_t updated_v:1;        /**< updated VMID */
82     };
83     uint32_t ctxtID;    /**< Context ID */
84     uint8_t VMID;       /**< VMID */
85 } ptm_context_t;
86 
87 typedef struct _ocsd_ptm_excep {
88     ocsd_armv7_exception type; /**<  exception type. */
89     uint16_t number;    /**< exception as number */
90     struct {
91         uint32_t present:1;      /**< exception present in packet */
92     } bits;
93 } ocsd_ptm_excep;
94 
95 
96 typedef struct _ocsd_ptm_pkt
97 {
98     ocsd_ptm_pkt_type type;        /**< Primary packet type. */
99 
100     ocsd_isa curr_isa;         /**< current ISA. */
101     ocsd_isa prev_isa;         /**< previous ISA */
102 
103     ocsd_pkt_vaddr addr;       /**< current address. */
104     ptm_context_t   context;    /**< current context. */
105     ocsd_pkt_atom  atom;
106 
107     ocsd_iSync_reason i_sync_reason;   /**< reason for ISync Packet. */
108 
109     uint32_t cycle_count;       /**< cycle count value associated with this packet. */
110     uint8_t cc_valid;           /**< cycle count value valid. */
111 
112     uint64_t timestamp;         /**< timestamp value. */
113     uint8_t ts_update_bits;     /**< bits of ts updated this packet. (if TS packet) */
114 
115     ocsd_ptm_excep exception;  /**< exception information in packet */
116 
117     ocsd_ptm_pkt_type err_type;    /**< Basic packet type if primary type indicates error or incomplete. */
118 
119 } ocsd_ptm_pkt;
120 
121 typedef struct _ocsd_ptm_cfg
122 {
123     uint32_t                reg_idr;    /**< PTM ID register */
124     uint32_t                reg_ctrl;   /**< Control Register */
125     uint32_t                reg_ccer;   /**< Condition code extension register */
126     uint32_t                reg_trc_id; /**< CoreSight Trace ID register */
127     ocsd_arch_version_t    arch_ver;   /**< Architecture version */
128     ocsd_core_profile_t    core_prof;  /**< Core Profile */
129 } ocsd_ptm_cfg;
130 
131 /** @}*/
132 
133 
134 /** @}*/
135 #endif // ARM_TRC_PKT_PTM_TYPES_H_INCLUDED
136 
137 /* End of File trc_pkt_ptm_types.h */
138