sl@0
|
1 |
// Copyright (c) 1994-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 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include "arm_mem.h"
|
sl@0
|
17 |
#include "../mmu/mm.h"
|
sl@0
|
18 |
|
sl@0
|
19 |
TInt DArmPlatThread::SetupContext(SThreadCreateInfo& aInfo)
|
sl@0
|
20 |
{
|
sl@0
|
21 |
switch(iThreadType)
|
sl@0
|
22 |
{
|
sl@0
|
23 |
case EThreadSupervisor:
|
sl@0
|
24 |
case EThreadMinimalSupervisor:
|
sl@0
|
25 |
case EThreadInitial:
|
sl@0
|
26 |
case EThreadAPInitial:
|
sl@0
|
27 |
break;
|
sl@0
|
28 |
case EThreadUser:
|
sl@0
|
29 |
#ifndef __SMP__
|
sl@0
|
30 |
iNThread.iSpare3 /*iUserContextType*/ = NThread::EContextUndefined;
|
sl@0
|
31 |
#endif
|
sl@0
|
32 |
break;
|
sl@0
|
33 |
}
|
sl@0
|
34 |
iNThread.SetAddressSpace(iOwningProcess);
|
sl@0
|
35 |
iNThread.SetAttributes(KThreadAttAddressSpace);
|
sl@0
|
36 |
#ifdef __SMP__
|
sl@0
|
37 |
iCpuRestoreCookie = -1;
|
sl@0
|
38 |
#else
|
sl@0
|
39 |
// OK to get this thread's owning process os asid as the process can't free
|
sl@0
|
40 |
// it's asid while this thread is being created because the current thread
|
sl@0
|
41 |
// has the same owning process.
|
sl@0
|
42 |
MM::IpcAliasPde(iAliasPdePtr,((DMemModelProcess*)iOwningProcess)->OsAsid());
|
sl@0
|
43 |
#endif
|
sl@0
|
44 |
return KErrNone;
|
sl@0
|
45 |
}
|
sl@0
|
46 |
|
sl@0
|
47 |
TIpcExcTrap::TExcLocation TIpcExcTrap::ExcLocation(DThread* aThread, TAny* aContext)
|
sl@0
|
48 |
{
|
sl@0
|
49 |
TArmExcInfo& info=*(TArmExcInfo*)aContext;
|
sl@0
|
50 |
if (info.iExcCode==EArmExceptionDataAbort)
|
sl@0
|
51 |
{
|
sl@0
|
52 |
TLinAddr va=(TLinAddr)info.iFaultAddress;
|
sl@0
|
53 |
|
sl@0
|
54 |
TLinAddr aliasAddr = ((DMemModelThread*)aThread)->iAliasLinAddr;
|
sl@0
|
55 |
TBool remoteError;
|
sl@0
|
56 |
if(aliasAddr)
|
sl@0
|
57 |
remoteError = TUint(va^aliasAddr)<TUint(KPageSize);
|
sl@0
|
58 |
else
|
sl@0
|
59 |
// The second clause in the statement below was "va < iRemoteBase + iSize".
|
sl@0
|
60 |
// iRemoteBase + iSize might conceivably wrap round.
|
sl@0
|
61 |
// The usual fix for this is to change
|
sl@0
|
62 |
// va >= base && va < base + size
|
sl@0
|
63 |
// to va >= base && (va - base) < size
|
sl@0
|
64 |
// but this requires the first clause (va >= base) so that va-base doesn't wrap negative.
|
sl@0
|
65 |
// Since the first clause in this expression is va >= (iRemoteBase & ~3)
|
sl@0
|
66 |
// we have to re-write the expression as follows:
|
sl@0
|
67 |
// Let base' = iRemoteBase & ~3
|
sl@0
|
68 |
// so base = base' + (base & 3)
|
sl@0
|
69 |
// then we have va >= base' && va < base' + (base & 3) + iSize
|
sl@0
|
70 |
// (effectively the & ~3 on the first clause extends the range downwards by base & 3)
|
sl@0
|
71 |
remoteError = va>=(iRemoteBase&~3) &&
|
sl@0
|
72 |
(va - (iRemoteBase & ~3)) < iSize + (iRemoteBase & 3);
|
sl@0
|
73 |
if (remoteError)
|
sl@0
|
74 |
return EExcRemote;
|
sl@0
|
75 |
|
sl@0
|
76 |
// Third clause was va < iLocalBase + iSize, fixed as in the "remoteError =" line above
|
sl@0
|
77 |
if (iLocalBase && va>=(iLocalBase&~3) &&
|
sl@0
|
78 |
(va - (iLocalBase & ~3)) < iSize + (iLocalBase & 3))
|
sl@0
|
79 |
return EExcLocal;
|
sl@0
|
80 |
}
|
sl@0
|
81 |
return EExcUnknown;
|
sl@0
|
82 |
}
|