Esempio n. 1
0
void DmacSim::StartEmulation()
	{
	__DMA_ASSERTA(StartStop==EDmaSimIdle);
	new (&Timer) NTimer(&TickCB, 0);
	__e32_atomic_store_ord32(&StartStop, EDmaSimStarted);
	__DMA_ASSERTA(Timer.OneShot(KPeriod, EFalse) == KErrNone);
	}
TInt DExampleChannel::StartAsyncGetValue(TInt* aValue, TRequestStatus* aStatus)
{
    iAsyncGetValueDest = aValue;
    iAsyncGetValueStatus = aStatus;

    // queue a timer to simulate an asynchronous operation
    iAsyncGetValueTimer.OneShot(KAsyncDelay, iAsyncGetValueDfc);
    return KErrNone;
}
TInt DExampleChannel::StartAsyncGetValue2(TInt* aValue1, TInt* aValue2, TRequestStatus* aStatus)
{
    iAsyncGetValue2Dest1 = aValue1;
    iAsyncGetValue2Dest2 = aValue2;
    iAsyncGetValue2Status = aStatus;

    // queue a timer to simulate an asynchronous operation
    iAsyncGetValue2Timer.OneShot(KAsyncDelay, iAsyncGetValue2Dfc);
    return KErrNone;
}
Esempio n. 4
0
TInt DBMLChannel::RequestNTimerJitterInterrupt()
	{
	if (!iStarted)
		{
		return KErrNotReady;
		}
	if (iPendingInterruptRequest) 
		{
		return KErrInUse;
		}
	iPendingInterruptRequest = ETrue;
	iNTimerShotCount = 0;
	iNTimer.OneShot(1);
	return KErrNone;
	}
Esempio n. 5
0
void DmacSim::TickCB(TAny*)
	{
	TInt orig = (TInt)__e32_atomic_ior_acq32(&StartStop, EDmaSimInISR);
	if (orig >= 0)
		{
		DmacSb::DoTransfer();
		DmacDb::DoTransfer();
		DmacSg::DoTransfer();
		}
	orig = (TInt)__e32_atomic_and_rel32(&StartStop, (TUint32)~EDmaSimInISR);
	if (orig < 0)
		{
		__e32_atomic_store_rel32(&StartStop, EDmaSimIdle);
		return;
		}
	TInt r = Timer.Again(KPeriod);
	if (r == KErrArgument)
		r = Timer.OneShot(KPeriod);
	__DMA_ASSERTA(r == KErrNone);
	}
void DExampleChannel::SendFromWriteBuffer()
{
    // just queue a timer to simulate an asynchronous send operation
    iWriteTimer.OneShot(KAsyncDelay, iCompleteWriteDfc);
}
void DExampleChannel::ReceiveToReadBuffer()
{
    // just queue a timer to simulate an asynchronous receive operation
    // actually will return the previous contents of the buffer
    iReadTimer.OneShot(KAsyncDelay, iCompleteReadDfc);
}
Esempio n. 8
0
TInt DNE1Keypad::DoCreate()
	{
	iKeyboardTimer.OneShot(KKeybPollTime, ETrue);
	return KErrNone;
	}
Esempio n. 9
0
TInt DPowerManager::PowerDown()
	{ // called by ExecHandler 
	__KTRACE_OPT(KPOWER,Kern::Printf(">PowerManger::PowerDown(0x%x) Enter", iPowerController->iTargetState));
	__ASSERT_CRITICAL;

	Lock();


	if (iPowerController->iTargetState == EPwActive)
		{
		Unlock();
		return KErrNotReady;
		}

    __PM_ASSERT(iHandlers);
	NFastSemaphore shutdownSem(0);
	NTimer ntimer;
	TDfc dfc(ShutDownTimeoutFn, &shutdownSem);
#ifndef _DEBUG_POWER	
	iPendingShutdownCount = 0;
#endif	
	DPowerHandler* ph = iHandlers;
	//Power down in reverse order of handle registration.
	do
		{
#ifdef _DEBUG_POWER
		__PM_ASSERT(!(ph->iStatus & DPowerHandler::EDone));
#endif
		ph->iSem = &shutdownSem; 
		ph->PowerDown(iPowerController->iTargetState);
#ifndef _DEBUG_POWER		
		iPendingShutdownCount++; 
#else
		if(iPslShutdownTimeoutMs>0)
			{
		    // Fire shut down timeout timer			
			ntimer.OneShot(iPslShutdownTimeoutMs, dfc);
			}

		NKern::FSWait(&shutdownSem);	// power down drivers one after another to simplify debug
		__e32_atomic_and_ord32(&(ph->iStatus), ~DPowerHandler::EDone);

		// timeout condition
		if(iPslShutdownTimeoutMs>0 && ph->iSem)
			{
			__e32_atomic_store_ord_ptr(&ph->iSem, 0);
			}
		ntimer.Cancel();
#endif		
		ph = ph->iPrev;
		}while(ph != iHandlers);

#ifndef _DEBUG_POWER
	if(iPslShutdownTimeoutMs>0)
		{
		// Fire shut down timeout timer
		ntimer.OneShot(iPslShutdownTimeoutMs, dfc);
		}

	ph = iHandlers;
	do
		{
		NKern::FSWait(&shutdownSem);
		if(__e32_atomic_load_acq32(&iPendingShutdownCount)==ESHUTDOWN_TIMEOUT)
			{
			iPendingShutdownCount = 0;
			NKern::Lock();
			shutdownSem.Reset(); // iPendingShutdownCount could be altered while ShutDownTimeoutFn is running
		       			     // reset it to make sure shutdownSem is completely clean.	
			NKern::Unlock();
			break;
			}
		__e32_atomic_add_ord32(&iPendingShutdownCount, (TUint)(~0x0)); // iPendingShutDownCount--;
		ph = ph->iPrev;
		}while(ph != iHandlers);

	ntimer.Cancel();
	
#endif

	TTickQ::Wait();

	iPowerController->PowerDown(K::SecondQ->WakeupTime());
	__PM_ASSERT(iPowerController->iTargetState != EPwOff);
	iPowerController->iTargetState = EPwActive;

	K::SecondQ->WakeUp();
	TTickQ::Signal();

	NFastSemaphore powerupSem(0);

	ph = iHandlers->iNext;
	//Power up in same order of handle registration.
	do
		{
#ifdef _DEBUG_POWER
		__PM_ASSERT(!(ph->iStatus & DPowerHandler::EDone));
#endif
		ph->iSem = &powerupSem;
		ph->PowerUp();
#ifdef _DEBUG_POWER
		NKern::FSWait(&powerupSem);	// power down drivers one after another to simplify debug
		__PM_ASSERT(!ph->iSem);
		__PM_ASSERT(ph->iStatus & DPowerHandler::EDone);
		ph->iStatus &= ~DPowerHandler::EDone;
#endif
		ph = ph->iNext;
		}while(ph != iHandlers->iNext);

#ifndef _DEBUG_POWER
	ph = iHandlers->iNext;
	do
		{
		NKern::FSWait(&powerupSem);
		ph = ph->iNext;
		}while(ph != iHandlers->iNext);
#endif

	// complete wakeup notification request if any
	NotifyWakeupEvent(KErrNone); 

	Unlock();

	__KTRACE_OPT(KPOWER,Kern::Printf("<PowerManger::PowerDown() Leave"));

	return KErrNone;
	}