sl@0: // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Responsible for dealing with requests for the SM interface sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: @prototype sl@0: */ sl@0: sl@0: #include sl@0: #include sl@0: sl@0: #include "d_rmd_breakpoints.h" sl@0: sl@0: sl@0: #ifdef __LAUNCH_AS_EXTENSION__ sl@0: sl@0: using namespace Debug; sl@0: sl@0: _LIT(KLitLocal,"Local-"); sl@0: _LIT(KColonColon,"::"); sl@0: sl@0: /** sl@0: * This is the generic exit point for all stop mode routines sl@0: * @param aReturnValue Symbian Error Code to return sl@0: * @return One of the Symbian wide error codes sl@0: */ sl@0: EXPORT_C TInt StopModeDebug::ExitPoint(const TInt aReturnValue) sl@0: { sl@0: return aReturnValue; sl@0: } sl@0: sl@0: /** sl@0: * This is the routine that shall return lists of information such as sl@0: * process list or code segment list etc sl@0: * @pre aItem->iBufferAddress must be word aligned sl@0: * @param aItem Describes the list to retrieve sl@0: * @param aCheckConsistent Should we check the mutex on the list sl@0: * @return One of the Symbian wide error codes sl@0: */ sl@0: EXPORT_C TInt StopModeDebug::GetList(const TListItem* aItem, TBool aCheckConsistent) sl@0: { sl@0: //Check arguments sl@0: if(!aItem || sl@0: ((TUint32)aItem->iBufferAddress == 0)|| sl@0: ((TUint32)aItem->iBufferAddress % 4) ) sl@0: { sl@0: return StopModeDebug::ExitPoint(KErrArgument); sl@0: } sl@0: sl@0: switch(aItem->iListId) sl@0: { sl@0: case ECodeSegs: sl@0: { sl@0: return StopModeDebug::ExitPoint(StopModeDebug::GetCodeSegList(aItem, aCheckConsistent)); sl@0: } sl@0: case EProcesses: sl@0: { sl@0: return StopModeDebug::ExitPoint(StopModeDebug::GetProcessList(aItem, aCheckConsistent)); sl@0: } sl@0: case EStaticInfo: sl@0: { sl@0: return StopModeDebug::ExitPoint(StopModeDebug::GetStaticInfo(aItem, aCheckConsistent)); sl@0: } sl@0: default: sl@0: { sl@0: return StopModeDebug::ExitPoint(KErrUnknown); sl@0: } sl@0: } sl@0: } sl@0: sl@0: TInt StopModeDebug::CopyAndExpandDes(const TDesC& aSrc, TDes& aDest) sl@0: { sl@0: //check bounds sl@0: if(aSrc.Length() * 2 > aDest.MaxLength()) sl@0: { sl@0: return KErrArgument; sl@0: } sl@0: sl@0: //get a pointer to the start of the destination descriptor sl@0: TUint16* destPtr = (TUint16*)aDest.Ptr(); sl@0: sl@0: //get pointers to the start and end of the aSrc descriptor sl@0: const TUint8* srcPtr = aSrc.Ptr(); sl@0: const TUint8* srcEnd = srcPtr + aSrc.Length(); sl@0: sl@0: //copy the characters from aSrc into aDest, expanding to make them 16-bit characters sl@0: while(srcPtr < srcEnd) sl@0: { sl@0: *destPtr = (TUint16)*srcPtr; sl@0: destPtr++; sl@0: srcPtr++; sl@0: } sl@0: sl@0: //set aDest's length to reflect the new contents sl@0: aDest.SetLength(2*aSrc.Length()); sl@0: return KErrNone; sl@0: } sl@0: sl@0: /** sl@0: * This is a function used to test communications with the Stop Mode API sl@0: * We pass in aItem which is interpreted in a different way to normal to allow sl@0: * us to test different scenarios: sl@0: * sl@0: * 1. Sending in aItem.iSize = 0xFFFFFFFF will result in the response buffer being sl@0: * filled with 0xFFFFFFFF sl@0: * sl@0: * @param aItem Drives the test according to its parameters sl@0: */ sl@0: EXPORT_C TInt StopModeDebug::TestAPI(const TListItem* aItem) sl@0: { sl@0: //Check params are valid sl@0: if(!aItem || ((TUint32)aItem->iBufferAddress % 4) || sl@0: ((TUint32)aItem->iBufferAddress == 0) || sl@0: (aItem->iBufferSize % 4) ) sl@0: { sl@0: return StopModeDebug::ExitPoint(KErrArgument); sl@0: } sl@0: sl@0: //Performs the test function sl@0: if(aItem->iSize == 0xFFFFFFFF) sl@0: { sl@0: //Write all 0xFFFFFFFF into the entire buffer sl@0: TUint8* pos = (TUint8*)aItem->iBufferAddress; sl@0: while(pos < ( (TUint8*)aItem->iBufferAddress + aItem->iBufferSize) ) sl@0: { sl@0: *pos = 0xFF; sl@0: ++pos; sl@0: } sl@0: } sl@0: sl@0: return StopModeDebug::ExitPoint(KErrNone); sl@0: } sl@0: sl@0: /** sl@0: * Reads the raw name for this object instead of using API in DObject, sl@0: * as we can't meet the preconditions sl@0: * @param DObject object whose name we want sl@0: */ sl@0: void StopModeDebug::GetObjectFullName(const DObject* aObj, TFullName& aName) sl@0: { sl@0: if(aObj->iOwner) sl@0: { sl@0: GetObjectFullName(aObj->iOwner, aName); sl@0: aName.Append(KColonColon); sl@0: } sl@0: sl@0: if (aObj->iName) sl@0: { sl@0: aName.Append(*aObj->iName); sl@0: } sl@0: else sl@0: { sl@0: aName.Append(KLitLocal); sl@0: aName.AppendNumFixedWidth((TInt)aObj,EHex,8); sl@0: } sl@0: } sl@0: sl@0: #endif sl@0: sl@0: sl@0: // End of file d_stopmode.cpp