TBool CMemoryMonitorSession::IsDataPaged(const RMessage2& aMessage)
    {
    RThread clientThread;
    TInt err = aMessage.Client(clientThread);
    TBool dataPaged = EFalse;
    if(err == KErrNone)
        {
        RProcess processName;
        err = clientThread.Process(processName);
        if(err == KErrNone)
            {
            dataPaged = processName.DefaultDataPaged();
            processName.Close();
            clientThread.Close();
            }
        else
            {
            clientThread.Close();                        
            PanicClient(aMessage, EPanicIllegalFunction);
            }
        }
    else
        {
        PanicClient(aMessage, EPanicIllegalFunction);
        }
    return dataPaged;            
    }
Exemplo n.º 2
0
void CWsTop::InitStaticsL()
	{
	iShuttingDown=EFalse;
	// By default shell should be started.
	TBool startShell = ETrue;
	
	iCurrentFocusScreen = 0;

	// The windows server has been invoked.
	// This may have been from the system starter (via a
	// start up rss file)  
	// This block looks for a "-NoShell" argument in the invocation.
	// The existence of the argument means that shell does not need to be 
	// invoked from here because the new system starter
	// is in charge, and it will do it if required.
	
	_LIT(KNoShell,"-NOSHELL");
	
	TInt argLen = User::CommandLineLength();
	if(argLen)
		{
		HBufC* arg = HBufC::NewLC(argLen);
		TPtr argPtr = arg->Des();
		User::CommandLine(argPtr);
		argPtr.UpperCase();

		if(KErrNotFound != argPtr.Find(KNoShell))
			{
			// Don't start the shell. It will be started if required by 
			// the system starter.
			startShell = EFalse;
			}
		CleanupStack::PopAndDestroy(arg);
		}
		
	TheActiveScheduler=new(ELeave) CWsActiveScheduler;
	CActiveScheduler::Install(TheActiveScheduler);
	// WsIniFile is already created (before E32Main's Loop)
	_LIT(KWSERVIniFileVarLogEnable,"LOGENABLE");
	TInt loggingLevel;
	if (WsIniFile->FindVar(KWSERVIniFileVarLogEnable,loggingLevel))
		{
		EnableLogging(EDoNotReloadWsIni);
		if (wsDebugLog)
			{
			wsDebugLog->SetLoggingLevel(loggingLevel);
			}
		}
		
	_LIT(KWSERVIniFileVarFadeEnable,"FADEDISABLE");
	iFadeEnabled = !WsIniFile->FindVar(KWSERVIniFileVarFadeEnable);

	_LIT(KWSERVIniFileVarFinishEveryFlush,"FINISHEVERYFLUSH");
	iFinishEveryFlush = WsIniFile->FindVar(KWSERVIniFileVarFinishEveryFlush);
	
	_LIT(KWSERVIniFileVarSwitchOffEvent,"IGNORESWITCHOFFEVENT");
	iIgnoreSwitchOffEvent = WsIniFile->FindVar(KWSERVIniFileVarSwitchOffEvent);	

	iPluginManager = CWsPluginManager::NewL(); // need to be constructed before iServer!
	iServer=CWindowServer::NewL();
	CClick::InitStaticsL();
	
	RProcess wservProc;
	if (!wservProc.DefaultDataPaged())
	{
		iServer->SetPinClientDescriptors(ETrue);
	}
	User::LeaveIfError(FbsStartup());
	User::LeaveIfError(RFbsSession::Connect());
	User::LeaveIfError(iTimer.CreateLocal());

	TWindowServerEvent::InitStaticsL();
	CWsClient::InitStaticsL();
	//-------------------------------------------
	User::LeaveIfError(  HAL::Get( HAL::EDisplayNumberOfScreens, iNumberOfScreens ) ) ; 
	// Check that the INI file matches the HAL
	WS_ASSERT_ALWAYS(WsIniFile->NumberOfScreens()<=iNumberOfScreens, EWsPanicScreenInformationError);

	iScreens = new (ELeave) CArrayPtrFlat<CScreen>( iNumberOfScreens ) ;  //
	// now construct screens for as long as there is information
	
	TInt ii ;
	for ( ii = 0 ; ii < iNumberOfScreens ; ++ii )
		{
		InitScreenL( ii ) ;
		}
	//---------------------------------------------
	iCurrentFocusScreen = (*iScreens)[0] ;
	iServer->StartL();

	CWsFontCache::CreateInstanceL();
	CWsGc::InitStaticsL();
	CPlaybackGc::InitStaticsL();
	CWsSpriteBase::InitStaticsL();
	CEventQueue::InitStaticsL();

//
	CWsAnimDll::InitStaticsL();
//
	TInt bootMode=0;
	_LIT(KWSERVIniFileVarReboot,"REBOOT");
	WsIniFile->FindVar(KWSERVIniFileVarReboot,bootMode);
	if (bootMode>=0 && bootMode<=2)
		iShellBootMode=bootMode;
//
	CWsBackedUpWindow::StaticInitL();
	CWsRedrawMsgWindow::StaticInitL();
//
	TWsPointer::InitStaticsL();
	iShellStarter=new (ELeave) CShellStarter;
	iShellStarter->ConstructL();
	_LIT(KPreProcess,"REMOVEFADINGONFOCUSGAIN");
	CWsWindowGroup::SetFocusGainPreprocessing(WsIniFile->FindVar(KPreProcess));
	_LIT(KAbsFade,"ABSOLUTEFADING");
	CWsClientWindow::SetAbsoluteFading(WsIniFile->FindVar(KAbsFade));

//Set the focus policy
	_LIT(KFocusPolicy,"MULTIFOCUSPOLICY");
	if(WsIniFile->FindVar(KFocusPolicy))
		{
		iMultiFocusPolicy = ETrue;	
		}
	RProcess::Rendezvous(KErrNone);
	// Start the shell from here unless the 'NoShell' option has been 
	// received indicating that the system starter will start the shell directly.
	if(startShell)
		{
		StartShell();
		}
	UserSvr::WsRegisterSwitchOnScreenHandling(ETrue);
	
	iRenderOrientationTracker = CWsRenderOrienationTracker::NewL();	
	}
Exemplo n.º 3
0
GLDEF_C TInt E32Main()
	{
	RTest test(_L("T_SVRPINNING...main"));
	test.Title();


	if (DPTest::Attributes() & DPTest::ERomPaging)
		test.Printf(_L("Rom paging supported\n"));
	if (DPTest::Attributes() & DPTest::ECodePaging)
		test.Printf(_L("Code paging supported\n"));
	if (DPTest::Attributes() & DPTest::EDataPaging)
		{
		test.Printf(_L("Data paging supported\n"));
		gDataPagingSupport = ETrue;
		}

	// Determine the data paging attribute.
	RProcess process;	// Default to point to current process.
	gProcessPaged = process.DefaultDataPaged();
	test.Printf(_L("Process data paged %x\n"), gProcessPaged);

	test.Start(_L("Test IPC message arguments pinning"));
	test_KErrNone(HAL::Get(HAL::EMemoryPageSize, gPageSize));
	gPageMask = gPageSize - 1;
	test_Equal(KPageSize, gPageSize);
	// Disable JIT as we are testing panics and don't want the emulator to hang.
	TBool justInTime = User::JustInTime();
	User::SetJustInTime(EFalse);

	TBool exitFailure = EFalse;
	for (	gServerPinningState = EServerDefault; 
			gServerPinningState < EServerSetPinningTooLate && !exitFailure; 
			gServerPinningState++)
		{
		// Create the server with the specified pinning mode.
		switch (gServerPinningState)
			{
			case EServerDefault : 
				test.Next(_L("Test server with default pinning policy"));
				break;
			case EServerPinning : 
				test.Next(_L("Test server with pinning policy"));
				break;
			case EServerNotPinning : 
				test.Next(_L("Test server with not pinning policy"));
				break;
			}
		test_KErrNone(gSem.CreateLocal(0));
		test_KErrNone(gSem1.CreateLocal(0));
		// Create the server thread it needs to have a unpaged stack and heap.
		TThreadCreateInfo serverInfo(_L("Server Thread"), ServerThread, KDefaultStackSize, (TAny*)gServerPinningState);
		serverInfo.SetPaging(TThreadCreateInfo::EUnpaged);
		serverInfo.SetCreateHeap(KHeapMinSize, KHeapMaxSize);
		RThread serverThread;
		test_KErrNone(serverThread.Create(serverInfo));
		TRequestStatus serverStat;
		serverThread.Logon(serverStat);
		serverThread.Resume();

		// Wait for the server to start and then create a session to it.
		gSem.Wait();
		RSession session;
		test_KErrNone(session.PublicCreateSession(_L("CTestServer"),5));
		
		for (	TUint clientTest = CTestSession::ETestRdPinAll; 
				clientTest <= CTestSession::ETestPinDefault && !exitFailure;
				clientTest++)
			{
			// Create the client thread it needs to have a paged stack and heap.
			TThreadCreateInfo clientInfo(_L("Client Thread"), ClientThread, 10 * gPageSize, (TAny*)clientTest);
			clientInfo.SetPaging(TThreadCreateInfo::EPaged);
			clientInfo.SetCreateHeap(KHeapMinSize, KHeapMaxSize);
			RThread clientThread;
			test_KErrNone(clientThread.Create(clientInfo));

			TRequestStatus clientStat;
			clientThread.Logon(clientStat);
			clientThread.Resume();

			// Wait for the client thread to end.
			User::WaitForRequest(clientStat);

			// If all the descriptor arguments were not pinned then the client 
			// thread should have been panicked.
			TBool expectPanic = (clientTest == CTestSession::ETestRdPinAll || 
								clientTest == CTestSession::ETestWrPinAll ||
								clientTest == CTestSession::ETestPinOOM )? 0 : 1;
			expectPanic = !UpdateExpected(!expectPanic);

			TInt exitReason = clientThread.ExitReason();
			TInt exitType = clientThread.ExitType();
			if (expectPanic)
				{
				if (exitType != EExitPanic || 
					exitReason != EIllegalFunctionForRealtimeThread ||
					clientThread.ExitCategory() != _L("KERN-EXEC"))
					{
					test.Printf(_L("Thread didn't panic as expected\n"));
					exitFailure = ETrue;
					}
				}
			else
				{
				if (exitType != EExitKill || exitReason != KErrNone)
					{
					test.Printf(_L("Thread didn't exit gracefully as expected\n"));
					exitFailure = ETrue;
					}
				}
			test(!exitFailure);
			CLOSE_AND_WAIT(clientThread);
			}

		test.Next(_L("Test client sending message to closed server"));
		TThreadCreateInfo clientInfo(_L("Client Thread"), ClientThread, 10 * gPageSize, (TAny*)CTestSession::ETestDeadServer);
		clientInfo.SetPaging(TThreadCreateInfo::EPaged);
		clientInfo.SetCreateHeap(KHeapMinSize, KHeapMaxSize);
		RThread clientThread;
		test_KErrNone(clientThread.Create(clientInfo));
		TRequestStatus clientStat;
		clientThread.Logon(clientStat);
		clientThread.Resume();
		gSem.Wait();
		
		// Signal to stop ActiveScheduler and wait for server to stop.
		session.PublicSendReceive(CTestSession::EStop, TIpcArgs());
		session.Close();
		User::WaitForRequest(serverStat);
		if (serverThread.ExitType() != EExitKill)
			{
			test.Printf(_L("!!Server thread did something bizarre %d\n"), serverThread.ExitReason());
			}

		gSem1.Signal();
		User::WaitForRequest(clientStat);
		test_Equal(EExitKill, clientThread.ExitType());
		test_Equal(KErrServerTerminated, clientThread.ExitReason());

		CLOSE_AND_WAIT(clientThread);
		CLOSE_AND_WAIT(serverThread);
		CLOSE_AND_WAIT(gSem);
		CLOSE_AND_WAIT(gSem1);
		}

	test.Next(_L("Test server setting pinning policy after server started"));
	RThread serverThread;
	test_KErrNone(serverThread.Create(_L("Server Thread"),ServerThread,KDefaultStackSize,KHeapMinSize,KHeapMaxSize, (TAny*)gServerPinningState));
	TRequestStatus serverStat;
	serverThread.Logon(serverStat);
	serverThread.Resume();
	// The server should have panicked with E32USER-CBase 106.
	User::WaitForRequest(serverStat);
	TInt exitReason = serverThread.ExitReason();
	TInt exitType = serverThread.ExitType();
	test_Equal(EExitPanic, exitType);
	test_Equal(ECServer2InvalidSetPin, exitReason);
	if (_L("E32USER-CBase") != serverThread.ExitCategory())
		test(0);
	CLOSE_AND_WAIT(serverThread);

	test.End();

	// Set JIT back to original state.
	User::SetJustInTime(justInTime);

	return (KErrNone);
	}