os/ossrv/genericopenlibs/posixrealtimeextensions/test/testclock/src/tclockserver.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/posixrealtimeextensions/test/testclock/src/tclockserver.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,193 @@
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 : tclockserver.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 +#include "tclockserver.h"
1.35 +#include "tclock.h"
1.36 +
1.37 +
1.38 +_LIT(KServerName, "tclock");
1.39 +
1.40 +CClockTestServer* CClockTestServer::NewL()
1.41 + {
1.42 + CClockTestServer *server = new(ELeave) CClockTestServer();
1.43 + CleanupStack::PushL(server);
1.44 + server->ConstructL(KServerName);
1.45 + CleanupStack::Pop(server);
1.46 + return server;
1.47 + }
1.48 +
1.49 +static void InitCommsL()
1.50 + {
1.51 + TInt ret = User::LoadPhysicalDevice(PDD_NAME);
1.52 + User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
1.53 +
1.54 +#ifndef __WINS__
1.55 + ret = User::LoadPhysicalDevice(PDD2_NAME);
1.56 + ret = User::LoadPhysicalDevice(PDD3_NAME);
1.57 + ret = User::LoadPhysicalDevice(PDD4_NAME);
1.58 +#endif
1.59 +
1.60 + ret = User::LoadLogicalDevice(LDD_NAME);
1.61 + User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
1.62 + ret = StartC32();
1.63 + User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
1.64 + }
1.65 +
1.66 +LOCAL_C void MainL()
1.67 + {
1.68 + // Leave the hooks in for platform security
1.69 +#if (defined __DATA_CAGING__)
1.70 + RProcess().DataCaging(RProcess::EDataCagingOn);
1.71 + RProcess().SecureApi(RProcess::ESecureApiOn);
1.72 +#endif
1.73 + //InitCommsL();
1.74 +
1.75 + CActiveScheduler* sched=NULL;
1.76 + sched=new(ELeave) CActiveScheduler;
1.77 + CActiveScheduler::Install(sched);
1.78 + CClockTestServer* server = NULL;
1.79 + // Create the CTestServer derived server
1.80 + TRAPD(err, server = CClockTestServer::NewL());
1.81 + if(!err)
1.82 + {
1.83 + // Sync with the client and enter the active scheduler
1.84 + RProcess::Rendezvous(KErrNone);
1.85 + sched->Start();
1.86 + }
1.87 + delete server;
1.88 + delete sched;
1.89 + }
1.90 +
1.91 +/**
1.92 + * Server entry point
1.93 + * @return Standard Epoc error code on exit
1.94 + */
1.95 +TInt main()
1.96 + {
1.97 + __UHEAP_MARK;
1.98 + CTrapCleanup* cleanup = CTrapCleanup::New();
1.99 + if(cleanup == NULL)
1.100 + {
1.101 + return KErrNoMemory;
1.102 + }
1.103 + TRAP_IGNORE(MainL());
1.104 + delete cleanup;
1.105 + __UHEAP_MARKEND;
1.106 +
1.107 + return KErrNone;
1.108 + }
1.109 +
1.110 +CTestStep* CClockTestServer::CreateTestStep(const TDesC& aStepName)
1.111 + {
1.112 + CTestStep* testStep = NULL;
1.113 +
1.114 + if(aStepName == KTestgetclockid1)
1.115 + {
1.116 + testStep = new CTestclock(aStepName);
1.117 + }
1.118 + if(aStepName == KTestgetclockid2)
1.119 + {
1.120 + testStep = new CTestclock(aStepName);
1.121 + }
1.122 + if(aStepName == KTestgetclockid3)
1.123 + {
1.124 + testStep = new CTestclock(aStepName);
1.125 + }
1.126 + if(aStepName == KTestgetclockid4)
1.127 + {
1.128 + testStep = new CTestclock(aStepName);
1.129 + }
1.130 + if(aStepName == KTestgetclockid5)
1.131 + {
1.132 + testStep = new CTestclock(aStepName);
1.133 + }
1.134 + if(aStepName == KTestclockresolution1)
1.135 + {
1.136 + testStep = new CTestclock(aStepName);
1.137 + }
1.138 + if(aStepName == KTestclockresolution2)
1.139 + {
1.140 + testStep = new CTestclock(aStepName);
1.141 + }
1.142 + if(aStepName == KTestclockresolution3)
1.143 + {
1.144 + testStep = new CTestclock(aStepName);
1.145 + }
1.146 + if(aStepName == KTestclocknanosleep1)
1.147 + {
1.148 + testStep = new CTestclock(aStepName);
1.149 + }
1.150 + if(aStepName == KTestclocknanosleep2)
1.151 + {
1.152 + testStep = new CTestclock(aStepName);
1.153 + }
1.154 + if(aStepName == KTestclocknanosleep3)
1.155 + {
1.156 + testStep = new CTestclock(aStepName);
1.157 + }
1.158 + if(aStepName == KTestclocknanosleep4)
1.159 + {
1.160 + testStep = new CTestclock(aStepName);
1.161 + }
1.162 + if(aStepName == KTestclocknanosleep5)
1.163 + {
1.164 + testStep = new CTestclock(aStepName);
1.165 + }
1.166 + if(aStepName == KTestclocknanosleep6)
1.167 + {
1.168 + testStep = new CTestclock(aStepName);
1.169 + }
1.170 + if(aStepName == KTestclockgettime1)
1.171 + {
1.172 + testStep = new CTestclock(aStepName);
1.173 + }
1.174 + if(aStepName == KTestclockgettime2)
1.175 + {
1.176 + testStep = new CTestclock(aStepName);
1.177 + }
1.178 + if(aStepName == KTestclockgettime3)
1.179 + {
1.180 + testStep = new CTestclock(aStepName);
1.181 + }
1.182 + if(aStepName == KTestclocksettime1)
1.183 + {
1.184 + testStep = new CTestclock(aStepName);
1.185 + }
1.186 + if(aStepName == KTestclocksettime2)
1.187 + {
1.188 + testStep = new CTestclock(aStepName);
1.189 + }
1.190 + if(aStepName == KTestclocksettime3)
1.191 + {
1.192 + testStep = new CTestclock(aStepName);
1.193 + }
1.194 + return testStep;
1.195 + }
1.196 +