sl@0: // Copyright (c) 1998-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 the License "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: // e32\include\drivers\pccard.h sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @publishedPartner sl@0: @released sl@0: */ sl@0: sl@0: #ifndef __P32PCCD_H__ sl@0: #define __P32PCCD_H__ sl@0: #include sl@0: sl@0: const TUint KPccdIntMaskIReq=0x1; sl@0: const TUint KPccdIntMaskIndChg=0x2; sl@0: const TUint KPccdIntMaskRdyChg=0x4; sl@0: sl@0: enum TPccdInt sl@0: { sl@0: EPccdIntIReq=0, sl@0: EPccdIntIndChange=1, sl@0: EPccdIntRdyChange=2, sl@0: }; sl@0: sl@0: const TUint KPccdEvFlagIReqLevelMode=0x00000001; sl@0: const TUint KPccdEvFlagReserved=0x80000000; sl@0: sl@0: // sl@0: // PC Card maximum system settings sl@0: // sl@0: const TInt KMaxPccdSockets=KMaxPBusSockets; sl@0: const TInt KMaxPccdMediaChanges=2; sl@0: const TInt KMaxPccdVccSupplies=2; sl@0: const TUint KMaxFuncPerCard=8; sl@0: const TUint KDefaultAttribMemSize=0x10000; // 64K Bytes (32K CIS) sl@0: sl@0: const TSocket KInvalidSocket=-1; sl@0: const TUint8 KInvalidFuncNum=(KMaxFuncPerCard+1); sl@0: // sl@0: // PC Card Enumerates sl@0: // sl@0: enum TPccdFuncType {EGlobalCard,EVendorMultiFuncCard,EMemoryCard,ESerialCard, sl@0: EParallelCard,EFixedDiskCard,EVideoCard,ENetworkCard,EAimsCard, sl@0: EScsiCard,EVendorSpecificCard,EUnknownCard}; // Order important sl@0: enum TPccdMemType {EPccdAttribMem,EPccdCommon8Mem,EPccdCommon16Mem,EPccdIo8Mem,EPccdIo16Mem}; sl@0: enum TPccdCardStatus {ECardNotPresent,ECardNotReady,ECardBad,ECardReady}; sl@0: enum TPccdAccessSpeed {EAcSpeed50nS,EAcSpeed100nS,EAcSpeed150nS,EAcSpeed200nS, sl@0: EAcSpeed250nS,EAcSpeed300nS,EAcSpeed450nS,EAcSpeed600nS, sl@0: EAcSpeed750nS,EAcSpeedExtended,EAcSpeedInValid}; sl@0: enum TMemDeviceType {EDeviceNull,EDeviceRom,EDeviceOTP,EDeviceEPROM, sl@0: EDeviceEEPROM,EDeviceFlash,EDeviceSRam,EDeviceDRam, sl@0: EDeviceFunSpec,EDeviceInvalid}; // Order important sl@0: sl@0: // Active signals (correspond to Config entry tuple - dont change) sl@0: const TUint KSigBvdActive=0x00000010; sl@0: const TUint KSigWpActive=0x00000020; sl@0: const TUint KSigReadyActive=0x00000040; sl@0: const TUint KSigWaitRequired=0x00000080; sl@0: const TUint KSigWaitSupported=KSigWaitRequired; sl@0: // sl@0: const TUint KPccdVcc_5V0=0x01; sl@0: const TUint KPccdVcc_3V3=0x02; sl@0: const TUint KPccdVcc_xVx=0x04; sl@0: const TUint KPccdVcc_yVy=0x08; sl@0: // Interrupt info sl@0: const TUint KPccdIntShare=0x00000080; sl@0: const TUint KPccdIntPulse=0x00000040; sl@0: const TUint KPccdIntLevel=0x00000020; sl@0: sl@0: enum TPccdSocketVcc {EPccdSocket_Invalid=0,EPccdSocket_5V0=KPccdVcc_5V0,EPccdSocket_3V3=KPccdVcc_3V3, sl@0: EPccdSocket_xVx=KPccdVcc_xVx,EPccdSocket_yVy=KPccdVcc_yVy}; sl@0: sl@0: enum TPccdOpCritical {EPccdOpCritical,EPccdOpNonCritical}; sl@0: // sl@0: // PC Card memory chunk speed/type/signal definitions sl@0: // sl@0: #define __IS_COMMON_MEM(aMemType) (aMemType==EPccdCommon8Mem||aMemType==EPccdCommon16Mem) sl@0: #define __IS_IO_MEM(aMemType) (aMemType==EPccdIo8Mem||aMemType==EPccdIo16Mem) sl@0: #define __IS_ATTRIB_MEM(aMemType) (aMemType==EPccdAttribMem) sl@0: #define DEF_IO_ACSPEED EAcSpeed200nS sl@0: #define DEF_MEM_ACSPEED EAcSpeed250nS sl@0: #define DEF_ATTR_ACSPEED EAcSpeed600nS sl@0: // sl@0: // PC Card Vcc definitions sl@0: // sl@0: const TInt KVcc_Level_5V=5000; sl@0: const TInt KVcc_Level_3V3=3300; sl@0: const TInt KVcc_Level_xVx=0; sl@0: const TInt KVcc_Level_yVy=0; sl@0: // sl@0: // General tuple parsing definitions sl@0: // sl@0: const TInt KSmallTplBufSize=16; sl@0: const TInt KLargeTplBufSize=257; sl@0: const TInt KMaxCfEntriesPerCis=20; sl@0: // sl@0: // Link Tuple definitions sl@0: // sl@0: const TUint KPccdLinkA=0x00000001; sl@0: const TUint KPccdLinkC=0x00000002; sl@0: const TUint KPccdLinkMFC=0x00000004; sl@0: const TUint KPccdNoLink=0x00000008; sl@0: // sl@0: // Tuple codes sl@0: // sl@0: const TUint8 KCisTplNull=0x00; sl@0: const TUint8 KCisTplDevice=0x01; sl@0: const TUint8 KCisTplLongLinkMfc=0x06; sl@0: const TUint8 KCisTplCheckSum=0x10; sl@0: const TUint8 KCisTplLongLinkA=0x11; sl@0: const TUint8 KCisTplLongLinkC=0x12; sl@0: const TUint8 KCisTplLinkTarget=0x13; sl@0: const TUint8 KCisTplNoLink=0x14; sl@0: const TUint8 KCisTplVers1=0x15; sl@0: const TUint8 KCisTplAltStr=0x16; sl@0: const TUint8 KCisTplDeviceA=0x17; sl@0: const TUint8 KCisTplJedecC=0x18; sl@0: const TUint8 KCisTplJedecA=0x19; sl@0: const TUint8 KCisTplConfig=0x1A; sl@0: const TUint8 KCisTplCfTableEntry=0x1B; sl@0: const TUint8 KCisTplDeviceOC=0x1C; sl@0: const TUint8 KCisTplDeviceOA=0x1D; sl@0: const TUint8 KCisTplDeviceGeo=0x1E; sl@0: const TUint8 KCisTplDeviceGeoA=0x1F; sl@0: const TUint8 KCisTplManfId=0x20; sl@0: const TUint8 KCisTplFuncId=0x21; sl@0: const TUint8 KCisTplFunce=0x22; sl@0: const TUint8 KCisTplSwIl=0x23; sl@0: const TUint8 KCisTplVers2=0x40; sl@0: const TUint8 KCisTplFormat=0x41; sl@0: const TUint8 KCisTplGeometry=0x42; sl@0: const TUint8 KCisTplByteOrder=0x43; sl@0: const TUint8 KCisTplDate=0x44; sl@0: const TUint8 KCisTplBattery=0x45; sl@0: const TUint8 KCisTplOrg=0x46; sl@0: const TUint8 KCisTplLongLinkCB=0x47; sl@0: const TUint8 KCisTplVendorSpecific1=0x80; sl@0: const TUint8 KCisTplVendorSpecific2=0x81; sl@0: const TUint8 KCisTplVendorSpecific3=0x82; sl@0: const TUint8 KCisTplEnd=0xFF; sl@0: // sl@0: const TUint8 KPccdNonSpecificTpl=0xff; sl@0: const TUint8 KInvalidConfOpt=0xFF; sl@0: const TUint KPccdRestartCis=0x8000; sl@0: // sl@0: // PC Card Configuration Register definitions sl@0: // sl@0: const TUint KConfigOptionReg=0; sl@0: const TUint KConfigOptionRegM=0x00000001; sl@0: const TUint KConfigAndStatusReg=1; sl@0: const TUint KConfigAndStatusRegM=0x00000002; sl@0: const TUint KPinReplacementReg=2; sl@0: const TUint KPinReplacementRegM=0x00000004; sl@0: const TUint KSocketAndCopyReg=3; sl@0: const TUint KSocketAndCopyRegM=0x00000008; sl@0: sl@0: const TUint KConfOptConfM=0x0000003F; sl@0: const TUint KConfOptLevIReqM=0x00000040; sl@0: const TUint KConfOptSResetM=0x00000080; sl@0: const TUint KConfStatIntrAckM=0x00000001; sl@0: const TUint KConfStatIntrM=0x00000002; sl@0: const TUint KConfStatPwrDwnM=0x00000004; sl@0: const TUint KConfStatAudioEnableM=0x00000008; sl@0: const TUint KConfStatIoIs8M=0x00000020; sl@0: const TUint KConfStatSigChgM=0x00000040; sl@0: const TUint KConfStatChangedM=0x00000080; sl@0: const TUint KPinRepWProtM=0x00000001; sl@0: const TUint KPinRepReadyM=0x00000002; sl@0: const TUint KPinRepBvdM=0x0000000C; sl@0: // sl@0: // Pc Card Flag definitions - Mem request/setup and others sl@0: // sl@0: const TUint KPccdRequestWait=0x00000001; // Memory request sl@0: const TUint KPccdChunkCacheable=0x00000010; // Memory request sl@0: const TUint KPccdChunkShared=0x00000020; // Memory request sl@0: const TUint KPccdChunkPermanent=0x00000040; // Memory request sl@0: const TUint KPccdChunkSystemOwned=0x00000080; // Memory request sl@0: sl@0: const TUint KPccdDisableWaitStateCntrl=0x00000100; // Memory chunk setup sl@0: const TUint KPccdBusWidth32=0x00000200; // Memory chunk setup sl@0: sl@0: const TUint KPccdReturnLinkTpl=0x00001000; // Cis parsing sl@0: const TUint KPccdReportErrors=0x00002000; // Cis parsing sl@0: const TUint KPccdFindOnly=0x00004000; // Cis parsing sl@0: sl@0: const TUint KPccdCompatNoVccCheck=0x00000001; // Config compatibility checking sl@0: const TUint KPccdCompatNoVppCheck=0x00000002; // Config compatibility checking sl@0: const TUint KPccdCompatNoPwrCheck=0x00000004; // Config compatibility checking sl@0: sl@0: const TUint KPccdConfigRestorable=0x00000001; // Configuration request sl@0: // sl@0: // PC Card tick definitions sl@0: // sl@0: const TInt KPccdPowerUpReqInterval=20000; // Units 1uS sl@0: const TInt KResetOnDefaultLen=5; // Units 20ms sl@0: const TInt KResetOffDefaultLen=5; // Units 20ms sl@0: const TInt KPwrUpTimeOut=125; // Units 20mS sl@0: const TUint KResetOnMask=0x0000FFFF; sl@0: const TUint KResetOffMask=0x7FFF0000; sl@0: const TInt KResetOffShift=16; sl@0: const TInt KResetProfileDefault=((KResetOffDefaultLen< TPcCardMachineInfoPckg; sl@0: // sl@0: class RPccdWindow; sl@0: class DPcCardSocket; sl@0: NONSHARABLE_CLASS(DPccdChunkBase) : public DBase sl@0: { sl@0: public: sl@0: DPccdChunkBase(); sl@0: virtual ~DPccdChunkBase(); sl@0: virtual void Close(); sl@0: TInt Create(DPcCardSocket* aSocket, TPccdChnk aChunk, TUint aFlag); sl@0: public: sl@0: virtual TInt DoCreate(TPccdChnk aChunk, TUint aFlag)=0; sl@0: virtual TInt SetupChunkHw(TPccdAccessSpeed aSpeed, TPccdMemType aMemType, TBool aWaitSig, TUint aFlag)=0; sl@0: virtual TLinAddr LinearAddress()=0; sl@0: virtual TInt Read(TInt aPos, TAny *aPtr, TInt aLength)=0; sl@0: virtual TInt Write(TInt aPos, const TAny *aPtr, TInt aLength)=0; sl@0: virtual TInt ReadByteMultiple(TInt aPos, TAny *aPtr, TInt aCount)=0; sl@0: virtual TInt WriteByteMultiple(TInt aPos, const TAny *aPtr, TInt aCount)=0; sl@0: virtual TInt ReadHWordMultiple(TInt aPos, TAny *aPtr, TInt aCount)=0; sl@0: virtual TInt WriteHWordMultiple(TInt aPos, const TAny *aPtr, TInt aCount)=0; sl@0: virtual TUint Read8(TInt aPos)=0; sl@0: virtual void Write8(TInt aPos, TUint aValue)=0; sl@0: virtual TBool IsTypeCompatible(TPccdMemType aMemType)=0; sl@0: public: sl@0: TInt AllocateWinCheck(TPccdChnk aWin, TUint aFlag); sl@0: void AddWindow(RPccdWindow *aWindow); sl@0: void RemoveWindow(RPccdWindow *aWindow); sl@0: TBool IsRemovable(); sl@0: TBool IsLocked(); sl@0: inline TUint32 BaseAddr(); sl@0: public: sl@0: SDblQue iWindowQ; sl@0: TInt iWindows; sl@0: TInt iPermanentWindows; sl@0: TInt iShareableWindows; sl@0: TInt iSystemWindows; sl@0: DPcCardSocket* iSocket; sl@0: TPccdChnk iChnk; sl@0: TBool iCacheable; sl@0: }; sl@0: sl@0: class RPccdWindow : public SDblQueLink sl@0: { sl@0: public: sl@0: IMPORT_C RPccdWindow(); sl@0: IMPORT_C TInt Create(DPcCardSocket* aSocket, TPccdChnk aChnk, TPccdAccessSpeed aSpeed, TUint aFlag); sl@0: IMPORT_C void Close(); sl@0: IMPORT_C TInt SetupChunkHw(TUint aFlag=0); sl@0: inline TInt Read(TInt aPos, TAny *aPtr, TInt aLength); sl@0: inline TInt Write(TInt aPos, const TAny *aPtr, TInt aLength); sl@0: inline TInt ReadByteMultiple(TInt aPos, TAny *aPtr, TInt aCount); sl@0: inline TInt WriteByteMultiple(TInt aPos, const TAny *aPtr, TInt aCount); sl@0: inline TInt ReadHWordMultiple(TInt aPos, TAny *aPtr, TInt aCount); sl@0: inline TInt WriteHWordMultiple(TInt aPos, const TAny *aPtr, TInt aCount); sl@0: inline TUint Read8(TInt aPos); sl@0: inline void Write8(TInt aPos, TUint aValue); sl@0: inline void SetAccessSpeed(TPccdAccessSpeed aSpeed); sl@0: IMPORT_C TLinAddr LinearAddress(); sl@0: public: sl@0: TBool Overlap(TUint32 anOffset, TUint aLen); sl@0: inline TBool IsPermanent(); sl@0: inline TBool IsShareable(); sl@0: inline TBool IsSystemOwned(); sl@0: public: sl@0: TPccdAccessSpeed iAccessSpeed; sl@0: TPccdMemType iMemType; // ??? sl@0: TUint32 iOffset; sl@0: TUint32 iLen; sl@0: DPccdChunkBase* iChunk; sl@0: TUint iType; sl@0: TBool iWaitSig; sl@0: }; sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @released sl@0: sl@0: Provides functions for parsing a CIS. sl@0: sl@0: These range from functions for selecting a CIS and reading 'raw' tuples to sl@0: functions that return card configuration and memory region information sl@0: in a standard format (and hide the detail of the corresponding tuples). sl@0: sl@0: An object of this type stores the current position of the CIS pointer sl@0: allowing multiple clients to parse a card CIS simultaneousy. sl@0: sl@0: Following a CIS chain may require the controller to allocate extra memory (e.g. a CIS with a link to Common memory) sl@0: so this class should only be used during a Kernel Server call. sl@0: */ sl@0: class TCisReader sl@0: { sl@0: public: sl@0: /** sl@0: Initialises function number,CisOffset,LinkOffset,LinkFlags,RegionCount and Configcount to 0, sl@0: memory type to EPccdAttribMem, and restarted flag to flase. sl@0: sl@0: Pc Card contains following memory types : EPccdAttribMem,EPccdCommon8Mem,EPccdCommon16Mem,EPccdIo8Mem,EPccdIo16Mem. sl@0: sl@0: Default constructor initializes to EPccAttribMem. sl@0: */ sl@0: IMPORT_C TCisReader(); sl@0: /** sl@0: Sets the CIS reader to a socket and function and then restarts. sl@0: sl@0: @param aSocket socket to be set to the CIS reader. sl@0: sl@0: @param aCardFunc card function to be assigned to CIS reader. sl@0: sl@0: @return KErrNone if successful, otherwise KErrNotReady,if Card not powered/ready (possible media change),KErrNotFound, if Selected function isn't valid. sl@0: */ sl@0: IMPORT_C TInt SelectCis(TSocket aSocket,TInt aCardFunc); sl@0: /** sl@0: Sets the CIS reader back to the start of the CIS for this function. sl@0: @return KErrNone if successful, otherwise KErrGeneral, if a CIS hasn't been selected (i.e. SelectCis() not called). sl@0: */ sl@0: IMPORT_C TInt Restart(); sl@0: /** sl@0: Find the next instance of the specified tuple, 'aDesiredTpl' in the CIS chain sl@0: and read it into 'aDes'. The search starts from the current position in the CIS (ie CIS pointer), sl@0: not from the start of the CIS. If the tuple cannot be found then KErrNotFound is returned. sl@0: When changing the desired tuple it is normal to precede this function with Restart() to reset sl@0: the current position in the CIS. To find multiple instances of the same tuple in a CIS, sl@0: keep calling the function with the same value for 'aDesired' tuple without calling Restart(). sl@0: sl@0: To use this function to find a tuple without reading it, OR 'aFlag' with KPccdFindOnly. sl@0: (It is recomended not to read an un-recognisd tuple in case it contains active registers. sl@0: Therefore this option should generally be used with KPccdNonSpecificTpl when the requirement sl@0: is to just validate a CIS). To turn on full error reporting (e.g. when validating a CIS), sl@0: OR 'aFlag' with 'KPccdReportErrors'. sl@0: sl@0: @param aDesiredTpl Tuple to be searched in CIS chain. sl@0: sl@0: @param aDes Tuple searched is read into aDes. sl@0: sl@0: @param aFlag Used to read tuple which are not read by default by ORing aFlag with KPccdReturnLinkTpl. sl@0: sl@0: sl@0: @return KErrNone if successful,KErrNotFound,if could not find a tuple of the type specified sl@0: (or possible invalid CIS if 'KPccdReportErrors' isn't set).KErrNotReady,if card not powered/ready(possible media change). sl@0: KErrCorrupt,if only returned when 'KPccdReportErrors' set.Too many tuples found (>256), too many link tuples, no link target etc. sl@0: KErrArguement,if Tuple is longer than maximum length of 'aDes'.KErrNoMemory,if problem allocating memory during processing of request (no memory). sl@0: KerrAccessDenied, if problem allocating memory during processing of request (memory containing CIS already allocated to another client). sl@0: */ sl@0: IMPORT_C TInt FindReadTuple(TUint8 aDesiredTpl,TDes8 &aDes,TUint aFlag=0); sl@0: /** sl@0: Gets the tuple at the current CIS offset. This is identical to FindReadTuple() except that it always returns sl@0: the tuple at the current CIS offset rather than searching for a tuple of a specified type. sl@0: sl@0: @param aDec8 Tuple is read into aDes8. sl@0: sl@0: @return KErrNone if successful, KErrNotFound, if could not find a tuple of the type specified (or possible invalid CIS if 'KPccdReportErrors' isn't set). sl@0: KErrNotReady,if card not powered/ready (possible media change).KErrCorrupt,if only returned when 'KPccdReportErrors' set. sl@0: Too many tuples found (>256), too many link tuples, no link target etc.KErrArguement ,if Tuple is longer than maximum length of 'aDes'. sl@0: KErrNoMemory if problem allocating memory during processing of request (no memory). KErrAccessDenied, if problem allocating memory during processing of request sl@0: (memory containing CIS already allocated to another client). sl@0: */ sl@0: IMPORT_C TInt ReadTuple(TDes8 &aDes); sl@0: /** sl@0: Gets information in 'anInfo' from the selected CIS on the card's memory devices. sl@0: sl@0: This information is contained in the CIS in the appropriate Device tuple. sl@0: Each time the function is called it returns information on the next device specified sl@0: (i.e. next Device Info field). When all regions have been reported, KErrNotFound is returned. sl@0: By default, it reports on devices in common memory space. sl@0: sl@0: To receive device info when the card is operated at 5V, set 'aSocketVcc' sl@0: to EPccdSocket_5V0 (and KCisTplDevice tuples are processed). For characteristics at 3.3V, sl@0: set 'aSocketVcc' to EPccdSocket_3V3 (and KCisTplDeviceOC tuples are processed). sl@0: sl@0: To receive info on devices in attribute memory space, use 'aDesiredTpl' to override sl@0: the type of tuple processed. E.g. to receive device information on attribute memory at 5V, sl@0: set 'aDesiredTpl' to KCisTplDeviceA. (This feature also allows FindReadRegion() to be used sl@0: to parse vendor specific tuples which conform to device tuple structure). sl@0: This function searches for the appropriate tuple type starting from the current position sl@0: of the CIS pointer so it may be necessary to issue a Restart() before each sequence of Calls of this function. sl@0: sl@0: The TPcCardRegion object contains a TPccdChnk which can then be used directly in a sl@0: call to DPcCardController::RequestMemory() to request a chunk of PC Card memory. sl@0: sl@0: @param aSocketVcc Used to set the Pc Card Socket voltage. sl@0: sl@0: @param anInfo This has the information returned from the selected CIS on the card's memory devices. sl@0: sl@0: @param aDesiredTpl Desired Tuple used to find, initialized to zero. sl@0: sl@0: @return KErrNone if successful.KErrNotFound,if no more configurations present. KErrNotReady if card not powered/ready (possible media change). sl@0: KErrCorrupt, if invalid configuration/configuration-table-entry tuple detected. KErrNotSupported, if Configuration table entry not supported. sl@0: KErrNoMemory, if problem allocating memory during processing of request (no memory). KErrAccessDenied if problem allocating memory during sl@0: processing of request (memory containing CIS already allocated to another client). sl@0: */ sl@0: IMPORT_C TInt FindReadRegion(TPccdSocketVcc aSocketVcc,TPcCardRegion &anInfo,TUint8 aDesiredTpl=0); sl@0: /** sl@0: Find the next configuration table entry in the CIS and return the detail of it in 'anInfo'. sl@0: When all entries have been found, KErrNotFound is returned. This function allows a client to parse a CIS, sl@0: reading information on each of the different configuration option present. sl@0: It is necessary to issue a Restart() before each sequence of calls of this function. sl@0: sl@0: Following a call to this function, the TPcCardConfig object can then be used directly sl@0: in a call to DPcCardController::RequestConfig() to configure the card. Also the TPcCardConfig object sl@0: contains a TPccdChnk which can then be used directly in a call to DPcCardController::RequestMemory() sl@0: to request the appropriate chunk of PC Card memory. sl@0: sl@0: @param anInfo has the PcCardconfig information read from CIS entry. sl@0: sl@0: @return KErrNone if successful. KerrNotFound, if no more regions of the type specified to be found. sl@0: KErrNotReady,if card not powered/ready (possible media change). KErrCorrupt, if device tuple contained invalid device info. field. sl@0: KErrNotSupported ,if device tuple contained extended device type. KErrNoMemory,if problem allocating memory during processing sl@0: of request (no memory). KErrAccessDenied if problem allocating memory during processing of request sl@0: (memory containing CIS already allocated to another client). sl@0: sl@0: */ sl@0: IMPORT_C TInt FindReadConfig(TPcCardConfig &anInfo); sl@0: public: sl@0: /** sl@0: Sets the CIS reader to socket and function, and checks that the function is valid. sl@0: sl@0: @param aCardFunc Card function to be assined to the CIS reader. sl@0: */ sl@0: TInt DoSelectCis(TInt aCardFunc); sl@0: /** sl@0: Sets the CIS reader back to the start of the CIS. sl@0: */ sl@0: void DoRestart(); sl@0: /** sl@0: Find a specified tuple from the CIS and read it. sl@0: sl@0: @param aDesiredTpl Tuple to be searched in CIS chain. sl@0: sl@0: @param aDec8 Tuple is read into aDes8. sl@0: sl@0: @param aFlag Used to read tuple which are not read by default by ORing aFlag with KPccdReturnLinkTpl. sl@0: sl@0: To use this function to find a tuple without reading it, OR 'aFlag' with KPccdFindOnly. sl@0: (It is recomended not to read an un-recognisd tuple in case it contains active registers. sl@0: Therefore this option should generally be used with KPccdNonSpecificTpl when the requirement sl@0: is to just validate a CIS). To turn on full error reporting (e.g. when validating a CIS), sl@0: OR 'aFlag' with 'KPccdReportErrors'. sl@0: @return KErrNone if successful, KErrNotFound,if could not find a tuple of the type specified sl@0: (or possible invalid CIS if 'KPccdReportErrors' isn't set).KErrNotReady if card not powered/ready (possible media change). sl@0: KErrCorrupt if only returned when 'KPccdReportErrors' set.Too many tuples found (>256), too many link tuples, no link target etc. sl@0: KErrArguement,if tuple is longer than maximum length of 'aDes'. KErrNoMemory if problem allocating memory during processing of request (no memory). sl@0: KErrAccessDenied,if problem allocating memory during processing of request (memory containing CIS already allocated to another client). sl@0: */ sl@0: TInt DoFindReadTuple(TUint8 aDesiredTpl,TDes8 &aDes,TUint aFlag); sl@0: /** sl@0: Gets the tuple at the current CIS offset. This is identical to FindReadTuple() except that it always returns sl@0: the tuple at the current CIS offset rather than searching for a tuple of a specified type. sl@0: sl@0: @param aDec8 Tuple is read into aDes8. sl@0: sl@0: @return KErrNone if successful, KErrNotFound,if could not find a tuple of the type specified sl@0: (or possible invalid CIS if 'KPccdReportErrors' isn't set).KErrNotReady if card not powered/ready (possible media change). sl@0: KErrCorrupt if only returned when 'KPccdReportErrors' set.Too many tuples found (>256), too many link tuples, no link target etc. sl@0: KErrArguement,if tuple is longer than maximum length of 'aDes'. KErrNoMemory if problem allocating memory during processing of request (no memory). sl@0: KErrAccessDenied,if problem allocating memory during processing of request (memory containing CIS already allocated to another client). sl@0: */ sl@0: TInt DoReadTuple(TDes8 &aDes); sl@0: /** sl@0: Gets the error report when their is no more CIS links. sl@0: sl@0: Called at the end of a tuple chain, this moves CIS pointer to the next CIS chain if a long link has been detected. sl@0: sl@0: @param aFullErrorReport Error report after when their is no more CIS links. sl@0: */ sl@0: TInt FollowLink(TUint aFullErrorReport); sl@0: /** sl@0: Verify a new tuple chain starts with a valid link target tuple. sl@0: sl@0: @return KErrNone if successfull, otherwise KErrCorrupt. sl@0: */ sl@0: TInt VerifyLinkTarget(); sl@0: public: sl@0: /** sl@0: A pointer to Pc Card Socket. sl@0: */ sl@0: DPcCardSocket *iSocket; sl@0: /** sl@0: Pc Card function. sl@0: */ sl@0: TInt iFunc; sl@0: /** sl@0: Offset within the CIS memory. sl@0: */ sl@0: TUint32 iCisOffset; sl@0: /** sl@0: Link offset within the CIS memory. sl@0: */ sl@0: TUint32 iLinkOffset; sl@0: /** sl@0: Pc Card memory type. sl@0: @see TPccdMemType sl@0: */ sl@0: TPccdMemType iMemType; sl@0: /** sl@0: Linkflags used to link the tuple. sl@0: */ sl@0: TInt iLinkFlags; sl@0: /** sl@0: Used in constructor to mark Pc Card as not restarted. sl@0: */ sl@0: TBool iRestarted; sl@0: /** sl@0: For FindReadRegion() - Count of regions read so far. sl@0: */ sl@0: TInt iRegionCount; sl@0: /** sl@0: For FindReadConfig() - Configurations read so far. sl@0: */ sl@0: TInt iConfigCount; sl@0: }; sl@0: sl@0: NONSHARABLE_CLASS(DPcCardVcc) : public DPBusPsuBase sl@0: { sl@0: public: sl@0: DPcCardVcc(TInt aPsuNum, TInt aMediaChangeNum); sl@0: virtual TBool IsLocked(); sl@0: virtual void ReceiveVoltageCheckResult(TInt anError); sl@0: inline void SetVoltage(TPccdSocketVcc aVoltage); sl@0: inline TPccdSocketVcc VoltageSetting(); sl@0: static TInt SocketVccToMilliVolts(TPccdSocketVcc aVcc); sl@0: public: sl@0: TPccdSocketVcc iVoltageSetting; sl@0: }; sl@0: sl@0: NONSHARABLE_CLASS(DPcCardMediaChange) : public DMediaChangeBase sl@0: { sl@0: public: sl@0: DPcCardMediaChange(TInt aMediaChangeNum); sl@0: virtual TInt Create(); sl@0: }; sl@0: /** sl@0: This class contains functions provided by Pc Card. sl@0: sl@0: @publishedPartner sl@0: @released sl@0: */ sl@0: class TPcCardFunction sl@0: { sl@0: public: sl@0: /** sl@0: Constructor, intialises iFuncType (EUnknownCard),iInitCisOffset(anOffset),iInitCisMemType(aMemType), sl@0: iConfigBaseAddr(0),iConfigRegMask(0),iConfigIndex(KInvalidConfOpt),iConfigFlags(0). sl@0: sl@0: @param anOffset An offset value to be initialised for Cis. sl@0: sl@0: @param aMemType Cis memory type to be initialised. sl@0: sl@0: @see TPccdMemType sl@0: */ sl@0: TPcCardFunction(TUint32 anOffset,TPccdMemType aMemType); sl@0: /** sl@0: Sets the configuration option(anIndex), client ID and flags used to configure the Pc Card . sl@0: sl@0: @param anIndex Configuration option of the Pc Card. sl@0: sl@0: @param aClientId A pointer to the LDD making the configuration. sl@0: sl@0: @param aConfigFlags Select Pc Card features. sl@0: */ sl@0: void SetConfigOption(TInt anIndex,DBase *aClientID,TUint aConfigFlags); sl@0: /** sl@0: Sets the configuration base address for Pc Card. sl@0: sl@0: @param anAddr Base address to configure Pc Card. sl@0: */ sl@0: inline void SetConfigBaseAddr(TUint32 anAddr); sl@0: /** sl@0: Sets the Mask register with aMask value. sl@0: sl@0: @param aMask The mask value to which the register to be masked. sl@0: */ sl@0: inline void SetConfigRegMask(TInt aMask); sl@0: /** sl@0: Sets the function type of the Pc Card. sl@0: sl@0: @param aType Function type of the Pc Card. sl@0: sl@0: @see TPccdFuncType sl@0: */ sl@0: inline void SetFuncType(TPccdFuncType aType); sl@0: /** sl@0: Sets the register and offset address. sl@0: sl@0: @param anRegOffset Offset within the register address. sl@0: sl@0: @param anAddr Register address to configure. sl@0: sl@0: @return KErrNone if successful, otherwise Error if the register isn't present. sl@0: */ sl@0: TInt ConfigRegAddress(TInt aRegOffset,TInt &anAddr); sl@0: /** sl@0: Gets a fuction type the card can provide. sl@0: sl@0: @param anAddr , Address to be configured. sl@0: sl@0: @return iFuncType The type of function the card can provide. sl@0: sl@0: @see TPccdFuncType sl@0: */ sl@0: inline TPccdFuncType FuncType(); sl@0: /** sl@0: Gets configuration index of the Pc Card. sl@0: sl@0: @return iConfigIndex the configuration option of the Pc Card. sl@0: */ sl@0: inline TInt ConfigOption(); sl@0: /** sl@0: Checks whether the Pc Card is configured to the given configuration. sl@0: sl@0: @return True if the Pc Card is configured for the given configuration. sl@0: sl@0: */ sl@0: inline TBool IsConfigured(); sl@0: /** sl@0: Checks whether the Pc Card is configured by the client. sl@0: sl@0: @param aClientId A pointer to the LDD making the configuration. sl@0: sl@0: @return True if the card is configured for the given clientId. sl@0: */ sl@0: inline TBool IsConfiguredByClient(DBase *aClientID); sl@0: /** sl@0: Checks whether the configuration is restoreable after it has been powered sl@0: down due to inactivity (but not media change). sl@0: sl@0: @return True if it can restore sl@0: */ sl@0: inline TBool IsRestorableConfig(); sl@0: /** sl@0: Gets CIS initialisation of the Pc Card. sl@0: sl@0: @return iInitCisOffset CIS initialisation of the Pc Card. sl@0: */ sl@0: inline TUint32 InitCisOffset(); sl@0: /** sl@0: Gets the type of CIS memory. sl@0: sl@0: @return iInitCisMemType type of Cis Memory type. sl@0: */ sl@0: inline TPccdMemType InitCisMemType(); sl@0: public: sl@0: /** sl@0: Type of function the Pc Card can provide. sl@0: sl@0: @see TPccdFuncType. sl@0: */ sl@0: TPccdFuncType iFuncType; sl@0: /** sl@0: To store offset of CIS memory to be initialzed. sl@0: */ sl@0: TUint32 iInitCisOffset; sl@0: /** sl@0: To store the type of memory which needs to be configured. sl@0: sl@0: @see TPccdMemType. sl@0: */ sl@0: TPccdMemType iInitCisMemType; sl@0: /** sl@0: To hold the base configuration address of the Pc Card. sl@0: */ sl@0: TUint32 iConfigBaseAddr; sl@0: /** sl@0: To hold the configuration register mask of the Pc Card. sl@0: */ sl@0: TInt iConfigRegMask; sl@0: /** sl@0: To store the configuration option of the Pc Card. sl@0: */ sl@0: TInt iConfigIndex; sl@0: /** sl@0: A pointer to the LDD which request Cis configuration. sl@0: */ sl@0: DBase *iClientID; sl@0: /** sl@0: Configuration flags that can be used to configure the Pc Card. sl@0: */ sl@0: TUint iConfigFlags; sl@0: }; sl@0: sl@0: NONSHARABLE_CLASS(DPcCardSocket) : public DPBusSocket sl@0: { sl@0: public: sl@0: enum TPowerUpState sl@0: { sl@0: EIdle=0, sl@0: EInit=1, sl@0: EApplyingReset=2, sl@0: ECheckVcc=3, sl@0: EWaitForVccReading=4, sl@0: EWaitForReady=5, sl@0: EPauseAfterReady=6, sl@0: }; sl@0: public: sl@0: DPcCardSocket(TSocket aSocketNum); sl@0: virtual TInt Create(const TDesC* aName); sl@0: virtual void InitiatePowerUpSequence(); sl@0: void TerminatePowerUpSequence(TInt aResult); sl@0: void ResetPowerUpState(); sl@0: void CardPowerUpTick(); sl@0: virtual void SocketInfo(TPcCardSocketInfo& anInfo)=0; sl@0: virtual void Reset1(); sl@0: virtual void Reset2(); sl@0: virtual TInt CardIsReadyAndVerified(); sl@0: virtual TBool CardIsReady(); sl@0: virtual TBool CardIsPowered(); sl@0: IMPORT_C TInt VerifyCard(TPccdType& aType); sl@0: TInt GetCisFormat(); sl@0: IMPORT_C TInt RequestConfig(TInt aCardFunc,DBase *aClientID,TPcCardConfig &anInfo,TUint aFlag); sl@0: IMPORT_C void ReleaseConfig(TInt aCardFunc,DBase *aClientID); sl@0: IMPORT_C TInt ReadConfigReg(TInt aCardFunc,TInt aRegOffset,TUint8 &aVal); sl@0: IMPORT_C TInt WriteConfigReg(TInt aCardFunc,TInt aRegOffset,const TUint8 aVal); sl@0: TInt ReadCis(TPccdMemType aMemType,TInt aPos,TDes8 &aDes,TInt aLen); sl@0: TPcCardFunction *CardFunc(TInt aCardFunc); sl@0: TInt AddNewFunc(TUint32 anOffset,TPccdMemType aMemType); sl@0: TInt ValidateCis(TInt aCardFunc); sl@0: inline TInt CardFuncCount(); sl@0: inline TBool IsValidCardFunc(TInt aCardFunc); sl@0: inline TBool IsMultiFuncCard(); sl@0: TBool IsConfigLocked(); sl@0: TBool IsMemoryLocked(); sl@0: TBool IsVerified(); sl@0: virtual void HwReset(TBool anAssert)=0; sl@0: virtual TInt Indicators(TSocketIndicators &anInd)=0; sl@0: virtual TBool Ready(TInt aCardFunc=KInvalidFuncNum)=0; sl@0: TPccdSocketVcc VccSetting(); sl@0: void Restore(); sl@0: public: sl@0: virtual DPccdChunkBase *NewPccdChunk(TPccdMemType aType)=0; sl@0: virtual TInt InterruptEnable(TPccdInt anInt, TUint aFlag)=0; sl@0: virtual void InterruptDisable(TPccdInt anInt)=0; sl@0: void RemoveChunk(DPccdChunkBase *aChunk); sl@0: public: sl@0: RPointerArray iCardFuncArray; sl@0: RPointerArray iMemChunks; sl@0: RPccdWindow iAttribWin; sl@0: TInt iCardPowerUpState; sl@0: TTickLink iCardPowerUpTimer; sl@0: TDfc iCardPowerUpDfc; sl@0: TInt iCardPowerUpTickCount; sl@0: TInt iCardPowerUpResetLen; sl@0: TInt iCardPowerUpPauseLen; sl@0: TInt iClientWindows; sl@0: TInt iActiveConfigs; sl@0: }; sl@0: sl@0: enum TPcCardPanic sl@0: { sl@0: EPcCardBadSocketNumber=0, sl@0: EPcCardCisReaderUnInit=1, sl@0: EPcCardBadFunctionNumber=2, sl@0: EPcCardPowerUpReqFault=3, sl@0: EPcCardMediaDriverCurrentConsumption=4, sl@0: EPcCardAddEventError=5 sl@0: }; sl@0: sl@0: GLREF_C void PcCardPanic(TPcCardPanic aPanic); sl@0: sl@0: #include sl@0: sl@0: sl@0: #endif