diff -r 43365a9b78a3 -r d8d70de2bd36 kerneltest/e32test/dmav2/d_dma2.cpp --- a/kerneltest/e32test/dmav2/d_dma2.cpp Tue Jul 06 15:50:07 2010 +0300 +++ b/kerneltest/e32test/dmav2/d_dma2.cpp Wed Aug 18 11:08:29 2010 +0300 @@ -101,6 +101,8 @@ TInt OpenDmaChannel(TUint aPslCookie, TUint& aDriverCookie); TInt OpenDmaChannel(TUint& aDriverCookie, TDmaChannel::SCreateInfo& aInfo); + TInt LinkDmaChannelByCookie(TUint aDriverCookie); + TInt UnlinkDmaChannelByCookie(TUint aDriverCookie); TInt CloseDmaChannelByCookie(TUint aDriverCookie); TInt PauseDmaChannelByCookie(TUint aDriverCookie); TInt ResumeDmaChannelByCookie(TUint aDriverCookie); @@ -109,12 +111,26 @@ TInt CancelAllByCookie(TUint aDriverCookie); TInt IsrRedoRequestByCookie(TUint aDriverCookie,TUint32 aSrcAddr,TUint32 aDstAddr,TInt aTransferCount,TUint32 aPslRequestInfo,TBool aIsrCb); TInt IsQueueEmptyByCookie(TUint aDriverCookie, TBool& aQueueEmpty); - TInt ChannelIsOpenedByCookie(TUint aDriverCookie, TBool& aChannelOpen); + TInt ChannelIsOpenedByCookie(TUint aDriverCookie, TBool& aChannelOpen); + TInt EnableDstElementCountingByCookie(TUint aDriverCookie); + TInt EnableSrcElementCountingByCookie(TUint aDriverCookie); + TInt DisableDstElementCountingByCookie(TUint aDriverCookie); + TInt DisableSrcElementCountingByCookie(TUint aDriverCookie); + TInt TotalNumDstElementsTransferredByCookie(TUint aDriverCookie); + TInt TotalNumSrcElementsTransferredByCookie(TUint aDriverCookie); void CloseDmaChannelByIndex(TInt aIndex); void CancelAllByIndex(TInt aIndex); + TInt LinkDmaChannelByIndex(TInt aIndex); + TInt UnlinkDmaChannelByIndex(TInt aIndex); TInt PauseDmaChannelByIndex(TInt aIndex); TInt ResumeDmaChannelByIndex(TInt aIndex); TInt IsrRedoRequestByIndex(TInt aIndex,TUint32 aSrcAddr,TUint32 aDstAddr,TInt aTransferCount,TUint32 aPslRequestInfo,TBool aIsrCb); + void EnableDstElementCountingByIndex(TInt aIndex); + void EnableSrcElementCountingByIndex(TInt aIndex); + void DisableDstElementCountingByIndex(TInt aIndex); + void DisableSrcElementCountingByIndex(TInt aIndex); + TInt TotalNumDstElementsTransferredByIndex(TInt aIndex); + TInt TotalNumSrcElementsTransferredByIndex(TInt aIndex); TInt CreateSharedChunk(); TUint OpenSharedChunkHandle(); @@ -145,13 +161,12 @@ TInt QueueRequest(TUint aRequestCookie, TRequestStatus* aStatus, TCallbackRecord* aRecord, TUint64* aDurationMicroSecs); DClientDmaRequest* RequestFromCookie(TUint aRequestCookie) const; TInt RequestFragmentCount(TUint aRequestCookie); - TDmaV2TestInfo ConvertTestInfo(const TDmaTestInfo& aOldInfo) const; private: DThread* iClient; TDynamicDfcQue* iDfcQ; TDynamicDfcQue* iIsrCallbackDfcQ; // Will be used by requests which complete with an ISR callback - static const TInt KMaxChunkSize = 8 * KMega; + static const TInt KMaxChunkSize; TLinAddr iChunkBase; DChunk* iChunk; @@ -377,7 +392,7 @@ The new style callback called by the DMA framework may be called in either thread or ISR context */ -void DClientDmaRequest::Callback(TUint aCallbackType, TDmaResult aResult, TAny* aArg, SDmaDesHdr* aHdr) +void DClientDmaRequest::Callback(TUint aCallbackType, TDmaResult aResult, TAny* aArg, SDmaDesHdr* /*aHdr*/) { const TInt context = NKern::CurrentContext(); __KTRACE_OPT(KDMA, Kern::Printf(">DClientDmaRequest::CallBack: TDmaResult result = %d, NKern::TContext context = %d", aResult, context)); @@ -503,7 +518,7 @@ Kern::QueueRequestComplete(self.iClient, self.iClientDataRequest, KErrNone); } -const TInt DDmaTestSession::KMaxChunkSize; +const TInt DDmaTestSession::KMaxChunkSize = 8 * KMega; TInt DDmaTestSession::RequestUserHandle(DThread* aThread, TOwnerType aType) { @@ -517,24 +532,31 @@ {} // called in thread critical section -TInt DDmaTestSession::DoCreate(TInt /*aUnit*/, const TDesC8* aInfo, const TVersion& /*aVer*/) +TInt DDmaTestSession::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/) { __NK_ASSERT_ALWAYS(iDfcQ == NULL); __NK_ASSERT_ALWAYS(iIsrCallbackDfcQ == NULL); TInt r = Kern::DynamicDfcQCreate(iDfcQ, KDFCThreadPriority, KDFCThreadName); if (r != KErrNone) + { + Kern::Printf("DDmaTestSession::DoCreate D_DMA_DFC_THREAD returned (%d)\n", r); return r; + } NKern::ThreadSetCpuAffinity((NThread*)(iDfcQ->iThread), KCpuAffinityAny); r = Kern::DynamicDfcQCreate(iIsrCallbackDfcQ, KDFCThreadPriority, KIsrCbDfcThreadName); if (r != KErrNone) + { + Kern::Printf("DDmaTestSession::DoCreate D_DMA_IsrCb_thread returned (%d)\n", r); return r; + } NKern::ThreadSetCpuAffinity((NThread*)(iIsrCallbackDfcQ->iThread), KCpuAffinityAny); iClient = &Kern::CurrentThread(); r = CreateSharedChunk(); + Kern::Printf("DDmaTestSession::DoCreate CreateSharedChunk returned (%d)\n", r); return r; } @@ -636,12 +658,60 @@ TInt r = ResumeDmaChannelByCookie(driverCookie); return r; } + case RDmaSession::ELinkChannel: + { + TUint driverCookie = reinterpret_cast(a1); + TInt r = LinkDmaChannelByCookie(driverCookie); + return r; + } + case RDmaSession::EUnlinkChannel: + { + TUint driverCookie = reinterpret_cast(a1); + TInt r = UnlinkDmaChannelByCookie(driverCookie); + return r; + } case RDmaSession::EFragmentCount: { TUint requestCookie = reinterpret_cast(a1); TInt r = RequestFragmentCount(requestCookie); return r; } + case RDmaSession::EEnableDstElementCounting: + { + TUint requestCookie = reinterpret_cast(a1); + TInt r = EnableDstElementCountingByCookie(requestCookie); + return r; + } + case RDmaSession::EEnableSrcElementCounting: + { + TUint requestCookie = reinterpret_cast(a1); + TInt r = EnableSrcElementCountingByCookie(requestCookie); + return r; + } + case RDmaSession::EDisableDstElementCounting: + { + TUint requestCookie = reinterpret_cast(a1); + TInt r = DisableDstElementCountingByCookie(requestCookie); + return r; + } + case RDmaSession::EDisableSrcElementCounting: + { + TUint requestCookie = reinterpret_cast(a1); + TInt r = DisableSrcElementCountingByCookie(requestCookie); + return r; + } + case RDmaSession::ETotalNumDstElementsTransferred: + { + TUint requestCookie = reinterpret_cast(a1); + TInt r = TotalNumDstElementsTransferredByCookie(requestCookie); + return r; + } + case RDmaSession::ETotalNumSrcElementsTransferred: + { + TUint requestCookie = reinterpret_cast(a1); + TInt r = TotalNumSrcElementsTransferredByCookie(requestCookie); + return r; + } case RDmaSession::ERequestOpen: { RDmaSession::TRequestCreateArgs createArgs(0, EFalse, 0); @@ -915,6 +985,64 @@ channel->CancelAll(); } +TInt DDmaTestSession::LinkDmaChannelByIndex(TInt aIndex) + { + __KTRACE_OPT(KDMA, Kern::Printf("LinkDmaChannelByIndex: %d", aIndex)); + __NK_ASSERT_DEBUG(aIndex < iChannels.Count()); + +#ifdef DMA_APIV2 + TDmaChannel* channel = iChannels[aIndex]; + return channel->LinkToChannel(channel); +#else + return KErrNotSupported; +#endif + } + +TInt DDmaTestSession::LinkDmaChannelByCookie(TUint aDriverCookie) + { + __KTRACE_OPT(KDMA, Kern::Printf("LinkDmaChannelByCookie: 0x%08x", aDriverCookie)); + const TInt index = CookieToChannelIndex(aDriverCookie); + + if(index >= 0) + { + TInt r = LinkDmaChannelByIndex(index); + return r; + } + else + { + return KErrNotFound; + } + } + +TInt DDmaTestSession::UnlinkDmaChannelByIndex(TInt aIndex) + { + __KTRACE_OPT(KDMA, Kern::Printf("UnlinkDmaChannelByIndex: %d", aIndex)); + __NK_ASSERT_DEBUG(aIndex < iChannels.Count()); + +#ifdef DMA_APIV2 + TDmaChannel* channel = iChannels[aIndex]; + return channel->LinkToChannel(NULL); +#else + return KErrNotSupported; +#endif + } + +TInt DDmaTestSession::UnlinkDmaChannelByCookie(TUint aDriverCookie) + { + __KTRACE_OPT(KDMA, Kern::Printf("UnlinkDmaChannelByCookie: 0x%08x", aDriverCookie)); + const TInt index = CookieToChannelIndex(aDriverCookie); + + if(index >= 0) + { + TInt r = UnlinkDmaChannelByIndex(index); + return r; + } + else + { + return KErrNotFound; + } + } + TInt DDmaTestSession::PauseDmaChannelByIndex(TInt aIndex) { __KTRACE_OPT(KDMA, Kern::Printf("PauseDmaChannelByIndex: %d", aIndex)); @@ -973,6 +1101,164 @@ } } +TInt DDmaTestSession::EnableDstElementCountingByCookie(TUint aDriverCookie) + { + __KTRACE_OPT(KDMA, Kern::Printf("EnableDstElementCountingByCookie: 0x%08x", aDriverCookie)); + const TInt index = CookieToRequestIndex(aDriverCookie); + + if(index >= 0) + { + EnableDstElementCountingByIndex(index); + return KErrNone; + } + else + { + return KErrNotFound; + } + } + +void DDmaTestSession::EnableDstElementCountingByIndex(TInt aIndex) + { + __KTRACE_OPT(KDMA, Kern::Printf("EnableDstElementCountingByIndex: %d", aIndex)); + __NK_ASSERT_DEBUG(aIndex < iClientDmaReqs.Count()); +#ifdef DMA_APIV2 + iClientDmaReqs[aIndex]->EnableDstElementCounting(); +#endif + } + +TInt DDmaTestSession::EnableSrcElementCountingByCookie(TUint aDriverCookie) + { + __KTRACE_OPT(KDMA, Kern::Printf("EnableSrcElementCountingByCookie: 0x%08x", aDriverCookie)); + const TInt index = CookieToRequestIndex(aDriverCookie); + + if(index >= 0) + { + EnableSrcElementCountingByIndex(index); + return KErrNone; + } + else + { + return KErrNotFound; + } + } + +void DDmaTestSession::EnableSrcElementCountingByIndex(TInt aIndex) + { + __KTRACE_OPT(KDMA, Kern::Printf("EnableSrcElementCountingByIndex: %d", aIndex)); + __NK_ASSERT_DEBUG(aIndex < iClientDmaReqs.Count()); + +#ifdef DMA_APIV2 + iClientDmaReqs[aIndex]->EnableSrcElementCounting(); +#endif + } + +TInt DDmaTestSession::DisableDstElementCountingByCookie(TUint aDriverCookie) + { + __KTRACE_OPT(KDMA, Kern::Printf("DisableDstElementCountingByCookie: 0x%08x", aDriverCookie)); + const TInt index = CookieToRequestIndex(aDriverCookie); + + if(index >= 0) + { + DisableDstElementCountingByIndex(index); + return KErrNone; + } + else + { + return KErrNotFound; + } + } + +void DDmaTestSession::DisableDstElementCountingByIndex(TInt aIndex) + { + __KTRACE_OPT(KDMA, Kern::Printf("DisableDstElementCountingByIndex: %d", aIndex)); + __NK_ASSERT_DEBUG(aIndex < iClientDmaReqs.Count()); +#ifdef DMA_APIV2 + iClientDmaReqs[aIndex]->DisableDstElementCounting(); +#endif + } + +TInt DDmaTestSession::DisableSrcElementCountingByCookie(TUint aDriverCookie) + { + __KTRACE_OPT(KDMA, Kern::Printf("DisableSrcElementCountingByCookie: 0x%08x", aDriverCookie)); + const TInt index = CookieToRequestIndex(aDriverCookie); + + if(index >= 0) + { + DisableSrcElementCountingByIndex(index); + return KErrNone; + } + else + { + return KErrNotFound; + } + } + +void DDmaTestSession::DisableSrcElementCountingByIndex(TInt aIndex) + { + __KTRACE_OPT(KDMA, Kern::Printf("DisableSrcElementCountingByIndex: %d", aIndex)); + __NK_ASSERT_DEBUG(aIndex < iClientDmaReqs.Count()); +#ifdef DMA_APIV2 + iClientDmaReqs[aIndex]->DisableSrcElementCounting(); +#endif + } + +TInt DDmaTestSession::TotalNumDstElementsTransferredByCookie(TUint aDriverCookie) + { + __KTRACE_OPT(KDMA, Kern::Printf("TotalNumDstElementsTransferredByCookie: 0x%08x", aDriverCookie)); + const TInt index = CookieToRequestIndex(aDriverCookie); + + if(index >= 0) + { + TInt r = TotalNumDstElementsTransferredByIndex(index); + return r; + } + else + { + return KErrNotFound; + } + } + +TInt DDmaTestSession::TotalNumDstElementsTransferredByIndex(TInt aIndex) + { + __KTRACE_OPT(KDMA, Kern::Printf("TotalNumDstElementsTransferredByIndex: %d", aIndex)); + __NK_ASSERT_DEBUG(aIndex < iClientDmaReqs.Count()); + +#ifdef DMA_APIV2 + TInt r = iClientDmaReqs[aIndex]->TotalNumDstElementsTransferred(); + return r; +#else + return KErrNotSupported; +#endif + } + +TInt DDmaTestSession::TotalNumSrcElementsTransferredByCookie(TUint aDriverCookie) + { + __KTRACE_OPT(KDMA, Kern::Printf("TotalNumSrcElementsTransferredByCookie: 0x%08x", aDriverCookie)); + const TInt index = CookieToRequestIndex(aDriverCookie); + + if(index >= 0) + { + TInt r = TotalNumSrcElementsTransferredByIndex(index); + return r; + } + else + { + return KErrNotFound; + } + } + +TInt DDmaTestSession::TotalNumSrcElementsTransferredByIndex(TInt aIndex) + { + __KTRACE_OPT(KDMA, Kern::Printf("TotalNumSrcElementsTransferredByIndex: %d", aIndex)); + __NK_ASSERT_DEBUG(aIndex < iClientDmaReqs.Count()); + +#ifdef DMA_APIV2 + TInt r = iClientDmaReqs[aIndex]->TotalNumSrcElementsTransferred(); + return r; +#else + return KErrNotSupported; +#endif + } TInt DDmaTestSession::IsrRedoRequestByCookie(TUint aDriverCookie,TUint32 aSrcAddr,TUint32 aDstAddr,TInt aTransferCount,TUint32 aPslRequestInfo,TBool aIsrCb) { __KTRACE_OPT(KDMA, Kern::Printf("IsrRedoRequestByCookie: 0x%08x", aDriverCookie)); @@ -1152,7 +1438,10 @@ TChunkCreateInfo info; info.iType = TChunkCreateInfo::ESharedKernelSingle; info.iMaxSize = KMaxChunkSize; +#ifndef __WINS__ info.iMapAttr = EMapAttrFullyBlocking | EMapAttrUserRw; +#endif + info.iOwnsMemory = ETrue; info.iDestroyedDfc = NULL; @@ -1299,16 +1588,28 @@ newInfo.iMemMemPslInfo = aOldInfo.iMemMemPslInfo; newInfo.iMaxSbChannels = aOldInfo.iMaxSbChannels; - for(TInt i=0; i