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