os/ossrv/genericopenlibs/posixrealtimeextensions/test/testtimer/src/ttimerserver.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/posixrealtimeextensions/test/testtimer/src/ttimerserver.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,230 @@
1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Name : ttimerserver.cpp
1.18 +//
1.19 +//
1.20 +
1.21 +#include <c32comm.h>
1.22 +
1.23 +#if defined (__WINS__)
1.24 +#define PDD_NAME _L("ECDRV")
1.25 +#else
1.26 +#define PDD_NAME _L("EUART1")
1.27 +#define PDD2_NAME _L("EUART2")
1.28 +#define PDD3_NAME _L("EUART3")
1.29 +#define PDD4_NAME _L("EUART4")
1.30 +#endif
1.31 +
1.32 +#define LDD_NAME _L("ECOMM")
1.33 +
1.34 +/**
1.35 + * @file
1.36 + *
1.37 + * Pipe test server implementation
1.38 + */
1.39 +#include "ttimerserver.h"
1.40 +#include "ttimer.h"
1.41 +
1.42 +
1.43 +_LIT(KServerName, "ttimer");
1.44 +
1.45 +CTimerTestServer* CTimerTestServer::NewL()
1.46 + {
1.47 + CTimerTestServer *server = new(ELeave) CTimerTestServer();
1.48 + CleanupStack::PushL(server);
1.49 + server->ConstructL(KServerName);
1.50 + CleanupStack::Pop(server);
1.51 + return server;
1.52 + }
1.53 +
1.54 +static void InitCommsL()
1.55 + {
1.56 + TInt ret = User::LoadPhysicalDevice(PDD_NAME);
1.57 + User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
1.58 +
1.59 +#ifndef __WINS__
1.60 + ret = User::LoadPhysicalDevice(PDD2_NAME);
1.61 + ret = User::LoadPhysicalDevice(PDD3_NAME);
1.62 + ret = User::LoadPhysicalDevice(PDD4_NAME);
1.63 +#endif
1.64 +
1.65 + ret = User::LoadLogicalDevice(LDD_NAME);
1.66 + User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
1.67 + ret = StartC32();
1.68 + User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
1.69 + }
1.70 +
1.71 +LOCAL_C void MainL()
1.72 + {
1.73 + // Leave the hooks in for platform security
1.74 +#if (defined __DATA_CAGING__)
1.75 + RProcess().DataCaging(RProcess::EDataCagingOn);
1.76 + RProcess().SecureApi(RProcess::ESecureApiOn);
1.77 +#endif
1.78 + //InitCommsL();
1.79 +
1.80 + CActiveScheduler* sched=NULL;
1.81 + sched=new(ELeave) CActiveScheduler;
1.82 + CActiveScheduler::Install(sched);
1.83 + CTimerTestServer* server = NULL;
1.84 + // Create the CTestServer derived server
1.85 + TRAPD(err, server = CTimerTestServer::NewL());
1.86 + if(!err)
1.87 + {
1.88 + // Sync with the client and enter the active scheduler
1.89 + RProcess::Rendezvous(KErrNone);
1.90 + sched->Start();
1.91 + }
1.92 + delete server;
1.93 + delete sched;
1.94 + }
1.95 +
1.96 +/**
1.97 + * Server entry point
1.98 + * @return Standard Epoc error code on exit
1.99 + */
1.100 +TInt main()
1.101 + {
1.102 + __UHEAP_MARK;
1.103 + CTrapCleanup* cleanup = CTrapCleanup::New();
1.104 + if(cleanup == NULL)
1.105 + {
1.106 + return KErrNoMemory;
1.107 + }
1.108 + TRAP_IGNORE(MainL());
1.109 + delete cleanup;
1.110 + __UHEAP_MARKEND;
1.111 +
1.112 + return KErrNone;
1.113 + }
1.114 +
1.115 +CTestStep* CTimerTestServer::CreateTestStep(const TDesC& aStepName)
1.116 + {
1.117 + CTestStep* testStep = NULL;
1.118 +
1.119 + if(aStepName == KTesttimerapi1)
1.120 + {
1.121 + testStep = new CTesttimer(aStepName);
1.122 + }
1.123 + if(aStepName == KTesttimerapi2)
1.124 + {
1.125 + testStep = new CTesttimer(aStepName);
1.126 + }
1.127 + if(aStepName == KTesttimerapi3)
1.128 + {
1.129 + testStep = new CTesttimer(aStepName);
1.130 + }
1.131 + if(aStepName == KTesttimerapi4)
1.132 + {
1.133 + testStep = new CTesttimer(aStepName);
1.134 + }
1.135 + if(aStepName == KTesttimerapi5)
1.136 + {
1.137 + testStep = new CTesttimer(aStepName);
1.138 + }
1.139 + if(aStepName == KTesttimerapi6)
1.140 + {
1.141 + testStep = new CTesttimer(aStepName);
1.142 + }
1.143 + if(aStepName == KTesttimerapi7)
1.144 + {
1.145 + testStep = new CTesttimer(aStepName);
1.146 + }
1.147 + if(aStepName == KTesttimerapi8)
1.148 + {
1.149 + testStep = new CTesttimer(aStepName);
1.150 + }
1.151 + if(aStepName == KTesttimerapi9)
1.152 + {
1.153 + testStep = new CTesttimer(aStepName);
1.154 + }
1.155 + if(aStepName == KTesttimerapi10)
1.156 + {
1.157 + testStep = new CTesttimer(aStepName);
1.158 + }
1.159 + if(aStepName == KTesttimerapi11)
1.160 + {
1.161 + testStep = new CTesttimer(aStepName);
1.162 + }
1.163 + if(aStepName == KTesttimerapi12)
1.164 + {
1.165 + testStep = new CTesttimer(aStepName);
1.166 + }
1.167 + if(aStepName == KTesttimerapi13)
1.168 + {
1.169 + testStep = new CTesttimer(aStepName);
1.170 + }
1.171 + if(aStepName == KTesttimerapi14)
1.172 + {
1.173 + testStep = new CTesttimer(aStepName);
1.174 + }
1.175 + if(aStepName == KTesttimerapi15)
1.176 + {
1.177 + testStep = new CTesttimer(aStepName);
1.178 + }
1.179 + if(aStepName == KTesttimerapi16)
1.180 + {
1.181 + testStep = new CTesttimer(aStepName);
1.182 + }
1.183 + if(aStepName == KTesttimerapi17)
1.184 + {
1.185 + testStep = new CTesttimer(aStepName);
1.186 + }
1.187 + if(aStepName == KTesttimerapi18)
1.188 + {
1.189 + testStep = new CTesttimer(aStepName);
1.190 + }
1.191 + if(aStepName == KTesttimerapi19)
1.192 + {
1.193 + testStep = new CTesttimer(aStepName);
1.194 + }
1.195 + if(aStepName == KTesttimerapi20)
1.196 + {
1.197 + testStep = new CTesttimer(aStepName);
1.198 + }
1.199 + if(aStepName == KTesttimerapi21)
1.200 + {
1.201 + testStep = new CTesttimer(aStepName);
1.202 + }
1.203 + if(aStepName == KTesttimerapi22)
1.204 + {
1.205 + testStep = new CTesttimer(aStepName);
1.206 + }
1.207 + if(aStepName == KTesttimerapi23)
1.208 + {
1.209 + testStep = new CTesttimer(aStepName);
1.210 + }
1.211 + if(aStepName == KTesttimerapi24)
1.212 + {
1.213 + testStep = new CTesttimer(aStepName);
1.214 + }
1.215 + if(aStepName == KTesttimerapi25)
1.216 + {
1.217 + testStep = new CTesttimer(aStepName);
1.218 + }
1.219 + if(aStepName == KTesttimerapi26)
1.220 + {
1.221 + testStep = new CTesttimer(aStepName);
1.222 + }
1.223 + if(aStepName == KTesttimerapi27)
1.224 + {
1.225 + testStep = new CTesttimer(aStepName);
1.226 + }
1.227 + if(aStepName == KTesttimerapi28)
1.228 + {
1.229 + testStep = new CTesttimer(aStepName);
1.230 + }
1.231 + return testStep;
1.232 + }
1.233 +