Enables templated interface classes to be handled generically
Updates to classes to prepare for generic handling of decoder registration and connection.
Attachment point function added to simply replace current attached component with supplied replacement. Supply 0 to detach.
Trace component common base class adjusted to be virtual + added method to associate trace components.
Trace packet decoded added information on usage of memory access and instruction decoder interfaces (STM decoder will not need these)
Signed-off-by: Mike Leach mike.leach@linaro.org --- decoder/include/common/comp_attach_pt_t.h | 15 ++++++ decoder/include/common/trc_component.h | 22 ++++++++- decoder/include/common/trc_pkt_decode_base.h | 36 +++++++++----- decoder/include/interfaces/trc_abs_typed_base_i.h | 57 +++++++++++++++++++++++ decoder/include/interfaces/trc_indexer_pkt_i.h | 4 +- decoder/include/interfaces/trc_pkt_in_i.h | 4 +- decoder/include/interfaces/trc_pkt_raw_in_i.h | 4 +- 7 files changed, 126 insertions(+), 16 deletions(-) create mode 100644 decoder/include/interfaces/trc_abs_typed_base_i.h
diff --git a/decoder/include/common/comp_attach_pt_t.h b/decoder/include/common/comp_attach_pt_t.h index ee9a06f..1d56240 100644 --- a/decoder/include/common/comp_attach_pt_t.h +++ b/decoder/include/common/comp_attach_pt_t.h @@ -81,6 +81,10 @@ public: */ virtual ocsd_err_t detach(T* component);
+ + // detach current first if anything attached, connect supplied pointer, remain unattached if pointer 0 + virtual ocsd_err_t replace_first(T* component); + /*! * Detach all components. */ @@ -170,6 +174,17 @@ template<class T> ocsd_err_t componentAttachPt<T>::attach(T* component) return OCSD_OK; }
+template<class T> ocsd_err_t componentAttachPt<T>::replace_first(T* component) +{ + if(m_hasAttached) + detach(m_comp); + + if(component == 0) + return OCSD_OK; + + return attach(component); +} + template<class T> ocsd_err_t componentAttachPt<T>::detach(T* component) { if(m_comp != component) diff --git a/decoder/include/common/trc_component.h b/decoder/include/common/trc_component.h index 3ccbac6..49ad265 100644 --- a/decoder/include/common/trc_component.h +++ b/decoder/include/common/trc_component.h @@ -58,7 +58,7 @@ class TraceComponent public: TraceComponent(const std::string &name); TraceComponent(const std::string &name, int instIDNum); - ~TraceComponent(); /**< Default Destructor */ + virtual ~TraceComponent(); /**< Default Destructor */
const std::string &getComponentName() const { return m_name; }; void setComponentName(const std::string &name) { m_name = name; }; @@ -94,6 +94,22 @@ public: */ const uint32_t getSupportedOpModes() const { return m_supported_op_flags; };
+ /*! + * Set associated trace component - used by generic code to track + * packet processor / packet decoder pairs. + * + * @param *assocComp : pointer to the associated component + */ + void setAssocComponent(TraceComponent *assocComp) { m_assocComp = assocComp; }; + + + /*! + * get associated trace component pointer + * + * @return TraceComponent *: associated component. + */ + TraceComponent *getAssocComponent() { return m_assocComp; }; + protected: friend class errLogAttachMonitor;
@@ -114,7 +130,9 @@ private: ocsd_err_severity_t m_errVerbosity; errLogAttachMonitor *m_pErrAttachMon;
- std::string m_name; + std::string m_name; + + TraceComponent *m_assocComp; //!< associated component -> if this is a pkt decoder, associated pkt processor. }; /** @}*/ #endif // ARM_TRC_COMPONENT_H_INCLUDED diff --git a/decoder/include/common/trc_pkt_decode_base.h b/decoder/include/common/trc_pkt_decode_base.h index 38b4ebd..2bbf5e5 100644 --- a/decoder/include/common/trc_pkt_decode_base.h +++ b/decoder/include/common/trc_pkt_decode_base.h @@ -43,7 +43,6 @@ #include "interfaces/trc_tgt_mem_access_i.h" #include "interfaces/trc_instr_decode_i.h"
- /** @defgroup ocsd_pkt_decode OpenCSD Library : Packet Decoders.
@brief Classes providing Protocol Packet Decoding capability. @@ -64,11 +63,17 @@ class TrcPktDecodeI : public TraceComponent public: TrcPktDecodeI(const char *component_name); TrcPktDecodeI(const char *component_name, int instIDNum); + virtual ~TrcPktDecodeI() {};
componentAttachPt<ITrcGenElemIn> *getTraceElemOutAttachPt() { return &m_trace_elem_out; }; componentAttachPt<ITargetMemAccess> *getMemoryAccessAttachPt() { return &m_mem_access; }; componentAttachPt<IInstrDecode> *getInstrDecodeAttachPt() { return &m_instr_decode; };
+ void setUsesMemAccess(bool bUsesMemaccess) { m_uses_memaccess = bUsesMemaccess; }; + const bool getUsesMemAccess() const { return m_uses_memaccess; }; + + void setUsesIDecode(bool bUsesIDecode) { m_uses_idecode = bUsesIDecode; }; + const bool getUsesIDecode() const { return m_uses_idecode; };
protected:
@@ -103,13 +108,18 @@ protected:
std::string init_err_msg; //!< error message for init error
+ bool m_uses_memaccess; + bool m_uses_idecode; + };
inline TrcPktDecodeI::TrcPktDecodeI(const char *component_name) : TraceComponent(component_name), m_index_curr_pkt(0), m_decode_init_ok(false), - m_config_init_ok(false) + m_config_init_ok(false), + m_uses_memaccess(true), + m_uses_idecode(true) { }
@@ -117,7 +127,9 @@ inline TrcPktDecodeI::TrcPktDecodeI(const char *component_name, int instIDNum) : TraceComponent(component_name, instIDNum), m_index_curr_pkt(0), m_decode_init_ok(false), - m_config_init_ok(false) + m_config_init_ok(false), + m_uses_memaccess(true), + m_uses_idecode(true) { }
@@ -129,9 +141,9 @@ inline const bool TrcPktDecodeI::checkInit() init_err_msg = "No decoder configuration information"; else if(!m_trace_elem_out.hasAttachedAndEnabled()) init_err_msg = "No element output interface attached and enabled"; - else if(!m_mem_access.hasAttachedAndEnabled()) + else if(m_uses_memaccess && !m_mem_access.hasAttachedAndEnabled()) init_err_msg = "No memory access interface attached and enabled"; - else if(!m_instr_decode.hasAttachedAndEnabled()) + else if(m_uses_idecode && !m_instr_decode.hasAttachedAndEnabled()) init_err_msg = "No instruction decoder interface attached and enabled"; else m_decode_init_ok = true; @@ -151,17 +163,19 @@ inline ocsd_datapath_resp_t TrcPktDecodeI::outputTraceElementIdx(ocsd_trc_index_
inline ocsd_err_t TrcPktDecodeI::instrDecode(ocsd_instr_info *instr_info) { - return m_instr_decode.first()->DecodeInstruction(instr_info); + if(m_uses_idecode) + return m_instr_decode.first()->DecodeInstruction(instr_info); + return OCSD_ERR_DCD_INTERFACE_UNUSED; }
inline ocsd_err_t TrcPktDecodeI::accessMemory(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, uint32_t *num_bytes, uint8_t *p_buffer) { - return m_mem_access.first()->ReadTargetMemory(address,getCoreSightTraceID(),mem_space, num_bytes,p_buffer); + if(m_uses_memaccess) + return m_mem_access.first()->ReadTargetMemory(address,getCoreSightTraceID(),mem_space, num_bytes,p_buffer); + return OCSD_ERR_DCD_INTERFACE_UNUSED; }
- /**********************************************************************/ - template <class P, class Pc> class TrcPktDecodeBase : public TrcPktDecodeI, public IPktDataIn<P> { @@ -176,7 +190,7 @@ public:
/* protocol configuration */ - ocsd_err_t setProtocolConfig(Pc *config); + ocsd_err_t setProtocolConfig(const Pc *config); const Pc * getProtocolConfig() const { return m_config; };
protected: @@ -255,7 +269,7 @@ template <class P, class Pc> ocsd_datapath_resp_t TrcPktDecodeBase<P, Pc>::Packe }
/* protocol configuration */ -template <class P, class Pc> ocsd_err_t TrcPktDecodeBase<P, Pc>::setProtocolConfig(Pc *config) +template <class P, class Pc> ocsd_err_t TrcPktDecodeBase<P, Pc>::setProtocolConfig(const Pc *config) { ocsd_err_t err = OCSD_ERR_INVALID_PARAM_VAL; if(config != 0) diff --git a/decoder/include/interfaces/trc_abs_typed_base_i.h b/decoder/include/interfaces/trc_abs_typed_base_i.h new file mode 100644 index 0000000..034ecd3 --- /dev/null +++ b/decoder/include/interfaces/trc_abs_typed_base_i.h @@ -0,0 +1,57 @@ +/* + * \file trc_abs_typed_base_i.h + * \brief OpenCSD : + * + * \copyright Copyright (c) 2016, ARM Limited. All Rights Reserved. + */ + + +/* + * 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_TRC_ABS_TYPED_BASE_I_H_INCLUDED +#define ARM_TRC_ABS_TYPED_BASE_I_H_INCLUDED + +/*! + * @class ITrcTypedBase : Abstract base class to for interfaces templated types. + * + * This class is used as an abstract base for any interfaces that are specialised using + * template<> types. + * + * Designed to allow interface objects to be passed through generic interfaces into type + * specific templated implmentation handlers. + */ +class ITrcTypedBase +{ +public: + ITrcTypedBase() {}; + virtual ~ITrcTypedBase() {}; +}; + +#endif // ARM_TRC_ABS_TYPED_BASE_I_H_INCLUDED + +/* End of File trc_abs_typed_base_i.h */ diff --git a/decoder/include/interfaces/trc_indexer_pkt_i.h b/decoder/include/interfaces/trc_indexer_pkt_i.h index 138a0a6..02aecda 100644 --- a/decoder/include/interfaces/trc_indexer_pkt_i.h +++ b/decoder/include/interfaces/trc_indexer_pkt_i.h @@ -36,6 +36,8 @@ #ifndef ARM_TRC_INDEXER_PKT_I_H_INCLUDED #define ARM_TRC_INDEXER_PKT_I_H_INCLUDED
+#include "trc_abs_typed_base_i.h" + /*! * @class ITrcPktIndexer
@@ -55,7 +57,7 @@ * */ template <class Pt> -class ITrcPktIndexer +class ITrcPktIndexer : public ITrcTypedBase { public: ITrcPktIndexer() {}; /**< Default constructor. */ diff --git a/decoder/include/interfaces/trc_pkt_in_i.h b/decoder/include/interfaces/trc_pkt_in_i.h index 0d3135d..8f6c5ef 100644 --- a/decoder/include/interfaces/trc_pkt_in_i.h +++ b/decoder/include/interfaces/trc_pkt_in_i.h @@ -36,6 +36,8 @@ #ifndef ARM_TRC_PKT_IN_I_H_INCLUDED #define ARM_TRC_PKT_IN_I_H_INCLUDED
+#include "trc_abs_typed_base_i.h" + /*! * @class IPktDataIn * @ingroup ocsd_interfaces @@ -49,7 +51,7 @@ * */ template<class P> -class IPktDataIn +class IPktDataIn : public ITrcTypedBase { public: IPktDataIn() {}; /**< Default constructor. */ diff --git a/decoder/include/interfaces/trc_pkt_raw_in_i.h b/decoder/include/interfaces/trc_pkt_raw_in_i.h index 3cb711d..6f7b213 100644 --- a/decoder/include/interfaces/trc_pkt_raw_in_i.h +++ b/decoder/include/interfaces/trc_pkt_raw_in_i.h @@ -36,6 +36,8 @@ #ifndef ARM_TRC_PKT_RAW_IN_I_H_INCLUDED #define ARM_TRC_PKT_RAW_IN_I_H_INCLUDED
+#include "trc_abs_typed_base_i.h" + /*! * @class IPktRawDataMon * @@ -52,7 +54,7 @@ * */ template<class P> -class IPktRawDataMon +class IPktRawDataMon : public ITrcTypedBase { public: IPktRawDataMon() {}; /**< Default constructor. */