libraries/clogger/debugRouter/debugRouter.h
changeset 0 7f656887cf89
equal deleted inserted replaced
-1:000000000000 0:7f656887cf89
       
     1 // debugRouter.h
       
     2 // 
       
     3 // Copyright (c) 2007 - 2010 Accenture. All rights reserved.
       
     4 // This component and the accompanying materials are made available
       
     5 // under the terms of the "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 // Accenture - Initial contribution
       
    11 //
       
    12 
       
    13 #ifndef __DebugRouter_H__
       
    14 #define __DebugRouter_H__
       
    15 
       
    16 #ifndef __KERNEL_MODE__
       
    17 #include <e32std.h>
       
    18 #endif
       
    19 #include <u32std.h>
       
    20 
       
    21 _LIT(KDebugRouterName,"Clogger-DebugRouter");
       
    22 class RChunk;
       
    23 
       
    24 struct SCloggerCrashDumpArea
       
    25 	{
       
    26 	TInt iChunkHandle;
       
    27 	TUint iOffset;
       
    28 	TUint iSize;
       
    29 	TBuf8<32> iName;
       
    30 	};
       
    31 
       
    32 struct SCreateChunkParams
       
    33 	{
       
    34 	TInt iHandleOfOtherThread;
       
    35 	TInt iMaxSize;
       
    36 	TInt iCommittedSize;
       
    37 	TInt iChunkHandle; // Return value
       
    38 	TInt iOtherThreadChunkHandle; // Return value, If iHandleOfOtherThread != 0
       
    39 	};
       
    40 
       
    41 struct SCloggerTraceInfo
       
    42 	{
       
    43 	TUint8 iTraceType; // 'P', 'K', 'U'
       
    44 	TUint8 iReserved;
       
    45 	TUint16 iLength; // Kern trace is always <=256 chars but unfortunately platsec diagnostics aren't!
       
    46 	TUint32 iTickCount;
       
    47 	TUint iThreadId;
       
    48 	};
       
    49 
       
    50 struct SDebugChunkHeader
       
    51 	{
       
    52 	TUint iStartOffset;
       
    53 	TUint iEndOffset;
       
    54 	TUint iOverflows; // Number of log statements that were dropped because the buffer was full (measured since last completion, not cumulative)
       
    55 	};
       
    56 	
       
    57 class RCloggerDebugRouter : public RBusLogicalChannel
       
    58 	{
       
    59 public:
       
    60 	enum TControl
       
    61 		{
       
    62 		EControlEnableRouting,
       
    63 		EControlOpenChunk,
       
    64 		ERequestGetData,
       
    65 		EControlRegisterBuffers,
       
    66 		EControlCreateAndOpenAChunk,
       
    67 		EControlAdjustChunk,
       
    68 		ENumRequests,  // Add new commands above this line
       
    69 		EAllRequests= (1<<ENumRequests)-1
       
    70         };
       
    71 	enum TEnableOption
       
    72 		{
       
    73 		EDisable,
       
    74 		EEnableRouting,
       
    75 		EEnableRoutingAndConsume,
       
    76 		};
       
    77 public:
       
    78 	static TInt LoadDriver();
       
    79 	static void CloseDriver();
       
    80 	TInt Open();
       
    81 	void Close();
       
    82 
       
    83 public: // For retreiving RDebug::Print data
       
    84 	TInt OpenChunk(RChunk& aChunk);
       
    85 	void ReceiveData(TRequestStatus& aStatus);
       
    86 	void CancelReceive();
       
    87 	TInt EnableDebugRouting(TEnableOption aEnable);
       
    88 
       
    89 public: // For registering buffers with the crash dumber (NOTE: requires support in the baseport to have any effect)
       
    90 	// This supercedes any previous call to RegisterCrashDumpAreas. Therefore to unregister everything, call RegisterCrashDumpAreas(KNullDesC8)
       
    91 	TInt RegisterCrashDumpAreas(const TDesC8& aCrashDumpAreas); // packed array of SCloggerCrashDumpAreas
       
    92 	
       
    93 	TInt CreateChunk(SCreateChunkParams& aParams); // returns chunk handle or error
       
    94 	TInt AdjustChunk(RChunk& aChunk, TInt aNewSize);
       
    95 	};
       
    96 
       
    97 #ifndef __KERNEL_MODE__
       
    98 // Inline implementations of user side interface
       
    99 
       
   100 inline TInt RCloggerDebugRouter::LoadDriver()
       
   101 	{	return User::LoadLogicalDevice(KDebugRouterName);	}
       
   102 inline void RCloggerDebugRouter::CloseDriver()
       
   103 	{	User::FreeLogicalDevice(KDebugRouterName);	}
       
   104 inline void RCloggerDebugRouter::Close()
       
   105 	{	RHandleBase::Close(); }
       
   106 inline TInt RCloggerDebugRouter::Open()
       
   107 	{	return DoCreate(KDebugRouterName,TVersion(1,0,0),KNullUnit,NULL,NULL); 	}
       
   108 	
       
   109 inline TInt RCloggerDebugRouter::EnableDebugRouting(TEnableOption aEnable)
       
   110 	{	return DoControl(EControlEnableRouting, (TAny*)aEnable);	}
       
   111 
       
   112 inline TInt RCloggerDebugRouter::OpenChunk(RChunk& aChunk)
       
   113 	{	
       
   114 	TInt res = DoControl(EControlOpenChunk);
       
   115 	if (res >= 0) 
       
   116 		{
       
   117 		aChunk.SetHandle(res);
       
   118 		return KErrNone;
       
   119 		}
       
   120 	return res;
       
   121 	}
       
   122 
       
   123 inline void RCloggerDebugRouter::ReceiveData(TRequestStatus& aStatus)
       
   124 	{
       
   125 	DoRequest(ERequestGetData, aStatus);
       
   126 	}
       
   127 
       
   128 inline void RCloggerDebugRouter::CancelReceive()
       
   129 	{
       
   130 	DoCancel(0xFFFFFFFF); // We only have 1 async request at the moment
       
   131 	}
       
   132 
       
   133 inline TInt RCloggerDebugRouter::RegisterCrashDumpAreas(const TDesC8& aCrashDumpAreas)
       
   134 	{
       
   135 	return DoControl(EControlRegisterBuffers, (TAny*)&aCrashDumpAreas);
       
   136 	}
       
   137 
       
   138 inline TInt RCloggerDebugRouter::CreateChunk(SCreateChunkParams& aParams)
       
   139 	{
       
   140 	return DoControl(EControlCreateAndOpenAChunk, (TAny*)&aParams);
       
   141 	}
       
   142 
       
   143 inline TInt RCloggerDebugRouter::AdjustChunk(RChunk& aChunk, TInt aNewSize)
       
   144 	{
       
   145 	return DoControl(EControlAdjustChunk, (TAny*)aChunk.Handle(), (TAny*)aNewSize);
       
   146 	}
       
   147 
       
   148 #endif //__KERNEL_MODE__
       
   149 
       
   150 #endif //__DebugRouter_H__