1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/boardsupport/emulator/emulatorbsp/specific/sdcard/sdcard3c/sdio/pp_sdio.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,181 @@
1.4 +// Copyright (c) 2000-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 "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 +// PP_SDC.H
1.18 +//
1.19 +//
1.20 +
1.21 +#ifndef __PP_SDC_H__
1.22 +#define __PP_SDC_H__
1.23 +#if defined(_UNICODE) && !defined(UNICODE)
1.24 + #define UNICODE
1.25 +#endif
1.26 +
1.27 +#include <sdiocard.h>
1.28 +#include <emulator.h>
1.29 +
1.30 +GLREF_C TInt MapLastErrorEpoc();
1.31 +GLREF_C TMMCErr MapLastErrorMmc();
1.32 +
1.33 +const TInt KMediaChangeTickInterval=20000; // Units 1uS
1.34 +
1.35 +const TInt KTotalWinsCardSlots=2;
1.36 +const TInt KTotalWinsCards=(KTotalWinsCardSlots+1); // Need 2 cards for slot 0
1.37 +
1.38 +const TUint32 KMMCWinsCardOCRValue = 0x00FFFF00;
1.39 +
1.40 +const TInt KSDMediaAreasPerCard = 3;
1.41 +const TInt KSDUserArea = 0;
1.42 +const TInt KSDProtectedArea = 1;
1.43 +const TInt KSDIOArea = 2;
1.44 +
1.45 +const TUint32 KWinsSdioFunctionCount = 3;
1.46 +const TUint8 KWinsSdioFunctionMask = 0x0A; /** TODO: Non-Contuguous functions not yet supported */
1.47 +const TBool KWinsSdioMemoryPresent = ETrue;
1.48 +
1.49 +const TUint32 KFunctionEnableDelay_uS = 1000000; // 1S Second Function Enable Delay
1.50 +
1.51 +
1.52 +class TWinsCardInfo
1.53 + {
1.54 +public:
1.55 + void GetCSD(TUint8* aResp) const;
1.56 +public:
1.57 + TCID iCID;
1.58 + TMediaPassword* iPWD; // PWD_LEN calculated from PWD.
1.59 + TBool iIsLocked; // Could use iCurrentCardIsLocked
1.60 + TMMCardStateEnum iState; // Simulation of card's current state
1.61 + HANDLE iAreaHandles[KSDMediaAreasPerCard];
1.62 + TRCA iRCA;
1.63 + TBool iIsSDCard;
1.64 + TInt iBusWidth;
1.65 + };
1.66 +
1.67 +class DWinsSDIOStack : public DSDIOStack
1.68 + {
1.69 +private:
1.70 + DWinsSDIOStack(TInt aBus, DMMCSocket* aSocket);
1.71 + TInt Init();
1.72 +private:
1.73 + virtual void MachineInfo(TMMCMachineInfo& aMachineInfo);
1.74 +public:
1.75 + virtual void AdjustPartialRead(const TMMCard* aCard, TUint32 aStart, TUint32 aEnd, TUint32* aPhysStart, TUint32* aPhysEnd) const;
1.76 + virtual void GetBufferInfo(TUint8** aMDBuf, TInt* aMDBufLen);
1.77 + virtual void AddressCard(TInt aCardNumber);
1.78 +
1.79 + enum TWinsMMCPanic
1.80 + {
1.81 + EWinsMMCLidOpenIntBind=0,
1.82 + EWinsMMCBadMachineInfo=1,
1.83 + EWinsMMCMediaChangeTickFault = 2,
1.84 + EWinsMMCCorruptCommand = 3,
1.85 + EWinsMMCLockAttempt = 4,
1.86 + EWinsMMCAPRNotSupp = 5,
1.87 + EWinsMMCAPRRange = 6,
1.88 + EWinsMMCAPRBoundary = 7,
1.89 +
1.90 + EStkFFCNotSelCard = 0x010, EStkFFCNoneSel,
1.91 + EStkFOCNotSelCard = 0x020, EStkFOCMultiSel, EStkFOCNoneSel,
1.92 + EStkIMCBadStateCmd2 = 0x30, EStkIMCBadStateCmd3, EStkIMCCmd6InvalidWidth,
1.93 + EStkICMACMD13NotSD, EStkICMACMD22NotSD,
1.94 + };
1.95 + static void Panic(TWinsMMCPanic aPanic);
1.96 +
1.97 + static TInt AccessIoEnable (TInt aTargetCard, TInt aVal, TAny* aSelfP, TBool aRead, TUint8& aData);
1.98 + static TInt AccessCsaWindow (TInt aTargetCard, TInt aVal, TAny* aSelfP, TBool aRead, TUint8& aData);
1.99 + static TInt AccessCsaPointer(TInt aTargetCard, TInt aVal, TAny* aSelfP, TBool aRead, TUint8& aData);
1.100 +
1.101 +private:
1.102 + // Stack service provided by ASSP layer
1.103 + void SetBusConfigDefaults(TMMCBusConfig&, TUint aClock);
1.104 + void InitClockOff();
1.105 + void ASSPReset();
1.106 + void ASSPDisengage();
1.107 + void DoPowerDown();
1.108 + // State Machine functions implemented in ASSP layer
1.109 + TMMCErr DoPowerUpSM();
1.110 + TMMCErr InitClockOnSM();
1.111 + TMMCErr IssueMMCCommandSM();
1.112 +
1.113 + void EnableSDIOInterrupt(TBool aEnable);
1.114 + void SetBusWidth(TUint32 aBusWidth);
1.115 + TUint32 MaxBlockSize() const;
1.116 +
1.117 +
1.118 +private:
1.119 + TInt SetupSimulatedCard(TInt aCardNum); // init
1.120 + TInt CreateBinFileForCard(TInt aCardNum, TInt aAreaNum, HANDLE* aHandle);
1.121 + TInt GetTargetSlotNumber(const TRCA& anRCA);
1.122 + TInt FindAnyCardInStack(TMMCardStateEnum aState);
1.123 + TInt FindFirstCardInStack(TMMCardStateEnum aState);
1.124 + TInt FindOneCardInStack(TMMCardStateEnum aState);
1.125 +
1.126 + static void EnableTimerCallback(TAny* aPtr);
1.127 +
1.128 +private:
1.129 + TWinsCardInfo* iCardPool[KTotalWinsCards]; // all cards
1.130 + TWinsCardInfo* iCardInfo[KTotalWinsCardSlots]; // present cards
1.131 + TInt iAddressedCard;
1.132 + TBool iCMD42Failed;
1.133 + TInt iMBWOKBlocks;
1.134 + TUint8* iMDBuf;
1.135 + TInt iMDBufLen;
1.136 +
1.137 + NTimer iEnableTimer;
1.138 +
1.139 + friend class TSDCardControllerInterfaceWins;
1.140 + friend class DWinsMMCMediaChange;
1.141 + };
1.142 +
1.143 +class DWinsMMCMediaChange : public DMMCMediaChange
1.144 + {
1.145 +public:
1.146 + DWinsMMCMediaChange(TInt aMediaChangeNum);
1.147 + virtual TInt Create();
1.148 + virtual void ForceMediaChange();
1.149 + virtual void DoDoorOpen();
1.150 + virtual void DoDoorClosed();
1.151 + virtual TMediaState MediaState();
1.152 +protected:
1.153 + void DoorOpenService();
1.154 +private:
1.155 + static TInt MediaChangeDfc(TAny *aPtr);
1.156 + static void Tick(TAny *aPtr);
1.157 + void TickService();
1.158 + void Enable();
1.159 + void Disable();
1.160 + static void MediaChangeCallBack(TAny *aPtr);
1.161 + inline void SetStackP(DWinsSDIOStack* aStackP) {iStackP=aStackP;}
1.162 +private:
1.163 + TTickLink iTickLink;
1.164 + TInt iDoorClosedCount;
1.165 + TBool iMediaChangeEnable;
1.166 + TInt iMediaDoorCloseReload; // Units: In theory-20ms, Actual-100ms
1.167 + DWinsSDIOStack* iStackP;
1.168 + friend class DWinsSDIOStack;
1.169 + };
1.170 +
1.171 +class DWinsSDIOPsu : public DSDIOPsu
1.172 + {
1.173 +public:
1.174 + DWinsSDIOPsu(TInt aVccNum, TInt aMcId);
1.175 + virtual void Init();
1.176 + virtual void DoSetState(TPBusPsuState aState);
1.177 + virtual TInt VoltageInMilliVolts();
1.178 +private:
1.179 + virtual void DoCheckVoltage();
1.180 + virtual void PsuInfo(TPBusPsuInfo &anInfo);
1.181 + };
1.182 +
1.183 +
1.184 +#endif // #ifndef __PP_SDC_H__