sl@0: // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // PP_SDC.H sl@0: // sl@0: // sl@0: sl@0: #ifndef __PP_SDC_H__ sl@0: #define __PP_SDC_H__ sl@0: #if defined(_UNICODE) && !defined(UNICODE) sl@0: #define UNICODE sl@0: #endif sl@0: sl@0: #include sl@0: #include sl@0: sl@0: GLREF_C TInt MapLastErrorEpoc(); sl@0: GLREF_C TMMCErr MapLastErrorMmc(); sl@0: sl@0: const TInt KMediaChangeTickInterval=20000; // Units 1uS sl@0: sl@0: const TInt KTotalWinsCardSlots=2; sl@0: const TInt KTotalWinsCards=(KTotalWinsCardSlots+1); // Need 2 cards for slot 0 sl@0: sl@0: const TUint32 KMMCWinsCardOCRValue = 0x00FFFF00; sl@0: sl@0: const TInt KSDMediaAreasPerCard = 3; sl@0: const TInt KSDUserArea = 0; sl@0: const TInt KSDProtectedArea = 1; sl@0: const TInt KSDIOArea = 2; sl@0: sl@0: const TUint32 KWinsSdioFunctionCount = 3; sl@0: const TUint8 KWinsSdioFunctionMask = 0x0A; /** TODO: Non-Contuguous functions not yet supported */ sl@0: const TBool KWinsSdioMemoryPresent = ETrue; sl@0: sl@0: const TUint32 KFunctionEnableDelay_uS = 1000000; // 1S Second Function Enable Delay sl@0: sl@0: sl@0: class TWinsCardInfo sl@0: { sl@0: public: sl@0: void GetCSD(TUint8* aResp) const; sl@0: public: sl@0: TCID iCID; sl@0: TMediaPassword* iPWD; // PWD_LEN calculated from PWD. sl@0: TBool iIsLocked; // Could use iCurrentCardIsLocked sl@0: TMMCardStateEnum iState; // Simulation of card's current state sl@0: HANDLE iAreaHandles[KSDMediaAreasPerCard]; sl@0: TRCA iRCA; sl@0: TBool iIsSDCard; sl@0: TInt iBusWidth; sl@0: }; sl@0: sl@0: class DWinsSDIOStack : public DSDIOStack sl@0: { sl@0: private: sl@0: DWinsSDIOStack(TInt aBus, DMMCSocket* aSocket); sl@0: TInt Init(); sl@0: private: sl@0: virtual void MachineInfo(TMMCMachineInfo& aMachineInfo); sl@0: public: sl@0: virtual void AdjustPartialRead(const TMMCard* aCard, TUint32 aStart, TUint32 aEnd, TUint32* aPhysStart, TUint32* aPhysEnd) const; sl@0: virtual void GetBufferInfo(TUint8** aMDBuf, TInt* aMDBufLen); sl@0: virtual void AddressCard(TInt aCardNumber); sl@0: sl@0: enum TWinsMMCPanic sl@0: { sl@0: EWinsMMCLidOpenIntBind=0, sl@0: EWinsMMCBadMachineInfo=1, sl@0: EWinsMMCMediaChangeTickFault = 2, sl@0: EWinsMMCCorruptCommand = 3, sl@0: EWinsMMCLockAttempt = 4, sl@0: EWinsMMCAPRNotSupp = 5, sl@0: EWinsMMCAPRRange = 6, sl@0: EWinsMMCAPRBoundary = 7, sl@0: sl@0: EStkFFCNotSelCard = 0x010, EStkFFCNoneSel, sl@0: EStkFOCNotSelCard = 0x020, EStkFOCMultiSel, EStkFOCNoneSel, sl@0: EStkIMCBadStateCmd2 = 0x30, EStkIMCBadStateCmd3, EStkIMCCmd6InvalidWidth, sl@0: EStkICMACMD13NotSD, EStkICMACMD22NotSD, sl@0: }; sl@0: static void Panic(TWinsMMCPanic aPanic); sl@0: sl@0: static TInt AccessIoEnable (TInt aTargetCard, TInt aVal, TAny* aSelfP, TBool aRead, TUint8& aData); sl@0: static TInt AccessCsaWindow (TInt aTargetCard, TInt aVal, TAny* aSelfP, TBool aRead, TUint8& aData); sl@0: static TInt AccessCsaPointer(TInt aTargetCard, TInt aVal, TAny* aSelfP, TBool aRead, TUint8& aData); sl@0: sl@0: private: sl@0: // Stack service provided by ASSP layer sl@0: void SetBusConfigDefaults(TMMCBusConfig&, TUint aClock); sl@0: void InitClockOff(); sl@0: void ASSPReset(); sl@0: void ASSPDisengage(); sl@0: void DoPowerDown(); sl@0: // State Machine functions implemented in ASSP layer sl@0: TMMCErr DoPowerUpSM(); sl@0: TMMCErr InitClockOnSM(); sl@0: TMMCErr IssueMMCCommandSM(); sl@0: sl@0: void EnableSDIOInterrupt(TBool aEnable); sl@0: void SetBusWidth(TUint32 aBusWidth); sl@0: TUint32 MaxBlockSize() const; sl@0: sl@0: sl@0: private: sl@0: TInt SetupSimulatedCard(TInt aCardNum); // init sl@0: TInt CreateBinFileForCard(TInt aCardNum, TInt aAreaNum, HANDLE* aHandle); sl@0: TInt GetTargetSlotNumber(const TRCA& anRCA); sl@0: TInt FindAnyCardInStack(TMMCardStateEnum aState); sl@0: TInt FindFirstCardInStack(TMMCardStateEnum aState); sl@0: TInt FindOneCardInStack(TMMCardStateEnum aState); sl@0: sl@0: static void EnableTimerCallback(TAny* aPtr); sl@0: sl@0: private: sl@0: TWinsCardInfo* iCardPool[KTotalWinsCards]; // all cards sl@0: TWinsCardInfo* iCardInfo[KTotalWinsCardSlots]; // present cards sl@0: TInt iAddressedCard; sl@0: TBool iCMD42Failed; sl@0: TInt iMBWOKBlocks; sl@0: TUint8* iMDBuf; sl@0: TInt iMDBufLen; sl@0: sl@0: NTimer iEnableTimer; sl@0: sl@0: friend class TSDCardControllerInterfaceWins; sl@0: friend class DWinsMMCMediaChange; sl@0: }; sl@0: sl@0: class DWinsMMCMediaChange : public DMMCMediaChange sl@0: { sl@0: public: sl@0: DWinsMMCMediaChange(TInt aMediaChangeNum); sl@0: virtual TInt Create(); sl@0: virtual void ForceMediaChange(); sl@0: virtual void DoDoorOpen(); sl@0: virtual void DoDoorClosed(); sl@0: virtual TMediaState MediaState(); sl@0: protected: sl@0: void DoorOpenService(); sl@0: private: sl@0: static TInt MediaChangeDfc(TAny *aPtr); sl@0: static void Tick(TAny *aPtr); sl@0: void TickService(); sl@0: void Enable(); sl@0: void Disable(); sl@0: static void MediaChangeCallBack(TAny *aPtr); sl@0: inline void SetStackP(DWinsSDIOStack* aStackP) {iStackP=aStackP;} sl@0: private: sl@0: TTickLink iTickLink; sl@0: TInt iDoorClosedCount; sl@0: TBool iMediaChangeEnable; sl@0: TInt iMediaDoorCloseReload; // Units: In theory-20ms, Actual-100ms sl@0: DWinsSDIOStack* iStackP; sl@0: friend class DWinsSDIOStack; sl@0: }; sl@0: sl@0: class DWinsSDIOPsu : public DSDIOPsu sl@0: { sl@0: public: sl@0: DWinsSDIOPsu(TInt aVccNum, TInt aMcId); sl@0: virtual void Init(); sl@0: virtual void DoSetState(TPBusPsuState aState); sl@0: virtual TInt VoltageInMilliVolts(); sl@0: private: sl@0: virtual void DoCheckVoltage(); sl@0: virtual void PsuInfo(TPBusPsuInfo &anInfo); sl@0: }; sl@0: sl@0: sl@0: #endif // #ifndef __PP_SDC_H__