kernel/eka/drivers/debug/smdebug/d_stopmode.cpp
changeset 0 a41df078684a
child 43 c1f20ce4abcf
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 2009 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 "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Responsible for dealing with requests for the SM interface
       
    15 //
       
    16 
       
    17 /**
       
    18 @file
       
    19 @internalComponent
       
    20 @prototype
       
    21 */
       
    22 
       
    23 #include <rm_debug_api.h>
       
    24 #include <sm_debug_api.h>
       
    25 
       
    26 #include "d_rmd_breakpoints.h"
       
    27 
       
    28 
       
    29 #ifdef __LAUNCH_AS_EXTENSION__
       
    30 
       
    31 using namespace Debug;
       
    32 
       
    33 _LIT(KLitLocal,"Local-");
       
    34 _LIT(KColonColon,"::");
       
    35 
       
    36 /**
       
    37  * This is the generic exit point for all stop mode routines
       
    38  * @param aReturnValue Symbian Error Code to return
       
    39  * @return One of the Symbian wide error codes
       
    40  */
       
    41 EXPORT_C TInt StopModeDebug::ExitPoint(const TInt aReturnValue)
       
    42 	{
       
    43 	return aReturnValue;
       
    44 	}
       
    45 
       
    46 /**
       
    47  * This is the routine that shall return lists of information such as
       
    48  * process list or code segment list etc
       
    49  * @pre aItem->iBufferAddress must be word aligned
       
    50  * @param aItem Describes the list to retrieve
       
    51  * @param aCheckConsistent Should we check the mutex on the list
       
    52  * @return One of the Symbian wide error codes
       
    53  */
       
    54 EXPORT_C TInt StopModeDebug::GetList(const TListItem* aItem, TBool aCheckConsistent)
       
    55 	{
       
    56 	//Check arguments
       
    57 	if(!aItem ||
       
    58 		((TUint32)aItem->iBufferAddress == 0)||
       
    59 		((TUint32)aItem->iBufferAddress % 4) )
       
    60 		{
       
    61 		return StopModeDebug::ExitPoint(KErrArgument);
       
    62 		}
       
    63 
       
    64 	switch(aItem->iListId)
       
    65 		{
       
    66 		case ECodeSegs:
       
    67 			{
       
    68 			return StopModeDebug::ExitPoint(StopModeDebug::GetCodeSegList(aItem, aCheckConsistent));
       
    69 			}
       
    70 		case EProcesses:
       
    71 			{
       
    72 			return StopModeDebug::ExitPoint(StopModeDebug::GetProcessList(aItem, aCheckConsistent));
       
    73 			}
       
    74 		case EStaticInfo:
       
    75 		    {
       
    76 		    return StopModeDebug::ExitPoint(StopModeDebug::GetStaticInfo(aItem, aCheckConsistent));
       
    77 		    }
       
    78 		default:
       
    79 			{
       
    80 			return StopModeDebug::ExitPoint(KErrUnknown);
       
    81 			}
       
    82 		}
       
    83 	}
       
    84 
       
    85 TInt StopModeDebug::CopyAndExpandDes(const TDesC& aSrc, TDes& aDest)
       
    86 	{
       
    87 	//check bounds
       
    88 	if(aSrc.Length() * 2 > aDest.MaxLength())
       
    89 		{
       
    90 		return KErrArgument;
       
    91 		}
       
    92 
       
    93 	//get a pointer to the start of the destination descriptor
       
    94 	TUint16* destPtr = (TUint16*)aDest.Ptr();
       
    95 
       
    96 	//get pointers to the start and end of the aSrc descriptor
       
    97 	const TUint8* srcPtr = aSrc.Ptr();
       
    98 	const TUint8* srcEnd = srcPtr + aSrc.Length();
       
    99 
       
   100 	//copy the characters from aSrc into aDest, expanding to make them 16-bit characters
       
   101 	while(srcPtr < srcEnd)
       
   102 		{
       
   103 		*destPtr = (TUint16)*srcPtr;
       
   104 		destPtr++;
       
   105 		srcPtr++;
       
   106 		}
       
   107 
       
   108 	//set aDest's length to reflect the new contents
       
   109 	aDest.SetLength(2*aSrc.Length());
       
   110 	return KErrNone;
       
   111 	}
       
   112 
       
   113 /** 
       
   114  * This is a function used to test communications with the Stop Mode API
       
   115  * We pass in aItem which is interpreted in a different way to normal to allow 
       
   116  * us to test different scenarios:
       
   117  *		
       
   118  *		1. Sending in aItem.iSize = 0xFFFFFFFF will result in the response buffer being
       
   119  *		   filled with 0xFFFFFFFF
       
   120  *
       
   121  * @param aItem Drives the test according to its parameters
       
   122  */
       
   123 EXPORT_C TInt StopModeDebug::TestAPI(const TListItem* aItem)
       
   124 	{
       
   125 	//Check params are valid
       
   126 	if(!aItem	||	((TUint32)aItem->iBufferAddress % 4)	||
       
   127 		   ((TUint32)aItem->iBufferAddress == 0) ||
       
   128 		   (aItem->iBufferSize % 4)	)
       
   129 		{
       
   130 		return StopModeDebug::ExitPoint(KErrArgument);
       
   131 		}
       
   132 
       
   133 	//Performs the test function
       
   134 	if(aItem->iSize == 0xFFFFFFFF)
       
   135 		{		
       
   136 		//Write all 0xFFFFFFFF into the entire buffer
       
   137 		TUint8* pos = (TUint8*)aItem->iBufferAddress;
       
   138 		while(pos < (	(TUint8*)aItem->iBufferAddress + aItem->iBufferSize) )
       
   139 			{
       
   140 			*pos = 0xFF;
       
   141 			++pos;
       
   142 			}
       
   143 		}
       
   144 		
       
   145 	return StopModeDebug::ExitPoint(KErrNone);
       
   146 	}
       
   147 
       
   148 /**
       
   149  * Reads the raw name for this object instead of using API in DObject,
       
   150  * as we can't meet the preconditions
       
   151  * @param DObject object whose name we want
       
   152  */
       
   153 void StopModeDebug::GetObjectFullName(const DObject* aObj, TFullName& aName)
       
   154 	{
       
   155 	if(aObj->iOwner)
       
   156 		{
       
   157 		GetObjectFullName(aObj->iOwner, aName);
       
   158 		aName.Append(KColonColon);
       
   159 		}
       
   160 	
       
   161     if (aObj->iName)
       
   162 		{
       
   163         aName.Append(*aObj->iName);
       
   164 		}
       
   165      else
       
   166         {
       
   167         aName.Append(KLitLocal);
       
   168         aName.AppendNumFixedWidth((TInt)aObj,EHex,8);
       
   169         }
       
   170 	}
       
   171 
       
   172 #endif
       
   173 
       
   174 
       
   175 // End of file d_stopmode.cpp