sl@0
|
1 |
// Copyright (c) 1998-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\misc\t_ipccpy.cpp
|
sl@0
|
15 |
// Overview:
|
sl@0
|
16 |
// Test and benchmark IPC reading, writing, copying.
|
sl@0
|
17 |
// API Information:
|
sl@0
|
18 |
// RBusLogicalChannel, DLogicalChannel.
|
sl@0
|
19 |
// Details:
|
sl@0
|
20 |
// - Load the specified logical device driver, open a channel to it, allocate
|
sl@0
|
21 |
// a cell of specified size from the current thread's heap, get Kernel HAL
|
sl@0
|
22 |
// memory model information.
|
sl@0
|
23 |
// - Make a synchronous Kernel Executive type request to the logical channel
|
sl@0
|
24 |
// to write specified data to the buffer, read the data and calculate the
|
sl@0
|
25 |
// time taken for writing and reading the data. Benchmark the time required
|
sl@0
|
26 |
// to for 1000 64K user->kernel and kernel->user copies.
|
sl@0
|
27 |
// - Create a chunk, get a pointer to the base of the chunk's reserved region,
|
sl@0
|
28 |
// create a server thread, establish a session with the server, signal
|
sl@0
|
29 |
// completion of the client's request when message is received, read,
|
sl@0
|
30 |
// write specified bits and check it is as expected.
|
sl@0
|
31 |
// Platforms/Drives/Compatibility:
|
sl@0
|
32 |
// All.
|
sl@0
|
33 |
// Assumptions/Requirement/Pre-requisites:
|
sl@0
|
34 |
// Failures and causes:
|
sl@0
|
35 |
// Base Port information:
|
sl@0
|
36 |
//
|
sl@0
|
37 |
//
|
sl@0
|
38 |
|
sl@0
|
39 |
#include <e32test.h>
|
sl@0
|
40 |
#include "d_ipccpy.h"
|
sl@0
|
41 |
#include "u32std.h"
|
sl@0
|
42 |
#include <e32kpan.h>
|
sl@0
|
43 |
#include "../mmu/mmudetect.h"
|
sl@0
|
44 |
#include <hal.h>
|
sl@0
|
45 |
|
sl@0
|
46 |
RTest test(_L("T_IPCCPY"));
|
sl@0
|
47 |
TUint8* Buffer;
|
sl@0
|
48 |
TUint8* Disc;
|
sl@0
|
49 |
RIpcCpy Ipccpy;
|
sl@0
|
50 |
TUint32 MainId;
|
sl@0
|
51 |
TUint8 Bss[4096];
|
sl@0
|
52 |
TUint8* Kern;
|
sl@0
|
53 |
TUint8* RamDrive;
|
sl@0
|
54 |
TUint8* Nonexistent;
|
sl@0
|
55 |
TUint8* Unaligned=Bss+1;
|
sl@0
|
56 |
TInt CloseTime;
|
sl@0
|
57 |
TLinAddr HwChunkAddr[RIpcCpy::ENumHwChunkTypes];
|
sl@0
|
58 |
TPtr8 UserDes(Buffer+96,96,96);
|
sl@0
|
59 |
|
sl@0
|
60 |
void SetupAddresses()
|
sl@0
|
61 |
{
|
sl@0
|
62 |
Kern=KernData();
|
sl@0
|
63 |
TUint32 mm_attr=MemModelAttributes();
|
sl@0
|
64 |
TUint32 mm_type=mm_attr & EMemModelTypeMask;
|
sl@0
|
65 |
switch (mm_type)
|
sl@0
|
66 |
{
|
sl@0
|
67 |
case EMemModelTypeDirect:
|
sl@0
|
68 |
RamDrive=(TUint8*)0; // not used anyway
|
sl@0
|
69 |
Nonexistent=(TUint8*)0xa8000000;
|
sl@0
|
70 |
break;
|
sl@0
|
71 |
case EMemModelTypeMoving:
|
sl@0
|
72 |
RamDrive=(TUint8*)0x40000000;
|
sl@0
|
73 |
Nonexistent=(TUint8*)0x60f00000;
|
sl@0
|
74 |
break;
|
sl@0
|
75 |
case EMemModelTypeMultiple:
|
sl@0
|
76 |
RamDrive=(TUint8*)0xa0000000;
|
sl@0
|
77 |
Nonexistent=(TUint8*)0xfe000000;
|
sl@0
|
78 |
break;
|
sl@0
|
79 |
case EMemModelTypeFlexible:
|
sl@0
|
80 |
RamDrive=(TUint8*)0;
|
sl@0
|
81 |
Nonexistent=(TUint8*)0x8ff00000;
|
sl@0
|
82 |
break;
|
sl@0
|
83 |
case EMemModelTypeEmul:
|
sl@0
|
84 |
RamDrive=(TUint8*)0; // not used anyway
|
sl@0
|
85 |
Nonexistent=(TUint8*)0xf0000000;
|
sl@0
|
86 |
break;
|
sl@0
|
87 |
default:
|
sl@0
|
88 |
test(0);
|
sl@0
|
89 |
break;
|
sl@0
|
90 |
}
|
sl@0
|
91 |
new (&UserDes) TPtr8(Buffer+96,96,96);
|
sl@0
|
92 |
Ipccpy.HardwareChunks(HwChunkAddr,UserDes);
|
sl@0
|
93 |
test.Printf(_L("Buffer=%08x\n"),Buffer);
|
sl@0
|
94 |
test.Printf(_L("Bss=%08x\n"),Bss);
|
sl@0
|
95 |
test.Printf(_L("Kern=%08x\n"),Kern);
|
sl@0
|
96 |
test.Printf(_L("RamDrive=%08x\n"),RamDrive);
|
sl@0
|
97 |
test.Printf(_L("Nonexistent=%08x\n"),Nonexistent);
|
sl@0
|
98 |
test.Printf(_L("Unaligned=%08x\n"),Unaligned);
|
sl@0
|
99 |
test.Printf(_L("HwChunkSupRw=%08x\n"),HwChunkAddr[RIpcCpy::EHwChunkSupRw]);
|
sl@0
|
100 |
test.Printf(_L("HwChunkUserRw=%08x\n"),HwChunkAddr[RIpcCpy::EHwChunkUserRw]);
|
sl@0
|
101 |
test.Printf(_L("HwChunkUserRo=%08x\n"),HwChunkAddr[RIpcCpy::EHwChunkUserRo]);
|
sl@0
|
102 |
}
|
sl@0
|
103 |
|
sl@0
|
104 |
_LIT(KLitKernExec,"KERN-EXEC");
|
sl@0
|
105 |
|
sl@0
|
106 |
void TestEq(TInt a, TInt b, TInt l);
|
sl@0
|
107 |
void Test(TBool c, TInt l);
|
sl@0
|
108 |
|
sl@0
|
109 |
#define TESTEQ(a,b) TestEq((a),(b),__LINE__)
|
sl@0
|
110 |
#define TEST(c) Test((c),__LINE__)
|
sl@0
|
111 |
|
sl@0
|
112 |
void TestEq(TInt a, TInt b, TInt l)
|
sl@0
|
113 |
{
|
sl@0
|
114 |
if (a!=b)
|
sl@0
|
115 |
{
|
sl@0
|
116 |
if (TUint32(RThread().Id())==MainId)
|
sl@0
|
117 |
{
|
sl@0
|
118 |
test.Printf(_L("Line %d a=%d, b=%d\n"),l,a,b);
|
sl@0
|
119 |
test(0);
|
sl@0
|
120 |
}
|
sl@0
|
121 |
else
|
sl@0
|
122 |
User::Panic(_L("TESTEQ"),l);
|
sl@0
|
123 |
}
|
sl@0
|
124 |
}
|
sl@0
|
125 |
|
sl@0
|
126 |
void Test(TBool c, TInt l)
|
sl@0
|
127 |
{
|
sl@0
|
128 |
if (!c)
|
sl@0
|
129 |
{
|
sl@0
|
130 |
if (TUint32(RThread().Id())==MainId)
|
sl@0
|
131 |
{
|
sl@0
|
132 |
test.Printf(_L("Line %d FAIL\n"),l);
|
sl@0
|
133 |
test(0);
|
sl@0
|
134 |
}
|
sl@0
|
135 |
else
|
sl@0
|
136 |
User::Panic(_L("TEST"),l);
|
sl@0
|
137 |
}
|
sl@0
|
138 |
}
|
sl@0
|
139 |
|
sl@0
|
140 |
struct SIpcTestInfo
|
sl@0
|
141 |
{
|
sl@0
|
142 |
const TAny* iLocal;
|
sl@0
|
143 |
const TAny* iRemote;
|
sl@0
|
144 |
TInt iOffset;
|
sl@0
|
145 |
TInt iMode; // bit 0 = 1 for 16 bit, bit 1 = 1 for write
|
sl@0
|
146 |
};
|
sl@0
|
147 |
|
sl@0
|
148 |
class RLocalSession : public RSessionBase
|
sl@0
|
149 |
{
|
sl@0
|
150 |
public:
|
sl@0
|
151 |
TInt Connect(RServer2 aSrv,TRequestStatus* aStat)
|
sl@0
|
152 |
{return CreateSession(aSrv,TVersion(),-1,EIpcSession_Unsharable,0,aStat);}
|
sl@0
|
153 |
void Test(const TAny* aRemote)
|
sl@0
|
154 |
{Send(0,TIpcArgs((const TDesC8*)aRemote,(const TDesC16*)aRemote,(TDes8*)aRemote,(TDes16*)aRemote));}
|
sl@0
|
155 |
void Wait()
|
sl@0
|
156 |
{SendReceive(1);}
|
sl@0
|
157 |
};
|
sl@0
|
158 |
|
sl@0
|
159 |
RServer2 IpcServer;
|
sl@0
|
160 |
|
sl@0
|
161 |
TInt IpcTestFn(TAny* aInfo)
|
sl@0
|
162 |
{
|
sl@0
|
163 |
SIpcTestInfo& i=*(SIpcTestInfo*)aInfo;
|
sl@0
|
164 |
|
sl@0
|
165 |
if (IpcServer.Handle())
|
sl@0
|
166 |
IpcServer.Close();
|
sl@0
|
167 |
|
sl@0
|
168 |
TESTEQ(IpcServer.CreateGlobal(KNullDesC),KErrNone);
|
sl@0
|
169 |
RLocalSession sess;
|
sl@0
|
170 |
TRequestStatus stat;
|
sl@0
|
171 |
TESTEQ(sess.Connect(IpcServer,&stat),KErrNone);
|
sl@0
|
172 |
RMessage2 m;
|
sl@0
|
173 |
IpcServer.Receive(m);
|
sl@0
|
174 |
m.Complete(KErrNone); // connect
|
sl@0
|
175 |
User::WaitForRequest(stat); // connection message report
|
sl@0
|
176 |
sess.Test(i.iRemote);
|
sl@0
|
177 |
IpcServer.Receive(m);
|
sl@0
|
178 |
|
sl@0
|
179 |
TInt r=KMinTInt;
|
sl@0
|
180 |
switch (i.iMode)
|
sl@0
|
181 |
{
|
sl@0
|
182 |
case 0:
|
sl@0
|
183 |
{ // read 8 bit
|
sl@0
|
184 |
TDesC8* pR=(TDesC8*)i.iRemote;
|
sl@0
|
185 |
TDes8* pL=(TDes8*)i.iLocal;
|
sl@0
|
186 |
r=m.Read(0,*pL,i.iOffset);
|
sl@0
|
187 |
if (r==KErrNone)
|
sl@0
|
188 |
{
|
sl@0
|
189 |
TESTEQ(pL->Length(),pR->Length()-i.iOffset);
|
sl@0
|
190 |
TEST(*pL==pR->Mid(i.iOffset));
|
sl@0
|
191 |
}
|
sl@0
|
192 |
break;
|
sl@0
|
193 |
}
|
sl@0
|
194 |
case 1:
|
sl@0
|
195 |
{ // read 16 bit
|
sl@0
|
196 |
TDesC16* pR=(TDesC16*)i.iRemote;
|
sl@0
|
197 |
TDes16* pL=(TDes16*)i.iLocal;
|
sl@0
|
198 |
r=m.Read(1,*pL,i.iOffset);
|
sl@0
|
199 |
if (r==KErrNone)
|
sl@0
|
200 |
{
|
sl@0
|
201 |
TESTEQ(pL->Length(),pR->Length()-i.iOffset);
|
sl@0
|
202 |
TEST(*pL==pR->Mid(i.iOffset));
|
sl@0
|
203 |
}
|
sl@0
|
204 |
break;
|
sl@0
|
205 |
}
|
sl@0
|
206 |
case 2:
|
sl@0
|
207 |
{ // write 8 bit
|
sl@0
|
208 |
TDes8* pR=(TDes8*)i.iRemote;
|
sl@0
|
209 |
TDesC8* pL=(TDesC8*)i.iLocal;
|
sl@0
|
210 |
r=m.Write(2,*pL,i.iOffset);
|
sl@0
|
211 |
if (r==KErrNone)
|
sl@0
|
212 |
{
|
sl@0
|
213 |
TESTEQ(pR->Length(),pL->Length()+i.iOffset);
|
sl@0
|
214 |
TEST(*pL==pR->Mid(i.iOffset));
|
sl@0
|
215 |
}
|
sl@0
|
216 |
break;
|
sl@0
|
217 |
}
|
sl@0
|
218 |
case 3:
|
sl@0
|
219 |
{ // write 16 bit
|
sl@0
|
220 |
TDes16* pR=(TDes16*)i.iRemote;
|
sl@0
|
221 |
TDesC16* pL=(TDesC16*)i.iLocal;
|
sl@0
|
222 |
r=m.Write(3,*pL,i.iOffset);
|
sl@0
|
223 |
if (r==KErrNone)
|
sl@0
|
224 |
{
|
sl@0
|
225 |
TESTEQ(pR->Length(),pL->Length()+i.iOffset);
|
sl@0
|
226 |
TEST(*pL==pR->Mid(i.iOffset));
|
sl@0
|
227 |
}
|
sl@0
|
228 |
break;
|
sl@0
|
229 |
}
|
sl@0
|
230 |
default:
|
sl@0
|
231 |
User::Panic(_L("MODE"),i.iMode);
|
sl@0
|
232 |
}
|
sl@0
|
233 |
m.Complete(0);
|
sl@0
|
234 |
sess.Close();
|
sl@0
|
235 |
IpcServer.Close();
|
sl@0
|
236 |
|
sl@0
|
237 |
return r;
|
sl@0
|
238 |
}
|
sl@0
|
239 |
|
sl@0
|
240 |
void _DoIpcTest(const TAny* aLocal, const TAny* aRemote, TInt aOffset, TInt aMode, const TDesC* aPanicCat, TInt aResult, TInt aLine)
|
sl@0
|
241 |
{
|
sl@0
|
242 |
test.Printf(_L("Line %d\n"),aLine);
|
sl@0
|
243 |
SIpcTestInfo info;
|
sl@0
|
244 |
info.iLocal=aLocal;
|
sl@0
|
245 |
info.iRemote=aRemote;
|
sl@0
|
246 |
info.iOffset=aOffset;
|
sl@0
|
247 |
info.iMode=aMode;
|
sl@0
|
248 |
if (!aPanicCat)
|
sl@0
|
249 |
{
|
sl@0
|
250 |
// do test in this thread
|
sl@0
|
251 |
TInt r=IpcTestFn(&info);
|
sl@0
|
252 |
TESTEQ(r,aResult);
|
sl@0
|
253 |
return;
|
sl@0
|
254 |
}
|
sl@0
|
255 |
TBool jit=User::JustInTime();
|
sl@0
|
256 |
RThread t;
|
sl@0
|
257 |
TInt r=t.Create(KNullDesC(),IpcTestFn,0x2000,NULL,&info);
|
sl@0
|
258 |
test(r==KErrNone);
|
sl@0
|
259 |
TRequestStatus s;
|
sl@0
|
260 |
t.Logon(s);
|
sl@0
|
261 |
User::SetJustInTime(EFalse);
|
sl@0
|
262 |
t.Resume();
|
sl@0
|
263 |
User::WaitForRequest(s);
|
sl@0
|
264 |
User::SetJustInTime(jit);
|
sl@0
|
265 |
test(t.ExitType()==EExitPanic);
|
sl@0
|
266 |
test(t.ExitCategory()==*aPanicCat);
|
sl@0
|
267 |
TESTEQ(t.ExitReason(),aResult);
|
sl@0
|
268 |
t.Close();
|
sl@0
|
269 |
}
|
sl@0
|
270 |
|
sl@0
|
271 |
void DoIpcTest(const TUint8* aLocal, const TUint8* aRemote, TInt aLength, TInt aMode, const TDesC* aPanicCat, TInt aResult, TInt aLine)
|
sl@0
|
272 |
{
|
sl@0
|
273 |
TPtr8 local((TUint8*)aLocal,aLength,aLength);
|
sl@0
|
274 |
TPtr8 remote((TUint8*)aRemote,aLength,aLength);
|
sl@0
|
275 |
_DoIpcTest(&local,&remote,0,aMode,aPanicCat,aResult,aLine);
|
sl@0
|
276 |
}
|
sl@0
|
277 |
|
sl@0
|
278 |
void DoIpcTest(const TUint8* aLocal, const TDesC8& aRemote, TInt aLength, TInt aMode, const TDesC* aPanicCat, TInt aResult, TInt aLine)
|
sl@0
|
279 |
{
|
sl@0
|
280 |
TPtr8 local((TUint8*)aLocal,aLength,aLength);
|
sl@0
|
281 |
_DoIpcTest(&local,&aRemote,0,aMode,aPanicCat,aResult,aLine);
|
sl@0
|
282 |
}
|
sl@0
|
283 |
|
sl@0
|
284 |
void TestIpcCopyErrors()
|
sl@0
|
285 |
{
|
sl@0
|
286 |
RChunk c;
|
sl@0
|
287 |
TInt r=c.CreateDisconnectedLocal(0,0,0x500000);
|
sl@0
|
288 |
test(r==KErrNone);
|
sl@0
|
289 |
r=c.Commit(0,0x1000);
|
sl@0
|
290 |
test(r==KErrNone);
|
sl@0
|
291 |
r=c.Commit(0x2000,0x1000);
|
sl@0
|
292 |
test(r==KErrNone);
|
sl@0
|
293 |
r=c.Commit(0x3ff000,0x1000);
|
sl@0
|
294 |
test(r==KErrNone);
|
sl@0
|
295 |
Disc=c.Base();
|
sl@0
|
296 |
test.Printf(_L("Disc=%08x\n"),Disc);
|
sl@0
|
297 |
DoIpcTest(Buffer,(const TUint8*)&TestEq,100,0,NULL,KErrNone,__LINE__);
|
sl@0
|
298 |
DoIpcTest(Buffer,(const TUint8*)&TestEq,100,2,NULL,KErrBadDescriptor,__LINE__);
|
sl@0
|
299 |
DoIpcTest((const TUint8*)&TestEq,Buffer,100,2,NULL,KErrNone,__LINE__);
|
sl@0
|
300 |
DoIpcTest((const TUint8*)&TestEq,Buffer,100,0,&KLitKernExec,ECausedException,__LINE__);
|
sl@0
|
301 |
DoIpcTest(Buffer,Nonexistent,100,0,NULL,KErrBadDescriptor,__LINE__);
|
sl@0
|
302 |
DoIpcTest(Buffer,Nonexistent,100,2,NULL,KErrBadDescriptor,__LINE__);
|
sl@0
|
303 |
DoIpcTest(Nonexistent,Buffer,100,2,&KLitKernExec,ECausedException,__LINE__);
|
sl@0
|
304 |
DoIpcTest(Nonexistent,Buffer,100,0,&KLitKernExec,ECausedException,__LINE__);
|
sl@0
|
305 |
DoIpcTest(Buffer,Unaligned,100,0,NULL,KErrNone,__LINE__);
|
sl@0
|
306 |
DoIpcTest(Buffer,Unaligned,100,2,NULL,KErrNone,__LINE__);
|
sl@0
|
307 |
DoIpcTest(Unaligned,Buffer,100,2,NULL,KErrNone,__LINE__);
|
sl@0
|
308 |
DoIpcTest(Unaligned,Buffer,100,0,NULL,KErrNone,__LINE__);
|
sl@0
|
309 |
|
sl@0
|
310 |
DoIpcTest(Disc+4001,Buffer,95,0,NULL,KErrNone,__LINE__);
|
sl@0
|
311 |
if (HaveVirtMem())
|
sl@0
|
312 |
DoIpcTest(Disc+4001,Buffer,96,0,&KLitKernExec,ECausedException,__LINE__);
|
sl@0
|
313 |
DoIpcTest(Buffer,Disc+4001,95,0,NULL,KErrNone,__LINE__);
|
sl@0
|
314 |
if (HaveVirtMem())
|
sl@0
|
315 |
DoIpcTest(Buffer,Disc+4001,96,0,NULL,KErrBadDescriptor,__LINE__);
|
sl@0
|
316 |
|
sl@0
|
317 |
TPtr8* pdes;
|
sl@0
|
318 |
if (HaveVirtMem())
|
sl@0
|
319 |
{
|
sl@0
|
320 |
// test descriptor stored stradling chunk end...
|
sl@0
|
321 |
pdes = (TPtr8*)(Disc+0x3ffff4);
|
sl@0
|
322 |
memcpy(pdes,&UserDes,12);
|
sl@0
|
323 |
DoIpcTest(Buffer,*pdes,pdes->Size(),0,NULL,KErrNone,__LINE__);
|
sl@0
|
324 |
pdes = (TPtr8*)(Disc+0x3ffff8);
|
sl@0
|
325 |
memcpy(pdes,&UserDes,8);
|
sl@0
|
326 |
DoIpcTest(Buffer,*pdes,pdes->Size(),0,NULL,KErrBadDescriptor,__LINE__);
|
sl@0
|
327 |
pdes = (TPtr8*)(Disc+0x3ffffc);
|
sl@0
|
328 |
memcpy(pdes,&UserDes,4);
|
sl@0
|
329 |
DoIpcTest(Buffer,*pdes,pdes->Size(),0,NULL,KErrBadDescriptor,__LINE__);
|
sl@0
|
330 |
r=c.Commit(0x400000,0x1000);
|
sl@0
|
331 |
test(r==KErrNone);
|
sl@0
|
332 |
pdes = (TPtr8*)(Disc+0x3ffff4);
|
sl@0
|
333 |
memcpy(pdes,&UserDes,12);
|
sl@0
|
334 |
DoIpcTest(Buffer,*pdes,pdes->Size(),0,NULL,KErrNone,__LINE__);
|
sl@0
|
335 |
pdes = (TPtr8*)(Disc+0x3ffff8);
|
sl@0
|
336 |
memcpy(pdes,&UserDes,12);
|
sl@0
|
337 |
DoIpcTest(Buffer,*pdes,pdes->Size(),0,NULL,KErrNone,__LINE__);
|
sl@0
|
338 |
pdes = (TPtr8*)(Disc+0x3ffffc);
|
sl@0
|
339 |
memcpy(pdes,&UserDes,12);
|
sl@0
|
340 |
DoIpcTest(Buffer,*pdes,pdes->Size(),0,NULL,KErrNone,__LINE__);
|
sl@0
|
341 |
}
|
sl@0
|
342 |
|
sl@0
|
343 |
if (HaveMultAddr())
|
sl@0
|
344 |
{
|
sl@0
|
345 |
if(RamDrive)
|
sl@0
|
346 |
{
|
sl@0
|
347 |
DoIpcTest(Disc+0x100000,Buffer,96,0,&KLitKernExec,ECausedException,__LINE__);
|
sl@0
|
348 |
DoIpcTest(Buffer,Disc+0x100000,96,0,NULL,KErrBadDescriptor,__LINE__);
|
sl@0
|
349 |
DoIpcTest(RamDrive,Buffer,4,0,&KLitKernExec,ECausedException,__LINE__);
|
sl@0
|
350 |
DoIpcTest(Buffer,RamDrive,4,0,NULL,KErrBadDescriptor,__LINE__);
|
sl@0
|
351 |
DoIpcTest(RamDrive,Buffer,4,2,&KLitKernExec,ECausedException,__LINE__);
|
sl@0
|
352 |
DoIpcTest(Buffer,RamDrive,4,2,NULL,KErrBadDescriptor,__LINE__);
|
sl@0
|
353 |
}
|
sl@0
|
354 |
|
sl@0
|
355 |
// if memory alising happens during IPC then the memory at 'Disc' would be aliased
|
sl@0
|
356 |
// at KIPCAliasAddress and so would not be protected by MMU permission checks.
|
sl@0
|
357 |
// However, the kernel should still prevent this, to avoid degrading process
|
sl@0
|
358 |
// protection for memory in other parts of the alias region.
|
sl@0
|
359 |
#ifdef __CPU_X86
|
sl@0
|
360 |
const TUint8* KIPCAliasAddress;
|
sl@0
|
361 |
if((MemModelAttributes()&EMemModelTypeMask) == EMemModelTypeFlexible)
|
sl@0
|
362 |
KIPCAliasAddress = (TUint8*)0x7e000000;
|
sl@0
|
363 |
else
|
sl@0
|
364 |
KIPCAliasAddress = (TUint8*)0xc0400000;
|
sl@0
|
365 |
#else
|
sl@0
|
366 |
const TUint8* KIPCAliasAddress = (TUint8*)0x00200000;
|
sl@0
|
367 |
#endif
|
sl@0
|
368 |
DoIpcTest(KIPCAliasAddress,Disc,4,0,&KLitKernExec,ECausedException,__LINE__);
|
sl@0
|
369 |
DoIpcTest(Disc,KIPCAliasAddress,4,0,NULL,KErrBadDescriptor,__LINE__);
|
sl@0
|
370 |
DoIpcTest(KIPCAliasAddress,Disc,4,2,&KLitKernExec,ECausedException,__LINE__);
|
sl@0
|
371 |
DoIpcTest(Disc,KIPCAliasAddress,4,2,NULL,KErrBadDescriptor,__LINE__);
|
sl@0
|
372 |
}
|
sl@0
|
373 |
|
sl@0
|
374 |
if (HaveIPCKernProt())
|
sl@0
|
375 |
{
|
sl@0
|
376 |
DoIpcTest(Kern,Buffer,96,0,&KLitKernExec,ECausedException,__LINE__);
|
sl@0
|
377 |
DoIpcTest(Buffer,Kern,96,0,NULL,KErrBadDescriptor,__LINE__);
|
sl@0
|
378 |
TUint8* addrRW = (TUint8*)HwChunkAddr[RIpcCpy::EHwChunkSupRw];
|
sl@0
|
379 |
if(addrRW)
|
sl@0
|
380 |
{
|
sl@0
|
381 |
DoIpcTest(Buffer,*(TDes8*)addrRW,96,0,NULL,KErrBadDescriptor,__LINE__);
|
sl@0
|
382 |
DoIpcTest(Buffer,*(TDes8*)addrRW,96,2,NULL,KErrBadDescriptor,__LINE__);
|
sl@0
|
383 |
DoIpcTest(addrRW+96,Buffer,96,0,&KLitKernExec,ECausedException,__LINE__);
|
sl@0
|
384 |
DoIpcTest(Buffer,addrRW,96,0,NULL,KErrBadDescriptor,__LINE__);
|
sl@0
|
385 |
DoIpcTest(addrRW+96,Buffer,96,2,&KLitKernExec,ECausedException,__LINE__);
|
sl@0
|
386 |
DoIpcTest(Buffer,addrRW,96,2,NULL,KErrBadDescriptor,__LINE__);
|
sl@0
|
387 |
}
|
sl@0
|
388 |
}
|
sl@0
|
389 |
|
sl@0
|
390 |
if((MemModelAttributes()&EMemModelTypeMask) == EMemModelTypeMultiple
|
sl@0
|
391 |
|| (MemModelAttributes()&EMemModelTypeMask) == EMemModelTypeFlexible
|
sl@0
|
392 |
)
|
sl@0
|
393 |
{
|
sl@0
|
394 |
// On multiple memory model, test IPC to Hardware Chunks.
|
sl@0
|
395 |
// IPC to hardware chunks not supported on Moving Memory
|
sl@0
|
396 |
TUint8* addrRW = (TUint8*)HwChunkAddr[RIpcCpy::EHwChunkUserRw];
|
sl@0
|
397 |
if(addrRW)
|
sl@0
|
398 |
{
|
sl@0
|
399 |
DoIpcTest(Buffer,*(TDes8*)addrRW,96,0,NULL,KErrNone,__LINE__);
|
sl@0
|
400 |
DoIpcTest(Buffer,*(TDes8*)addrRW,96,2,NULL,KErrNone,__LINE__);
|
sl@0
|
401 |
DoIpcTest(addrRW+96,Buffer,96,0,NULL,KErrNone,__LINE__);
|
sl@0
|
402 |
DoIpcTest(Buffer,addrRW,96,0,NULL,KErrNone,__LINE__);
|
sl@0
|
403 |
DoIpcTest(addrRW+96,Buffer,96,2,NULL,KErrNone,__LINE__);
|
sl@0
|
404 |
DoIpcTest(Buffer,addrRW,96,2,NULL,KErrNone,__LINE__);
|
sl@0
|
405 |
DoIpcTest(addrRW+96,addrRW,96,0,NULL,KErrNone,__LINE__);
|
sl@0
|
406 |
DoIpcTest(addrRW+96,addrRW,96,2,NULL,KErrNone,__LINE__);
|
sl@0
|
407 |
}
|
sl@0
|
408 |
TUint8* addrRO = (TUint8*)HwChunkAddr[RIpcCpy::EHwChunkUserRo];
|
sl@0
|
409 |
if(addrRO && HaveWriteProt())
|
sl@0
|
410 |
{
|
sl@0
|
411 |
DoIpcTest(Buffer,*(TDes8*)addrRO,96,0,NULL,KErrNone,__LINE__);
|
sl@0
|
412 |
DoIpcTest(Buffer,*(TDes8*)addrRO,96,2,&KLitKernExec,EBadIpcDescriptor,__LINE__);
|
sl@0
|
413 |
DoIpcTest(addrRO+96,Buffer,96,0,&KLitKernExec,ECausedException,__LINE__);
|
sl@0
|
414 |
DoIpcTest(Buffer,addrRO,96,0,NULL,KErrNone,__LINE__);
|
sl@0
|
415 |
DoIpcTest(addrRO+96,Buffer,96,2,NULL,KErrNone,__LINE__);
|
sl@0
|
416 |
DoIpcTest(Buffer,addrRO,96,2,NULL,KErrBadDescriptor,__LINE__);
|
sl@0
|
417 |
DoIpcTest(addrRW+96,addrRO,96,0,NULL,KErrNone,__LINE__);
|
sl@0
|
418 |
DoIpcTest(addrRW+96,addrRW,96,2,NULL,KErrNone,__LINE__);
|
sl@0
|
419 |
DoIpcTest(addrRO+96,addrRO,96,0,&KLitKernExec,ECausedException,__LINE__);
|
sl@0
|
420 |
DoIpcTest(addrRO+96,addrRW,96,2,NULL,KErrNone,__LINE__);
|
sl@0
|
421 |
}
|
sl@0
|
422 |
}
|
sl@0
|
423 |
|
sl@0
|
424 |
c.Close();
|
sl@0
|
425 |
}
|
sl@0
|
426 |
|
sl@0
|
427 |
RMessage2 Msg1, Msg2;
|
sl@0
|
428 |
|
sl@0
|
429 |
TInt SendAndExit(TAny* aPtr)
|
sl@0
|
430 |
{
|
sl@0
|
431 |
RLocalSession sess;
|
sl@0
|
432 |
TInt r=sess.Connect(IpcServer,NULL);
|
sl@0
|
433 |
if (r!=KErrNone)
|
sl@0
|
434 |
return r;
|
sl@0
|
435 |
sess.Test(aPtr);
|
sl@0
|
436 |
sess.Wait();
|
sl@0
|
437 |
sess.Close();
|
sl@0
|
438 |
User::AfterHighRes(1000*CloseTime);
|
sl@0
|
439 |
Msg1.Complete(0); // complete my own message! - this removes message reference to thread
|
sl@0
|
440 |
return 0;
|
sl@0
|
441 |
}
|
sl@0
|
442 |
|
sl@0
|
443 |
void TestIpcAsyncClose()
|
sl@0
|
444 |
{
|
sl@0
|
445 |
|
sl@0
|
446 |
// Create a 16MB chunk
|
sl@0
|
447 |
const TInt desSize = 8*1024*1024;
|
sl@0
|
448 |
RChunk chunk;
|
sl@0
|
449 |
test(chunk.CreateLocal(2 * desSize, 2 * desSize) == KErrNone);
|
sl@0
|
450 |
test(chunk.Adjust(2 * desSize) == KErrNone);
|
sl@0
|
451 |
|
sl@0
|
452 |
TUint8* bigBuf=chunk.Base();
|
sl@0
|
453 |
test(bigBuf!=NULL);
|
sl@0
|
454 |
TUint8* bigBuf2=chunk.Base() + desSize;
|
sl@0
|
455 |
test(bigBuf2!=NULL);
|
sl@0
|
456 |
TPtr8 bigBufPtr(bigBuf, desSize, desSize);
|
sl@0
|
457 |
TPtr8 bigBufPtr2(bigBuf2, 0, desSize);
|
sl@0
|
458 |
|
sl@0
|
459 |
if (IpcServer.Handle())
|
sl@0
|
460 |
IpcServer.Close();
|
sl@0
|
461 |
TESTEQ(IpcServer.CreateGlobal(KNullDesC),KErrNone);
|
sl@0
|
462 |
|
sl@0
|
463 |
RThread t;
|
sl@0
|
464 |
TInt r=t.Create(KNullDesC,SendAndExit,0x1000,NULL,&bigBufPtr);
|
sl@0
|
465 |
test(r==KErrNone);
|
sl@0
|
466 |
TFullName fn(t.FullName());
|
sl@0
|
467 |
TRequestStatus s;
|
sl@0
|
468 |
t.Logon(s);
|
sl@0
|
469 |
t.SetPriority(EPriorityMuchMore);
|
sl@0
|
470 |
t.Resume();
|
sl@0
|
471 |
|
sl@0
|
472 |
IpcServer.Receive(Msg1); // connect
|
sl@0
|
473 |
Msg1.Complete(KErrNone);
|
sl@0
|
474 |
IpcServer.Receive(Msg1); // test message
|
sl@0
|
475 |
IpcServer.Receive(Msg2); // wait/synch message
|
sl@0
|
476 |
TUint32 initial = User::NTickCount();
|
sl@0
|
477 |
r=Msg1.Read(2,bigBufPtr2,0); // arg2 is writable 8 bit descriptor
|
sl@0
|
478 |
TUint32 final = User::NTickCount();
|
sl@0
|
479 |
TUint32 elapsed = final - initial;
|
sl@0
|
480 |
if (elapsed<3)
|
sl@0
|
481 |
test.Printf(_L("*** WARNING! The big IPC only took %dms, which means the next test might fail! \n"),elapsed);
|
sl@0
|
482 |
else
|
sl@0
|
483 |
test.Printf(_L("Big IPC took %dms\n"),elapsed);
|
sl@0
|
484 |
CloseTime = (TInt)(elapsed>>2);
|
sl@0
|
485 |
Msg2.Complete(0);
|
sl@0
|
486 |
IpcServer.Receive(Msg2); // disconnect
|
sl@0
|
487 |
TUint32 disconnect = User::NTickCount();
|
sl@0
|
488 |
|
sl@0
|
489 |
// We expect this IPC read to fail part way through
|
sl@0
|
490 |
r=Msg1.Read(2,bigBufPtr2,0); // arg2 is writable 8 bit descriptor
|
sl@0
|
491 |
test.Printf(_L("counters: initial=%d final=%d disconnect=%d current=%d\n"),initial,final,disconnect,User::NTickCount());
|
sl@0
|
492 |
test.Printf(_L("2nd Big IPC returned %d\n"),r);
|
sl@0
|
493 |
test(r==KErrDied);
|
sl@0
|
494 |
test(Msg1.IsNull());
|
sl@0
|
495 |
Msg2.Complete(0); // complete session closure as well
|
sl@0
|
496 |
User::WaitForRequest(s);
|
sl@0
|
497 |
test(s==KErrNone);
|
sl@0
|
498 |
CLOSE_AND_WAIT(t);
|
sl@0
|
499 |
test(t.Open(fn)==KErrNotFound);
|
sl@0
|
500 |
IpcServer.Close();
|
sl@0
|
501 |
|
sl@0
|
502 |
// t already closed
|
sl@0
|
503 |
// User::Free(bigBuf);
|
sl@0
|
504 |
// User::Free(bigBuf2);
|
sl@0
|
505 |
chunk.Close();
|
sl@0
|
506 |
}
|
sl@0
|
507 |
|
sl@0
|
508 |
void BenchmarkTest()
|
sl@0
|
509 |
{
|
sl@0
|
510 |
TAny* bigbuf = User::Alloc(65536);
|
sl@0
|
511 |
test(bigbuf != NULL);
|
sl@0
|
512 |
TInt i;
|
sl@0
|
513 |
TUint32 initial, final;
|
sl@0
|
514 |
initial = User::NTickCount();
|
sl@0
|
515 |
for (i=0; i<1000; ++i)
|
sl@0
|
516 |
Ipccpy.BigWrite(bigbuf, 0);
|
sl@0
|
517 |
final = User::NTickCount();
|
sl@0
|
518 |
TUint32 wcal = final - initial;
|
sl@0
|
519 |
initial = User::NTickCount();
|
sl@0
|
520 |
for (i=0; i<1000; ++i)
|
sl@0
|
521 |
Ipccpy.BigWrite(bigbuf, 65536);
|
sl@0
|
522 |
final = User::NTickCount();
|
sl@0
|
523 |
TUint32 write = final - initial;
|
sl@0
|
524 |
test.Printf(_L("64K user->kernel copy takes %d us\n"), write - wcal);
|
sl@0
|
525 |
initial = User::NTickCount();
|
sl@0
|
526 |
for (i=0; i<1000; ++i)
|
sl@0
|
527 |
Ipccpy.BigRead(bigbuf, 0);
|
sl@0
|
528 |
final = User::NTickCount();
|
sl@0
|
529 |
TUint32 rcal = final - initial;
|
sl@0
|
530 |
initial = User::NTickCount();
|
sl@0
|
531 |
for (i=0; i<1000; ++i)
|
sl@0
|
532 |
Ipccpy.BigRead(bigbuf, 65536);
|
sl@0
|
533 |
final = User::NTickCount();
|
sl@0
|
534 |
TUint32 read = final - initial;
|
sl@0
|
535 |
test.Printf(_L("64K kernel->user copy takes %d us\n"), read - rcal);
|
sl@0
|
536 |
User::Free(bigbuf);
|
sl@0
|
537 |
// User::After(10*1000*1000);
|
sl@0
|
538 |
}
|
sl@0
|
539 |
|
sl@0
|
540 |
|
sl@0
|
541 |
RMessage2 IpcMesage;
|
sl@0
|
542 |
const TInt KTestChunkSize = 1024*1024;
|
sl@0
|
543 |
const TInt KReadSize = 4096;
|
sl@0
|
544 |
|
sl@0
|
545 |
TInt IpcMultipleAliasesThread(TAny* aBuffer)
|
sl@0
|
546 |
{
|
sl@0
|
547 |
TBuf8<KReadSize> data;
|
sl@0
|
548 |
TAny** dataStart = (TAny**)data.Ptr();
|
sl@0
|
549 |
TAny** dataEnd = (TAny**)(data.Ptr()+KReadSize-sizeof(TAny*));
|
sl@0
|
550 |
for(;;)
|
sl@0
|
551 |
{
|
sl@0
|
552 |
TInt offset;
|
sl@0
|
553 |
for(offset=0; offset<KTestChunkSize; offset+=KReadSize)
|
sl@0
|
554 |
{
|
sl@0
|
555 |
TInt r = IpcMesage.Read(0,data,offset);
|
sl@0
|
556 |
if(r!=KErrNone)
|
sl@0
|
557 |
return r;
|
sl@0
|
558 |
if(data.Size()!=KReadSize)
|
sl@0
|
559 |
return 1;
|
sl@0
|
560 |
TAny* expected = (TAny*)((TInt)aBuffer+offset);
|
sl@0
|
561 |
if(*dataStart != expected)
|
sl@0
|
562 |
{
|
sl@0
|
563 |
RDebug::Printf("Offset=%x, expected %x but read %x",offset,expected,*dataStart);
|
sl@0
|
564 |
return 2;
|
sl@0
|
565 |
}
|
sl@0
|
566 |
expected = (TAny*)((TInt)aBuffer+offset+KReadSize-sizeof(TAny*));
|
sl@0
|
567 |
if(*dataEnd != expected)
|
sl@0
|
568 |
{
|
sl@0
|
569 |
RDebug::Printf("Offset=%x, expected %x but read %x",offset,expected,*dataEnd);
|
sl@0
|
570 |
return 3;
|
sl@0
|
571 |
}
|
sl@0
|
572 |
}
|
sl@0
|
573 |
}
|
sl@0
|
574 |
}
|
sl@0
|
575 |
|
sl@0
|
576 |
/*
|
sl@0
|
577 |
This tests exercises the situation where multiple threads are doing IPC simultaneousely.
|
sl@0
|
578 |
On the Multiple Memory Model, this aims to test the per-thread memory aliasing code.
|
sl@0
|
579 |
(DMemModelThread::Alias and company)
|
sl@0
|
580 |
*/
|
sl@0
|
581 |
void TestIpcMultipleThreads()
|
sl@0
|
582 |
{
|
sl@0
|
583 |
test.Start(_L("Test Multiple Threads IPC"));
|
sl@0
|
584 |
|
sl@0
|
585 |
// create chunk for threads to do IPC from...
|
sl@0
|
586 |
RChunk chunk;
|
sl@0
|
587 |
TESTEQ(chunk.CreateLocal(KTestChunkSize,KTestChunkSize),KErrNone);
|
sl@0
|
588 |
TAny** buffer = (TAny**)chunk.Base();
|
sl@0
|
589 |
TAny** bufferEnd = (TAny**)((TInt)buffer+KTestChunkSize);
|
sl@0
|
590 |
for(; buffer<bufferEnd; ++buffer)
|
sl@0
|
591 |
*buffer=buffer;
|
sl@0
|
592 |
|
sl@0
|
593 |
// create a server message which test threads can use to do IPC memory operations
|
sl@0
|
594 |
if (IpcServer.Handle())
|
sl@0
|
595 |
IpcServer.Close();
|
sl@0
|
596 |
TESTEQ(IpcServer.CreateGlobal(KNullDesC),KErrNone);
|
sl@0
|
597 |
RLocalSession sess;
|
sl@0
|
598 |
TRequestStatus stat;
|
sl@0
|
599 |
TESTEQ(sess.Connect(IpcServer,&stat),KErrNone);
|
sl@0
|
600 |
RMessage2 m;
|
sl@0
|
601 |
IpcServer.Receive(m);
|
sl@0
|
602 |
m.Complete(KErrNone); // connect
|
sl@0
|
603 |
User::WaitForRequest(stat); // connection message report
|
sl@0
|
604 |
TAny* ptrMem = User::Alloc(0x2000);
|
sl@0
|
605 |
TPtr8* pptr = (TPtr8*)(((TInt)ptrMem&~0xfff)+0x1000-sizeof(TInt));
|
sl@0
|
606 |
new (pptr) TPtr8(chunk.Base(),KTestChunkSize,KTestChunkSize); // create a TPtr8 which straddles a page boundary
|
sl@0
|
607 |
sess.Test(pptr);
|
sl@0
|
608 |
IpcServer.Receive(IpcMesage);
|
sl@0
|
609 |
|
sl@0
|
610 |
// create some test threads...
|
sl@0
|
611 |
const TInt KNumIpcThreads = 10;
|
sl@0
|
612 |
RThread threads[KNumIpcThreads];
|
sl@0
|
613 |
TRequestStatus stats[KNumIpcThreads];
|
sl@0
|
614 |
TInt i;
|
sl@0
|
615 |
for(i=0; i<KNumIpcThreads; i++)
|
sl@0
|
616 |
{
|
sl@0
|
617 |
TESTEQ(threads[i].Create(KNullDesC,IpcMultipleAliasesThread,KReadSize+0x1000,&User::Allocator(),chunk.Base()),KErrNone);
|
sl@0
|
618 |
threads[i].Logon(stats[i]);
|
sl@0
|
619 |
}
|
sl@0
|
620 |
test.Printf(_L("Resuming threads...\n"));
|
sl@0
|
621 |
for(i=0; i<KNumIpcThreads; i++)
|
sl@0
|
622 |
threads[i].Resume();
|
sl@0
|
623 |
|
sl@0
|
624 |
User::After(10*1000000);
|
sl@0
|
625 |
for(i=0; i<KNumIpcThreads; i++)
|
sl@0
|
626 |
{
|
sl@0
|
627 |
test(stats[i]==KRequestPending); // theads should still be running
|
sl@0
|
628 |
}
|
sl@0
|
629 |
|
sl@0
|
630 |
// close chunk whilst test threads are still doing IPC...
|
sl@0
|
631 |
test.Printf(_L("Closing chunk...\n"));
|
sl@0
|
632 |
chunk.Close();
|
sl@0
|
633 |
for(i=0; i<KNumIpcThreads; i++)
|
sl@0
|
634 |
{
|
sl@0
|
635 |
User::WaitForRequest(stats[i]);
|
sl@0
|
636 |
TInt r=stats[i].Int();
|
sl@0
|
637 |
test.Printf(_L("Thread %d result = %d\n"),i,r);
|
sl@0
|
638 |
test(r==KErrBadDescriptor);
|
sl@0
|
639 |
}
|
sl@0
|
640 |
|
sl@0
|
641 |
IpcServer.Close();
|
sl@0
|
642 |
User::Free(ptrMem);
|
sl@0
|
643 |
test.End();
|
sl@0
|
644 |
}
|
sl@0
|
645 |
|
sl@0
|
646 |
GLDEF_C TInt E32Main()
|
sl@0
|
647 |
{
|
sl@0
|
648 |
MainId=TUint32(RThread().Id());
|
sl@0
|
649 |
// RThread().SetPriority(EPriorityAbsoluteForeground);
|
sl@0
|
650 |
test.Title();
|
sl@0
|
651 |
test.Start(_L("Load LDD"));
|
sl@0
|
652 |
TInt r=User::LoadLogicalDevice(_L("D_IPCCPY"));
|
sl@0
|
653 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
654 |
test.Next(_L("Open channel"));
|
sl@0
|
655 |
r=Ipccpy.Open();
|
sl@0
|
656 |
test(r==KErrNone);
|
sl@0
|
657 |
test.Next(_L("Allocate heap buffer"));
|
sl@0
|
658 |
Buffer=(TUint8*)User::Alloc(4096);
|
sl@0
|
659 |
test(Buffer!=NULL);
|
sl@0
|
660 |
SetupAddresses();
|
sl@0
|
661 |
|
sl@0
|
662 |
BenchmarkTest();
|
sl@0
|
663 |
|
sl@0
|
664 |
TestIpcCopyErrors();
|
sl@0
|
665 |
TestIpcAsyncClose();
|
sl@0
|
666 |
TestIpcMultipleThreads();
|
sl@0
|
667 |
|
sl@0
|
668 |
FOREVER
|
sl@0
|
669 |
{
|
sl@0
|
670 |
TRequestStatus s;
|
sl@0
|
671 |
Mem::Fill(Buffer,272,0xcd);
|
sl@0
|
672 |
TPtr8 ptr(Buffer,0,272);
|
sl@0
|
673 |
Ipccpy.IpcCpy(s,ptr);
|
sl@0
|
674 |
User::WaitForRequest(s);
|
sl@0
|
675 |
TInt x=s.Int();
|
sl@0
|
676 |
if (x<0)
|
sl@0
|
677 |
{
|
sl@0
|
678 |
test.Printf(_L("Error %d\n"),x);
|
sl@0
|
679 |
test(0);
|
sl@0
|
680 |
}
|
sl@0
|
681 |
TInt src_offset=x&3;
|
sl@0
|
682 |
TInt dest_offset=(x>>2)&3;
|
sl@0
|
683 |
TInt length=(x>>4)+1;
|
sl@0
|
684 |
TInt err=-1;
|
sl@0
|
685 |
TInt i;
|
sl@0
|
686 |
for (i=0; i<dest_offset && err<0; ++i)
|
sl@0
|
687 |
{
|
sl@0
|
688 |
if (Buffer[i]!=0xcd)
|
sl@0
|
689 |
err=i;
|
sl@0
|
690 |
}
|
sl@0
|
691 |
TUint8 v=(TUint8)src_offset;
|
sl@0
|
692 |
for (i=0; i<length && err<0; ++i)
|
sl@0
|
693 |
{
|
sl@0
|
694 |
++v;
|
sl@0
|
695 |
if (Buffer[i+dest_offset]!=v)
|
sl@0
|
696 |
err=i+dest_offset;
|
sl@0
|
697 |
}
|
sl@0
|
698 |
for (i=dest_offset+length; i<272 && err<0; ++i)
|
sl@0
|
699 |
{
|
sl@0
|
700 |
if (Buffer[i]!=0xcd)
|
sl@0
|
701 |
err=i;
|
sl@0
|
702 |
}
|
sl@0
|
703 |
if (err>=0)
|
sl@0
|
704 |
{
|
sl@0
|
705 |
test.Printf(_L("Sequence number %03x\nSrcOffset %d, DestOffset %d, Length %d\n"),x,src_offset,dest_offset,length);
|
sl@0
|
706 |
test.Printf(_L("First error at %d"),err);
|
sl@0
|
707 |
for (i=0; i<272; i+=16)
|
sl@0
|
708 |
{
|
sl@0
|
709 |
TInt j;
|
sl@0
|
710 |
test.Printf(_L("%03x:"),i);
|
sl@0
|
711 |
for (j=0; j<16; ++j)
|
sl@0
|
712 |
{
|
sl@0
|
713 |
test.Printf(_L(" %02x"),Buffer[i+j]);
|
sl@0
|
714 |
}
|
sl@0
|
715 |
}
|
sl@0
|
716 |
test(0);
|
sl@0
|
717 |
}
|
sl@0
|
718 |
if (x==4095)
|
sl@0
|
719 |
break;
|
sl@0
|
720 |
}
|
sl@0
|
721 |
Ipccpy.Close();
|
sl@0
|
722 |
test.End();
|
sl@0
|
723 |
return KErrNone;
|
sl@0
|
724 |
}
|