|
1 // Copyright (c) 2001-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 // Thread for executing benchmark test threads |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file bf_execute.cpp |
|
20 */ |
|
21 |
|
22 #include <e32std.h> |
|
23 #include <e32std_private.h> |
|
24 #include <e32svr.h> |
|
25 #include "bf_raw.h" |
|
26 |
|
27 GLREF_D TUint32 Count; |
|
28 GLREF_D TTestInfo TestInfo; ///< Data passed to exector thread |
|
29 |
|
30 GLREF_D TBusLocalDrive drive; |
|
31 GLREF_D TLocalDriveCapsV2Buf driveInfo; |
|
32 GLREF_D HBufC8* writeBuffer; |
|
33 GLREF_D HBufC8* readBuffer; |
|
34 |
|
35 GLREF_D TBool StopTest; |
|
36 |
|
37 GLREF_D TInt mainThreadHandle; |
|
38 |
|
39 _LIT( KPanicCat, "bf_raw" ); |
|
40 |
|
41 GLDEF_C TInt BmWrite(TAny*) |
|
42 /** |
|
43 * Performs writes continuously |
|
44 */ |
|
45 { |
|
46 TPtrC8 wd( writeBuffer->Des().Ptr(), TestInfo.iLength ); |
|
47 while( !StopTest ) |
|
48 { |
|
49 TInt r = drive.Write( TestInfo.iOffset, wd ); |
|
50 if( KErrNone != r ) |
|
51 { |
|
52 User::Panic( KPanicCat, r ); |
|
53 } |
|
54 ++Count; |
|
55 } |
|
56 return KErrNone; |
|
57 } |
|
58 |
|
59 |
|
60 GLDEF_C TInt BmWriteThread(TAny*) |
|
61 /** |
|
62 * Performs writes continuously, telling device driver that a thread |
|
63 * read is required |
|
64 */ |
|
65 { |
|
66 TAny* p = writeBuffer; |
|
67 while( !StopTest ) |
|
68 { |
|
69 TInt r = drive.Write( TestInfo.iOffset, TestInfo.iLength, p, mainThreadHandle, 0 ); |
|
70 if( KErrNone != r ) |
|
71 { |
|
72 User::Panic( KPanicCat, r ); |
|
73 } |
|
74 ++Count; |
|
75 } |
|
76 return KErrNone; |
|
77 } |
|
78 |
|
79 |
|
80 GLDEF_C TInt BmRead(TAny*) |
|
81 /** |
|
82 * Performs reads continously |
|
83 */ |
|
84 { |
|
85 TPtr8 rd = readBuffer->Des(); |
|
86 while( !StopTest ) |
|
87 { |
|
88 TInt r = drive.Read( TestInfo.iOffset, TestInfo.iLength, rd ); |
|
89 if( KErrNone != r ) |
|
90 { |
|
91 User::Panic( KPanicCat, r ); |
|
92 } |
|
93 ++Count; |
|
94 } |
|
95 return KErrNone; |
|
96 } |
|
97 |
|
98 GLDEF_C TInt BmReadThread(TAny*) |
|
99 /** |
|
100 * Performs reads continously, telling device driver that a thread |
|
101 * write is required |
|
102 */ |
|
103 { |
|
104 TPtr8 des = readBuffer->Des(); |
|
105 TAny* p = &des; |
|
106 while( !StopTest ) |
|
107 { |
|
108 TInt r = drive.Read( TestInfo.iOffset, TestInfo.iLength, p, mainThreadHandle, 0 ); |
|
109 if( KErrNone != r ) |
|
110 { |
|
111 User::Panic( KPanicCat, r ); |
|
112 } |
|
113 ++Count; |
|
114 } |
|
115 return KErrNone; |
|
116 } |