genericopenlibs/openenvcore/libpthread/test/testsemtrywait/src/tsemtrywaitserver.cpp
changeset 0 e4d67989cc36
child 48 ab61c4cedc64
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright (c) 2002-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        : tsemtrywaitserver.cpp
       
    15 // Part of     : testsemtrywait
       
    16 // This material, including documentation and any related 
       
    17 // computer programs, is protected by copyright controlled by 
       
    18 // Nokia Corporation. All rights are reserved. Copying, 
       
    19 // including reproducing, storing,  adapting or translating, any 
       
    20 // or all of this material requires the prior written consent of 
       
    21 // Nokia Corporation. This material also contains confidential 
       
    22 // information which may not be disclosed to others without the 
       
    23 // prior written consent of Nokia Corporation.
       
    24 //
       
    25 
       
    26 
       
    27 
       
    28 #include <c32comm.h>
       
    29 
       
    30 #if defined (__WINS__)
       
    31 #define PDD_NAME		_L("ECDRV")
       
    32 #else
       
    33 #define PDD_NAME		_L("EUART1")
       
    34 #define PDD2_NAME		_L("EUART2")
       
    35 #define PDD3_NAME		_L("EUART3")
       
    36 #define PDD4_NAME		_L("EUART4")
       
    37 #endif
       
    38 
       
    39 #define LDD_NAME		_L("ECOMM")
       
    40 
       
    41 /**
       
    42  * @file
       
    43  *
       
    44  * Pipe test server implementation
       
    45  */
       
    46 #include "tsemtrywaitserver.h"
       
    47 #include "tsemtrywait.h"
       
    48 
       
    49 
       
    50 _LIT(KServerName, "tsemtrywait");
       
    51 
       
    52 CSemtrywaitTestServer* CSemtrywaitTestServer::NewL()
       
    53 	{
       
    54 	CSemtrywaitTestServer *server = new(ELeave) CSemtrywaitTestServer();
       
    55 	CleanupStack::PushL(server);
       
    56 	server->ConstructL(KServerName);
       
    57 	CleanupStack::Pop(server);
       
    58 	return server;
       
    59 	}
       
    60 
       
    61 static void InitCommsL()
       
    62     {
       
    63     TInt ret = User::LoadPhysicalDevice(PDD_NAME);
       
    64     User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
       
    65 
       
    66 #ifndef __WINS__
       
    67     ret = User::LoadPhysicalDevice(PDD2_NAME);
       
    68     ret = User::LoadPhysicalDevice(PDD3_NAME);
       
    69     ret = User::LoadPhysicalDevice(PDD4_NAME);
       
    70 #endif
       
    71 
       
    72     ret = User::LoadLogicalDevice(LDD_NAME);
       
    73     User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
       
    74     ret = StartC32();
       
    75     User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
       
    76     }
       
    77 
       
    78 LOCAL_C void MainL()
       
    79 	{
       
    80 	// Leave the hooks in for platform security
       
    81 #if (defined __DATA_CAGING__)
       
    82 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
    83 	RProcess().SecureApi(RProcess::ESecureApiOn);
       
    84 #endif
       
    85 	InitCommsL();
       
    86 	
       
    87 	CActiveScheduler* sched=NULL;
       
    88 	sched=new(ELeave) CActiveScheduler;
       
    89 	CActiveScheduler::Install(sched);
       
    90 	CSemtrywaitTestServer* server = NULL;
       
    91 	// Create the CTestServer derived server
       
    92 	TRAPD(err, server = CSemtrywaitTestServer::NewL());
       
    93 	if(!err)
       
    94 		{
       
    95 		// Sync with the client and enter the active scheduler
       
    96 		RProcess::Rendezvous(KErrNone);
       
    97 		sched->Start();
       
    98 		}
       
    99 	delete server;
       
   100 	delete sched;
       
   101 	}
       
   102 
       
   103 /**
       
   104  * Server entry point
       
   105  * @return Standard Epoc error code on exit
       
   106  */
       
   107 TInt main()
       
   108 	{
       
   109 	__UHEAP_MARK;
       
   110 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
   111 	if(cleanup == NULL) 
       
   112 		{
       
   113 		return KErrNoMemory;  
       
   114 		}
       
   115 	TRAP_IGNORE(MainL());
       
   116 	delete cleanup;
       
   117 	__UHEAP_MARKEND;
       
   118 	
       
   119 	return KErrNone;
       
   120 	}
       
   121 
       
   122 CTestStep* CSemtrywaitTestServer::CreateTestStep(const TDesC& aStepName)
       
   123 	{
       
   124 	CTestStep* testStep = NULL;
       
   125 
       
   126 	// This server creates just one step but create as many as you want
       
   127 	// They are created "just in time" when the worker thread is created
       
   128 	// install steps
       
   129 	if(aStepName == KTestSem388)
       
   130 		{
       
   131 		testStep = new CTestSemtrywait(aStepName);
       
   132 		}
       
   133 	if(aStepName == KTestSem389)
       
   134 		{
       
   135 		testStep = new CTestSemtrywait(aStepName);
       
   136 		}
       
   137 	if(aStepName == KTestSem390)
       
   138 		{
       
   139 		testStep = new CTestSemtrywait(aStepName);
       
   140 		}
       
   141 	if(aStepName == KTestSem391)
       
   142 		{
       
   143 		testStep = new CTestSemtrywait(aStepName);
       
   144 		}
       
   145 	if(aStepName == KTestSem392)
       
   146 		{
       
   147 		testStep = new CTestSemtrywait(aStepName);
       
   148 		}
       
   149 	if(aStepName == KTestSem700)
       
   150 		{
       
   151 		testStep = new CTestSemtrywait(aStepName);
       
   152 		}
       
   153 	
       
   154 	return testStep;
       
   155 	}
       
   156