OpenCSD - CoreSight Trace Decode Library  1.3.3
ocsd_gen_elem_stack.h
Go to the documentation of this file.
1 /*
2 * \file ocsd_gen_elem_stack.h
3 * \brief OpenCSD : Generic element output stack.
4 *
5 * \copyright Copyright (c) 2020, 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 "trc_gen_elem.h"
36 #include "comp_attach_pt_t.h"
38 
39 /* element stack to handle cases where a trace element can generate multiple output packets
40 
41  maintains the "current" element, which might be sent independently of this stack, and also
42  ensures that persistent data in the output elements is maintained between elements.
43 */
45 {
46 public:
49 
51  void initCSID(const uint8_t CSID) { m_CSID = CSID; };
52 
55  ocsd_err_t addElem(const ocsd_trc_index_t trc_pkt_idx);
56  void setCurrElemIdx(const ocsd_trc_index_t trc_pkt_idx);
58 
60  const int numElemToSend() const;
61 
62 private:
63  typedef struct _elemPtr {
64  OcsdTraceElement *pElem;
65  ocsd_trc_index_t trc_pkt_idx;
66  } elemPtr_t;
67 
68  const bool isInit();
69 
70  ocsd_err_t growArray();
71  void copyPersistentData(int src, int dst);
72  void resetIndexes();
73 
74  elemPtr_t *m_pElemArray;
75  int m_elemArraySize;
76 
77  int m_elem_to_send;
78  int m_curr_elem_idx;
79  int m_send_elem_idx;
80 
82  uint8_t m_CSID;
84 
85  bool m_is_init;
86 };
87 
88 inline const int OcsdGenElemStack::numElemToSend() const
89 {
90  return m_elem_to_send;
91 }
92 
94 {
95  m_sendIf = pGenElemIf;
96 }
97 
98 inline void OcsdGenElemStack::setCurrElemIdx(const ocsd_trc_index_t trc_pkt_idx)
99 {
100  m_pElemArray[m_curr_elem_idx].trc_pkt_idx = trc_pkt_idx;
101 }
102 
104 {
105  return *(m_pElemArray[m_curr_elem_idx].pElem);
106 }
107 
108 
109 /* End of File ocsd_gen_elem_stack.h */
ocsd_err_t addElem(const ocsd_trc_index_t trc_pkt_idx)
add elem to stack and set current.
OcsdTraceElement & getCurrElem()
get the current element.
const int numElemToSend() const
ocsd_datapath_resp_t sendElements()
send elements on the stack
void setCurrElemIdx(const ocsd_trc_index_t trc_pkt_idx)
packet index for this element
ocsd_err_t resetElemStack()
set pointers to base of stack
ocsd_err_t addElemType(const ocsd_trc_index_t trc_pkt_idx, ocsd_gen_trc_elem_t elem_type)
void initSendIf(componentAttachPt< ITrcGenElemIn > *pGenElemIf)
void initCSID(const uint8_t CSID)
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
enum _ocsd_err_t ocsd_err_t
OpenCSD : Decoder Generic trace element output class.