kerneltest/e32test/mmu/t_wsd_dl3.cpp
branchRCL_3
changeset 81 e7d2d738d3c2
equal deleted inserted replaced
80:597aaf25e343 81:e7d2d738d3c2
       
     1 // Copyright (c) 2006-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 // e32test\mmu\t_wsd_dl3.cpp
       
    15 //
       
    16 
       
    17 // MMH file will define	T_WSD_DL3
       
    18 #include "t_wsd_tst.h"
       
    19 
       
    20 #define C 		((void*)DummyFn)
       
    21 #define D 		((void*)TestData)
       
    22 #define A4W		C, D, C, D												// 4 words
       
    23 #define A16W	A4W, A4W, A4W, A4W										// 16 words
       
    24 #define A64W 	A16W, A16W, A16W, A16W									// 64 words
       
    25 #define A256W 	A64W, A64W, A64W, A64W									// 256 words
       
    26 #define A1KW	A256W, A256W, A256W, A256W								// 1Kwords
       
    27 #define A4KW	A1KW, A1KW, A1KW, A1KW									// 4Kwords
       
    28 
       
    29 // Non-exported dummy function whose address is put in the initialised
       
    30 // data, to check that it gets relocated correctly
       
    31 void DummyFn(void)
       
    32 	{
       
    33 	}
       
    34 
       
    35 // Non-exported const data, which should end up in the text segment
       
    36 // but doesn't on some platforms :(
       
    37 static const void* const TestData[] = { A4KW, A4KW };					// 8Kwords
       
    38 const TInt KSizeOfTestData = sizeof(TestData);							// 32Kbytes
       
    39 
       
    40 // Exported Ordinals 2-5
       
    41 EXPORT_D TInt32 TestDataSize = KSizeOfTestData;
       
    42 EXPORT_D void* WritableTestData[] = { A4KW, A4KW };
       
    43 EXPORT_D const void* const* PointerToStaticData = TestData;
       
    44 EXPORT_D void** PointerToWritableData = WritableTestData;
       
    45 
       
    46 // Dummy function, just so that this DLL contains more than one page of
       
    47 // text even on platforms where the read-only data ends up in the data
       
    48 // rather than the text segment ...
       
    49 TUint AddEmUp()
       
    50 	{
       
    51 	const void* const* p = TestData;
       
    52 	TUint sum = 0;
       
    53 
       
    54 #define	ADD1W	{ sum += (TUint)*p++; }									// 1 word
       
    55 #define	ADD4W	{ ADD1W; ADD1W; ADD1W; ADD1W; }							// 4 words
       
    56 #define	ADD16W	{ ADD4W; ADD4W; ADD4W; ADD4W; }							// 16 words
       
    57 #define	ADD64W	{ ADD16W; ADD16W; ADD16W; ADD16W; }						// 64 words
       
    58 #define	ADD256W	{ ADD64W; ADD64W; ADD64W; ADD64W; }						// 256 words
       
    59 #define	ADD1KW	{ ADD256W; ADD256W; ADD256W; ADD256W; }					// 1K words
       
    60 
       
    61 	// The macro ADD1KW should expand to ~2K instructions i.e. ~8Kb of inline code
       
    62 	for (TUint i = 0; i < sizeof(TestData)/(1024*sizeof(void*)); ++i)
       
    63 		ADD1KW;
       
    64 
       
    65 	// We've added up all 8Kwords (32kb) of the test data ...
       
    66 	return sum;
       
    67 	}
       
    68 
       
    69 // Exported Ordinal 1
       
    70 EXPORT_C void** GetAddressOfData(TInt& aSize, void*& aCodeAddr, void*& aDataAddr)
       
    71 	{
       
    72 	TAny* p = User::Alloc(KSizeOfTestData);
       
    73 	aSize = AddEmUp();
       
    74 	aSize = KSizeOfTestData;
       
    75 	aCodeAddr = C;
       
    76 	aDataAddr = D;
       
    77 	User::Free(p);
       
    78 	return (void**)&PointerToStaticData;
       
    79 	}
       
    80