Re: passing buffer from User Client to Driver
Re: passing buffer from User Client to Driver
- Subject: Re: passing buffer from User Client to Driver
- From: Godfrey van der Linden <email@hidden>
- Date: Tue, 19 Apr 2005 10:55:45 -0700
G'day Imran,
I only have a couple of observations.
Can you change "com_MySoftwareCompany" to "com_spsoftindia"?
can assure you that the IOMemoryDescriptor works and readBytes does
return data from user land as expected. So now it is just an
exercise in debugging. This is what I'd do, first check the
arguments to the memory descriptor, do you have the correct task and
virtual address? Does the user land task indeed have the expected
data? Have you prepared() the descriptor? Is it still prepared when
the I/O is performed, i.e. if the I/O is asynch did you complete()
the descriptor prematurely?
This is what I do when I debug code that I'm sure works.
Godfrey
On 04/18/2005, at 23:21 , Imran wrote:
Hi GodFrey,
As per your reply, I had eliminated the mapping calls and change
variables
(vInStruct to InStruct)in my userclient.
But still I am facing the same problem, my IOMemoryDescriptor
buffer is not
getting passed from userclient to driver.
When I print the IOMemoryDescriptor address in driver it shows the
following
output:
IOMemoryDescriptor address value in driver = 0x11b2680
The Output of readBytes is as follows.
MyFilterScheme:: readBytes = 512 byteStart = 0 bufLength = 512
buffer =
Please take your time to go through the code segment of my driver.
Or do we need to use vm_allocate for achieving the buffer passing
from user
space application to the driver through user client.
***********************************************************
// kMyDoWrite
IOReturn
com_MySoftwareCompany_driver_MyFilterScheme::DoDriverWrite
(IOMemoryDescripto
r * inBuffer)
{
IOLog("\n Inside
com_MySoftwareCompany_driver_MyFilterScheme::myDoWrite
call\n");
IOLog("%s[%p]::%s\n", getName(), this, __FUNCTION__);
IOLog("\n IOMemoryDescriptor value in driver = %p\n", inBuffer);
IOLog("\n IOMemoryDescriptor buffer in driver = %s\n", inBuffer);
IOReturn retDrWrite = kIOReturnSuccess;
IOStorageCompletion completion;
// If the user client's 'open' method was never called, return
kIOReturnNotOpen.
if (!isOpen()) /* if-else Added - 15 Apr 2005 */
{
IOLog("\n Failed to open userclient for the driver....\n");
return kIOReturnNotOpen;
}
else
{
IOLog("\n Userclient is open for the driver....\n");
}
IOByteCount readBytes;
UInt64 byteStart = 0;
IOByteCount bufLength = inBuffer->getLength();
IOLog("\n bufLength = %lu\n", bufLength);
//char *myBuff = new char[bufLength];
char myBuff[512];
IOLog("\n Calling readbytes.......in driver\n");
readBytes = inBuffer->readBytes(0, myBuff, bufLength);
IOLog("MyFilterScheme:: readBytes = %lu byteStart = %lu
bufLength = %lu
buffer = %s \n", (long)readBytes, (long)byteStart, (long)bufLength,
myBuff);
getProvider()->write(this, byteStart, inBuffer, completion);
return retWrite;
}
The Outputs are:
IOMemoryDescriptor value in driver = 0x11b2680
IOMemoryDescriptor buffer in driver =
bufLength = 512
MyFilterScheme:: readBytes = 512 byteStart = 0 bufLength = 512
buffer =
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden