2015年8月22日 星期六

Linux Device Drivers

An Introduction to Device Drivers (LDD3 ch1 PDF)
  • The Role of the Device Driver
  • Splitting the Kernel
  • Classes of Devices and Modules
  • Security Issues
  • Version Numbering
  • License Terms
  • Joining the Kernel Development Community
  • Overview of the Book
Building and Running Modules (LDD3 ch2 PDF)
  • 建立測試系統
  • 簡易模組:hello
  • Kernel Modules Versus Applications
  • Compiling and Loading
  • The Kernel Symbol Table
  • Preliminaries
  • Initialization and Shutdown
  • 模組參數
  • Doing It in User Space
  • Quick Reference
  • Linux Modules(1.1)module parameters
Char Drivers (LDD3 ch3 PDF)
  • scull (Simple Character Utility for Loading Localities) 是用一塊取得的記憶體作為 device 的 char driver,有多種形式示範不同功能:
    • scull0 ~ scull3:每個包含 global 且 persistent 的記憶體區塊。global 表示 device 開啟後,記憶體區塊是共享的。persistent 表示 device 關閉後再開啟,資料還是在。可用 cp、cat、shell I/O 轉向等指令存取和 tested。
    • scullpipe0 ~ scullpipe3 (ch6 A Blocking I/O Example):FIFO (first-in-first-out) device,行為類似 pipe,一個 process 讀另一個 process 寫的。如果多個 process 同時讀,競爭取得資料。scullpipe 內部不用中斷實作 blocking and non-blocking read and write,雖然真實 driver 使用硬體中斷同步 device, the topic of blocking and nonblocking operations is an important one and is separate from interrupt handling (covered in Chapter 10).
    • scullsingle, scullpriv, sculluid, scullwuid (ch6 Access Control on a Device File):類似 scull0 但有一些開啟限制。scullsingle 只允許一個 process 使用。scullpriv 對每個 virtual console 或 X terminal session 會取到不同記憶體區域而各自獨立。sculluid 和 scullwuid 同一個 user 可以開啟多次,但如果有其它 user 使用時開啟,前者會回「Device Busy」的錯誤,後者實作會 blocking。雖然看起來混淆 policy 和 mechanism,但一些真實 device 需要這類的管理而值得了解。
  • Major and Minor Numbers
  • Some Important Data Structures:包括 File Operations、The file Structure、The inode Structure
  • Char Device Registration
  • open and release
  • scull’s Memory Usage
  • read and write
  • Playing with the New Devices
  • Quick Reference

Debugging Techniques (LDD3 ch4 PDF)
Concurrency and Race Conditions (LDD3 ch5PDF)
Advanced Char Driver Operations (LDD3 ch6 PDF)

  • 在 LDD Chap. 3 建立了一個可以 read()/write() 的 device driver,但真實的 device 提供的功能不只這樣。現在可以進一步,萬一出現 concurrency 問題造成混亂,也有除錯工具可徹底了解。ioctl() 系統呼叫是 device 的共通控制界面。synchronizing with user space 的各種方式; 如何 put processes to sleep (and wake them up), implement nonblocking I/O, and inform user space when your devices are available for reading or writing. a look at how to implement a few different device access policies within drivers. 這些透過 a couple of modified versions of the scull driver 示範,所有實作仍使用 in-memory virtual devices,而不需要特殊硬體。LDD Chap. 9 才會用到真正的硬體。
  • ioctlioctl()
  • Blocking I/O
  • poll and select
  • Asynchronous Notification
  • Seeking a Device
  • Access Control on a Device File
  • Quick Reference

Time, Delays, and Deferred Work (LDD3 ch7 PDF)

Allocating Memory (LDD3 ch8 PDF)
Communicating with Hardware(LDD3 ch9 PDF)
Interrupt Handling (LDD3 ch10 PDF)
Data Types in the Kernel (LDD3 ch11 PDF)
PCI Drivers (LDD3 ch12 PDF)
USB Drivers (LDD3 ch13 PDF)
The Linux Device Model (LDD3 ch14 PDF)
Memory Mapping and DMA (LDD3 ch15 PDF)
Block Drivers (LDD3 ch16 PDF)
Network Drivers (LDD3 ch17 PDF)
TTY Drivers (LDD3 ch18 PDF)

參考來源

  1. https://lwn.net/Kernel/LDD3/ (Table of ContentsIndex、調整過的範例程式:martinezjavier, jesstess)
  • Free Tutorials: Linux Device Drivers
  • Linux Device Drivers 4th, ISBN 978-1-4493-7161-6, Published 2017 O'Reilly Media, Authors:Jessica McKellarAlessandro RubiniJonathan CorbetGreg Kroah-Hartman

沒有留言:

張貼留言

SIP header Via

所有 SIP 訊息 都要有 Via,縮寫 v。一開始的 UAC 和後續途經的每個 proxy 都會疊加一個 Via 放傳送的位址,依序作為回應的路徑。 格式 sent-protocol sent-by [ ;branch= branch ][ ; 參數 ...] s...