62
|
1 |
// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "Symbian Foundation License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// Trace Core
|
|
15 |
//
|
|
16 |
|
|
17 |
#ifndef TRACECOREMEDIASWRITER_H_
|
|
18 |
#define TRACECOREMEDIASWRITER_H_
|
|
19 |
|
|
20 |
|
|
21 |
// Include files
|
|
22 |
#include "TraceCoreWriter.h"
|
|
23 |
|
|
24 |
|
|
25 |
// Forward declarations
|
|
26 |
class DTraceCoreMediaIf;
|
|
27 |
class TMediaSWriterStatistics;
|
|
28 |
|
|
29 |
/**
|
|
30 |
* Properties of a single trace
|
|
31 |
*/
|
|
32 |
class TTraceBuffer
|
|
33 |
{
|
|
34 |
public:
|
|
35 |
TTraceBuffer* iNext;
|
|
36 |
TUint8* iBuffer;
|
|
37 |
TUint16 iLength;
|
|
38 |
TUint16 iMissedBefore;
|
|
39 |
TUint8 iType;
|
|
40 |
};
|
|
41 |
|
|
42 |
|
|
43 |
/**
|
|
44 |
* Writer implementation, which uses the media interface to write data
|
|
45 |
*/
|
|
46 |
class DTraceCoreMediaSWriter : public DTraceCoreWriter
|
|
47 |
{
|
|
48 |
public:
|
|
49 |
|
|
50 |
/**
|
|
51 |
* Constructor
|
|
52 |
*/
|
|
53 |
IMPORT_C DTraceCoreMediaSWriter();
|
|
54 |
|
|
55 |
/**
|
|
56 |
* Destructor
|
|
57 |
*/
|
|
58 |
IMPORT_C ~DTraceCoreMediaSWriter();
|
|
59 |
|
|
60 |
/**
|
|
61 |
* Registers this writer to TraceCore
|
|
62 |
*/
|
|
63 |
IMPORT_C TInt Register();
|
|
64 |
|
|
65 |
/**
|
|
66 |
* Gets the number of traces allowed per second
|
|
67 |
*/
|
|
68 |
virtual TInt GetTraceFrequency() = 0;
|
|
69 |
|
|
70 |
/**
|
|
71 |
* Initializes a trace buffer
|
|
72 |
*
|
|
73 |
* @param aType the entry type
|
|
74 |
* @param aBuffer the buffer
|
|
75 |
*/
|
|
76 |
virtual void StartBuffer( TWriterEntryType aType, TTraceBuffer& aBuffer ) = 0;
|
|
77 |
|
|
78 |
/**
|
|
79 |
* Finishes a trace buffer
|
|
80 |
*
|
|
81 |
* @param aBuffer the buffer
|
|
82 |
* @return ETrue if trace can be 'dropped'
|
|
83 |
*/
|
|
84 |
virtual TBool EndBuffer( TTraceBuffer& aBuffer ) = 0;
|
|
85 |
|
|
86 |
private:
|
|
87 |
|
|
88 |
/**
|
|
89 |
* Starts an entry
|
|
90 |
*
|
|
91 |
* @return the entry ID that is passed to other Write-functions
|
|
92 |
*/
|
|
93 |
IMPORT_C TUint32 WriteStart( TWriterEntryType aType );
|
|
94 |
|
|
95 |
/**
|
|
96 |
* Ends an entry
|
|
97 |
*
|
|
98 |
* @param aEntryId the entry ID returned by WriteStart
|
|
99 |
*/
|
|
100 |
IMPORT_C void WriteEnd( TUint32 aEntryId );
|
|
101 |
|
|
102 |
/**
|
|
103 |
* Writes 8-bit data to given entry
|
|
104 |
*
|
|
105 |
* @param aEntryId the entry ID returned by WriteStart
|
|
106 |
* @param aData the trace data
|
|
107 |
*/
|
|
108 |
IMPORT_C void WriteData( TUint32 aEntryId, TUint8 aData );
|
|
109 |
|
|
110 |
/**
|
|
111 |
* Writes 16-bit data to given entry
|
|
112 |
*
|
|
113 |
* @param aEntryId the entry ID returned by WriteStart
|
|
114 |
* @param aData the trace data
|
|
115 |
*/
|
|
116 |
IMPORT_C void WriteData( TUint32 aEntryId, TUint16 aData );
|
|
117 |
|
|
118 |
/**
|
|
119 |
* Writes 32-bit data to given entry
|
|
120 |
*
|
|
121 |
* @param aEntryId the entry ID returned by WriteStart
|
|
122 |
* @param aData the trace data
|
|
123 |
*/
|
|
124 |
IMPORT_C void WriteData( TUint32 aEntryId, TUint32 aData );
|
|
125 |
|
|
126 |
/**
|
|
127 |
* DFC for sending data
|
|
128 |
*
|
|
129 |
* @param aMediaWriter the media writer
|
|
130 |
*/
|
|
131 |
static void SendDfc( TAny* aMediaWriter );
|
|
132 |
|
|
133 |
/**
|
|
134 |
* Called from the static function to send data
|
|
135 |
*/
|
|
136 |
void SendDfc();
|
|
137 |
|
|
138 |
/**
|
|
139 |
* Initializes the statistics
|
|
140 |
*/
|
|
141 |
TBool InitStatistics();
|
|
142 |
|
|
143 |
|
|
144 |
private:
|
|
145 |
|
|
146 |
/**
|
|
147 |
* Media interface for sending data
|
|
148 |
*/
|
|
149 |
DTraceCoreMediaIf* iMediaIf;
|
|
150 |
|
|
151 |
/**
|
|
152 |
* DFC for sending data
|
|
153 |
*/
|
|
154 |
TDfc iSendDfc;
|
|
155 |
|
|
156 |
/**
|
|
157 |
* Timer which is used to send traces
|
|
158 |
*/
|
|
159 |
TTickLink iSendTimer;
|
|
160 |
|
|
161 |
/**
|
|
162 |
* Flags which tells if the timer is active or not
|
|
163 |
*/
|
|
164 |
TBool iSendTimerActive;
|
|
165 |
|
|
166 |
/**
|
|
167 |
* Pointer to the list of free trace buffers
|
|
168 |
*/
|
|
169 |
TTraceBuffer* iFirstFreeBuffer;
|
|
170 |
|
|
171 |
/**
|
|
172 |
* Pointer to the next trace to be sent
|
|
173 |
*/
|
|
174 |
TTraceBuffer* iFirstReadyBuffer;
|
|
175 |
|
|
176 |
/**
|
|
177 |
* Pointer to the end of list where new traces are added
|
|
178 |
*/
|
|
179 |
TTraceBuffer* iLastReadyBuffer;
|
|
180 |
|
|
181 |
/**
|
|
182 |
* All trace buffers
|
|
183 |
*/
|
|
184 |
TTraceBuffer* iTraceBuffers;
|
|
185 |
|
|
186 |
/**
|
|
187 |
* Number of free buffers
|
|
188 |
*/
|
|
189 |
TUint32 iFreeBuffers;
|
|
190 |
|
|
191 |
/**
|
|
192 |
* Thread which sends data
|
|
193 |
*/
|
|
194 |
NThread* iSenderThread;
|
|
195 |
|
|
196 |
/**
|
|
197 |
* Timestamp of the last trace sent
|
|
198 |
*/
|
|
199 |
TUint32 iLastTraceSent;
|
|
200 |
|
|
201 |
/**
|
|
202 |
* Media writer statistics
|
|
203 |
*/
|
|
204 |
TMediaSWriterStatistics* iStatistics;
|
|
205 |
|
|
206 |
/**
|
|
207 |
* Number of FastCounter ticks between traces
|
|
208 |
*/
|
|
209 |
TInt iFastCounterBetweenTraces;
|
|
210 |
|
|
211 |
};
|
|
212 |
|
|
213 |
|
|
214 |
#endif /*TRACECOREMEDIASWRITER_H_*/
|
|
215 |
|
|
216 |
// End of file
|