sl@0
|
1 |
// Copyright (c) 2008-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\demandpaging\t_dpcmn.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <e32test.h>
|
sl@0
|
19 |
#include <dptest.h>
|
sl@0
|
20 |
#include <e32hal.h>
|
sl@0
|
21 |
#include <u32exec.h>
|
sl@0
|
22 |
#include <e32svr.h>
|
sl@0
|
23 |
#include <e32panic.h>
|
sl@0
|
24 |
#include "u32std.h"
|
sl@0
|
25 |
|
sl@0
|
26 |
TInt gPageSize;
|
sl@0
|
27 |
TBool gPagingSupported = EFalse;
|
sl@0
|
28 |
TBool gRomPagingSupported = EFalse;
|
sl@0
|
29 |
TBool gCodePagingSupported = EFalse;
|
sl@0
|
30 |
TBool gDataPagingSupported = EFalse;
|
sl@0
|
31 |
TInt gDataPagingPolicy;
|
sl@0
|
32 |
TBool gProcessPaged;
|
sl@0
|
33 |
|
sl@0
|
34 |
TBool gGlobalNoPaging = EFalse;
|
sl@0
|
35 |
TBool gGlobalAlwaysPage = EFalse;
|
sl@0
|
36 |
TBool gGlobalDefaultUnpaged = EFalse;
|
sl@0
|
37 |
TBool gGlobalDefaultPage = EFalse;
|
sl@0
|
38 |
|
sl@0
|
39 |
// Size of paging cache in pages
|
sl@0
|
40 |
TUint gMinCacheSize = 0;
|
sl@0
|
41 |
TUint gMaxCacheSize = 0;
|
sl@0
|
42 |
TUint gCurrentCacheSize = 0;
|
sl@0
|
43 |
|
sl@0
|
44 |
RChunk gChunk;
|
sl@0
|
45 |
|
sl@0
|
46 |
//
|
sl@0
|
47 |
// GetGlobalPolicies
|
sl@0
|
48 |
//
|
sl@0
|
49 |
// Determine the global dapaging policies as specified at rombuild time
|
sl@0
|
50 |
//
|
sl@0
|
51 |
TInt GetGlobalPolicies()
|
sl@0
|
52 |
{
|
sl@0
|
53 |
// Determine which types of paging are supported
|
sl@0
|
54 |
TUint32 attrs = DPTest::Attributes();
|
sl@0
|
55 |
|
sl@0
|
56 |
gRomPagingSupported = (attrs & DPTest::ERomPaging) != 0;
|
sl@0
|
57 |
gCodePagingSupported = (attrs & DPTest::ECodePaging) != 0;
|
sl@0
|
58 |
gDataPagingSupported = (attrs & DPTest::EDataPaging) != 0;
|
sl@0
|
59 |
gPagingSupported = gRomPagingSupported || gCodePagingSupported || gDataPagingSupported;
|
sl@0
|
60 |
|
sl@0
|
61 |
if (gRomPagingSupported)
|
sl@0
|
62 |
RDebug::Printf("Rom paging supported");
|
sl@0
|
63 |
if (gCodePagingSupported)
|
sl@0
|
64 |
RDebug::Printf("Code paging supported");
|
sl@0
|
65 |
if (gDataPagingSupported)
|
sl@0
|
66 |
RDebug::Printf("Data paging supported");
|
sl@0
|
67 |
|
sl@0
|
68 |
// Determine the data paging attributes
|
sl@0
|
69 |
TInt kernelFlags = UserSvr::HalFunction(EHalGroupKernel, EKernelHalConfigFlags, 0, 0);
|
sl@0
|
70 |
if (kernelFlags < 0)
|
sl@0
|
71 |
return kernelFlags;
|
sl@0
|
72 |
|
sl@0
|
73 |
gDataPagingPolicy = kernelFlags & EKernelConfigDataPagingPolicyMask;
|
sl@0
|
74 |
if (gDataPagingPolicy == EKernelConfigDataPagingPolicyNoPaging)
|
sl@0
|
75 |
{
|
sl@0
|
76 |
RDebug::Printf("Global NO PAGING policy is set");
|
sl@0
|
77 |
gGlobalNoPaging = ETrue;
|
sl@0
|
78 |
}
|
sl@0
|
79 |
if (gDataPagingPolicy == EKernelConfigDataPagingPolicyAlwaysPage)
|
sl@0
|
80 |
{
|
sl@0
|
81 |
RDebug::Printf("Global ALWAYS PAGE policy is set");
|
sl@0
|
82 |
gGlobalAlwaysPage = ETrue;
|
sl@0
|
83 |
}
|
sl@0
|
84 |
if (gDataPagingPolicy == EKernelConfigDataPagingPolicyDefaultUnpaged)
|
sl@0
|
85 |
{
|
sl@0
|
86 |
RDebug::Printf("Global DEFAULT UNPAGED policy is set");
|
sl@0
|
87 |
gGlobalDefaultUnpaged = ETrue;
|
sl@0
|
88 |
}
|
sl@0
|
89 |
if (gDataPagingPolicy == EKernelConfigDataPagingPolicyDefaultPaged)
|
sl@0
|
90 |
{
|
sl@0
|
91 |
RDebug::Printf("Global DEFAULT PAGED policy is set");
|
sl@0
|
92 |
gGlobalDefaultPage = ETrue;
|
sl@0
|
93 |
}
|
sl@0
|
94 |
|
sl@0
|
95 |
// Determine this process' data paging attribute
|
sl@0
|
96 |
RProcess process; // Default to point to current process.
|
sl@0
|
97 |
gProcessPaged = process.DefaultDataPaged();
|
sl@0
|
98 |
RDebug::Printf(gProcessPaged ? "This process is paged" : "This process is not paged");
|
sl@0
|
99 |
|
sl@0
|
100 |
// Get page size
|
sl@0
|
101 |
TInt r = UserHal::PageSizeInBytes(gPageSize);
|
sl@0
|
102 |
if (r != KErrNone)
|
sl@0
|
103 |
return r;
|
sl@0
|
104 |
|
sl@0
|
105 |
if (gPagingSupported)
|
sl@0
|
106 |
{
|
sl@0
|
107 |
TUint minSize;
|
sl@0
|
108 |
TUint maxSize;
|
sl@0
|
109 |
TUint currentSize;
|
sl@0
|
110 |
r = DPTest::CacheSize(minSize, maxSize, currentSize);
|
sl@0
|
111 |
if (r != KErrNone)
|
sl@0
|
112 |
return r;
|
sl@0
|
113 |
|
sl@0
|
114 |
gMinCacheSize = minSize / gPageSize;
|
sl@0
|
115 |
gMaxCacheSize = maxSize / gPageSize;
|
sl@0
|
116 |
gCurrentCacheSize = currentSize / gPageSize;
|
sl@0
|
117 |
RDebug::Printf("Cache size (pages): min == %d, max == %d, current == %d",
|
sl@0
|
118 |
gMinCacheSize, gMaxCacheSize, gCurrentCacheSize);
|
sl@0
|
119 |
}
|
sl@0
|
120 |
|
sl@0
|
121 |
return r;
|
sl@0
|
122 |
}
|
sl@0
|
123 |
|
sl@0
|
124 |
//
|
sl@0
|
125 |
// IsDataPagingSupported
|
sl@0
|
126 |
//
|
sl@0
|
127 |
// Determine whether data paging is supported
|
sl@0
|
128 |
//
|
sl@0
|
129 |
TBool IsDataPagingSupported()
|
sl@0
|
130 |
{
|
sl@0
|
131 |
return gDataPagingSupported;
|
sl@0
|
132 |
}
|
sl@0
|
133 |
|
sl@0
|
134 |
//
|
sl@0
|
135 |
// UpdatePaged
|
sl@0
|
136 |
//
|
sl@0
|
137 |
// Update whether the expected paged status based on the global paging policy.
|
sl@0
|
138 |
//
|
sl@0
|
139 |
void UpdatePaged(TBool& aPaged)
|
sl@0
|
140 |
{
|
sl@0
|
141 |
if (gGlobalNoPaging)
|
sl@0
|
142 |
aPaged = EFalse;
|
sl@0
|
143 |
if (gGlobalAlwaysPage)
|
sl@0
|
144 |
aPaged = ETrue;
|
sl@0
|
145 |
if (!gDataPagingSupported)
|
sl@0
|
146 |
aPaged = EFalse;
|
sl@0
|
147 |
}
|
sl@0
|
148 |
|
sl@0
|
149 |
|
sl@0
|
150 |
//
|
sl@0
|
151 |
// TestThreadExit
|
sl@0
|
152 |
//
|
sl@0
|
153 |
// Resume the specified thread and verify the exit reason.
|
sl@0
|
154 |
//
|
sl@0
|
155 |
TInt TestThreadExit(RThread& aThread, TExitType aExitType, TInt aExitReason)
|
sl@0
|
156 |
{
|
sl@0
|
157 |
// Disable JIT debugging.
|
sl@0
|
158 |
TBool justInTime=User::JustInTime();
|
sl@0
|
159 |
User::SetJustInTime(EFalse);
|
sl@0
|
160 |
|
sl@0
|
161 |
TRequestStatus status;
|
sl@0
|
162 |
aThread.Logon(status);
|
sl@0
|
163 |
aThread.Resume();
|
sl@0
|
164 |
User::WaitForRequest(status);
|
sl@0
|
165 |
if (aExitType != aThread.ExitType())
|
sl@0
|
166 |
return KErrGeneral;
|
sl@0
|
167 |
|
sl@0
|
168 |
if (aExitReason != status.Int())
|
sl@0
|
169 |
return KErrGeneral;
|
sl@0
|
170 |
|
sl@0
|
171 |
if (aExitReason != aThread.ExitReason())
|
sl@0
|
172 |
return KErrGeneral;
|
sl@0
|
173 |
|
sl@0
|
174 |
|
sl@0
|
175 |
if (aExitType == EExitPanic)
|
sl@0
|
176 |
{
|
sl@0
|
177 |
if (aThread.ExitCategory()!=_L("USER"))
|
sl@0
|
178 |
{
|
sl@0
|
179 |
return KErrGeneral;
|
sl@0
|
180 |
}
|
sl@0
|
181 |
}
|
sl@0
|
182 |
|
sl@0
|
183 |
CLOSE_AND_WAIT(aThread);
|
sl@0
|
184 |
|
sl@0
|
185 |
// Put JIT debugging back to previous status.
|
sl@0
|
186 |
User::SetJustInTime(justInTime);
|
sl@0
|
187 |
return KErrNone;
|
sl@0
|
188 |
}
|