1 /*!
2  * \file       ocsd_c_api_types.h
3  * \brief      OpenCSD : Trace Decoder "C" API 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_OCSD_C_API_TYPES_H_INCLUDED
36 #define ARM_OCSD_C_API_TYPES_H_INCLUDED
37 
38 /* select the library types that are C compatible - the interface data types */
39 #include "opencsd/ocsd_if_types.h"
40 #include "opencsd/trc_gen_elem_types.h"
41 #include "opencsd/trc_pkt_types.h"
42 
43 /* pull in the protocol decoder types. */
44 #include "opencsd/etmv3/trc_pkt_types_etmv3.h"
45 #include "opencsd/etmv4/trc_pkt_types_etmv4.h"
46 #include "opencsd/ptm/trc_pkt_types_ptm.h"
47 #include "opencsd/stm/trc_pkt_types_stm.h"
48 
49 /** @ingroup lib_c_api
50 @{*/
51 
52 
53 /* Specific C-API only types */
54 
55 /** Handle to decode tree */
56 typedef void * dcd_tree_handle_t;
57 
58 /** define invalid handle value for decode tree handle */
59 #define C_API_INVALID_TREE_HANDLE (dcd_tree_handle_t)0
60 
61 /** Logger output printer - no output. */
62 #define C_API_MSGLOGOUT_FLG_NONE   0x0
63 /** Logger output printer - output to file. */
64 #define C_API_MSGLOGOUT_FLG_FILE   0x1
65 /** Logger output printer - output to stderr. */
66 #define C_API_MSGLOGOUT_FLG_STDERR 0x2
67 /** Logger output printer - output to stdout. */
68 #define C_API_MSGLOGOUT_FLG_STDOUT 0x4
69 /** Logger output printer - mask of valid flags. */
70 #define C_API_MSGLOGOUT_MASK       0x7
71 
72 /** function pointer type for decoder outputs. all protocols, generic data element input */
73 typedef ocsd_datapath_resp_t (* FnTraceElemIn)( const void *p_context,
74                                                 const ocsd_trc_index_t index_sop,
75                                                 const uint8_t trc_chan_id,
76                                                 const ocsd_generic_trace_elem *elem);
77 
78 /** function pointer type for packet processor packet output sink, packet analyser/decoder input - generic declaration */
79 typedef ocsd_datapath_resp_t (* FnDefPktDataIn)(const void *p_context,
80                                                 const ocsd_datapath_op_t op,
81                                                 const ocsd_trc_index_t index_sop,
82                                                 const void *p_packet_in);
83 
84 /** function pointer type for packet processor packet monitor sink, raw packet monitor / display input - generic declaration */
85 typedef void (* FnDefPktDataMon)(const void *p_context,
86                                                  const ocsd_datapath_op_t op,
87                                                  const ocsd_trc_index_t index_sop,
88                                                  const void *p_packet_in,
89                                                  const uint32_t size,
90                                                  const uint8_t *p_data);
91 
92 /** function pointer tyee for library default logger output to allow client to print zero terminated output string */
93 typedef void (* FnDefLoggerPrintStrCB)(const void *p_context, const char *psz_msg_str, const int str_len);
94 
95 /** Callback interface type when attaching monitor/sink to packet processor */
96 typedef enum _ocsd_c_api_cb_types {
97     OCSD_C_API_CB_PKT_SINK, /** Attach to the packet processor primary packet output (CB fn is FnDefPktDataIn) */
98     OCSD_C_API_CB_PKT_MON,  /** Attach to the packet processor packet monitor output (CB fn is FnDefPktDataMon) */
99 } ocsd_c_api_cb_types;
100 
101 /** @}*/
102 
103 #endif // ARM_OCSD_C_API_TYPES_H_INCLUDED
104 
105 /* End of File ocsd_c_api_types.h */
106