|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "MemSpyDriverLogChanRawMemory.h" |
|
19 |
|
20 // System includes |
|
21 #include <memspy/driver/memspydriverobjectsshared.h> |
|
22 |
|
23 // Shared includes |
|
24 #include "MemSpyDriverOpCodes.h" |
|
25 #include "MemSpyDriverObjectsInternal.h" |
|
26 |
|
27 // User includes |
|
28 #include "MemSpyDriverUtils.h" |
|
29 |
|
30 |
|
31 |
|
32 DMemSpyDriverLogChanRawMemory::DMemSpyDriverLogChanRawMemory( DMemSpyDriverDevice& aDevice, DThread& aThread ) |
|
33 : DMemSpyDriverLogChanBase( aDevice, aThread ) |
|
34 { |
|
35 TRACE( Kern::Printf("DMemSpyDriverLogChanRawMemory::DMemSpyDriverLogChanRawMemory() - this: 0x%08x", this )); |
|
36 } |
|
37 |
|
38 |
|
39 DMemSpyDriverLogChanRawMemory::~DMemSpyDriverLogChanRawMemory() |
|
40 { |
|
41 TRACE( Kern::Printf("DMemSpyDriverLogChanRawMemory::~DMemSpyDriverLogChanRawMemory() - START - this: 0x%08x", this )); |
|
42 |
|
43 TRACE( Kern::Printf("DMemSpyDriverLogChanRawMemory::~DMemSpyDriverLogChanRawMemory() - END - this: 0x%08x", this )); |
|
44 } |
|
45 |
|
46 |
|
47 |
|
48 TInt DMemSpyDriverLogChanRawMemory::Request( TInt aFunction, TAny* a1, TAny* a2 ) |
|
49 { |
|
50 TInt r = DMemSpyDriverLogChanBase::Request( aFunction, a1, a2 ); |
|
51 if ( r == KErrNone ) |
|
52 { |
|
53 switch( aFunction ) |
|
54 { |
|
55 case EMemSpyDriverOpCodeRawMemoryRead: |
|
56 r = ReadMem( (TMemSpyDriverInternalReadMemParams*) a1); |
|
57 break; |
|
58 |
|
59 default: |
|
60 r = KErrNotSupported; |
|
61 break; |
|
62 } |
|
63 } |
|
64 // |
|
65 return r; |
|
66 } |
|
67 |
|
68 |
|
69 TBool DMemSpyDriverLogChanRawMemory::IsHandler( TInt aFunction ) const |
|
70 { |
|
71 return ( aFunction > EMemSpyDriverOpCodeRawMemoryBase && aFunction < EMemSpyDriverOpCodeRawMemoryEnd ); |
|
72 } |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 TInt DMemSpyDriverLogChanRawMemory::ReadMem( TMemSpyDriverInternalReadMemParams* aParams ) |
|
83 { |
|
84 TRACE( Kern::Printf("DMemSpyDriverLogChanRawMemory::ReadMem() - START")); |
|
85 TMemSpyDriverInternalReadMemParams params; |
|
86 TInt r = Kern::ThreadRawRead( &ClientThread(), aParams, ¶ms, sizeof( TMemSpyDriverInternalReadMemParams ) ); |
|
87 // |
|
88 if ( r == KErrNone ) |
|
89 { |
|
90 NKern::ThreadEnterCS(); |
|
91 |
|
92 // Get user side descriptor length info |
|
93 TInt destLen = 0; |
|
94 TInt destMax = 0; |
|
95 TUint8* destPtr = NULL; |
|
96 r = Kern::ThreadGetDesInfo( &ClientThread(), params.iDes, destLen, destMax, destPtr, ETrue ); |
|
97 TRACE( Kern::Printf("DMemSpyDriverLogChanRawMemory::ReadMem - user side descriptor: 0x%08x (0x%08x), len: %8d, maxLen: %8d, r: %d", params.iDes, destPtr, destLen, destMax, r )); |
|
98 // |
|
99 r = OpenTempObject( params.iTid, EThread ); |
|
100 // |
|
101 if ( r == KErrNone ) |
|
102 { |
|
103 r = Kern::ThreadRawRead( (DThread*) TempObject(), (TAny*) params.iAddr, destPtr, destMax ); |
|
104 // |
|
105 if ( r == KErrNone ) |
|
106 { |
|
107 r = destMax; |
|
108 } |
|
109 else |
|
110 { |
|
111 Kern::Printf( "DMemSpyDriverLogChanRawMemory::ReadMem - could not xfer memory" ); |
|
112 } |
|
113 // |
|
114 CloseTempObject(); |
|
115 } |
|
116 else |
|
117 { |
|
118 Kern::Printf( "DMemSpyDriverLogChanRawMemory::ReadMem - could not open thread: %d", params.iTid ); |
|
119 } |
|
120 // |
|
121 NKern::ThreadLeaveCS(); |
|
122 } |
|
123 else |
|
124 { |
|
125 Kern::Printf( "DMemSpyDriverLogChanRawMemory::ReadMem - params read error" ); |
|
126 } |
|
127 // |
|
128 TRACE( Kern::Printf("DMemSpyDriverLogChanRawMemory::ReadMem() - END - r: %d", r)); |
|
129 return r; |
|
130 } |