os/kernelhwsrv/kernel/eka/memmodel/epoc/direct/arm/xkernel.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // e32\memmodel\epoc\direct\arm\xkernel.cpp
    15 // 
    16 //
    17 
    18 #include "arm_mem.h"
    19 
    20 /********************************************
    21  * Thread
    22  ********************************************/
    23 
    24 TInt DArmPlatThread::SetupContext(SThreadCreateInfo& anInfo)
    25 	{
    26 #ifndef __SMP__
    27 	if(iThreadType==EThreadUser)
    28 		iNThread.iSpare3 /*iUserContextType*/ = NThread::EContextUndefined;
    29 #endif
    30 	return KErrNone;
    31 	}
    32 
    33 DArmPlatProcess::DArmPlatProcess()
    34 	{}
    35 
    36 DArmPlatProcess::~DArmPlatProcess()
    37 	{
    38 	__KTRACE_OPT(KMMU,Kern::Printf("DArmPlatProcess destruct"));
    39 	DMemModelProcess::Destruct();
    40 	}
    41 
    42 TBool Exc::IsMagic(TLinAddr /*anAddress*/)
    43 //
    44 // Return TRUE if anAddress is a 'magic' exception handling instruction
    45 //
    46 	{
    47 	return EFalse;
    48 	}
    49 
    50 void DThread::IpcExcHandler(TExcTrap* aTrap, DThread* aThread, TAny* aContext)
    51 	{
    52 	aThread->iIpcClient = 0;
    53 	TIpcExcTrap& xt=*(TIpcExcTrap*)aTrap;
    54 	TArmExcInfo& info=*(TArmExcInfo*)aContext;
    55 	if (info.iExcCode==EArmExceptionDataAbort)
    56 		{
    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;
    61 		TBool load;
    62 		if ( (opc1==2) || (opc1==4) || (opc1==3 && !(opcode&0x10)) )
    63 			load=opcode & 0x00100000;				// bit 20=1 for load, 0 for store
    64 		else if (opc1==0)
    65 			{
    66 			TUint32 opc2 = (opcode>>4)&0xf;
    67 			if (opc2==0x0b)
    68 				load=opcode & 0x00100000;			// bit 20=1 for load, 0 for store
    69 			else if ((opc2&0x0d)==0x0d)
    70 				{
    71 				if (opcode&0x00100000)
    72 					load=ETrue;						// LDRSB/LDRSH
    73 				else
    74 					load=(opcode&0x20)^0x20;		// LDRD/STRD, bit5=1 for STRD, 0 for LDRD
    75 				}
    76 			else
    77 				return;								// not a load/store so fault the kernel
    78 			}
    79 		else
    80 			return;									// not a load/store so fault the kernel
    81 
    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
    85 		}
    86 	// otherwise return and fault kernel
    87 	}
    88