os/kernelhwsrv/kernel/eka/drivers/pbus/pccard/epoc/pccd_medchg.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/drivers/pbus/pccard/epoc/pccd_medchg.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,102 @@
     1.4 +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32\drivers\pbus\pccard\epoc\pccd_medchg.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include <pccd_medchg.h>
    1.22 +
    1.23 +DPlatPcCardMediaChange::DPlatPcCardMediaChange(TInt aMediaChangeNum)
    1.24 +//
    1.25 +// Constructor
    1.26 +//
    1.27 +	:	DPcCardMediaChange(aMediaChangeNum),
    1.28 +		iDelayCallBack(DelayCallBack,this)
    1.29 +	{
    1.30 +    }
    1.31 +
    1.32 +TInt DPlatPcCardMediaChange::Create()
    1.33 +//
    1.34 +// Initialiser.
    1.35 +//
    1.36 +	{
    1.37 +
    1.38 +	TInt r=DPcCardMediaChange::Create();
    1.39 +	if (r==KErrNone)
    1.40 +		{
    1.41 +		iMedChgIntId=ThePccdCntrlInterface->IntIdMediaChange(iMediaChangeNum);
    1.42 +		r=Interrupt::Bind(iMedChgIntId,Isr,this);
    1.43 +		}
    1.44 +	__KTRACE_OPT(KPBUS1,Kern::Printf("<PlatMedCh:Init(M:%d)-%d",iMediaChangeNum,r));
    1.45 +	return(r);
    1.46 +	}
    1.47 +
    1.48 +void DPlatPcCardMediaChange::Isr(TAny *aPtr)
    1.49 +//
    1.50 +// Handle the media change (this function, never postponed is called on media
    1.51 +// change interrupt). 
    1.52 +//
    1.53 +	{
    1.54 +	__KTRACE_OPT(KFAIL,Kern::Printf("!^"));
    1.55 +	DPlatPcCardMediaChange* pM=(DPlatPcCardMediaChange*)aPtr;
    1.56 +	Interrupt::Disable(pM->iMedChgIntId);
    1.57 +	ThePccdCntrlInterface->ClearMediaChange(pM->iMediaChangeNum);
    1.58 +	pM->DoorOpenService();
    1.59 +	}
    1.60 +
    1.61 +void DPlatPcCardMediaChange::DelayCallBack(TAny *aPtr)
    1.62 +//
    1.63 +// Timer callback after media change
    1.64 +//
    1.65 +	{
    1.66 +	DPlatPcCardMediaChange* pM=(DPlatPcCardMediaChange*)aPtr;
    1.67 +	pM->DoorClosedService();
    1.68 +	}
    1.69 +
    1.70 +void DPlatPcCardMediaChange::ForceMediaChange()
    1.71 +	{
    1.72 +	Interrupt::Disable(iMedChgIntId);
    1.73 +	ThePccdCntrlInterface->ClearMediaChange(iMediaChangeNum);
    1.74 +	DoorOpenService();
    1.75 +	}
    1.76 +
    1.77 +void DPlatPcCardMediaChange::DoDoorOpen()
    1.78 +//
    1.79 +// Called after media change has been recognised
    1.80 +//
    1.81 +	{
    1.82 +
    1.83 +	__KTRACE_OPT(KPBUS2,Kern::Printf(">PlatMedCh(%d):DoDoorOpen",iMediaChangeNum));
    1.84 +    iDelayCallBack.OneShot(NKern::TimerTicks(20),ETrue);
    1.85 +	}
    1.86 +
    1.87 +void DPlatPcCardMediaChange::DoDoorClosed()
    1.88 +//
    1.89 +// Handle the media door closing (called on tick).
    1.90 +//
    1.91 +	{
    1.92 +
    1.93 +	ThePccdCntrlInterface->ClearMediaChange(iMediaChangeNum);
    1.94 +	Interrupt::Enable(iMedChgIntId);
    1.95 +	}
    1.96 +
    1.97 +TMediaState DPlatPcCardMediaChange::MediaState()
    1.98 +//
    1.99 +// Return status of media changed signal.
   1.100 +//
   1.101 +	{
   1.102 +
   1.103 +	return ThePccdCntrlInterface->MediaState(iMediaChangeNum);
   1.104 +	}
   1.105 +