|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 * Header file template definition |
|
17 * |
|
18 */ |
|
19 package com.nokia.tracecompiler.engine.header; |
|
20 |
|
21 import com.nokia.tracecompiler.engine.header.TraceHeaderWriter.HeaderTemplateElementType; |
|
22 import com.nokia.tracecompiler.plugin.TraceAPIFormatter.TraceFormatType; |
|
23 import com.nokia.tracecompiler.plugin.TraceHeaderContribution.TraceHeaderContributionType; |
|
24 import com.nokia.tracecompiler.source.SymbianConstants; |
|
25 |
|
26 /** |
|
27 * Header file template definition |
|
28 * |
|
29 */ |
|
30 interface HeaderTemplate { |
|
31 |
|
32 /** |
|
33 * Tag written to trace header |
|
34 */ |
|
35 String HEADER_COMMENT_CREATED_BY = "// Created by TraceCompiler"; //$NON-NLS-1$ |
|
36 |
|
37 /** |
|
38 * Empty template |
|
39 */ |
|
40 Object[] EMPTY_TEMPLATE = {}; |
|
41 |
|
42 /** |
|
43 * Sets line count to 1 |
|
44 */ |
|
45 Object SET_LINES_PACKED = new SetNewLineCount(1); |
|
46 |
|
47 /** |
|
48 * Sets line count to 2 |
|
49 */ |
|
50 Object SET_LINES_MIDDLE = new SetNewLineCount(2); // CodForChk_Dis_Magic |
|
51 |
|
52 /** |
|
53 * Sets line count to 3 |
|
54 */ |
|
55 Object SET_LINES_LOOSE = new SetNewLineCount(3); // CodForChk_Dis_Magic |
|
56 |
|
57 /** |
|
58 * Template for empty trace macros |
|
59 */ |
|
60 Object[] EMPTY_TRACE_FUNCTION_EXISTS_TEMPLATE = { |
|
61 HeaderTemplateElementType.NEW_LINE, "#define ", //$NON-NLS-1$ |
|
62 HeaderTemplateElementType.FORMATTED_TRACE }; |
|
63 |
|
64 /** |
|
65 * Empty trace macro template switch. This formats the trace using |
|
66 * TraceFormatType.EmptyPreprocessorDefinition and checks if the definition |
|
67 * has already been written using CheckIsTraceFormatDuplicate switch |
|
68 */ |
|
69 Object[] EMPTY_TRACE_FUNCTION_TEMPLATE = { |
|
70 TraceFormatType.EMPTY_MACRO, |
|
71 new TemplateChoice(CheckIsTraceFormatDuplicate.class, |
|
72 EMPTY_TEMPLATE, EMPTY_TRACE_FUNCTION_EXISTS_TEMPLATE), }; |
|
73 |
|
74 /** |
|
75 * Template for trace activation check |
|
76 */ |
|
77 Object[] TRACE_FUNCTION_ACTIVATION_CHECK = { |
|
78 "TBool retval = ", //$NON-NLS-1$ |
|
79 TraceFormatType.TRACE_ACTIVATION, |
|
80 // Checks if the TraceActivation format exists |
|
81 new TemplateChoice(CheckFormattedTraceExists.class, new Object[] { |
|
82 HeaderTemplateElementType.FORMATTED_TRACE, ";", //$NON-NLS-1$ |
|
83 HeaderTemplateElementType.NEW_LINE, "if ( retval )", //$NON-NLS-1$ |
|
84 HeaderTemplateElementType.OPEN_BRACE }, new Object[] { |
|
85 "EFalse;", HeaderTemplateElementType.NEW_LINE }), //$NON-NLS-1$ |
|
86 }; |
|
87 |
|
88 /** |
|
89 * Template if no activation check is needed |
|
90 */ |
|
91 Object[] TRACE_FUNCTION_NO_ACTIVATION_CHECK = { "TBool retval;", //$NON-NLS-1$ |
|
92 HeaderTemplateElementType.NEW_LINE }; |
|
93 |
|
94 /** |
|
95 * Template for trace functions |
|
96 */ |
|
97 Object[] TRACE_FUNCTION_EXISTS_TEMPLATE = { |
|
98 SET_LINES_PACKED, |
|
99 HeaderTemplateElementType.BUILD_TRACE_BUFFER_CHECK, |
|
100 // If the trace contains TDesC16 parameter, __KERNEL_MODE__ flag is |
|
101 // added to it |
|
102 new TemplateChoice(CheckIsKernelModeFlagNeeded.class, new Object[] { |
|
103 "#ifndef __KERNEL_MODE__", //$NON-NLS-1$ |
|
104 HeaderTemplateElementType.NEW_LINE }, EMPTY_TEMPLATE), |
|
105 "inline TBool ", //$NON-NLS-1$ |
|
106 HeaderTemplateElementType.FORMATTED_TRACE, |
|
107 HeaderTemplateElementType.OPEN_BRACE, |
|
108 // If the trace is buffered activation check is written |
|
109 new TemplateChoice(CheckIsTraceBufferBuilt.class, |
|
110 TRACE_FUNCTION_ACTIVATION_CHECK, |
|
111 TRACE_FUNCTION_NO_ACTIVATION_CHECK), |
|
112 HeaderTemplateElementType.TRACE_FUNCTION_BODY, // Parameters + API |
|
113 HeaderTemplateElementType.CLOSE_EXTRA_BRACES, |
|
114 "return retval;", //$NON-NLS-1$ |
|
115 HeaderTemplateElementType.NEW_LINE, |
|
116 HeaderTemplateElementType.CLOSE_BRACE, |
|
117 // The __KERNEL_MODE__ #ifdef added above needs to be closed |
|
118 new TemplateChoice( |
|
119 CheckIsKernelModeEndifNeeded.class, |
|
120 new Object[] { "#endif", HeaderTemplateElementType.NEW_LINE }, //$NON-NLS-1$ |
|
121 EMPTY_TEMPLATE), SET_LINES_LOOSE, |
|
122 HeaderTemplateElementType.NEW_LINE }; |
|
123 |
|
124 /** |
|
125 * Trace function template switch. This formats the trace using |
|
126 * TraceFormatType.Header and checks if the definition has already been |
|
127 * written using TRACE_FORMAT_EXISTS_TEMPLATE_INDEX switch |
|
128 */ |
|
129 Object[] TRACE_FUNCTION_TEMPLATE = { |
|
130 TraceFormatType.HEADER, |
|
131 new TemplateChoice(CheckIsTraceFormatDuplicate.class, |
|
132 EMPTY_TEMPLATE, TRACE_FUNCTION_EXISTS_TEMPLATE) }; |
|
133 |
|
134 /** |
|
135 * Template for trace ID's |
|
136 */ |
|
137 Object[] TRACE_ID_TEMPLATE = { |
|
138 "#define ", //$NON-NLS-1$ |
|
139 HeaderTemplateElementType.TRACE_NAME, |
|
140 " 0x", //$NON-NLS-1$ |
|
141 HeaderTemplateElementType.TRACE_ID_HEX, |
|
142 HeaderTemplateElementType.NEW_LINE }; |
|
143 |
|
144 /** |
|
145 * Main header template |
|
146 */ |
|
147 Object[] HEADER_TEMPLATE = { |
|
148 SET_LINES_PACKED, |
|
149 HeaderTemplateElementType.LICENCE_TEXT, |
|
150 HeaderTemplateElementType.NEW_LINE, |
|
151 HEADER_COMMENT_CREATED_BY, " ", //$NON-NLS-1$ |
|
152 HeaderTemplateElementType.TRACE_COMPILER_VERSION, |
|
153 HeaderTemplateElementType.NEW_LINE, |
|
154 "// DO NOT EDIT, CHANGES WILL BE LOST", //$NON-NLS-1$ |
|
155 SET_LINES_MIDDLE, |
|
156 HeaderTemplateElementType.NEW_LINE, |
|
157 HeaderTemplateElementType.HEADER_GUARD, |
|
158 HeaderTemplateElementType.NEW_LINE, |
|
159 SET_LINES_PACKED, |
|
160 TraceHeaderContributionType.GLOBAL_DEFINES, |
|
161 SET_LINES_MIDDLE, |
|
162 HeaderTemplateElementType.NEW_LINE, |
|
163 SET_LINES_PACKED, |
|
164 TraceHeaderContributionType.GLOBAL_INCLUDES, |
|
165 SET_LINES_MIDDLE, |
|
166 HeaderTemplateElementType.NEW_LINE, |
|
167 SET_LINES_PACKED, |
|
168 new TemplateIterator(IteratorTraces.class, TRACE_ID_TEMPLATE), |
|
169 SET_LINES_LOOSE, |
|
170 HeaderTemplateElementType.NEW_LINE, |
|
171 // Trace functions |
|
172 new TemplateIterator(IteratorComplexTraces.class, |
|
173 TRACE_FUNCTION_TEMPLATE), |
|
174 // End of header guard |
|
175 SET_LINES_MIDDLE, "#endif", HeaderTemplateElementType.NEW_LINE, //$NON-NLS-1$ |
|
176 HeaderTemplateElementType.NEW_LINE, "// End of file", //$NON-NLS-1$ |
|
177 HeaderTemplateElementType.NEW_LINE }; |
|
178 |
|
179 /** |
|
180 * Template for parameter with fixed size |
|
181 */ |
|
182 Object[] FIXED_PARAMETER_TEMPLATE = { "*( ( ", //$NON-NLS-1$ |
|
183 HeaderTemplateElementType.PARAMETER_TYPE, "* )ptr ) = ", //$NON-NLS-1$ |
|
184 HeaderTemplateElementType.PARAMETER_NAME, ";", //$NON-NLS-1$ |
|
185 HeaderTemplateElementType.NEW_LINE, "ptr += sizeof ( ", //$NON-NLS-1$ |
|
186 HeaderTemplateElementType.PARAMETER_TYPE, " );", //$NON-NLS-1$ |
|
187 HeaderTemplateElementType.NEW_LINE }; |
|
188 |
|
189 /** |
|
190 * Template for parameter with fixed size and length check |
|
191 */ |
|
192 Object[] FIXED_PARAMETER_TEMPLATE_WITH_LENGTH_CHECK = { |
|
193 "// Check that there are enough space to next parameter", //$NON-NLS-1$ |
|
194 HeaderTemplateElementType.NEW_LINE, |
|
195 "if ((length + sizeof ( ", //$NON-NLS-1$ |
|
196 HeaderTemplateElementType.PARAMETER_TYPE, |
|
197 " )) <= KOstMaxDataLength)", //$NON-NLS-1$ |
|
198 HeaderTemplateElementType.OPEN_BRACE, |
|
199 FIXED_PARAMETER_TEMPLATE, |
|
200 "length += sizeof ( ", //$NON-NLS-1$ |
|
201 HeaderTemplateElementType.PARAMETER_TYPE, |
|
202 " );", //$NON-NLS-1$ |
|
203 HeaderTemplateElementType.NEW_LINE, |
|
204 HeaderTemplateElementType.CLOSE_BRACE}; |
|
205 |
|
206 /** |
|
207 * Template for writing 32-bit alignment for parameters |
|
208 */ |
|
209 Object[] DYNAMIC_PARAMETER_ALIGNMENT_TEMPLATE = { |
|
210 "// Fillers are written to get 32-bit alignment", //$NON-NLS-1$ |
|
211 HeaderTemplateElementType.NEW_LINE, |
|
212 "while ( length", //$NON-NLS-1$ |
|
213 HeaderTemplateElementType.PARAMETER_INDEX, |
|
214 "++ < lengthAligned", //$NON-NLS-1$ |
|
215 HeaderTemplateElementType.PARAMETER_INDEX, |
|
216 " )", //$NON-NLS-1$ |
|
217 HeaderTemplateElementType.OPEN_BRACE, |
|
218 "*ptr++ = 0;", //$NON-NLS-1$ |
|
219 HeaderTemplateElementType.NEW_LINE, |
|
220 HeaderTemplateElementType.CLOSE_BRACE }; |
|
221 |
|
222 /** |
|
223 * Template for parameter with dynamic size |
|
224 */ |
|
225 Object[] DYNAMIC_PARAMETER_TEMPLATE = { |
|
226 "if (length", //$NON-NLS-1$ |
|
227 HeaderTemplateElementType.PARAMETER_INDEX, |
|
228 " > 0)", //$NON-NLS-1$ |
|
229 HeaderTemplateElementType.OPEN_BRACE, |
|
230 "// Number of elements is written before data", //$NON-NLS-1$ |
|
231 HeaderTemplateElementType.NEW_LINE, |
|
232 "// In case of Unicode string, number of elements is half of length", //$NON-NLS-1$ |
|
233 HeaderTemplateElementType.NEW_LINE, |
|
234 "*( ( TUint32* )ptr ) = length", //$NON-NLS-1$ |
|
235 HeaderTemplateElementType.PARAMETER_INDEX, |
|
236 " / (", //$NON-NLS-1$ |
|
237 HeaderTemplateElementType.PARAMETER_NAME, |
|
238 ".Size() / ", //$NON-NLS-1$ |
|
239 HeaderTemplateElementType.PARAMETER_NAME, |
|
240 ".Length());", //$NON-NLS-1$ |
|
241 HeaderTemplateElementType.NEW_LINE, |
|
242 "ptr += sizeof ( TUint32 );", //$NON-NLS-1$ |
|
243 HeaderTemplateElementType.NEW_LINE, |
|
244 "memcpy( ptr, ", //$NON-NLS-1$ |
|
245 HeaderTemplateElementType.PARAMETER_NAME, |
|
246 ".Ptr(), length", //$NON-NLS-1$ |
|
247 HeaderTemplateElementType.PARAMETER_INDEX, |
|
248 " );", //$NON-NLS-1$ |
|
249 HeaderTemplateElementType.NEW_LINE, |
|
250 "ptr += length", //$NON-NLS-1$ |
|
251 HeaderTemplateElementType.PARAMETER_INDEX, |
|
252 ";", //$NON-NLS-1$ |
|
253 HeaderTemplateElementType.NEW_LINE, |
|
254 new TemplateChoice(CheckParameterNeedsAlignment.class, |
|
255 DYNAMIC_PARAMETER_ALIGNMENT_TEMPLATE, EMPTY_TEMPLATE), |
|
256 HeaderTemplateElementType.NEW_LINE, |
|
257 "length += sizeof ( TUint32 ) + lengthAligned", //$NON-NLS-1$ |
|
258 HeaderTemplateElementType.PARAMETER_INDEX, |
|
259 ";", //$NON-NLS-1$ |
|
260 HeaderTemplateElementType.NEW_LINE, |
|
261 HeaderTemplateElementType.CLOSE_BRACE, |
|
262 "else if (length + sizeof ( TUint32 ) <= KOstMaxDataLength)", //$NON-NLS-1$ |
|
263 HeaderTemplateElementType.OPEN_BRACE, |
|
264 HeaderTemplateElementType.NEW_LINE, |
|
265 "*( ( TUint32* )ptr ) = 0;", //$NON-NLS-1$ |
|
266 HeaderTemplateElementType.NEW_LINE, |
|
267 "ptr += sizeof ( TUint32 );", //$NON-NLS-1$ |
|
268 HeaderTemplateElementType.NEW_LINE, |
|
269 "length += sizeof ( TUint32 );", //$NON-NLS-1$ |
|
270 HeaderTemplateElementType.NEW_LINE, |
|
271 HeaderTemplateElementType.CLOSE_BRACE}; |
|
272 |
|
273 /** |
|
274 * Template to allocate the buffer for parameters if buffer size is fixed |
|
275 */ |
|
276 Object[] FIXED_BUFFER_ALLOCATION_TEMPLATE = { "TUint8 data[ ", //$NON-NLS-1$ |
|
277 HeaderTemplateElementType.FIXED_BUFFER_SIZE, " ];", //$NON-NLS-1$ |
|
278 HeaderTemplateElementType.NEW_LINE, "TUint8* ptr = data;", //$NON-NLS-1$ |
|
279 HeaderTemplateElementType.NEW_LINE}; |
|
280 |
|
281 /** |
|
282 * Template to allocate the buffer for parameters if buffer size is dynamic |
|
283 */ |
|
284 Object[] DYNAMIC_BUFFER_ALLOCATION_TEMPLATE = { |
|
285 // KOstMaxDataLength is defined in opensystemtrace.h |
|
286 "TUint8 data[ KOstMaxDataLength ];", //$NON-NLS-1$ |
|
287 HeaderTemplateElementType.NEW_LINE, "TUint8* ptr = data;", //$NON-NLS-1$ |
|
288 HeaderTemplateElementType.NEW_LINE, "// Set length to zero and calculate it againg", //$NON-NLS-1$ |
|
289 HeaderTemplateElementType.NEW_LINE, "// when adding parameters", //$NON-NLS-1$ |
|
290 HeaderTemplateElementType.NEW_LINE, "length = 0;", //$NON-NLS-1$ |
|
291 HeaderTemplateElementType.NEW_LINE }; |
|
292 |
|
293 /** |
|
294 * Template to allocate buffer for trace data |
|
295 */ |
|
296 Object[] BUFFER_ALLOCATION_TEMPLATE = { new TemplateChoice( |
|
297 CheckIsBufferSizeDynamic.class, DYNAMIC_BUFFER_ALLOCATION_TEMPLATE, |
|
298 FIXED_BUFFER_ALLOCATION_TEMPLATE) }; |
|
299 |
|
300 /** |
|
301 * Template to length variable definition |
|
302 */ |
|
303 Object[] LENGTH_VARIABLE_DEFINITION_TEMPLATE = { |
|
304 "TInt length = 0;", //$NON-NLS-1$ |
|
305 HeaderTemplateElementType.NEW_LINE }; |
|
306 |
|
307 /** |
|
308 * Beging template to length variable increase |
|
309 */ |
|
310 Object[] LENGTH_VARIABLE_INCREASE_TEMPLATE_BEGIN = { |
|
311 "// Increase length because of fixed size parameters", //$NON-NLS-1$ |
|
312 HeaderTemplateElementType.NEW_LINE, |
|
313 "length += "}; //$NON-NLS-1$ |
|
314 |
|
315 /** |
|
316 * End template to length variable increase |
|
317 */ |
|
318 Object[] LENGTH_VARIABLE_INCREASE_TEMPLATE_END = { |
|
319 ";", //$NON-NLS-1$ |
|
320 HeaderTemplateElementType.NEW_LINE }; |
|
321 |
|
322 /** |
|
323 * Template to calculate the length for a dynamic parameter |
|
324 */ |
|
325 Object[] DYNAMIC_PARAMETER_LENGTH_TEMPLATE = { |
|
326 "// Check that parameter lenght is not too long", //$NON-NLS-1$ |
|
327 HeaderTemplateElementType.NEW_LINE, |
|
328 "TInt length", //$NON-NLS-1$ |
|
329 HeaderTemplateElementType.PARAMETER_INDEX, |
|
330 " = ", //$NON-NLS-1$ |
|
331 SymbianConstants.PARAMETER_DECLARATION_PREFIX, |
|
332 HeaderTemplateElementType.PARAMETER_INDEX, ".Size();", //$NON-NLS-1$ |
|
333 HeaderTemplateElementType.NEW_LINE, |
|
334 "if ((length + length", //$NON-NLS-1$ |
|
335 HeaderTemplateElementType.PARAMETER_INDEX, |
|
336 " + sizeof ( TUint32 )) > KOstMaxDataLength)", //$NON-NLS-1$ |
|
337 HeaderTemplateElementType.OPEN_BRACE, |
|
338 "length", //$NON-NLS-1$ |
|
339 HeaderTemplateElementType.PARAMETER_INDEX, |
|
340 " = KOstMaxDataLength - (length + sizeof ( TUint32 ));", //$NON-NLS-1$ |
|
341 HeaderTemplateElementType.NEW_LINE, |
|
342 HeaderTemplateElementType.CLOSE_BRACE, |
|
343 HeaderTemplateElementType.NEW_LINE, |
|
344 "TInt lengthAligned", //$NON-NLS-1$ |
|
345 HeaderTemplateElementType.PARAMETER_INDEX, |
|
346 " = ( length", //$NON-NLS-1$ |
|
347 HeaderTemplateElementType.PARAMETER_INDEX, |
|
348 " + 3 ) & ~3;", //$NON-NLS-1$ |
|
349 HeaderTemplateElementType.NEW_LINE, |
|
350 "if (lengthAligned", //$NON-NLS-1$ |
|
351 HeaderTemplateElementType.PARAMETER_INDEX, |
|
352 " > 0)", //$NON-NLS-1$ |
|
353 HeaderTemplateElementType.OPEN_BRACE, |
|
354 "length = length + sizeof ( TUint32 ) + lengthAligned", //$NON-NLS-1$ |
|
355 HeaderTemplateElementType.PARAMETER_INDEX, |
|
356 ";", //$NON-NLS-1$ |
|
357 HeaderTemplateElementType.NEW_LINE, |
|
358 HeaderTemplateElementType.CLOSE_BRACE, |
|
359 HeaderTemplateElementType.NEW_LINE }; |
|
360 |
|
361 /** |
|
362 * Template for the optimized single dynamic parameter case, where buffer is |
|
363 * not needed |
|
364 */ |
|
365 Object[] SINGLE_DYNAMIC_PARAMETER_TEMPLATE = { |
|
366 "TInt size = ", //$NON-NLS-1$ |
|
367 SymbianConstants.PARAMETER_DECLARATION_PREFIX, "1.Size();", //$NON-NLS-1$ |
|
368 HeaderTemplateElementType.NEW_LINE, |
|
369 "// BTrace assumes that parameter size is atleast 4 bytes", //$NON-NLS-1$ |
|
370 HeaderTemplateElementType.NEW_LINE, |
|
371 "if (size % 4 == 0)", //$NON-NLS-1$ |
|
372 HeaderTemplateElementType.OPEN_BRACE, |
|
373 "TUint8* ptr = ( TUint8* )aParam1.Ptr();", //$NON-NLS-1$ |
|
374 HeaderTemplateElementType.NEW_LINE, |
|
375 "// Data is written directly and length is determined from trace message length", //$NON-NLS-1$ |
|
376 HeaderTemplateElementType.NEW_LINE, |
|
377 "retval = OstSendNBytes( EXTRACT_GROUP_ID(aTraceID), EOstTrace, KOstTraceComponentID, aTraceID, ptr, size );", //$NON-NLS-1$ |
|
378 HeaderTemplateElementType.NEW_LINE, |
|
379 HeaderTemplateElementType.CLOSE_BRACE, |
|
380 HeaderTemplateElementType.NEW_LINE, |
|
381 "else", //$NON-NLS-1$ |
|
382 HeaderTemplateElementType.OPEN_BRACE, |
|
383 "TUint8 data[ KOstMaxDataLength ];", //$NON-NLS-1$ |
|
384 HeaderTemplateElementType.NEW_LINE, |
|
385 "TUint8* ptr = data;", //$NON-NLS-1$ |
|
386 HeaderTemplateElementType.NEW_LINE, |
|
387 "if (size > KOstMaxDataLength)", //$NON-NLS-1$ |
|
388 HeaderTemplateElementType.OPEN_BRACE, |
|
389 "size = KOstMaxDataLength;", //$NON-NLS-1$ |
|
390 HeaderTemplateElementType.NEW_LINE, |
|
391 HeaderTemplateElementType.CLOSE_BRACE, |
|
392 HeaderTemplateElementType.NEW_LINE, |
|
393 "TInt sizeAligned = ( size + 3 ) & ~3;", //$NON-NLS-1$ |
|
394 HeaderTemplateElementType.NEW_LINE, |
|
395 "memcpy( ptr, ", //$NON-NLS-1$ |
|
396 SymbianConstants.PARAMETER_DECLARATION_PREFIX, "1.Ptr(), size );", //$NON-NLS-1$ |
|
397 HeaderTemplateElementType.NEW_LINE, |
|
398 "ptr += size;", //$NON-NLS-1$ |
|
399 HeaderTemplateElementType.NEW_LINE, |
|
400 "// Fillers are written to get 32-bit alignment", //$NON-NLS-1$ |
|
401 HeaderTemplateElementType.NEW_LINE, |
|
402 "while ( size++ < sizeAligned )", //$NON-NLS-1$ |
|
403 HeaderTemplateElementType.OPEN_BRACE, |
|
404 "*ptr++ = 0;", //$NON-NLS-1$ |
|
405 HeaderTemplateElementType.NEW_LINE, |
|
406 HeaderTemplateElementType.CLOSE_BRACE, |
|
407 HeaderTemplateElementType.NEW_LINE, |
|
408 "ptr -= sizeAligned;", //$NON-NLS-1$ |
|
409 HeaderTemplateElementType.NEW_LINE, |
|
410 "size = sizeAligned;", //$NON-NLS-1$ |
|
411 HeaderTemplateElementType.NEW_LINE, |
|
412 "// Data is written directly and length is determined from trace message length", //$NON-NLS-1$ |
|
413 HeaderTemplateElementType.NEW_LINE, |
|
414 "retval = OstSendNBytes( EXTRACT_GROUP_ID(aTraceID), EOstTrace, KOstTraceComponentID, aTraceID, ptr, size );", //$NON-NLS-1$ |
|
415 HeaderTemplateElementType.NEW_LINE, |
|
416 HeaderTemplateElementType.CLOSE_BRACE, |
|
417 HeaderTemplateElementType.NEW_LINE}; |
|
418 |
|
419 /** |
|
420 * Template for buffered parameters |
|
421 */ |
|
422 Object[] BUFFERED_PARAMETERS_TEMPLATE = { HeaderTemplateElementType.TRACE_FUNCTION_PARAMETERS }; |
|
423 |
|
424 /** |
|
425 * Template when the trace buffer needs to be allocated |
|
426 */ |
|
427 Object[] BUILD_TRACE_BUFFER_TEMPLATE = { |
|
428 new TemplateIterator(IteratorParameters.class, |
|
429 BUFFERED_PARAMETERS_TEMPLATE), |
|
430 "ptr -= ", //$NON-NLS-1$ |
|
431 new TemplateChoice(CheckIsBufferSizeDynamic.class, |
|
432 new Object[] { "length;" }, new Object[] { //$NON-NLS-1$ |
|
433 HeaderTemplateElementType.FIXED_BUFFER_SIZE, ";" }), //$NON-NLS-1$ |
|
434 HeaderTemplateElementType.NEW_LINE }; |
|
435 |
|
436 /** |
|
437 * Template for trace parameters. |
|
438 */ |
|
439 Object[] PARAMETERS_TEMPLATE = { new TemplateChoice( |
|
440 CheckIsTraceBufferBuilt.class, BUILD_TRACE_BUFFER_TEMPLATE, |
|
441 SINGLE_DYNAMIC_PARAMETER_TEMPLATE) }; |
|
442 |
|
443 } |