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_cp0.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <e32test.h>
|
sl@0
|
19 |
#include <cpudefs.h>
|
sl@0
|
20 |
#include "nk_cpu.h"
|
sl@0
|
21 |
#include "../misc/prbs.h"
|
sl@0
|
22 |
|
sl@0
|
23 |
RTest test(_L("T_CP0"));
|
sl@0
|
24 |
|
sl@0
|
25 |
extern void GetAcc0(TInt64&);
|
sl@0
|
26 |
extern void SetAcc0(const TInt64&);
|
sl@0
|
27 |
extern void InnerProduct(TInt64& /*aResult*/, const TInt16* /*aVec1*/, const TInt16* /*aVec2*/, TInt /*aLength*/);
|
sl@0
|
28 |
extern void InnerProduct2(TInt64& /*aResult*/, const TInt16* /*aVec1*/, const TInt16* /*aVec2*/, TInt /*aLength*/);
|
sl@0
|
29 |
|
sl@0
|
30 |
|
sl@0
|
31 |
TInt DoCP0Test(TAny* aPtr)
|
sl@0
|
32 |
{
|
sl@0
|
33 |
TUint seed[2];
|
sl@0
|
34 |
seed[0]=(TUint)aPtr;
|
sl@0
|
35 |
seed[1]=0;
|
sl@0
|
36 |
TInt16 vec1[128];
|
sl@0
|
37 |
TInt16 vec2[128];
|
sl@0
|
38 |
TInt run;
|
sl@0
|
39 |
for (run=0; run<100000; ++run)
|
sl@0
|
40 |
{
|
sl@0
|
41 |
TInt n=(Random(seed)&63)+64; // vector length
|
sl@0
|
42 |
TInt i;
|
sl@0
|
43 |
for (i=0; i<n; ++i)
|
sl@0
|
44 |
{
|
sl@0
|
45 |
vec1[i]=(TInt16)(Random(seed)&0xffff);
|
sl@0
|
46 |
vec2[i]=(TInt16)(Random(seed)&0xffff);
|
sl@0
|
47 |
TInt64 result, result2;
|
sl@0
|
48 |
InnerProduct(result,vec1,vec2,n);
|
sl@0
|
49 |
InnerProduct2(result2,vec1,vec2,n);
|
sl@0
|
50 |
if (result != result2)
|
sl@0
|
51 |
{
|
sl@0
|
52 |
User::Panic(_L("ERROR"),run);
|
sl@0
|
53 |
}
|
sl@0
|
54 |
}
|
sl@0
|
55 |
}
|
sl@0
|
56 |
return 0;
|
sl@0
|
57 |
}
|
sl@0
|
58 |
|
sl@0
|
59 |
void CheckExit(TInt aThreadNum, RThread aThread)
|
sl@0
|
60 |
{
|
sl@0
|
61 |
TInt exitType=aThread.ExitType();
|
sl@0
|
62 |
TInt exitReason=aThread.ExitReason();
|
sl@0
|
63 |
TBuf<32> exitCat=aThread.ExitCategory();
|
sl@0
|
64 |
test.Printf(_L("Thread %d: %d,%d,%S\n"),aThreadNum,exitType,exitReason,&exitCat);
|
sl@0
|
65 |
test(exitType==EExitKill);
|
sl@0
|
66 |
test(exitReason==KErrNone);
|
sl@0
|
67 |
}
|
sl@0
|
68 |
|
sl@0
|
69 |
TInt E32Main()
|
sl@0
|
70 |
{
|
sl@0
|
71 |
test.Title();
|
sl@0
|
72 |
test.Start(_L("Testing XScale DSP Coprocessor"));
|
sl@0
|
73 |
|
sl@0
|
74 |
TInt64 acc0;
|
sl@0
|
75 |
GetAcc0(acc0);
|
sl@0
|
76 |
test.Printf(_L("acc0=%lx\n"),acc0);
|
sl@0
|
77 |
|
sl@0
|
78 |
SetAcc0(0);
|
sl@0
|
79 |
GetAcc0(acc0);
|
sl@0
|
80 |
test.Printf(_L("acc0=%lx\n"),acc0);
|
sl@0
|
81 |
|
sl@0
|
82 |
test.Next(_L("Test CP0 in single thread"));
|
sl@0
|
83 |
DoCP0Test((TAny*)487);
|
sl@0
|
84 |
|
sl@0
|
85 |
test.Next(_L("Test CP0 in multiple threads"));
|
sl@0
|
86 |
RThread t1, t2;
|
sl@0
|
87 |
TRequestStatus s1, s2;
|
sl@0
|
88 |
TInt r=t1.Create(KNullDesC(),DoCP0Test,0x1000,NULL,(TAny*)0xddb3d743);
|
sl@0
|
89 |
test(r==KErrNone);
|
sl@0
|
90 |
r=t2.Create(KNullDesC(),DoCP0Test,0x1000,NULL,(TAny*)0xb504f334);
|
sl@0
|
91 |
test(r==KErrNone);
|
sl@0
|
92 |
t1.Logon(s1);
|
sl@0
|
93 |
t2.Logon(s2);
|
sl@0
|
94 |
t1.Resume();
|
sl@0
|
95 |
t2.Resume();
|
sl@0
|
96 |
User::WaitForRequest(s1);
|
sl@0
|
97 |
User::WaitForRequest(s2);
|
sl@0
|
98 |
CheckExit(1,t1);
|
sl@0
|
99 |
CheckExit(2,t2);
|
sl@0
|
100 |
CLOSE_AND_WAIT(t1);
|
sl@0
|
101 |
CLOSE_AND_WAIT(t2);
|
sl@0
|
102 |
|
sl@0
|
103 |
test.End();
|
sl@0
|
104 |
return 0;
|
sl@0
|
105 |
}
|
sl@0
|
106 |
|