0
|
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".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// e32test\mmu\t_wbc.cpp
|
|
15 |
// Overview:
|
|
16 |
// Read and write RChunk data.
|
|
17 |
// API Information:
|
|
18 |
// RChunk
|
|
19 |
// Details:
|
|
20 |
// Create two local RChunk objects. Perform ReadModifyWrite, WriteOnly
|
|
21 |
// and ReadOnly operations on the chunks. Verify that the results are
|
|
22 |
// as expected.
|
|
23 |
// Platforms/Drives/Compatibility:
|
|
24 |
// All.
|
|
25 |
// Assumptions/Requirement/Pre-requisites:
|
|
26 |
// Failures and causes:
|
|
27 |
// Base Port information:
|
|
28 |
//
|
|
29 |
//
|
|
30 |
|
|
31 |
#include <e32test.h>
|
|
32 |
#include <e32hal.h>
|
|
33 |
#include <e32svr.h>
|
|
34 |
|
|
35 |
RTest test(_L("T_WBC"));
|
|
36 |
|
|
37 |
TUint32 ReadModifyWrite(volatile TUint32* p, TInt aNumWords)
|
|
38 |
{
|
|
39 |
TUint32 x=0;
|
|
40 |
while(aNumWords--)
|
|
41 |
{
|
|
42 |
x=*p;
|
|
43 |
*p++=0;
|
|
44 |
}
|
|
45 |
return x;
|
|
46 |
}
|
|
47 |
|
|
48 |
void WriteOnly(volatile TUint32* p, TInt aNumWords)
|
|
49 |
{
|
|
50 |
while(aNumWords--)
|
|
51 |
*p++=0xffffffff;
|
|
52 |
}
|
|
53 |
|
|
54 |
TUint32 ReadOnly(volatile TUint32* p, TInt aNumWords)
|
|
55 |
{
|
|
56 |
TUint32 x=0;
|
|
57 |
while(aNumWords--)
|
|
58 |
x+=*p++;
|
|
59 |
return x;
|
|
60 |
}
|
|
61 |
|
|
62 |
void Dump(volatile TUint32* p, TInt aNumWords)
|
|
63 |
{
|
|
64 |
while(aNumWords>0)
|
|
65 |
{
|
|
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]);
|
|
68 |
p+=8;
|
|
69 |
aNumWords-=8;
|
|
70 |
}
|
|
71 |
}
|
|
72 |
|
|
73 |
void Verify(volatile TUint32* p, TInt aNumWords)
|
|
74 |
{
|
|
75 |
while(aNumWords--)
|
|
76 |
test(*p++==0xffffffff);
|
|
77 |
}
|
|
78 |
|
|
79 |
GLDEF_C TInt E32Main()
|
|
80 |
{
|
|
81 |
|
|
82 |
TInt pageSize;
|
|
83 |
UserHal::PageSizeInBytes(pageSize);
|
|
84 |
test.Title();
|
|
85 |
test.Start(_L("Create chunk 1"));
|
|
86 |
RChunk c1;
|
|
87 |
TInt r=c1.CreateLocal(4*pageSize,0x100000); // initial size 4 pages
|
|
88 |
test(r==KErrNone);
|
|
89 |
test.Next(_L("Create chunk 2"));
|
|
90 |
RChunk c2;
|
|
91 |
r=c2.CreateLocal(pageSize,0x100000); // initial size 1 page
|
|
92 |
test(r==KErrNone);
|
|
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);
|
|
103 |
Dump(p,pageSize>>1);
|
|
104 |
Verify(p,pageSize>>1);
|
|
105 |
test.Printf(_L("\n"));
|
|
106 |
test.End();
|
|
107 |
return 0;
|
|
108 |
}
|