Re: Passing 40KB data from user to kernel space. How??
Re: Passing 40KB data from user to kernel space. How??
- Subject: Re: Passing 40KB data from user to kernel space. How??
- From: Terry Lambert <email@hidden>
- Date: Thu, 5 Jul 2007 11:14:59 -0700
On Jul 4, 2007, at 5:16 AM, rohit dhamija wrote:
Dear All,
Developing a USB KEXT for my bulk USB device and wanted suggestions
from this group. The device has two bulk endpoints
I continously pass around 40KB data from the user level application -
Write 40K data from OUT EP– Read single byte data. This
is a continous process.
Since the data amount is huge, I need a mechanism which takes minimum
memory and time to pass this data to device.
Well, there's always the write system call... is there any reason your
device isn't supporting the write method?
man 2 write
But since you are saying that you are writing a driver for a bulk
device:
Introduction to Mass Storage Device Driver Programming Guide
<http://developer.apple.com/documentation/DeviceDrivers/Conceptual/MassStorage/01_Introduction/chapter_1_section_1.html
>
is probably most appropriate, unless you are merely taking to it with
existing classes (i.e. the current system recognizes it, or can be
made to recignize it, by adding your USB IDs into a plist for the
appropriate driver.
Below are my thoughts for the same:
1. I cannot pass/copy the entire data from IOConnect methods since
these methods cannot pass more than 512kb data. Please
correct me if I am wrong
40 < 512 in all places, except the universe where Spock has a beard,
so you should be fine with this method. 8^).
2. Send the address of the buffer and buffer size from the user
application. At kernel level, we will get this address and
length, Then use copyin function to copy this buffer at kernel level
and use further.
status = copyin((user_addr_t)Bufferaddr, Buffer, Buflen);
I am able to pass the data correctly using this procedure, but i
suppose this is not the preffered way because
(a) I am developing the buffer at user level
(b) then again at kernel level , i copyin the entire buffer
So this process is much time and space consuming.
Plus if your allocation for the buffer fails for the copyin(), you are
stuck not being able to service the request, and about your only
option is to return an EIO. Don't do this, please: the I/O
abstractions exist for a reason.
B/w is it required to get the entire memory buffer at kernel level and
then pass to the driver? Can we use the user level
address and size and use the user space itself? IF yes, please detail
how it is possible?
That's the write system call.
3. Can we use IOConnectMapMemory to map the user level buffer with the
kernel memory ?? If yes, please detail.
As per Apple documentation, we can only map the device registers to
map with user level. Please refer
http://developer.apple.com/documentation/DeviceDrivers/Conceptual/AccessingHardware/AH_IOKitLib_API/chapter_5_section_5.html
Hardware registers include memory on board the card. In general,
this is only useful for polled I/O devices for which you own the
lowest lever driver (USB is not such a stack; do not use this method
for USB, or you will prevent power management of USB devices). It
also only works if there's RAM on the device for the user space
application to access, not the other way around.
-- Terry _______________________________________________
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