wlan_bearer/wlanldd/wlan_symbian/wlanldd_symbian/inc/RWlanLogicalChannel.inl
changeset 0 c40eb8fe8501
child 10 0abc8c98be24
equal deleted inserted replaced
-1:000000000000 0:c40eb8fe8501
       
     1 /*
       
     2 * Copyright (c) 2002-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:   Implementation of RWlanLogicalChannel inline methods.
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: 16 %
       
    20 */
       
    21 
       
    22 // -----------------------------------------------------------------------------
       
    23 // 
       
    24 // -----------------------------------------------------------------------------
       
    25 //
       
    26 inline TVersion RWlanLogicalChannel::VersionRequired() const
       
    27    {
       
    28 	return TVersion( 
       
    29         KWlanDriverMajorVersion, 
       
    30         KWlanDriverMinorVersion, 
       
    31         KWlanDriverBuildVersion );
       
    32    }
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // 
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 inline TInt RWlanLogicalChannel::Open( 
       
    39     TWlanUnit aUnit, 
       
    40     TOpenParam& aOpenParam )
       
    41     {
       
    42     iWlanSystemInitialized = EFalse;
       
    43     
       
    44 	TInt err = DoCreate(
       
    45         LDD_NAME, 
       
    46         VersionRequired(), 
       
    47         aUnit, 
       
    48         NULL, 
       
    49         NULL,
       
    50         EOwnerProcess);
       
    51 
       
    52     if ( err == KErrNone )
       
    53         {
       
    54         // driver load sequence success
       
    55         // do system init
       
    56         err = InitWlanSystem( aOpenParam  );
       
    57         
       
    58         if ( err == KErrNone )
       
    59             {
       
    60             // WLAN system successfully initialized
       
    61             iWlanSystemInitialized = ETrue;
       
    62             }
       
    63         }
       
    64 
       
    65     return err;
       
    66     }
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // 
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 inline void RWlanLogicalChannel::CloseChannel()
       
    73     {
       
    74     // release WLAN system resources only if we have been able to do the 
       
    75     // initialization successfully.
       
    76     // This check is done to prevent a release attempt in a case where the 
       
    77     // device driver framework has not been properly initialized to be able to 
       
    78     // handle requests
       
    79     if ( iWlanSystemInitialized )
       
    80         {
       
    81         TRequestStatus status;
       
    82         DoRequest( EWlanFinitSystem, status );
       
    83         User::WaitForRequest(status);
       
    84 
       
    85         // not initialized any more. This is needed to handle the case
       
    86         // that this method is called multiple times
       
    87         iWlanSystemInitialized = EFalse;
       
    88         }
       
    89     // internally call close
       
    90     Close();
       
    91     }
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // 
       
    95 // -----------------------------------------------------------------------------
       
    96 //
       
    97 inline TInt RWlanLogicalChannel::InitWlanSystem( 
       
    98     TOpenParam& aOpenParam )
       
    99     {
       
   100     TRequestStatus status;
       
   101     DoRequest( EWlanInitSystem, status, &aOpenParam );
       
   102     User::WaitForRequest(status);
       
   103     return status.Int();
       
   104     }
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // 
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 inline TInt RWlanLogicalChannel::ManagementCommand(
       
   111     const TDesC8& aInBuffer, 
       
   112     TDes8* aOutBuffer, 
       
   113     TRequestStatus* aStatus)
       
   114     {
       
   115     TInt ret( KErrNoMemory );
       
   116     SOidMsgStorage* pdu( new SOidMsgStorage );
       
   117     
       
   118     if ( pdu )
       
   119         {
       
   120         TUint32 input_param_len( aInBuffer.Length() );
       
   121         os_memcpy( pdu, aInBuffer.Ptr(), input_param_len );
       
   122 
       
   123         SOutputBuffer output = { NULL, 0 };
       
   124         if ( aOutBuffer )
       
   125             {
       
   126             output.iData = const_cast<TUint8*>(aOutBuffer->Ptr());
       
   127             output.iLen = aOutBuffer->Length();
       
   128             }
       
   129 
       
   130         if (aStatus == NULL)
       
   131             {
       
   132             // Execute command synchronously
       
   133             TRequestStatus status;
       
   134             
       
   135             DoRequest( 
       
   136                 EWlanCommand, 
       
   137                 status, 
       
   138                 pdu, 
       
   139                 (output.iData ? &output : NULL) );
       
   140             
       
   141 	        User::WaitForRequest(status);
       
   142         
       
   143             ret = status.Int();
       
   144             }
       
   145         else
       
   146             {
       
   147             // Execute command asynchronously
       
   148             
       
   149             iAsyncOidCommandMsg = *pdu;
       
   150             iAsyncOidCommandOutput = output;
       
   151             DoRequest(
       
   152                 EWlanCommand, 
       
   153                 *aStatus, 
       
   154                 &iAsyncOidCommandMsg, 
       
   155                 (output.iData ? &iAsyncOidCommandOutput : NULL) );
       
   156 
       
   157             ret = KErrNone;
       
   158             }
       
   159 
       
   160         // always remember to deallocate
       
   161         delete pdu;
       
   162         }
       
   163 
       
   164     return ret;
       
   165     }
       
   166 
       
   167 // -----------------------------------------------------------------------------
       
   168 // 
       
   169 // -----------------------------------------------------------------------------
       
   170 //
       
   171 inline void RWlanLogicalChannel::RequestSignal(
       
   172     TRequestStatus &aStatus,  
       
   173     TIndication &aBuffer)
       
   174     {
       
   175 	DoRequest(EWlanRequestNotify, aStatus, &aBuffer);
       
   176     }
       
   177 
       
   178 // -----------------------------------------------------------------------------
       
   179 // 
       
   180 // -----------------------------------------------------------------------------
       
   181 //
       
   182 inline void RWlanLogicalChannel::CancelRequestSignal()
       
   183     {
       
   184     // DoCancel uses mask instead of real values.
       
   185     DoCancel(1<<EWlanRequestNotify);
       
   186     }
       
   187 
       
   188 // -----------------------------------------------------------------------------
       
   189 // 
       
   190 // -----------------------------------------------------------------------------
       
   191 //
       
   192 inline void RWlanLogicalChannel::CancelRxRequests()
       
   193     {
       
   194     // DoCancel uses mask instead of real values.
       
   195 	DoCancel(1<<EWlanRequestFrame);
       
   196     }
       
   197 
       
   198 // -----------------------------------------------------------------------------
       
   199 // 
       
   200 // -----------------------------------------------------------------------------
       
   201 //
       
   202 inline TInt RWlanLogicalChannel::InitialiseBuffers( 
       
   203     RFrameXferBlock*& aFrameXferBlock )
       
   204     {
       
   205     TInt status ( KErrNone );
       
   206     
       
   207     TSharedChunkInfo info;
       
   208     
       
   209     status = DoSvControl( EWlanSvControlInitBuffers, 
       
   210         static_cast<TAny*>(&info) );
       
   211 
       
   212     if ( status == KErrNone )
       
   213         {
       
   214         // shared memory chunk initialization success
       
   215 
       
   216         // Set the handle for the shared memory chunk
       
   217         iSharedMemoryChunk.SetHandle( info.iChunkHandle );
       
   218 
       
   219         // Set the relevant user mode 
       
   220         // addresses as offsets from the chunk base address
       
   221 
       
   222         TUint8* baseAddress ( iSharedMemoryChunk.Base() );
       
   223         
       
   224         const TUint KRxDataChunkSize( 
       
   225             info.iSize
       
   226             - ( sizeof( TDataBuffer )
       
   227                 + KMgmtSideTxBufferLength
       
   228                 + KProtocolStackSideTxDataChunkSize
       
   229                 + sizeof( RFrameXferBlock ) 
       
   230                 + sizeof( RFrameXferBlockProtocolStack ) ) );
       
   231 
       
   232         aFrameXferBlock = reinterpret_cast<RFrameXferBlock*>(
       
   233             baseAddress
       
   234             + KRxDataChunkSize
       
   235             + sizeof( TDataBuffer )
       
   236             + KMgmtSideTxBufferLength
       
   237             + KProtocolStackSideTxDataChunkSize );
       
   238 
       
   239         aFrameXferBlock->SetRxDataChunkField( reinterpret_cast<TLinAddr>(
       
   240             baseAddress) );
       
   241 
       
   242         aFrameXferBlock->SetTxDataBufferField( reinterpret_cast<TLinAddr>(
       
   243             baseAddress
       
   244             + KRxDataChunkSize ) );
       
   245         }
       
   246     
       
   247     return status;
       
   248     }
       
   249 
       
   250 // -----------------------------------------------------------------------------
       
   251 // 
       
   252 // -----------------------------------------------------------------------------
       
   253 //
       
   254 inline TInt RWlanLogicalChannel::ReleaseBuffers()
       
   255     {
       
   256     // close the handle to the shared memory chunk
       
   257     iSharedMemoryChunk.Close();
       
   258     
       
   259     return DoSvControl( EWlanSvControlFreeBuffers );
       
   260     }
       
   261 
       
   262 // -----------------------------------------------------------------------------
       
   263 // 
       
   264 // -----------------------------------------------------------------------------
       
   265 //
       
   266 inline void RWlanLogicalChannel::WriteFrame( 
       
   267     TRequestStatus &aStatus )
       
   268     {
       
   269     DoRequest( EWlanRequestSend, aStatus );
       
   270     }
       
   271 
       
   272 // -----------------------------------------------------------------------------
       
   273 // 
       
   274 // -----------------------------------------------------------------------------
       
   275 //
       
   276 inline void RWlanLogicalChannel::RequestFrame( 
       
   277     TRequestStatus &aStatus )
       
   278     {
       
   279     DoRequest( EWlanRequestFrame, aStatus );
       
   280     }