os/boardsupport/haitest/bspsvs/suite/bsp/uart/src/T_SerialDriverServer.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/boardsupport/haitest/bspsvs/suite/bsp/uart/src/T_SerialDriverServer.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,132 @@
     1.4 +/*
     1.5 +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +#include "T_SerialDriverServer.h"
    1.22 +#include "T_RBusDevCommData.h"
    1.23 +#include "T_TCommCapsV03Data.h"
    1.24 +#include "T_TCommConfigV02Data.h"
    1.25 +
    1.26 +/*@{*/
    1.27 +_LIT(KT_RBusDevComm,		"RBusDevComm");
    1.28 +_LIT(KT_TCommCapsV01,		"TCommCapsV01");
    1.29 +_LIT(KT_TCommCapsV02,		"TCommCapsV02");
    1.30 +_LIT(KT_TCommCapsV03,		"TCommCapsV03");
    1.31 +_LIT(KT_TCommConfigV01,		"TCommConfigV01");
    1.32 +_LIT(KT_TCommConfigV02,		"TCommConfigV02");
    1.33 +/*@}*/
    1.34 +
    1.35 +CT_SerialDriverServer* CT_SerialDriverServer::NewL()
    1.36 +/**
    1.37 + * @return - Instance of the test server
    1.38 + * Same code for Secure and non-secure variants
    1.39 + * Called inside the MainL() function to create and start the
    1.40 + * CTestServer derived server.
    1.41 + */
    1.42 +	{
    1.43 +    CT_SerialDriverServer* server = new (ELeave) CT_SerialDriverServer();
    1.44 +    CleanupStack::PushL(server);
    1.45 +    server->ConstructL();
    1.46 +    CleanupStack::Pop(server);
    1.47 +    return server;
    1.48 +    }
    1.49 +
    1.50 +
    1.51 +LOCAL_C void MainL()
    1.52 +/**
    1.53 + * Secure variant
    1.54 + * Much simpler, uses the new Rendezvous() call to sync with the client
    1.55 + */
    1.56 +	{
    1.57 +#if (defined __DATA_CAGING__)
    1.58 +    RProcess().DataCaging(RProcess::EDataCagingOn);
    1.59 +    RProcess().SecureApi(RProcess::ESecureApiOn);
    1.60 +#endif
    1.61 +    CActiveScheduler*	sched=NULL;
    1.62 +    sched=new(ELeave) CActiveScheduler;
    1.63 +    CActiveScheduler::Install(sched);
    1.64 +    CT_SerialDriverServer* server = NULL;
    1.65 +
    1.66 +    // Create the CTestServer derived server
    1.67 +    TRAPD(err,server = CT_SerialDriverServer::NewL());
    1.68 +    if(!err)
    1.69 +	    {
    1.70 +        // Sync with the client and enter the active scheduler
    1.71 +        RProcess::Rendezvous(KErrNone);
    1.72 +        sched->Start();
    1.73 +        }
    1.74 +
    1.75 +    delete server;
    1.76 +    delete sched;
    1.77 +    }
    1.78 +
    1.79 +
    1.80 +GLDEF_C TInt E32Main()
    1.81 +/**
    1.82 + * @return - Standard Epoc error code on process exit
    1.83 + * Secure variant only
    1.84 + * Process entry point. Called by client using RProcess API
    1.85 + */
    1.86 +	{
    1.87 +    __UHEAP_MARK;
    1.88 +    CTrapCleanup* cleanup = CTrapCleanup::New();
    1.89 +    if(cleanup == NULL)
    1.90 +	    {
    1.91 +        return KErrNoMemory;
    1.92 +        }
    1.93 +
    1.94 +#if (defined TRAP_IGNORE)
    1.95 +	TRAP_IGNORE(MainL());
    1.96 +#else
    1.97 +    TRAPD(err,MainL());
    1.98 +#endif
    1.99 +
   1.100 +    delete cleanup;
   1.101 +    __UHEAP_MARKEND;
   1.102 +    return KErrNone;
   1.103 +    }
   1.104 +
   1.105 +CDataWrapper* CT_SerialDriverServer::CT_SerialDriverBlock::CreateDataL(const TDesC& aData)
   1.106 +	{
   1.107 +	CDataWrapper*	wrapper=NULL;
   1.108 +
   1.109 +	if( aData==KT_RBusDevComm() )
   1.110 +		{
   1.111 +		wrapper=CT_RBusDevCommData::NewL();
   1.112 +		}
   1.113 +	else if ( aData==KT_TCommCapsV01 )
   1.114 +		{
   1.115 +		wrapper=new (ELeave) CT_TCommCapsV01Data();
   1.116 +		}
   1.117 +	else if ( aData==KT_TCommCapsV02 )
   1.118 +		{
   1.119 +		wrapper=new (ELeave) CT_TCommCapsV02Data();
   1.120 +		}
   1.121 +	else if ( aData==KT_TCommCapsV03 )
   1.122 +		{
   1.123 +		wrapper=new (ELeave) CT_TCommCapsV03Data();
   1.124 +		}
   1.125 +	else if ( aData==KT_TCommConfigV01 )
   1.126 +		{
   1.127 +		wrapper=new (ELeave) CT_TCommConfigV01Data();
   1.128 +		}
   1.129 +	else if ( aData==KT_TCommConfigV02 )
   1.130 +		{
   1.131 +		wrapper=new (ELeave) CT_TCommConfigV02Data();
   1.132 +		}
   1.133 +
   1.134 +	return wrapper;
   1.135 +	}