opencsd_c_api.h
Go to the documentation of this file.
/*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ARM_OPENCSD_C_API_H_INCLUDED
#define ARM_OPENCSD_C_API_H_INCLUDED
/* ensure C bindings */
#if defined(WIN32) /* windows bindings */
#ifdef _OCSD_C_API_DLL_EXPORT
#ifdef __cplusplus
#define OCSD_C_API extern "C" __declspec(dllexport)
#else
#define OCSD_C_API __declspec(dllexport)
#endif
#else
#if defined(_LIB) || defined(OCSD_USE_STATIC_C_API)
#ifdef __cplusplus
#define OCSD_C_API extern "C"
#else
#define OCSD_C_API
#endif
#else
#ifdef __cplusplus
#define OCSD_C_API extern "C" __declspec(dllimport)
#else
#define OCSD_C_API __declspec(dllimport)
#endif
#endif
#endif
#else /* linux bindings */
#ifdef __cplusplus
#define OCSD_C_API extern "C"
#else
#define OCSD_C_API
#endif
#endif
#include "ocsd_c_api_types.h"
#include "ocsd_c_api_custom.h"
OCSD_C_API uint32_t ocsd_get_version(void);
OCSD_C_API const char * ocsd_get_version_str(void);
/*---------------------- Trace Decode Tree ----------------------------------------------------------------------------------*/
OCSD_C_API dcd_tree_handle_t ocsd_create_dcd_tree(const ocsd_dcd_tree_src_t src_type, const uint32_t deformatterCfgFlags);
OCSD_C_API void ocsd_destroy_dcd_tree(const dcd_tree_handle_t handle);
OCSD_C_API ocsd_datapath_resp_t ocsd_dt_process_data(const dcd_tree_handle_t handle,
const ocsd_datapath_op_t op,
const ocsd_trc_index_t index,
const uint32_t dataBlockSize,
const uint8_t *pDataBlock,
uint32_t *numBytesProcessed);
/*---------------------- Generic Trace Element Output --------------------------------------------------------------*/
OCSD_C_API ocsd_err_t ocsd_dt_set_gen_elem_outfn(const dcd_tree_handle_t handle, FnTraceElemIn pFn, const void *p_context);
/*---------------------- Trace Decoders ----------------------------------------------------------------------------------*/
OCSD_C_API ocsd_err_t ocsd_dt_create_decoder(const dcd_tree_handle_t handle,
const char *decoder_name,
const int create_flags,
const void *decoder_cfg,
unsigned char *pCSID
);
OCSD_C_API ocsd_err_t ocsd_dt_remove_decoder( const dcd_tree_handle_t handle,
const unsigned char CSID);
OCSD_C_API ocsd_err_t ocsd_dt_attach_packet_callback( const dcd_tree_handle_t handle,
const unsigned char CSID,
const ocsd_c_api_cb_types callback_type,
void *p_fn_callback_data,
const void *p_context);
/*---------------------- Memory Access for traced opcodes ----------------------------------------------------------------------------------*/
OCSD_C_API ocsd_err_t ocsd_dt_add_binfile_mem_acc(const dcd_tree_handle_t handle, const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const char *filepath);
OCSD_C_API ocsd_err_t ocsd_dt_add_binfile_region_mem_acc(const dcd_tree_handle_t handle, const ocsd_file_mem_region_t *region_array, const int num_regions, const ocsd_mem_space_acc_t mem_space, const char *filepath);
OCSD_C_API ocsd_err_t ocsd_dt_add_buffer_mem_acc(const dcd_tree_handle_t handle, const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint8_t *p_mem_buffer, const uint32_t mem_length);
OCSD_C_API ocsd_err_t ocsd_dt_add_callback_mem_acc(const dcd_tree_handle_t handle, const ocsd_vaddr_t st_address, const ocsd_vaddr_t en_address, const ocsd_mem_space_acc_t mem_space, Fn_MemAcc_CB p_cb_func, const void *p_context);
OCSD_C_API ocsd_err_t ocsd_dt_add_callback_trcid_mem_acc(const dcd_tree_handle_t handle, const ocsd_vaddr_t st_address, const ocsd_vaddr_t en_address, const ocsd_mem_space_acc_t mem_space, Fn_MemAccID_CB p_cb_func, const void *p_context);
OCSD_C_API ocsd_err_t ocsd_dt_remove_mem_acc(const dcd_tree_handle_t handle, const ocsd_vaddr_t st_address, const ocsd_mem_space_acc_t mem_space);
/*
* Print the mapped memory accessor ranges to the configured logger.
*
* @param handle : Handle to decode tree.
*/
OCSD_C_API void ocsd_tl_log_mapped_mem_ranges(const dcd_tree_handle_t handle);
/*---------------------- Library Logging and debug ----------------------------------------------------------------------------------*/
OCSD_C_API ocsd_err_t ocsd_def_errlog_init(const ocsd_err_severity_t verbosity, const int create_output_logger);
OCSD_C_API ocsd_err_t ocsd_def_errlog_config_output(const int output_flags, const char *log_file_name);
OCSD_C_API ocsd_err_t ocsd_def_errlog_set_strprint_cb(const dcd_tree_handle_t handle, void *p_context, FnDefLoggerPrintStrCB p_str_print_cb);
OCSD_C_API void ocsd_def_errlog_msgout(const char *msg);
OCSD_C_API ocsd_err_t ocsd_pkt_str(const ocsd_trace_protocol_t pkt_protocol, const void *p_pkt, char *buffer, const int buffer_size);
OCSD_C_API ocsd_err_t ocsd_gen_elem_str(const ocsd_generic_trace_elem *p_pkt, char *buffer, const int buffer_size);
OCSD_C_API void ocsd_gen_elem_init(ocsd_generic_trace_elem *p_pkt, const ocsd_gen_trc_elem_t elem_type);
OCSD_C_API ocsd_err_t ocsd_dt_set_raw_frame_printer(const dcd_tree_handle_t handle, int flags);
OCSD_C_API ocsd_err_t ocsd_dt_set_gen_elem_printer(const dcd_tree_handle_t handle);
OCSD_C_API ocsd_err_t ocsd_dt_set_pkt_protocol_printer(const dcd_tree_handle_t handle, uint8_t cs_id, int monitor);
OCSD_C_API ocsd_err_t ocsd_register_custom_decoder(const char *name, ocsd_extern_dcd_fact_t *p_dcd_fact);
OCSD_C_API ocsd_err_t ocsd_deregister_decoders(void);
OCSD_C_API ocsd_err_t ocsd_cust_protocol_to_str(const ocsd_trace_protocol_t pkt_protocol, const void *trc_pkt, char *buffer, const int buflen);
#endif // ARM_OPENCSD_C_API_H_INCLUDED
/* End of File opencsd_c_api.h */
ocsd_get_version_str
const OCSD_C_API char * ocsd_get_version_str(void)
ocsd_dt_add_callback_trcid_mem_acc
OCSD_C_API ocsd_err_t ocsd_dt_add_callback_trcid_mem_acc(const dcd_tree_handle_t handle, const ocsd_vaddr_t st_address, const ocsd_vaddr_t en_address, const ocsd_mem_space_acc_t mem_space, Fn_MemAccID_CB p_cb_func, const void *p_context)
ocsd_err_t
enum _ocsd_err_t ocsd_err_t
ocsd_dt_add_buffer_mem_acc
OCSD_C_API ocsd_err_t ocsd_dt_add_buffer_mem_acc(const dcd_tree_handle_t handle, const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint8_t *p_mem_buffer, const uint32_t mem_length)
ocsd_destroy_dcd_tree
OCSD_C_API void ocsd_destroy_dcd_tree(const dcd_tree_handle_t handle)
ocsd_dt_set_gen_elem_printer
OCSD_C_API ocsd_err_t ocsd_dt_set_gen_elem_printer(const dcd_tree_handle_t handle)
ocsd_dt_attach_packet_callback
OCSD_C_API ocsd_err_t ocsd_dt_attach_packet_callback(const dcd_tree_handle_t handle, const unsigned char CSID, const ocsd_c_api_cb_types callback_type, void *p_fn_callback_data, const void *p_context)
ocsd_dt_add_binfile_region_mem_acc
OCSD_C_API ocsd_err_t ocsd_dt_add_binfile_region_mem_acc(const dcd_tree_handle_t handle, const ocsd_file_mem_region_t *region_array, const int num_regions, const ocsd_mem_space_acc_t mem_space, const char *filepath)
ocsd_deregister_decoders
OCSD_C_API ocsd_err_t ocsd_deregister_decoders(void)
ocsd_pkt_str
OCSD_C_API ocsd_err_t ocsd_pkt_str(const ocsd_trace_protocol_t pkt_protocol, const void *p_pkt, char *buffer, const int buffer_size)
FnDefLoggerPrintStrCB
void(* FnDefLoggerPrintStrCB)(const void *p_context, const char *psz_msg_str, const int str_len)
Definition: ocsd_c_api_types.h:94
ocsd_dt_add_callback_mem_acc
OCSD_C_API ocsd_err_t ocsd_dt_add_callback_mem_acc(const dcd_tree_handle_t handle, const ocsd_vaddr_t st_address, const ocsd_vaddr_t en_address, const ocsd_mem_space_acc_t mem_space, Fn_MemAcc_CB p_cb_func, const void *p_context)
ocsd_dt_process_data
OCSD_C_API ocsd_datapath_resp_t ocsd_dt_process_data(const dcd_tree_handle_t handle, const ocsd_datapath_op_t op, const ocsd_trc_index_t index, const uint32_t dataBlockSize, const uint8_t *pDataBlock, uint32_t *numBytesProcessed)
ocsd_gen_elem_init
OCSD_C_API void ocsd_gen_elem_init(ocsd_generic_trace_elem *p_pkt, const ocsd_gen_trc_elem_t elem_type)
ocsd_dt_set_gen_elem_outfn
OCSD_C_API ocsd_err_t ocsd_dt_set_gen_elem_outfn(const dcd_tree_handle_t handle, FnTraceElemIn pFn, const void *p_context)
ocsd_create_dcd_tree
OCSD_C_API dcd_tree_handle_t ocsd_create_dcd_tree(const ocsd_dcd_tree_src_t src_type, const uint32_t deformatterCfgFlags)
_ocsd_generic_trace_elem
Definition: trc_gen_elem_types.h:78
ocsd_register_custom_decoder
OCSD_C_API ocsd_err_t ocsd_register_custom_decoder(const char *name, ocsd_extern_dcd_fact_t *p_dcd_fact)
ocsd_c_api_types.h
OpenCSD : Trace Decoder "C" API types.
ocsd_vaddr_t
uint64_t ocsd_vaddr_t
Definition: ocsd_if_types.h:308
ocsd_c_api_cb_types
enum _ocsd_c_api_cb_types ocsd_c_api_cb_types
ocsd_dt_add_binfile_mem_acc
OCSD_C_API ocsd_err_t ocsd_dt_add_binfile_mem_acc(const dcd_tree_handle_t handle, const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const char *filepath)
ocsd_dt_set_raw_frame_printer
OCSD_C_API ocsd_err_t ocsd_dt_set_raw_frame_printer(const dcd_tree_handle_t handle, int flags)
ocsd_dt_remove_mem_acc
OCSD_C_API ocsd_err_t ocsd_dt_remove_mem_acc(const dcd_tree_handle_t handle, const ocsd_vaddr_t st_address, const ocsd_mem_space_acc_t mem_space)
ocsd_cust_protocol_to_str
OCSD_C_API ocsd_err_t ocsd_cust_protocol_to_str(const ocsd_trace_protocol_t pkt_protocol, const void *trc_pkt, char *buffer, const int buflen)
Fn_MemAcc_CB
uint32_t(* Fn_MemAcc_CB)(const void *p_context, const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint32_t reqBytes, uint8_t *byteBuffer)
Definition: ocsd_if_types.h:459
ocsd_gen_trc_elem_t
enum _ocsd_gen_trc_elem_t ocsd_gen_trc_elem_t
ocsd_tl_log_mapped_mem_ranges
OCSD_C_API void ocsd_tl_log_mapped_mem_ranges(const dcd_tree_handle_t handle)
_ocsd_extern_dcd_fact
Definition: ocsd_c_api_custom.h:237
ocsd_def_errlog_set_strprint_cb
OCSD_C_API ocsd_err_t ocsd_def_errlog_set_strprint_cb(const dcd_tree_handle_t handle, void *p_context, FnDefLoggerPrintStrCB p_str_print_cb)
ocsd_def_errlog_config_output
OCSD_C_API ocsd_err_t ocsd_def_errlog_config_output(const int output_flags, const char *log_file_name)
FnTraceElemIn
ocsd_datapath_resp_t(* FnTraceElemIn)(const void *p_context, const ocsd_trc_index_t index_sop, const uint8_t trc_chan_id, const ocsd_generic_trace_elem *elem)
Definition: ocsd_c_api_types.h:74
dcd_tree_handle_t
void * dcd_tree_handle_t
Definition: ocsd_c_api_types.h:57
ocsd_dt_create_decoder
OCSD_C_API ocsd_err_t ocsd_dt_create_decoder(const dcd_tree_handle_t handle, const char *decoder_name, const int create_flags, const void *decoder_cfg, unsigned char *pCSID)
OCSD_C_API
#define OCSD_C_API
Definition: opencsd_c_api.h:77
ocsd_trc_index_t
uint32_t ocsd_trc_index_t
Definition: ocsd_if_types.h:67
ocsd_get_version
OCSD_C_API uint32_t ocsd_get_version(void)
ocsd_datapath_op_t
enum _ocsd_datapath_op_t ocsd_datapath_op_t
ocsd_def_errlog_msgout
OCSD_C_API void ocsd_def_errlog_msgout(const char *msg)
Fn_MemAccID_CB
uint32_t(* Fn_MemAccID_CB)(const void *p_context, const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint8_t trcID, const uint32_t reqBytes, uint8_t *byteBuffer)
Definition: ocsd_if_types.h:483
_ocsd_file_mem_region
Definition: ocsd_if_types.h:487
ocsd_def_errlog_init
OCSD_C_API ocsd_err_t ocsd_def_errlog_init(const ocsd_err_severity_t verbosity, const int create_output_logger)
ocsd_dt_remove_decoder
OCSD_C_API ocsd_err_t ocsd_dt_remove_decoder(const dcd_tree_handle_t handle, const unsigned char CSID)
ocsd_dcd_tree_src_t
enum _ocsd_dcd_tree_src_t ocsd_dcd_tree_src_t
ocsd_mem_space_acc_t
enum _ocsd_mem_space_acc_t ocsd_mem_space_acc_t
ocsd_dt_set_pkt_protocol_printer
OCSD_C_API ocsd_err_t ocsd_dt_set_pkt_protocol_printer(const dcd_tree_handle_t handle, uint8_t cs_id, int monitor)
ocsd_datapath_resp_t
enum _ocsd_datapath_resp_t ocsd_datapath_resp_t
ocsd_trace_protocol_t
enum _ocsd_trace_protocol_t ocsd_trace_protocol_t
ocsd_err_severity_t
enum _ocsd_err_severity_t ocsd_err_severity_t
ocsd_c_api_custom.h
ocsd_gen_elem_str
OCSD_C_API ocsd_err_t ocsd_gen_elem_str(const ocsd_generic_trace_elem *p_pkt, char *buffer, const int buffer_size)