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