|
1 /* |
|
2 * Copyright (c) 2007 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 "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: Implementation of DIscDataTransmissionBase class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <IscDevice.h> |
|
22 #include "IscTrace.h" |
|
23 #include "IscDataTransmissionBase.h" |
|
24 #include "IscBufferAllocator.h" |
|
25 |
|
26 #ifdef __WINS__ |
|
27 #include <windows.h> |
|
28 #endif |
|
29 |
|
30 // EXTERNAL DATA STRUCTURES |
|
31 |
|
32 // EXTERNAL FUNCTION PROTOTYPES |
|
33 |
|
34 // CONSTANTS |
|
35 |
|
36 // MACROS |
|
37 |
|
38 // LOCAL CONSTANTS AND MACROS |
|
39 |
|
40 // MODULE DATA STRUCTURES |
|
41 |
|
42 // LOCAL FUNCTION PROTOTYPES |
|
43 |
|
44 // FORWARD DECLARATIONS |
|
45 #ifdef __WINS__ |
|
46 CRITICAL_SECTION g_IscDTBCriticalSection; |
|
47 #endif |
|
48 |
|
49 // ============================ MEMBER FUNCTIONS =============================== |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // DIscDataTransmissionBase::DIscDataTransmissionBase |
|
53 // C++ default constructor |
|
54 // ( other items were commented in a header ). |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 EXPORT_C DIscDataTransmissionBase::DIscDataTransmissionBase() |
|
58 :iDevice( NULL ), |
|
59 iIscBufferAllocator( NULL ) |
|
60 { |
|
61 A_TRACE( ( _T( "DIscDataTransmissionBase::DIscDataTransmissionBase()" ) ) ); |
|
62 #ifdef __WINS__ |
|
63 InitializeCriticalSection( &g_IscDTBCriticalSection ); |
|
64 #endif |
|
65 } |
|
66 |
|
67 |
|
68 // Destructor |
|
69 EXPORT_C DIscDataTransmissionBase::~DIscDataTransmissionBase() |
|
70 { |
|
71 A_TRACE( ( _T( "DIscDataTransmissionBase::~DIscDataTransmissionBase()" ) ) ); |
|
72 if ( iIscBufferAllocator ) |
|
73 { |
|
74 delete iIscBufferAllocator; |
|
75 iIscBufferAllocator=NULL; |
|
76 } |
|
77 #ifdef __WINS__ |
|
78 DeleteCriticalSection( &g_IscDTBCriticalSection ); |
|
79 #endif |
|
80 A_TRACE( ( _T( "DIscDataTransmissionBase::~DIscDataTransmissionBase - return void" ) ) ); |
|
81 } |
|
82 |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // DIscDataTransmissionBase::AllocBuffers |
|
86 // buffer allocations according to the ISC Multiplexer |
|
87 // ( other items were commented in a header ). |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 EXPORT_C void DIscDataTransmissionBase::AllocBuffers( TIscBufferEntry* aBufferConfig ) |
|
91 { |
|
92 A_TRACE( ( _T( "DIscDataTransmissionBase::AllocBuffers(0x%x)" ), aBufferConfig ) ); |
|
93 // Allocate buffers |
|
94 if ( !iIscBufferAllocator ) |
|
95 { |
|
96 iIscBufferAllocator = new DIscBufferAllocator( aBufferConfig ); |
|
97 ASSERT_RESET_ALWAYS( iIscBufferAllocator, "ISCDataTransmissionBase",EIscMemoryAllocationFailure ); |
|
98 iIscBufferAllocator->AllocBuffers(); |
|
99 } |
|
100 A_TRACE( ( _T( "DIscDataTransmissionBase::AllocBuffers - return void" ) ) ); |
|
101 } |
|
102 // ----------------------------------------------------------------------------- |
|
103 // DIscDataTransmissionBase::ReceiveFrame |
|
104 // Transfer incoming frame to ISC Driver |
|
105 // ( other items were commented in a header ). |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 EXPORT_C void DIscDataTransmissionBase::ReceiveFrame( |
|
109 TDesC8& aFrame ) |
|
110 { |
|
111 |
|
112 if ( iDevice ) |
|
113 { |
|
114 iDevice->Receive( &aFrame ); |
|
115 } |
|
116 else |
|
117 { |
|
118 TRACE_ASSERT_ALWAYS; |
|
119 } |
|
120 |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // DIscDataTransmissionBase::NotifyConnectionStatus |
|
125 // Notifies any connection status changes to ISC Driver |
|
126 // ( other items were commented in a header ). |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 EXPORT_C void DIscDataTransmissionBase::NotifyConnectionStatus( |
|
130 TInt aStatus ) |
|
131 { |
|
132 A_TRACE( ( _T( "DIscDataTransmissionBase::NotifyConnectionStatus(0x%x)" ), aStatus ) ); |
|
133 |
|
134 if ( iDevice ) |
|
135 { |
|
136 iDevice->NotifyConnectionStatus( aStatus ); |
|
137 } |
|
138 |
|
139 A_TRACE( ( _T( "DIscDataTransmissionBase::NotifyConnectionStatus - return void" ) ) ); |
|
140 } |
|
141 |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // DIscDataTransmissionBase::ReserveMemoryBlock |
|
145 // Reserve memory block |
|
146 // ( other items were commented in a header ). |
|
147 // ----------------------------------------------------------------------------- |
|
148 // |
|
149 EXPORT_C void DIscDataTransmissionBase::ReserveMemoryBlock( |
|
150 TDes8*& aPtr, |
|
151 TUint16 aSize ) |
|
152 { |
|
153 E_TRACE( ( _T( "IDTB:Res(0x%x)" ), aSize ) ); |
|
154 |
|
155 iIscBufferAllocator->ReserveMemoryBlock( aPtr, aSize ); |
|
156 } |
|
157 |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // DIscDataTransmissionBase::ReleaseMemoryBlock |
|
161 // Release the reserved memory block |
|
162 // ( other items were commented in a header ). |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 EXPORT_C void DIscDataTransmissionBase::ReleaseMemoryBlock( |
|
166 TDes8* aPtr ) |
|
167 { |
|
168 |
|
169 E_TRACE( ( _T( "IDTB:Rel (0x%x)" ), aPtr ) ); |
|
170 iIscBufferAllocator->ReleaseMemoryBlock( aPtr ); |
|
171 |
|
172 } |
|
173 |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // DIscDataTransmissionBase::Connect |
|
177 // Connects ISC Driver to ISC Data Transmission Driver |
|
178 // ( other items were commented in a header ). |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 EXPORT_C void DIscDataTransmissionBase::Connect( |
|
182 DIscDevice* aDevice ) |
|
183 { |
|
184 A_TRACE( ( _T( "DIscDataTransmissionBase::Connect(0x%x)" ), aDevice ) ); |
|
185 ASSERT_RESET_ALWAYS( aDevice, "ISCDataTransmissionBase", EIscNullIscDriverPointer ); |
|
186 iDevice = aDevice; |
|
187 A_TRACE( ( _T( "DIscDataTransmissionBase::Connect - return void" ) ) ); |
|
188 } |
|
189 |
|
190 |
|
191 // ----------------------------------------------------------------------------- |
|
192 // DIscDataTransmissionBase::Install |
|
193 // Implementation of pure-virtual Install from DLogicalDevice |
|
194 // ( other items were commented in a header ). |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 EXPORT_C TInt DIscDataTransmissionBase::Install() |
|
198 { |
|
199 A_TRACE( ( _T( "DIscDataTransmissionBase::Install()" ) ) ); |
|
200 SetName( &KIscDataTransmissionDriverName ); |
|
201 |
|
202 // call second phase install ( located in the driver realizing this API ) |
|
203 TInt r = Install2ndPhase(); |
|
204 |
|
205 A_TRACE( ( _T( "DIscDataTransmissionBase::Install - return 0x%x" ), r ) ); |
|
206 return r; |
|
207 } |
|
208 |
|
209 #if defined( __WINSCW__ ) |
|
210 DECLARE_STANDARD_LDD() |
|
211 { |
|
212 return NULL; |
|
213 } |
|
214 #endif |
|
215 |
|
216 // End of File |