Loading...
Searching...
No Matches
ocsd_dcd_tree.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_OCSD_DCD_TREE_H_INCLUDED
#define ARM_OCSD_DCD_TREE_H_INCLUDED
#include <vector>
#include <list>
#include "opencsd.h"
#include "ocsd_dcd_tree_elem.h"
class DecodeTree : public ITrcDataIn
{
public:
DecodeTree();
~DecodeTree();
static DecodeTree *CreateDecodeTree(const ocsd_dcd_tree_src_t src_type, const uint32_t formatterCfgFlags);
static void DestroyDecodeTree(DecodeTree *p_dcd_tree);
static ocsdDefaultErrorLogger* getDefaultErrorLogger() { return &s_error_logger; };
static ITraceErrorLog *getCurrentErrorLogI() { return s_i_error_logger; };
static void setAlternateErrorLogger(ITraceErrorLog *p_error_logger);
std::vector<ItemPrinter *> &getPrinterList() { return m_printer_list; };
ocsd_err_t addPacketPrinter(uint8_t CSID, bool bMonitor, ItemPrinter **ppPrinter);
ocsd_err_t addRawFramePrinter(RawFramePrinter **ppPrinter, uint32_t flags);
ocsd_err_t addGenElemPrinter(TrcGenericElementPrinter **ppPrinter);
virtual ocsd_datapath_resp_t TraceDataIn( const ocsd_datapath_op_t op,
const ocsd_trc_index_t index,
const uint32_t dataBlockSize,
const uint8_t *pDataBlock,
uint32_t *numBytesProcessed);
void setGenTraceElemOutI(ITrcGenElemIn *i_gen_trace_elem);
ITrcGenElemIn *getGenTraceElemOutI() const { return m_i_gen_elem_out; };
ocsd_err_t createDecoder(const std::string &decoderName, const int createFlags, const CSConfig *pConfig);
/* */
ocsd_err_t removeDecoder(const uint8_t CSID);
ocsd_err_t getDecoderStats(const uint8_t CSID, ocsd_decode_stats_t **p_stats_block);
ocsd_err_t resetDecoderStats(const uint8_t CSID);
/* get decoder elements currently in use */
DecodeTreeElement *getDecoderElement(const uint8_t CSID) const;
/* iterate decoder elements */
DecodeTreeElement *getFirstElement(uint8_t &elemID);
DecodeTreeElement *getNextElement(uint8_t &elemID);
/* set key interfaces - attach / replace on any existing tree components */
void setInstrDecoder(IInstrDecode *i_instr_decode);
void setMemAccessI(ITargetMemAccess *i_mem_access);
/* */
ocsd_err_t createMemAccMapper(memacc_mapper_t type = MEMACC_MAP_GLOBAL);
TrcMemAccMapper *getMemAccMapper() const { return m_default_mapper; };
void setExternMemAccMapper(TrcMemAccMapper * pMapper);
const bool hasMemAccMapper() const { return (bool)(m_default_mapper != 0); };
void logMappedRanges();
ocsd_err_t setMemAccCacheing(const bool enable, const uint16_t page_size, const int nr_pages);
ocsd_err_t addBufferMemAcc(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_err_t addBinFileMemAcc(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const std::string &filepath);
ocsd_err_t addBinFileRegionMemAcc(const ocsd_file_mem_region_t *region_array, const int num_regions, const ocsd_mem_space_acc_t mem_space, const std::string &filepath);
ocsd_err_t updateBinFileRegionMemAcc(const ocsd_file_mem_region_t *region_array, const int num_regions, const ocsd_mem_space_acc_t mem_space, const std::string &filepath);
ocsd_err_t addCallbackMemAcc(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_err_t addCallbackIDMemAcc(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 removeMemAccByAddress(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space);
TraceFormatterFrameDecoder *getFrameDeformatter() const { return m_frame_deformatter_root; };
ocsd_err_t setIDFilter(std::vector<uint8_t> &ids); // only supplied IDs will be decoded
ocsd_err_t clearIDFilter();
private:
bool initialise(const ocsd_dcd_tree_src_t type, uint32_t formatterCfgFlags);
const bool usingFormatter() const { return (bool)(m_dcd_tree_type == OCSD_TRC_SRC_FRAME_FORMATTED); };
void setSingleRoot(TrcPktProcI *pComp);
ocsd_err_t createDecodeElement(const uint8_t CSID);
void destroyDecodeElement(const uint8_t CSID);
void destroyMemAccMapper();
ocsd_err_t initCallbackMemAcc(const ocsd_vaddr_t st_address, const ocsd_vaddr_t en_address,
const ocsd_mem_space_acc_t mem_space, void *p_cb_func, bool IDfn, const void *p_context);
TrcPktProcI *getPktProcI(const uint8_t CSID);
// keep internal list of memory accessors created by this object.
void addMemAccessorToList(TrcMemAccessorBase* p_accessor);
// destroy mem accessors in use by this object
void destroyMemAccessors();
ocsd_dcd_tree_src_t m_dcd_tree_type;
IInstrDecode *m_i_instr_decode;
ITargetMemAccess *m_i_mem_access;
ITrcGenElemIn *m_i_gen_elem_out;
ITrcDataIn* m_i_decoder_root;
TraceFormatterFrameDecoder *m_frame_deformatter_root;
DecodeTreeElement *m_decode_elements[0x80];
uint8_t m_decode_elem_iter;
TrcMemAccMapper *m_default_mapper;
bool m_created_mapper;
std::vector<ItemPrinter *> m_printer_list;
/* global error logger - all sources */
static ITraceErrorLog *s_i_error_logger;
static std::list<DecodeTree *> s_trace_dcd_trees;
static ocsdDefaultErrorLogger s_error_logger;
static TrcIDecode s_instruction_decoder;
ocsd_demux_stats_t m_demux_stats;
std::list<TrcMemAccessorBase*> m_mem_accessors;
};
#endif // ARM_OCSD_DCD_TREE_H_INCLUDED
/* End of File ocsd_dcd_tree.h */
CSConfig
Base class for configuration data on CoreSight trace component.
Definition trc_cs_config.h:50
DecodeTreeElement
Decode tree element.
Definition ocsd_dcd_tree_elem.h:69
DecodeTree::addCallbackIDMemAcc
ocsd_err_t addCallbackIDMemAcc(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)
DecodeTree::getFirstElement
DecodeTreeElement * getFirstElement(uint8_t &elemID)
DecodeTree::getGenTraceElemOutI
ITrcGenElemIn * getGenTraceElemOutI() const
Return the connected generic element interface.
Definition ocsd_dcd_tree.h:138
DecodeTree::addCallbackMemAcc
ocsd_err_t addCallbackMemAcc(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)
DecodeTree::removeDecoder
ocsd_err_t removeDecoder(const uint8_t CSID)
DecodeTree::hasMemAccMapper
const bool hasMemAccMapper() const
Definition ocsd_dcd_tree.h:289
DecodeTree::TraceDataIn
virtual ocsd_datapath_resp_t TraceDataIn(const ocsd_datapath_op_t op, const ocsd_trc_index_t index, const uint32_t dataBlockSize, const uint8_t *pDataBlock, uint32_t *numBytesProcessed)
Trace Data input interface (ITrcDataIn).
DecodeTree::getDecoderElement
DecodeTreeElement * getDecoderElement(const uint8_t CSID) const
DecodeTree::setIDFilter
ocsd_err_t setIDFilter(std::vector< uint8_t > &ids)
ID filtering - sets the output filter on the trace deformatter.
DecodeTree::addBinFileMemAcc
ocsd_err_t addBinFileMemAcc(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const std::string &filepath)
DecodeTree::getCurrentErrorLogI
static ITraceErrorLog * getCurrentErrorLogI()
Definition ocsd_dcd_tree.h:92
DecodeTree::DecodeTree
DecodeTree()
default constructor
DecodeTree::addBufferMemAcc
ocsd_err_t addBufferMemAcc(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint8_t *p_mem_buffer, const uint32_t mem_length)
DecodeTree::addBinFileRegionMemAcc
ocsd_err_t addBinFileRegionMemAcc(const ocsd_file_mem_region_t *region_array, const int num_regions, const ocsd_mem_space_acc_t mem_space, const std::string &filepath)
DecodeTree::createDecoder
ocsd_err_t createDecoder(const std::string &decoderName, const int createFlags, const CSConfig *pConfig)
DecodeTree::getFrameDeformatter
TraceFormatterFrameDecoder * getFrameDeformatter() const
Get the Trace Frame de-mux.
Definition ocsd_dcd_tree.h:396
DecodeTree::setAlternateErrorLogger
static void setAlternateErrorLogger(ITraceErrorLog *p_error_logger)
DecodeTree::setMemAccCacheing
ocsd_err_t setMemAccCacheing(const bool enable, const uint16_t page_size, const int nr_pages)
DecodeTree::removeMemAccByAddress
ocsd_err_t removeMemAccByAddress(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space)
DecodeTree::setInstrDecoder
void setInstrDecoder(IInstrDecode *i_instr_decode)
DecodeTree::getNextElement
DecodeTreeElement * getNextElement(uint8_t &elemID)
DecodeTree::logMappedRanges
void logMappedRanges()
Log the mapped memory ranges to the default message logger.
DecodeTree::getDecoderStats
ocsd_err_t getDecoderStats(const uint8_t CSID, ocsd_decode_stats_t **p_stats_block)
DecodeTree::CreateDecodeTree
static DecodeTree * CreateDecodeTree(const ocsd_dcd_tree_src_t src_type, const uint32_t formatterCfgFlags)
Create a decode tree. Automatically creates a trace frame deformatter if required and a default error...
DecodeTree::getPrinterList
std::vector< ItemPrinter * > & getPrinterList()
Definition ocsd_dcd_tree.h:98
DecodeTree::setExternMemAccMapper
void setExternMemAccMapper(TrcMemAccMapper *pMapper)
DecodeTree::resetDecoderStats
ocsd_err_t resetDecoderStats(const uint8_t CSID)
DecodeTree::getDefaultErrorLogger
static ocsdDefaultErrorLogger * getDefaultErrorLogger()
The library default error logger.
Definition ocsd_dcd_tree.h:89
DecodeTree::setMemAccessI
void setMemAccessI(ITargetMemAccess *i_mem_access)
DecodeTree::setGenTraceElemOutI
void setGenTraceElemOutI(ITrcGenElemIn *i_gen_trace_elem)
Decoded Trace output.
DecodeTree::updateBinFileRegionMemAcc
ocsd_err_t updateBinFileRegionMemAcc(const ocsd_file_mem_region_t *region_array, const int num_regions, const ocsd_mem_space_acc_t mem_space, const std::string &filepath)
DecodeTree::createMemAccMapper
ocsd_err_t createMemAccMapper(memacc_mapper_t type=MEMACC_MAP_GLOBAL)
DecodeTree::clearIDFilter
ocsd_err_t clearIDFilter()
remove filter, all IDs will be decoded
DecodeTree::addPacketPrinter
ocsd_err_t addPacketPrinter(uint8_t CSID, bool bMonitor, ItemPrinter **ppPrinter)
DecodeTree::addRawFramePrinter
ocsd_err_t addRawFramePrinter(RawFramePrinter **ppPrinter, uint32_t flags)
DecodeTree::addGenElemPrinter
ocsd_err_t addGenElemPrinter(TrcGenericElementPrinter **ppPrinter)
DecodeTree::DestroyDecodeTree
static void DestroyDecodeTree(DecodeTree *p_dcd_tree)
Destroy a decode tree.
DecodeTree::getMemAccMapper
TrcMemAccMapper * getMemAccMapper() const
Definition ocsd_dcd_tree.h:276
DecodeTree::~DecodeTree
~DecodeTree()
default destructor
IInstrDecode
Interface class to an instruction opcode decoder.
Definition trc_instr_decode_i.h:48
ITargetMemAccess
Interface to target memory access.
Definition trc_tgt_mem_access_i.h:57
ITraceErrorLog
Error logging interface.
Definition trc_error_log_i.h:57
ITrcDataIn
Interface to either trace data frame deformatter or packet processor.
Definition trc_data_raw_in_i.h:52
ITrcDataIn::ITrcDataIn
ITrcDataIn()
Definition trc_data_raw_in_i.h:54
ITrcGenElemIn
Interface for the input of generic trace elements.
Definition trc_gen_elem_in_i.h:52
TraceFormatterFrameDecoder
Definition trc_frame_deformatter.h:53
TrcMemAccMapper
Definition trc_mem_acc_mapper.h:51
TrcMemAccessorBase
Memory range to access by trace decoder.
Definition trc_mem_acc_base.h:53
TrcPktProcI
Base Packet processing interface.
Definition trc_pkt_proc_base.h:66
ocsdDefaultErrorLogger
Definition ocsd_error_logger.h:47
ocsd_dcd_tree_src_t
enum _ocsd_dcd_tree_src_t ocsd_dcd_tree_src_t
ocsd_file_mem_region_t
struct _ocsd_file_mem_region ocsd_file_mem_region_t
ocsd_trc_index_t
uint32_t ocsd_trc_index_t
Definition ocsd_if_types.h:59
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:490
ocsd_datapath_resp_t
enum _ocsd_datapath_resp_t ocsd_datapath_resp_t
ocsd_decode_stats_t
struct _ocsd_decode_stats ocsd_decode_stats_t
ocsd_mem_space_acc_t
enum _ocsd_mem_space_acc_t ocsd_mem_space_acc_t
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:466
ocsd_demux_stats_t
struct _ocsd_demux_stats ocsd_demux_stats_t
ocsd_datapath_op_t
enum _ocsd_datapath_op_t ocsd_datapath_op_t
ocsd_err_t
enum _ocsd_err_t ocsd_err_t
ocsd_vaddr_t
uint64_t ocsd_vaddr_t
Definition ocsd_if_types.h:306
OCSD_TRC_SRC_FRAME_FORMATTED
@ OCSD_TRC_SRC_FRAME_FORMATTED
Definition ocsd_if_types.h:235
ocsd_dcd_tree_elem.h
OpenCSD : Decode tree element.
opencsd.h
OpenCSD: Open CoreSight Trace Decoder -Master include file for C++ library.
MEMACC_MAP_GLOBAL
@ MEMACC_MAP_GLOBAL
Definition trc_mem_acc_mapper.h:47
memacc_mapper_t
enum _memacc_mapper_t memacc_mapper_t