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