65 } |
65 } |
66 |
66 |
67 class DIicSlaveClientChan : public DBase |
67 class DIicSlaveClientChan : public DBase |
68 { |
68 { |
69 public: |
69 public: |
70 DIicSlaveClientChan(DIicBusChannel* aChan, TInt8 aChanNum, TInt aChanType):iChan(aChan),iChanNumber(aChanNum),iChanType(aChanType){}; |
70 DIicSlaveClientChan(DIicBusChannel* aChan, TInt8 aChanNum, TInt aChanType):iChanNumber(aChanNum),iChanType(aChanType),iChan(aChan){}; |
71 ~DIicSlaveClientChan(); |
71 ~DIicSlaveClientChan(); |
72 TInt GetChanNum()const {return iChanNumber;}; |
72 TInt GetChanNum()const {return iChanNumber;}; |
73 TInt GetChanType()const {return iChanType;}; |
73 TInt GetChanType()const {return iChanType;}; |
74 DIicBusChannel* GetChannelPtr(){return iChan;}; |
74 DIicBusChannel* GetChannelPtr(){return iChan;}; |
75 private: |
75 private: |
91 const TInt KIicSlaveClientDfcPriority = 3; // 0 to 7, 7 is highest |
91 const TInt KIicSlaveClientDfcPriority = 3; // 0 to 7, 7 is highest |
92 |
92 |
93 const TInt KMaxNumChannels = 2; // 1 "true" slave, one "dummy" |
93 const TInt KMaxNumChannels = 2; // 1 "true" slave, one "dummy" |
94 |
94 |
95 #ifdef STANDALONE_CHANNEL |
95 #ifdef STANDALONE_CHANNEL |
|
96 #ifdef IIC_STUBS |
|
97 _LIT(KLddRootName,"iic_slaveclient_stubs"); |
|
98 #else |
96 _LIT(KLddRootName,"iic_slaveclient_ctrless"); |
99 _LIT(KLddRootName,"iic_slaveclient_ctrless"); |
|
100 #endif/*IIC_STUBS*/ |
97 #else |
101 #else |
98 _LIT(KLddRootName,"iic_slaveclient"); |
102 _LIT(KLddRootName,"iic_slaveclient"); |
99 #endif |
103 #endif |
100 _LIT(KIicSlaveClientThreadName,"IicSlaveClientLddThread"); |
104 _LIT(KIicSlaveClientThreadName,"IicSlaveClientLddThread"); |
101 |
105 |
162 TInt SetNotificationTrigger(TInt aChannelId, TInt aTrigger); |
166 TInt SetNotificationTrigger(TInt aChannelId, TInt aTrigger); |
163 TInt StaticExtension(TUint aId, TUint aFunction, TAny* aParam1, TAny* aParam2); |
167 TInt StaticExtension(TUint aId, TUint aFunction, TAny* aParam1, TAny* aParam2); |
164 TInt RegisterTxBuffer(TInt aChannelId, TPtr8 aTxBuffer, TInt8 aBufGranularity, TInt8 aNumWords, TInt8 aOffset); |
168 TInt RegisterTxBuffer(TInt aChannelId, TPtr8 aTxBuffer, TInt8 aBufGranularity, TInt8 aNumWords, TInt8 aOffset); |
165 TInt CaptureChannel(TInt aBusId, TDes8* aConfigHdr, TIicBusSlaveCallback* aCallback, TInt& aChannelId, TBool aAsynch=NULL); |
169 TInt CaptureChannel(TInt aBusId, TDes8* aConfigHdr, TIicBusSlaveCallback* aCallback, TInt& aChannelId, TBool aAsynch=NULL); |
166 TInt ReleaseChannel(TInt aChannelId); |
170 TInt ReleaseChannel(TInt aChannelId); |
|
171 #ifdef STANDALONE_CHANNEL |
|
172 TInt Spare1(TInt aBusId); |
|
173 #endif |
167 private: |
174 private: |
168 TDynamicDfcQue* iDfcQue; |
175 TDynamicDfcQue* iDfcQue; |
169 TIicBusSlaveCallback* iNotif; |
176 TIicBusSlaveCallback* iNotif; |
170 |
177 |
171 HBuf8* iConfigHdr; |
178 HBuf8* iConfigHdr; |
469 TInt r = KErrNone; |
476 TInt r = KErrNone; |
470 #ifdef STANDALONE_CHANNEL |
477 #ifdef STANDALONE_CHANNEL |
471 DIicSlaveClientChan* aChanPtr = NULL; |
478 DIicSlaveClientChan* aChanPtr = NULL; |
472 if(iCapturedChan.iChannelId == aChannelId) |
479 if(iCapturedChan.iChannelId == aChannelId) |
473 aChanPtr = iCapturedChan.iChannel; |
480 aChanPtr = iCapturedChan.iChannel; |
|
481 #ifdef IIC_STUBS |
|
482 //in the code coverage tests, a slave channel will not be captured before other slave |
|
483 //operations get called, e.g. calling DIicBusChannelSlave::CaptureChannel in MASTER_MODE |
|
484 //should return a KErrNotSupported. In controller-less mode, the client creates and manages its own channels. |
|
485 //So in here, we pretend a slave channel has been captured and can be used for the current operation. |
|
486 aChanPtr=iCapturedChan.iChannel; |
|
487 #endif/*IIC_STUBS*/ |
474 if(!aChanPtr) |
488 if(!aChanPtr) |
475 return KErrArgument; |
489 return KErrArgument; |
476 if(aChanPtr->GetChanType() == DIicBusChannel::EMasterSlave) |
490 if(aChanPtr->GetChanType() == DIicBusChannel::EMasterSlave) |
477 r = ((DIicBusChannelMasterSlave*)(aChanPtr->GetChannelPtr()))->RegisterRxBuffer(aRxBuffer, aBufGranularity, aNumWords, aOffset); |
491 r = ((DIicBusChannelMasterSlave*)(aChanPtr->GetChannelPtr()))->RegisterRxBuffer(aRxBuffer, aBufGranularity, aNumWords, aOffset); |
478 else if(aChanPtr->GetChanType() == DIicBusChannel::ESlave) |
492 else if(aChanPtr->GetChanType() == DIicBusChannel::ESlave) |
488 TInt r = KErrNone; |
502 TInt r = KErrNone; |
489 #ifdef STANDALONE_CHANNEL |
503 #ifdef STANDALONE_CHANNEL |
490 DIicSlaveClientChan* aChanPtr = NULL; |
504 DIicSlaveClientChan* aChanPtr = NULL; |
491 if(iCapturedChan.iChannelId == aChannelId) |
505 if(iCapturedChan.iChannelId == aChannelId) |
492 aChanPtr = iCapturedChan.iChannel; |
506 aChanPtr = iCapturedChan.iChannel; |
|
507 #ifdef IIC_STUBS |
|
508 //in the code coverage tests, a slave channel will not be captured before other slave |
|
509 //operations get called, e.g. calling DIicBusChannelSlave::CaptureChannel in MASTER_MODE |
|
510 //should return a KErrNotSupported. In controller-less mode, the client creates and manages its own channels. |
|
511 //So in here, we pretend a slave channel has been captured and can be used for the current operation. |
|
512 aChanPtr=iCapturedChan.iChannel; |
|
513 #endif/*IIC_STUBS*/ |
493 if(!aChanPtr) |
514 if(!aChanPtr) |
494 return KErrArgument; |
515 return KErrArgument; |
495 if(aChanPtr->GetChanType() == DIicBusChannel::EMasterSlave) |
516 if(aChanPtr->GetChanType() == DIicBusChannel::EMasterSlave) |
496 r = ((DIicBusChannelMasterSlave*)(aChanPtr->GetChannelPtr()))->SetNotificationTrigger(aTrigger); |
517 r = ((DIicBusChannelMasterSlave*)(aChanPtr->GetChannelPtr()))->SetNotificationTrigger(aTrigger); |
497 else if(aChanPtr->GetChanType() == DIicBusChannel::ESlave) |
518 else if(aChanPtr->GetChanType() == DIicBusChannel::ESlave) |
527 TInt r = KErrNone; |
548 TInt r = KErrNone; |
528 #ifdef STANDALONE_CHANNEL |
549 #ifdef STANDALONE_CHANNEL |
529 DIicSlaveClientChan* aChanPtr = NULL; |
550 DIicSlaveClientChan* aChanPtr = NULL; |
530 if(iCapturedChan.iChannelId == aChannelId) |
551 if(iCapturedChan.iChannelId == aChannelId) |
531 aChanPtr = iCapturedChan.iChannel; |
552 aChanPtr = iCapturedChan.iChannel; |
|
553 #ifdef IIC_STUBS |
|
554 //in the code coverage tests, a slave channel will not be captured before other slave |
|
555 //operations get called, e.g. calling DIicBusChannelSlave::CaptureChannel in MASTER_MODE |
|
556 //should return a KErrNotSupported. In controller-less mode, the client creates and manages its own channels. |
|
557 //So in here, we pretend a slave channel has been captured and can be used for the current operation. |
|
558 aChanPtr=iCapturedChan.iChannel; |
|
559 #endif/*IIC_STUBS*/ |
532 if(!aChanPtr) |
560 if(!aChanPtr) |
533 return KErrArgument; |
561 return KErrArgument; |
534 if(aChanPtr->GetChanType() == DIicBusChannel::EMasterSlave) |
562 if(aChanPtr->GetChanType() == DIicBusChannel::EMasterSlave) |
535 r = ((DIicBusChannelMasterSlave*)(aChanPtr->GetChannelPtr()))->RegisterTxBuffer(aTxBuffer, aBufGranularity, aNumWords, aOffset); |
563 r = ((DIicBusChannelMasterSlave*)(aChanPtr->GetChannelPtr()))->RegisterTxBuffer(aTxBuffer, aBufGranularity, aNumWords, aOffset); |
536 else if(aChanPtr->GetChanType() == DIicBusChannel::ESlave) |
564 else if(aChanPtr->GetChanType() == DIicBusChannel::ESlave) |
587 default: |
615 default: |
588 { |
616 { |
589 r = KErrArgument; |
617 r = KErrArgument; |
590 } |
618 } |
591 } |
619 } |
|
620 #ifdef IIC_STUBS |
|
621 //if we try to capture a slave channel in MASTER_MODE, the capture should fail with KErrNotSupported. |
|
622 //However, we need a slave channel to be captured before running most of slave operation |
|
623 //tests,e.g. RegisterRxBuf. So in here, we pretend the channel is captured, and save |
|
624 //the channel pointer in iCapturedChan, so it can be used for other slave operation tests. |
|
625 iCapturedChan.iChannel = chanPtr; |
|
626 #endif/*IIC_STUBS*/ |
592 // For synchronous capture, if successful then install the channel |
627 // For synchronous capture, if successful then install the channel |
593 if(r == KErrNone) |
628 if(r == KErrNone) |
594 { |
629 { |
595 if(!aAsynch) |
630 if(!aAsynch) |
596 { |
631 { |
628 iCapturedChan.iChannel = NULL; |
663 iCapturedChan.iChannel = NULL; |
629 iCapturedChan.iChannelId = 0; |
664 iCapturedChan.iChannelId = 0; |
630 #endif |
665 #endif |
631 return r; |
666 return r; |
632 } |
667 } |
|
668 |
|
669 //this function is added for improving the code coverage of IIC. |
|
670 //Spare1 is a placeholder for future expansion, so returns KErrNotSupported. |
|
671 #ifdef STANDALONE_CHANNEL |
|
672 TInt DChannelIicSlaveClient::Spare1(TInt aBusId) |
|
673 { |
|
674 TInt r = KErrNone; |
|
675 DIicSlaveClientChan* chanPtr = NULL; |
|
676 if(r == KErrNone) |
|
677 { |
|
678 r = GetChanPtr(aBusId, chanPtr); |
|
679 if(r == KErrNone) |
|
680 { |
|
681 if(!chanPtr) |
|
682 { |
|
683 r = KErrArgument; |
|
684 } |
|
685 else |
|
686 { |
|
687 switch(chanPtr->GetChanType()) |
|
688 { |
|
689 case DIicBusChannel::EMaster: |
|
690 { |
|
691 r = ((DIicBusChannelMaster*)(chanPtr->GetChannelPtr()))->Spare1(0,NULL,NULL); |
|
692 break; |
|
693 } |
|
694 case DIicBusChannel::EMasterSlave: |
|
695 { |
|
696 r = KErrNotSupported; |
|
697 break; |
|
698 } |
|
699 case DIicBusChannel::ESlave: |
|
700 { |
|
701 r = ((DIicBusChannelSlave*)(chanPtr->GetChannelPtr()))->Spare1(0,NULL,NULL); |
|
702 break; |
|
703 } |
|
704 default: |
|
705 { |
|
706 r = KErrArgument; |
|
707 } |
|
708 } |
|
709 } |
|
710 } |
|
711 } |
|
712 return r; |
|
713 } |
|
714 #endif |
|
715 |
633 TInt DChannelIicSlaveClient::CbProcessOverUnderRunRxTx() |
716 TInt DChannelIicSlaveClient::CbProcessOverUnderRunRxTx() |
634 { |
717 { |
635 CLIENT_PRINT(("> DChannelIicSlaveClient::CbProcessOverUnderRunRxTx(), iTestOverUnderState=%d\n",iTestOverUnderState)); |
718 CLIENT_PRINT(("> DChannelIicSlaveClient::CbProcessOverUnderRunRxTx(), iTestOverUnderState=%d\n",iTestOverUnderState)); |
636 TInt r = KErrNone; |
719 TInt r = KErrNone; |
637 switch (iTestOverUnderState) |
720 switch (iTestOverUnderState) |
1333 // Set the flags for duplex processing |
1416 // Set the flags for duplex processing |
1334 if((parms[1]&ERxAllBytes)&&(parms[1]&ETxAllBytes)) |
1417 if((parms[1]&ERxAllBytes)&&(parms[1]&ETxAllBytes)) |
1335 iFullDuplexReq |= (ERxAllBytes|ETxAllBytes); |
1418 iFullDuplexReq |= (ERxAllBytes|ETxAllBytes); |
1336 r = SetNotificationTrigger(parms[0],parms[1]); |
1419 r = SetNotificationTrigger(parms[0],parms[1]); |
1337 if(r == KErrTimedOut) |
1420 if(r == KErrTimedOut) |
|
1421 { |
|
1422 //the TRequestStatus is being completed with the error code to indicate |
|
1423 //that the timeout was detected, but KErrNone is returned because |
|
1424 //the requested notification settings were accepted. |
|
1425 Kern::RequestComplete(iClient, iStatus, r); |
1338 r=KErrNone; // KErrTimedOut is returned if the Client has not interacted with IIC for a while |
1426 r=KErrNone; // KErrTimedOut is returned if the Client has not interacted with IIC for a while |
|
1427 } |
1339 break; |
1428 break; |
1340 } |
1429 } |
1341 |
1430 |
1342 case(RBusDevIicClient::ECtrlIoNotifNoTrigger): |
1431 case(RBusDevIicClient::ECtrlIoNotifNoTrigger): |
1343 { |
1432 { |
1414 tempTrigger |= ETxUnderrun; |
1503 tempTrigger |= ETxUnderrun; |
1415 if(iExpectedTrigger != EGeneralBusError) |
1504 if(iExpectedTrigger != EGeneralBusError) |
1416 iExpectedTrigger |= tempTrigger; |
1505 iExpectedTrigger |= tempTrigger; |
1417 else |
1506 else |
1418 iBlockedTrigger |= tempTrigger; |
1507 iBlockedTrigger |= tempTrigger; |
1419 |
|
1420 // The bytes "transmitted" are stored in the simulated bus' iTxCheckBuf |
1508 // The bytes "transmitted" are stored in the simulated bus' iTxCheckBuf |
1421 // Since the simulated bus channel is also in the kernel process it shares the same address space |
1509 // Since the simulated bus channel is also in the kernel process it shares the same address space |
1422 // Get the address of the buffer |
1510 // Get the address of the buffer |
1423 // As part of the callback invoked by IIC, this client will check the data stored by the simulated |
1511 // As part of the callback invoked by IIC, this client will check the data stored by the simulated |
1424 // bus. Since the simulated bus channel is also in the kernel process it shares the same address space, |
1512 // bus. Since the simulated bus channel is also in the kernel process it shares the same address space, |
1466 |
1554 |
1467 if(iExpectedTrigger != EGeneralBusError) |
1555 if(iExpectedTrigger != EGeneralBusError) |
1468 iExpectedTrigger |= tempTrigger; |
1556 iExpectedTrigger |= tempTrigger; |
1469 else |
1557 else |
1470 iBlockedTrigger |= tempTrigger; |
1558 iBlockedTrigger |= tempTrigger; |
1471 |
|
1472 // The bytes "transmitted" are stored in the simulated bus' iTxCheckBuf |
1559 // The bytes "transmitted" are stored in the simulated bus' iTxCheckBuf |
1473 // Since the simulated bus channel is also in the kernel process it shares the same address space |
1560 // Since the simulated bus channel is also in the kernel process it shares the same address space |
1474 // Get the address of the buffer |
1561 // Get the address of the buffer |
1475 // As part of the callback invoked by IIC, this client will check the data stored by the simulated |
1562 // As part of the callback invoked by IIC, this client will check the data stored by the simulated |
1476 // bus. Since the simulated bus channel is also in the kernel process it shares the same address space, |
1563 // bus. Since the simulated bus channel is also in the kernel process it shares the same address space, |
1532 // (4) Return to the original value, and readback to confirm |
1619 // (4) Return to the original value, and readback to confirm |
1533 CLIENT_PRINT(("DChannelIicSlaveClient::DoControl invoking StaticExtension (ECtrlIoBlockNotification) \n")); |
1620 CLIENT_PRINT(("DChannelIicSlaveClient::DoControl invoking StaticExtension (ECtrlIoBlockNotification) \n")); |
1534 r = StaticExtension((TUint)a1, (TUint)ctrlIoVal, NULL, NULL); |
1621 r = StaticExtension((TUint)a1, (TUint)ctrlIoVal, NULL, NULL); |
1535 break; |
1622 break; |
1536 } |
1623 } |
1537 |
1624 #ifdef STANDALONE_CHANNEL |
|
1625 case(RBusDevIicClient::ETestSpare1): |
|
1626 { |
|
1627 //a1 represents a BusId passed from the user. |
|
1628 //Spare1 is a placeholder for future expansion. |
|
1629 r = Spare1((TInt)a1); |
|
1630 break; |
|
1631 } |
|
1632 case(RBusDevIicClient::ETestStaticEx): |
|
1633 { |
|
1634 //Passing a1, which represents a BusId, and the value of a function to StaticExtension. |
|
1635 //Using ECtlIoNone here, so StaticExtension will be called to execute the default case, |
|
1636 // but since this is only called when using stubs KErrNotSupported will be expected. |
|
1637 r = StaticExtension((TUint32)a1, (TUint)RBusDevIicClient::ECtlIoNone, NULL, NULL); |
|
1638 break; |
|
1639 } |
|
1640 #endif |
1538 default: |
1641 default: |
1539 { |
1642 { |
1540 CLIENT_PRINT(("DChannelIicSlaveClient::DoControl - unrecognised value for aId=0x%x\n",aId)); |
1643 CLIENT_PRINT(("DChannelIicSlaveClient::DoControl - unrecognised value for aId=0x%x\n",aId)); |
1541 r=KErrArgument; |
1644 r=KErrArgument; |
1542 break; |
1645 break; |