1*c120c564SAndrew Turner /*! 2*c120c564SAndrew Turner * \file trc_component.h 3*c120c564SAndrew Turner * \brief OpenCSD : Base trace decode component. 4*c120c564SAndrew Turner * 5*c120c564SAndrew Turner * \copyright Copyright (c) 2015, ARM Limited. All Rights Reserved. 6*c120c564SAndrew Turner */ 7*c120c564SAndrew Turner 8*c120c564SAndrew Turner 9*c120c564SAndrew Turner /* 10*c120c564SAndrew Turner * Redistribution and use in source and binary forms, with or without modification, 11*c120c564SAndrew Turner * are permitted provided that the following conditions are met: 12*c120c564SAndrew Turner * 13*c120c564SAndrew Turner * 1. Redistributions of source code must retain the above copyright notice, 14*c120c564SAndrew Turner * this list of conditions and the following disclaimer. 15*c120c564SAndrew Turner * 16*c120c564SAndrew Turner * 2. Redistributions in binary form must reproduce the above copyright notice, 17*c120c564SAndrew Turner * this list of conditions and the following disclaimer in the documentation 18*c120c564SAndrew Turner * and/or other materials provided with the distribution. 19*c120c564SAndrew Turner * 20*c120c564SAndrew Turner * 3. Neither the name of the copyright holder nor the names of its contributors 21*c120c564SAndrew Turner * may be used to endorse or promote products derived from this software without 22*c120c564SAndrew Turner * specific prior written permission. 23*c120c564SAndrew Turner * 24*c120c564SAndrew Turner * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND 25*c120c564SAndrew Turner * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26*c120c564SAndrew Turner * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 27*c120c564SAndrew Turner * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28*c120c564SAndrew Turner * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29*c120c564SAndrew Turner * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30*c120c564SAndrew Turner * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 31*c120c564SAndrew Turner * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32*c120c564SAndrew Turner * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33*c120c564SAndrew Turner * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34*c120c564SAndrew Turner */ 35*c120c564SAndrew Turner 36*c120c564SAndrew Turner #ifndef ARM_TRC_COMPONENT_H_INCLUDED 37*c120c564SAndrew Turner #define ARM_TRC_COMPONENT_H_INCLUDED 38*c120c564SAndrew Turner 39*c120c564SAndrew Turner #include <string> 40*c120c564SAndrew Turner #include "comp_attach_pt_t.h" 41*c120c564SAndrew Turner #include "interfaces/trc_error_log_i.h" 42*c120c564SAndrew Turner #include "ocsd_error.h" 43*c120c564SAndrew Turner 44*c120c564SAndrew Turner class errLogAttachMonitor; 45*c120c564SAndrew Turner 46*c120c564SAndrew Turner /** @addtogroup ocsd_infrastructure 47*c120c564SAndrew Turner @{*/ 48*c120c564SAndrew Turner 49*c120c564SAndrew Turner /*! 50*c120c564SAndrew Turner * @class TraceComponent 51*c120c564SAndrew Turner * @brief Base class for all decode components in the library. 52*c120c564SAndrew Turner * 53*c120c564SAndrew Turner * Provides error logging attachment point and component type and instance naming 54*c120c564SAndrew Turner * Interface for handling of component operational mode. 55*c120c564SAndrew Turner */ 56*c120c564SAndrew Turner class TraceComponent 57*c120c564SAndrew Turner { 58*c120c564SAndrew Turner public: 59*c120c564SAndrew Turner TraceComponent(const std::string &name); 60*c120c564SAndrew Turner TraceComponent(const std::string &name, int instIDNum); 61*c120c564SAndrew Turner virtual ~TraceComponent(); /**< Default Destructor */ 62*c120c564SAndrew Turner getComponentName()63*c120c564SAndrew Turner const std::string &getComponentName() const { return m_name; }; setComponentName(const std::string & name)64*c120c564SAndrew Turner void setComponentName(const std::string &name) { m_name = name; }; 65*c120c564SAndrew Turner 66*c120c564SAndrew Turner /** Error logger attachment point.*/ getErrorLogAttachPt()67*c120c564SAndrew Turner componentAttachPt<ITraceErrorLog> *getErrorLogAttachPt() { return &m_error_logger; }; 68*c120c564SAndrew Turner 69*c120c564SAndrew Turner /*! 70*c120c564SAndrew Turner * Set the operational mode for the component. 71*c120c564SAndrew Turner * This controls the way the component behaves under error conditions etc. 72*c120c564SAndrew Turner * These flags may also control output formats or data. 73*c120c564SAndrew Turner * Operation mode flags used are component specific and defined by derived classes. 74*c120c564SAndrew Turner * 75*c120c564SAndrew Turner * @param op_flags : Set of operation mode flags. 76*c120c564SAndrew Turner * 77*c120c564SAndrew Turner * @return ocsd_err_t : OCSD_OK if flags supported by this component, error if unsuppored 78*c120c564SAndrew Turner */ 79*c120c564SAndrew Turner ocsd_err_t setComponentOpMode(uint32_t op_flags); 80*c120c564SAndrew Turner 81*c120c564SAndrew Turner /*! 82*c120c564SAndrew Turner * Return the current operational mode flags values 83*c120c564SAndrew Turner * 84*c120c564SAndrew Turner * @return const uint32_t : Op Mode flags. 85*c120c564SAndrew Turner */ getComponentOpMode()86*c120c564SAndrew Turner const uint32_t getComponentOpMode() const { return m_op_flags; }; 87*c120c564SAndrew Turner 88*c120c564SAndrew Turner /*! 89*c120c564SAndrew Turner * Get the supported operational mode flags for this component. 90*c120c564SAndrew Turner * Base class will return nothing supported. 91*c120c564SAndrew Turner * Derived class must set the value correctly for the component. 92*c120c564SAndrew Turner * 93*c120c564SAndrew Turner * @return const uint32_t : Supported flags values. 94*c120c564SAndrew Turner */ getSupportedOpModes()95*c120c564SAndrew Turner const uint32_t getSupportedOpModes() const { return m_supported_op_flags; }; 96*c120c564SAndrew Turner 97*c120c564SAndrew Turner /*! 98*c120c564SAndrew Turner * Set associated trace component - used by generic code to track 99*c120c564SAndrew Turner * packet processor / packet decoder pairs. 100*c120c564SAndrew Turner * 101*c120c564SAndrew Turner * @param *assocComp : pointer to the associated component 102*c120c564SAndrew Turner */ setAssocComponent(TraceComponent * assocComp)103*c120c564SAndrew Turner void setAssocComponent(TraceComponent *assocComp) { m_assocComp = assocComp; }; 104*c120c564SAndrew Turner 105*c120c564SAndrew Turner 106*c120c564SAndrew Turner /*! 107*c120c564SAndrew Turner * get associated trace component pointer 108*c120c564SAndrew Turner * 109*c120c564SAndrew Turner * @return TraceComponent *: associated component. 110*c120c564SAndrew Turner */ getAssocComponent()111*c120c564SAndrew Turner TraceComponent *getAssocComponent() { return m_assocComp; }; 112*c120c564SAndrew Turner 113*c120c564SAndrew Turner /*! 114*c120c564SAndrew Turner * Log a message at the default severity on this component. 115*c120c564SAndrew Turner */ LogDefMessage(const std::string & msg)116*c120c564SAndrew Turner void LogDefMessage(const std::string &msg) 117*c120c564SAndrew Turner { 118*c120c564SAndrew Turner LogMessage(m_errVerbosity, msg); 119*c120c564SAndrew Turner } 120*c120c564SAndrew Turner 121*c120c564SAndrew Turner protected: 122*c120c564SAndrew Turner friend class errLogAttachMonitor; 123*c120c564SAndrew Turner 124*c120c564SAndrew Turner void LogError(const ocsdError &Error); 125*c120c564SAndrew Turner void LogMessage(const ocsd_err_severity_t filter_level, const std::string &msg); getErrorLogLevel()126*c120c564SAndrew Turner const ocsd_err_severity_t getErrorLogLevel() const { return m_errVerbosity; }; isLoggingErrorLevel(const ocsd_err_severity_t level)127*c120c564SAndrew Turner const bool isLoggingErrorLevel(const ocsd_err_severity_t level) const { return level <= m_errVerbosity; }; 128*c120c564SAndrew Turner void updateErrorLogLevel(); 129*c120c564SAndrew Turner 130*c120c564SAndrew Turner void do_attach_notify(const int num_attached); 131*c120c564SAndrew Turner void Init(const std::string &name); 132*c120c564SAndrew Turner 133*c120c564SAndrew Turner uint32_t m_op_flags; //!< current component operational mode flags. 134*c120c564SAndrew Turner uint32_t m_supported_op_flags; //!< supported component operational mode flags - derived class to intialise. 135*c120c564SAndrew Turner 136*c120c564SAndrew Turner private: 137*c120c564SAndrew Turner componentAttachPt<ITraceErrorLog> m_error_logger; 138*c120c564SAndrew Turner ocsd_hndl_err_log_t m_errLogHandle; 139*c120c564SAndrew Turner ocsd_err_severity_t m_errVerbosity; 140*c120c564SAndrew Turner errLogAttachMonitor *m_pErrAttachMon; 141*c120c564SAndrew Turner 142*c120c564SAndrew Turner std::string m_name; 143*c120c564SAndrew Turner 144*c120c564SAndrew Turner TraceComponent *m_assocComp; //!< associated component -> if this is a pkt decoder, associated pkt processor. 145*c120c564SAndrew Turner }; 146*c120c564SAndrew Turner /** @}*/ 147*c120c564SAndrew Turner #endif // ARM_TRC_COMPONENT_H_INCLUDED 148*c120c564SAndrew Turner 149*c120c564SAndrew Turner /* End of File trc_component.h */ 150