os/boardsupport/haitest/bspsvs/suite/bsp/uart/src/T_SerialDriverServer.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2005-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 "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 #include "T_SerialDriverServer.h"
    19 #include "T_RBusDevCommData.h"
    20 #include "T_TCommCapsV03Data.h"
    21 #include "T_TCommConfigV02Data.h"
    22 
    23 /*@{*/
    24 _LIT(KT_RBusDevComm,		"RBusDevComm");
    25 _LIT(KT_TCommCapsV01,		"TCommCapsV01");
    26 _LIT(KT_TCommCapsV02,		"TCommCapsV02");
    27 _LIT(KT_TCommCapsV03,		"TCommCapsV03");
    28 _LIT(KT_TCommConfigV01,		"TCommConfigV01");
    29 _LIT(KT_TCommConfigV02,		"TCommConfigV02");
    30 /*@}*/
    31 
    32 CT_SerialDriverServer* CT_SerialDriverServer::NewL()
    33 /**
    34  * @return - Instance of the test server
    35  * Same code for Secure and non-secure variants
    36  * Called inside the MainL() function to create and start the
    37  * CTestServer derived server.
    38  */
    39 	{
    40     CT_SerialDriverServer* server = new (ELeave) CT_SerialDriverServer();
    41     CleanupStack::PushL(server);
    42     server->ConstructL();
    43     CleanupStack::Pop(server);
    44     return server;
    45     }
    46 
    47 
    48 LOCAL_C void MainL()
    49 /**
    50  * Secure variant
    51  * Much simpler, uses the new Rendezvous() call to sync with the client
    52  */
    53 	{
    54 #if (defined __DATA_CAGING__)
    55     RProcess().DataCaging(RProcess::EDataCagingOn);
    56     RProcess().SecureApi(RProcess::ESecureApiOn);
    57 #endif
    58     CActiveScheduler*	sched=NULL;
    59     sched=new(ELeave) CActiveScheduler;
    60     CActiveScheduler::Install(sched);
    61     CT_SerialDriverServer* server = NULL;
    62 
    63     // Create the CTestServer derived server
    64     TRAPD(err,server = CT_SerialDriverServer::NewL());
    65     if(!err)
    66 	    {
    67         // Sync with the client and enter the active scheduler
    68         RProcess::Rendezvous(KErrNone);
    69         sched->Start();
    70         }
    71 
    72     delete server;
    73     delete sched;
    74     }
    75 
    76 
    77 GLDEF_C TInt E32Main()
    78 /**
    79  * @return - Standard Epoc error code on process exit
    80  * Secure variant only
    81  * Process entry point. Called by client using RProcess API
    82  */
    83 	{
    84     __UHEAP_MARK;
    85     CTrapCleanup* cleanup = CTrapCleanup::New();
    86     if(cleanup == NULL)
    87 	    {
    88         return KErrNoMemory;
    89         }
    90 
    91 #if (defined TRAP_IGNORE)
    92 	TRAP_IGNORE(MainL());
    93 #else
    94     TRAPD(err,MainL());
    95 #endif
    96 
    97     delete cleanup;
    98     __UHEAP_MARKEND;
    99     return KErrNone;
   100     }
   101 
   102 CDataWrapper* CT_SerialDriverServer::CT_SerialDriverBlock::CreateDataL(const TDesC& aData)
   103 	{
   104 	CDataWrapper*	wrapper=NULL;
   105 
   106 	if( aData==KT_RBusDevComm() )
   107 		{
   108 		wrapper=CT_RBusDevCommData::NewL();
   109 		}
   110 	else if ( aData==KT_TCommCapsV01 )
   111 		{
   112 		wrapper=new (ELeave) CT_TCommCapsV01Data();
   113 		}
   114 	else if ( aData==KT_TCommCapsV02 )
   115 		{
   116 		wrapper=new (ELeave) CT_TCommCapsV02Data();
   117 		}
   118 	else if ( aData==KT_TCommCapsV03 )
   119 		{
   120 		wrapper=new (ELeave) CT_TCommCapsV03Data();
   121 		}
   122 	else if ( aData==KT_TCommConfigV01 )
   123 		{
   124 		wrapper=new (ELeave) CT_TCommConfigV01Data();
   125 		}
   126 	else if ( aData==KT_TCommConfigV02 )
   127 		{
   128 		wrapper=new (ELeave) CT_TCommConfigV02Data();
   129 		}
   130 
   131 	return wrapper;
   132 	}