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.
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
// e32\memmodel\epoc\direct\arm\xkernel.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include "arm_mem.h"
sl@0
    19
sl@0
    20
/********************************************
sl@0
    21
 * Thread
sl@0
    22
 ********************************************/
sl@0
    23
sl@0
    24
TInt DArmPlatThread::SetupContext(SThreadCreateInfo& anInfo)
sl@0
    25
	{
sl@0
    26
#ifndef __SMP__
sl@0
    27
	if(iThreadType==EThreadUser)
sl@0
    28
		iNThread.iSpare3 /*iUserContextType*/ = NThread::EContextUndefined;
sl@0
    29
#endif
sl@0
    30
	return KErrNone;
sl@0
    31
	}
sl@0
    32
sl@0
    33
DArmPlatProcess::DArmPlatProcess()
sl@0
    34
	{}
sl@0
    35
sl@0
    36
DArmPlatProcess::~DArmPlatProcess()
sl@0
    37
	{
sl@0
    38
	__KTRACE_OPT(KMMU,Kern::Printf("DArmPlatProcess destruct"));
sl@0
    39
	DMemModelProcess::Destruct();
sl@0
    40
	}
sl@0
    41
sl@0
    42
TBool Exc::IsMagic(TLinAddr /*anAddress*/)
sl@0
    43
//
sl@0
    44
// Return TRUE if anAddress is a 'magic' exception handling instruction
sl@0
    45
//
sl@0
    46
	{
sl@0
    47
	return EFalse;
sl@0
    48
	}
sl@0
    49
sl@0
    50
void DThread::IpcExcHandler(TExcTrap* aTrap, DThread* aThread, TAny* aContext)
sl@0
    51
	{
sl@0
    52
	aThread->iIpcClient = 0;
sl@0
    53
	TIpcExcTrap& xt=*(TIpcExcTrap*)aTrap;
sl@0
    54
	TArmExcInfo& info=*(TArmExcInfo*)aContext;
sl@0
    55
	if (info.iExcCode==EArmExceptionDataAbort)
sl@0
    56
		{
sl@0
    57
		TUint32 opcode = *(TUint32*)info.iR15;		// faulting instruction
sl@0
    58
		if (opcode>=0xf0000000)
sl@0
    59
			return;									// not a load/store so fault the kernel
sl@0
    60
		TUint32 opc1 = (opcode>>25)&7;
sl@0
    61
		TBool load;
sl@0
    62
		if ( (opc1==2) || (opc1==4) || (opc1==3 && !(opcode&0x10)) )
sl@0
    63
			load=opcode & 0x00100000;				// bit 20=1 for load, 0 for store
sl@0
    64
		else if (opc1==0)
sl@0
    65
			{
sl@0
    66
			TUint32 opc2 = (opcode>>4)&0xf;
sl@0
    67
			if (opc2==0x0b)
sl@0
    68
				load=opcode & 0x00100000;			// bit 20=1 for load, 0 for store
sl@0
    69
			else if ((opc2&0x0d)==0x0d)
sl@0
    70
				{
sl@0
    71
				if (opcode&0x00100000)
sl@0
    72
					load=ETrue;						// LDRSB/LDRSH
sl@0
    73
				else
sl@0
    74
					load=(opcode&0x20)^0x20;		// LDRD/STRD, bit5=1 for STRD, 0 for LDRD
sl@0
    75
				}
sl@0
    76
			else
sl@0
    77
				return;								// not a load/store so fault the kernel
sl@0
    78
			}
sl@0
    79
		else
sl@0
    80
			return;									// not a load/store so fault the kernel
sl@0
    81
sl@0
    82
		if ((load && !xt.iDir) || (!load && xt.iDir))
sl@0
    83
			xt.Exception(KErrBadDescriptor);	// problem accessing remote address - 'leave' so an error code will be returned
sl@0
    84
		NKern::UnlockSystem();			// else assume problem accessing local address - return and panic current thread as usual
sl@0
    85
		}
sl@0
    86
	// otherwise return and fault kernel
sl@0
    87
	}
sl@0
    88