os/boardsupport/emulator/emulatorbsp/specific/sdcard/sdcard3c/pp_sdc.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#ifndef __PP_SDC_H__
sl@0
    17
#define __PP_SDC_H__
sl@0
    18
#if defined(_UNICODE) && !defined(UNICODE)
sl@0
    19
	#define UNICODE
sl@0
    20
#endif
sl@0
    21
sl@0
    22
#include <sdcard.h>
sl@0
    23
#include <emulator.h>
sl@0
    24
sl@0
    25
GLREF_C TInt MapLastErrorEpoc();
sl@0
    26
GLREF_C TMMCErr MapLastErrorMmc();
sl@0
    27
sl@0
    28
const TInt KMediaChangeTickInterval=20000;	// Units 1uS
sl@0
    29
sl@0
    30
const TInt KTotalWinsCardSlots=2;
sl@0
    31
const TInt KTotalWinsCards=(KTotalWinsCardSlots+1); // Need 2 cards for slot 0
sl@0
    32
sl@0
    33
const TUint32 KMMCWinsCardOCRValue = 0x00FFFF00;
sl@0
    34
sl@0
    35
const TInt KSDMediaAreasPerCard = 2;
sl@0
    36
const TInt KSDUserArea = 0;
sl@0
    37
const TInt KSDProtectedArea = 1;
sl@0
    38
sl@0
    39
class TWinsCardInfo
sl@0
    40
	{
sl@0
    41
public:
sl@0
    42
	void GetCSD(TUint8* aResp) const;
sl@0
    43
public:
sl@0
    44
	TCID iCID;
sl@0
    45
	TMediaPassword* iPWD;				// PWD_LEN calculated from PWD.
sl@0
    46
	TBool iIsLocked;					// Could use iCurrentCardIsLocked
sl@0
    47
	TMMCardStateEnum iState;			// Simulation of card's current state
sl@0
    48
	HANDLE iAreaHandles[KSDMediaAreasPerCard];
sl@0
    49
	TRCA iRCA;
sl@0
    50
	TBool iIsSDCard;
sl@0
    51
	TInt iBusWidth;
sl@0
    52
	};
sl@0
    53
sl@0
    54
class DWinsSDStack : public DSDStack
sl@0
    55
	{
sl@0
    56
private:
sl@0
    57
	DWinsSDStack(TInt aBus, DMMCSocket* aSocket);
sl@0
    58
	TInt Init();
sl@0
    59
private:
sl@0
    60
	virtual void MachineInfo(TMMCMachineInfo& aMachineInfo);
sl@0
    61
public:
sl@0
    62
	virtual void AdjustPartialRead(const TMMCard* aCard, TUint32 aStart, TUint32 aEnd, TUint32* aPhysStart, TUint32* aPhysEnd) const;
sl@0
    63
	virtual void GetBufferInfo(TUint8** aMDBuf, TInt* aMDBufLen);
sl@0
    64
	virtual void AddressCard(TInt aCardNumber);
sl@0
    65
sl@0
    66
	enum TWinsMMCPanic
sl@0
    67
		{
sl@0
    68
	    EWinsMMCLidOpenIntBind=0,
sl@0
    69
		EWinsMMCBadMachineInfo=1,
sl@0
    70
		EWinsMMCMediaChangeTickFault = 2,
sl@0
    71
		EWinsMMCCorruptCommand = 3,
sl@0
    72
		EWinsMMCLockAttempt = 4,
sl@0
    73
		EWinsMMCAPRNotSupp = 5,
sl@0
    74
		EWinsMMCAPRRange = 6,
sl@0
    75
		EWinsMMCAPRBoundary = 7,
sl@0
    76
sl@0
    77
		EStkFFCNotSelCard = 0x010, EStkFFCNoneSel,
sl@0
    78
		EStkFOCNotSelCard = 0x020, EStkFOCMultiSel, EStkFOCNoneSel,
sl@0
    79
		EStkIMCBadStateCmd2 = 0x30, EStkIMCBadStateCmd3, EStkIMCCmd6InvalidWidth,
sl@0
    80
			EStkICMACMD13NotSD, EStkICMACMD22NotSD,
sl@0
    81
		};
sl@0
    82
    static void Panic(TWinsMMCPanic aPanic);
sl@0
    83
sl@0
    84
private:
sl@0
    85
	// Stack service provided by ASSP layer
sl@0
    86
	void SetBusConfigDefaults(TMMCBusConfig&, TUint aClock);
sl@0
    87
	void InitClockOff();
sl@0
    88
	void ASSPReset();
sl@0
    89
	void ASSPDisengage();
sl@0
    90
	void DoPowerDown();
sl@0
    91
	// State Machine functions implemented in ASSP layer
sl@0
    92
	TMMCErr DoPowerUpSM();
sl@0
    93
	TMMCErr InitClockOnSM();
sl@0
    94
	TMMCErr IssueMMCCommandSM();
sl@0
    95
    TMMCErr ModifyCardCapabilitySM();
sl@0
    96
private:
sl@0
    97
	TInt SetupSimulatedCard(TInt aCardNum);						// init
sl@0
    98
	TInt CreateBinFileForCard(TInt aCardNum, TInt aAreaNum, HANDLE* aHandle);
sl@0
    99
	TInt GetTargetSlotNumber(const TRCA& anRCA);
sl@0
   100
	TInt FindAnyCardInStack(TMMCardStateEnum aState);
sl@0
   101
	TInt FindFirstCardInStack(TMMCardStateEnum aState);
sl@0
   102
	TInt FindOneCardInStack(TMMCardStateEnum aState);
sl@0
   103
private:
sl@0
   104
	TWinsCardInfo* iCardPool[KTotalWinsCards];		// all cards
sl@0
   105
	TWinsCardInfo* iCardInfo[KTotalWinsCardSlots];		// present cards
sl@0
   106
	TInt iAddressedCard;
sl@0
   107
	TBool iCMD42Failed;
sl@0
   108
	TInt iMBWOKBlocks;
sl@0
   109
	TUint8* iMDBuf;
sl@0
   110
	TInt iMDBufLen;
sl@0
   111
sl@0
   112
	friend class TSDCardControllerInterfaceWins;
sl@0
   113
	friend class DWinsMMCMediaChange;
sl@0
   114
	};
sl@0
   115
sl@0
   116
class DWinsMMCMediaChange : public DMMCMediaChange
sl@0
   117
	{
sl@0
   118
public:
sl@0
   119
	DWinsMMCMediaChange(TInt aMediaChangeNum);
sl@0
   120
	virtual TInt Create();
sl@0
   121
	virtual void ForceMediaChange();
sl@0
   122
	virtual void DoDoorOpen();
sl@0
   123
	virtual void DoDoorClosed();
sl@0
   124
	virtual TMediaState MediaState();
sl@0
   125
protected:
sl@0
   126
    void DoorOpenService();
sl@0
   127
private:
sl@0
   128
	static TInt MediaChangeDfc(TAny *aPtr);
sl@0
   129
	static void Tick(TAny *aPtr);
sl@0
   130
	void TickService();
sl@0
   131
	void Enable();
sl@0
   132
	void Disable();
sl@0
   133
	static void MediaChangeCallBack(TAny *aPtr);
sl@0
   134
	inline void SetStackP(DWinsSDStack* aStackP) {iStackP=aStackP;}	
sl@0
   135
private:
sl@0
   136
	TTickLink iTickLink;
sl@0
   137
	TInt iDoorClosedCount;
sl@0
   138
	TBool iMediaChangeEnable;
sl@0
   139
	TInt iMediaDoorCloseReload; 	// Units: In theory-20ms, Actual-100ms  
sl@0
   140
	DWinsSDStack* iStackP;
sl@0
   141
	friend class DWinsSDStack;
sl@0
   142
	};
sl@0
   143
sl@0
   144
class DWinsMMCPsu : public DMMCPsu 
sl@0
   145
    {
sl@0
   146
public:
sl@0
   147
    DWinsMMCPsu(TInt aVccNum, TInt aMcId);
sl@0
   148
    virtual void Init();
sl@0
   149
	virtual void DoSetState(TPBusPsuState aState);
sl@0
   150
	virtual TInt VoltageInMilliVolts();
sl@0
   151
private:
sl@0
   152
	virtual void DoCheckVoltage();
sl@0
   153
    virtual void PsuInfo(TPBusPsuInfo &anInfo);
sl@0
   154
    };
sl@0
   155
sl@0
   156
sl@0
   157
#endif	// #ifndef __PP_SDC_H__