Re: Write/Read Bulk communication process in KEXT. How?
Re: Write/Read Bulk communication process in KEXT. How?
- Subject: Re: Write/Read Bulk communication process in KEXT. How?
- From: Michael Smith <email@hidden>
- Date: Wed, 24 May 2006 22:53:06 -0700
On May 24, 2006, at 9:02 PM, Chinki wrote:
Step4. Communicating with the KEY [ MAIN PART OF OUR DISCUSSION]
a) I get the structure (got from user level) and Allocate the
memory using IOMemoryDescriptor in my communication module (kext)
i.e,
// assign for OUT pipe
IOMemoryDescriptor *memDescOut = NULL;
// assign for IN pipe
IOMemoryDescriptor *memDescIN = NULL;
// Now create and initialize an IOMemoryDescriptor for memory FOR
WRITE
memDescOut = IOMemoryDescriptor::withAddress( (void*)
&myOutStructure, sizeof(MY_OUTSTRUCTURE), kDirectionOUT)
I assume you mean kIODirectionOut?
// check for validation of memDescOut
// Fill myOutStructure
// Do write operation with the allocated outpipe
status = (pdx->fOUTPipe)->Write( memDescOut, (UInt32)1000, (UInt32)
2000, size, NULL);
You are missing the ->prepare() and ->complete() calls.
// Similarly for IN structure
// Now create and initialize an IOMemoryDescriptor for memory FOR READ
memDescIN = IOMemoryDescriptor::withAddress( (void*)&myINStructure,
sizeof(MY_OUTSTRUCTURE), kDirectionOUT)
I assume you mean kIODirectionIn?
// check for validation of memDescIn
// Fill myOutStructure
// Do write operation with the allocated outpipe
status = (pdx->fINPipe)->Read( memDescIN , (UInt32)1000, (UInt32)
2000, size, NULL, &gotsize);
You are missing the ->prepare() and ->complete() calls.
I also note that you're not checking the result of the
IOMemoryDescriptor::withAddress() calls. It's imperative that you do
this, and handle the case where they return NULL in a sensible fashion.
= Mike
_______________________________________________
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