0
|
1 |
// Copyright (c) 2005-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\bench\d_kernasmbm.cpp
|
|
15 |
// Device driver providing benchmarking for assmblerised kernel routines
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
#include <kernel/kern_priv.h>
|
|
20 |
#include <kernel/cache.h>
|
|
21 |
#include "d_kernasmbm.h"
|
|
22 |
#include "d_kernbm.h"
|
|
23 |
|
|
24 |
RPointerArray<TKernelBenchmark> KernelBenchmarks;
|
|
25 |
|
|
26 |
// TKernelBenchmark ////////////////////////////////////////////////////////////
|
|
27 |
|
|
28 |
TKernelBenchmark::TKernelBenchmark(const TDesC8& aName)
|
|
29 |
{
|
|
30 |
iInfo.iName = aName;
|
|
31 |
iInfo.iCategories = KCategoryGeneral;
|
|
32 |
iInfo.iAlignStep = 0;
|
|
33 |
KernelBenchmarks.Append(this); // Ignores rc
|
|
34 |
}
|
|
35 |
|
|
36 |
TKernelBenchmark::TKernelBenchmark(const TDesC8& aName, TInt aAlignStep)
|
|
37 |
{
|
|
38 |
iInfo.iName = aName;
|
|
39 |
iInfo.iCategories = KCategoryGeneral | KCategoryMemory;
|
|
40 |
iInfo.iAlignStep = aAlignStep;
|
|
41 |
KernelBenchmarks.Append(this); // Ignores rc
|
|
42 |
}
|
|
43 |
|
|
44 |
const TBmInfo& TKernelBenchmark::Info() const
|
|
45 |
{
|
|
46 |
return iInfo;
|
|
47 |
}
|
|
48 |
|
|
49 |
TInt TKernelBenchmark::Run(const TBmParams& aParams, TInt& aResult)
|
|
50 |
{
|
|
51 |
TUint init, final;
|
|
52 |
init = NKern::FastCounter();
|
|
53 |
DoRun(aParams);
|
|
54 |
final = NKern::FastCounter();
|
|
55 |
aResult = final - init;
|
|
56 |
return KErrNone;
|
|
57 |
}
|
|
58 |
|
|
59 |
// TThreadedBenchmark //////////////////////////////////////////////////////////
|
|
60 |
|
|
61 |
TThreadedBenchmark::TThreadedBenchmark(const TDesC8& aName, TInt aRelPri) :
|
|
62 |
TKernelBenchmark(aName), iRelPri(aRelPri)
|
|
63 |
{
|
|
64 |
}
|
|
65 |
|
|
66 |
TInt TThreadedBenchmark::Run(const TBmParams& aParams, TInt& aResult)
|
|
67 |
{
|
|
68 |
iIts = aParams.iIts;
|
|
69 |
iThread1 = &Kern::CurrentThread();
|
|
70 |
|
|
71 |
SThreadCreateInfo info;
|
|
72 |
info.iType=EThreadSupervisor;
|
|
73 |
info.iFunction=Thread2Func;
|
|
74 |
info.iPtr=this;
|
|
75 |
info.iSupervisorStack=NULL;
|
|
76 |
info.iSupervisorStackSize=0; // zero means use default value
|
|
77 |
info.iInitialThreadPriority=iThread1->iNThread.iPriority + iRelPri;
|
|
78 |
info.iName.Set(_L("bmthread"));
|
|
79 |
info.iTotalSize = sizeof(info);
|
|
80 |
|
|
81 |
NKern::ThreadEnterCS();
|
|
82 |
TInt r = Kern::ThreadCreate(info);
|
|
83 |
NKern::ThreadLeaveCS();
|
|
84 |
if (r != KErrNone)
|
|
85 |
return r;
|
|
86 |
|
|
87 |
iThread2 = (DThread*)info.iHandle;
|
|
88 |
|
|
89 |
return TKernelBenchmark::Run(aParams, aResult);
|
|
90 |
}
|
|
91 |
|
|
92 |
TInt TThreadedBenchmark::Thread2Func(TAny* aPtr)
|
|
93 |
{
|
|
94 |
TThreadedBenchmark* self = (TThreadedBenchmark*)aPtr;
|
|
95 |
self->DoRun2(self->iIts);
|
|
96 |
return KErrNone;
|
|
97 |
}
|
|
98 |
|
|
99 |
// Device driver implementation ////////////////////////////////////////////////
|
|
100 |
|
|
101 |
class DKernAsmBmFactory : public DLogicalDevice
|
|
102 |
{
|
|
103 |
public:
|
|
104 |
virtual TInt Install(); //overriding pure virtual
|
|
105 |
virtual void GetCaps(TDes8& aDes) const; //overriding pure virtual
|
|
106 |
virtual TInt Create(DLogicalChannelBase*& aChannel);
|
|
107 |
};
|
|
108 |
|
|
109 |
class DKernAsmBm : public DLogicalChannel
|
|
110 |
{
|
|
111 |
public:
|
|
112 |
virtual ~DKernAsmBm();
|
|
113 |
virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
|
|
114 |
virtual TInt Request(TInt aFunction, TAny* a1, TAny* a2);
|
|
115 |
virtual void HandleMsg(TMessageBase *aMsg);
|
|
116 |
};
|
|
117 |
|
|
118 |
TInt DKernAsmBmFactory::Install()
|
|
119 |
{
|
|
120 |
return(SetName(&KKernAsmBmLddName));
|
|
121 |
}
|
|
122 |
|
|
123 |
void DKernAsmBmFactory::GetCaps(TDes8& /*aDes*/) const
|
|
124 |
{
|
|
125 |
}
|
|
126 |
|
|
127 |
TInt DKernAsmBmFactory::Create(DLogicalChannelBase*& aChannel)
|
|
128 |
{
|
|
129 |
aChannel = new DKernAsmBm;
|
|
130 |
if(!aChannel)
|
|
131 |
return KErrNoMemory;
|
|
132 |
return KErrNone;
|
|
133 |
}
|
|
134 |
|
|
135 |
DECLARE_STANDARD_LDD()
|
|
136 |
{
|
|
137 |
return new DKernAsmBmFactory;
|
|
138 |
}
|
|
139 |
|
|
140 |
DKernAsmBm::~DKernAsmBm()
|
|
141 |
{
|
|
142 |
CloseData();
|
|
143 |
}
|
|
144 |
|
|
145 |
TInt DKernAsmBm::DoCreate(TInt /*aUnit*/, const TDesC8* /*anInfo*/, const TVersion& /*aVer*/)
|
|
146 |
{
|
|
147 |
return InitData();
|
|
148 |
}
|
|
149 |
|
|
150 |
TInt DKernAsmBm::Request(TInt aFunction, TAny* a1, TAny* a2)
|
|
151 |
{
|
|
152 |
TInt index = aFunction >> 8;
|
|
153 |
aFunction &= 0xff;
|
|
154 |
|
|
155 |
if (aFunction != RKernAsmBmLdd::ECount && (index < 0 || index >= KernelBenchmarks.Count()))
|
|
156 |
return KErrArgument;
|
|
157 |
|
|
158 |
switch (aFunction)
|
|
159 |
{
|
|
160 |
case RKernAsmBmLdd::ECount:
|
|
161 |
return KernelBenchmarks.Count();
|
|
162 |
|
|
163 |
case RKernAsmBmLdd::EInfo:
|
|
164 |
{
|
|
165 |
TPckgC<TBmInfo> info(KernelBenchmarks[index]->Info());
|
|
166 |
return Kern::ThreadDesWrite(&Kern::CurrentThread(), a1, info, 0, 0, NULL);
|
|
167 |
}
|
|
168 |
|
|
169 |
case RKernAsmBmLdd::ERun:
|
|
170 |
{
|
|
171 |
TPckgBuf<TBmParams> params;
|
|
172 |
Kern::ThreadDesRead(&Kern::CurrentThread(), a1, params, 0, 0);
|
|
173 |
UserPtr = (TUint8*)ALIGN_ADDR(a2);
|
|
174 |
|
|
175 |
TInt delta;
|
|
176 |
TInt r = KernelBenchmarks[index]->Run(params(), delta);
|
|
177 |
if (r == KErrNone)
|
|
178 |
r = Kern::ThreadRawWrite(&Kern::CurrentThread(), a2, &delta, sizeof(TInt));
|
|
179 |
return r;
|
|
180 |
}
|
|
181 |
|
|
182 |
default:
|
|
183 |
return KErrArgument;
|
|
184 |
}
|
|
185 |
}
|
|
186 |
|
|
187 |
void DKernAsmBm::HandleMsg(TMessageBase* /*aMsg*/)
|
|
188 |
{
|
|
189 |
}
|