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