Foxcoon Confidential 1
Linux Driver
David Chen
Foxcoon Confidential 2
Kernel
Process
Resource
computing power
Memory
network connectivity
Kernel
是一塊可讓 CPU 直接執行的 machine code
分配系統資源給各 process
Foxcoon Confidential 3
kernel functions architecture
Foxcoon Confidential 4
kernel functions
Process Management
Creating and destroying processes
scheduler
Memory Management
The different parts of the kernel interact with the memory-management
subsystem through a set of function calls
File system
Linux supports multiple filesystem types
ex2,ex3,FAT…
Device Control
All device control operations are performed by device drivers
Networking
must be managed by the operating system
Foxcoon Confidential 5
Kernel Modules
Modules
Each piece of code that can be added to the
kernel at runtime
Each module is made up of object code
insmod and rmmod
Foxcoon Confidential 6
Classes of devices and modules
Character device
can be accessed as a stream of bytes
Usually implements at least the open, close, read, and
write system calls
Text console (/dev/console) and the serial ports
(/dev/ttyS0)
Block device
block devices are accessed by filesystem nodes in the
/dev directory
disk
Network interface
Foxcoon Confidential 7
Security Issues
Any security check in the system is enforced by kernel code
init_module checks if the invoking process is authorized to load a
module into the kernel
only the superuser can exploit the power of privileged code
Driver writers must also be careful, of course, to avoid
introducing security bugs
Buffer overrun
uninitialized memory
Any input received from user processes should be treated with
great suspicion
Foxcoon Confidential 8
Linux Version Numbering
Every software package used in a Linux system has its own
release number, and there are often interdependencies
across them
even-numbered kernel versions(2.6.x)
stable
odd-numbered kernel versions(2.7.x)
Not stable
Foxcoon Confidential 9
License Terms
General Public license version 2(GPLv2)
GPL 允許任何人散 與銷售佈 GPL 規範的產品 , 前提是必須
要讓收受者能獲得原始程式 , 並繼承同樣的權利
Foxcoon Confidential 9
License Terms
General Public license version 2(GPLv2)
GPL 允許任何人散 與銷售佈 GPL 規範的產品 , 前提是必須
要讓收受者能獲得原始程式 , 並繼承同樣的權利

Linux Device Driver Introduction

  • 1.
  • 2.
    Foxcoon Confidential 2 Kernel Process Resource computingpower Memory network connectivity Kernel 是一塊可讓 CPU 直接執行的 machine code 分配系統資源給各 process
  • 3.
    Foxcoon Confidential 3 kernelfunctions architecture
  • 4.
    Foxcoon Confidential 4 kernelfunctions Process Management Creating and destroying processes scheduler Memory Management The different parts of the kernel interact with the memory-management subsystem through a set of function calls File system Linux supports multiple filesystem types ex2,ex3,FAT… Device Control All device control operations are performed by device drivers Networking must be managed by the operating system
  • 5.
    Foxcoon Confidential 5 KernelModules Modules Each piece of code that can be added to the kernel at runtime Each module is made up of object code insmod and rmmod
  • 6.
    Foxcoon Confidential 6 Classesof devices and modules Character device can be accessed as a stream of bytes Usually implements at least the open, close, read, and write system calls Text console (/dev/console) and the serial ports (/dev/ttyS0) Block device block devices are accessed by filesystem nodes in the /dev directory disk Network interface
  • 7.
    Foxcoon Confidential 7 SecurityIssues Any security check in the system is enforced by kernel code init_module checks if the invoking process is authorized to load a module into the kernel only the superuser can exploit the power of privileged code Driver writers must also be careful, of course, to avoid introducing security bugs Buffer overrun uninitialized memory Any input received from user processes should be treated with great suspicion
  • 8.
    Foxcoon Confidential 8 LinuxVersion Numbering Every software package used in a Linux system has its own release number, and there are often interdependencies across them even-numbered kernel versions(2.6.x) stable odd-numbered kernel versions(2.7.x) Not stable
  • 9.
    Foxcoon Confidential 9 LicenseTerms General Public license version 2(GPLv2) GPL 允許任何人散 與銷售佈 GPL 規範的產品 , 前提是必須 要讓收受者能獲得原始程式 , 並繼承同樣的權利
  • 10.
    Foxcoon Confidential 9 LicenseTerms General Public license version 2(GPLv2) GPL 允許任何人散 與銷售佈 GPL 規範的產品 , 前提是必須 要讓收受者能獲得原始程式 , 並繼承同樣的權利