Questions tagged [linux-device-driver]

Device drivers take on a special role in the Linux kernel. They are distinct programmatically abstracted “black boxes” that make a particular piece of hardware respond to a well-defined internal programming interface; they hide completely the details of how the device works.

User activities are performed by means of a set of standardized calls that are independent of the specific driver. Mapping those calls to device-specific operations that act on real hardware is the role of the device driver. This programming interface is such that drivers can be built separately from the rest of the kernel and “plugged in” at runtime when needed. This modularity makes Linux device drivers easy to write, to the point that there are now thousands of them available.

There are a number of reasons to be interested in the writing of Linux device drivers.

  • The rate at which new hardware becomes available (and obsolete!) alone guarantees that driver writers will be busy for the foreseeable future.

  • Individuals may need to know about drivers in order to gain access to a particular device that is of interest to them.

  • Hardware vendors, by making a Linux device driver available for their products, can add the large and growing Linux user-base to their potential markets.

The open-source nature of the Linux system means that if the driver writer wishes, the source to a driver can be quickly disseminated to millions of users.

Source -

  1. Linux Device Drivers 3rd edition

  2. Linux module programming guide

4991 questions
16
votes
2 answers

How would one prevent MMAP from caching values?

I've written a linux driver that ioremaps exports PCI BAR0 for a particular device to a sysfs binary attribute allowing userspace to directly control it. The problem rears when I attempt to MMAP on top of the attribute to directly access that bit of…
Sean Madden
  • 1,069
  • 2
  • 10
  • 22
16
votes
6 answers

Linux keyboard event capturing /dev/inputX

I was trying to capture keyboard events. e.g. I want to drill down a keylogger from the scratch. After 2 hours of fighting I found the following neel@pc1$ ls -l /dev/input/by-id lrwxrwxrwx 1 root root 9 2010-05-05 21:33…
Neel Basu
  • 12,638
  • 12
  • 82
  • 146
16
votes
1 answer

Why softirq is used for highly threaded and high frequency uses?

What makes the softirq so special that we use it for high frequency uses., like in network drivers and block drivers.
16
votes
2 answers

strerror-like functionality in the kernel?

Is there any strerror-like functionality currently in the kernel? I haven't been able to find one so my thought is no, but more importantly, has their been any discussion about this? I would think it could reduce troubleshooting time, since you wont…
Daniel Santos
  • 3,098
  • 26
  • 25
15
votes
6 answers

How to create a device in /dev automatically upon loading of the kernel module for a device driver?

I am attempting to develop Linux device drivers and as my first attempt I am trying to develop a char device driver that has the following file options, struct file_operations fops{ .open=open_fun, .release=release_fun, .write=write_fun, …
Mir
  • 670
  • 4
  • 9
  • 20
15
votes
1 answer

Call trace when loading a module in Linux

I'm writing my first Linux kernel module, which actually is a RAM disk driver plus some additional features. When I tried to insmod the module, "Segmentation fault" happened. And here is the corresponding kernel log, actually two pieces of kernel…
OliveU
  • 359
  • 2
  • 5
  • 10
15
votes
7 answers

c++ device driver development in linux

I wanted to get more details for writing Graphics device drivers and audio device drivers using c++ for Linux box. I am newbie at developing device drivers , Please provide me development/documentation details for the same. Thanks -Pravin
pravin
  • 2,155
  • 8
  • 37
  • 49
15
votes
1 answer

Docker container: lsmod not found

How can I get lsmod and modprobe installed in Ubuntu 14 that is running on Docker? I need to install a device driver in the container, but first I need these commands. (The docker image is originally from docker hub, from a tomcat:7 image).
nikk
  • 2,627
  • 5
  • 30
  • 51
15
votes
1 answer

Pass a string parameter with space character to kernel module

module name: params.ko #include #include #include #include #include MODULE_LICENSE("Dual BSD/GPL"); static char *mystring = "this is my char…
rickhau
  • 263
  • 5
  • 14
15
votes
2 answers

fatal error: libudev.h: No such file or directory

I compile with g++/gcc on ubuntu12.04 and it is "OK" but I cannot cross compile using raspberry pi tools master toolsmaster CC :=…
WenJuan
  • 624
  • 1
  • 8
  • 21
15
votes
3 answers

How to pass a value to a builtin Linux kernel module at boot time?

I want to pass a custom parameter to the kernel at boot time, which my new code will use. This parameter is a number. I know how to pass value to kernel module using kernel command line i.e module_param(). Now i want to pass value from u-boot. Is…
vishnumotghare
  • 591
  • 1
  • 5
  • 23
15
votes
2 answers

How can I find which physical device /dev/console connects to?

There is a device file called /dev/console, whose (major,minor) is (5,1). When I boot with a serial console, it connects to my UART port as /dev/ttyS0 does. But when I boot with serial console disabled, the /dev/console seems to connect to…
user1937358
  • 239
  • 1
  • 2
  • 8
15
votes
2 answers

copy_to_user vs memcpy

I have always been told(In books and tutorials) that while copying data from kernel space to user space, we should use copy_to_user() and using memcpy() would cause problems to the system. Recently by mistake i have used memcpy() and it worked…
Sandeep
  • 18,356
  • 16
  • 68
  • 108
15
votes
2 answers

Device node at /dev/tty* not getting created for uart serial driver

I have written a simple UART serial driver in embedded Linux running busybox with mdev rules. I have provided .dev_name as "ttyC2C" in my driver code. static struct uart_driver serial_omap_reg = { .owner = THIS_MODULE, .driver_name =…
manav m-n
  • 11,136
  • 23
  • 74
  • 97
15
votes
2 answers

What happens when a mov instruction causes a page fault with interrupts disabled on x86?

I recently encountered an issue in a custom Linux kernel (2.6.31.5, x86) driver where copy_to_user would periodically not copy any bytes to user space. It would return the count of bytes passed to it, indicating that it had not copied anything. …
Edward
  • 488
  • 2
  • 16