wspeirs
wspeirs

Reputation: 1413

Write to a UIO Device

I understand the basics behind a UIO driver, as described in the documentation. The part I'm missing is how to write data from the user space program back to the device driver. My guess is that you'd write this data to the mmap region, but then how to do you let the device driver know it should read said memory?

Ultimately I'm trying to write a block device that can be implemented by a user space program. I've got the block device code stubbed out and working: https://github.com/wspeirs/usbd. My thought was that UIO was the most efficient way to transfer blocks/sectors between the block device and the user space program. Is this the wrong way to go about communicating with the block device driver from user space? Should I be using sysfs or some other communication mechanism?

Upvotes: 1

Views: 2669

Answers (1)

Jamey Hicks
Jamey Hicks

Reputation: 2370

UIO is designed so that user space bypasses the kernel to communicate with a hardware device. That does not seem to fit your needs.

In a standard Linux block device, you can use mmap() to write data to your block and msync() to indicate to the driver which regions you have written.

Upvotes: 2

Related Questions