sl@0
|
1 |
// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// e32test\mmu\t_wbc.cpp
|
sl@0
|
15 |
// Overview:
|
sl@0
|
16 |
// Read and write RChunk data.
|
sl@0
|
17 |
// API Information:
|
sl@0
|
18 |
// RChunk
|
sl@0
|
19 |
// Details:
|
sl@0
|
20 |
// Create two local RChunk objects. Perform ReadModifyWrite, WriteOnly
|
sl@0
|
21 |
// and ReadOnly operations on the chunks. Verify that the results are
|
sl@0
|
22 |
// as expected.
|
sl@0
|
23 |
// Platforms/Drives/Compatibility:
|
sl@0
|
24 |
// All.
|
sl@0
|
25 |
// Assumptions/Requirement/Pre-requisites:
|
sl@0
|
26 |
// Failures and causes:
|
sl@0
|
27 |
// Base Port information:
|
sl@0
|
28 |
//
|
sl@0
|
29 |
//
|
sl@0
|
30 |
|
sl@0
|
31 |
#include <e32test.h>
|
sl@0
|
32 |
#include <e32hal.h>
|
sl@0
|
33 |
#include <e32svr.h>
|
sl@0
|
34 |
|
sl@0
|
35 |
RTest test(_L("T_WBC"));
|
sl@0
|
36 |
|
sl@0
|
37 |
TUint32 ReadModifyWrite(volatile TUint32* p, TInt aNumWords)
|
sl@0
|
38 |
{
|
sl@0
|
39 |
TUint32 x=0;
|
sl@0
|
40 |
while(aNumWords--)
|
sl@0
|
41 |
{
|
sl@0
|
42 |
x=*p;
|
sl@0
|
43 |
*p++=0;
|
sl@0
|
44 |
}
|
sl@0
|
45 |
return x;
|
sl@0
|
46 |
}
|
sl@0
|
47 |
|
sl@0
|
48 |
void WriteOnly(volatile TUint32* p, TInt aNumWords)
|
sl@0
|
49 |
{
|
sl@0
|
50 |
while(aNumWords--)
|
sl@0
|
51 |
*p++=0xffffffff;
|
sl@0
|
52 |
}
|
sl@0
|
53 |
|
sl@0
|
54 |
TUint32 ReadOnly(volatile TUint32* p, TInt aNumWords)
|
sl@0
|
55 |
{
|
sl@0
|
56 |
TUint32 x=0;
|
sl@0
|
57 |
while(aNumWords--)
|
sl@0
|
58 |
x+=*p++;
|
sl@0
|
59 |
return x;
|
sl@0
|
60 |
}
|
sl@0
|
61 |
|
sl@0
|
62 |
void Dump(volatile TUint32* p, TInt aNumWords)
|
sl@0
|
63 |
{
|
sl@0
|
64 |
while(aNumWords>0)
|
sl@0
|
65 |
{
|
sl@0
|
66 |
RDebug::Print(_L("%08x: %08x %08x %08x %08x %08x %08x %08x %08x"),p,
|
sl@0
|
67 |
p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
|
sl@0
|
68 |
p+=8;
|
sl@0
|
69 |
aNumWords-=8;
|
sl@0
|
70 |
}
|
sl@0
|
71 |
}
|
sl@0
|
72 |
|
sl@0
|
73 |
void Verify(volatile TUint32* p, TInt aNumWords)
|
sl@0
|
74 |
{
|
sl@0
|
75 |
while(aNumWords--)
|
sl@0
|
76 |
test(*p++==0xffffffff);
|
sl@0
|
77 |
}
|
sl@0
|
78 |
|
sl@0
|
79 |
GLDEF_C TInt E32Main()
|
sl@0
|
80 |
{
|
sl@0
|
81 |
|
sl@0
|
82 |
TInt pageSize;
|
sl@0
|
83 |
UserHal::PageSizeInBytes(pageSize);
|
sl@0
|
84 |
test.Title();
|
sl@0
|
85 |
test.Start(_L("Create chunk 1"));
|
sl@0
|
86 |
RChunk c1;
|
sl@0
|
87 |
TInt r=c1.CreateLocal(4*pageSize,0x100000); // initial size 4 pages
|
sl@0
|
88 |
test(r==KErrNone);
|
sl@0
|
89 |
test.Next(_L("Create chunk 2"));
|
sl@0
|
90 |
RChunk c2;
|
sl@0
|
91 |
r=c2.CreateLocal(pageSize,0x100000); // initial size 1 page
|
sl@0
|
92 |
test(r==KErrNone);
|
sl@0
|
93 |
test.Next(_L("Fill DCache with modified lines from chunk 1"));
|
sl@0
|
94 |
volatile TUint32* p=(volatile TUint32*)(c1.Base()+2*pageSize);
|
sl@0
|
95 |
ReadModifyWrite(p,pageSize>>1);
|
sl@0
|
96 |
c1.Adjust(2*pageSize); // lose the two modified pages
|
sl@0
|
97 |
c2.Adjust(3*pageSize); // map them back into chunk 2
|
sl@0
|
98 |
p=(volatile TUint32*)(c2.Base()+pageSize);
|
sl@0
|
99 |
WriteOnly(p,pageSize>>1); // write to the modified pages at new virtual address
|
sl@0
|
100 |
p=(volatile TUint32*)c1.Base();
|
sl@0
|
101 |
ReadOnly(p,pageSize>>1); // read two other pages (this will evict the modified lines)
|
sl@0
|
102 |
p=(volatile TUint32*)(c2.Base()+pageSize);
|
sl@0
|
103 |
Dump(p,pageSize>>1);
|
sl@0
|
104 |
Verify(p,pageSize>>1);
|
sl@0
|
105 |
test.Printf(_L("\n"));
|
sl@0
|
106 |
test.End();
|
sl@0
|
107 |
return 0;
|
sl@0
|
108 |
}
|