OpenCSD - CoreSight Trace Decode Library 1.8.3
Loading...
Searching...
No Matches
cs_frame_mux_data.h
Go to the documentation of this file.
1
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#ifndef ARM_CS_FRAME_MUX_DATA_H_INCLUDED
36#define ARM_CS_FRAME_MUX_DATA_H_INCLUDED
37
38
39#include <cstdio>
40#include <inttypes.h>
41#include <vector>
42
44{
45public:
48
49
50 void initMux(const size_t frame_capacity = 16); // initialise the muxer state with initial capacity for frames
51
63 int muxInData(const uint8_t* in_data, const uint32_t in_size, const uint8_t in_CSID, const bool padEnd);
64
65 /* extract complete frames into output buffer. Removes these frames from the current frame vector
66 * return bytes written to input buffer.
67 */
68 int extractFrames(uint8_t* out_frame_buffer, const uint32_t out_size);
69
70 /* true if an incomplete frame exists */
71 const bool hasIncompleteFrame() const { return (bool)(curr_frame_idx != 0); };
72
73 /* number of complete frames in the buffer */
74 const int numFrames() const { return ((int)cs_frames.size() / frame_size_bytes); };
75
76 /* direct access to frame buffer and size */
77 const uint8_t* getFrameBuffer() { return cs_frames.data(); };
78 size_t getFrameBufferSize() { return cs_frames.size(); };
79 void clearFrames(int nFrames); // remove copied frames
80
81
82private:
83 void copyCurrFrameToStack(); // copy the completed current frame to the frame stack
84 void setCSIDByte(const int frame_idx, const uint8_t newCSID, const bool nextDataNewID = true);
85 void padCurrFrame();
86
87 static const int frame_size_bytes = 16;
88
89 std::vector<uint8_t> cs_frames; // completed frame data
90 int frames_since_id; // coutn of frames since last ID
91 uint8_t curr_frame[frame_size_bytes]; // the current in progress frame.
92 int curr_frame_idx; // index into current frame for the next data/id value
93 uint8_t curr_CSID; // current CSID for the muxer
94};
95
96#endif // ARM_CS_FRAME_MUX_DATA_H_INCLUDED
const bool hasIncompleteFrame() const
size_t getFrameBufferSize()
const int numFrames() const
void clearFrames(int nFrames)
int extractFrames(uint8_t *out_frame_buffer, const uint32_t out_size)
const uint8_t * getFrameBuffer()
void initMux(const size_t frame_capacity=16)
int muxInData(const uint8_t *in_data, const uint32_t in_size, const uint8_t in_CSID, const bool padEnd)