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