First public contribution.
1 // Copyright (c) 1995-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\mmu\t_wbc.cpp
16 // Read and write RChunk data.
20 // Create two local RChunk objects. Perform ReadModifyWrite, WriteOnly
21 // and ReadOnly operations on the chunks. Verify that the results are
23 // Platforms/Drives/Compatibility:
25 // Assumptions/Requirement/Pre-requisites:
26 // Failures and causes:
27 // Base Port information:
35 RTest test(_L("T_WBC"));
37 TUint32 ReadModifyWrite(volatile TUint32* p, TInt aNumWords)
48 void WriteOnly(volatile TUint32* p, TInt aNumWords)
54 TUint32 ReadOnly(volatile TUint32* p, TInt aNumWords)
62 void Dump(volatile TUint32* p, TInt aNumWords)
66 RDebug::Print(_L("%08x: %08x %08x %08x %08x %08x %08x %08x %08x"),p,
67 p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
73 void Verify(volatile TUint32* p, TInt aNumWords)
76 test(*p++==0xffffffff);
79 GLDEF_C TInt E32Main()
83 UserHal::PageSizeInBytes(pageSize);
85 test.Start(_L("Create chunk 1"));
87 TInt r=c1.CreateLocal(4*pageSize,0x100000); // initial size 4 pages
89 test.Next(_L("Create chunk 2"));
91 r=c2.CreateLocal(pageSize,0x100000); // initial size 1 page
93 test.Next(_L("Fill DCache with modified lines from chunk 1"));
94 volatile TUint32* p=(volatile TUint32*)(c1.Base()+2*pageSize);
95 ReadModifyWrite(p,pageSize>>1);
96 c1.Adjust(2*pageSize); // lose the two modified pages
97 c2.Adjust(3*pageSize); // map them back into chunk 2
98 p=(volatile TUint32*)(c2.Base()+pageSize);
99 WriteOnly(p,pageSize>>1); // write to the modified pages at new virtual address
100 p=(volatile TUint32*)c1.Base();
101 ReadOnly(p,pageSize>>1); // read two other pages (this will evict the modified lines)
102 p=(volatile TUint32*)(c2.Base()+pageSize);
104 Verify(p,pageSize>>1);
105 test.Printf(_L("\n"));