os/ossrv/genericopenlibs/posixrealtimeextensions/test/testsharedmemory/src/tsharedmemoryserver.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        : tsharedmemoryserver.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 /**
    32  * @file
    33  *
    34  * Pipe test server implementation
    35  */
    36 #include "tsharedmemoryserver.h"
    37 #include "tsharedmemory.h"
    38 
    39 
    40 _LIT(KServerName, "tsharedmemory");
    41 
    42 CSharedmemoryTestServer* CSharedmemoryTestServer::NewL()
    43 	{
    44 	CSharedmemoryTestServer *server = new(ELeave) CSharedmemoryTestServer();
    45 	CleanupStack::PushL(server);
    46 	server->ConstructL(KServerName);
    47 	CleanupStack::Pop(server);
    48 	return server;
    49 	}
    50 
    51 static void InitCommsL()
    52     {
    53     TInt ret = User::LoadPhysicalDevice(PDD_NAME);
    54     User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
    55 
    56 #ifndef __WINS__
    57     ret = User::LoadPhysicalDevice(PDD2_NAME);
    58     ret = User::LoadPhysicalDevice(PDD3_NAME);
    59     ret = User::LoadPhysicalDevice(PDD4_NAME);
    60 #endif
    61 
    62     ret = User::LoadLogicalDevice(LDD_NAME);
    63     User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
    64     ret = StartC32();
    65     User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
    66     }
    67 
    68 LOCAL_C void MainL()
    69 	{
    70 	// Leave the hooks in for platform security
    71 #if (defined __DATA_CAGING__)
    72 	RProcess().DataCaging(RProcess::EDataCagingOn);
    73 	RProcess().SecureApi(RProcess::ESecureApiOn);
    74 #endif
    75 	//InitCommsL();
    76 	
    77 	CActiveScheduler* sched=NULL;
    78 	sched=new(ELeave) CActiveScheduler;
    79 	CActiveScheduler::Install(sched);
    80 	CSharedmemoryTestServer* server = NULL;
    81 	// Create the CTestServer derived server
    82 	TRAPD(err, server = CSharedmemoryTestServer::NewL());
    83 	if(!err)
    84 		{
    85 		// Sync with the client and enter the active scheduler
    86 		RProcess::Rendezvous(KErrNone);
    87 		sched->Start();
    88 		}
    89 	delete server;
    90 	delete sched;
    91 	}
    92 
    93 /**
    94  * Server entry point
    95  * @return Standard Epoc error code on exit
    96  */
    97 TInt main()
    98 	{
    99 	__UHEAP_MARK;
   100 	CTrapCleanup* cleanup = CTrapCleanup::New();
   101 	if(cleanup == NULL) 
   102 		{
   103 		return KErrNoMemory;  
   104 		}
   105 	TRAP_IGNORE(MainL());
   106 	delete cleanup;
   107 	__UHEAP_MARKEND;
   108 	
   109 	return KErrNone;
   110 	}
   111 
   112 CTestStep* CSharedmemoryTestServer::CreateTestStep(const TDesC& aStepName)
   113 	{
   114 	CTestStep* testStep = NULL;
   115 
   116 	if(aStepName == KTestsharedmemory1)
   117 		{
   118 			testStep = new CTestsharedmemory(aStepName);
   119 		}
   120 	if(aStepName == KTestsharedmemory2)
   121 		{
   122 			testStep = new CTestsharedmemory(aStepName);
   123 		}
   124 	if(aStepName == KTestsharedmemory3)
   125 		{
   126 			testStep = new CTestsharedmemory(aStepName);
   127 		}
   128 	if(aStepName == KTestsharedmemory4)
   129 		{
   130 			testStep = new CTestsharedmemory(aStepName);
   131 		}
   132 	if(aStepName == KTestsharedmemory5)
   133 		{
   134 			testStep = new CTestsharedmemory(aStepName);
   135 		}
   136 	if(aStepName == KTestsharedmemory6)
   137 		{
   138 			testStep = new CTestsharedmemory(aStepName);
   139 		}
   140 	if(aStepName == KTestsharedmemory7)
   141 		{
   142 			testStep = new CTestsharedmemory(aStepName);
   143 		}
   144 	if(aStepName == KTestsharedmemory8)
   145 		{
   146 			testStep = new CTestsharedmemory(aStepName);
   147 		}
   148 	if(aStepName == KTestsharedmemory9)
   149 		{
   150 			testStep = new CTestsharedmemory(aStepName);
   151 		}
   152 	if(aStepName == KTestsharedmemory10)
   153 		{
   154 			testStep = new CTestsharedmemory(aStepName);
   155 		}
   156 	if(aStepName == KTestsharedmemory11)
   157 		{
   158 			testStep = new CTestsharedmemory(aStepName);
   159 		}
   160 	if(aStepName == KTestsharedmemory12)
   161 		{
   162 			testStep = new CTestsharedmemory(aStepName);
   163 		}
   164 	if(aStepName == KTestsharedmemory13)
   165 		{
   166 			testStep = new CTestsharedmemory(aStepName);
   167 		}
   168 	if(aStepName == KTestsharedmemory14)
   169 		{
   170 			testStep = new CTestsharedmemory(aStepName);
   171 		}
   172 	if(aStepName == KTestsharedmemory15)
   173 		{
   174 			testStep = new CTestsharedmemory(aStepName);
   175 		}
   176 	if(aStepName == KTestsharedmemory16)
   177 		{
   178 			testStep = new CTestsharedmemory(aStepName);
   179 		}
   180 	if(aStepName == KTestsharedmemory17)
   181 		{
   182 			testStep = new CTestsharedmemory(aStepName);
   183 		}
   184 	if(aStepName == KTestsharedmemory18)
   185 		{
   186 			testStep = new CTestsharedmemory(aStepName);
   187 		}
   188 	if(aStepName == KTestsharedmemory19)
   189 		{
   190 			testStep = new CTestsharedmemory(aStepName);
   191 		}
   192 	if(aStepName == KTestsharedmemory20)
   193 		{
   194 			testStep = new CTestsharedmemory(aStepName);
   195 		}
   196 	if(aStepName == KTestsharedmemory21)
   197 		{
   198 			testStep = new CTestsharedmemory(aStepName);
   199 		}
   200 	if(aStepName == KTestsharedmemory22)
   201 		{
   202 			testStep = new CTestsharedmemory(aStepName);
   203 		}
   204 	if(aStepName == KTestsharedmemory23)
   205 		{
   206 			testStep = new CTestsharedmemory(aStepName);
   207 		}
   208 	if(aStepName == KTestsharedmemory24)
   209 		{
   210 			testStep = new CTestsharedmemory(aStepName);
   211 		}
   212 	if(aStepName == KTestsharedmemory25)
   213 		{
   214 			testStep = new CTestsharedmemory(aStepName);
   215 		}
   216 	if(aStepName == KTestsharedmemory26)
   217 		{
   218 			testStep = new CTestsharedmemory(aStepName);
   219 		}
   220 	if(aStepName == KTestsharedmemory27)
   221 		{
   222 			testStep = new CTestsharedmemory(aStepName);
   223 		}
   224 	if(aStepName == KTestsharedmemory28)
   225 		{
   226 			testStep = new CTestsharedmemory(aStepName);
   227 		}
   228 	if(aStepName == KTestsharedmemory29)
   229 		{
   230 			testStep = new CTestsharedmemory(aStepName);
   231 		}
   232 	if(aStepName == KTestsharedmemory30)
   233 		{
   234 			testStep = new CTestsharedmemory(aStepName);
   235 		}
   236 	return testStep;
   237 	 }
   238