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); |
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); |
113 void CloseDmaChannelByIndex(TInt aIndex); |
115 void CloseDmaChannelByIndex(TInt aIndex); |
114 void CancelAllByIndex(TInt aIndex); |
116 void CancelAllByIndex(TInt aIndex); |
|
117 TInt LinkDmaChannelByIndex(TInt aIndex); |
|
118 TInt UnlinkDmaChannelByIndex(TInt aIndex); |
115 TInt PauseDmaChannelByIndex(TInt aIndex); |
119 TInt PauseDmaChannelByIndex(TInt aIndex); |
116 TInt ResumeDmaChannelByIndex(TInt aIndex); |
120 TInt ResumeDmaChannelByIndex(TInt aIndex); |
117 TInt IsrRedoRequestByIndex(TInt aIndex,TUint32 aSrcAddr,TUint32 aDstAddr,TInt aTransferCount,TUint32 aPslRequestInfo,TBool aIsrCb); |
121 TInt IsrRedoRequestByIndex(TInt aIndex,TUint32 aSrcAddr,TUint32 aDstAddr,TInt aTransferCount,TUint32 aPslRequestInfo,TBool aIsrCb); |
118 TInt CreateSharedChunk(); |
122 TInt CreateSharedChunk(); |
119 TUint OpenSharedChunkHandle(); |
123 TUint OpenSharedChunkHandle(); |
149 TDmaV2TestInfo ConvertTestInfo(const TDmaTestInfo& aOldInfo) const; |
153 TDmaV2TestInfo ConvertTestInfo(const TDmaTestInfo& aOldInfo) const; |
150 private: |
154 private: |
151 DThread* iClient; |
155 DThread* iClient; |
152 TDynamicDfcQue* iDfcQ; |
156 TDynamicDfcQue* iDfcQ; |
153 TDynamicDfcQue* iIsrCallbackDfcQ; // Will be used by requests which complete with an ISR callback |
157 TDynamicDfcQue* iIsrCallbackDfcQ; // Will be used by requests which complete with an ISR callback |
154 static const TInt KMaxChunkSize = 8 * KMega; |
158 static const TInt KMaxChunkSize; |
155 TLinAddr iChunkBase; |
159 TLinAddr iChunkBase; |
156 DChunk* iChunk; |
160 DChunk* iChunk; |
157 |
161 |
158 RPointerArray<TDmaChannel> iChannels; |
162 RPointerArray<TDmaChannel> iChannels; |
159 RPointerArray<DClientDmaRequest> iClientDmaReqs; |
163 RPointerArray<DClientDmaRequest> iClientDmaReqs; |
375 |
379 |
376 /** |
380 /** |
377 The new style callback called by the DMA framework |
381 The new style callback called by the DMA framework |
378 may be called in either thread or ISR context |
382 may be called in either thread or ISR context |
379 */ |
383 */ |
380 void DClientDmaRequest::Callback(TUint aCallbackType, TDmaResult aResult, TAny* aArg, SDmaDesHdr* aHdr) |
384 void DClientDmaRequest::Callback(TUint aCallbackType, TDmaResult aResult, TAny* aArg, SDmaDesHdr* /*aHdr*/) |
381 { |
385 { |
382 const TInt context = NKern::CurrentContext(); |
386 const TInt context = NKern::CurrentContext(); |
383 __KTRACE_OPT(KDMA, Kern::Printf(">DClientDmaRequest::CallBack: TDmaResult result = %d, NKern::TContext context = %d", aResult, context)); |
387 __KTRACE_OPT(KDMA, Kern::Printf(">DClientDmaRequest::CallBack: TDmaResult result = %d, NKern::TContext context = %d", aResult, context)); |
384 |
388 |
385 DClientDmaRequest& self = *reinterpret_cast<DClientDmaRequest*>(aArg); |
389 DClientDmaRequest& self = *reinterpret_cast<DClientDmaRequest*>(aArg); |
501 // We can always complete with KErrNone, the actual DMA result is |
505 // We can always complete with KErrNone, the actual DMA result is |
502 // logged in the TCallbackRecord |
506 // logged in the TCallbackRecord |
503 Kern::QueueRequestComplete(self.iClient, self.iClientDataRequest, KErrNone); |
507 Kern::QueueRequestComplete(self.iClient, self.iClientDataRequest, KErrNone); |
504 } |
508 } |
505 |
509 |
506 const TInt DDmaTestSession::KMaxChunkSize; |
510 const TInt DDmaTestSession::KMaxChunkSize = 8 * KMega; |
507 |
511 |
508 TInt DDmaTestSession::RequestUserHandle(DThread* aThread, TOwnerType aType) |
512 TInt DDmaTestSession::RequestUserHandle(DThread* aThread, TOwnerType aType) |
509 { |
513 { |
510 if (aType!=EOwnerThread || aThread!=iClient) |
514 if (aType!=EOwnerThread || aThread!=iClient) |
511 return KErrAccessDenied; |
515 return KErrAccessDenied; |
515 DDmaTestSession::DDmaTestSession() |
519 DDmaTestSession::DDmaTestSession() |
516 : iClient(NULL), iDfcQ(NULL), iIsrCallbackDfcQ(NULL), iChunkBase(0), iChunk(NULL) |
520 : iClient(NULL), iDfcQ(NULL), iIsrCallbackDfcQ(NULL), iChunkBase(0), iChunk(NULL) |
517 {} |
521 {} |
518 |
522 |
519 // called in thread critical section |
523 // called in thread critical section |
520 TInt DDmaTestSession::DoCreate(TInt /*aUnit*/, const TDesC8* aInfo, const TVersion& /*aVer*/) |
524 TInt DDmaTestSession::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/) |
521 { |
525 { |
522 __NK_ASSERT_ALWAYS(iDfcQ == NULL); |
526 __NK_ASSERT_ALWAYS(iDfcQ == NULL); |
523 __NK_ASSERT_ALWAYS(iIsrCallbackDfcQ == NULL); |
527 __NK_ASSERT_ALWAYS(iIsrCallbackDfcQ == NULL); |
524 |
528 |
525 TInt r = Kern::DynamicDfcQCreate(iDfcQ, KDFCThreadPriority, KDFCThreadName); |
529 TInt r = Kern::DynamicDfcQCreate(iDfcQ, KDFCThreadPriority, KDFCThreadName); |
526 if (r != KErrNone) |
530 if (r != KErrNone) |
|
531 { |
|
532 Kern::Printf("DDmaTestSession::DoCreate D_DMA_DFC_THREAD returned (%d)\n", r); |
527 return r; |
533 return r; |
|
534 } |
528 NKern::ThreadSetCpuAffinity((NThread*)(iDfcQ->iThread), KCpuAffinityAny); |
535 NKern::ThreadSetCpuAffinity((NThread*)(iDfcQ->iThread), KCpuAffinityAny); |
529 |
536 |
530 r = Kern::DynamicDfcQCreate(iIsrCallbackDfcQ, KDFCThreadPriority, KIsrCbDfcThreadName); |
537 r = Kern::DynamicDfcQCreate(iIsrCallbackDfcQ, KDFCThreadPriority, KIsrCbDfcThreadName); |
531 if (r != KErrNone) |
538 if (r != KErrNone) |
|
539 { |
|
540 Kern::Printf("DDmaTestSession::DoCreate D_DMA_IsrCb_thread returned (%d)\n", r); |
532 return r; |
541 return r; |
|
542 } |
533 NKern::ThreadSetCpuAffinity((NThread*)(iIsrCallbackDfcQ->iThread), KCpuAffinityAny); |
543 NKern::ThreadSetCpuAffinity((NThread*)(iIsrCallbackDfcQ->iThread), KCpuAffinityAny); |
534 |
544 |
535 iClient = &Kern::CurrentThread(); |
545 iClient = &Kern::CurrentThread(); |
536 |
546 |
537 r = CreateSharedChunk(); |
547 r = CreateSharedChunk(); |
|
548 Kern::Printf("DDmaTestSession::DoCreate CreateSharedChunk returned (%d)\n", r); |
538 return r; |
549 return r; |
539 } |
550 } |
540 |
551 |
541 DDmaTestSession::~DDmaTestSession() |
552 DDmaTestSession::~DDmaTestSession() |
542 { |
553 { |
632 } |
643 } |
633 case RDmaSession::EResumeChannel: |
644 case RDmaSession::EResumeChannel: |
634 { |
645 { |
635 TUint driverCookie = reinterpret_cast<TUint>(a1); |
646 TUint driverCookie = reinterpret_cast<TUint>(a1); |
636 TInt r = ResumeDmaChannelByCookie(driverCookie); |
647 TInt r = ResumeDmaChannelByCookie(driverCookie); |
|
648 return r; |
|
649 } |
|
650 case RDmaSession::ELinkChannel: |
|
651 { |
|
652 TUint driverCookie = reinterpret_cast<TUint>(a1); |
|
653 TInt r = LinkDmaChannelByCookie(driverCookie); |
|
654 return r; |
|
655 } |
|
656 case RDmaSession::EUnlinkChannel: |
|
657 { |
|
658 TUint driverCookie = reinterpret_cast<TUint>(a1); |
|
659 TInt r = UnlinkDmaChannelByCookie(driverCookie); |
637 return r; |
660 return r; |
638 } |
661 } |
639 case RDmaSession::EFragmentCount: |
662 case RDmaSession::EFragmentCount: |
640 { |
663 { |
641 TUint requestCookie = reinterpret_cast<TUint>(a1); |
664 TUint requestCookie = reinterpret_cast<TUint>(a1); |
913 |
936 |
914 TDmaChannel* channel = iChannels[aIndex]; |
937 TDmaChannel* channel = iChannels[aIndex]; |
915 channel->CancelAll(); |
938 channel->CancelAll(); |
916 } |
939 } |
917 |
940 |
|
941 TInt DDmaTestSession::LinkDmaChannelByIndex(TInt aIndex) |
|
942 { |
|
943 __KTRACE_OPT(KDMA, Kern::Printf("LinkDmaChannelByIndex: %d", aIndex)); |
|
944 __NK_ASSERT_DEBUG(aIndex < iChannels.Count()); |
|
945 |
|
946 #ifdef DMA_APIV2 |
|
947 TDmaChannel* channel = iChannels[aIndex]; |
|
948 return channel->LinkToChannel(channel); |
|
949 #else |
|
950 return KErrNotSupported; |
|
951 #endif |
|
952 } |
|
953 |
|
954 TInt DDmaTestSession::LinkDmaChannelByCookie(TUint aDriverCookie) |
|
955 { |
|
956 __KTRACE_OPT(KDMA, Kern::Printf("LinkDmaChannelByCookie: 0x%08x", aDriverCookie)); |
|
957 const TInt index = CookieToChannelIndex(aDriverCookie); |
|
958 |
|
959 if(index >= 0) |
|
960 { |
|
961 TInt r = LinkDmaChannelByIndex(index); |
|
962 return r; |
|
963 } |
|
964 else |
|
965 { |
|
966 return KErrNotFound; |
|
967 } |
|
968 } |
|
969 |
|
970 TInt DDmaTestSession::UnlinkDmaChannelByIndex(TInt aIndex) |
|
971 { |
|
972 __KTRACE_OPT(KDMA, Kern::Printf("UnlinkDmaChannelByIndex: %d", aIndex)); |
|
973 __NK_ASSERT_DEBUG(aIndex < iChannels.Count()); |
|
974 |
|
975 #ifdef DMA_APIV2 |
|
976 TDmaChannel* channel = iChannels[aIndex]; |
|
977 return channel->LinkToChannel(NULL); |
|
978 #else |
|
979 return KErrNotSupported; |
|
980 #endif |
|
981 } |
|
982 |
|
983 TInt DDmaTestSession::UnlinkDmaChannelByCookie(TUint aDriverCookie) |
|
984 { |
|
985 __KTRACE_OPT(KDMA, Kern::Printf("UnlinkDmaChannelByCookie: 0x%08x", aDriverCookie)); |
|
986 const TInt index = CookieToChannelIndex(aDriverCookie); |
|
987 |
|
988 if(index >= 0) |
|
989 { |
|
990 TInt r = UnlinkDmaChannelByIndex(index); |
|
991 return r; |
|
992 } |
|
993 else |
|
994 { |
|
995 return KErrNotFound; |
|
996 } |
|
997 } |
|
998 |
918 TInt DDmaTestSession::PauseDmaChannelByIndex(TInt aIndex) |
999 TInt DDmaTestSession::PauseDmaChannelByIndex(TInt aIndex) |
919 { |
1000 { |
920 __KTRACE_OPT(KDMA, Kern::Printf("PauseDmaChannelByIndex: %d", aIndex)); |
1001 __KTRACE_OPT(KDMA, Kern::Printf("PauseDmaChannelByIndex: %d", aIndex)); |
921 __NK_ASSERT_DEBUG(aIndex < iChannels.Count()); |
1002 __NK_ASSERT_DEBUG(aIndex < iChannels.Count()); |
922 |
1003 |
1150 |
1231 |
1151 // Create the chunk |
1232 // Create the chunk |
1152 TChunkCreateInfo info; |
1233 TChunkCreateInfo info; |
1153 info.iType = TChunkCreateInfo::ESharedKernelSingle; |
1234 info.iType = TChunkCreateInfo::ESharedKernelSingle; |
1154 info.iMaxSize = KMaxChunkSize; |
1235 info.iMaxSize = KMaxChunkSize; |
|
1236 #ifndef __WINS__ |
1155 info.iMapAttr = EMapAttrFullyBlocking | EMapAttrUserRw; |
1237 info.iMapAttr = EMapAttrFullyBlocking | EMapAttrUserRw; |
|
1238 #endif |
|
1239 |
1156 info.iOwnsMemory = ETrue; |
1240 info.iOwnsMemory = ETrue; |
1157 info.iDestroyedDfc = NULL; |
1241 info.iDestroyedDfc = NULL; |
1158 |
1242 |
1159 DChunk* chunk; |
1243 DChunk* chunk; |
1160 TUint32 mapAttr; |
1244 TUint32 mapAttr; |
1297 newInfo.iMaxTransferSize = aOldInfo.iMaxTransferSize; |
1381 newInfo.iMaxTransferSize = aOldInfo.iMaxTransferSize; |
1298 newInfo.iMemAlignMask = aOldInfo.iMemAlignMask; |
1382 newInfo.iMemAlignMask = aOldInfo.iMemAlignMask; |
1299 newInfo.iMemMemPslInfo = aOldInfo.iMemMemPslInfo; |
1383 newInfo.iMemMemPslInfo = aOldInfo.iMemMemPslInfo; |
1300 |
1384 |
1301 newInfo.iMaxSbChannels = aOldInfo.iMaxSbChannels; |
1385 newInfo.iMaxSbChannels = aOldInfo.iMaxSbChannels; |
1302 for(TInt i=0; i<aOldInfo.iMaxSbChannels; i++) |
1386 { |
1303 newInfo.iSbChannels[i] = aOldInfo.iSbChannels[i]; |
1387 for(TInt i=0; i<aOldInfo.iMaxSbChannels; i++) |
|
1388 { |
|
1389 newInfo.iSbChannels[i] = aOldInfo.iSbChannels[i]; |
|
1390 } |
|
1391 } |
1304 |
1392 |
1305 newInfo.iMaxDbChannels = aOldInfo.iMaxDbChannels; |
1393 newInfo.iMaxDbChannels = aOldInfo.iMaxDbChannels; |
1306 for(TInt i=0; i<aOldInfo.iMaxDbChannels; i++) |
1394 { |
1307 newInfo.iDbChannels[i] = aOldInfo.iDbChannels[i]; |
1395 for(TInt i=0; i<aOldInfo.iMaxDbChannels; i++) |
|
1396 { |
|
1397 newInfo.iDbChannels[i] = aOldInfo.iDbChannels[i]; |
|
1398 } |
|
1399 } |
1308 |
1400 |
1309 newInfo.iMaxSgChannels = aOldInfo.iMaxSgChannels; |
1401 newInfo.iMaxSgChannels = aOldInfo.iMaxSgChannels; |
1310 for(TInt i=0; i<aOldInfo.iMaxSgChannels; i++) |
1402 { |
1311 newInfo.iSgChannels[i] = aOldInfo.iSgChannels[i]; |
1403 for(TInt i=0; i<aOldInfo.iMaxSgChannels; i++) |
|
1404 { |
|
1405 newInfo.iSgChannels[i] = aOldInfo.iSgChannels[i]; |
|
1406 } |
|
1407 } |
1312 |
1408 |
1313 return newInfo; |
1409 return newInfo; |
1314 } |
1410 } |
1315 ////////////////////////////////////////////////////////////////////////////// |
1411 ////////////////////////////////////////////////////////////////////////////// |
1316 |
1412 |
1337 |
1433 |
1338 |
1434 |
1339 TInt DDmaTestFactory::Create(DLogicalChannelBase*& aChannel) |
1435 TInt DDmaTestFactory::Create(DLogicalChannelBase*& aChannel) |
1340 { |
1436 { |
1341 aChannel=new DDmaTestSession; |
1437 aChannel=new DDmaTestSession; |
|
1438 Kern::Printf("DDmaTestFactory::Create %d\n", aChannel?KErrNone : KErrNoMemory); |
1342 return aChannel ? KErrNone : KErrNoMemory; |
1439 return aChannel ? KErrNone : KErrNoMemory; |
1343 } |
1440 } |
1344 |
1441 |
1345 |
1442 |
1346 TInt DDmaTestFactory::Install() |
1443 TInt DDmaTestFactory::Install() |
1347 { |
1444 { |
1348 return SetName(&KTestDmaLddName); |
1445 TInt r = SetName(&KTestDmaLddName); |
|
1446 Kern::Printf("DDmaTestFactory::Install %d\n",r); |
|
1447 return r; |
1349 } |
1448 } |
1350 |
1449 |
1351 |
1450 |
1352 void DDmaTestFactory::GetCaps(TDes8& /*aDes*/) const |
1451 void DDmaTestFactory::GetCaps(TDes8& /*aDes*/) const |
1353 { |
1452 { |