TInt DExampleChannel::DoCancel(TUint /*aMask*/)
{
    if (iAsyncGetValueStatus)
    {
        iAsyncGetValueTimer.Cancel();
        iAsyncGetValueDfc.Cancel();
        Kern::RequestComplete(iClient, iAsyncGetValueStatus, KErrCancel);
    }

    if (iAsyncGetValue2Status)
    {
        iAsyncGetValue2Timer.Cancel();
        iAsyncGetValue2Dfc.Cancel();
        Kern::RequestComplete(iClient, iAsyncGetValue2Status, KErrCancel);
    }

    if (iReadStatus)
    {
        iReadTimer.Cancel();
        iCompleteReadDfc.Cancel();
        Kern::RequestComplete(iClient, iReadStatus, KErrCancel);
    }

    if (iWriteStatus)
    {
        iWriteTimer.Cancel();
        iCompleteWriteDfc.Cancel();
        Kern::RequestComplete(iClient, iWriteStatus, KErrCancel);
    }

    return KErrNone;
}
Beispiel #2
0
TInt DMediaDriverFlashWin32::DoRead()
	{
	if (iWriteReq)
		return 1;	// write in progress so defer read
	
	__KTRACE_OPT(KLOCDRV,Kern::Printf("Flash:DoRead"));

	if (iState==EErasePending)
		{
		iTimer.Cancel();
		iState = ESuspended;
		}
	if (iState==EIdle || iState==ESuspended)
		{
		// can do the read now
		TInt pos=(TInt)iReadReq->Pos();
		TInt len=(TInt)iReadReq->Length();

		TPtrC8 des(iBase+pos,len);
		TInt r=iReadReq->WriteRemote(&des,0);
		Complete(EReqRead,r);
		if (iState==ESuspended)
			StartErase();
		}
	else if (iState==EErase)
		{
		// erase in progress - suspend it
		SuspendErase();
		}
	else if (iState==EEraseNoSuspend)
		iState=ESuspendPending;
	// wait for suspend to complete
	return KErrNone;
	}
Beispiel #3
0
TInt DMediaDriverFlashWin32::DoWrite()
	{
	if (iReadReq)
		return 1;	// read in progress so defer write

	if (iState==EErasePending)
		{
		iTimer.Cancel();
		iState = ESuspended;
		}
	if (iState==EIdle || iState==ESuspended)
		{
		// can start the write now
		__KTRACE_OPT(KLOCDRV,Kern::Printf("Flash:Write Pos=%08x Length=%08x RemDesOff=%08x",
											(TInt)iWriteReq->Pos(),(TInt)iWriteReq->Length(),iWriteReq->RemoteDesOffset()));
		if (iState==EIdle)
			iState=EWriting;
		TInt pos = (TInt)iWriteReq->Pos();
		TInt end = pos + (TInt)iWriteReq->Length();
		pos &= ~(iWriteBlockSize-1);
		end = (end + iWriteBlockSize-1) & ~(iWriteBlockSize-1);
		StartTimer(((end-pos)/iWriteBlockSize) * iWriteTime);
		}
	else if (iState==EErase)
		{
		// erase in progress - suspend it
		SuspendErase();
		}
	else if (iState==EEraseNoSuspend)
		iState=ESuspendPending;
	// wait for suspend to complete
	return KErrNone;
	}
Beispiel #4
0
void DmacSim::StopEmulation()
	{
	TInt orig = __e32_atomic_tas_ord32(&StartStop, (TInt)EDmaSimStarted, (TInt)EDmaSimStopping, 0);
	if (orig == EDmaSimIdle)
		return;		// wasn't running
	// loop until we succeed in cancelling the timer or the timer callback
	// notices that we are shutting down
	while (!Timer.Cancel() && __e32_atomic_load_acq32(&StartStop)!=EDmaSimIdle)
		{}
	__e32_atomic_store_ord32(&StartStop, EDmaSimIdle);
	}
Beispiel #5
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;
	}