OpenCSD - CoreSight Trace Decode Library  0.14.0
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);
57  ocsd_err_t addElemType(const ocsd_trc_index_t trc_pkt_idx, ocsd_gen_trc_elem_t elem_type);
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 */
OcsdGenElemStack::setCurrElemIdx
void setCurrElemIdx(const ocsd_trc_index_t trc_pkt_idx)
packet index for this element
Definition: ocsd_gen_elem_stack.h:98
ocsd_err_t
enum _ocsd_err_t ocsd_err_t
OcsdGenElemStack::~OcsdGenElemStack
~OcsdGenElemStack()
OcsdTraceElement
Generic trace element class.
Definition: trc_gen_elem.h:49
OcsdGenElemStack::initCSID
void initCSID(const uint8_t CSID)
Definition: ocsd_gen_elem_stack.h:51
OcsdGenElemStack::getCurrElem
OcsdTraceElement & getCurrElem()
get the current element.
Definition: ocsd_gen_elem_stack.h:103
OcsdGenElemStack::initSendIf
void initSendIf(componentAttachPt< ITrcGenElemIn > *pGenElemIf)
Definition: ocsd_gen_elem_stack.h:93
OcsdGenElemStack
Definition: ocsd_gen_elem_stack.h:44
trc_gen_elem_in_i.h
OcsdGenElemStack::OcsdGenElemStack
OcsdGenElemStack()
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
ocsd_trc_index_t
uint32_t ocsd_trc_index_t
Definition: ocsd_if_types.h:67
OcsdGenElemStack::addElem
ocsd_err_t addElem(const ocsd_trc_index_t trc_pkt_idx)
add elem to stack and set current.
componentAttachPt< ITrcGenElemIn >
comp_attach_pt_t.h
OpenCSD : Component attachment point interface class.
OcsdGenElemStack::addElemType
ocsd_err_t addElemType(const ocsd_trc_index_t trc_pkt_idx, ocsd_gen_trc_elem_t elem_type)
OcsdGenElemStack::sendElements
ocsd_datapath_resp_t sendElements()
send elements on the stack
ocsd_datapath_resp_t
enum _ocsd_datapath_resp_t ocsd_datapath_resp_t
OcsdGenElemStack::resetElemStack
ocsd_err_t resetElemStack()
set pointers to base of stack
OcsdGenElemStack::numElemToSend
const int numElemToSend() const
Definition: ocsd_gen_elem_stack.h:88