0
|
1 |
// Copyright (c) 1998-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 |
// e32\include\memmodel\epoc\multiple\arm\arm_mem.h
|
|
15 |
//
|
|
16 |
// WARNING: This file contains some APIs which are internal and are subject
|
|
17 |
// to change without notice. Such APIs should therefore not be used
|
|
18 |
// outside the Kernel and Hardware Services package.
|
|
19 |
//
|
|
20 |
|
|
21 |
/**
|
|
22 |
@file
|
|
23 |
@internalComponent
|
|
24 |
*/
|
|
25 |
|
|
26 |
#ifndef __ARM_MEM_H__
|
|
27 |
#define __ARM_MEM_H__
|
|
28 |
#include <mmboot.h>
|
|
29 |
|
|
30 |
#if defined (__CPU_USE_SHARED_MEMORY)
|
|
31 |
#define SHARABLE_PDE KArmV6PdeSectionS
|
|
32 |
#define SHARABLE_PTE KArmV6PteS
|
|
33 |
#else
|
|
34 |
#define SHARABLE_PDE 0
|
|
35 |
#define SHARABLE_PTE 0
|
|
36 |
#endif
|
|
37 |
|
|
38 |
/** Section entry in the 1st level (aka page directory) descriptor*/
|
|
39 |
#define SECTION_PDE(perm, attr, domain, execute, global) \
|
|
40 |
( (((perm)&3)<<10)|(((perm)&4)<<13) |\
|
|
41 |
(((attr)&3)<<2)|(((attr)&28)<<10) |\
|
|
42 |
((domain)<<5) |\
|
|
43 |
((execute)?0:KArmV6PdeSectionXN) |\
|
|
44 |
((global)?0:KArmV6PdeSectionNG) |\
|
|
45 |
(SHARABLE_PDE) |\
|
|
46 |
KArmV6PdeSection )
|
|
47 |
|
|
48 |
/** Page table entry in the 1st level (aka page directory) descriptor*/
|
|
49 |
#define PT_PDE(domain) (KArmV6PdePageTable|((domain)<<5))
|
|
50 |
|
|
51 |
/** Large page (64K) entry in the 2nd level (aka page table) descriptor*/
|
|
52 |
#define LP_PTE(perm, attr, execute, global) \
|
|
53 |
( (((perm)&3)<<4)|(((perm)&4)<<7) |\
|
|
54 |
(((attr)&3)<<2)|(((attr)&28)<<10) |\
|
|
55 |
((execute)?0:KArmV6PteLargeXN) |\
|
|
56 |
((global)?0:KArmV6PteNG) |\
|
|
57 |
(SHARABLE_PTE) |\
|
|
58 |
KArmV6PteLargePage )
|
|
59 |
|
|
60 |
/** Small page (4K) entry in the 2nd level (aka page table) descriptor*/
|
|
61 |
#define SP_PTE(perm, attr, execute, global) \
|
|
62 |
( (((perm)&3)<<4)|(((perm)&4)<<7) |\
|
|
63 |
(((attr)&3)<<2)|(((attr)&28)<<4) |\
|
|
64 |
((execute)?0:KArmV6PteSmallXN) |\
|
|
65 |
((global)?0:KArmV6PteNG) |\
|
|
66 |
(SHARABLE_PTE) |\
|
|
67 |
KArmV6PteSmallPage )
|
|
68 |
|
|
69 |
#define SECTION_PDE_FROM_PDEPTE(pde, pte) \
|
|
70 |
( (((pte)<< 6)&0x0003fc00) |\
|
|
71 |
(((pde) )&0x000003e0) |\
|
|
72 |
(((pte)<< 4)&0x00000010) |\
|
|
73 |
(((pte) )&0x0000000c) |\
|
|
74 |
KArmV6PdeSection )
|
|
75 |
|
|
76 |
#define LP_PTE_FROM_SP_PTE(pte) \
|
|
77 |
( (((pte)<<15)&0x00008000) |\
|
|
78 |
(((pte)<< 6)&0x00007000) |\
|
|
79 |
(((pte) )&0x00000e3c) |\
|
|
80 |
KArmV6PteLargePage )
|
|
81 |
|
|
82 |
#define SP_PTE_FROM_LP_PTE(pte) \
|
|
83 |
( (((pte)>>15)&0x00000001) |\
|
|
84 |
(((pte)>> 6)&0x000001c0) |\
|
|
85 |
(((pte) )&0x00000e3c) |\
|
|
86 |
KArmV6PteSmallPage )
|
|
87 |
|
|
88 |
#define SP_PTE_PERM_SET(pte, perm) \
|
|
89 |
( ((pte)&~KArmV6PtePermMask) |\
|
|
90 |
(((perm)&3)<<4)|(((perm)&4)<<7) )
|
|
91 |
|
|
92 |
#define SP_PTE_PERM_GET(pte) \
|
|
93 |
( (((pte)>> 4)&0x00000003) |\
|
|
94 |
(((pte)>> 7)&0x00000004) )
|
|
95 |
|
|
96 |
TPde* const InitPageDirectory = ((TPde*)KPageDirectoryBase); // initial page directory
|
|
97 |
|
|
98 |
inline TPde* PageDirectory(TInt aOsAsid)
|
|
99 |
{
|
|
100 |
return (TPde*)(KPageDirectoryBase+(aOsAsid<<KPageDirectoryShift));
|
|
101 |
}
|
|
102 |
|
|
103 |
class DArmPlatThread : public DMemModelThread
|
|
104 |
{
|
|
105 |
public:
|
|
106 |
~DArmPlatThread();
|
|
107 |
virtual TInt SetupContext(SThreadCreateInfo& anInfo);
|
|
108 |
virtual TInt Context(TDes8& aDes);
|
|
109 |
virtual void DoExit2();
|
|
110 |
public:
|
|
111 |
friend class Monitor;
|
|
112 |
};
|
|
113 |
|
|
114 |
class DArmPlatProcess : public DMemModelProcess
|
|
115 |
{
|
|
116 |
public:
|
|
117 |
DArmPlatProcess();
|
|
118 |
~DArmPlatProcess();
|
|
119 |
public:
|
|
120 |
virtual TInt GetNewChunk(DMemModelChunk*& aChunk, SChunkCreateInfo& aInfo);
|
|
121 |
virtual TInt GetNewThread(DThread*& aThread, SThreadCreateInfo& aInfo);
|
|
122 |
private:
|
|
123 |
friend class Monitor;
|
|
124 |
};
|
|
125 |
|
|
126 |
class DArmPlatChunk : public DMemModelChunk
|
|
127 |
{
|
|
128 |
public:
|
|
129 |
DArmPlatChunk();
|
|
130 |
~DArmPlatChunk();
|
|
131 |
TInt Create(SChunkCreateInfo& aInfo);
|
|
132 |
virtual TInt SetupPermissions();
|
|
133 |
TInt SetAttributes(SChunkCreateInfo& aInfo);
|
|
134 |
public:
|
|
135 |
friend class Monitor;
|
|
136 |
};
|
|
137 |
|
|
138 |
class ArmMmu : public Mmu
|
|
139 |
{
|
|
140 |
public:
|
|
141 |
// overriding MmuBase
|
|
142 |
virtual void Init1();
|
|
143 |
// virtual void Init2();
|
|
144 |
virtual void DoInit2();
|
|
145 |
virtual TBool PteIsPresent(TPte aPte);
|
|
146 |
virtual TPhysAddr PtePhysAddr(TPte aPte, TInt aPteIndex);
|
|
147 |
virtual TPhysAddr PdePhysAddr(TLinAddr aAddr);
|
|
148 |
// virtual void SetupInitialPageInfo(SPageInfo* aPageInfo, TLinAddr aChunkAddr, TInt aPdeIndex);
|
|
149 |
// virtual void SetupInitialPageTableInfo(TInt aId, TLinAddr aChunkAddr, TInt aNumPtes);
|
|
150 |
// virtual void AssignPageTable(TInt aId, TInt aUsage, TAny* aObject, TLinAddr aAddr, TPde aPdePerm);
|
|
151 |
// virtual TInt UnassignPageTable(TLinAddr aAddr);
|
|
152 |
virtual void BootstrapPageTable(TInt aXptId, TPhysAddr aXptPhys, TInt aId, TPhysAddr aPhysAddr);
|
|
153 |
virtual void FixupXPageTable(TInt aId, TLinAddr aTempMap, TPhysAddr aOld, TPhysAddr aNew);
|
|
154 |
// virtual TInt PageTableId(TLinAddr aAddr);
|
|
155 |
virtual TInt BootPageTableId(TLinAddr aAddr, TPhysAddr& aPtPhys);
|
|
156 |
virtual void ClearPageTable(TInt aId, TInt aFirstIndex=0);
|
|
157 |
// virtual TPhysAddr LinearToPhysical(TLinAddr aAddr);
|
|
158 |
virtual void MapRamPages(TInt aId, SPageInfo::TType aType, TAny* aPtr, TUint32 aOffset, const TPhysAddr* aPageList, TInt aNumPages, TPte aPtePerm);
|
|
159 |
virtual void MapPhysicalPages(TInt aId, SPageInfo::TType aType, TAny* aPtr, TUint32 aOffset, TPhysAddr aPhysAddr, TInt aNumPages, TPte aPtePerm);
|
|
160 |
virtual void RemapPage(TInt aId, TUint32 aAddr, TPhysAddr aOldAddr, TPhysAddr aNewAddr, TPte aPtePerm, DProcess* aProcess);
|
|
161 |
virtual TInt UnmapPages(TInt aId, TUint32 aAddr, TInt aNumPages, TPhysAddr* aPageList, TBool aSetPagesFree, TInt& aNumPtes, TInt& aNumFree, DProcess* aProcess);
|
|
162 |
virtual TInt UnmapUnownedPages(TInt aId, TUint32 aAddr, TInt aNumPages, TPhysAddr* aPageList, TLinAddr* aLAPageList, TInt& aNumPtes, TInt& aNumFree, DProcess* aProcess);
|
|
163 |
virtual void ClearRamDrive(TLinAddr aStart);
|
286
|
164 |
virtual TInt PdePtePermissions(TUint& aMapAttr, TPde& aPde, TPte& aPte, TBool aGlobal);
|
0
|
165 |
virtual void Map(TLinAddr aLinAddr, TPhysAddr aPhysAddr, TInt aSize, TPde aPdePerm, TPte aPtePerm, TInt aMapShift);
|
|
166 |
virtual void Unmap(TLinAddr aLinAddr, TInt aSize);
|
|
167 |
virtual void InitShadowPageTable(TInt aId, TLinAddr aRomAddr, TPhysAddr aOrigPhys);
|
|
168 |
virtual void InitShadowPage(TPhysAddr aShadowPhys, TLinAddr aRomAddr);
|
|
169 |
virtual void DoUnmapShadowPage(TInt aId, TLinAddr aRomAddr, TPhysAddr aOrigPhys);
|
|
170 |
virtual TInt UnassignShadowPageTable(TLinAddr aRomAddr, TPhysAddr aOrigPhys);
|
|
171 |
virtual void DoFreezeShadowPage(TInt aId, TLinAddr aRomAddr);
|
|
172 |
virtual void FlushShadow(TLinAddr aRomAddr);
|
|
173 |
virtual void AssignShadowPageTable(TInt aId, TLinAddr aRomAddr);
|
|
174 |
virtual void ClearPages(TInt aNumPages, TPhysAddr* aPageList, TUint8 aClearByte);
|
|
175 |
virtual void Pagify(TInt aId, TLinAddr aLinAddr);
|
|
176 |
#if defined(__CPU_MEMORY_TYPE_REMAPPING) // arm1176, arm11mcore, armv7, ...
|
|
177 |
virtual TInt CopyToShadowMemory(TLinAddr aDest, TLinAddr aSrc, TUint32 aLength);
|
|
178 |
#endif
|
|
179 |
virtual TPte PtePermissions(TChunkType aChunkType);
|
|
180 |
virtual TInt RamDefragFault(TAny* aExceptionInfo);
|
|
181 |
virtual void DisablePageModification(DMemModelChunk* aChunk, TInt aOffset);
|
|
182 |
|
|
183 |
// overriding Mmu
|
|
184 |
virtual TInt NewPageDirectory(TInt aOsAsid, TBool aSeparateGlobal, TPhysAddr& aPhysAddr, TInt& aNumPages);
|
|
185 |
virtual void InitPageDirectory(TInt aOsAsid, TBool aGlobal);
|
|
186 |
virtual TInt PageTableId(TLinAddr aAddr, TInt aOsAsid);
|
|
187 |
virtual TPhysAddr LinearToPhysical(TLinAddr aAddr, TInt aOsAsid);
|
|
188 |
// virtual TPhysAddr LinearToPhysical(TLinAddr aAddr, TInt aOsAsid, TInt& aPerm, TInt& aAttr);
|
|
189 |
virtual TInt LinearToPhysical(TLinAddr aAddr, TInt aSize, TPhysAddr& aPhysicalAddress, TPhysAddr* aPhysicalPageList, TInt aOsAsid);
|
|
190 |
virtual TInt PreparePagesForDMA(TLinAddr aAddr, TInt aSize, TInt aOsAsid, TPhysAddr* aPhysicalPageList);
|
|
191 |
virtual TInt ReleasePagesFromDMA(TPhysAddr* aPhysicalPageList, TInt aPageCount);
|
|
192 |
virtual void DoAssignPageTable(TInt aId, TLinAddr aAddr, TPde aPdePerm, const TAny* aOsAsids);
|
|
193 |
virtual void RemapPageTableSingle(TPhysAddr aOld, TPhysAddr aNew, TLinAddr aAddr, TInt aOsAsid);
|
|
194 |
virtual void RemapPageTableMultiple(TPhysAddr aOld, TPhysAddr aNew, TLinAddr aAddr, const TAny* aOsAsids);
|
|
195 |
virtual void RemapPageTableGlobal(TPhysAddr aOld, TPhysAddr aNew, TLinAddr aAddr);
|
|
196 |
virtual void RemapPageTableAliases(TPhysAddr aOld, TPhysAddr aNew);
|
|
197 |
virtual void DoUnassignPageTable(TLinAddr aAddr, const TAny* aOsAsids);
|
|
198 |
virtual TPde PdePermissions(TChunkType aChunkType, TBool aRO);
|
|
199 |
virtual void ApplyTopLevelPermissions(TLinAddr aAddr, TInt aOsAsid, TInt aNumPdes, TPde aPdePerm);
|
|
200 |
virtual void ApplyPagePermissions(TInt aId, TInt aPageOffset, TInt aNumPages, TPte aPtePerm);
|
|
201 |
virtual void GenericFlush(TUint32 aMask);
|
|
202 |
virtual TLinAddr MapTemp(TPhysAddr aPage,TLinAddr aLinAddr, TInt aPages=1);
|
|
203 |
virtual TLinAddr MapTemp(TPhysAddr aPage,TLinAddr aLinAddr,TInt aPages, TMemoryType aMemType);
|
|
204 |
virtual TLinAddr MapSecondTemp(TPhysAddr aPage,TLinAddr aLinAddr, TInt aPages=1);
|
|
205 |
virtual void UnmapTemp();
|
|
206 |
virtual void UnmapSecondTemp();
|
|
207 |
virtual TBool ValidateLocalIpcAddress(TLinAddr aAddr,TInt aSize,TBool aWrite);
|
|
208 |
virtual TInt UnlockRamCachePages(TLinAddr aLinAddr, TInt aNumPages, DProcess* aProcess);
|
|
209 |
virtual TInt LockRamCachePages(TLinAddr aLinAddr, TInt aNumPages, DProcess* aProcess);
|
|
210 |
virtual void MapVirtual(TInt aId, TInt aNumPages);
|
|
211 |
virtual TInt UnmapVirtual(TInt aId, TUint32 aAddr, TInt aNumPages, TPhysAddr* aPageList, TBool aSetPagesFree, TInt& aNumPtes, TInt& aNumFree, DProcess* aProcess);
|
|
212 |
virtual TInt UnmapUnownedVirtual(TInt aId, TUint32 aAddr, TInt aNumPages, TPhysAddr* aPageList, TLinAddr* aLAPageList, TInt& aNumPtes, TInt& aNumFree, DProcess* aProcess);
|
|
213 |
virtual void RemapPageByAsid(TBitMapAllocator* aOsAsids, TLinAddr aLinAddr, TPhysAddr aOldAddr, TPhysAddr aNewAddr, TPte aPtePerm);
|
|
214 |
virtual void CacheMaintenanceOnDecommit(const TPhysAddr* aPhysAddr, TInt aPageCount);
|
|
215 |
virtual void CacheMaintenanceOnDecommit(const TPhysAddr aPhysAddr);
|
|
216 |
virtual void CacheMaintenanceOnPreserve(const TPhysAddr* aPhysAddr, TInt aPageCount, TUint iMapAttr);
|
|
217 |
virtual void CacheMaintenanceOnPreserve(const TPhysAddr aPhysAddr, TUint iMapAttr);
|
|
218 |
virtual void CacheMaintenanceOnPreserve(TPhysAddr aPhysAddr, TInt aSize, TLinAddr aLinAddr, TUint iMapAttr);
|
|
219 |
static void UnlockAlias();
|
|
220 |
static void LockAlias();
|
|
221 |
private:
|
|
222 |
TInt iTempMapColor;
|
|
223 |
TInt iSecondTempMapColor;
|
|
224 |
public:
|
|
225 |
friend class TScheduler;
|
|
226 |
friend class Monitor;
|
|
227 |
};
|
|
228 |
|
|
229 |
GLREF_D ArmMmu TheMmu;
|
|
230 |
|
|
231 |
#if !defined(__CPU_ARM1136__) || !defined(__CPU_ARM1136_ERRATUM_399234_FIXED)
|
|
232 |
/**
|
|
233 |
Write-Through cache mode is not used by Kernel internally. Also, any request
|
|
234 |
(by device drivers) for Write-Through memory will be downgraded to buffered&non-cached memory.
|
|
235 |
*/
|
|
236 |
#define __CPU_WriteThroughDisabled
|
|
237 |
#endif
|
|
238 |
|
|
239 |
#endif // __ARM_MEM_H__
|