0
|
1 |
/*
|
|
2 |
* Copyright (c) 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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
#include "isiif.h" // For RISIIf
|
|
21 |
#include "isiiftrace.h" // For C_TRACE, ASSERT_RESET.. and fault codes
|
|
22 |
#include "isiinternaldefs.h" //
|
|
23 |
|
|
24 |
const TInt KConnectArraySize( 2 );
|
|
25 |
const TInt KSendArraySize( 1 );
|
|
26 |
const TInt KReceiveArraySize( 3 );
|
|
27 |
const TInt KFirstParam( 0 );
|
|
28 |
const TInt KSecondParam( 1 );
|
|
29 |
const TInt KThirdParam( 1 );
|
|
30 |
|
|
31 |
// We need binary type suffix because LDD FW loads .ldd suffix as assumption.
|
|
32 |
_LIT( KISIDriverLddBinaryName, "isirouter.dll" );
|
|
33 |
|
|
34 |
enum TISIApiFaults
|
|
35 |
{
|
|
36 |
EISIApiDriverLoadFailed = 0x00,
|
|
37 |
};
|
|
38 |
|
|
39 |
EXPORT_C MISIIf* MISIIf::NewISIIf( const TInt32 aUID, TUint8& aObjId )
|
|
40 |
{
|
|
41 |
C_TRACE( ( _T( "RISIIf::RISIIf <->" ) ) );
|
|
42 |
return RISIIf::NewF( aUID, aObjId );
|
|
43 |
}
|
|
44 |
|
|
45 |
RISIIf* RISIIf::NewF( const TInt32 aUID, TUint8& aObjId )
|
|
46 |
{
|
|
47 |
C_TRACE((_T("RISIIf::NewF>") ));
|
|
48 |
RISIIf* tmp = new RISIIf( aUID, aObjId );
|
|
49 |
ASSERT_PANIC_ALWAYS( tmp, ( EISIMemAllocFailure ) );
|
|
50 |
C_TRACE((_T("RISIIf::NewF 0x%x<"), tmp ));
|
|
51 |
return tmp;
|
|
52 |
}
|
|
53 |
|
|
54 |
RISIIf::RISIIf( const TInt32 aUID, TUint8& aObjId )
|
|
55 |
{
|
|
56 |
C_TRACE( ( _T( "RISIIf::RISIIf 0x%x>" ), this ) );
|
|
57 |
// Same driver is used for all ISI user clients, it might be already loaded (KErrAlreadyExists), that is ok.
|
|
58 |
TInt loadStatus( User::LoadLogicalDevice( KISIDriverLddBinaryName ) );
|
|
59 |
C_TRACE( ( _T( "RISIIf::Connect devicedriver loaded %d" ), loadStatus ) );
|
|
60 |
ASSERT_PANIC_ALWAYS( ( KErrNone == loadStatus || KErrAlreadyExists == loadStatus), EISIApiDriverLoadFailed );
|
|
61 |
TInt error( KErrInUse );
|
|
62 |
// KErrPermissionDenied( no capabilities), KErrGeneral (DThread::Open)
|
|
63 |
error = DoCreate( KISIDriverName,
|
|
64 |
TVersion(),
|
|
65 |
KNullUnit,
|
|
66 |
NULL,
|
|
67 |
NULL,
|
|
68 |
EOwnerThread );
|
|
69 |
if( KErrNone != error )
|
|
70 |
{
|
|
71 |
C_TRACE( ( _T( "RISIIf::Connect 0x%x error %d" ), this, error ) );
|
|
72 |
}
|
|
73 |
else
|
|
74 |
{
|
|
75 |
C_TRACE( ( _T( "RISIIf::Connect 0x%x " ), this ) );
|
|
76 |
TAny* params[ KConnectArraySize ];
|
|
77 |
params[ KFirstParam ] = reinterpret_cast< TAny* >( aUID );
|
|
78 |
params[ KSecondParam ] = reinterpret_cast< TAny* >( &aObjId );
|
|
79 |
error = DoControl( EISIConnect, params );
|
|
80 |
C_TRACE( ( _T( "RISIIf::id is 0x%x " ), aObjId ) );
|
|
81 |
TRACE_ASSERT_ALWAYS_COND( KErrNone == error );
|
|
82 |
}
|
|
83 |
C_TRACE( ( _T( "RISIIf::RISIIf 0x%x<" ), this ) );
|
|
84 |
}
|
|
85 |
|
|
86 |
RISIIf::~RISIIf()
|
|
87 |
{
|
|
88 |
C_TRACE( ( _T( "RISIIf::~RISIIf 0x%x>" ), this ) );
|
|
89 |
RHandleBase::Close();
|
|
90 |
C_TRACE( ( _T( "RISIIf::~RISIIf 0x%x<" ), this ) );
|
|
91 |
}
|
|
92 |
|
|
93 |
void RISIIf::Receive( TRequestStatus& aRxStatus, TDes8& aRxMsg, TUint16& aNeededBufLen )
|
|
94 |
{
|
|
95 |
C_TRACE( ( _T( "RISIIf::Receive 0x%x s %d b 0x%x>" ), this , &aRxStatus, &aRxMsg ) );
|
|
96 |
TAny* params[ KReceiveArraySize ];
|
|
97 |
// Set status pending, just in case client haven't done it.
|
|
98 |
aRxStatus = KRequestPending;
|
|
99 |
params[ KFirstParam ] = reinterpret_cast<TAny*>( &aRxStatus );
|
|
100 |
params[ KSecondParam ] = reinterpret_cast<TAny*>( &aRxMsg );
|
|
101 |
params[ KThirdParam ] = reinterpret_cast<TAny*>( &aNeededBufLen );
|
|
102 |
DoControl( EISIAsyncReceive, params );
|
|
103 |
C_TRACE( ( _T( "RISIIf::Receive 0x%x s %d b 0x%x<" ), this , &aRxStatus, &aRxMsg ) );
|
|
104 |
}
|
|
105 |
|
|
106 |
void RISIIf::ReceiveCancel()
|
|
107 |
{
|
|
108 |
C_TRACE( ( _T( "RISIIf::ReceiveCancel 0x%x>" ), this ) );
|
|
109 |
DoCancel( EISIAsyncReceive );
|
|
110 |
C_TRACE( ( _T( "RISIIf::ReceiveCancel 0x%x<" ), this ) );
|
|
111 |
}
|
|
112 |
|
|
113 |
void RISIIf::Release()
|
|
114 |
{
|
|
115 |
C_TRACE( ( _T( "RISIIf::Release 0x%x>" ), this ) );
|
|
116 |
delete this;
|
|
117 |
C_TRACE( ( _T( "RISIIf::Release 0x%x<" ), this ) );
|
|
118 |
}
|
|
119 |
|
|
120 |
TInt RISIIf::Send( const TDesC8& aTxMsg )
|
|
121 |
{
|
|
122 |
C_TRACE( ( _T( "RISIIf::Send 0x%x m 0x%x>" ), this, &aTxMsg ) );
|
|
123 |
TAny* params[ KSendArraySize ];
|
|
124 |
params[ KFirstParam ] = reinterpret_cast<TAny*>( const_cast<TDesC8*>( &aTxMsg ));
|
|
125 |
TInt sendResult = DoControl( EISISend, params );
|
|
126 |
C_TRACE( ( _T( "RISIIf::Send 0x%x 0x%x %d <" ), this, &aTxMsg, sendResult ) );
|
|
127 |
return sendResult;
|
|
128 |
}
|
|
129 |
|
|
130 |
// End of File
|