2012/06/15

Linux Device Driver Topics

Tested on Ubuntu 12.04

Where does printk go
The result of the printk wouldn't be displayed on terminal, we can find them at 
tail -f /var/log/kern.log

To load module
use insmod
modprobe may not work
http://stackoverflow.com/questions/3140478/fatal-module-not-found-error-using-modprobe
lsmod can list loaded module


Poll and interrupt
unsigned int (*poll) (struct file *filp, poll_table *wait);

The driver method is called whenever the user-space program performs a poll, select,or epoll system call involving a file descriptor associated with the driver. The device method is in charge of these two steps:
1. Call poll_wait on one or more wait queues that could indicate a change in the poll status. If no file descriptors are currently available for I/O, the kernel causes the process to wait on the wait queues for all file descriptors passed to the system call.
2. Return a bit mask describing the operations (if any) that could be immediately performed without blocking.

Driver entry points such as read() and poll() operate in tandem with interrupt handler roll_interrupt(). For example, when the handler deciphers wheel movement, it wakes up any waiting poll() threads that may have gone to sleep in response to a select() system call issued by an application

No comments:

Post a Comment

Post Code on Blogger

Simplest way to post code to blogger for me: <pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black;overflow-x:...