os/kernelhwsrv/kernel/eka/memmodel/epoc/multiple/x86/xmonitor.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
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\multiple\x86\xmonitor.cpp
sl@0
    15
// Kernel crash debugger - ARM specific portion
sl@0
    16
// 
sl@0
    17
//
sl@0
    18
sl@0
    19
#include <kernel/monitor.h>
sl@0
    20
#include <x86_mem.h>
sl@0
    21
sl@0
    22
void SetPageDir(DMemModelProcess* aProcess);
sl@0
    23
sl@0
    24
void Monitor::CpuInit()
sl@0
    25
	{
sl@0
    26
	}
sl@0
    27
sl@0
    28
void Monitor::DumpCpuProcessData(DProcess* aProcess)
sl@0
    29
	{
sl@0
    30
	}
sl@0
    31
sl@0
    32
void Monitor::DumpCpuChunkData(DChunk* aChunk)
sl@0
    33
	{
sl@0
    34
	}
sl@0
    35
sl@0
    36
sl@0
    37
// From xmmu.cpp:
sl@0
    38
const TUint32 KPdePteAccessed=0x20;
sl@0
    39
const TUint32 KPdePteDirty=0x40;
sl@0
    40
sl@0
    41
// Mask to ignore accessed and dirty bits
sl@0
    42
const TUint32 KPdeEqualMask=~(KPdePteAccessed|KPdePteDirty);
sl@0
    43
sl@0
    44
TBool PdesEqual(const TPde* aLeft, const TPde* aRight, TLinAddr aBase, TLinAddr aEnd)
sl@0
    45
	{
sl@0
    46
	for (TUint addr = aBase ; addr != aEnd ; addr += (1 << KChunkShift))
sl@0
    47
		{
sl@0
    48
		TUint i = addr >> KChunkShift;		
sl@0
    49
		if ((aLeft[i] & KPdeEqualMask) != (aRight[i] & KPdeEqualMask))
sl@0
    50
			return EFalse;
sl@0
    51
		}	
sl@0
    52
	return ETrue;
sl@0
    53
	}
sl@0
    54
sl@0
    55
TInt MapProcess(DMemModelProcess* aProcess, TBool aForce)
sl@0
    56
	{
sl@0
    57
	// Check top half of page dir is same as for the kernel
sl@0
    58
	TUint a = (TUint)aProcess;
sl@0
    59
	DMonObject* o = (DMonObject*)aProcess;
sl@0
    60
	if (a<KPrimaryIOBase || a>=KKernelSectionEnd || (a&3))
sl@0
    61
		return KErrArgument;
sl@0
    62
	if (o->Type()!=EProcess)
sl@0
    63
		return KErrArgument;
sl@0
    64
sl@0
    65
	const TPde* kpd=(const TPde*)KPageDirectoryBase;
sl@0
    66
	const TPde* ppd=(const TPde*)(KPageDirectoryBase+(aProcess->iOsAsid<<KPageTableShift));
sl@0
    67
	if (!PdesEqual(kpd, ppd, KRomLinearBase, KUserGlobalDataEnd) ||		// ROM + user global
sl@0
    68
		!PdesEqual(kpd, ppd, KRamDriveEndAddress, 0x00000000))			// kernel mappings
sl@0
    69
		{
sl@0
    70
		if (!aForce)
sl@0
    71
			return KErrCorrupt;
sl@0
    72
		wordmove((TAny*)(ppd+(KRomLinearBase>>KChunkShift)), (TAny*)(kpd+(KRomLinearBase>>KChunkShift)), ((KUserGlobalDataEnd-KRomLinearBase)>>KChunkShift)*sizeof(TPde));
sl@0
    73
		wordmove((TAny*)(ppd+(KRamDriveEndAddress>>KChunkShift)), (TAny*)(kpd+(KRamDriveEndAddress>>KChunkShift)), ((0-KRamDriveEndAddress)>>KChunkShift)*sizeof(TPde));
sl@0
    74
		}
sl@0
    75
	SetPageDir(aProcess);
sl@0
    76
	return KErrNone;
sl@0
    77
	}