OpenCSD - CoreSight Trace Decode Library  1.3.3
ocsd_gen_elem_list.h
Go to the documentation of this file.
1 /*
2  * \file ocsd_gen_elem_list.h
3  * \brief OpenCSD : Generic element output list.
4  *
5  * \copyright Copyright (c) 2016, ARM Limited. All Rights Reserved.
6  */
7 
8 /*
9  * Redistribution and use in source and binary forms, with or without modification,
10  * are permitted provided that the following conditions are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  *
19  * 3. Neither the name of the copyright holder nor the names of its contributors
20  * may be used to endorse or promote products derived from this software without
21  * specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26  * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 #include <list>
36 #include "trc_gen_elem.h"
37 #include "comp_attach_pt_t.h"
39 
57 {
58 public:
61 
63  void initCSID(const uint8_t CSID) { m_CSID = CSID; };
64 
65  void reset();
66 
68  const int getNumElem() const;
69 
70  const ocsd_gen_trc_elem_t getElemType(const int entryN) const;
71 
72  void pendLastNElem(int numPend);
73  void commitAllPendElem();
74  void cancelPendElem();
75  const int numPendElem() const;
76 
81  const bool elemToSend() const;
82 
83 private:
84 
85  void growArray();
86  const int getAdjustedIdx(int idxIn) const;
87 
88 
89  // list element contains pointer and byte index in trace stream
90  typedef struct _elemPtr {
91  OcsdTraceElement *pElem;
92  ocsd_trc_index_t trc_pkt_idx;
93  } elemPtr_t;
94 
95  elemPtr_t *m_pElemArray;
96  int m_elemArraySize;
97 
98  int m_firstElemIdx;
99  int m_numUsed;
100  int m_numPend;
101 
102  uint8_t m_CSID;
103 
105 };
106 
107 inline const int OcsdGenElemList::getAdjustedIdx(int idxIn) const
108 {
109  if(idxIn >= m_elemArraySize)
110  idxIn -= m_elemArraySize;
111  return idxIn;
112 }
113 
114 inline const int OcsdGenElemList::getNumElem() const
115 {
116  return m_numUsed;
117 }
118 
119 inline const int OcsdGenElemList::numPendElem() const
120 {
121  return m_numPend;
122 }
123 
124 inline void OcsdGenElemList::pendLastNElem(int numPend)
125 {
126  if(numPend >= getNumElem())
127  m_numPend = numPend;
128 }
129 
131 {
132  m_numPend = 0;
133 }
134 
136 {
137  if(m_numPend > 0)
138  {
139  m_numUsed -= m_numPend;
140  }
141 }
142 
143 inline const bool OcsdGenElemList::elemToSend() const
144 {
145  return ((getNumElem() - m_numPend) > 0);
146 }
147 
149 {
150  m_sendIf = pGenElemIf;
151 }
152 
153 /* End of File ocsd_gen_elem_list.h */
Maintain a list of elements to be output.
void pendLastNElem(int numPend)
Last element to be pended prior to cancel/commit decision.
void reset()
reset the element list.
const int getNumElem() const
return the total number of elements on the stack (inlcuding any pended ones).
void initSendIf(componentAttachPt< ITrcGenElemIn > *pGenElemIf)
ocsd_datapath_resp_t sendElements()
const bool elemToSend() const
true if any none-pending elements left to send.
const ocsd_gen_trc_elem_t getElemType(const int entryN) const
get the type for the nth element in the stack (0 indexed)
OcsdTraceElement * getNextElem(const ocsd_trc_index_t trc_pkt_idx)
get next free element on the stack (add one to the output)
void cancelPendElem()
cancel the last pended element on the stack.
void initCSID(const uint8_t CSID)
void commitAllPendElem()
commit all pended elements.
const int numPendElem() const
return the number of pended elements.
Generic trace element class.
Definition: trc_gen_elem.h:50
OpenCSD : Component attachment point interface class.
enum _ocsd_gen_trc_elem_t ocsd_gen_trc_elem_t
uint32_t ocsd_trc_index_t
Definition: ocsd_if_types.h:67
enum _ocsd_datapath_resp_t ocsd_datapath_resp_t
OpenCSD : Decoder Generic trace element output class.