|
1 // Copyright (c) 1997-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 // e32test\mmu\d_shadow.h |
|
15 // |
|
16 // |
|
17 |
|
18 #if !defined(__D_SHADOW_H__) |
|
19 #define __D_SHADOW_H__ |
|
20 #include <e32cmn.h> |
|
21 #ifndef __KERNEL_MODE__ |
|
22 #include <e32std.h> |
|
23 #endif |
|
24 |
|
25 |
|
26 enum TMemModel |
|
27 { |
|
28 EMemModelOther, |
|
29 EMemModelMoving, |
|
30 EMemModelMultiple, |
|
31 EMemModelFlexible |
|
32 }; |
|
33 |
|
34 enum TCpu |
|
35 { |
|
36 ECpuUnknown, |
|
37 ECpuArm, |
|
38 ECpuX86 |
|
39 }; |
|
40 |
|
41 |
|
42 #ifdef __KERNEL_MODE__ |
|
43 |
|
44 // Memory Model Architecture |
|
45 |
|
46 #ifdef __CPU_X86 |
|
47 const TUint KPageDirectorySize = 1024; |
|
48 const TUint KMaxNumberOfPageDirectories = 1024; |
|
49 const TUint KPsudoX86TTBCR = 512; |
|
50 |
|
51 #else |
|
52 const TUint KPageDirectorySize = 4096; // Full size (ttbr0+ttbr1) |
|
53 const TUint KMaxNumberOfPageDirectories = 256; |
|
54 #endif |
|
55 |
|
56 #if defined(__MEMMODEL_MOVING__) |
|
57 const TUint KPageDirectoryBase = 0x61000000; |
|
58 const TUint KPageTableBase = 0x62000000; |
|
59 const TMemModel KMemoryModel = EMemModelMoving; |
|
60 |
|
61 #elif defined(__MEMMODEL_MULTIPLE__) |
|
62 const TUint KPageDirectoryBase = 0xC1000000; |
|
63 const TUint KPageTableBase = 0xC2000000; |
|
64 const TMemModel KMemoryModel = EMemModelMultiple; |
|
65 |
|
66 #elif defined(__MEMMODEL_FLEXIBLE__) |
|
67 const TUint KPageDirectoryBase = 0xF4000000u; |
|
68 const TUint KPageTableBase = 0xF8000000u; |
|
69 const TMemModel KMemoryModel = EMemModelFlexible; |
|
70 |
|
71 #else // other memory model |
|
72 const TUint KPageDirectoryBase = 0x00000000; |
|
73 const TUint KPageTableBase = 0x00000000; |
|
74 const TMemModel KMemoryModel = EMemModelOther; |
|
75 #endif |
|
76 |
|
77 #endif |
|
78 |
|
79 |
|
80 |
|
81 class TCapsShadowV01 |
|
82 { |
|
83 public: |
|
84 TVersion iVersion; |
|
85 }; |
|
86 |
|
87 const TUint KGlobalPageDirectory=0xFFFFFFFF; |
|
88 const TUint KErrNoPageTable = 0x80000000; |
|
89 const TUint KPageOffsetMask = 0x7FFFFFFF; |
|
90 |
|
91 class RShadow : public RBusLogicalChannel |
|
92 { |
|
93 public: |
|
94 enum TControl |
|
95 { |
|
96 EControlAllocShadow, |
|
97 EControlFreeShadow, |
|
98 EControlWriteShadow, |
|
99 EControlFreezeShadow, |
|
100 EControlSetPriority, |
|
101 EControlRead, |
|
102 EControlMmuId, |
|
103 EControlCacheType, |
|
104 EControlMeasureKernStackUse, |
|
105 EControlMeasureKernHeapFree, |
|
106 EControlWalkHeap, |
|
107 EControlCallFunction, |
|
108 EControlAllocPhys, |
|
109 EControlFreePhys, |
|
110 EControlClaimPhys, |
|
111 EControlGetMemoryArchitecture, |
|
112 EControlGetMemModelInfo, |
|
113 EControlGetPdInfo |
|
114 }; |
|
115 |
|
116 public: |
|
117 inline TInt Open(); |
|
118 inline TInt Alloc(TUint anAddr); // allocate a shadow ROM page |
|
119 inline TInt Free(TUint anAddr); // free a shadow ROM page |
|
120 inline TInt Write(TUint anAddr, TAny* aSrc); // write to a shadow ROM page |
|
121 inline TInt Freeze(TUint anAddr); // freeze a shadow ROM page |
|
122 inline TInt SetPriority(TInt aHandle, TInt aPriority); |
|
123 inline TUint Read(TUint aLinAddr); |
|
124 inline TUint MmuId(); |
|
125 inline TUint CacheType(); |
|
126 inline TInt KernStackUsed(); |
|
127 inline TInt KernHeapFree(); |
|
128 inline void WalkHeap(TInt aThreadHandle); |
|
129 inline TInt CallFunction(TThreadFunction aFunction, TAny* aPtr); |
|
130 inline TInt AllocPhysicalRam(TUint32& aAddr, TInt aSize, TInt aAlign); |
|
131 inline TInt FreePhysicalRam(TUint32 aAddr, TInt aSize); |
|
132 inline TInt ClaimPhysicalRam(TUint32 aAddr, TInt aSize); |
|
133 inline void GetMemoryArchitecture(TCpu &aCpu, TUint &aCR); |
|
134 inline TMemModel GetMemModelInfo(TUint &aPageTable, TUint &aNumPds); |
|
135 inline TInt GetPdInfo(TUint aPdNo, TUint &aPdSize, TUint &aPdBase, TUint &aOffset); |
|
136 }; |
|
137 |
|
138 |
|
139 #ifndef __KERNEL_MODE__ |
|
140 inline TInt RShadow::Open() |
|
141 { |
|
142 return DoCreate(_L("Shadow"),TVersion(0,1,1),KNullUnit,NULL,NULL); |
|
143 } |
|
144 |
|
145 inline TInt RShadow::Alloc(TUint anAddr) |
|
146 { return DoControl(EControlAllocShadow,(TAny*)anAddr); } |
|
147 |
|
148 inline TInt RShadow::Free(TUint anAddr) |
|
149 { return DoControl(EControlFreeShadow,(TAny*)anAddr); } |
|
150 |
|
151 inline TInt RShadow::Write(TUint anAddr, TAny *aSrc) |
|
152 { return DoControl(EControlWriteShadow,(TAny*)anAddr,aSrc); } |
|
153 |
|
154 inline TInt RShadow::Freeze(TUint anAddr) |
|
155 { return DoControl(EControlFreezeShadow,(TAny*)anAddr); } |
|
156 |
|
157 inline TInt RShadow::SetPriority(TInt aHandle, TInt aPriority) |
|
158 { return DoControl(EControlSetPriority, (TAny*)aHandle, (TAny*)aPriority); } |
|
159 |
|
160 inline TUint RShadow::Read(TUint aLinAddr) |
|
161 { return DoControl(EControlRead, (TAny*)aLinAddr); } |
|
162 |
|
163 inline TUint RShadow::MmuId() |
|
164 { return DoControl(EControlMmuId); } |
|
165 |
|
166 inline TUint RShadow::CacheType() |
|
167 { return DoControl(EControlCacheType); } |
|
168 |
|
169 inline TInt RShadow::KernStackUsed() |
|
170 { return DoControl(EControlMeasureKernStackUse); } |
|
171 |
|
172 inline TInt RShadow::KernHeapFree() |
|
173 { return DoControl(EControlMeasureKernHeapFree); } |
|
174 |
|
175 inline void RShadow::WalkHeap(TInt aThreadHandle) |
|
176 { DoControl(EControlWalkHeap,(TAny*)aThreadHandle); } |
|
177 |
|
178 inline TInt RShadow::CallFunction(TThreadFunction aFunction, TAny* aPtr) |
|
179 { return DoControl(EControlCallFunction, (TAny*)aFunction, aPtr); } |
|
180 |
|
181 inline TInt RShadow::AllocPhysicalRam(TUint32& aAddr, TInt aSize, TInt aAlign) |
|
182 { TInt r=DoControl(EControlAllocPhys, (TAny*)aSize, (TAny*)aAlign); if (r>=0) aAddr=TUint32(r)<<4; return r<0?r:KErrNone; } |
|
183 |
|
184 inline TInt RShadow::FreePhysicalRam(TUint32 aAddr, TInt aSize) |
|
185 { return DoControl(EControlFreePhys, (TAny*)aAddr, (TAny*)aSize); } |
|
186 |
|
187 inline TInt RShadow::ClaimPhysicalRam(TUint32 aAddr, TInt aSize) |
|
188 { return DoControl(EControlClaimPhys, (TAny*)aAddr, (TAny*)aSize); } |
|
189 |
|
190 inline void RShadow::GetMemoryArchitecture(TCpu &aCpu, TUint &aCR) |
|
191 { DoControl(EControlGetMemoryArchitecture, (TAny*) &aCpu, (TAny*) &aCR); } |
|
192 |
|
193 inline TMemModel RShadow::GetMemModelInfo(TUint &aPageTable, TUint &aNumPds) |
|
194 { return (TMemModel) DoControl(EControlGetMemModelInfo,(TAny*) &aPageTable, (TAny*) &aNumPds); } |
|
195 |
|
196 inline TInt RShadow::GetPdInfo(TUint aPdNo, TUint &aPdSize, TUint &aPdBase, TUint &aOffset) |
|
197 { |
|
198 aPdSize=aPdNo; |
|
199 TUint ret= (TUint) DoControl(EControlGetPdInfo,(TAny*) &aPdSize, (TAny*) &aPdBase); |
|
200 aOffset = ret & KPageOffsetMask; |
|
201 return (ret & KErrNoPageTable)?KErrNotFound:KErrNone; |
|
202 } |
|
203 |
|
204 #endif |
|
205 |
|
206 #endif |