TInt DKLDDChannel::Request(TInt aReqNo, TAny* a1, TAny* /*a2*/) { TInt r=KErrNone; TInt repeats=0; switch(aReqNo) { case RTestKeyRepeatLdd::ESetRepeat: kumemget(&iStoredKeyEvent,a1,sizeof(RKeyEvent)); iStoredEvent.SetRepeat(TRawEvent::EKeyRepeat, iStoredKeyEvent.iKey, iStoredKeyEvent.iRepeatCount); NKern::ThreadEnterCS(); r=Kern::AddEvent(iStoredEvent); NKern::ThreadLeaveCS(); break; case RTestKeyRepeatLdd::ERepeats: repeats = iStoredEvent.Repeats(); if (repeats!=iStoredKeyEvent.iRepeatCount) { r=KErrGeneral; } break; default: r=KErrNotSupported; break; } return r; }
/** Set the internal loopback mode of the device (Uart). This is device specific API, that provides functionality to configure the uart's internal loopback mode, as set by the user.User calls this by using RBusLogicalChannel::DoControl() with appropriate request number @param aMode Holds the loopback enable and disable option KLoopbackEnable for enable and KLoopbackDisable for disable @return KErrNone or system wide standard error code */ TInt DExDriverLogicalChannel::SetIntLoopback(const TInt* aMode) { KEXDEBUG(Kern::Printf("++DExDriverLogicalChannel::SetIntLoopback")); TInt r=KErrNone; TInt mode; // Read the user option. kumemget (&mode, aMode , sizeof(TInt)); // See the Rx and Tx Status. // Anything in progress then do not allow changing the loopback mode. WaitOnConfigDMutex(); WaitOnRxFMutex(); if (iRxProgress) { SignalRxFMutex(); SignalConfigDMutex(); return KErrInUse; } iRxProgress = ETrue; SignalRxFMutex(); WaitOnTxFMutex(); if (iTxProgress) { SignalTxFMutex(); SignalConfigDMutex(); return KErrInUse; } iTxProgress = ETrue; SignalTxFMutex(); if ((mode==KLoopbackEnable)||(mode==KLoopbackDisable)) { // Invoke PDD function to actually do the hardware // specific configuration on the device. Here the // buffer pointer can be passed and accessd directly // as both LDD and PDD are in kernel space. // Pdd()->SetIntLoopback(mode); } else r= KErrArgument; WaitOnRxFMutex(); iRxProgress = EFalse; SignalRxFMutex(); WaitOnTxFMutex(); iTxProgress = EFalse; SignalTxFMutex(); SignalConfigDMutex(); // return the result return r; }
TInt DEventDD::SendEvent(TRawEvent* aEvent) { TRawEvent event; kumemget(&event,aEvent,sizeof(TRawEvent)); //fetch event from user memory NKern::ThreadEnterCS(); TInt err=Kern::AddEvent(event); NKern::ThreadLeaveCS(); return err; }
/** Copies the content of the source descriptor to the destination descriptor. If the current thread is a user thread, i.e. the mode in spsr_svc is 'User', then data is read using user mode privileges . @param aDest The destination descriptor. @param aSrc The source descriptor. @panic KERN-COMMON 19, if aDest is not a valid descriptor type. @panic KERN-COMMON 23, if aSrc is longer that the maximum length of aDest. @panic KERN-EXEC 33, if aSrc is not a valid descriptor type. @pre Do not call from User thread if in a critical section. @pre Interrupts must be enabled. @pre Kernel must be unlocked. @pre No fast mutex can be held. @pre Call in a thread context. @pre Can be used in a device driver. @post The length of the destination descriptor is equal to the length of the source descriptor. */ EXPORT_C void Kern::KUDesGet(TDes8& aDest, const TDesC8& aSrc) { CHECK_PRECONDITIONS(MASK_NO_CRITICAL_IF_USER|MASK_THREAD_STANDARD,"Kern::KUDesGet"); //ETDes8BadDescriptorType = 19 //ETDes8Overflow = 23 //EKUDesInfoInvalidType= 33 TInt ulen, umax; TUint8* kptr=(TUint8*)aDest.Ptr(); const TUint8* uptr=Kern::KUDesInfo(aSrc, ulen, umax); aDest.SetLength(ulen); kumemget(kptr,uptr,ulen); }
TInt DKLDDChannel::Request(TInt aReqNo, TAny* a1, TAny* /*a2*/) { TInt r=KErrNone; TestTRawDigitiserEvent theEventObj; switch(aReqNo) { case RTestDigitiserLdd::EStartTest: kumemget(&theEventObj,a1,sizeof(TestTRawDigitiserEvent)); theEventObj.TestEvents(); break; default: r=KErrNotSupported; break; } return r; }
/** Transmit the data over the serial port.Transmit data is passed as buffer descriptor to this function by user. User calls this by using RBusLogicalChannel::DoControl() to LDD and ldd inturn calls the PDD function to do the actual transmission to the device. @param aData Transmit buffer descriptor @return KErrNone on success KErrAbort on invalid length or any other system wide error code */ TInt DExDriverLogicalChannel::TransmitData(const TDesC8* aData) { KEXDEBUG(Kern::Printf("++DExDriverLogicalChannel::TransmitData")); TInt r; TInt maxlength,size; // Reset offset for every Tx iTxOffset=0; // In case of zero length buffer or invalid length, abort the request. // Kern::KUDesInfo(*aData,iBytesTxed,maxlength); if (iBytesTxed<=0) { WaitOnTxFMutex(); iTxProgress = EFalse; SignalTxFMutex(); return KErrAbort; } // Transmit data 1 frame (256 bytes) at a time. // Loop around till the complete User data is transferred. // do { // Copy the data ptr to intermediate ptr. // iTxData=(TAny*)aData; // Transmit the data to device/PDD in blocks of LDD buffer length (256). // Loop around untill the complete data is transferred. // size=(iBytesTxed<KTxBufferSize)?iBytesTxed:KTxBufferSize; // Clear the buffer to zero using the nanokernel // utility function, memclr() // memclr(iTxBuffer, KTxBufferSize); // Constructs 8-bit modifiable pointer descriptor, with // length 0 and max length, size // TPtr8 txbuf(iTxBuffer,0,size); // Copy the descriptor from user into LDD buffer. // aData->Ptr()+iTxOffset will give the pointer to the next frame to be // transferred. And size is the number bytes to be copied. // txbuf.SetLength(size); kumemget(iTxBuffer,(TAny *)((aData->Ptr()) + iTxOffset),size); // Invoke PDD function to actually do the hardware specific // operation on the device. Here the buffer pointer can be // accessed directly as both LDD and PDD are in kernel space. // r = Pdd()->TransmitData(txbuf); // iBytesTxed keeps track of how many bytes transferred till now. iBytesTxed = iBytesTxed - size; // iTxOffset will give the next data frame offset. iTxOffset = iTxOffset + size; } while (iBytesTxed>0); WaitOnTxFMutex(); iTxProgress = EFalse; SignalTxFMutex(); return r; }
TInt DKUCopy::Request(TInt aFunction, TAny* a1, TAny* a2) // // Client requests // { TInt r=KErrNone; switch (aFunction) { case RKUCopy::EControlPut: { SCopyInfo info; kumemget(&info, a1, sizeof(info)); kumemput( (TUint8*)info.iPtr, ((const TUint8*)RandomData)+info.iOffset, info.iLength ); break; } case RKUCopy::EControlGet: { SCopyInfo info; kumemget(&info, a1, sizeof(info)); wordmove(iBuf,RandomData,KBufSize); kumemget( iBuf+info.iOffset, info.iPtr, info.iLength ); break; } case RKUCopy::EControlPut32: { SCopyInfo info; kumemget(&info, a1, sizeof(info)); kumemput32( (TUint8*)info.iPtr, ((const TUint8*)RandomData)+info.iOffset, info.iLength ); break; } case RKUCopy::EControlGet32: { SCopyInfo info; kumemget(&info, a1, sizeof(info)); wordmove(iBuf,RandomData,KBufSize); kumemget32( iBuf+info.iOffset, info.iPtr, info.iLength ); break; } case RKUCopy::EControlSet: { SSetInfo info; kumemget(&info, a1, sizeof(info)); kumemset( info.iPtr, (TUint8)info.iValue, info.iLength ); break; } case RKUCopy::EControlLength: r=KBufSize; break; case RKUCopy::EControlRead: { kumemput(a1,iBuf,KBufSize); break; } case RKUCopy::EControlRandomLength: r=(TInt)sizeof(RandomData); break; case RKUCopy::EControlReadRandom: kumemput(a1,RandomData,sizeof(RandomData)); break; case RKUCopy::EControlDesPut8: { TPtr8 buf(iBuf,0,KBufSize); Kern::KUDesGet(buf,*(const TDesC8*)a2); Kern::KUDesPut(*(TDes8*)a1,buf); break; } case RKUCopy::EControlDesGet8: { TPtr8 buf(iBuf,0,KBufSize); Kern::KUDesGet(buf,*(const TDesC8*)a2); Kern::KUDesPut(*((TDes8*)a1),buf); break; } case RKUCopy::EControlDesInfo8: { SDesInfo info; info.iPtr=(TAny*)Kern::KUDesInfo(*(const TDesC8*)a1,info.iLength,info.iMaxLength); kumemput(a2,&info,sizeof(info)); break; } case RKUCopy::EControlKernBufAddr: r=(TInt)iBuf; break; case RKUCopy::EControlRequestComplete: Kern::RequestComplete(*(TRequestStatus**)&a1, KErrNone); break; case RKUCopy::EControlRequestCompleteLocal: Kern::RequestComplete(*(TRequestStatus**)&a1, KErrNone); break; case RKUCopy::EControlQueueRequestComplete: r = iClientRequest->SetStatus((TRequestStatus*)a1); Kern::QueueRequestComplete(&Kern::CurrentThread(), iClientRequest, KErrNone); break; default: r=KErrNotSupported; break; } return r; }