|
1 /* |
|
2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: WlanDfc implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * %version: 5 % |
|
20 */ |
|
21 |
|
22 #include "osa_includeme.h" |
|
23 |
|
24 #include <wlandfcclient.h> |
|
25 |
|
26 #include "osadfc.h" |
|
27 #include "osa.h" |
|
28 |
|
29 // mask value to check is dfc cancel event occurred |
|
30 const TUint KDfcCancelledMask( 1 << 0 ); |
|
31 |
|
32 struct WlanDfcImpl : public DBase |
|
33 { |
|
34 |
|
35 /** |
|
36 * Ctor |
|
37 * |
|
38 * @since S60 v3.2 |
|
39 * @param aWlanDfc wlandfc object |
|
40 * @param aOsa wlanosa object |
|
41 * @param aDfcQueue Pointer to the DFC queue to use |
|
42 */ |
|
43 WlanDfcImpl( WlanDfc& aWlanDfc, WlanOsa& aOsa, TDfcQue* aDfcQueue ); |
|
44 |
|
45 /** |
|
46 * Dtor |
|
47 * |
|
48 * @since S60 v3.2 |
|
49 */ |
|
50 virtual ~WlanDfcImpl(); |
|
51 |
|
52 /** |
|
53 * OS dfc callback method |
|
54 * |
|
55 * @since S60 v3.2 |
|
56 * @param aPtr callback context |
|
57 */ |
|
58 static void DfcDoToggle( TAny* aPtr ); |
|
59 |
|
60 /** |
|
61 * osa object reference |
|
62 */ |
|
63 WlanOsa& iOsa; |
|
64 |
|
65 /** |
|
66 * dfc object |
|
67 */ |
|
68 TDfc iDfc; |
|
69 |
|
70 /** |
|
71 * dfc client callback interface |
|
72 * Not Own. |
|
73 */ |
|
74 MWlanDfcClient* iDfcClient; |
|
75 |
|
76 /** |
|
77 * callback context |
|
78 */ |
|
79 TInt iCtx; |
|
80 |
|
81 /** |
|
82 * internal state flags |
|
83 */ |
|
84 TUint iFlags; |
|
85 |
|
86 private: |
|
87 |
|
88 // Prohibit copy constructor. |
|
89 WlanDfcImpl( const WlanDfcImpl& ); |
|
90 // Prohibit assigment operator. |
|
91 WlanDfcImpl& operator= ( const WlanDfcImpl& ); |
|
92 |
|
93 }; |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 WlanDfcImpl::WlanDfcImpl( |
|
100 WlanDfc& aWlanDfc, |
|
101 WlanOsa& aOsa, |
|
102 TDfcQue* aDfcQueue ) |
|
103 : iOsa( aOsa ), iDfc( DfcDoToggle, &aWlanDfc, 0 ), |
|
104 iDfcClient( NULL ), iCtx( 0 ), iFlags( 0 ) |
|
105 { |
|
106 TraceDump(INFO_LEVEL | DFC_LEVEL, |
|
107 (("[WLAN] WlanDfcImpl ctor: + this 0x%08x"), this)); |
|
108 |
|
109 MWlanOsa::Assert( |
|
110 reinterpret_cast<const TInt8*>(WLAN_FILE), __LINE__, |
|
111 aDfcQueue != NULL ); |
|
112 |
|
113 iDfc.SetDfcQ( aDfcQueue ); |
|
114 |
|
115 TraceDump(INFO_LEVEL | DFC_LEVEL, |
|
116 (("[WLAN] WlanDfcImpl ctor: - this 0x%08x"), this)); |
|
117 }; |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 WlanDfcImpl::~WlanDfcImpl() |
|
124 { |
|
125 TraceDump(INFO_LEVEL | DFC_LEVEL, |
|
126 (("[WLAN] WlanDfcImpl dtor: + this 0x%08x"), this)); |
|
127 |
|
128 iDfc.Cancel(); |
|
129 |
|
130 TraceDump(INFO_LEVEL | DFC_LEVEL, |
|
131 (("[WLAN] WlanDfcImpl dtor: - this 0x%08x"), this)); |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 void WlanDfcImpl::DfcDoToggle( TAny* aPtr ) |
|
139 { |
|
140 TraceDump(INFO_LEVEL | DFC_LEVEL, |
|
141 (("[WLAN] WlanDfcImpl::DfcDoToggle: + addr: 0x%08x"), aPtr)); |
|
142 |
|
143 WlanDfc* ptr( static_cast<WlanDfc*>(aPtr) ); |
|
144 ptr->RealDfc(); |
|
145 |
|
146 TraceDump(INFO_LEVEL | DFC_LEVEL, |
|
147 (("[WLAN] WlanDfcImpl::DfcDoToggle: - addr: 0x%08x"), aPtr)); |
|
148 } |
|
149 |
|
150 |
|
151 // ======== MEMBER FUNCTIONS ======== |
|
152 |
|
153 |
|
154 // --------------------------------------------------------------------------- |
|
155 // |
|
156 // --------------------------------------------------------------------------- |
|
157 // |
|
158 WlanDfc::~WlanDfc() |
|
159 { |
|
160 TraceDump(INFO_LEVEL | DFC_LEVEL, |
|
161 (("[WLAN] WlanDfc dtor + addr: 0x%08x"), this)); |
|
162 |
|
163 if ( IsValid() ) |
|
164 { |
|
165 delete iPimpl; |
|
166 } |
|
167 else |
|
168 { |
|
169 // left intentionally empty |
|
170 } |
|
171 |
|
172 TraceDump(INFO_LEVEL | DFC_LEVEL, |
|
173 (("[WLAN] WlanDfc dtor - addr: 0x%08x"), this)); |
|
174 } |
|
175 |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 // --------------------------------------------------------------------------- |
|
179 // |
|
180 WlanDfc::WlanDfc( |
|
181 WlanOsa& aOsa, |
|
182 void* aDfcQueue ) : iPimpl( NULL ) |
|
183 { |
|
184 TraceDump(INFO_LEVEL | DFC_LEVEL, |
|
185 (("[WLAN] WlanDfc ctor + addr: 0x%08x"), this)); |
|
186 |
|
187 iPimpl = new WlanDfcImpl( |
|
188 *this, |
|
189 aOsa, |
|
190 reinterpret_cast<TDfcQue*>(aDfcQueue) ); |
|
191 |
|
192 if ( iPimpl ) |
|
193 { |
|
194 // allocation success -> proceed |
|
195 Validate(); |
|
196 } |
|
197 else |
|
198 { |
|
199 // allocation failed invalidate object |
|
200 TraceDump(ERROR_LEVEL, ("[WLAN] error: allocation")); |
|
201 Trace( ERROR_LEVEL, |
|
202 reinterpret_cast<const TInt8*>(WLAN_FILE), __LINE__ ); |
|
203 |
|
204 InValidate(); |
|
205 } |
|
206 |
|
207 TraceDump(INFO_LEVEL | DFC_LEVEL, |
|
208 (("[WLAN] WlanDfc ctor - addr: 0x%08x"), this)); |
|
209 } |
|
210 |
|
211 // --------------------------------------------------------------------------- |
|
212 // |
|
213 // --------------------------------------------------------------------------- |
|
214 // |
|
215 void WlanDfc::RealDfc() |
|
216 { |
|
217 TraceDump(INFO_LEVEL | DFC_LEVEL, |
|
218 (("[WLAN] WlanDfc::RealDfc: + addr: 0x%08x"), this)); |
|
219 |
|
220 // acquire system lock |
|
221 Pimpl().iOsa.MutexAcquire(); |
|
222 |
|
223 if ( !(Pimpl().iFlags & KDfcCancelledMask) ) |
|
224 { |
|
225 // DFC has NOT been cancelled |
|
226 Pimpl().iDfcClient->OnDfc( Pimpl().iCtx ); |
|
227 } |
|
228 else |
|
229 { |
|
230 TraceDump(DFC_LEVEL, |
|
231 (("[WLAN] WlanDfc::RealDfc: DFC cancelled -> skip client call"))); |
|
232 // left intentionally empty |
|
233 } |
|
234 |
|
235 // release system lock |
|
236 Pimpl().iOsa.MutexRelease(); |
|
237 |
|
238 TraceDump(INFO_LEVEL | DFC_LEVEL, |
|
239 (("[WLAN] WlanDfc::RealDfc: - addr: 0x%08x"), this)); |
|
240 } |
|
241 |
|
242 // --------------------------------------------------------------------------- |
|
243 // From class MWlanDfc. |
|
244 // |
|
245 // --------------------------------------------------------------------------- |
|
246 // |
|
247 void WlanDfc::Enqueue( MWlanDfcClient& aDfcClient, TInt aCtx ) |
|
248 { |
|
249 TraceDump(INFO_LEVEL | DFC_LEVEL, |
|
250 (("[WLAN] WlanDfc::Enqueue: + addr: 0x%08x"), this)); |
|
251 |
|
252 Pimpl().iFlags &= ~KDfcCancelledMask; |
|
253 Pimpl().iDfcClient = &aDfcClient; |
|
254 Pimpl().iCtx = aCtx; |
|
255 |
|
256 if ( NKern::CurrentContext() == NKern::EInterrupt ) |
|
257 { |
|
258 TraceDump(DFC_LEVEL, |
|
259 ("[WLAN] WlanDfc::Enqueue: in ISR context")); |
|
260 Pimpl().iDfc.Add(); |
|
261 } |
|
262 else |
|
263 { |
|
264 TraceDump(DFC_LEVEL, |
|
265 ("[WLAN] WlanDfc::Enqueue: in other than ISR context")); |
|
266 Pimpl().iDfc.Enque(); |
|
267 } |
|
268 |
|
269 TraceDump(INFO_LEVEL | DFC_LEVEL, |
|
270 (("[WLAN] WlanDfc::Enqueue: - addr: 0x%08x"), this)); |
|
271 } |
|
272 |
|
273 // --------------------------------------------------------------------------- |
|
274 // From class MWlanDfc. |
|
275 // |
|
276 // --------------------------------------------------------------------------- |
|
277 // |
|
278 void WlanDfc::Dequeue() |
|
279 { |
|
280 TraceDump(INFO_LEVEL | DFC_LEVEL, |
|
281 (("[WLAN] WlanDfc::Dequeue: + addr: 0x%08x"), this)); |
|
282 |
|
283 Pimpl().iFlags |= KDfcCancelledMask; |
|
284 Pimpl().iDfc.Cancel(); |
|
285 |
|
286 TraceDump(INFO_LEVEL | DFC_LEVEL, |
|
287 (("[WLAN] WlanDfc::Dequeue: - addr: 0x%08x"), this)); |
|
288 } |
|
289 |
|
290 |
|
291 |