ocsd_gen_elem_list.h
Go to the documentation of this file.
/*
* \file ocsd_gen_elem_stack.h
* \brief OpenCSD : Generic element output stack.
*
* \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.
*/
#include <list>
#include "trc_gen_elem.h"
#include "comp_attach_pt_t.h"
#include "interfaces/trc_gen_elem_in_i.h"
class OcsdGenElemList
{
public:
OcsdGenElemList();
~OcsdGenElemList();
void initSendIf(componentAttachPt<ITrcGenElemIn> *pGenElemIf);
void initCSID(const uint8_t CSID) { m_CSID = CSID; };
void reset();
OcsdTraceElement *getNextElem(const ocsd_trc_index_t trc_pkt_idx);
const int getNumElem() const;
const ocsd_gen_trc_elem_t getElemType(const int entryN) const;
void pendLastNElem(int numPend);
void commitAllPendElem();
void cancelPendElem();
const int numPendElem() const;
ocsd_datapath_resp_t sendElements();
const bool elemToSend() const;
private:
void growArray();
const int getAdjustedIdx(int idxIn) const;
// list element contains pointer and byte index in trace stream
typedef struct _elemPtr {
OcsdTraceElement *pElem;
ocsd_trc_index_t trc_pkt_idx;
} elemPtr_t;
elemPtr_t *m_pElemArray;
int m_elemArraySize;
int m_firstElemIdx;
int m_numUsed;
int m_numPend;
uint8_t m_CSID;
componentAttachPt<ITrcGenElemIn> *m_sendIf;
};
inline const int OcsdGenElemList::getAdjustedIdx(int idxIn) const
{
if(idxIn >= m_elemArraySize)
idxIn -= m_elemArraySize;
return idxIn;
}
inline const int OcsdGenElemList::getNumElem() const
{
return m_numUsed;
}
inline const int OcsdGenElemList::numPendElem() const
{
return m_numPend;
}
inline void OcsdGenElemList::pendLastNElem(int numPend)
{
if(numPend >= getNumElem())
m_numPend = numPend;
}
inline void OcsdGenElemList::commitAllPendElem()
{
m_numPend = 0;
}
inline void OcsdGenElemList::cancelPendElem()
{
if(m_numPend > 0)
{
m_numUsed -= m_numPend;
}
}
inline const bool OcsdGenElemList::elemToSend() const
{
return ((getNumElem() - m_numPend) > 0);
}
inline void OcsdGenElemList::initSendIf(componentAttachPt<ITrcGenElemIn> *pGenElemIf)
{
m_sendIf = pGenElemIf;
}
/* End of File ocsd_gen_elem_stack.h */
OcsdGenElemList::cancelPendElem
void cancelPendElem()
cancel the last pended element on the stack.
Definition: ocsd_gen_elem_list.h:135
OcsdTraceElement
Generic trace element class.
Definition: trc_gen_elem.h:49
OcsdGenElemList::commitAllPendElem
void commitAllPendElem()
commit all pended elements.
Definition: ocsd_gen_elem_list.h:130
OcsdGenElemList::numPendElem
const int numPendElem() const
return the number of pended elements.
Definition: ocsd_gen_elem_list.h:119
OcsdGenElemList::~OcsdGenElemList
~OcsdGenElemList()
OcsdGenElemList::getNextElem
OcsdTraceElement * getNextElem(const ocsd_trc_index_t trc_pkt_idx)
get next free element on the stack (add one to the output)
trc_gen_elem_in_i.h
trc_gen_elem.h
OpenCSD : Decoder Generic trace element output class.
ocsd_gen_trc_elem_t
enum _ocsd_gen_trc_elem_t ocsd_gen_trc_elem_t
OcsdGenElemList::pendLastNElem
void pendLastNElem(int numPend)
Last element to be pended prior to cancel/commit decision.
Definition: ocsd_gen_elem_list.h:124
OcsdGenElemList::initCSID
void initCSID(const uint8_t CSID)
Definition: ocsd_gen_elem_list.h:63
OcsdGenElemList::OcsdGenElemList
OcsdGenElemList()
OcsdGenElemList::initSendIf
void initSendIf(componentAttachPt< ITrcGenElemIn > *pGenElemIf)
Definition: ocsd_gen_elem_list.h:148
OcsdGenElemList::getNumElem
const int getNumElem() const
return the total number of elements on the stack (inlcuding any pended ones).
Definition: ocsd_gen_elem_list.h:114
ocsd_trc_index_t
uint32_t ocsd_trc_index_t
Definition: ocsd_if_types.h:67
componentAttachPt< ITrcGenElemIn >
comp_attach_pt_t.h
OpenCSD : Component attachment point interface class.
OcsdGenElemList::getElemType
const ocsd_gen_trc_elem_t getElemType(const int entryN) const
get the type for the nth element in the stack (0 indexed)
OcsdGenElemList::elemToSend
const bool elemToSend() const
true if any none-pending elements left to send.
Definition: ocsd_gen_elem_list.h:143
OcsdGenElemList::sendElements
ocsd_datapath_resp_t sendElements()
ocsd_datapath_resp_t
enum _ocsd_datapath_resp_t ocsd_datapath_resp_t
OcsdGenElemList
Maintain a list of elements to be output.
Definition: ocsd_gen_elem_list.h:56
OcsdGenElemList::reset
void reset()
reset the element list.