Linux 内核源代码是否包含设备驱动程序?

Linux 内核源代码是否包含设备驱动程序?

我对内核开发很感兴趣。我想知道的是内核源代码是否包含有关硬件组件的代码。

换句话说,设备驱动程序是内核源代码的一部分吗?

如果它们是内核源代码的一部分,那怎么可能呢?

通过使用虚拟机或双启动,我们可以在任何计算机上安装 Linux。Linus Torvalds 如何编写它以与所有计算机及其硬件组件兼容?

我认为设备驱动程序不是内核的一部分。

答案1

设备驱动程序位于内核中。

Linus 亲自编写了最初的 Linux 内核,并且仍然积极参与(至少我最近听说了),但现在有成千上万的人在为 Linux 内核开发。这些人包括英特尔等公司的员工,他们为 Linux 内核编写设备驱动程序(并因此获得报酬)。

请注意,一个驱动程序可以适用于许多不同的设备。例如,i915 是内核的 Intel CPU 驱动程序。不需要为每个不同的 Intel CPU 都设置一个驱动程序。

粗略地讲,Linux 内核开发是一个庞大且分布广泛的项目,由 Linus 和其他核心开发人员监督,人们将贡献作为他们的全职工作、工作的一部分、业余爱好或项目,所有人都通过邮件列表进行交流。任何人都可以为内核编写补丁、修补内核,并使用和分发修补后的内核。但如果您的补丁非常棒,它真的应该默认包含在内核中,在其他人的反馈和帮助下,它可能会合并到未来的内核版本中。这种开放而分散的开发模式,以及许多思想和观点,在一定程度上解释了 Linux 内核如何能够支持如此广泛的硬件。这是内核开发的文档

作为chilli555指出您可以下载内核源代码并查找设备驱动程序。为此,请启用源代码存储库,在您的主目录中创建一个目录并进入该目录,然后从那里运行(sudo不需要):

apt source linux

答案2

你可以从 linux 内核源代码中获取它,与 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"

谢谢 David,如何找到源代码?Debian 和 ubuntu 有搜索网页。CentOS 可以解压 src.rpm 来获取源代码

例如:前往https://packages.ubuntu.com/hirsute/linux-image-5.11.0-49-generic 您可以在右侧看到linux-signed_5.11.0-49.55.tar.xz。

  1. Ubuntu

  2. 德比安

  3. centos解压 src.rpm

centos:http://ftp.riken.jp/Linux/cern/centos/7/os/Sources/SPackages/kernel-3.10.0-1160.el7.src.rpm

相关内容