First public contribution.
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\direct\arm\xkernel.cpp
20 /********************************************
22 ********************************************/
24 TInt DArmPlatThread::SetupContext(SThreadCreateInfo& anInfo)
27 if(iThreadType==EThreadUser)
28 iNThread.iSpare3 /*iUserContextType*/ = NThread::EContextUndefined;
33 DArmPlatProcess::DArmPlatProcess()
36 DArmPlatProcess::~DArmPlatProcess()
38 __KTRACE_OPT(KMMU,Kern::Printf("DArmPlatProcess destruct"));
39 DMemModelProcess::Destruct();
42 TBool Exc::IsMagic(TLinAddr /*anAddress*/)
44 // Return TRUE if anAddress is a 'magic' exception handling instruction
50 void DThread::IpcExcHandler(TExcTrap* aTrap, DThread* aThread, TAny* aContext)
52 aThread->iIpcClient = 0;
53 TIpcExcTrap& xt=*(TIpcExcTrap*)aTrap;
54 TArmExcInfo& info=*(TArmExcInfo*)aContext;
55 if (info.iExcCode==EArmExceptionDataAbort)
57 TUint32 opcode = *(TUint32*)info.iR15; // faulting instruction
58 if (opcode>=0xf0000000)
59 return; // not a load/store so fault the kernel
60 TUint32 opc1 = (opcode>>25)&7;
62 if ( (opc1==2) || (opc1==4) || (opc1==3 && !(opcode&0x10)) )
63 load=opcode & 0x00100000; // bit 20=1 for load, 0 for store
66 TUint32 opc2 = (opcode>>4)&0xf;
68 load=opcode & 0x00100000; // bit 20=1 for load, 0 for store
69 else if ((opc2&0x0d)==0x0d)
71 if (opcode&0x00100000)
72 load=ETrue; // LDRSB/LDRSH
74 load=(opcode&0x20)^0x20; // LDRD/STRD, bit5=1 for STRD, 0 for LDRD
77 return; // not a load/store so fault the kernel
80 return; // not a load/store so fault the kernel
82 if ((load && !xt.iDir) || (!load && xt.iDir))
83 xt.Exception(KErrBadDescriptor); // problem accessing remote address - 'leave' so an error code will be returned
84 NKern::UnlockSystem(); // else assume problem accessing local address - return and panic current thread as usual
86 // otherwise return and fault kernel