From the course: Linux Device Drivers: Reading, Writing, and Debugging

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Kernel modules for user space drivers

Kernel modules for user space drivers

- [Instructor] Let's talk briefly about the kernel module you need to write so that you can get that UIO device that you can map from user space. The key function in your module is going to be the uio_register_device. So, you got to set up this device object and the info object, and when you call this function, then the uio device file will get created. First time this happens, it's uio0, second time it happens, it's uio1, and so forth, so. You have to be a little bit careful in user space that you open up the right file. And in your info, you're specifying what memory is available so that when user space does the nmap, its mappin' the memory on your device. So, your kernel module code can look something like this. A name and a version for your info, so your driver could check that. And then, for the memory, we're saying where the memory starts, so we got to get the address from our device of where that is. And then, we're setting a size, so that's how much we can map. And then a…

Contents