os/ossrv/genericopenlibs/posixrealtimeextensions/test/testclock/src/tclockserver.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // Name        : tclockserver.cpp
    15 // 
    16 //
    17 
    18 #include <c32comm.h>
    19 
    20 #if defined (__WINS__)
    21 #define PDD_NAME		_L("ECDRV")
    22 #else
    23 #define PDD_NAME		_L("EUART1")
    24 #define PDD2_NAME		_L("EUART2")
    25 #define PDD3_NAME		_L("EUART3")
    26 #define PDD4_NAME		_L("EUART4")
    27 #endif
    28 
    29 #define LDD_NAME		_L("ECOMM")
    30 
    31 #include "tclockserver.h"
    32 #include "tclock.h"
    33 
    34 
    35 _LIT(KServerName, "tclock");
    36 
    37 CClockTestServer* CClockTestServer::NewL()
    38 	{
    39 	CClockTestServer *server = new(ELeave) CClockTestServer();
    40 	CleanupStack::PushL(server);
    41 	server->ConstructL(KServerName);
    42 	CleanupStack::Pop(server);
    43 	return server;
    44 	}
    45 
    46 static void InitCommsL()
    47     {
    48     TInt ret = User::LoadPhysicalDevice(PDD_NAME);
    49     User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
    50 
    51 #ifndef __WINS__
    52     ret = User::LoadPhysicalDevice(PDD2_NAME);
    53     ret = User::LoadPhysicalDevice(PDD3_NAME);
    54     ret = User::LoadPhysicalDevice(PDD4_NAME);
    55 #endif
    56 
    57     ret = User::LoadLogicalDevice(LDD_NAME);
    58     User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
    59     ret = StartC32();
    60     User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
    61     }
    62 
    63 LOCAL_C void MainL()
    64 	{
    65 	// Leave the hooks in for platform security
    66 #if (defined __DATA_CAGING__)
    67 	RProcess().DataCaging(RProcess::EDataCagingOn);
    68 	RProcess().SecureApi(RProcess::ESecureApiOn);
    69 #endif
    70 	//InitCommsL();
    71 	
    72 	CActiveScheduler* sched=NULL;
    73 	sched=new(ELeave) CActiveScheduler;
    74 	CActiveScheduler::Install(sched);
    75 	CClockTestServer* server = NULL;
    76 	// Create the CTestServer derived server
    77 	TRAPD(err, server = CClockTestServer::NewL());
    78 	if(!err)
    79 		{
    80 		// Sync with the client and enter the active scheduler
    81 		RProcess::Rendezvous(KErrNone);
    82 		sched->Start();
    83 		}
    84 	delete server;
    85 	delete sched;
    86 	}
    87 
    88 /**
    89  * Server entry point
    90  * @return Standard Epoc error code on exit
    91  */
    92 TInt main()
    93 	{
    94 	__UHEAP_MARK;
    95 	CTrapCleanup* cleanup = CTrapCleanup::New();
    96 	if(cleanup == NULL) 
    97 		{
    98 		return KErrNoMemory;  
    99 		}
   100 	TRAP_IGNORE(MainL());
   101 	delete cleanup;
   102 	__UHEAP_MARKEND;
   103 	
   104 	return KErrNone;
   105 	}
   106 
   107 CTestStep* CClockTestServer::CreateTestStep(const TDesC& aStepName)
   108 	{
   109 	CTestStep* testStep = NULL;
   110 
   111 	if(aStepName == KTestgetclockid1)
   112 		{
   113 			testStep = new CTestclock(aStepName);
   114 		}
   115 	if(aStepName == KTestgetclockid2)
   116 		{
   117 			testStep = new CTestclock(aStepName);
   118 		}
   119 	if(aStepName == KTestgetclockid3)
   120 		{
   121 			testStep = new CTestclock(aStepName);
   122 		}
   123 	if(aStepName == KTestgetclockid4)
   124 		{
   125 			testStep = new CTestclock(aStepName);
   126 		}
   127 	if(aStepName == KTestgetclockid5)
   128 		{
   129 			testStep = new CTestclock(aStepName);
   130 		}
   131 	if(aStepName == KTestclockresolution1)
   132 		{
   133 			testStep = new CTestclock(aStepName);
   134 		}
   135 	if(aStepName == KTestclockresolution2)
   136 		{
   137 			testStep = new CTestclock(aStepName);
   138 		}
   139 	if(aStepName == KTestclockresolution3)
   140 		{
   141 			testStep = new CTestclock(aStepName);
   142 		}
   143 	if(aStepName == KTestclocknanosleep1)
   144 		{
   145 			testStep = new CTestclock(aStepName);
   146 		}
   147 	if(aStepName == KTestclocknanosleep2)
   148 		{
   149 			testStep = new CTestclock(aStepName);
   150 		}
   151 	if(aStepName == KTestclocknanosleep3)
   152 		{
   153 			testStep = new CTestclock(aStepName);
   154 		}
   155 	if(aStepName == KTestclocknanosleep4)
   156 		{
   157 			testStep = new CTestclock(aStepName);
   158 		}
   159 	if(aStepName == KTestclocknanosleep5)
   160 		{
   161 			testStep = new CTestclock(aStepName);
   162 		}
   163 	if(aStepName == KTestclocknanosleep6)
   164 		{
   165 			testStep = new CTestclock(aStepName);
   166 		}
   167 	if(aStepName == KTestclockgettime1)
   168 		{
   169 			testStep = new CTestclock(aStepName);
   170 		}
   171 	if(aStepName == KTestclockgettime2)
   172 		{
   173 			testStep = new CTestclock(aStepName);
   174 		}
   175 	if(aStepName == KTestclockgettime3)
   176 		{
   177 			testStep = new CTestclock(aStepName);
   178 		}
   179 	if(aStepName == KTestclocksettime1)
   180 		{
   181 			testStep = new CTestclock(aStepName);
   182 		}
   183 	if(aStepName == KTestclocksettime2)
   184 		{
   185 			testStep = new CTestclock(aStepName);
   186 		}
   187 	if(aStepName == KTestclocksettime3)
   188 		{
   189 			testStep = new CTestclock(aStepName);
   190 		}
   191 	return testStep;
   192 	 }
   193