Update contrib.
1 // Copyright (c) 2008-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\demandpaging\t_dpcmn.cpp
27 TBool gPagingSupported = EFalse;
28 TBool gRomPagingSupported = EFalse;
29 TBool gCodePagingSupported = EFalse;
30 TBool gDataPagingSupported = EFalse;
31 TInt gDataPagingPolicy;
34 TBool gGlobalNoPaging = EFalse;
35 TBool gGlobalAlwaysPage = EFalse;
36 TBool gGlobalDefaultUnpaged = EFalse;
37 TBool gGlobalDefaultPage = EFalse;
39 // Size of paging cache in pages
40 TUint gMinCacheSize = 0;
41 TUint gMaxCacheSize = 0;
42 TUint gCurrentCacheSize = 0;
49 // Determine the global dapaging policies as specified at rombuild time
51 TInt GetGlobalPolicies()
53 // Determine which types of paging are supported
54 TUint32 attrs = DPTest::Attributes();
56 gRomPagingSupported = (attrs & DPTest::ERomPaging) != 0;
57 gCodePagingSupported = (attrs & DPTest::ECodePaging) != 0;
58 gDataPagingSupported = (attrs & DPTest::EDataPaging) != 0;
59 gPagingSupported = gRomPagingSupported || gCodePagingSupported || gDataPagingSupported;
61 if (gRomPagingSupported)
62 RDebug::Printf("Rom paging supported");
63 if (gCodePagingSupported)
64 RDebug::Printf("Code paging supported");
65 if (gDataPagingSupported)
66 RDebug::Printf("Data paging supported");
68 // Determine the data paging attributes
69 TInt kernelFlags = UserSvr::HalFunction(EHalGroupKernel, EKernelHalConfigFlags, 0, 0);
73 gDataPagingPolicy = kernelFlags & EKernelConfigDataPagingPolicyMask;
74 if (gDataPagingPolicy == EKernelConfigDataPagingPolicyNoPaging)
76 RDebug::Printf("Global NO PAGING policy is set");
77 gGlobalNoPaging = ETrue;
79 if (gDataPagingPolicy == EKernelConfigDataPagingPolicyAlwaysPage)
81 RDebug::Printf("Global ALWAYS PAGE policy is set");
82 gGlobalAlwaysPage = ETrue;
84 if (gDataPagingPolicy == EKernelConfigDataPagingPolicyDefaultUnpaged)
86 RDebug::Printf("Global DEFAULT UNPAGED policy is set");
87 gGlobalDefaultUnpaged = ETrue;
89 if (gDataPagingPolicy == EKernelConfigDataPagingPolicyDefaultPaged)
91 RDebug::Printf("Global DEFAULT PAGED policy is set");
92 gGlobalDefaultPage = ETrue;
95 // Determine this process' data paging attribute
96 RProcess process; // Default to point to current process.
97 gProcessPaged = process.DefaultDataPaged();
98 RDebug::Printf(gProcessPaged ? "This process is paged" : "This process is not paged");
101 TInt r = UserHal::PageSizeInBytes(gPageSize);
105 if (gPagingSupported)
110 r = DPTest::CacheSize(minSize, maxSize, currentSize);
114 gMinCacheSize = minSize / gPageSize;
115 gMaxCacheSize = maxSize / gPageSize;
116 gCurrentCacheSize = currentSize / gPageSize;
117 RDebug::Printf("Cache size (pages): min == %d, max == %d, current == %d",
118 gMinCacheSize, gMaxCacheSize, gCurrentCacheSize);
125 // IsDataPagingSupported
127 // Determine whether data paging is supported
129 TBool IsDataPagingSupported()
131 return gDataPagingSupported;
137 // Update whether the expected paged status based on the global paging policy.
139 void UpdatePaged(TBool& aPaged)
143 if (gGlobalAlwaysPage)
145 if (!gDataPagingSupported)
153 // Resume the specified thread and verify the exit reason.
155 TInt TestThreadExit(RThread& aThread, TExitType aExitType, TInt aExitReason)
157 // Disable JIT debugging.
158 TBool justInTime=User::JustInTime();
159 User::SetJustInTime(EFalse);
161 TRequestStatus status;
162 aThread.Logon(status);
164 User::WaitForRequest(status);
165 if (aExitType != aThread.ExitType())
168 if (aExitReason != status.Int())
171 if (aExitReason != aThread.ExitReason())
175 if (aExitType == EExitPanic)
177 if (aThread.ExitCategory()!=_L("USER"))
183 CLOSE_AND_WAIT(aThread);
185 // Put JIT debugging back to previous status.
186 User::SetJustInTime(justInTime);