Update contrib.
1 // Copyright (c) 1994-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 // e32\memmodel\epoc\multiple\x86\xkernel.cpp
21 /********************************************
23 ********************************************/
25 TInt DX86PlatThread::SetupContext(SThreadCreateInfo& aInfo)
29 case EThreadSupervisor:
30 case EThreadMinimalSupervisor:
32 case EThreadAPInitial:
37 iNThread.SetAddressSpace(iOwningProcess);
38 iNThread.SetAttributes(KThreadAttAddressSpace);
40 iCpuRestoreCookie = -1;
42 iAliasPdePtr = &PageDirectory(((DMemModelProcess*)iOwningProcess)->iOsAsid)[KIPCAlias>>KChunkShift];
47 /********************************************
49 ********************************************/
51 DX86PlatProcess::DX86PlatProcess()
53 iAddressCheckMaskR=0x000fffffu; // addresses<0xA0000000 OK
54 iAddressCheckMaskW=0x0000ffffu; // addresses<0x80000000 OK
57 DX86PlatProcess::~DX86PlatProcess()
59 __KTRACE_OPT(KMMU,Kern::Printf("DX86PlatProcess destruct"));
60 DMemModelProcess::Destruct();
63 TInt DX86PlatProcess::GetNewChunk(DMemModelChunk*& aChunk, SChunkCreateInfo& aInfo)
66 DX86PlatChunk* pC=new DX86PlatChunk;
70 TChunkType type = aInfo.iType;
72 TInt r=pC->SetAttributes(aInfo);
75 if(type==ESharedKernelSingle || type==ESharedKernelMultiple || type==ESharedIo)
77 DX86PlatChunk* pM=new DX86PlatChunk;
80 pC->iKernelMirror = pM;
81 pM->iChunkType = ESharedKernelMirror;
82 r=pM->SetAttributes(aInfo);
88 TInt DX86PlatChunk::SetAttributes(SChunkCreateInfo& aInfo)
93 iAttributes = EAddressFixed|EMapTypeGlobal|EPrivate;
96 iAttributes = EAddressFixed|EMapTypeShared|EPrivate;
99 iAttributes = EAddressKernel|EMapTypeGlobal|EPrivate;
102 iAttributes = EAddressKernel|EMapTypeGlobal|EPrivate|ECode;
107 iAttributes = EAddressUserGlobal|EMapTypeGlobal|ECode;
109 iAttributes = EAddressFixed|EMapTypeLocal|EPrivate|ECode;
113 iAttributes = EAddressShared|EMapTypeShared;
115 iAttributes = EAddressLocal|EMapTypeLocal|EPrivate;
118 iAttributes = EAddressFixed|EMapTypeLocal|EPrivate;
120 case EUserSelfModCode:
122 iAttributes = EAddressShared|EMapTypeShared|ECode;
124 iAttributes = EAddressLocal|EMapTypeLocal|EPrivate|ECode;
126 case ESharedKernelSingle:
127 case ESharedKernelMultiple:
129 iAttributes = EAddressShared|EMapTypeShared;
131 case ESharedKernelMirror:
132 iAttributes = EAddressKernel|EMapTypeGlobal|EPrivate;
135 iAttributes = EAddressKernel|EMapTypeGlobal|EPrivate;
143 /********************************************
145 ********************************************/
147 DX86PlatChunk::DX86PlatChunk()
150 DX86PlatChunk::~DX86PlatChunk()
152 DMemModelChunk::Destruct();
155 TInt DX86PlatChunk::SetupPermissions()
158 if(iChunkType==ESharedKernelSingle || iChunkType==ESharedKernelMultiple || iChunkType==ESharedIo || iChunkType==ESharedKernelMirror)
160 // override map attributes for shared kernel chunks
161 TUint ma = (iMapAttr &~ EMapAttrAccessMask) | (iChunkType==ESharedKernelMirror?EMapAttrSupRw:EMapAttrUserRw);
162 TInt r = m.PdePtePermissions(ma, iPdePermissions, iPtePermissions);
169 iPtePermissions=m.PtePermissions(iChunkType);
170 iPdePermissions=m.PdePermissions(iChunkType,EFalse);
173 __KTRACE_OPT(KMMU,Kern::Printf("Chunk permissions PTE=%08x PDE=%08x",iPtePermissions,iPdePermissions));
177 TIpcExcTrap::TExcLocation TIpcExcTrap::ExcLocation(DThread* aThread, TAny* aContext)
179 TX86ExcInfo& info=*(TX86ExcInfo*)aContext;
180 if (info.iExcId==EX86VectorPageFault)
182 TLinAddr va=(TLinAddr)info.iFaultAddress;
184 TLinAddr aliasAddr = ((DMemModelThread*)aThread)->iAliasLinAddr;
187 remoteError = TUint(va^aliasAddr)<TUint(KPageSize);
189 remoteError = va>=iRemoteBase && (va-iRemoteBase)<iSize;
193 if (iLocalBase && va>=iLocalBase && (va-iLocalBase)<iSize)
196 else if (info.iExcId==EX86VectorGPF)
198 TUint16 ds=(TUint16)info.iDs;
199 TUint16 es=(TUint16)info.iEs;
200 TUint16 seg=iDir?ds:es; // write -> local read -> DS restricted, else ES restricted
201 if (seg==KRing3DS || seg==KRing3CS)