os/boardsupport/emulator/emulatorbsp/specific/mmci.h
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) 2000-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 "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 // PP_MMC.H
    15 // 
    16 //
    17 
    18 #ifndef __PP_MMC_H__
    19 
    20 #if defined(_UNICODE) && !defined(UNICODE)
    21 	#define UNICODE
    22 #endif
    23 
    24 #include <mmc.h>
    25 #include <emulator.h>
    26 
    27 //	MultiMedia Card Controller - platform specific layer.
    28 
    29 GLREF_C TInt MapLastErrorEpoc();
    30 GLREF_C TMMCErr MapLastErrorMmc();
    31 
    32 const TInt KMediaChangeTickInterval=20000;	// Units 1uS
    33 
    34 
    35 const TInt KMax_TotalWinsCardSlots=8; ///< Maximal number of MMC cards supported by the emulator
    36 const TInt KMax_TotalWinsCards=(KMax_TotalWinsCardSlots+1); ///< Maximal number of MMC slots, supported by the emulator. Need 2 cards for slot 0
    37 
    38 const TInt KDefault_TotalWinsCardSlots=2; ///< Default number of MMC cards supported by the emulator
    39 const TInt KDefault_TotalWinsCards=(KDefault_TotalWinsCardSlots+1); ///< Default number of MMC slots, supported by the emulator. Need 2 cards for slot 0
    40 
    41 
    42 const TUint32 KMMCWinsCardOCRValue = 0x00FFFF00;
    43 
    44 class TWinsCardInfo
    45 	{
    46 public:
    47 	void GetCSD(TUint8* aResp) const;
    48 public:
    49 	TCID iCID;
    50 	TMediaPassword* iPWD;				// PWD_LEN calculated from PWD.
    51 	TBool iIsLocked;					// Could use iCurrentCardIsLocked
    52 	TMMCardStateEnum iState;			// Simulation of card's current state
    53 	HANDLE iWinHandle;
    54 	TRCA iRCA;
    55 	};
    56 
    57 class DWinsMMCStack : public DMMCStack
    58 	{
    59 private:
    60 	DWinsMMCStack(TInt aBus, DMMCSocket* aSocket);
    61 	TInt Init();
    62 private:
    63 	virtual void  MachineInfo(TMMCMachineInfo& aMachineInfo);
    64 public:
    65 	virtual void  AdjustPartialRead(const TMMCard* aCard, TUint32 aStart, TUint32 aEnd, TUint32* aPhysStart, TUint32* aPhysEnd) const;
    66 	virtual void  GetBufferInfo(TUint8** aMDBuf, TInt* aMDBufLen);
    67 
    68 	enum TWinsMMCPanic
    69 		{
    70 	    EWinsMMCLidOpenIntBind=0,
    71 		EWinsMMCBadMachineInfo=1,
    72 		EWinsMMCMediaChangeTickFault = 2,
    73 		EWinsMMCCorruptCommand = 3,
    74 		EWinsMMCLockAttempt = 4,
    75 		EWinsMMCAPRNotSupp = 5,
    76 		EWinsMMCAPRRange = 6,
    77 		EWinsMMCAPRBoundary = 7,
    78 
    79 		EStkFFCNotSelCard = 0x010, EStkFFCNoneSel,
    80 		EStkFOCNotSelCard = 0x011, EStkFOCMultiSel, EStkFOCNoneSel
    81 		};
    82 	
    83     static TInt  TotalMDiskSize;		// mmc card size for emulator
    84 	static TUint CSIZE;					// mmc card size field
    85 	static TUint CSIZE_MULT;			// mmc card size field
    86     
    87     static TInt TotalWinsMMC_CardSlots; // total number of MMC card slots for the emulator
    88     static TInt TotalWinsMMC_Cards;     // total number of MMC cards for the emulator
    89 
    90     static void Panic(TWinsMMCPanic aPanic);
    91 
    92 private:
    93 	TUint8* iMDBuf;
    94 	TInt iMDBufLen;
    95 
    96 private:
    97 	// Stack service provided by ASSP layer
    98 	void SetBusConfigDefaults(TMMCBusConfig&, TUint aClock);
    99 	void InitClockOff();
   100 	void ASSPReset();
   101 	void ASSPDisengage();
   102 	void DoPowerDown();
   103 	// State Machine functions implemented in ASSP layer
   104 	TMMCErr DoPowerUpSM();
   105 	TMMCErr InitClockOnSM();
   106 	TMMCErr IssueMMCCommandSM();
   107 	TMMCErr ModifyCardCapabilitySM();
   108 private:
   109 	TInt SetupSimulatedCard(TInt aCardNum);						// init
   110 	TInt CreateBinFileForCard(TInt aCardNum, HANDLE* aHandle, TBool aCreateNew = EFalse);
   111 	TInt GetTargetSlotNumber(TBool anRCASupplied, const TRCA& anRCA);
   112 	TInt FindAnyCardInStack(TMMCardStateEnum aState);
   113 	TInt FindFirstCardInStack(TMMCardStateEnum aState);
   114 	TInt FindOneCardInStack(TMMCardStateEnum aState);
   115 	void SetupDiskParms(TUint);
   116 	TMMCErr ReadWriteData(TInt aCardIdx, TUint8* aDataP, TUint32 aLength, TMMCCmdDirEnum aDir);
   117 private:
   118 	TWinsCardInfo* iCardPool[KMax_TotalWinsCards]; 		// All the cards created
   119 	TWinsCardInfo* iCardInfo[KMax_TotalWinsCardSlots]; 	// Cards currently present (1 per slot)
   120 	TBool iCMD42Failed;
   121 	TUint32 iBytesToTransfer;
   122 	friend class DWinsMMCMediaChange;
   123 	friend class TMMCardControllerInterfaceWins;			
   124 	};
   125 
   126 class DWinsMMCStack;
   127 class DWinsMMCMediaChange : public DMMCMediaChange
   128 	{
   129 public:
   130 	DWinsMMCMediaChange(TInt aMediaChangeNum);
   131 	virtual TInt Create();
   132 	virtual void ForceMediaChange();
   133 	virtual void DoDoorOpen();
   134 	virtual void DoDoorClosed();
   135 	virtual TMediaState MediaState();
   136 	inline void SetStackP(DWinsMMCStack* aStackP) {iStackP=aStackP;}	
   137 protected:
   138 	void DoorOpenService();
   139 private:
   140 	static void Tick(TAny *aPtr);
   141 	void TickService();
   142 	void Enable();
   143 	void Disable();
   144 	static void MediaChangeCallBack(TAny *aPtr);
   145 	static void MediaChangeDFC(TAny* aPtr);
   146 private:
   147 	TTickLink iTickLink;
   148 	TInt iDoorClosedCount;
   149 	TBool iMediaChangeEnable;
   150 	TInt iMediaDoorCloseReload; 	// Units: In theory-20ms, Actual-100ms  
   151 	DWinsMMCStack* iStackP;
   152 	friend class DWinsMMCStack;
   153 	};
   154 
   155 class DWinsMMCPsu : public DMMCPsu 
   156     {
   157 public:
   158     DWinsMMCPsu(TInt aVccNum, TInt aMcId);
   159     virtual TInt DoCreate();
   160 	virtual void DoSetState(TPBusPsuState aState);
   161 	virtual TInt VoltageInMilliVolts();
   162 private:
   163 	virtual void DoCheckVoltage();
   164     virtual void PsuInfo(TPBusPsuInfo &anInfo);
   165     };
   166 
   167 #endif	// #ifndef __PP_MMC_H__