sl@0: /* sl@0: * Copyright (c) 2005-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 "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: * sl@0: */ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include "mmcldd.h" sl@0: #include "d_mmcsdif.h" sl@0: sl@0: sl@0: sl@0: const TInt KMajorVersionNumber=1; sl@0: const TInt KMinorVersionNumber=0; sl@0: const TInt KBuildVersionNumber=0; sl@0: sl@0: // global Dfc Que sl@0: TDynamicDfcQue* gDfcQ; sl@0: sl@0: sl@0: sl@0: DECLARE_STANDARD_LDD() sl@0: { sl@0: return new DLddFactoryMmcCntrlInterface; sl@0: } sl@0: sl@0: /** sl@0: * DLddFactoryMmcCntrlInterface constructor sl@0: * sl@0: * @return N/A sl@0: * sl@0: * @leave N/A sl@0: */ sl@0: DLddFactoryMmcCntrlInterface::DLddFactoryMmcCntrlInterface() sl@0: { sl@0: iParseMask=KDeviceAllowUnit; // Pass stack number as unit sl@0: iUnitsMask=0xffffffff; sl@0: iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber); sl@0: } sl@0: sl@0: /** sl@0: * Create logical channel sl@0: * sl@0: * @param DLogicalChannelBase*& aChannel - logical channel sl@0: * sl@0: * @return TInt the error code sl@0: * sl@0: * @leave N/A sl@0: */ sl@0: TInt DLddFactoryMmcCntrlInterface::Create(DLogicalChannelBase*& aChannel) sl@0: { sl@0: aChannel = new DLddMmcCntrlInterface; sl@0: return aChannel ? KErrNone : KErrNoMemory; sl@0: } sl@0: sl@0: const TInt KDMmcThreadPriority = 27; sl@0: _LIT(KDMmcThread,"DMMCSDThread"); sl@0: sl@0: sl@0: /** sl@0: * Install driver sl@0: * sl@0: * @return TInt the error code sl@0: * sl@0: * @leave N/A sl@0: */ sl@0: TInt DLddFactoryMmcCntrlInterface::Install() sl@0: { sl@0: // Allocate a kernel thread to run the DFC sl@0: TInt r = Kern::DynamicDfcQCreate(gDfcQ, KDMmcThreadPriority, KDMmcThread); sl@0: sl@0: if (r != KErrNone) sl@0: return r; sl@0: __KTRACE_OPT(KHARDWARE,MMCSDLOG("installing driver name from factory")); sl@0: return SetName(&KLddName); sl@0: } sl@0: sl@0: /** sl@0: * Get the Pc Card Contoller Interface ldd's version info sl@0: * sl@0: * @param TDes8 &aDes - Buffer to contain version info sl@0: * sl@0: * @return N/A sl@0: * sl@0: * @leave N/A sl@0: */ sl@0: void DLddFactoryMmcCntrlInterface::GetCaps(TDes8 &aDes) const sl@0: { sl@0: TCapsMmcIfV01 b; sl@0: b.version=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber); sl@0: aDes.FillZ(aDes.MaxLength()); sl@0: aDes.Copy((TUint8 *)&b,Min(aDes.MaxLength(),sizeof(b))); sl@0: } sl@0: sl@0: /** sl@0: * Destructor sl@0: * sl@0: * @return N/A sl@0: * sl@0: * @leave N/A sl@0: */ sl@0: DLddFactoryMmcCntrlInterface::~DLddFactoryMmcCntrlInterface() sl@0: { sl@0: if (gDfcQ) sl@0: gDfcQ->Destroy(); sl@0: } sl@0: sl@0: /** sl@0: * DLddMmcCntrlInterface constructor sl@0: * sl@0: * @return N/A sl@0: * sl@0: * @leave N/A sl@0: */ sl@0: DLddMmcCntrlInterface::DLddMmcCntrlInterface() sl@0: { sl@0: iClient = &Kern::CurrentThread(); sl@0: ((DObject*)iClient)->Open(); // can't fail since thread is running sl@0: } sl@0: sl@0: /** sl@0: * Destructor sl@0: * sl@0: * @return N/A sl@0: * sl@0: * @leave N/A sl@0: */ sl@0: DLddMmcCntrlInterface::~DLddMmcCntrlInterface() sl@0: { sl@0: Kern::SafeClose((DObject*&)iClient,NULL); sl@0: iAsyncList.ResetAndDestroy(); sl@0: } sl@0: sl@0: /** sl@0: * Create driver ojects sl@0: * sl@0: * @param TInt aUnit - Socket ID sl@0: * @param const TDesC8* aInfo - Buffer for logging sl@0: * @param const TVersion& aVer - Current version sl@0: * sl@0: * @return TInt the error code sl@0: * sl@0: * @leave N/A sl@0: */ sl@0: TInt DLddMmcCntrlInterface::DoCreate(TInt aUnit, const TDesC8* aInfo, const TVersion& aVer) sl@0: { sl@0: if (!Kern::QueryVersionSupported(TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber),aVer)) sl@0: return(KErrNotSupported); sl@0: sl@0: MMCSDLOG2("DLddMmcCntrlInterface::DoCreate called aInfo(%S)", aInfo); sl@0: sl@0: // create the socket - there is only a DMMCSocket sl@0: iSocket = static_cast(DPBusSocket::SocketFromId(aUnit)); sl@0: if(!iSocket) sl@0: return(KErrNoMemory); sl@0: sl@0: //Obtain the appropriate card from the stack sl@0: iStack = static_cast(iSocket->Stack(KStackNo)); sl@0: if(iStack == NULL) sl@0: return(KErrNoMemory); sl@0: sl@0: //Obtain the appropriate card power supply sl@0: iPsu=static_cast(iSocket->iVcc); sl@0: if (iPsu==NULL) sl@0: return(KErrNoMemory); sl@0: sl@0: //Obtain the appropriate card Media change sl@0: iMediaChange=static_cast(iSocket->iMediaChange); sl@0: if (iMediaChange==NULL) sl@0: return(KErrNoMemory); sl@0: sl@0: SetDfcQ(gDfcQ); sl@0: iMsgQ.Receive(); sl@0: sl@0: iUnit = aUnit; // save the unit - needed for regitering callbacks for subsequent bus events sl@0: sl@0: return(KErrNone); sl@0: } sl@0: sl@0: /** sl@0: * Request cancelled callback sl@0: * sl@0: * @param TInt sReqNo - Request Number sl@0: * sl@0: * @return N/A sl@0: * sl@0: * @leave N/A sl@0: */ sl@0: void DLddMmcCntrlInterface::DoCancel(TInt /*aReqNo*/) sl@0: { sl@0: } sl@0: sl@0: /** sl@0: * Handle kernel side message sl@0: * sl@0: * @param TMessageBase* aMsg - The kernel side message sl@0: * sl@0: * @return N/A sl@0: * sl@0: * @leave N/A sl@0: */ sl@0: void DLddMmcCntrlInterface::HandleMsg(TMessageBase* aMsg) sl@0: { sl@0: TThreadMessage& m=*(TThreadMessage*)aMsg; sl@0: TInt id=m.iValue; sl@0: sl@0: if (id==(TInt)ECloseMsg) sl@0: { sl@0: m.Complete(KErrNone, EFalse); sl@0: return; sl@0: } sl@0: else if (id==KMaxTInt) sl@0: { sl@0: // DoCancel sl@0: m.Complete(KErrNone,ETrue); sl@0: return; sl@0: } sl@0: sl@0: if (id<0) sl@0: { sl@0: // DoRequest sl@0: TRequestStatus* pS=(TRequestStatus*)m.Ptr0(); sl@0: TInt r=DoRequest(~id, pS, m.Ptr1(), m.Ptr2()); sl@0: if (r!=KErrNone) sl@0: Kern::RequestComplete(iClient, pS, r); sl@0: m.Complete(KErrNone,ETrue); sl@0: } sl@0: else sl@0: { sl@0: // DoControl sl@0: TInt r=DoControl(id,m.Ptr0(),m.Ptr1()); sl@0: if(r != KErrCompletion) sl@0: { sl@0: m.Complete(r,ETrue); sl@0: } sl@0: } sl@0: } sl@0: sl@0: /** sl@0: * Do a kernel side request sl@0: * sl@0: * @param TInt aFunction - Request Function ID sl@0: * @param TRequestStatus* aStatus - Request Status sl@0: * @param TAny* a1 - Given parameter sl@0: * @param TAny* a2 - Given parameter sl@0: * sl@0: * @return TInt the error code sl@0: * sl@0: * @leave N/A sl@0: */ sl@0: TInt DLddMmcCntrlInterface::DoRequest(TInt aFunction, TRequestStatus* aStatus, TAny* a1, TAny *a2) sl@0: { sl@0: sl@0: TTCFunctionId fid = TTCFunctionId(aFunction); sl@0: switch(fid.TestType()) sl@0: { sl@0: case EMmcTestSocket: sl@0: return SocketDoRequest(aStatus, a1, a2, aFunction); sl@0: sl@0: case EMmcTestStack: sl@0: case EMmcTestPsu: sl@0: case EMmcTestMediaChange: sl@0: case EMmcGeneralTest: sl@0: default: sl@0: break; sl@0: }; sl@0: sl@0: switch(fid.FunctionId()) sl@0: { sl@0: case RMMCSDTestControllerInterface::EReadSector: sl@0: { sl@0: // read sector a1 is block number, a2 is client descriptor sl@0: // data will be written back to upon completion sl@0: MMCSDLOG3("RMMCSDTestControllerInterface::EReadSector a1(%d) a2(%x)", (TUint32)a1, a2); sl@0: if(!iCard) sl@0: { sl@0: MMCSDLOG("RMMCSDTestControllerInterface::EReadSector NULL card\n"); sl@0: return KErrNotReady; sl@0: } sl@0: sl@0: DMmcSessionAsyncRequest* request = CreateAsyncSessionRequest(EMmcSesReadBlk, aStatus); sl@0: sl@0: TUint32 srcAddr=((TUint32)a1)<MaxReadBlLen(); sl@0: TUint readBlMask=(readBlLen-1); sl@0: request->iBlkOffet=srcAddr-(srcAddr&(~readBlMask)); sl@0: request->iClientDesPtr = a2; sl@0: srcAddr &= (~readBlMask); sl@0: sl@0: MMCSDLOG("RMMCSDTestControllerInterface::EReadSector #2"); sl@0: TMMCArgument da(srcAddr); sl@0: sl@0: request->Session().SetupCIMReadBlock(da,readBlLen,&(request->iBuf[0])); sl@0: request->Session().Engage(); sl@0: sl@0: MMCSDLOG("RMMCSDTestControllerInterface::EReadSector #3"); sl@0: break; sl@0: } sl@0: case RMMCSDTestControllerInterface::EWriteSector: sl@0: { sl@0: MMCSDLOG3("RMMCSDTestControllerInterface::EWriteSector a1(%d) a2(%x) #1", (TUint32)a1, a2); sl@0: if(!iCard) sl@0: { sl@0: MMCSDLOG("RMMCSDTestControllerInterface::EWriteSector NULL card\n"); sl@0: return KErrNotReady; sl@0: } sl@0: sl@0: TUint32 destAddr=((TUint32)a1)<MaxWriteBlLen(); sl@0: sl@0: DMmcSessionAsyncRequest* request = CreateAsyncSessionRequest(EMmcSesWriteBlk, aStatus); sl@0: sl@0: TUint writeBlMask=(writeBlLen-1); sl@0: request->iBlkOffet=destAddr-(destAddr&(~writeBlMask)); sl@0: TPtr8* srcDes = (TPtr8*)a2; sl@0: TPtr8 ptr(&(request->iBuf[request->iBlkOffet]),KSectorSizeInBytes,KSectorSizeInBytes); sl@0: TInt r = Kern::ThreadDesRead(iClient, srcDes, ptr, 0, KChunkShiftBy0); sl@0: if(r != KErrNone) sl@0: { sl@0: return(r); sl@0: } sl@0: sl@0: destAddr&=(~writeBlMask); sl@0: request->Session().SetupCIMWriteBlock(TMMCArgument(destAddr),writeBlLen,&(request->iBuf[0])); sl@0: request->Session().Engage(); sl@0: sl@0: MMCSDLOG("RMMCSDTestControllerInterface::EWriteSector #4"); sl@0: break; sl@0: } sl@0: } sl@0: return(KErrNone); sl@0: } sl@0: sl@0: /** sl@0: * Do a kernel side control sl@0: * sl@0: * @param TInt aFunction - Request Function ID sl@0: * @param TAny* a1 - Given parameter sl@0: * @param TAny* a2 - Given parameter sl@0: * sl@0: * @return TInt the error code sl@0: * sl@0: * @leave N/A sl@0: */ sl@0: TInt DLddMmcCntrlInterface::DoControl(TInt aFunction,TAny* a1,TAny* a2) sl@0: { sl@0: TInt r = KErrNotSupported; sl@0: TTCFunctionId fid = TTCFunctionId(aFunction); sl@0: MMCSDLOG4("DLddMmcCntrlInterface::DoControl aFunction(%d) \ sl@0: fid.FunctionId()(%d) fid.TestType(%d)" sl@0: , aFunction, fid.FunctionId(), fid.TestType()); sl@0: sl@0: switch(fid.TestType()) sl@0: { sl@0: case EMmcTestStack: sl@0: return StackDoControl(aFunction, a1, a2); sl@0: case EMmcTestSocket: sl@0: return SocketDoControl(aFunction, a1, a2); sl@0: case EMmcTestPsu: sl@0: return PsuDoControl(aFunction, a1, a2); sl@0: case EMmcTestMediaChange: sl@0: return MediaChangeDoControl(aFunction, a1, a2); sl@0: case EMmcGeneralTest: sl@0: default: sl@0: break; sl@0: }; sl@0: sl@0: switch (fid.FunctionId()) sl@0: { sl@0: case RMMCSDTestControllerInterface::EReadCSD: sl@0: { sl@0: iCSD = iCard->CSD(); sl@0: { sl@0: TCSDInfo csdInfo(iCSD); sl@0: r = Kern::ThreadRawWrite(iClient, a1, &csdInfo, sizeof(csdInfo)); sl@0: } sl@0: } sl@0: break; sl@0: sl@0: case RMMCSDTestControllerInterface::EReadExtCSD: sl@0: { sl@0: iExtendedCSD = iCard->ExtendedCSD(); sl@0: TExtendedCSDInfo extendedCSDInfo(iExtendedCSD); sl@0: r = Kern::ThreadRawWrite(iClient, a1, &extendedCSDInfo, sizeof(extendedCSDInfo)); sl@0: } sl@0: break; sl@0: sl@0: case RMMCSDTestControllerInterface::ECardInfo: sl@0: { sl@0: TMMCCardInfo cardInfo; sl@0: cardInfo.SetCardInfo(*iCard); sl@0: r = Kern::ThreadRawWrite(iClient, a1, &cardInfo, sizeof(cardInfo)); sl@0: } sl@0: break; sl@0: sl@0: case RMMCSDTestControllerInterface::ECard: sl@0: { sl@0: r = Kern::ThreadRawWrite(iClient, a1, &iCard, sizeof(iCard)); sl@0: } sl@0: break; sl@0: sl@0: case RMMCSDTestControllerInterface::ECardIsPresent: sl@0: { sl@0: TBool isPresent = iCard->IsPresent(); sl@0: r = Kern::ThreadRawWrite(iClient, a1, &isPresent, sizeof(isPresent)); sl@0: } sl@0: break; sl@0: sl@0: case RMMCSDTestControllerInterface::ECardIsReady: sl@0: { sl@0: TBool isReady = iCard->IsReady(); sl@0: r = Kern::ThreadRawWrite(iClient, a1, &isReady, sizeof(isReady)); sl@0: } sl@0: break; sl@0: sl@0: case RMMCSDTestControllerInterface::ECardIsLocked: sl@0: { sl@0: TBool isLocked = iCard->IsLocked(); sl@0: r = Kern::ThreadRawWrite(iClient, a1, &isLocked, sizeof(isLocked)); sl@0: } sl@0: break; sl@0: sl@0: default: sl@0: { sl@0: MMCSDLOG2("DLddMmcCntrlInterface::DoControl - Invalid FunctionId()(%d)", fid.FunctionId()); sl@0: } sl@0: break; sl@0: } sl@0: sl@0: sl@0: return (r); sl@0: } sl@0: sl@0: /** sl@0: * Check if a request status exists sl@0: * sl@0: * @param TRequestStatus* aStatus - Request Status sl@0: * sl@0: * @return TBool A request status exists sl@0: * sl@0: * @leave N/A sl@0: */ sl@0: TBool DLddMmcCntrlInterface::RequestStatusExists(TRequestStatus* aStatus) sl@0: { sl@0: sl@0: // check whether this request status already exists in the async request list sl@0: for(int i=0;iStatus(%x)", i, iAsyncList[i]->Status()); sl@0: sl@0: if(iAsyncList[i]->Status() == aStatus) sl@0: { sl@0: MMCSDLOG3("WaRNING - adding duplicate TRequestStatus index[%d] aStatus(%x)", i, aStatus); sl@0: return ETrue; sl@0: } sl@0: } sl@0: sl@0: return EFalse; sl@0: } sl@0: sl@0: /** sl@0: * Create Asynchronous Session Request sl@0: * sl@0: * @param TMmcAsyncCmd aFunctionId - Request Function ID sl@0: * @param TRequestStatus* aStatus - Request Status sl@0: * sl@0: * @return DMmcSessionAsyncRequest* Poniter to the created session request object sl@0: * sl@0: * @leave N/A sl@0: */ sl@0: DMmcSessionAsyncRequest* DLddMmcCntrlInterface::CreateAsyncSessionRequest(TMmcAsyncCmd aFunctionId, TRequestStatus* aStatus) sl@0: { sl@0: sl@0: MMCSDLOG3("DLddMmcCntrlInterface::CreateAsyncRequest aStatus(%x) num requests in list (%d)", sl@0: aStatus, iAsyncList.Count()); sl@0: sl@0: // create an async request & append to async request list sl@0: DMmcSessionAsyncRequest* request = new DMmcSessionAsyncRequest(aFunctionId, aStatus, *this, gDfcQ, *iStack, *iCard); sl@0: iAsyncList.Append(request); sl@0: MMCSDLOG4("DLddMmcCntrlInterface::CreateAsyncSessionRequest created OK Status(%x) functionID(%d) aFunctionId(%d)", sl@0: request->Status(), request->FunctionId(), aFunctionId); sl@0: return request; sl@0: } sl@0: sl@0: /** sl@0: * Create Asynchronous Bus Event Request sl@0: * sl@0: * @param TMmcAsyncCmd aFunctionId - Request Function ID sl@0: * @param TRequestStatus* aStatus - Request Status sl@0: * @param TInt aUnit - Socket ID sl@0: * sl@0: * @return DBusEventRequest* Poniter to the created bus event request object sl@0: * sl@0: * @leave N/A sl@0: */ sl@0: DBusEventRequest* DLddMmcCntrlInterface::CreateAsyncBusEventRequest(TMmcAsyncCmd aFunctionId, TRequestStatus* aStatus, TInt aUnit) sl@0: { sl@0: MMCSDLOG3("DLddMmcCntrlInterface::CreateAsyncBusEventRequest aStatus(%x) num requests in list (%d)", sl@0: aStatus, iAsyncList.Count()); sl@0: sl@0: MMCSDLOG4("gDfcQ(%x), iStack(%x), iCard(%x)", gDfcQ, iStack, iCard); sl@0: sl@0: // create an async request & append toS async request list sl@0: DBusEventRequest* request = new DBusEventRequest(aFunctionId, aStatus, *this, aUnit, gDfcQ, *iStack, *iCard); sl@0: iAsyncList.Append(request); sl@0: MMCSDLOG4("DLddMmcCntrlInterface::CreateAsyncBusEventRequest created OK Status(%x) functionID(%d) aFunctionId(%d)", sl@0: request->Status(), request->FunctionId(), aFunctionId); sl@0: return request; sl@0: sl@0: } sl@0: sl@0: /** sl@0: * Clears an asynchronous Request from list sl@0: * sl@0: * @param DLddAsyncRequest* aRequest - Pointer to the request sl@0: * sl@0: * @return N/A sl@0: * sl@0: * @leave N/A sl@0: */ sl@0: void DLddMmcCntrlInterface::ClearRequest(DLddAsyncRequest* aRequest) sl@0: { sl@0: if(!aRequest) sl@0: { sl@0: MMCSDLOG("ERROR IN DLddMmcCntrlInterface::ClearRequest NULL request"); sl@0: return; sl@0: } sl@0: sl@0: TInt i = iAsyncList.Find(aRequest); sl@0: if(i >= 0) sl@0: { sl@0: iAsyncList.Remove(i); sl@0: } sl@0: else sl@0: { sl@0: MMCSDLOG2("ERROR IN DLddMmcCntrlInterface::ClearRequest err(%d)", i); sl@0: } sl@0: sl@0: delete aRequest; sl@0: sl@0: } sl@0: sl@0: /** sl@0: * Callback when request has completed sl@0: * sl@0: * @param DLddAsyncRequest& aRequest - The completed request sl@0: * sl@0: * @return N/A sl@0: * sl@0: * @leave N/A sl@0: */ sl@0: void DLddMmcCntrlInterface::Notify(DLddAsyncRequest& aRequest) // callback from DLddAsyncRequest sl@0: { sl@0: MMCSDLOG("DLddMmcCntrlInterface::Notify called"); sl@0: TRequestStatus* status = aRequest.Status(); sl@0: switch (aRequest.FunctionId()) sl@0: { sl@0: case DLddMmcCntrlInterface::EMmcSesReadBlk: sl@0: { sl@0: DMmcSessionAsyncRequest& request = (DMmcSessionAsyncRequest&) aRequest; sl@0: MMCSDLOG("DLddMmcCntrlInterface::ReadBlockComplete"); sl@0: TInt r = KErrNone; sl@0: if (request.iClientDesPtr) // have we supplied descriptor to hold returned data sl@0: { sl@0: TPtr8 ptr(&(request.iBuf[request.iBlkOffet]), KSectorSizeInBytes, KSectorSizeInBytes); sl@0: TPtrC8* srcDes = (TPtrC8*)request.iClientDesPtr; sl@0: r = Kern::ThreadDesWrite(iClient, srcDes, ptr, 0, iClient); sl@0: if(r != KErrNone) sl@0: { sl@0: MMCSDLOG2("ERROR DLddMmcCntrlInterface::ReadBlockComplete Kern::ThreadDesWrite returned r(%d)", r); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: MMCSDLOG("ERROR DLddMmcCntrlInterface::ReadExtCSDComplete - No pointer provided to hold returned data"); sl@0: Kern::PanicCurrentThread(_L("PBUS-MMC"), 0); sl@0: } sl@0: Kern::RequestComplete(iClient, status, (r == KErrNone) ? aRequest.Error() : r); sl@0: } sl@0: break; sl@0: sl@0: case DLddMmcCntrlInterface::EMmcSesWriteBlk: sl@0: { sl@0: MMCSDLOG("DLddMmcCntrlInterface::WriteBlockComplete)"); sl@0: TRequestStatus* status = aRequest.Status(); sl@0: Kern::RequestComplete(iClient, status, aRequest.Error()); sl@0: } sl@0: break; sl@0: sl@0: case DLddMmcCntrlInterface::EMmcSesReadCSD: sl@0: { sl@0: DMmcSessionAsyncRequest& request = (DMmcSessionAsyncRequest&) aRequest; sl@0: MMCSDLOG("DLddMmcCntrlInterface::ReadCSDComplete"); sl@0: TInt r = KErrNone; sl@0: if (request.iClientDesPtr) // have we supplied pointer to hold returned data sl@0: { sl@0: { sl@0: TCSDInfo csdInfo(iCSD); sl@0: r = Kern::ThreadRawWrite(iClient, request.iClientDesPtr, &csdInfo, sizeof(csdInfo)); sl@0: } sl@0: if(r != KErrNone) sl@0: { sl@0: MMCSDLOG2("ERROR DLddMmcCntrlInterface::ReadCSDComplete Kern::ThreadRawWrite returned r(%d)", r); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: MMCSDLOG("ERROR DLddMmcCntrlInterface::ReadExtCSDComplete - No pointer provided to hold returned data"); sl@0: Kern::PanicCurrentThread(_L("PBUS-MMC"), 0); sl@0: } sl@0: Kern::RequestComplete(iClient, status, (r == KErrNone) ? aRequest.Error() : r); sl@0: } sl@0: break; sl@0: sl@0: case DLddMmcCntrlInterface::EMmcSesReadExtCSD: sl@0: { sl@0: DMmcSessionAsyncRequest& request = (DMmcSessionAsyncRequest&) aRequest; sl@0: MMCSDLOG("DLddMmcCntrlInterface::ReadExtCSDComplete"); sl@0: TInt r = KErrNone; sl@0: if (request.iClientDesPtr) // have we supplied pointer to hold returned data sl@0: { sl@0: TExtendedCSDInfo extendedCSDInfo(iExtendedCSD); sl@0: r = Kern::ThreadRawWrite(iClient, request.iClientDesPtr, &extendedCSDInfo, sizeof(extendedCSDInfo)); sl@0: if(r != KErrNone) sl@0: { sl@0: MMCSDLOG2("ERROR DLddMmcCntrlInterface::ReadExtCSDComplete Kern::ThreadRawWrite returned r(%d)", r); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: MMCSDLOG("ERROR DLddMmcCntrlInterface::ReadExtCSDComplete - No pointer provided to hold returned data"); sl@0: Kern::PanicCurrentThread(_L("PBUS-MMC"), 0); sl@0: } sl@0: Kern::RequestComplete(iClient, status, (r == KErrNone) ? aRequest.Error() : r); sl@0: } sl@0: break; sl@0: sl@0: case DLddMmcCntrlInterface::EMMcSocketPowerUp: sl@0: { sl@0: DBusEventRequest& request = (DBusEventRequest&) aRequest; sl@0: TInt retCode = KErrNone; sl@0: sl@0: MMCSDLOG2("DLddMmcCntrlInterface::EMMcSocketPowerUp ret code = %d", aRequest.Error()); sl@0: MMCSDLOG2("DLddMmcCntrlInterface::EMMcSocketPowerUp request.BusState() = %d", request.BusState()); sl@0: MMCSDLOG2("DLddMmcCntrlInterface::EMMcSocketPowerUp request.BusError() = %d", request.BusError()); sl@0: sl@0: switch(aRequest.Error()) sl@0: { sl@0: case TPBusCallBack::EPBusStateChange: sl@0: { sl@0: TPBusState newState = request.BusState(); sl@0: retCode = request.BusError(); sl@0: sl@0: if (retCode == KErrNone) sl@0: { sl@0: switch(newState) sl@0: { sl@0: case EPBusCardAbsent: retCode = KErrNotFound; break; sl@0: case EPBusPsuFault: retCode = KErrBadPower; break; sl@0: case EPBusOff: sl@0: case EPBusOn: sl@0: case EPBusPowerUpPending: sl@0: case EPBusPoweringUp: sl@0: default: sl@0: break; sl@0: } sl@0: } sl@0: sl@0: break; sl@0: } sl@0: } sl@0: sl@0: Kern::RequestComplete(iClient, status, retCode); sl@0: } sl@0: break; sl@0: sl@0: default: sl@0: MMCSDLOG("#######################################################################"); sl@0: MMCSDLOG("## UNHANDLED END DFC DLddAsyncRequest DLddMmcCntrlInterface::Notify ##"); sl@0: MMCSDLOG2("## aRequest.FunctionId(%d) ##", aRequest.FunctionId()); sl@0: MMCSDLOG("#######################################################################"); sl@0: Kern::PanicCurrentThread(_L("PBUS-MMC"), 0); sl@0: break; sl@0: }; sl@0: sl@0: ClearRequest(&aRequest); sl@0: sl@0: } sl@0: