First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\mmu\d_shadow.h
18 #if !defined(__D_SHADOW_H__)
19 #define __D_SHADOW_H__
21 #ifndef __KERNEL_MODE__
42 #ifdef __KERNEL_MODE__
44 // Memory Model Architecture
47 const TUint KPageDirectorySize = 1024;
48 const TUint KMaxNumberOfPageDirectories = 1024;
49 const TUint KPsudoX86TTBCR = 512;
52 const TUint KPageDirectorySize = 4096; // Full size (ttbr0+ttbr1)
53 const TUint KMaxNumberOfPageDirectories = 256;
56 #if defined(__MEMMODEL_MOVING__)
57 const TUint KPageDirectoryBase = 0x61000000;
58 const TUint KPageTableBase = 0x62000000;
59 const TMemModel KMemoryModel = EMemModelMoving;
61 #elif defined(__MEMMODEL_MULTIPLE__)
62 const TUint KPageDirectoryBase = 0xC1000000;
63 const TUint KPageTableBase = 0xC2000000;
64 const TMemModel KMemoryModel = EMemModelMultiple;
66 #elif defined(__MEMMODEL_FLEXIBLE__)
67 const TUint KPageDirectoryBase = 0xF4000000u;
68 const TUint KPageTableBase = 0xF8000000u;
69 const TMemModel KMemoryModel = EMemModelFlexible;
71 #else // other memory model
72 const TUint KPageDirectoryBase = 0x00000000;
73 const TUint KPageTableBase = 0x00000000;
74 const TMemModel KMemoryModel = EMemModelOther;
87 const TUint KGlobalPageDirectory=0xFFFFFFFF;
88 const TUint KErrNoPageTable = 0x80000000;
89 const TUint KPageOffsetMask = 0x7FFFFFFF;
91 class RShadow : public RBusLogicalChannel
104 EControlMeasureKernStackUse,
105 EControlMeasureKernHeapFree,
107 EControlCallFunction,
111 EControlGetMemoryArchitecture,
112 EControlGetMemModelInfo,
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);
139 #ifndef __KERNEL_MODE__
140 inline TInt RShadow::Open()
142 return DoCreate(_L("Shadow"),TVersion(0,1,1),KNullUnit,NULL,NULL);
145 inline TInt RShadow::Alloc(TUint anAddr)
146 { return DoControl(EControlAllocShadow,(TAny*)anAddr); }
148 inline TInt RShadow::Free(TUint anAddr)
149 { return DoControl(EControlFreeShadow,(TAny*)anAddr); }
151 inline TInt RShadow::Write(TUint anAddr, TAny *aSrc)
152 { return DoControl(EControlWriteShadow,(TAny*)anAddr,aSrc); }
154 inline TInt RShadow::Freeze(TUint anAddr)
155 { return DoControl(EControlFreezeShadow,(TAny*)anAddr); }
157 inline TInt RShadow::SetPriority(TInt aHandle, TInt aPriority)
158 { return DoControl(EControlSetPriority, (TAny*)aHandle, (TAny*)aPriority); }
160 inline TUint RShadow::Read(TUint aLinAddr)
161 { return DoControl(EControlRead, (TAny*)aLinAddr); }
163 inline TUint RShadow::MmuId()
164 { return DoControl(EControlMmuId); }
166 inline TUint RShadow::CacheType()
167 { return DoControl(EControlCacheType); }
169 inline TInt RShadow::KernStackUsed()
170 { return DoControl(EControlMeasureKernStackUse); }
172 inline TInt RShadow::KernHeapFree()
173 { return DoControl(EControlMeasureKernHeapFree); }
175 inline void RShadow::WalkHeap(TInt aThreadHandle)
176 { DoControl(EControlWalkHeap,(TAny*)aThreadHandle); }
178 inline TInt RShadow::CallFunction(TThreadFunction aFunction, TAny* aPtr)
179 { return DoControl(EControlCallFunction, (TAny*)aFunction, aPtr); }
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; }
184 inline TInt RShadow::FreePhysicalRam(TUint32 aAddr, TInt aSize)
185 { return DoControl(EControlFreePhys, (TAny*)aAddr, (TAny*)aSize); }
187 inline TInt RShadow::ClaimPhysicalRam(TUint32 aAddr, TInt aSize)
188 { return DoControl(EControlClaimPhys, (TAny*)aAddr, (TAny*)aSize); }
190 inline void RShadow::GetMemoryArchitecture(TCpu &aCpu, TUint &aCR)
191 { DoControl(EControlGetMemoryArchitecture, (TAny*) &aCpu, (TAny*) &aCR); }
193 inline TMemModel RShadow::GetMemModelInfo(TUint &aPageTable, TUint &aNumPds)
194 { return (TMemModel) DoControl(EControlGetMemModelInfo,(TAny*) &aPageTable, (TAny*) &aNumPds); }
196 inline TInt RShadow::GetPdInfo(TUint aPdNo, TUint &aPdSize, TUint &aPdBase, TUint &aOffset)
199 TUint ret= (TUint) DoControl(EControlGetPdInfo,(TAny*) &aPdSize, (TAny*) &aPdBase);
200 aOffset = ret & KPageOffsetMask;
201 return (ret & KErrNoPageTable)?KErrNotFound:KErrNone;