Does the Linux kernel source code contain device drivers?
I have been interested in kernel development for a while. What I am wondering is whether the kernel source code contains any code about the hardware components.
In other words, are device drivers part of kernel source code?
If they are part of kernel source code, how can it be possible?
By using a virtual machine or dual boot, we can set up Linux in any computer. How does Linus Torvalds write it to be compatible with all computers and their hardware components?
I think that device drivers are not part of the kernel.
12 Answers
Device drivers are in the kernel.
Linus wrote the original Linux kernel by himself, and remains very much involved (last I heard about it anyway) but now there are thousands of people developing for the Linux kernel. These folks include employees of companies like Intel who write drivers for their devices for the Linux kernel (and get paid to do it).
Note that one driver can work for many different devices. For example, i915 is the kernel's Intel CPU driver. There doesn't need to be a driver for every single different Intel CPU.
Loosely described, Linux kernel development is a huge, widely distributed project overseen by Linus and other core developers, with people contributing as their full time job, part of their work, as a hobby or project, all communicating through mailing lists. Anyone can write a patch for the kernel, patch the kernel, and use and distribute their patched kernel. But if your patch is so great it really ought to be in the kernel by default, with some feedback and help from others, it might get merged into a future kernel release. This open and diffuse model of development, with many minds and perspectives on the job, accounts somewhat for how the Linux kernel manages to support such a wide range of hardware. Here's the documentation for kernel development.
As chilli555 pointed out you can download the kernel source code and find device drivers. To do this, enable source repositories, create a directory in your home and enter it, and from there run (sudo is not needed):
apt source linux 2 You could get it from the linux kernel source code, the same as ubuntu
$ find linux-3.10.0-1127.el7/drivers/net/ethernet/broadcom/ -iname Kconfig | xargs grep -i support tristate "Broadcom 440x/47xx ethernet support" # Auto-select SSB PCI-HOST support, if possible tristate "Broadcom 63xx internal mac support" This driver supports the ethernet MACs in the Broadcom 63xx tristate "QLogic bnx2 support" This driver supports QLogic bnx2 gigabit Ethernet cards. tristate "QLogic CNIC support" This driver supports offload features of QLogic bnx2 gigabit tristate "SB1250 Gigabit Ethernet support" This driver supports Gigabit Ethernet interfaces based on the tristate "Broadcom Tigon3 support" This driver supports Broadcom Tigon3 based gigabit Ethernet cards. bool "Broadcom Tigon3 HWMON support" tristate "Broadcom NetXtremeII 10Gb support" This driver supports Broadcom NetXtremeII 10 gigabit Ethernet cards. bool "Broadcom 578xx and 57712 SR-IOV support" Virtualization support in the 578xx and 57712 products. This tristate "BCMA bus GBit core support" This driver supports GBit MAC and BCM4706 GBit MAC cores on BCMA bus. tristate "Broadcom NetXtreme-C/E support" This driver supports Broadcom NetXtreme-C/E 10/25/40/50 gigabit bool "Broadcom NetXtreme-C/E SR-IOV support" Virtualization support in the NetXtreme-C/E products. This bool "TC Flower offload support for NetXtreme-C/E" bool "Data Center Bridging (DCB) Support" bool "Broadcom NetXtreme-C/E HWMON support"Thanks David, How to find the source code ? Debian and ubuntu has the search web page. CentOS could unpack the src.rpm to got the source code
eg: go to you can see linux-signed_5.11.0-49.55.tar.xz in the right side.
centos:
2