1c120c564SAndrew Turner /*
2c120c564SAndrew Turner * \file ocsd_dcd_mngr.h
3c120c564SAndrew Turner * \brief OpenCSD : Decoder manager base class.
4c120c564SAndrew Turner *
5c120c564SAndrew Turner * \copyright Copyright (c) 2016, ARM Limited. All Rights Reserved.
6c120c564SAndrew Turner */
7c120c564SAndrew Turner
8c120c564SAndrew Turner /*
9c120c564SAndrew Turner * Redistribution and use in source and binary forms, with or without modification,
10c120c564SAndrew Turner * are permitted provided that the following conditions are met:
11c120c564SAndrew Turner *
12c120c564SAndrew Turner * 1. Redistributions of source code must retain the above copyright notice,
13c120c564SAndrew Turner * this list of conditions and the following disclaimer.
14c120c564SAndrew Turner *
15c120c564SAndrew Turner * 2. Redistributions in binary form must reproduce the above copyright notice,
16c120c564SAndrew Turner * this list of conditions and the following disclaimer in the documentation
17c120c564SAndrew Turner * and/or other materials provided with the distribution.
18c120c564SAndrew Turner *
19c120c564SAndrew Turner * 3. Neither the name of the copyright holder nor the names of its contributors
20c120c564SAndrew Turner * may be used to endorse or promote products derived from this software without
21c120c564SAndrew Turner * specific prior written permission.
22c120c564SAndrew Turner *
23c120c564SAndrew Turner * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
24c120c564SAndrew Turner * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25c120c564SAndrew Turner * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26c120c564SAndrew Turner * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27c120c564SAndrew Turner * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28c120c564SAndrew Turner * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29c120c564SAndrew Turner * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30c120c564SAndrew Turner * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31c120c564SAndrew Turner * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32c120c564SAndrew Turner * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33c120c564SAndrew Turner */
34c120c564SAndrew Turner
35c120c564SAndrew Turner #ifndef ARM_OCSD_DCD_MNGR_H_INCLUDED
36c120c564SAndrew Turner #define ARM_OCSD_DCD_MNGR_H_INCLUDED
37c120c564SAndrew Turner
38c120c564SAndrew Turner #include "opencsd/ocsd_if_types.h"
39c120c564SAndrew Turner #include "common/ocsd_dcd_mngr_i.h"
40c120c564SAndrew Turner #include "common/ocsd_lib_dcd_register.h"
41c120c564SAndrew Turner #include "common/trc_pkt_decode_base.h"
42c120c564SAndrew Turner #include "common/trc_pkt_proc_base.h"
43c120c564SAndrew Turner
44c120c564SAndrew Turner template <class P, class Pt, class Pc>
45c120c564SAndrew Turner class DecoderMngrBase : public IDecoderMngr
46c120c564SAndrew Turner {
47c120c564SAndrew Turner public:
48c120c564SAndrew Turner DecoderMngrBase(const std::string &decoderTypeName, ocsd_trace_protocol_t builtInProtocol);
~DecoderMngrBase()49c120c564SAndrew Turner virtual ~DecoderMngrBase() {};
50c120c564SAndrew Turner
51c120c564SAndrew Turner // create decoder interface.
52c120c564SAndrew Turner virtual ocsd_err_t createDecoder(const int create_flags, const int instID, const CSConfig *p_config, TraceComponent **p_component);
53c120c564SAndrew Turner virtual ocsd_err_t destroyDecoder(TraceComponent *p_component);
54c120c564SAndrew Turner
getProtocolType()55c120c564SAndrew Turner virtual const ocsd_trace_protocol_t getProtocolType() const { return m_builtInProtocol; }
56c120c564SAndrew Turner
57c120c564SAndrew Turner // common
58c120c564SAndrew Turner virtual ocsd_err_t attachErrorLogger(TraceComponent *pComponent, ITraceErrorLog *pIErrorLog);
59c120c564SAndrew Turner
60c120c564SAndrew Turner // pkt decoder
61c120c564SAndrew Turner virtual ocsd_err_t attachInstrDecoder(TraceComponent *pComponent, IInstrDecode *pIInstrDec);
62c120c564SAndrew Turner virtual ocsd_err_t attachMemAccessor(TraceComponent *pComponent, ITargetMemAccess *pMemAccessor);
63c120c564SAndrew Turner virtual ocsd_err_t attachOutputSink(TraceComponent *pComponent, ITrcGenElemIn *pOutSink);
64c120c564SAndrew Turner
65c120c564SAndrew Turner // pkt processor
66c120c564SAndrew Turner virtual ocsd_err_t attachPktMonitor(TraceComponent *pComponent, ITrcTypedBase *pPktRawDataMon);
67c120c564SAndrew Turner virtual ocsd_err_t attachPktIndexer(TraceComponent *pComponent, ITrcTypedBase *pPktIndexer);
68c120c564SAndrew Turner virtual ocsd_err_t attachPktSink(TraceComponent *pComponent, ITrcTypedBase *pPktDataInSink);
69c120c564SAndrew Turner
70c120c564SAndrew Turner // data input connection interface
71c120c564SAndrew Turner virtual ocsd_err_t getDataInputI(TraceComponent *pComponent, ITrcDataIn **ppDataIn);
72c120c564SAndrew Turner
73c120c564SAndrew Turner // generate a Config object from opaque config struct pointer.
74c120c564SAndrew Turner virtual ocsd_err_t createConfigFromDataStruct(CSConfig **pConfigBase, const void *pDataStruct);
75c120c564SAndrew Turner
76c120c564SAndrew Turner // implemented by decoder handler derived classes
77c120c564SAndrew Turner virtual TraceComponent *createPktProc(const bool useInstID, const int instID) = 0;
createPktDecode(const bool useInstID,const int instID)78c120c564SAndrew Turner virtual TraceComponent *createPktDecode(const bool useInstID, const int instID) { return 0; };
79c120c564SAndrew Turner virtual CSConfig *createConfig(const void *pDataStruct) = 0;
80c120c564SAndrew Turner
81c120c564SAndrew Turner
82c120c564SAndrew Turner private:
83*46e6e290SRuslan Bukin const ocsd_trace_protocol_t m_builtInProtocol; //!< Protocol ID if built in type.
84c120c564SAndrew Turner };
85c120c564SAndrew Turner
86c120c564SAndrew Turner template <class P, class Pt, class Pc>
DecoderMngrBase(const std::string & decoderTypeName,ocsd_trace_protocol_t builtInProtocol)87*46e6e290SRuslan Bukin DecoderMngrBase<P,Pt,Pc>::DecoderMngrBase(const std::string &decoderTypeName, ocsd_trace_protocol_t builtInProtocol) :
88*46e6e290SRuslan Bukin m_builtInProtocol(builtInProtocol)
89c120c564SAndrew Turner {
90c120c564SAndrew Turner OcsdLibDcdRegister *pDcdReg = OcsdLibDcdRegister::getDecoderRegister();
91c120c564SAndrew Turner if(pDcdReg)
92c120c564SAndrew Turner pDcdReg->registerDecoderTypeByName(decoderTypeName,this);
93c120c564SAndrew Turner }
94c120c564SAndrew Turner
95c120c564SAndrew Turner template <class P, class Pt, class Pc>
createDecoder(const int create_flags,const int instID,const CSConfig * pConfig,TraceComponent ** ppTrcComp)96c120c564SAndrew Turner ocsd_err_t DecoderMngrBase<P,Pt,Pc>::createDecoder(const int create_flags, const int instID, const CSConfig *pConfig, TraceComponent **ppTrcComp)
97c120c564SAndrew Turner {
98c120c564SAndrew Turner TraceComponent *pkt_proc = 0;
99c120c564SAndrew Turner TraceComponent *pkt_dcd = 0;
100c120c564SAndrew Turner bool bUseInstID = (create_flags & OCSD_CREATE_FLG_INST_ID) != 0;
101c120c564SAndrew Turner bool bDecoder = (create_flags & OCSD_CREATE_FLG_FULL_DECODER) != 0;
102c120c564SAndrew Turner bool bUnConfigured = (pConfig == 0);
103c120c564SAndrew Turner
104c120c564SAndrew Turner const Pc *pConf = dynamic_cast< const Pc * >(pConfig);
105c120c564SAndrew Turner
106c120c564SAndrew Turner // check inputs valid...
107c120c564SAndrew Turner if((pConf == 0) && !bUnConfigured)
108c120c564SAndrew Turner return OCSD_ERR_INVALID_PARAM_TYPE;
109c120c564SAndrew Turner
110c120c564SAndrew Turner if((create_flags & (OCSD_CREATE_FLG_PACKET_PROC | OCSD_CREATE_FLG_FULL_DECODER)) == 0)
111c120c564SAndrew Turner return OCSD_ERR_INVALID_PARAM_VAL;
112c120c564SAndrew Turner
113c120c564SAndrew Turner // always need a packet processor
114c120c564SAndrew Turner pkt_proc = createPktProc(bUseInstID, instID);
115c120c564SAndrew Turner if(!pkt_proc)
116c120c564SAndrew Turner return OCSD_ERR_MEM;
117c120c564SAndrew Turner
118b6aadd18SAndrew Turner // set the op mode flags
119b6aadd18SAndrew Turner pkt_proc->setComponentOpMode(create_flags & (OCSD_OPFLG_COMP_MODE_MASK | OCSD_OPFLG_PKTPROC_COMMON));
120b6aadd18SAndrew Turner
121c120c564SAndrew Turner // set the configuration
122c120c564SAndrew Turner TrcPktProcBase<P,Pt,Pc> *pProcBase = dynamic_cast< TrcPktProcBase<P,Pt,Pc> *>(pkt_proc);
123c120c564SAndrew Turner if(pProcBase == 0)
124c120c564SAndrew Turner return OCSD_ERR_INVALID_PARAM_TYPE;
125c120c564SAndrew Turner
126c120c564SAndrew Turner if(!bUnConfigured)
127c120c564SAndrew Turner pProcBase->setProtocolConfig(pConf);
128c120c564SAndrew Turner
129c120c564SAndrew Turner *ppTrcComp = pkt_proc;
130c120c564SAndrew Turner
131c120c564SAndrew Turner // may need a packet decoder
132c120c564SAndrew Turner if(bDecoder)
133c120c564SAndrew Turner {
134c120c564SAndrew Turner // create the decoder
135c120c564SAndrew Turner pkt_dcd = createPktDecode(bUseInstID, instID);
136c120c564SAndrew Turner if(!pkt_dcd)
137c120c564SAndrew Turner return OCSD_ERR_MEM;
138c120c564SAndrew Turner
139b6aadd18SAndrew Turner // set the op mode flags
140b6aadd18SAndrew Turner pkt_dcd->setComponentOpMode(create_flags & (OCSD_OPFLG_COMP_MODE_MASK | OCSD_OPFLG_PKTDEC_COMMON));
141b6aadd18SAndrew Turner
142c120c564SAndrew Turner // get the decoder base
143c120c564SAndrew Turner TrcPktDecodeBase<P,Pc> *pBase = dynamic_cast< TrcPktDecodeBase<P,Pc> *>(pkt_dcd);
144c120c564SAndrew Turner if(pBase == 0)
145c120c564SAndrew Turner return OCSD_ERR_INVALID_PARAM_TYPE;
146c120c564SAndrew Turner
147c120c564SAndrew Turner if(!bUnConfigured)
148c120c564SAndrew Turner pBase->setProtocolConfig(pConf);
149c120c564SAndrew Turner
150c120c564SAndrew Turner // associate decoder with packet processor
151c120c564SAndrew Turner // -> this means a TraceComponent with an associated component is a packet decoder.
152c120c564SAndrew Turner // the associated component is the connected packet processor.
153c120c564SAndrew Turner pkt_dcd->setAssocComponent(pkt_proc);
154c120c564SAndrew Turner
155c120c564SAndrew Turner // connect packet processor and decoder
156c120c564SAndrew Turner pProcBase->getPacketOutAttachPt()->attach(pBase);
157c120c564SAndrew Turner
158c120c564SAndrew Turner *ppTrcComp = pkt_dcd;
159c120c564SAndrew Turner }
160c120c564SAndrew Turner return OCSD_OK;
161c120c564SAndrew Turner }
162c120c564SAndrew Turner
163c120c564SAndrew Turner template <class P, class Pt, class Pc>
destroyDecoder(TraceComponent * pComponent)164c120c564SAndrew Turner ocsd_err_t DecoderMngrBase<P,Pt,Pc>::destroyDecoder(TraceComponent *pComponent)
165c120c564SAndrew Turner {
166c120c564SAndrew Turner if(pComponent->getAssocComponent() != 0)
167c120c564SAndrew Turner delete pComponent->getAssocComponent();
168c120c564SAndrew Turner delete pComponent;
169c120c564SAndrew Turner return OCSD_OK;
170c120c564SAndrew Turner }
171c120c564SAndrew Turner
172c120c564SAndrew Turner template <class P, class Pt, class Pc>
attachErrorLogger(TraceComponent * pComponent,ITraceErrorLog * pIErrorLog)173c120c564SAndrew Turner ocsd_err_t DecoderMngrBase<P,Pt,Pc>::attachErrorLogger(TraceComponent *pComponent, ITraceErrorLog *pIErrorLog)
174c120c564SAndrew Turner {
175c120c564SAndrew Turner return pComponent->getErrorLogAttachPt()->replace_first(pIErrorLog);
176c120c564SAndrew Turner }
177c120c564SAndrew Turner
178c120c564SAndrew Turner template <class P, class Pt, class Pc>
attachInstrDecoder(TraceComponent * pComponent,IInstrDecode * pIInstrDec)179c120c564SAndrew Turner ocsd_err_t DecoderMngrBase<P,Pt,Pc>::attachInstrDecoder(TraceComponent *pComponent, IInstrDecode *pIInstrDec)
180c120c564SAndrew Turner {
181c120c564SAndrew Turner ocsd_err_t err = OCSD_ERR_DCD_INTERFACE_UNUSED;
182c120c564SAndrew Turner
183c120c564SAndrew Turner if(pComponent->getAssocComponent() == 0) // no associated component - so this is a packet processor
184c120c564SAndrew Turner return OCSD_ERR_INVALID_PARAM_TYPE;
185c120c564SAndrew Turner
186c120c564SAndrew Turner TrcPktDecodeI *pDcdI = dynamic_cast< TrcPktDecodeI * >(pComponent);
187c120c564SAndrew Turner if(pDcdI == 0)
188c120c564SAndrew Turner return OCSD_ERR_INVALID_PARAM_TYPE;
189c120c564SAndrew Turner
190c120c564SAndrew Turner if(pDcdI->getUsesIDecode())
191c120c564SAndrew Turner err = pDcdI->getInstrDecodeAttachPt()->replace_first(pIInstrDec);
192c120c564SAndrew Turner
193c120c564SAndrew Turner return err;
194c120c564SAndrew Turner }
195c120c564SAndrew Turner
196c120c564SAndrew Turner template <class P, class Pt, class Pc>
attachMemAccessor(TraceComponent * pComponent,ITargetMemAccess * pMemAccessor)197c120c564SAndrew Turner ocsd_err_t DecoderMngrBase<P,Pt,Pc>::attachMemAccessor(TraceComponent *pComponent, ITargetMemAccess *pMemAccessor)
198c120c564SAndrew Turner {
199c120c564SAndrew Turner ocsd_err_t err = OCSD_ERR_DCD_INTERFACE_UNUSED;
200c120c564SAndrew Turner
201c120c564SAndrew Turner if(pComponent->getAssocComponent() == 0) // no associated component - so this is a packet processor
202c120c564SAndrew Turner return OCSD_ERR_INVALID_PARAM_TYPE;
203c120c564SAndrew Turner
204c120c564SAndrew Turner TrcPktDecodeI *pDcdI = dynamic_cast< TrcPktDecodeI * >(pComponent);
205c120c564SAndrew Turner if(pDcdI == 0)
206c120c564SAndrew Turner return OCSD_ERR_INVALID_PARAM_TYPE;
207c120c564SAndrew Turner
208c120c564SAndrew Turner if(pDcdI->getUsesMemAccess())
209c120c564SAndrew Turner err = pDcdI->getMemoryAccessAttachPt()->replace_first(pMemAccessor);
210c120c564SAndrew Turner
211c120c564SAndrew Turner return err;
212c120c564SAndrew Turner }
213c120c564SAndrew Turner
214c120c564SAndrew Turner template <class P, class Pt, class Pc>
attachOutputSink(TraceComponent * pComponent,ITrcGenElemIn * pOutSink)215c120c564SAndrew Turner ocsd_err_t DecoderMngrBase<P,Pt,Pc>::attachOutputSink(TraceComponent *pComponent, ITrcGenElemIn *pOutSink)
216c120c564SAndrew Turner {
217c120c564SAndrew Turner ocsd_err_t err = OCSD_ERR_INVALID_PARAM_TYPE;
218c120c564SAndrew Turner
219c120c564SAndrew Turner if(pComponent->getAssocComponent() == 0) // no associated component - so this is a packet processor
220c120c564SAndrew Turner return err;
221c120c564SAndrew Turner
222c120c564SAndrew Turner TrcPktDecodeI *pDcdI = dynamic_cast< TrcPktDecodeI * >(pComponent);
223c120c564SAndrew Turner if(pDcdI == 0)
224c120c564SAndrew Turner return OCSD_ERR_INVALID_PARAM_TYPE;
225c120c564SAndrew Turner
226c120c564SAndrew Turner err = pDcdI->getTraceElemOutAttachPt()->replace_first(pOutSink);
227c120c564SAndrew Turner
228c120c564SAndrew Turner return err;
229c120c564SAndrew Turner }
230c120c564SAndrew Turner
231c120c564SAndrew Turner template <class P, class Pt, class Pc>
getDataInputI(TraceComponent * pComponent,ITrcDataIn ** ppDataIn)232c120c564SAndrew Turner ocsd_err_t DecoderMngrBase<P,Pt,Pc>::getDataInputI(TraceComponent *pComponent, ITrcDataIn **ppDataIn)
233c120c564SAndrew Turner {
234c120c564SAndrew Turner // find the packet processor
235c120c564SAndrew Turner TraceComponent *pPktProc = pComponent;
236c120c564SAndrew Turner if(pComponent->getAssocComponent() != 0)
237c120c564SAndrew Turner pPktProc = pComponent->getAssocComponent();
238c120c564SAndrew Turner
239c120c564SAndrew Turner TrcPktProcI *pPPI = dynamic_cast< TrcPktProcI * >(pPktProc);
240c120c564SAndrew Turner if(pPPI == 0)
241c120c564SAndrew Turner return OCSD_ERR_INVALID_PARAM_TYPE;
242c120c564SAndrew Turner
243c120c564SAndrew Turner *ppDataIn = pPPI;
244c120c564SAndrew Turner
245c120c564SAndrew Turner return OCSD_OK;
246c120c564SAndrew Turner }
247c120c564SAndrew Turner
248c120c564SAndrew Turner template <class P, class Pt, class Pc>
attachPktMonitor(TraceComponent * pComponent,ITrcTypedBase * pPktRawDataMon)249c120c564SAndrew Turner ocsd_err_t DecoderMngrBase<P,Pt,Pc>::attachPktMonitor(TraceComponent *pComponent, ITrcTypedBase *pPktRawDataMon)
250c120c564SAndrew Turner {
251c120c564SAndrew Turner // find the packet processor
252c120c564SAndrew Turner TraceComponent *pPktProc = pComponent;
253c120c564SAndrew Turner if(pComponent->getAssocComponent() != 0)
254c120c564SAndrew Turner pPktProc = pComponent->getAssocComponent();
255c120c564SAndrew Turner
256c120c564SAndrew Turner // get the packet processor
257c120c564SAndrew Turner TrcPktProcBase<P,Pt,Pc> *pPktProcBase = dynamic_cast< TrcPktProcBase<P,Pt,Pc> * >(pPktProc);
258c120c564SAndrew Turner if(pPktProcBase == 0)
259c120c564SAndrew Turner return OCSD_ERR_INVALID_PARAM_TYPE;
260c120c564SAndrew Turner
261c120c564SAndrew Turner // get the interface
262c120c564SAndrew Turner IPktRawDataMon<P> *p_If = dynamic_cast< IPktRawDataMon<P> * >(pPktRawDataMon);
263c120c564SAndrew Turner if(p_If == 0)
264c120c564SAndrew Turner return OCSD_ERR_INVALID_PARAM_TYPE;
265c120c564SAndrew Turner
266c120c564SAndrew Turner return pPktProcBase->getRawPacketMonAttachPt()->replace_first(p_If);
267c120c564SAndrew Turner }
268c120c564SAndrew Turner
269c120c564SAndrew Turner template <class P, class Pt, class Pc>
attachPktIndexer(TraceComponent * pComponent,ITrcTypedBase * pPktIndexer)270c120c564SAndrew Turner ocsd_err_t DecoderMngrBase<P,Pt,Pc>::attachPktIndexer(TraceComponent *pComponent, ITrcTypedBase *pPktIndexer)
271c120c564SAndrew Turner {
272c120c564SAndrew Turner // find the packet processor
273c120c564SAndrew Turner TraceComponent *pPktProc = pComponent;
274c120c564SAndrew Turner if(pComponent->getAssocComponent() != 0)
275c120c564SAndrew Turner pPktProc = pComponent->getAssocComponent();
276c120c564SAndrew Turner
277c120c564SAndrew Turner // get the packet processor
278c120c564SAndrew Turner TrcPktProcBase<P,Pt,Pc> *pPktProcBase = dynamic_cast< TrcPktProcBase<P,Pt,Pc> * >(pPktProc);
279c120c564SAndrew Turner if(pPktProcBase == 0)
280c120c564SAndrew Turner return OCSD_ERR_INVALID_PARAM_TYPE;
281c120c564SAndrew Turner
282c120c564SAndrew Turner // get the interface
283c120c564SAndrew Turner ITrcPktIndexer<Pt> *p_If = dynamic_cast< ITrcPktIndexer<Pt> * >(pPktIndexer);
284c120c564SAndrew Turner if(p_If == 0)
285c120c564SAndrew Turner return OCSD_ERR_INVALID_PARAM_TYPE;
286c120c564SAndrew Turner
287c120c564SAndrew Turner return pPktProcBase->getTraceIDIndexerAttachPt()->replace_first(p_If);
288c120c564SAndrew Turner }
289c120c564SAndrew Turner
290c120c564SAndrew Turner template <class P, class Pt, class Pc>
attachPktSink(TraceComponent * pComponent,ITrcTypedBase * pPktDataInSink)291c120c564SAndrew Turner ocsd_err_t DecoderMngrBase<P,Pt,Pc>::attachPktSink(TraceComponent *pComponent, ITrcTypedBase *pPktDataInSink)
292c120c564SAndrew Turner {
293c120c564SAndrew Turner // must be solo packet processor
294c120c564SAndrew Turner if(pComponent->getAssocComponent() != 0)
295c120c564SAndrew Turner return OCSD_ERR_INVALID_PARAM_TYPE;
296c120c564SAndrew Turner
297c120c564SAndrew Turner // interface must be the correct one.
298c120c564SAndrew Turner IPktDataIn<P> *pkt_in_i = dynamic_cast< IPktDataIn<P> * >(pPktDataInSink);
299c120c564SAndrew Turner if(pkt_in_i == 0)
300c120c564SAndrew Turner return OCSD_ERR_INVALID_PARAM_TYPE;
301c120c564SAndrew Turner
302c120c564SAndrew Turner // get the packet processor
303c120c564SAndrew Turner TrcPktProcBase<P,Pt,Pc> *pPktProcBase = dynamic_cast< TrcPktProcBase<P,Pt,Pc> * >(pComponent);
304c120c564SAndrew Turner if(pPktProcBase == 0)
305c120c564SAndrew Turner return OCSD_ERR_INVALID_PARAM_TYPE;
306c120c564SAndrew Turner
307c120c564SAndrew Turner // attach
308c120c564SAndrew Turner return pPktProcBase->getPacketOutAttachPt()->replace_first(pkt_in_i);
309c120c564SAndrew Turner }
310c120c564SAndrew Turner
311c120c564SAndrew Turner template <class P, class Pt, class Pc>
createConfigFromDataStruct(CSConfig ** pConfigBase,const void * pDataStruct)312c120c564SAndrew Turner ocsd_err_t DecoderMngrBase<P,Pt,Pc>::createConfigFromDataStruct(CSConfig **pConfigBase, const void *pDataStruct)
313c120c564SAndrew Turner {
314c120c564SAndrew Turner CSConfig *pConfig = createConfig(pDataStruct);
315c120c564SAndrew Turner if(!pConfig)
316c120c564SAndrew Turner return OCSD_ERR_MEM;
317c120c564SAndrew Turner *pConfigBase = pConfig;
318c120c564SAndrew Turner return OCSD_OK;
319c120c564SAndrew Turner }
320c120c564SAndrew Turner
321c120c564SAndrew Turner /****************************************************************************************************/
322c120c564SAndrew Turner /* Full decoder / packet process pair, templated base for creating decoder objects */
323c120c564SAndrew Turner /****************************************************************************************************/
324c120c564SAndrew Turner
325c120c564SAndrew Turner template< class P, // Packet class.
326c120c564SAndrew Turner class Pt, // Packet enum type ID.
327c120c564SAndrew Turner class Pc, // Processor config class.
328c120c564SAndrew Turner class PcSt, // Processor config struct type
329c120c564SAndrew Turner class PktProc, // Packet processor class.
330c120c564SAndrew Turner class PktDcd> // Packet decoder class.
331c120c564SAndrew Turner class DecodeMngrFullDcd : public DecoderMngrBase<P,Pt,Pc>
332c120c564SAndrew Turner {
333c120c564SAndrew Turner public:
DecodeMngrFullDcd(const std::string & name,ocsd_trace_protocol_t builtInProtocol)334c120c564SAndrew Turner DecodeMngrFullDcd (const std::string &name, ocsd_trace_protocol_t builtInProtocol)
335c120c564SAndrew Turner : DecoderMngrBase<P,Pt,Pc>(name,builtInProtocol) {};
336c120c564SAndrew Turner
~DecodeMngrFullDcd()337c120c564SAndrew Turner virtual ~DecodeMngrFullDcd() {};
338c120c564SAndrew Turner
createPktProc(const bool useInstID,const int instID)339c120c564SAndrew Turner virtual TraceComponent *createPktProc(const bool useInstID, const int instID)
340c120c564SAndrew Turner {
341c120c564SAndrew Turner TraceComponent *pComp;
342c120c564SAndrew Turner if(useInstID)
343c120c564SAndrew Turner pComp = new (std::nothrow) PktProc(instID);
344c120c564SAndrew Turner else
345c120c564SAndrew Turner pComp = new (std::nothrow) PktProc();
346c120c564SAndrew Turner return pComp;
347c120c564SAndrew Turner }
348c120c564SAndrew Turner
createPktDecode(const bool useInstID,const int instID)349c120c564SAndrew Turner virtual TraceComponent *createPktDecode(const bool useInstID, const int instID)
350c120c564SAndrew Turner {
351c120c564SAndrew Turner TraceComponent *pComp;
352c120c564SAndrew Turner if(useInstID)
353c120c564SAndrew Turner pComp = new (std::nothrow)PktDcd(instID);
354c120c564SAndrew Turner else
355c120c564SAndrew Turner pComp = new (std::nothrow)PktDcd();
356c120c564SAndrew Turner return pComp;
357c120c564SAndrew Turner }
358c120c564SAndrew Turner
createConfig(const void * pDataStruct)359c120c564SAndrew Turner virtual CSConfig *createConfig(const void *pDataStruct)
360c120c564SAndrew Turner {
361c120c564SAndrew Turner return new (std::nothrow) Pc((PcSt *)pDataStruct);
362c120c564SAndrew Turner }
363c120c564SAndrew Turner };
364c120c564SAndrew Turner
365*46e6e290SRuslan Bukin /* full decode - extended config object - base + derived. */
366*46e6e290SRuslan Bukin template< class P, // Packet class.
367*46e6e290SRuslan Bukin class Pt, // Packet enum type ID.
368*46e6e290SRuslan Bukin class Pc, // Processor config base class.
369*46e6e290SRuslan Bukin class PcEx, // Processor config derived class
370*46e6e290SRuslan Bukin class PcSt, // Processor config struct type
371*46e6e290SRuslan Bukin class PktProc, // Packet processor class.
372*46e6e290SRuslan Bukin class PktDcd> // Packet decoder class.
373*46e6e290SRuslan Bukin class DecodeMngrFullDcdExCfg : public DecoderMngrBase<P, Pt, Pc>
374*46e6e290SRuslan Bukin {
375*46e6e290SRuslan Bukin public:
DecodeMngrFullDcdExCfg(const std::string & name,ocsd_trace_protocol_t builtInProtocol)376*46e6e290SRuslan Bukin DecodeMngrFullDcdExCfg(const std::string &name, ocsd_trace_protocol_t builtInProtocol)
377*46e6e290SRuslan Bukin : DecoderMngrBase<P, Pt, Pc>(name, builtInProtocol) {};
378*46e6e290SRuslan Bukin
~DecodeMngrFullDcdExCfg()379*46e6e290SRuslan Bukin virtual ~DecodeMngrFullDcdExCfg() {};
380*46e6e290SRuslan Bukin
createPktProc(const bool useInstID,const int instID)381*46e6e290SRuslan Bukin virtual TraceComponent *createPktProc(const bool useInstID, const int instID)
382*46e6e290SRuslan Bukin {
383*46e6e290SRuslan Bukin TraceComponent *pComp;
384*46e6e290SRuslan Bukin if (useInstID)
385*46e6e290SRuslan Bukin pComp = new (std::nothrow) PktProc(instID);
386*46e6e290SRuslan Bukin else
387*46e6e290SRuslan Bukin pComp = new (std::nothrow) PktProc();
388*46e6e290SRuslan Bukin return pComp;
389*46e6e290SRuslan Bukin }
390*46e6e290SRuslan Bukin
createPktDecode(const bool useInstID,const int instID)391*46e6e290SRuslan Bukin virtual TraceComponent *createPktDecode(const bool useInstID, const int instID)
392*46e6e290SRuslan Bukin {
393*46e6e290SRuslan Bukin TraceComponent *pComp;
394*46e6e290SRuslan Bukin if (useInstID)
395*46e6e290SRuslan Bukin pComp = new (std::nothrow)PktDcd(instID);
396*46e6e290SRuslan Bukin else
397*46e6e290SRuslan Bukin pComp = new (std::nothrow)PktDcd();
398*46e6e290SRuslan Bukin return pComp;
399*46e6e290SRuslan Bukin }
400*46e6e290SRuslan Bukin
createConfig(const void * pDataStruct)401*46e6e290SRuslan Bukin virtual CSConfig *createConfig(const void *pDataStruct)
402*46e6e290SRuslan Bukin {
403*46e6e290SRuslan Bukin return new (std::nothrow) PcEx((PcSt *)pDataStruct);
404*46e6e290SRuslan Bukin }
405*46e6e290SRuslan Bukin };
406*46e6e290SRuslan Bukin
407*46e6e290SRuslan Bukin
408c120c564SAndrew Turner /****************************************************************************************************/
409c120c564SAndrew Turner /* Packet processor only, templated base for creating decoder objects */
410c120c564SAndrew Turner /****************************************************************************************************/
411c120c564SAndrew Turner
412c120c564SAndrew Turner template< class P, // Packet class.
413c120c564SAndrew Turner class Pt, // Packet enum type ID.
414c120c564SAndrew Turner class Pc, // Processor config class.
415c120c564SAndrew Turner class PcSt, // Processor config struct type
416c120c564SAndrew Turner class PktProc> // Packet processor class.
417c120c564SAndrew Turner class DecodeMngrPktProc : public DecoderMngrBase<P,Pt,Pc>
418c120c564SAndrew Turner {
419c120c564SAndrew Turner public:
DecodeMngrPktProc(const std::string & name,ocsd_trace_protocol_t builtInProtocol)420c120c564SAndrew Turner DecodeMngrPktProc (const std::string &name, ocsd_trace_protocol_t builtInProtocol)
421c120c564SAndrew Turner : DecoderMngrBase<P,Pt,Pc>(name,builtInProtocol) {};
422c120c564SAndrew Turner
~DecodeMngrPktProc()423c120c564SAndrew Turner virtual ~DecodeMngrPktProc() {};
424c120c564SAndrew Turner
createPktProc(const bool useInstID,const int instID)425c120c564SAndrew Turner virtual TraceComponent *createPktProc(const bool useInstID, const int instID)
426c120c564SAndrew Turner {
427c120c564SAndrew Turner TraceComponent *pComp;
428c120c564SAndrew Turner if(useInstID)
429c120c564SAndrew Turner pComp = new (std::nothrow) PktProc(instID);
430c120c564SAndrew Turner else
431c120c564SAndrew Turner pComp = new (std::nothrow) PktProc();
432c120c564SAndrew Turner return pComp;
433c120c564SAndrew Turner }
434c120c564SAndrew Turner
createConfig(const void * pDataStruct)435c120c564SAndrew Turner virtual CSConfig *createConfig(const void *pDataStruct)
436c120c564SAndrew Turner {
437c120c564SAndrew Turner return new (std::nothrow) Pc((PcSt *)pDataStruct);
438c120c564SAndrew Turner }
439c120c564SAndrew Turner };
440c120c564SAndrew Turner
441c120c564SAndrew Turner
442c120c564SAndrew Turner
443c120c564SAndrew Turner #endif // ARM_OCSD_DCD_MNGR_H_INCLUDED
444c120c564SAndrew Turner
445c120c564SAndrew Turner /* End of File ocsd_dcd_mngr.h */
446