os/kernelhwsrv/kernel/eka/drivers/pbus/pccard/epoc/pccd_medchg.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 1995-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 the License "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 // e32\drivers\pbus\pccard\epoc\pccd_medchg.cpp
    15 // 
    16 //
    17 
    18 #include <pccd_medchg.h>
    19 
    20 DPlatPcCardMediaChange::DPlatPcCardMediaChange(TInt aMediaChangeNum)
    21 //
    22 // Constructor
    23 //
    24 	:	DPcCardMediaChange(aMediaChangeNum),
    25 		iDelayCallBack(DelayCallBack,this)
    26 	{
    27     }
    28 
    29 TInt DPlatPcCardMediaChange::Create()
    30 //
    31 // Initialiser.
    32 //
    33 	{
    34 
    35 	TInt r=DPcCardMediaChange::Create();
    36 	if (r==KErrNone)
    37 		{
    38 		iMedChgIntId=ThePccdCntrlInterface->IntIdMediaChange(iMediaChangeNum);
    39 		r=Interrupt::Bind(iMedChgIntId,Isr,this);
    40 		}
    41 	__KTRACE_OPT(KPBUS1,Kern::Printf("<PlatMedCh:Init(M:%d)-%d",iMediaChangeNum,r));
    42 	return(r);
    43 	}
    44 
    45 void DPlatPcCardMediaChange::Isr(TAny *aPtr)
    46 //
    47 // Handle the media change (this function, never postponed is called on media
    48 // change interrupt). 
    49 //
    50 	{
    51 	__KTRACE_OPT(KFAIL,Kern::Printf("!^"));
    52 	DPlatPcCardMediaChange* pM=(DPlatPcCardMediaChange*)aPtr;
    53 	Interrupt::Disable(pM->iMedChgIntId);
    54 	ThePccdCntrlInterface->ClearMediaChange(pM->iMediaChangeNum);
    55 	pM->DoorOpenService();
    56 	}
    57 
    58 void DPlatPcCardMediaChange::DelayCallBack(TAny *aPtr)
    59 //
    60 // Timer callback after media change
    61 //
    62 	{
    63 	DPlatPcCardMediaChange* pM=(DPlatPcCardMediaChange*)aPtr;
    64 	pM->DoorClosedService();
    65 	}
    66 
    67 void DPlatPcCardMediaChange::ForceMediaChange()
    68 	{
    69 	Interrupt::Disable(iMedChgIntId);
    70 	ThePccdCntrlInterface->ClearMediaChange(iMediaChangeNum);
    71 	DoorOpenService();
    72 	}
    73 
    74 void DPlatPcCardMediaChange::DoDoorOpen()
    75 //
    76 // Called after media change has been recognised
    77 //
    78 	{
    79 
    80 	__KTRACE_OPT(KPBUS2,Kern::Printf(">PlatMedCh(%d):DoDoorOpen",iMediaChangeNum));
    81     iDelayCallBack.OneShot(NKern::TimerTicks(20),ETrue);
    82 	}
    83 
    84 void DPlatPcCardMediaChange::DoDoorClosed()
    85 //
    86 // Handle the media door closing (called on tick).
    87 //
    88 	{
    89 
    90 	ThePccdCntrlInterface->ClearMediaChange(iMediaChangeNum);
    91 	Interrupt::Enable(iMedChgIntId);
    92 	}
    93 
    94 TMediaState DPlatPcCardMediaChange::MediaState()
    95 //
    96 // Return status of media changed signal.
    97 //
    98 	{
    99 
   100 	return ThePccdCntrlInterface->MediaState(iMediaChangeNum);
   101 	}
   102