os/kernelhwsrv/kernel/eka/include/sm_debug_api.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200 (2012-06-15)
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// Definition of the stop-mode debug interface.
sl@0
    15
// 
sl@0
    16
sl@0
    17
/**
sl@0
    18
@file
sl@0
    19
@publishedPartner
sl@0
    20
@prototype
sl@0
    21
*/
sl@0
    22
sl@0
    23
#ifndef D_STOP_MODE_API_H
sl@0
    24
#define D_STOP_MODE_API_H
sl@0
    25
sl@0
    26
#include <rm_debug_api.h>
sl@0
    27
#include <plat_priv.h>
sl@0
    28
sl@0
    29
namespace Debug
sl@0
    30
	{
sl@0
    31
	/**
sl@0
    32
	 * The stop-mode debug interface is a stateless interface which may be called at any point
sl@0
    33
	 * except user mode, provided the rest of the OS is not going to run or pre-empt it.
sl@0
    34
	 * For example, for stop-mode debugging, the ICE may run the stop_mode_api routine to
sl@0
    35
	 * collect information about the system so long as no exceptions are enabled, and all 
sl@0
    36
	 * registers/stack are preserved and restored after the call completes. Note that in an SMP environment
sl@0
    37
	 * it is expected that ALL the CPU's have been stopped
sl@0
    38
	 */
sl@0
    39
sl@0
    40
	/** Stop Mode Debug API Version Numbers */
sl@0
    41
	const TUint KStopModeMajorVersionNumber=0;
sl@0
    42
	const TUint KStopModeMinorVersionNumber=0;
sl@0
    43
	const TUint KStopModePatchVersionNumber=2;
sl@0
    44
sl@0
    45
	/**
sl@0
    46
	 * Enumerators used to identify the buffers created for use with the Stop-Mode Debug API.
sl@0
    47
	 */
sl@0
    48
	enum TBufferType
sl@0
    49
		{
sl@0
    50
		EBuffersFunctionality = 0,   /**< Enumerator corresponding to the buffer created to store the debug functionality block. */
sl@0
    51
		EBuffersRequest = 1,         /**< Enumerator corresponding to the request buffer. */
sl@0
    52
		EBuffersResponse = 2,        /**< Enumerator corresponding to the response buffer. */
sl@0
    53
		
sl@0
    54
		/**
sl@0
    55
		 * @internalTechnology
sl@0
    56
		 * A user should find the number of buffer tags from the DFBlock rather than this enumerator.
sl@0
    57
		 */
sl@0
    58
		EBuffersLast
sl@0
    59
		};
sl@0
    60
sl@0
    61
	/**
sl@0
    62
	 * Enumerators used to identify the functions for use with the Stop-Mode Debug API.
sl@0
    63
	 */
sl@0
    64
	enum TFunctionalityStopModeFunctions
sl@0
    65
		{
sl@0
    66
		EStopModeFunctionsExitPoint = 0,  /**< Enumerator corresponding to the Debug::GetList() function. */
sl@0
    67
		EStopModeFunctionsGetList = 1,    /**< Enumerator corresponding to the Debug::ExitPoint() function. */
sl@0
    68
		EStopModeFunctionsTestAPI = 2,	  /**< Enumerator corresponding to the Debug::TestAPI() function. */
sl@0
    69
		
sl@0
    70
		/**
sl@0
    71
		 * @internalTechnology
sl@0
    72
		 * A user should find the number of supported functions from the DFBlock rather than this enumerator.
sl@0
    73
		 */
sl@0
    74
		EStopModeFunctionsLast
sl@0
    75
		};
sl@0
    76
sl@0
    77
	/**
sl@0
    78
	 * This structure defines the start elements of a stop-mode debug functionality block.
sl@0
    79
	 * It is assumed that the rest of the functionality block will extend past the end of
sl@0
    80
	 * the structure and will be accessed according to the documented format of the
sl@0
    81
	 * stop-mode functionality block.
sl@0
    82
	 */
sl@0
    83
	struct DFunctionalityBlock
sl@0
    84
		{
sl@0
    85
		TUint32 iSize;				/**< Size of the functionality block in bytes. */
sl@0
    86
		TVersion iStopModeVersion;	/** Version of the stop-mode debug API. */
sl@0
    87
		TTagHeader iFirstHeader;	/** The header for the first sub-block in the functionality block. */
sl@0
    88
		};
sl@0
    89
sl@0
    90
	/**
sl@0
    91
	 * This structure used for extracting static data using the Stop Mode Extension API
sl@0
    92
	 * StopModeDebug::GetList using TListId::EStaticInfo
sl@0
    93
	 * as the first argument.
sl@0
    94
	 */
sl@0
    95
	class TStaticListEntry
sl@0
    96
		{
sl@0
    97
	public:
sl@0
    98
    
sl@0
    99
		/** Build time of ROM in microseconds */
sl@0
   100
	    TUint64 iTime;    
sl@0
   101
    
sl@0
   102
		/** Number of CPUs */
sl@0
   103
	    TInt iCpuNumbers;
sl@0
   104
    
sl@0
   105
		/** ROM build number */
sl@0
   106
	    TUint16 iBuildNumber;    
sl@0
   107
        
sl@0
   108
		/** Major Version of ROM build */
sl@0
   109
	    TUint8 iMajorVersion;                   
sl@0
   110
sl@0
   111
		/** Minor Version of ROM build */
sl@0
   112
	    TUint8 iMinorVersion;
sl@0
   113
    
sl@0
   114
		/** Currently unused element. May be used in future to aid maintaining compatibility. */
sl@0
   115
	    TUint32 iSpare[10];    
sl@0
   116
		};
sl@0
   117
sl@0
   118
	/**
sl@0
   119
	 * This structure represents a request to return a list via the SM API
sl@0
   120
	 */
sl@0
   121
	struct TListItem
sl@0
   122
		{
sl@0
   123
		/** Size of this TListItem */
sl@0
   124
		TUint32 iSize;
sl@0
   125
	
sl@0
   126
		/** The type of list to return */
sl@0
   127
		TListId iListId;
sl@0
   128
	
sl@0
   129
		/** The scope of the list to return  */
sl@0
   130
		TListScope iListScope;
sl@0
   131
	
sl@0
   132
		/**
sl@0
   133
		 * Data corresponding to the list scope, for example if iListScope specifies a thread
sl@0
   134
		 * specific listing then iScopeData should contain the thread ID to return the list for.
sl@0
   135
		 * If iListScope = EGlobalScope then iScopeData is ignored.
sl@0
   136
		 */
sl@0
   137
		TUint64 iScopeData;
sl@0
   138
	
sl@0
   139
		/**
sl@0
   140
		 * The first element in the target list to return data for. For example if a thread list is being
sl@0
   141
		 * requested then specifying iStartElement = 100 indicates that the first thread to be returned should
sl@0
   142
		 * be the first thread with thread ID >= 100.
sl@0
   143
		 */
sl@0
   144
		TUint64 iStartElement;
sl@0
   145
	
sl@0
   146
		/** Memory address of where the data should be written */
sl@0
   147
		TAny* iBufferAddress;
sl@0
   148
	
sl@0
   149
		/** Size of the buffer available for writing the data into */
sl@0
   150
		TUint32 iBufferSize;
sl@0
   151
		};
sl@0
   152
sl@0
   153
	/**
sl@0
   154
	 * Structure that describes a list being returned
sl@0
   155
	 */
sl@0
   156
	struct TListReturn
sl@0
   157
		{
sl@0
   158
		/** List that is being returned */
sl@0
   159
		TUint32 iReqNo;
sl@0
   160
sl@0
   161
		/** Number of items in the returned list */
sl@0
   162
		TUint32 iNumberItems;
sl@0
   163
sl@0
   164
		/** Size occupied by data */
sl@0
   165
		TUint32 iDataSize;
sl@0
   166
		};
sl@0
   167
sl@0
   168
	/**
sl@0
   169
	 * Class used to add extended functionality to DDebuggerInfo class.
sl@0
   170
	 * 
sl@0
   171
	 * @publishedPartner
sl@0
   172
	 * @prototype
sl@0
   173
	 */
sl@0
   174
	class DStopModeExtension
sl@0
   175
		{
sl@0
   176
		public:
sl@0
   177
			DStopModeExtension()
sl@0
   178
				:iFunctionalityBlock(NULL),
sl@0
   179
				iSpare1(0),
sl@0
   180
				iSpare2(0),
sl@0
   181
				iSpare3(0),
sl@0
   182
				iSpare4(0),
sl@0
   183
				iSpare5(0),
sl@0
   184
				iSpare6(0),
sl@0
   185
				iSpare7(0)
sl@0
   186
				{};        
sl@0
   187
		   
sl@0
   188
			static void Install(DStopModeExtension* aExt);
sl@0
   189
			
sl@0
   190
		public:
sl@0
   191
			Debug::DFunctionalityBlock* iFunctionalityBlock;
sl@0
   192
			TUint32 iSpare1;
sl@0
   193
			TUint32 iSpare2;
sl@0
   194
			TUint32 iSpare3;
sl@0
   195
			TUint32 iSpare4;
sl@0
   196
			TUint32 iSpare5;
sl@0
   197
			TUint32 iSpare6;
sl@0
   198
			TUint32 iSpare7;
sl@0
   199
		};
sl@0
   200
sl@0
   201
	/**
sl@0
   202
	 * This is the interface to the stop mode debug API. The ROM resident address of these functions can be found 
sl@0
   203
	 * from the Debug Functionality block via the superpage. It may be assumed that all of these functions
sl@0
   204
	 * will exit via the function ExitPoint and thus setting a breakpoint there will capture the end of execution.
sl@0
   205
	 * For more detailed information, see the stop mode guide.
sl@0
   206
	 */
sl@0
   207
	class StopModeDebug
sl@0
   208
			{
sl@0
   209
			public:
sl@0
   210
				/**
sl@0
   211
				 * Stop mode debug API. Call this to action any request for information, or to manipulate
sl@0
   212
				 * debug data.
sl@0
   213
				 * 
sl@0
   214
				 * This is a stateless interface - it does not record information about previous invocations. It
sl@0
   215
				 * does not take any OS locks, wait on any synchronisation objects, allocate/deallocate heap memory or call
sl@0
   216
				 * ANY OS routines (unless documented as doing so). It will not cause any exceptions due to page faults,
sl@0
   217
				 * but will report that it encountered such problems where appropriate.
sl@0
   218
				 *
sl@0
   219
				 * @pre This must be called with a valid stack in supervisor mode. There are no exceptions/interrupts
sl@0
   220
				 * enabled which will cause the OS state to change during the execution of this routine.
sl@0
   221
				 * @args aItem Structure describing the list we want to retrieve
sl@0
   222
				 * @args aCheckConsistent If true, this will honour any locks the system holds and return KErrNotReady
sl@0
   223
				 * @return KErrNone on success or one of the other system wide error codes.
sl@0
   224
				 */
sl@0
   225
				IMPORT_C static TInt GetList(const TListItem* aItem, TBool aCheckConsistent);
sl@0
   226
sl@0
   227
				/**
sl@0
   228
				 * Stop mode debug API
sl@0
   229
				 * 
sl@0
   230
				 * This is a test function that allows us to test our communications with the hardware debugger
sl@0
   231
				 * 
sl@0
   232
				 * @pre This must be called with a valid stack in supervisor mode. There are no exceptions/interrupts
sl@0
   233
				 * enabled which will cause the OS state to change during the execution of this routine.
sl@0
   234
				 * @args aItem Structure describing the list we want to retrieve
sl@0
   235
				 * @return KErrNone on success or one of the other system wide error codes.
sl@0
   236
				 */
sl@0
   237
				IMPORT_C static TInt TestAPI(const TListItem* aItem);
sl@0
   238
sl@0
   239
			public:	
sl@0
   240
				static TInt ExitPoint(const TInt aReturnValue);
sl@0
   241
sl@0
   242
			private:
sl@0
   243
				/** Code segment list routines */
sl@0
   244
				static TInt ProcessCodeSeg(TUint8*& aBuffer, TUint32& aBufferSize, DEpocCodeSeg* aCodeSeg);
sl@0
   245
			
sl@0
   246
				//TODO: Horrible signature. Structify it
sl@0
   247
				static TInt AppendCodeSegData(TUint8*& aBuffer, TUint32& aBufferSize, const TModuleMemoryInfo& aMemoryInfo, const TBool aIsXip, const TCodeSegType aCodeSegType, const TDesC8& aFileName, DEpocCodeSeg* aCodeSeg);
sl@0
   248
				static TInt GetCodeSegList(const TListItem* aItem, bool aCheckConsistent);
sl@0
   249
				static DEpocCodeSeg* GetNextCodeSeg(const TUint32 aStart, const Debug::TListScope aListScope, const TUint64 aScopeData);
sl@0
   250
				static DEpocCodeSeg* GetNextGlobalCodeSeg(const TUint32 aStart);
sl@0
   251
				static DEpocCodeSeg* GetNextThreadSpecificCodeSeg(const TUint32 aStart, const TUint64 aThreadId);
sl@0
   252
sl@0
   253
				/** Process list routines */
sl@0
   254
				static TInt GetProcessList(const TListItem* aItem, bool aCheckConsistent);	
sl@0
   255
				static TInt AppendProcessToBuffer(DProcess* aProc, TUint8* aBuffer, TUint8* aBufferEnd, TUint32& aProcSize);
sl@0
   256
				
sl@0
   257
				/** Static Info Retrieval routines */
sl@0
   258
				static TInt GetStaticInfo(const TListItem* aItem, bool aCheckConsistent);
sl@0
   259
				
sl@0
   260
				static void GetObjectFullName(const DObject* aObj, TFullName& aName);
sl@0
   261
		
sl@0
   262
				/** Utility functions */
sl@0
   263
				static TInt CopyAndExpandDes(const TDesC& aSrc, TDes& aDest);
sl@0
   264
				
sl@0
   265
			};
sl@0
   266
sl@0
   267
	};
sl@0
   268
#endif // D_STOP_MODE_API_H
sl@0
   269
sl@0
   270
// End of file sm_debug_api.h