kerneltest/e32test/dmav2/d_dma2.cpp
changeset 247 d8d70de2bd36
parent 139 95f71bcdcdb7
equal deleted inserted replaced
201:43365a9b78a3 247:d8d70de2bd36
    99 private:
    99 private:
   100 	TInt DoGetInfo(TAny* aInfo);
   100 	TInt DoGetInfo(TAny* aInfo);
   101 
   101 
   102 	TInt OpenDmaChannel(TUint aPslCookie, TUint& aDriverCookie);
   102 	TInt OpenDmaChannel(TUint aPslCookie, TUint& aDriverCookie);
   103 	TInt OpenDmaChannel(TUint& aDriverCookie, TDmaChannel::SCreateInfo& aInfo);
   103 	TInt OpenDmaChannel(TUint& aDriverCookie, TDmaChannel::SCreateInfo& aInfo);
       
   104 	TInt LinkDmaChannelByCookie(TUint aDriverCookie);	
       
   105 	TInt UnlinkDmaChannelByCookie(TUint aDriverCookie);
   104 	TInt CloseDmaChannelByCookie(TUint aDriverCookie);
   106 	TInt CloseDmaChannelByCookie(TUint aDriverCookie);
   105 	TInt PauseDmaChannelByCookie(TUint aDriverCookie);
   107 	TInt PauseDmaChannelByCookie(TUint aDriverCookie);
   106 	TInt ResumeDmaChannelByCookie(TUint aDriverCookie);
   108 	TInt ResumeDmaChannelByCookie(TUint aDriverCookie);
   107 	TInt GetChannelCapsByCookie(TUint aDriverCookie, SDmacCaps& aChannelCaps);
   109 	TInt GetChannelCapsByCookie(TUint aDriverCookie, SDmacCaps& aChannelCaps);
   108 	TInt GetChannelCapsByCookie(TUint aDriverCookie, TDmacTestCaps& aChannelCaps);
   110 	TInt GetChannelCapsByCookie(TUint aDriverCookie, TDmacTestCaps& aChannelCaps);
   109 	TInt CancelAllByCookie(TUint aDriverCookie);
   111 	TInt CancelAllByCookie(TUint aDriverCookie);
   110 	TInt IsrRedoRequestByCookie(TUint aDriverCookie,TUint32 aSrcAddr,TUint32 aDstAddr,TInt aTransferCount,TUint32 aPslRequestInfo,TBool aIsrCb);
   112 	TInt IsrRedoRequestByCookie(TUint aDriverCookie,TUint32 aSrcAddr,TUint32 aDstAddr,TInt aTransferCount,TUint32 aPslRequestInfo,TBool aIsrCb);
   111 	TInt IsQueueEmptyByCookie(TUint aDriverCookie, TBool& aQueueEmpty);		
   113 	TInt IsQueueEmptyByCookie(TUint aDriverCookie, TBool& aQueueEmpty);		
   112 	TInt ChannelIsOpenedByCookie(TUint aDriverCookie, TBool& aChannelOpen);		
   114 	TInt ChannelIsOpenedByCookie(TUint aDriverCookie, TBool& aChannelOpen);	
       
   115 	TInt EnableDstElementCountingByCookie(TUint aDriverCookie);
       
   116 	TInt EnableSrcElementCountingByCookie(TUint aDriverCookie);
       
   117 	TInt DisableDstElementCountingByCookie(TUint aDriverCookie);
       
   118 	TInt DisableSrcElementCountingByCookie(TUint aDriverCookie);
       
   119 	TInt TotalNumDstElementsTransferredByCookie(TUint aDriverCookie);
       
   120 	TInt TotalNumSrcElementsTransferredByCookie(TUint aDriverCookie);
   113 	void CloseDmaChannelByIndex(TInt aIndex);
   121 	void CloseDmaChannelByIndex(TInt aIndex);
   114 	void CancelAllByIndex(TInt aIndex);
   122 	void CancelAllByIndex(TInt aIndex);
       
   123 	TInt LinkDmaChannelByIndex(TInt aIndex);
       
   124 	TInt UnlinkDmaChannelByIndex(TInt aIndex);
   115 	TInt PauseDmaChannelByIndex(TInt aIndex);
   125 	TInt PauseDmaChannelByIndex(TInt aIndex);
   116 	TInt ResumeDmaChannelByIndex(TInt aIndex);		
   126 	TInt ResumeDmaChannelByIndex(TInt aIndex);		
   117 	TInt IsrRedoRequestByIndex(TInt aIndex,TUint32 aSrcAddr,TUint32 aDstAddr,TInt aTransferCount,TUint32 aPslRequestInfo,TBool aIsrCb);
   127 	TInt IsrRedoRequestByIndex(TInt aIndex,TUint32 aSrcAddr,TUint32 aDstAddr,TInt aTransferCount,TUint32 aPslRequestInfo,TBool aIsrCb);
       
   128 	void EnableDstElementCountingByIndex(TInt aIndex);
       
   129 	void EnableSrcElementCountingByIndex(TInt aIndex);
       
   130 	void DisableDstElementCountingByIndex(TInt aIndex);
       
   131 	void DisableSrcElementCountingByIndex(TInt aIndex);
       
   132 	TInt TotalNumDstElementsTransferredByIndex(TInt aIndex);
       
   133 	TInt TotalNumSrcElementsTransferredByIndex(TInt aIndex);
   118 	TInt CreateSharedChunk();
   134 	TInt CreateSharedChunk();
   119 	TUint OpenSharedChunkHandle();
   135 	TUint OpenSharedChunkHandle();
   120 
   136 
   121 	/**
   137 	/**
   122 	Creates a new kernel-side DMA request object, associated with a previously
   138 	Creates a new kernel-side DMA request object, associated with a previously
   143 	TInt FragmentRequest(TUint aRequestCookie, const TDmaTransferArgs& aTransferArgs, TBool aLegacy=ETrue);
   159 	TInt FragmentRequest(TUint aRequestCookie, const TDmaTransferArgs& aTransferArgs, TBool aLegacy=ETrue);
   144 
   160 
   145 	TInt QueueRequest(TUint aRequestCookie, TRequestStatus* aStatus, TCallbackRecord* aRecord, TUint64* aDurationMicroSecs);
   161 	TInt QueueRequest(TUint aRequestCookie, TRequestStatus* aStatus, TCallbackRecord* aRecord, TUint64* aDurationMicroSecs);
   146 	DClientDmaRequest* RequestFromCookie(TUint aRequestCookie) const;
   162 	DClientDmaRequest* RequestFromCookie(TUint aRequestCookie) const;
   147 	TInt RequestFragmentCount(TUint aRequestCookie);
   163 	TInt RequestFragmentCount(TUint aRequestCookie);
   148 
       
   149 	TDmaV2TestInfo ConvertTestInfo(const TDmaTestInfo& aOldInfo) const;
   164 	TDmaV2TestInfo ConvertTestInfo(const TDmaTestInfo& aOldInfo) const;
   150 private:
   165 private:
   151 	DThread* iClient;
   166 	DThread* iClient;
   152 	TDynamicDfcQue* iDfcQ;
   167 	TDynamicDfcQue* iDfcQ;
   153 	TDynamicDfcQue* iIsrCallbackDfcQ; // Will be used by requests which complete with an ISR callback
   168 	TDynamicDfcQue* iIsrCallbackDfcQ; // Will be used by requests which complete with an ISR callback
   154 	static const TInt KMaxChunkSize = 8 * KMega;
   169 	static const TInt KMaxChunkSize;
   155 	TLinAddr iChunkBase;
   170 	TLinAddr iChunkBase;
   156 	DChunk* iChunk;
   171 	DChunk* iChunk;
   157 
   172 
   158 	RPointerArray<TDmaChannel> iChannels;
   173 	RPointerArray<TDmaChannel> iChannels;
   159 	RPointerArray<DClientDmaRequest> iClientDmaReqs;
   174 	RPointerArray<DClientDmaRequest> iClientDmaReqs;
   375 
   390 
   376 /**
   391 /**
   377 The new style callback called by the DMA framework
   392 The new style callback called by the DMA framework
   378 may be called in either thread or ISR context
   393 may be called in either thread or ISR context
   379 */
   394 */
   380 void DClientDmaRequest::Callback(TUint aCallbackType, TDmaResult aResult, TAny* aArg, SDmaDesHdr* aHdr)
   395 void DClientDmaRequest::Callback(TUint aCallbackType, TDmaResult aResult, TAny* aArg, SDmaDesHdr* /*aHdr*/)
   381 	{
   396 	{
   382 	const TInt context = NKern::CurrentContext();
   397 	const TInt context = NKern::CurrentContext();
   383 	__KTRACE_OPT(KDMA, Kern::Printf(">DClientDmaRequest::CallBack: TDmaResult result = %d, NKern::TContext context = %d", aResult, context));
   398 	__KTRACE_OPT(KDMA, Kern::Printf(">DClientDmaRequest::CallBack: TDmaResult result = %d, NKern::TContext context = %d", aResult, context));
   384 	
   399 	
   385 	DClientDmaRequest& self = *reinterpret_cast<DClientDmaRequest*>(aArg);
   400 	DClientDmaRequest& self = *reinterpret_cast<DClientDmaRequest*>(aArg);
   501 	// We can always complete with KErrNone, the actual DMA result is
   516 	// We can always complete with KErrNone, the actual DMA result is
   502 	// logged in the TCallbackRecord
   517 	// logged in the TCallbackRecord
   503 	Kern::QueueRequestComplete(self.iClient, self.iClientDataRequest, KErrNone);
   518 	Kern::QueueRequestComplete(self.iClient, self.iClientDataRequest, KErrNone);
   504 	}
   519 	}
   505 
   520 
   506 const TInt DDmaTestSession::KMaxChunkSize;
   521 const TInt DDmaTestSession::KMaxChunkSize = 8 * KMega;
   507 
   522 
   508 TInt DDmaTestSession::RequestUserHandle(DThread* aThread, TOwnerType aType)
   523 TInt DDmaTestSession::RequestUserHandle(DThread* aThread, TOwnerType aType)
   509 	{
   524 	{
   510 	if (aType!=EOwnerThread || aThread!=iClient)
   525 	if (aType!=EOwnerThread || aThread!=iClient)
   511 		return KErrAccessDenied;
   526 		return KErrAccessDenied;
   515 DDmaTestSession::DDmaTestSession()
   530 DDmaTestSession::DDmaTestSession()
   516 	: iClient(NULL), iDfcQ(NULL), iIsrCallbackDfcQ(NULL), iChunkBase(0), iChunk(NULL)
   531 	: iClient(NULL), iDfcQ(NULL), iIsrCallbackDfcQ(NULL), iChunkBase(0), iChunk(NULL)
   517 	{}
   532 	{}
   518 
   533 
   519 // called in thread critical section
   534 // called in thread critical section
   520 TInt DDmaTestSession::DoCreate(TInt /*aUnit*/, const TDesC8* aInfo, const TVersion& /*aVer*/)
   535 TInt DDmaTestSession::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/)
   521 	{
   536 	{
   522 	__NK_ASSERT_ALWAYS(iDfcQ == NULL);
   537 	__NK_ASSERT_ALWAYS(iDfcQ == NULL);
   523 	__NK_ASSERT_ALWAYS(iIsrCallbackDfcQ == NULL);
   538 	__NK_ASSERT_ALWAYS(iIsrCallbackDfcQ == NULL);
   524 
   539 
   525 	TInt r = Kern::DynamicDfcQCreate(iDfcQ, KDFCThreadPriority, KDFCThreadName);
   540 	TInt r = Kern::DynamicDfcQCreate(iDfcQ, KDFCThreadPriority, KDFCThreadName);
   526 	if (r != KErrNone)
   541 	if (r != KErrNone)
       
   542 		{
       
   543 		Kern::Printf("DDmaTestSession::DoCreate D_DMA_DFC_THREAD returned (%d)\n", r);
   527 		return r;
   544 		return r;
       
   545 		}
   528 	NKern::ThreadSetCpuAffinity((NThread*)(iDfcQ->iThread), KCpuAffinityAny);
   546 	NKern::ThreadSetCpuAffinity((NThread*)(iDfcQ->iThread), KCpuAffinityAny);
   529 
   547 
   530 	r = Kern::DynamicDfcQCreate(iIsrCallbackDfcQ, KDFCThreadPriority, KIsrCbDfcThreadName);
   548 	r = Kern::DynamicDfcQCreate(iIsrCallbackDfcQ, KDFCThreadPriority, KIsrCbDfcThreadName);
   531 	if (r != KErrNone)
   549 	if (r != KErrNone)
       
   550 		{
       
   551 		Kern::Printf("DDmaTestSession::DoCreate D_DMA_IsrCb_thread returned (%d)\n", r);
   532 		return r;
   552 		return r;
       
   553 		}
   533 	NKern::ThreadSetCpuAffinity((NThread*)(iIsrCallbackDfcQ->iThread), KCpuAffinityAny);
   554 	NKern::ThreadSetCpuAffinity((NThread*)(iIsrCallbackDfcQ->iThread), KCpuAffinityAny);
   534 
   555 
   535 	iClient = &Kern::CurrentThread();
   556 	iClient = &Kern::CurrentThread();
   536 
   557 
   537 	r = CreateSharedChunk();
   558 	r = CreateSharedChunk();
       
   559 	Kern::Printf("DDmaTestSession::DoCreate CreateSharedChunk returned (%d)\n", r);
   538 	return r;
   560 	return r;
   539 	}
   561 	}
   540 
   562 
   541 DDmaTestSession::~DDmaTestSession()
   563 DDmaTestSession::~DDmaTestSession()
   542 	{
   564 	{
   634 			{
   656 			{
   635 			TUint driverCookie = reinterpret_cast<TUint>(a1);
   657 			TUint driverCookie = reinterpret_cast<TUint>(a1);
   636 			TInt r = ResumeDmaChannelByCookie(driverCookie);
   658 			TInt r = ResumeDmaChannelByCookie(driverCookie);
   637 			return r;
   659 			return r;
   638 			}
   660 			}
       
   661 	case RDmaSession::ELinkChannel:
       
   662 			{
       
   663 			TUint driverCookie = reinterpret_cast<TUint>(a1);
       
   664 			TInt r = LinkDmaChannelByCookie(driverCookie);
       
   665 			return r;
       
   666 			}
       
   667 	case RDmaSession::EUnlinkChannel:
       
   668 			{
       
   669 			TUint driverCookie = reinterpret_cast<TUint>(a1);
       
   670 			TInt r = UnlinkDmaChannelByCookie(driverCookie);
       
   671 			return r;
       
   672 			}
   639 	case RDmaSession::EFragmentCount:
   673 	case RDmaSession::EFragmentCount:
   640 			{
   674 			{
   641 			TUint requestCookie = reinterpret_cast<TUint>(a1);
   675 			TUint requestCookie = reinterpret_cast<TUint>(a1);
   642 			TInt r = RequestFragmentCount(requestCookie);
   676 			TInt r = RequestFragmentCount(requestCookie);
       
   677 			return r;
       
   678 			}
       
   679 	case RDmaSession::EEnableDstElementCounting:
       
   680 			{		
       
   681 			TUint requestCookie = reinterpret_cast<TUint>(a1);
       
   682 			TInt r = EnableDstElementCountingByCookie(requestCookie);
       
   683 			return r;
       
   684 			}
       
   685 	case RDmaSession::EEnableSrcElementCounting:
       
   686 			{
       
   687 			TUint requestCookie = reinterpret_cast<TUint>(a1);		
       
   688 			TInt r = EnableSrcElementCountingByCookie(requestCookie);
       
   689 			return r;
       
   690 			}
       
   691 	case RDmaSession::EDisableDstElementCounting:
       
   692 			{
       
   693 			TUint requestCookie = reinterpret_cast<TUint>(a1);
       
   694 			TInt r = DisableDstElementCountingByCookie(requestCookie);
       
   695 			return r;
       
   696 			}
       
   697 	case RDmaSession::EDisableSrcElementCounting:
       
   698 			{
       
   699 			TUint requestCookie = reinterpret_cast<TUint>(a1);
       
   700 			TInt r = DisableSrcElementCountingByCookie(requestCookie);
       
   701 			return r;
       
   702 			}
       
   703 	case RDmaSession::ETotalNumDstElementsTransferred:
       
   704 			{
       
   705 			TUint requestCookie = reinterpret_cast<TUint>(a1);
       
   706 			TInt r = TotalNumDstElementsTransferredByCookie(requestCookie);
       
   707 			return r;
       
   708 			}
       
   709 	case RDmaSession::ETotalNumSrcElementsTransferred:
       
   710 			{
       
   711 			TUint requestCookie = reinterpret_cast<TUint>(a1);
       
   712 			TInt r = TotalNumSrcElementsTransferredByCookie(requestCookie);
   643 			return r;
   713 			return r;
   644 			}
   714 			}
   645 	case RDmaSession::ERequestOpen:
   715 	case RDmaSession::ERequestOpen:
   646 			{
   716 			{
   647 			RDmaSession::TRequestCreateArgs createArgs(0, EFalse, 0);
   717 			RDmaSession::TRequestCreateArgs createArgs(0, EFalse, 0);
   913 	
   983 	
   914 	TDmaChannel* channel = iChannels[aIndex];	
   984 	TDmaChannel* channel = iChannels[aIndex];	
   915 	channel->CancelAll();
   985 	channel->CancelAll();
   916 	}
   986 	}
   917 
   987 
       
   988 TInt DDmaTestSession::LinkDmaChannelByIndex(TInt aIndex)
       
   989 	{
       
   990 	__KTRACE_OPT(KDMA, Kern::Printf("LinkDmaChannelByIndex: %d", aIndex)); 
       
   991 	__NK_ASSERT_DEBUG(aIndex < iChannels.Count()); 
       
   992 
       
   993 #ifdef DMA_APIV2
       
   994 	TDmaChannel* channel = iChannels[aIndex];
       
   995 	return channel->LinkToChannel(channel);
       
   996 #else
       
   997 	return KErrNotSupported;
       
   998 #endif	
       
   999 	}
       
  1000 
       
  1001 TInt DDmaTestSession::LinkDmaChannelByCookie(TUint aDriverCookie)
       
  1002 	{
       
  1003 	__KTRACE_OPT(KDMA, Kern::Printf("LinkDmaChannelByCookie: 0x%08x", aDriverCookie)); 
       
  1004 	const TInt index = CookieToChannelIndex(aDriverCookie);
       
  1005 	
       
  1006 	if(index >= 0)
       
  1007 		{
       
  1008 		TInt r = LinkDmaChannelByIndex(index);
       
  1009 		return r;
       
  1010 		}
       
  1011 	else
       
  1012 		{
       
  1013 		return KErrNotFound;
       
  1014 		}
       
  1015 	}
       
  1016 
       
  1017 TInt DDmaTestSession::UnlinkDmaChannelByIndex(TInt aIndex)
       
  1018 	{
       
  1019 	__KTRACE_OPT(KDMA, Kern::Printf("UnlinkDmaChannelByIndex: %d", aIndex)); 
       
  1020 	__NK_ASSERT_DEBUG(aIndex < iChannels.Count()); 
       
  1021 
       
  1022 #ifdef DMA_APIV2
       
  1023 	TDmaChannel* channel = iChannels[aIndex];
       
  1024 	return channel->LinkToChannel(NULL);
       
  1025 #else
       
  1026 	return KErrNotSupported;
       
  1027 #endif	
       
  1028 	}
       
  1029 
       
  1030 TInt DDmaTestSession::UnlinkDmaChannelByCookie(TUint aDriverCookie)
       
  1031 	{
       
  1032 	__KTRACE_OPT(KDMA, Kern::Printf("UnlinkDmaChannelByCookie: 0x%08x", aDriverCookie)); 
       
  1033 	const TInt index = CookieToChannelIndex(aDriverCookie);
       
  1034 	
       
  1035 	if(index >= 0)
       
  1036 		{
       
  1037 		TInt r = UnlinkDmaChannelByIndex(index);
       
  1038 		return r;
       
  1039 		}
       
  1040 	else
       
  1041 		{
       
  1042 		return KErrNotFound;
       
  1043 		}
       
  1044 	}
       
  1045 
   918 TInt DDmaTestSession::PauseDmaChannelByIndex(TInt aIndex)
  1046 TInt DDmaTestSession::PauseDmaChannelByIndex(TInt aIndex)
   919 	{
  1047 	{
   920 	__KTRACE_OPT(KDMA, Kern::Printf("PauseDmaChannelByIndex: %d", aIndex)); 
  1048 	__KTRACE_OPT(KDMA, Kern::Printf("PauseDmaChannelByIndex: %d", aIndex)); 
   921 	__NK_ASSERT_DEBUG(aIndex < iChannels.Count()); 
  1049 	__NK_ASSERT_DEBUG(aIndex < iChannels.Count()); 
   922 
  1050 
   971 		{
  1099 		{
   972 		return KErrNotFound;
  1100 		return KErrNotFound;
   973 		}
  1101 		}
   974 	}
  1102 	}
   975 
  1103 
       
  1104 TInt DDmaTestSession::EnableDstElementCountingByCookie(TUint aDriverCookie)
       
  1105 	{
       
  1106 	__KTRACE_OPT(KDMA, Kern::Printf("EnableDstElementCountingByCookie: 0x%08x", aDriverCookie)); 
       
  1107 	const TInt index = CookieToRequestIndex(aDriverCookie);
       
  1108 	
       
  1109 	if(index >= 0)
       
  1110 		{
       
  1111 		EnableDstElementCountingByIndex(index);
       
  1112 		return KErrNone;
       
  1113 		}
       
  1114 	else
       
  1115 		{
       
  1116 		return KErrNotFound;
       
  1117 		}
       
  1118 	}
       
  1119 
       
  1120 void DDmaTestSession::EnableDstElementCountingByIndex(TInt aIndex)
       
  1121 	{
       
  1122 	__KTRACE_OPT(KDMA, Kern::Printf("EnableDstElementCountingByIndex: %d", aIndex)); 		
       
  1123 	__NK_ASSERT_DEBUG(aIndex < iClientDmaReqs.Count()); 
       
  1124 #ifdef DMA_APIV2	
       
  1125 	iClientDmaReqs[aIndex]->EnableDstElementCounting();
       
  1126 #endif
       
  1127 	}
       
  1128 
       
  1129 TInt DDmaTestSession::EnableSrcElementCountingByCookie(TUint aDriverCookie)
       
  1130 	{
       
  1131 	__KTRACE_OPT(KDMA, Kern::Printf("EnableSrcElementCountingByCookie: 0x%08x", aDriverCookie)); 
       
  1132 	const TInt index = CookieToRequestIndex(aDriverCookie);
       
  1133 	
       
  1134 	if(index >= 0)
       
  1135 		{
       
  1136 		EnableSrcElementCountingByIndex(index);
       
  1137 		return KErrNone;
       
  1138 		}
       
  1139 	else
       
  1140 		{
       
  1141 		return KErrNotFound;
       
  1142 		}
       
  1143 	}
       
  1144 
       
  1145 void DDmaTestSession::EnableSrcElementCountingByIndex(TInt aIndex)
       
  1146 	{
       
  1147 	__KTRACE_OPT(KDMA, Kern::Printf("EnableSrcElementCountingByIndex: %d", aIndex)); 		
       
  1148 	__NK_ASSERT_DEBUG(aIndex < iClientDmaReqs.Count()); 
       
  1149 	
       
  1150 #ifdef DMA_APIV2
       
  1151 	iClientDmaReqs[aIndex]->EnableSrcElementCounting();
       
  1152 #endif
       
  1153 	}
       
  1154 
       
  1155 TInt DDmaTestSession::DisableDstElementCountingByCookie(TUint aDriverCookie)
       
  1156 	{
       
  1157 	__KTRACE_OPT(KDMA, Kern::Printf("DisableDstElementCountingByCookie: 0x%08x", aDriverCookie)); 
       
  1158 	const TInt index = CookieToRequestIndex(aDriverCookie);
       
  1159 	
       
  1160 	if(index >= 0)
       
  1161 		{
       
  1162 		DisableDstElementCountingByIndex(index);
       
  1163 		return KErrNone;
       
  1164 		}
       
  1165 	else
       
  1166 		{
       
  1167 		return KErrNotFound;
       
  1168 		}
       
  1169 	}
       
  1170 
       
  1171 void DDmaTestSession::DisableDstElementCountingByIndex(TInt aIndex)
       
  1172 	{
       
  1173 	__KTRACE_OPT(KDMA, Kern::Printf("DisableDstElementCountingByIndex: %d", aIndex)); 		
       
  1174 	__NK_ASSERT_DEBUG(aIndex < iClientDmaReqs.Count()); 
       
  1175 #ifdef DMA_APIV2
       
  1176 	iClientDmaReqs[aIndex]->DisableDstElementCounting();
       
  1177 #endif
       
  1178 	}
       
  1179 
       
  1180 TInt DDmaTestSession::DisableSrcElementCountingByCookie(TUint aDriverCookie)
       
  1181 	{
       
  1182 	__KTRACE_OPT(KDMA, Kern::Printf("DisableSrcElementCountingByCookie: 0x%08x", aDriverCookie)); 
       
  1183 	const TInt index = CookieToRequestIndex(aDriverCookie);
       
  1184 	
       
  1185 	if(index >= 0)
       
  1186 		{
       
  1187 		DisableSrcElementCountingByIndex(index);
       
  1188 		return KErrNone;
       
  1189 		}
       
  1190 	else
       
  1191 		{
       
  1192 		return KErrNotFound;
       
  1193 		}
       
  1194 	}
       
  1195 
       
  1196 void DDmaTestSession::DisableSrcElementCountingByIndex(TInt aIndex)
       
  1197 	{
       
  1198 	__KTRACE_OPT(KDMA, Kern::Printf("DisableSrcElementCountingByIndex: %d", aIndex)); 		
       
  1199 	__NK_ASSERT_DEBUG(aIndex < iClientDmaReqs.Count()); 
       
  1200 #ifdef DMA_APIV2
       
  1201 	iClientDmaReqs[aIndex]->DisableSrcElementCounting();
       
  1202 #endif
       
  1203 	}
       
  1204 
       
  1205 TInt DDmaTestSession::TotalNumDstElementsTransferredByCookie(TUint aDriverCookie)
       
  1206 	{
       
  1207 	__KTRACE_OPT(KDMA, Kern::Printf("TotalNumDstElementsTransferredByCookie: 0x%08x", aDriverCookie)); 
       
  1208 	const TInt index = CookieToRequestIndex(aDriverCookie);
       
  1209 	
       
  1210 	if(index >= 0)
       
  1211 		{
       
  1212 		TInt r = TotalNumDstElementsTransferredByIndex(index);
       
  1213 		return r;
       
  1214 		}
       
  1215 	else
       
  1216 		{
       
  1217 		return KErrNotFound;
       
  1218 		}
       
  1219 	}
       
  1220 
       
  1221 TInt DDmaTestSession::TotalNumDstElementsTransferredByIndex(TInt aIndex)
       
  1222 	{
       
  1223 	__KTRACE_OPT(KDMA, Kern::Printf("TotalNumDstElementsTransferredByIndex: %d", aIndex)); 		
       
  1224 	__NK_ASSERT_DEBUG(aIndex < iClientDmaReqs.Count()); 
       
  1225 	
       
  1226 #ifdef DMA_APIV2
       
  1227 	TInt r = iClientDmaReqs[aIndex]->TotalNumDstElementsTransferred();
       
  1228 	return r;
       
  1229 #else
       
  1230 	return KErrNotSupported;
       
  1231 #endif
       
  1232 	}
       
  1233 
       
  1234 TInt DDmaTestSession::TotalNumSrcElementsTransferredByCookie(TUint aDriverCookie)
       
  1235 	{
       
  1236 	__KTRACE_OPT(KDMA, Kern::Printf("TotalNumSrcElementsTransferredByCookie: 0x%08x", aDriverCookie)); 
       
  1237 	const TInt index = CookieToRequestIndex(aDriverCookie);
       
  1238 	
       
  1239 	if(index >= 0)
       
  1240 		{
       
  1241 		TInt r = TotalNumSrcElementsTransferredByIndex(index);
       
  1242 		return r;
       
  1243 		}
       
  1244 	else
       
  1245 		{
       
  1246 		return KErrNotFound;
       
  1247 		}
       
  1248 	}
       
  1249 
       
  1250 TInt DDmaTestSession::TotalNumSrcElementsTransferredByIndex(TInt aIndex)
       
  1251 	{
       
  1252 	__KTRACE_OPT(KDMA, Kern::Printf("TotalNumSrcElementsTransferredByIndex: %d", aIndex)); 		
       
  1253 	__NK_ASSERT_DEBUG(aIndex < iClientDmaReqs.Count()); 
       
  1254 	
       
  1255 #ifdef DMA_APIV2
       
  1256 	TInt r = iClientDmaReqs[aIndex]->TotalNumSrcElementsTransferred();
       
  1257 	return r;
       
  1258 #else
       
  1259 	return KErrNotSupported;
       
  1260 #endif
       
  1261 	}
   976 TInt DDmaTestSession::IsrRedoRequestByCookie(TUint aDriverCookie,TUint32 aSrcAddr,TUint32 aDstAddr,TInt aTransferCount,TUint32 aPslRequestInfo,TBool aIsrCb)
  1262 TInt DDmaTestSession::IsrRedoRequestByCookie(TUint aDriverCookie,TUint32 aSrcAddr,TUint32 aDstAddr,TInt aTransferCount,TUint32 aPslRequestInfo,TBool aIsrCb)
   977 {
  1263 {
   978 	__KTRACE_OPT(KDMA, Kern::Printf("IsrRedoRequestByCookie: 0x%08x", aDriverCookie)); 
  1264 	__KTRACE_OPT(KDMA, Kern::Printf("IsrRedoRequestByCookie: 0x%08x", aDriverCookie)); 
   979 	const TInt index = CookieToChannelIndex(aDriverCookie);
  1265 	const TInt index = CookieToChannelIndex(aDriverCookie);
   980 	
  1266 	
  1150 
  1436 
  1151     // Create the chunk
  1437     // Create the chunk
  1152     TChunkCreateInfo info;
  1438     TChunkCreateInfo info;
  1153     info.iType         = TChunkCreateInfo::ESharedKernelSingle;
  1439     info.iType         = TChunkCreateInfo::ESharedKernelSingle;
  1154     info.iMaxSize      = KMaxChunkSize;
  1440     info.iMaxSize      = KMaxChunkSize;
       
  1441 #ifndef __WINS__
  1155     info.iMapAttr      = EMapAttrFullyBlocking | EMapAttrUserRw;
  1442     info.iMapAttr      = EMapAttrFullyBlocking | EMapAttrUserRw;
       
  1443 #endif
       
  1444 
  1156     info.iOwnsMemory   = ETrue;
  1445     info.iOwnsMemory   = ETrue;
  1157     info.iDestroyedDfc = NULL;
  1446     info.iDestroyedDfc = NULL;
  1158 
  1447 
  1159     DChunk* chunk;
  1448     DChunk* chunk;
  1160 	TUint32 mapAttr;
  1449 	TUint32 mapAttr;
  1297 	newInfo.iMaxTransferSize = aOldInfo.iMaxTransferSize;
  1586 	newInfo.iMaxTransferSize = aOldInfo.iMaxTransferSize;
  1298 	newInfo.iMemAlignMask = aOldInfo.iMemAlignMask;
  1587 	newInfo.iMemAlignMask = aOldInfo.iMemAlignMask;
  1299 	newInfo.iMemMemPslInfo = aOldInfo.iMemMemPslInfo;
  1588 	newInfo.iMemMemPslInfo = aOldInfo.iMemMemPslInfo;
  1300 
  1589 
  1301 	newInfo.iMaxSbChannels = aOldInfo.iMaxSbChannels;
  1590 	newInfo.iMaxSbChannels = aOldInfo.iMaxSbChannels;
  1302 	for(TInt i=0; i<aOldInfo.iMaxSbChannels; i++)
  1591 		{
  1303 		newInfo.iSbChannels[i] = aOldInfo.iSbChannels[i];
  1592 		for(TInt i=0; i<aOldInfo.iMaxSbChannels; i++)
       
  1593 			{
       
  1594 			newInfo.iSbChannels[i] = aOldInfo.iSbChannels[i];
       
  1595 			}
       
  1596 		}
  1304 
  1597 
  1305 	newInfo.iMaxDbChannels = aOldInfo.iMaxDbChannels;
  1598 	newInfo.iMaxDbChannels = aOldInfo.iMaxDbChannels;
  1306 	for(TInt i=0; i<aOldInfo.iMaxDbChannels; i++)
  1599 		{
  1307 		newInfo.iDbChannels[i] = aOldInfo.iDbChannels[i];
  1600 		for(TInt i=0; i<aOldInfo.iMaxDbChannels; i++)
       
  1601 			{
       
  1602 			newInfo.iDbChannels[i] = aOldInfo.iDbChannels[i];
       
  1603 			}
       
  1604 		}
  1308 
  1605 
  1309 	newInfo.iMaxSgChannels = aOldInfo.iMaxSgChannels;
  1606 	newInfo.iMaxSgChannels = aOldInfo.iMaxSgChannels;
  1310 	for(TInt i=0; i<aOldInfo.iMaxSgChannels; i++)
  1607 		{
  1311 		newInfo.iSgChannels[i] = aOldInfo.iSgChannels[i];
  1608 		for(TInt i=0; i<aOldInfo.iMaxSgChannels; i++)
       
  1609 			{
       
  1610 			newInfo.iSgChannels[i] = aOldInfo.iSgChannels[i];
       
  1611 			}
       
  1612 		}
  1312 
  1613 
  1313 	return newInfo;
  1614 	return newInfo;
  1314 	}
  1615 	}
  1315 //////////////////////////////////////////////////////////////////////////////
  1616 //////////////////////////////////////////////////////////////////////////////
  1316 
  1617 
  1337 
  1638 
  1338 
  1639 
  1339 TInt DDmaTestFactory::Create(DLogicalChannelBase*& aChannel)
  1640 TInt DDmaTestFactory::Create(DLogicalChannelBase*& aChannel)
  1340     {
  1641     {
  1341 	aChannel=new DDmaTestSession;
  1642 	aChannel=new DDmaTestSession;
       
  1643 	Kern::Printf("DDmaTestFactory::Create %d\n", aChannel?KErrNone : KErrNoMemory);
  1342 	return aChannel ? KErrNone : KErrNoMemory;
  1644 	return aChannel ? KErrNone : KErrNoMemory;
  1343     }
  1645     }
  1344 
  1646 
  1345 
  1647 
  1346 TInt DDmaTestFactory::Install()
  1648 TInt DDmaTestFactory::Install()
  1347     {
  1649     {
  1348     return SetName(&KTestDmaLddName);
  1650     TInt r = SetName(&KTestDmaLddName);
       
  1651 	Kern::Printf("DDmaTestFactory::Install %d\n",r);
       
  1652 	return r;
  1349     }
  1653     }
  1350 
  1654 
  1351 
  1655 
  1352 void DDmaTestFactory::GetCaps(TDes8& /*aDes*/) const
  1656 void DDmaTestFactory::GetCaps(TDes8& /*aDes*/) const
  1353     {
  1657     {