os/kernelhwsrv/kerneltest/e32test/hcr/d_hcrsim_psl.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of the License "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description:
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
#include "hcr_debug.h"
sl@0
    19
#include "hcr_hai.h"
sl@0
    20
#include "d_hcrsim.h"
sl@0
    21
sl@0
    22
extern HCR::SRepositoryCompiled CompiledRepository;
sl@0
    23
extern HCR::SRepositoryCompiled CompiledEmptyRepository;
sl@0
    24
extern HCR::SRepositoryCompiled CompiledRepositoryCorrupt1;
sl@0
    25
extern HCR::SRepositoryCompiled CompiledRepositoryCorrupt2;
sl@0
    26
extern HCR::SRepositoryCompiled CompiledRepositoryNullOrderedList;
sl@0
    27
TUint32 PslConfigurationFlags = 0;
sl@0
    28
sl@0
    29
class HCRTest : public HCR::MVariant
sl@0
    30
	{
sl@0
    31
public:
sl@0
    32
	HCRTest();
sl@0
    33
	virtual ~HCRTest();
sl@0
    34
	
sl@0
    35
public:	
sl@0
    36
	TInt Initialise(); 
sl@0
    37
	TBool IgnoreCoreImgRepository();
sl@0
    38
	TInt GetCompiledRepositoryAddress( TAny* & aAddr);
sl@0
    39
	TInt GetOverrideRepositoryAddress( TAny* & aAddr);
sl@0
    40
	};
sl@0
    41
sl@0
    42
HCRTest::HCRTest()
sl@0
    43
	{
sl@0
    44
	HCR_FUNC("HCRTest");
sl@0
    45
	}
sl@0
    46
sl@0
    47
HCRTest::~HCRTest()
sl@0
    48
	{
sl@0
    49
	HCR_FUNC("~HCRTest");
sl@0
    50
	}
sl@0
    51
sl@0
    52
TInt HCRTest::Initialise()
sl@0
    53
	{
sl@0
    54
	HCR_FUNC("HCRTest::Initialise");
sl@0
    55
	if (PslConfigurationFlags & ETestInitialisationFail)
sl@0
    56
		{
sl@0
    57
		HCR_TRACE_RETURN(KErrBadPower); // random error code no.1
sl@0
    58
		}
sl@0
    59
	HCR_TRACE_RETURN(KErrNone);
sl@0
    60
	}
sl@0
    61
sl@0
    62
TInt HCRTest::GetCompiledRepositoryAddress(TAny*& aAddr)
sl@0
    63
	{
sl@0
    64
	HCR_FUNC("HCRTest::GetCompiledRepositoryAddress");
sl@0
    65
	TInt r = KErrNone;
sl@0
    66
	if (PslConfigurationFlags & ETestNullRepository)
sl@0
    67
		{
sl@0
    68
		aAddr = NULL;
sl@0
    69
		r = KErrNotSupported;
sl@0
    70
		}
sl@0
    71
	else if (PslConfigurationFlags & ETestEmptyRepository)
sl@0
    72
		{
sl@0
    73
		aAddr = static_cast<TAny*>(&CompiledEmptyRepository);
sl@0
    74
		}
sl@0
    75
	else if (PslConfigurationFlags & ETestCorruptRepository1)
sl@0
    76
		{
sl@0
    77
		aAddr = static_cast<TAny*>(&CompiledRepositoryCorrupt1);
sl@0
    78
		}
sl@0
    79
	else if (PslConfigurationFlags & ETestCorruptRepository2)
sl@0
    80
		{
sl@0
    81
		aAddr = static_cast<TAny*>(&CompiledRepositoryCorrupt2);
sl@0
    82
		}
sl@0
    83
	else if (PslConfigurationFlags & ETestNullOrderedList)
sl@0
    84
		{
sl@0
    85
		aAddr = static_cast<TAny*>(&CompiledRepositoryNullOrderedList);
sl@0
    86
		}
sl@0
    87
	else if (PslConfigurationFlags & ETestNullRepositoryKErrNone)
sl@0
    88
		{
sl@0
    89
		aAddr = NULL;
sl@0
    90
		r = KErrNone; // Invalid error code: should be KErrNotSupported
sl@0
    91
		}
sl@0
    92
	else if (PslConfigurationFlags & ETestBadErrorCode)
sl@0
    93
		{
sl@0
    94
		aAddr = static_cast<TAny*>(&CompiledEmptyRepository);
sl@0
    95
		r = KErrCommsParity; // random error code no.2
sl@0
    96
		}
sl@0
    97
	else
sl@0
    98
		{
sl@0
    99
		aAddr = static_cast<TAny*>(&CompiledRepository);
sl@0
   100
		}
sl@0
   101
	HCR_TRACE_RETURN(r);
sl@0
   102
	}
sl@0
   103
sl@0
   104
TBool HCRTest::IgnoreCoreImgRepository()
sl@0
   105
	{
sl@0
   106
	HCR_FUNC("HCRTest::IgnoreCoreImgRepository");
sl@0
   107
	HCR_TRACE_RETURN(PslConfigurationFlags & ETestIgnoreCoreImgRepository);
sl@0
   108
	}
sl@0
   109
sl@0
   110
TInt HCRTest::GetOverrideRepositoryAddress(TAny*& aAddr)
sl@0
   111
	{
sl@0
   112
	HCR_FUNC("HCRTest::GetRAMRepositoryAddress");
sl@0
   113
	// Note: the SMR feature by which we obtain the address of the override
sl@0
   114
	// repository is only supported in the ARM bootstrap, not X86 so this test 
sl@0
   115
	// code may in the future need conditional compilation should it need to
sl@0
   116
	// access the SuperPage SMR field to return KErrNotSupported for __X86__ 
sl@0
   117
	// compilations.
sl@0
   118
	TInt r = KErrNotSupported;
sl@0
   119
	if (PslConfigurationFlags & ETestEnableOverrideRepository)
sl@0
   120
		{
sl@0
   121
		aAddr = static_cast<TAny*>(&CompiledEmptyRepository);
sl@0
   122
		r = KErrNone;
sl@0
   123
		}
sl@0
   124
	HCR_TRACE_RETURN(r);
sl@0
   125
	}
sl@0
   126
sl@0
   127
GLDEF_C HCR::MVariant* CreateHCRVariant()
sl@0
   128
	{
sl@0
   129
	HCR_FUNC("CreateHCRTest");
sl@0
   130
	if (PslConfigurationFlags & ETestVariantObjectCreateFail)
sl@0
   131
		{
sl@0
   132
		return NULL;
sl@0
   133
		}
sl@0
   134
	return new HCRTest;
sl@0
   135
	}