|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // e32test\device\d_ldd2.cpp |
|
15 // Secondary LDD for testing linking one driver to another |
|
16 // |
|
17 // |
|
18 |
|
19 #include <kernel/kernel.h> |
|
20 #include "d_ldd2.h" |
|
21 |
|
22 TInt AFunction() |
|
23 { |
|
24 return KErrNone; |
|
25 } |
|
26 |
|
27 TInt data=0x100; |
|
28 TAny* dataptr=(TAny*)&AFunction; |
|
29 TInt TheBss; |
|
30 |
|
31 class TGlobal |
|
32 { |
|
33 public: |
|
34 TGlobal(); |
|
35 ~TGlobal(); |
|
36 void Update(TUint32 a); |
|
37 TInt Verify(); |
|
38 public: |
|
39 TUint32 iInt; |
|
40 TAny* iPtr; |
|
41 }; |
|
42 |
|
43 TGlobal Global; |
|
44 |
|
45 TGlobal::TGlobal() |
|
46 { |
|
47 __KTRACE_OPT(KDEVICE,Kern::Printf("TGlobal::TGlobal()")); |
|
48 iPtr = Kern::Alloc(65536); |
|
49 Update(487); |
|
50 } |
|
51 |
|
52 TGlobal::~TGlobal() |
|
53 { |
|
54 __KTRACE_OPT(KDEVICE,Kern::Printf("TGlobal::~TGlobal()")); |
|
55 Kern::Free(iPtr); |
|
56 } |
|
57 |
|
58 void TGlobal::Update(TUint32 a) |
|
59 { |
|
60 iInt = a; |
|
61 if (iPtr) |
|
62 { |
|
63 TUint32* p = (TUint32*)iPtr; |
|
64 TUint32* pE = p + 65536/4; |
|
65 while (p<pE) |
|
66 { |
|
67 a = (a*69069u)+41; |
|
68 *p++ = a; |
|
69 } |
|
70 } |
|
71 } |
|
72 |
|
73 TInt TGlobal::Verify() |
|
74 { |
|
75 TUint32 x = iInt; |
|
76 if (iPtr) |
|
77 { |
|
78 TUint32* p = (TUint32*)iPtr; |
|
79 TUint32* pE = p + 65536/4; |
|
80 while (p<pE) |
|
81 { |
|
82 x = (x*69069u)+41; |
|
83 if (*p++ != x) |
|
84 return KErrGeneral; |
|
85 } |
|
86 return KErrNone; |
|
87 } |
|
88 return KErrNoMemory; |
|
89 } |
|
90 |
|
91 EXPORT_C TInt LinkedTest1() |
|
92 { |
|
93 return (TInt)dataptr; |
|
94 } |
|
95 |
|
96 EXPORT_C TInt LinkedTest2() |
|
97 { |
|
98 return data++; |
|
99 } |
|
100 |
|
101 EXPORT_C TInt LinkedTest3() |
|
102 { |
|
103 return data--; |
|
104 } |
|
105 |
|
106 EXPORT_C TInt LinkedTest4() |
|
107 { |
|
108 return data; |
|
109 } |
|
110 |
|
111 EXPORT_C TInt LinkedTest5() |
|
112 { |
|
113 return TheBss; |
|
114 } |
|
115 |
|
116 EXPORT_C TInt LinkedTest6(TInt aValue) |
|
117 { |
|
118 TheBss = aValue; |
|
119 return KErrNone; |
|
120 } |
|
121 |
|
122 EXPORT_C TUint32 LinkedTest7() |
|
123 { |
|
124 return (TInt)Global.iInt; |
|
125 } |
|
126 |
|
127 EXPORT_C void LinkedTest8(TUint32 aValue) |
|
128 { |
|
129 Global.Update(aValue); |
|
130 } |
|
131 |
|
132 EXPORT_C TInt LinkedTest9() |
|
133 { |
|
134 return Global.Verify(); |
|
135 } |
|
136 |
|
137 DECLARE_STANDARD_LDD() |
|
138 { |
|
139 return NULL; |
|
140 } |