研究设备驱动程序源文件?

Hen*_*rik 1 kernel linux-device-driver linux-kernel raspberry-pi beagleboneblack

我想研究一些设备驱动程序的源文件,这些驱动程序是在raspberry pi(raspian),beaglebone(debian)或我的笔记本电脑(ubuntu)上安装和加载的.

我的目标是通过研究一些实际工作的驱动程序的源文件来学习如何正确实现我自己的模块.

我对与实际硬件(USB,I2C,SPI,UART等)通信的驱动程序特别感兴趣.

有人能告诉我如何找到这些来源吗?它们是否在某些特定文件夹中可用,例如/ usr/src/****或者我是否必须从特定内核版本下载所有内核源文件?

我们非常感谢所有建议,意见和建议.

ps我读过"Linux内核开发第3版"但请告诉我你是否知道关于这个主题的任何其他免费/开源书籍.

最好的问候Henrik

Arv*_*dav 6

Linux源目录和描述:

  • arch/ - arch子目录包含所有体系结构特定的内核代码.

    Example :
    1. 'arch/arm/' will have your board related configuration file.
        like 'arch/arm/mach-omap/' will have omap specific source code.
    2. 'arch/arm/config' Generates a new kernel configuration with the
        default answer being used for all options. The default values
        are taken from a file located in the arch/$ARCH/defconfig
        file,where $ARCH refers to the specific architecture for which
        the kernel is being built.
    3. arch/arm/boot have kernel zImage, dtb image after compilation.
    
    Run Code Online (Sandbox Code Playgroud)
  • block/ - 此文件夹包含块设备驱动程序的代码.块设备是以块为单位接受和发送数据的设备.数据块是数据块而不是连续流.

  • crypto/ - 此文件夹包含许多加密算法的源代码.

     example, “sha1_generic.c” is the file that contains the code for
               the sha1 encryption algorithm.
    
    Run Code Online (Sandbox Code Playgroud)
  • 文档/ - 它具有文本格式的内核相关信息.

  • drivers/ -所有系统的设备驱动程序都存在于此目录中.它们进一步细分为设备驱动程序类.

     Example,
     1. drivers/video/backlight/ has blacklight driver source which
        will control display brightness.
     2. drivers/video/display/ has display driver source. 
     3. drivers/input/ has input driver source code. like touch,
        keyboard and mouse driver.
     4. drivers/char/ has charter driver source code.
     5. drivers/i2c/ has i2c subsystem and driver source code.
     6. drivers/pci/ has pci subsytem and driver related source code.
     7. drivers/bluetooth  has Bluetooth driver file.
     8. drivers/power has power and battery driver.
    
    Run Code Online (Sandbox Code Playgroud)
  • firmware/ - 固件文件夹包含允许计算机读取和理解来自设备的信号的代码.例如,网络摄像头管理自己的硬件,但计算机必须了解网络摄像头发送计算机的信号.

  • fs/ - 所有文件系统代码.这进一步细分为目录,每个受支持的文件系统一个,例如vfat和ext2.

  • kernel/ - 此文件夹中的代码控制内核本身.例如,如果调试器需要跟踪问题,内核将使用源自此文件夹中的源文件的代码来通知调试器内核执行的所有操作.此处还有代码用于跟踪时间.在kernel文件夹中有一个名为"power"的目录.此文件夹中的某些代码提供计算机重新启动,关闭电源和挂起的功能.

  • net/ - net内核的网络代码.lib该目录包含内核的库代码.特定于体系结构的库代码可以在arch/*/lib /中找到.scripts此目录包含配置内核时使用的脚本(例如awk和tk脚本).

  • lib/ - 该目录包含内核的库代码.特定于体系结构的库代码可以在arch/*/lib /中找到.

  • scripts/ - 此目录包含配置内核时使用的脚本(例如awk和tk脚本).

  • mm/ - 此目录包含所有内存管理代码.特定于体系结构的内存管理代码以arch/*/mm /为单位,例如arch/i386/mm/fault.c.

  • ipc/ - 该目录包含内核进程间通信代码.

  • **init/ - **init文件夹包含处理内核启动的代码(INITiation).main.c文件是内核的核心.这是连接所有其他文件的主要源代码文件.

  • 声音/ -这是所有声卡驱动程序的所在.

还有更多的目录证书,加密,安全,包含,virt和usr等....