How to store userspace address in kernel driver and update when required

Hi,


Currently I'm using "IOUserclient" in order to communicate between user and kernel space,

I'm able to trigger the async responses when the data is available (as per my req..)

- with the async responses, I can send an array of max size 16

- so I need to use either internal queue or shared memory in driver and userspace app need to trigger a request to copy/get data from kernel


Is there a way to store the user buffer address in driver and update when required by storing the process context


Thanks

Venkat

Accepted Reply

If you’re working within I/O Kit the best way to manipulate client task memory is via

IOMemoryDescriptor
.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Replies

There are numerous ways to do this, and the best one very much depends on your specific requirements. To start, are your user/kernel interactions request/response based? That is, for each request do you get a response? Or is it more like a streaming operation, where the user code initiates things and then gets a stream of data back?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

basically for Async functionality,

ex: user will trigger the request and gets the response as part of Async callback


Thanks

Venkat

streaming operation, where the user code initiates things and then gets a stream of data back?

Yes,

Is it possible to implement aio operations like aio_read/io_submit, (aio is under bsd, so any analogous functionality to aio in IOKit) in Mac with IOKit


Thanks

venkat

I’m confused by the responses above. Your first response indicates that you want to do something request/response based (“user will trigger the request and gets the response as part of Async callback”). Your second indicates that you’re trying to do streaming. And your third puts you back into request/response territory (because that's how

aio_read
works).

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hi,


Please ignore the above statements,


Can I use "get_task_map()" to switch the context to userapp and modify the contents.

so that along with the async notification, the userspace buffer is also gets filled.


Is the above mentioned way is better to use, and I'm facing the issues while loading the module with the use of "get_task_map()/ vm_map_switch()"


If possible can you let me know the dependencies [like header/ library ] for "get_task_map()/ vm_map_switch()"


Thanks

Venkat

If you’re working within I/O Kit the best way to manipulate client task memory is via

IOMemoryDescriptor
.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thanks,

IOMemoryDescriptor
exactly meets my requirement

Cool.

IOMemoryDescriptor
is covered in some detail in the IOKit Fundamentals doc. If you’re neck deep in I/O Kit then I recommend that you read all of that doc in detail. It’s an excellent overview of the whole architecture.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"