1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kernel/eka/include/opensystemtrace.inl Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,203 @@
1.4 +/**
1.5 +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +* Trace API
1.19 +*
1.20 +*
1.21 +*/
1.22 +
1.23 +/**
1.24 + @file
1.25 + @publishedPartner
1.26 + @prototype
1.27 +*/
1.28 +
1.29 +#ifndef OPENSYSTEMTRACE_INL
1.30 +#define OPENSYSTEMTRACE_INL
1.31 +
1.32 +/**
1.33 +OST maximum data length
1.34 +The length of Component, Group and Trace IDs are subtracted from it
1.35 +*/
1.36 +const TUint KOstMaxDataLength = 512;
1.37 +
1.38 +/**
1.39 +BTrace maximum data length is defined in e32btrace.h
1.40 +The length of Component, Group and Trace IDs are subtracted from it
1.41 +*/
1.42 +const TUint KBTraceMaxDataLength = KMaxBTraceDataArray - 2 * sizeof(TUint32);
1.43 +
1.44 +/**
1.45 + * The TraceName is an amalgamation of two separate identifiers:
1.46 + * Group ID and Trace ID.
1.47 + *
1.48 + * These defines help get back the relevant bits from the
1.49 + * TraceName.
1.50 + *
1.51 + * Note that whilst the Group ID is defined as 16 bits we are
1.52 + * only taking the first 8 bits here.
1.53 + */
1.54 +#define GROUPIDMASK 0x00ff0000
1.55 +#define GROUPIDSHIFT 16
1.56 +#define TRACEIDMASK 0x0000ffff
1.57 +#define TRACEIDSHIFT 0
1.58 +#define EXTRACT_GROUP_ID(aTraceName) static_cast<TGroupId>((aTraceName & GROUPIDMASK) >> GROUPIDSHIFT)
1.59 +
1.60 +/**
1.61 + ---------------TTraceContext-----------------------
1.62 + Define the context of a trace packet by setting its attributes.
1.63 +
1.64 + The Component ID is defaulted according to the FW_DEFAULT_COMPONENTID definition.
1.65 + The HasThreadIdentification is defaulted to the FW_DEFAULT_HAS_THREAD_IDENTIFICATION definition.
1.66 + The HasProgramCounter is defaulted to the FW_DEFAULT_HAS_PC definition.
1.67 +
1.68 + @deprecated
1.69 +
1.70 + @param aGroupId @see TGroupId
1.71 +
1.72 +*/
1.73 +TTraceContext::TTraceContext(const TGroupId aGroupId)
1.74 +:iComponentId(FW_DEFAULT_COMPONENTID), iGroupId(aGroupId), iHasThreadIdentification(FW_DEFAULT_HAS_THREAD_IDENTIFICATION), iHasProgramCounter(FW_DEFAULT_HAS_PC), iReserved1(0), iReserved2(0)
1.75 + {
1.76 + }
1.77 +
1.78 +/**
1.79 + * Define the context of a trace packet by setting its attributes.
1.80 + *
1.81 + * The HasThreadIdentification is defaulted to the FW_DEFAULT_HAS_THREAD_IDENTIFICATION definition.
1.82 + * The HasProgramCounter is defaulted to the FW_DEFAULT_HAS_PC definition.
1.83 + *
1.84 + *
1.85 + * @deprecated
1.86 + *
1.87 + * @param aComponentId @see TComponentId
1.88 + * @param aGroupId @see TGroupId
1.89 + */
1.90 +TTraceContext::TTraceContext(const TComponentId aComponentId, const TGroupId aGroupId)
1.91 +:iComponentId(aComponentId), iGroupId(aGroupId), iHasThreadIdentification(FW_DEFAULT_HAS_THREAD_IDENTIFICATION), iHasProgramCounter(FW_DEFAULT_HAS_PC), iReserved1(0), iReserved2(0)
1.92 + {
1.93 + }
1.94 +
1.95 +/**
1.96 + * Define the context of a trace packet by setting its attributes.
1.97 + *
1.98 + * The Component ID is defaulted according to the FW_DEFAULT_COMPONENTID definition.
1.99 + *
1.100 + * @deprecated
1.101 + *
1.102 + * @param aGroupId @see TGroupId
1.103 + * @param aHasThreadIdentification Set whether to add thread identification automatically in the trace packet.
1.104 + * @param aHasProgramCounter Set whether to add PC (program counter) automatically in the trace packet.
1.105 + */
1.106 +TTraceContext::TTraceContext(const TGroupId aGroupId, const THasThreadIdentification aHasThreadIdentification, const THasProgramCounter aHasProgramCounter)
1.107 +:iComponentId(FW_DEFAULT_COMPONENTID), iGroupId(aGroupId), iHasThreadIdentification(aHasThreadIdentification), iHasProgramCounter(aHasProgramCounter), iReserved1(0), iReserved2(0)
1.108 + {
1.109 + }
1.110 +
1.111 +
1.112 +/**
1.113 + * Define the context of a trace packet by setting its attributes.
1.114 + *
1.115 + * @deprecated
1.116 + *
1.117 + * @param aComponentId @see TComponentId
1.118 + * @param aGroupId @see TGroupId
1.119 + * @param aHasThreadIdentification Set whether to add thread identification automatically in the trace packet.
1.120 + * @param aHasProgramCounter Set whether to add PC (program counter) automatically in the trace packet.
1.121 + */
1.122 +TTraceContext::TTraceContext(const TComponentId aComponentId, const TGroupId aGroupId, const THasThreadIdentification aHasThreadIdentification, const THasProgramCounter aHasProgramCounter)
1.123 +:iComponentId(aComponentId), iGroupId(aGroupId), iHasThreadIdentification(aHasThreadIdentification), iHasProgramCounter(aHasProgramCounter), iReserved1(0), iReserved2(0)
1.124 + {
1.125 + }
1.126 +
1.127 +//------------------ Trace -----------------------
1.128 +/**
1.129 +Outputs a trace packet containing variable length data.
1.130 +
1.131 +If the specified data is too big to fit into a single
1.132 +trace record a multipart trace is generated.
1.133 +
1.134 +@deprecated
1.135 +
1.136 +@param aContext Attributes of the trace point.
1.137 +@param aTraceId A format identifier as specified by @see TTraceId
1.138 +@param aData Additional data to add to trace packet.
1.139 + Must be word aligned, i.e. a multiple of 4.
1.140 +
1.141 +@return The trace packet was/was not logged.
1.142 +
1.143 +@See BTrace::TMultipart
1.144 +*/
1.145 +template<typename T>
1.146 +TBool OstTrace(const TTraceContext& aContext, TTraceId aTraceId, const T& aData)
1.147 + {
1.148 + return OstTrace(aContext, aTraceId, &aData, sizeof(aData));
1.149 + }
1.150 +
1.151 +
1.152 +/**
1.153 +Send N bytes of data
1.154 +
1.155 +@param aGroupId The Group ID of the trace packet. @see TGroupId
1.156 +@param aEOstTrace BTrace sub-category. Value between 0 and 255. The meaning of this is dependent on the Category
1.157 +@param aKOstTraceComponentID The Component ID of the trace
1.158 +@param aTraceName The Trace ID of the trace
1.159 +@param aPtr Address of addition data to add to trace.
1.160 +@param aLength Number of bytes of additional data.
1.161 +@return The trace packet was/was not logged.
1.162 +*/
1.163 +inline TBool OstSendNBytes( TUint8 aGroupId, TUint8 aEOstTrace, TUint32 aKOstTraceComponentID, TUint32 aTraceName, const TAny* aPtr, TInt aLength )
1.164 + {
1.165 + TBool retval;
1.166 +
1.167 + if (aLength <= (TInt)KBTraceMaxDataLength)
1.168 + {
1.169 + // Data length is less than BTrace max. data length, so we can directly call BTraceFilteredContextN macro.
1.170 + retval = BTraceFilteredContextN( aGroupId, aEOstTrace, aKOstTraceComponentID, aTraceName, aPtr, aLength );
1.171 + }
1.172 + else
1.173 + {
1.174 + // Data length is greater than BTrace max. data length, so we need to call BTraceContextBig macro
1.175 + TUint32 data[ KOstMaxDataLength / sizeof(TUint32)+ 1 ];
1.176 +
1.177 + TUint8* ptr = (TUint8*)((TUint32*)data+1); // First word holds Trace ID
1.178 +
1.179 + // Write Trace ID to data part because BTraceFilteredContextBig macro takes one parameter less than BTraceFilteredContextN macro
1.180 + data[0] = aTraceName;
1.181 +
1.182 + // If there is more data than we can show
1.183 + if (aLength > (TInt)KOstMaxDataLength)
1.184 + {
1.185 + aLength = KOstMaxDataLength;
1.186 + }
1.187 +
1.188 + // Copy the data to the buffer
1.189 + memcpy( ptr, aPtr, aLength );
1.190 + ptr += aLength;
1.191 +
1.192 + // Fillers are written to get 32-bit alignment
1.193 + TInt lengthAligned = ( aLength + (sizeof(TUint32)-1) ) & ~(sizeof(TUint32)-1);
1.194 + while ( aLength++ < lengthAligned )
1.195 + {
1.196 + *ptr++ = 0;
1.197 + }
1.198 +
1.199 + retval = BTraceFilteredContextBig( aGroupId, aEOstTrace, aKOstTraceComponentID, data, lengthAligned + sizeof(TUint32));
1.200 + }
1.201 +
1.202 + return retval;
1.203 + }
1.204 +
1.205 +
1.206 +#endif //OPENSYSTEMTRACE_INL