OpenCSD - CoreSight Trace Decode Library  1.3.3
ocsd_c_api_cust_impl.h
Go to the documentation of this file.
1 /*
2 * \file ocsd_c_api_cust_impl.h
3 * \brief OpenCSD : Custom decoder implementation common API definitions
4 *
5 * \copyright Copyright (c) 2016, 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 #ifndef ARM_OCSD_C_API_CUST_IMPL_H_INCLUDED
35 #define ARM_OCSD_C_API_CUST_IMPL_H_INCLUDED
36 
39 
51 static inline ocsd_datapath_resp_t lib_cb_GenElemOp(const ocsd_extern_dcd_cb_fns *callbacks,
52  const ocsd_trc_index_t index_sop,
53  const uint8_t trc_chan_id,
54  const ocsd_generic_trace_elem *elem)
55 {
56  if (callbacks->fn_gen_elem_out)
57  return callbacks->fn_gen_elem_out(callbacks->lib_context, index_sop, trc_chan_id, elem);
59 }
60 
61 static inline ocsd_err_t lib_cb_LogError(const ocsd_extern_dcd_cb_fns *callbacks,
62  const ocsd_err_severity_t filter_level,
63  const ocsd_err_t code,
64  const ocsd_trc_index_t idx,
65  const uint8_t chan_id,
66  const char *pMsg)
67 {
68  if (callbacks->fn_log_error)
69  {
70  callbacks->fn_log_error(callbacks->lib_context, filter_level, code, idx, chan_id, pMsg);
71  return OCSD_OK;
72  }
73  return OCSD_ERR_NOT_INIT;
74 }
75 
76 static inline ocsd_err_t lib_cb_LogMsg(const ocsd_extern_dcd_cb_fns *callbacks,
77  const ocsd_err_severity_t filter_level,
78  const char *pMsg)
79 {
80  if (callbacks->fn_log_msg)
81  {
82  callbacks->fn_log_msg(callbacks->lib_context, filter_level, pMsg);
83  return OCSD_OK;
84  }
85  return OCSD_ERR_NOT_INIT;
86 }
87 
88 static inline ocsd_err_t lib_cb_DecodeArmInst(const ocsd_extern_dcd_cb_fns *callbacks,
89  ocsd_instr_info *instr_info)
90 {
91  if (callbacks->fn_arm_instruction_decode)
92  return callbacks->fn_arm_instruction_decode(callbacks->lib_context, instr_info);
93  return OCSD_ERR_NOT_INIT;
94 }
95 
96 static inline ocsd_err_t lib_cb_MemAccess(const ocsd_extern_dcd_cb_fns *callbacks,
97  const ocsd_vaddr_t address,
98  const uint8_t cs_trace_id,
99  const ocsd_mem_space_acc_t mem_space,
100  uint32_t *num_bytes,
101  uint8_t *p_buffer)
102 {
103  if (callbacks->fn_memory_access)
104  return callbacks->fn_memory_access(callbacks->lib_context, address, cs_trace_id, mem_space, num_bytes, p_buffer);
105  return OCSD_ERR_NOT_INIT;
106 }
107 
108 static inline void lib_cb_PktMon(const ocsd_extern_dcd_cb_fns *callbacks,
109  const ocsd_datapath_op_t op,
110  const ocsd_trc_index_t index_sop,
111  const void *pkt,
112  const uint32_t size,
113  const uint8_t *p_data)
114 {
116  {
117  if (callbacks->fn_packet_mon)
118  callbacks->fn_packet_mon(callbacks->lib_context, op, index_sop, pkt, size, p_data);
119  }
120 }
121 
122 static inline int lib_cb_usePktMon(const ocsd_extern_dcd_cb_fns *callbacks)
123 {
124  return (callbacks->packetCBFlags & OCSD_CUST_DCD_PKT_CB_USE_MON);
125 }
126 
127 /* callback function to connect to the packet sink interface, on the main decode
128 data path - used if decoder created as packet processor only */
129 static inline ocsd_datapath_resp_t lib_cb_PktDataSink(const ocsd_extern_dcd_cb_fns *callbacks,
130  const ocsd_datapath_op_t op,
131  const ocsd_trc_index_t index_sop,
132  const void *pkt)
133 {
135  {
136  if (callbacks->fn_packet_data_sink)
137  return callbacks->fn_packet_data_sink(callbacks->lib_context, op, index_sop, pkt);
138  else
140  }
141  return OCSD_RESP_CONT;
142 }
143 
144 static inline int lib_cb_usePktSink(const ocsd_extern_dcd_cb_fns *callbacks)
145 {
146  return (callbacks->packetCBFlags & OCSD_CUST_DCD_PKT_CB_USE_SINK);
147 }
148 
149 static inline void lib_cb_updatePktCBFlags(ocsd_extern_dcd_cb_fns *callbacks, const int newFlags)
150 {
151  callbacks->packetCBFlags = newFlags;
152 }
153 
158 #endif /* ARM_OCSD_C_API_CUST_IMPL_H_INCLUDED */
#define OCSD_CUST_DCD_PKT_CB_USE_SINK
#define OCSD_CUST_DCD_PKT_CB_USE_MON
uint32_t ocsd_trc_index_t
Definition: ocsd_if_types.h:67
enum _ocsd_datapath_resp_t ocsd_datapath_resp_t
enum _ocsd_mem_space_acc_t ocsd_mem_space_acc_t
enum _ocsd_datapath_op_t ocsd_datapath_op_t
enum _ocsd_err_severity_t ocsd_err_severity_t
enum _ocsd_err_t ocsd_err_t
uint64_t ocsd_vaddr_t
@ OCSD_OK
Definition: ocsd_if_types.h:88
@ OCSD_ERR_NOT_INIT
Definition: ocsd_if_types.h:91
@ OCSD_RESP_CONT
@ OCSD_RESP_FATAL_NOT_INIT
OpenCSD : Trace Decoder "C" API types.
fnDecodeArmInstCB fn_arm_instruction_decode
fnPktDataSinkCB fn_packet_data_sink