diff options
author | Mike Leach <mike.leach@linaro.org> | 2022-10-27 16:59:36 +0100 |
---|---|---|
committer | Mike Leach <mike.leach@linaro.org> | 2022-10-31 23:07:14 +0000 |
commit | 5a3a235359b0ed1ec25a12e84cec38fef08b1d6c (patch) | |
tree | d034a19bfb58c883c1af4debb5f074369857751e | |
parent | ca132fc5059a0ba30356fe12856d5630d1ba9702 (diff) | |
download | OpenCSD-5a3a235359b0ed1ec25a12e84cec38fef08b1d6c.tar.gz |
opencsd: frame demux: Fix missing errors on incorrect config flags
Currently setting incorrect configuration flags on initialising the decode
tree for the demux formatter does not result in error messages being seen
Fix adjusts the demux module to split init and configure to allow attachement
of logger before configure.
Also reversed the priority of HSYNC and FSYNC alignment values.
Always 2 byte multiples on HSYNC or HSYNC + FSYNC, 4 byte if FSYNC only
Signed-off-by: Mike Leach <mike.leach@linaro.org>
-rw-r--r-- | decoder/include/common/trc_frame_deformatter.h | 3 | ||||
-rw-r--r-- | decoder/source/ocsd_dcd_tree.cpp | 12 | ||||
-rw-r--r-- | decoder/source/trc_frame_deformatter.cpp | 32 |
3 files changed, 33 insertions, 14 deletions
diff --git a/decoder/include/common/trc_frame_deformatter.h b/decoder/include/common/trc_frame_deformatter.h index b6476a2..cb2960f 100644 --- a/decoder/include/common/trc_frame_deformatter.h +++ b/decoder/include/common/trc_frame_deformatter.h @@ -73,6 +73,9 @@ public: componentAttachPt<ITraceErrorLog> *getErrLogAttachPt(); + /* init decoder implementation object */ + ocsd_err_t Init(); + /* configuration - set operational mode for incoming stream (has FSYNCS etc) */ ocsd_err_t Configure(uint32_t cfg_flags); const uint32_t getConfigFlags() const; diff --git a/decoder/source/ocsd_dcd_tree.cpp b/decoder/source/ocsd_dcd_tree.cpp index b423f7d..8e29269 100644 --- a/decoder/source/ocsd_dcd_tree.cpp +++ b/decoder/source/ocsd_dcd_tree.cpp @@ -590,7 +590,7 @@ DecodeTreeElement *DecodeTree::getNextElement(uint8_t &elemID) bool DecodeTree::initialise(const ocsd_dcd_tree_src_t type, uint32_t formatterCfgFlags) { - bool initOK = true; + ocsd_err_t err; m_dcd_tree_type = type; if(type == OCSD_TRC_SRC_FRAME_FORMATTED) { @@ -598,15 +598,19 @@ bool DecodeTree::initialise(const ocsd_dcd_tree_src_t type, uint32_t formatterCf m_frame_deformatter_root = new (std::nothrow) TraceFormatterFrameDecoder(); if(m_frame_deformatter_root) { - m_frame_deformatter_root->Configure(formatterCfgFlags); + if (m_frame_deformatter_root->Init() != OCSD_OK) + return false; m_frame_deformatter_root->getErrLogAttachPt()->attach(DecodeTree::s_i_error_logger); + err = m_frame_deformatter_root->Configure(formatterCfgFlags); + if (err != OCSD_OK) + return false; m_i_decoder_root = dynamic_cast<ITrcDataIn*>(m_frame_deformatter_root); m_frame_deformatter_root->SetDemuxStatsBlock(&m_demux_stats); } else - initOK = false; + return false; } - return initOK; + return true; } void DecodeTree::setSingleRoot(TrcPktProcI *pComp) diff --git a/decoder/source/trc_frame_deformatter.cpp b/decoder/source/trc_frame_deformatter.cpp index dc12e3f..76d64a6 100644 --- a/decoder/source/trc_frame_deformatter.cpp +++ b/decoder/source/trc_frame_deformatter.cpp @@ -325,12 +325,18 @@ ocsd_err_t TraceFmtDcdImpl::DecodeConfigure(uint32_t flags) } else { + // alightment is the multiple of bytes the buffer size must be. m_cfgFlags = flags; + + // using memory aligned buffers, the formatter always outputs 16 byte frames so enforce + // this on the input m_alignment = 16; - if(flags & OCSD_DFRMTR_HAS_FSYNCS) - m_alignment = 4; - else if(flags & OCSD_DFRMTR_HAS_HSYNCS) + // if we have HSYNCS then always align to 2 byte buffers + if(flags & OCSD_DFRMTR_HAS_HSYNCS) m_alignment = 2; + // otherwise FSYNCS only can have 4 byte aligned buffers. + else if(flags & OCSD_DFRMTR_HAS_FSYNCS) + m_alignment = 4; } return err; } @@ -866,21 +872,27 @@ componentAttachPt<ITraceErrorLog> *TraceFormatterFrameDecoder::getErrLogAttachPt return (m_pDecoder != 0) ? m_pDecoder->getErrorLogAttachPt() : 0; } -/* configuration - set operational mode for incoming stream (has FSYNCS etc) */ -ocsd_err_t TraceFormatterFrameDecoder::Configure(uint32_t cfg_flags) +ocsd_err_t TraceFormatterFrameDecoder::Init() { - if(!m_pDecoder) - { - if(m_instNum >= 0) + if (!m_pDecoder) + { + if (m_instNum >= 0) m_pDecoder = new (std::nothrow) TraceFmtDcdImpl(m_instNum); else m_pDecoder = new (std::nothrow) TraceFmtDcdImpl(); - if(!m_pDecoder) return OCSD_ERR_MEM; + if (!m_pDecoder) return OCSD_ERR_MEM; } - m_pDecoder->DecodeConfigure(cfg_flags); return OCSD_OK; } +/* configuration - set operational mode for incoming stream (has FSYNCS etc) */ +ocsd_err_t TraceFormatterFrameDecoder::Configure(uint32_t cfg_flags) +{ + if (!m_pDecoder) + return OCSD_ERR_NOT_INIT; + return m_pDecoder->DecodeConfigure(cfg_flags); +} + const uint32_t TraceFormatterFrameDecoder::getConfigFlags() const { uint32_t flags = 0; |