Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 1.305 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
1.305
Dung lượng
6,89 MB
Nội dung
Essential Linux Device Drivers by Sreekrishnan Venkateswaran Publisher: Prentice Hall Pub Date: March 27, 2008 Print ISBN-10: 0-13-239655-6 Print ISBN-13: 978-0-13-239655-4 Pages: 744 Table of Contents | Index Overview "Probably the most wide ranging and complete Linux device driver book I've read." Alan Cox, Linux Guru and Key Kernel Developer "Very comprehensive and detailed, covering almost every single Linux device driver type." Theodore Ts'o, First Linux Kernel Developer in North America and Chief Platform Strategist of the Linux Foundation The Most Practical Guide to Writing Linux Device Drivers Linux now offers an exceptionally robust environment for driver development: with today's kernels, what once required years of development time can be accomplished in days In this practical, example-driven book, one of the world's most experienced Linux driver developers systematically demonstrates how to develop reliable Linux drivers for virtually any device Essential Linux Device Drivers is for any programmer with a working knowledge of operating systems and C, including programmers who have never written drivers before Sreekrishnan Venkateswaran focuses on the essentials, bringing together all the concepts and techniques you need, while avoiding topics that only matter in highly specialized situations Venkateswaran begins by reviewing the Linux 2.6 kernel capabilities that are most relevant to driver developers He introduces simple device classes; then turns to serial buses such as I2C and SPI; external buses such as PCMCIA, PCI, and USB; video, audio, block, network, and wireless device drivers; user-space drivers; and drivers for embedded Linux–one of today's fastest growing areas of Linux development For each, Venkateswaran explains the technology, inspects relevant kernel source files, and walks through developing a complete example • Addresses drivers discussed in no other book, including drivers for I2C, video, sound, PCMCIA, and different types of flash memory • Demystifies essential kernel services and facilities, including kernel threads and helper interfaces • Teaches polling, asynchronous notification, and I/O control • Introduces the Inter-Integrated Circuit Protocol for embedded Linux drivers • Covers multimedia device drivers using the Linux-Video subsystem and Linux-Audio framework • Shows how Linux implements support for wireless technologies such as Bluetooth, Infrared, WiFi, and cellular networking • Describes the entire driver development lifecycle, through debugging and maintenance • Includes reference appendixes covering Linux assembly, BIOS calls, and Seq files Essential Linux Device Drivers by Sreekrishnan Venkateswaran Publisher: Prentice Hall Pub Date: March 27, 2008 Print ISBN-10: 0-13-239655-6 Print ISBN-13: 978-0-13-239655-4 Pages: 744 Table of Contents | Index Copyright Prentice Hall Open Source Software Development Series Foreword Preface Acknowledgments About the Author Chapter 1 Introduction Evolution The GNU Copyleft Kernel.org Mailing Lists and Forums Linux Distributions Looking at the Sources Building the Kernel Loadable Modules Before Starting Chapter 2 A Peek Inside the Kernel Booting Up Kernel Mode and User Mode Process Context and Interrupt Context Kernel Timers Concurrency in the Kernel Process Filesystem Allocating Memory Looking at the Sources Chapter 3 Kernel Facilities Kernel Threads Helper Interfaces Looking at the Sources Chapter 4 Laying the Groundwork Introducing Devices and Drivers Interrupt Handling The Linux Device Model Memory Barriers Power Management Looking at the Sources Chapter 5 Character Drivers Char Driver Basics Device Example: System CMOS Sensing Data Availability Talking to the Parallel Port RTC Subsystem Pseudo Char Drivers Misc Drivers Character Caveats Looking at the Sources Chapter 6 Serial Drivers Layered Architecture UART Drivers TTY Drivers Line Disciplines Looking at the Sources Chapter 7 Input Drivers Input Event Drivers Input Device Drivers Debugging Looking at the Sources Chapter 8 The Inter-Integrated Circuit Protocol What's I2C/SMBus? I2C Core Bus Transactions Device Example: EEPROM Device Example: Real Time Clock I2C-dev Hardware Monitoring Using LM-Sensors The Serial Peripheral Interface Bus The 1-Wire Bus Debugging Looking at the Sources Chapter 9 PCMCIA and Compact Flash What's PCMCIA/CF? Linux-PCMCIA Subsystem Host Controller Drivers PCMCIA Core Driver Services Client Drivers Tying the Pieces Together PCMCIA Storage Serial PCMCIA Debugging Looking at the Sources Chapter 10 Peripheral Component Interconnect The PCI Family Addressing and Identification Accessing PCI Regions Direct Memory Access Device Example: Ethernet-Modem Card Debugging Looking at the Sources Chapter 11 Universal Serial Bus USB Architecture Linux-USB Subsystem Driver Data Structures Enumeration Device Example: Telemetry Card Class Drivers Gadget Drivers Debugging Looking at the Sources Chapter 12 Video Drivers Display Architecture Linux-Video Subsystem Display Parameters The Frame Buffer API Frame Buffer Drivers Console Drivers Debugging Looking at the Sources Chapter 13 Audio Drivers Audio Architecture Linux-Sound Subsystem Device Example: MP3 Player Debugging Looking at the Sources Chapter 14 Block Drivers Storage Technologies Linux Block I/O Layer I/O Schedulers Block Driver Data Structures and Methods Device Example: Simple Storage Controller Advanced Topics Debugging Looking at the Sources Chapter 15 Network Interface Cards Driver Data Structures Talking with Protocol Layers Buffer Management and Concurrency Control Device Example: Ethernet NIC ISA Network Drivers Asynchronous Transfer Mode Network Throughput Looking at the Sources Chapter 16 Linux Without Wires Bluetooth Infrared WiFi Cellular Networking Current Trends Chapter 17 Memory Technology Devices What's Flash Memory? Linux-MTD Subsystem Map Drivers NOR Chip Drivers NAND Chip Drivers User Modules MTD-Utils Configuring MTD eXecute In Place The Firmware Hub Debugging Looking at the Sources Chapter 18 Embedding Linux Challenges Component Selection Tool Chains Embedded Bootloaders Memory Layout Kernel Porting Embedded Drivers The Root Filesystem Test Infrastructure Debugging Chapter 19 Drivers in User Space Process Scheduling and Response Times Accessing I/O Regions Accessing Memory Regions User Mode SCSI User Mode USB User Mode I2C UIO Looking at the Sources Chapter 20 More Devices and Drivers ECC Reporting Frequency Scaling Embedded Controllers ACPI ISA and MCA FireWire Intelligent Input/Output Amateur Radio Voice over IP High-Speed Interconnects Chapter 21 Debugging Device Drivers Kernel Debuggers Kernel Probes Kexec and Kdump Profiling Tracing Linux Test Project User Mode Linux Diagnostic Tools Kernel Hacking Config Options Test Equipment Chapter 22 Maintenance and Delivery Coding Style Change Markers Version Control Consistent Checksums Build Scripts Portable Code Chapter 23 Shutting Down Checklist What Next? Appendix A Linux Assembly Debugging Appendix B Linux and the BIOS Real Mode Calls Protected Mode Calls BIOS and Legacy Drivers Appendix C Seq Files The Seq File Advantage Updating the NVRAM Driver Looking at the Sources Index Copyright Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals The author and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests For more information, please contact: U.S Corporate and Government Sales (800) 382-3419 corpsales@pearsontechgroup.com For sales outside the United States please contact: International Sales international@pearson.com Visit us on the Web: www.informit.com/ph Library of Congress Cataloging-in-Publication Data: Venkateswaran, Sreekrishnan, 1972 Essential Linux device drivers / Sreekrishnan Venkateswaran.- 1st ed p cm ISBN 0-13-239655- compiling connection diagram flushing data I/O Control open/close operations opening read paths write paths touchpads touch screens trace daemon traced state (threads) tracereader tracevisualizer tracing LTT (Linux Trace Toolkit) components events LTTng LTTV (Linux Trace Toolkit Viewer) trace dumps overview trackpoints transactions (I2C) transceivers (USB) transfer [See data transfer.] Transistor-Transistor Logic (TTL) transmit paths (NICs) trojan_function() function TROUBLED_DS environmental variable TSC (Time Stamp Counter) 2nd tsdev driver TTL (Transistor-Transistor Logic) tty.c driver tty_buffer structure 2nd tty_bufhead structure 2nd tty_driver structure 2nd TTY drivers tty_flip_buffer_push() function 2nd tty_flip_buffer structure tty_insert_flip_char() function 2nd 3rd tty_ldisc structure 2nd tty_open() function tty_register_device() function tty_register_driver() function 2nd tty_register_ldisc() function tty_struct structure 2nd tty_unregister_driver() function tty_unregister_ldisc() function TUN/TAP device driver TUN network driver tuple_t structure 2nd Index [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] U-Boot uart_add_one_port() function 2nd 3rd uart_driver structure 2nd UART (Universal Asynchronous Receiver Transmitter) drivers 2nd cell phone device example claiming/freeing memory CPLD (Complex Programmable Logic Device) overview platform drivers SoC (System-on-Chip) USB_UART driver USB_UART ports USB_UART register layout registering RS-485 uart_driver structure uart_ops structure uart_port structure uart_ops structure 2nd uart_port structure 2nd uart_register_driver() function 2nd 3rd uart_unregister_driver() function UCEs (uncorrectable errors) uClibc uClinux UDB class drivers debugging udelay() function 2nd udev on embedded devices PCMCIA udevmonitor udevsend UHCI (Universal Host Controller Interface) UIO (Userspace IO) uIP UML (User Mode Linux) uncorrectable errors (UCEs) uninterruptible state (threads) Universal Asynchronous Receiver Transmitter [See UART (Universal Asynchronous Receiver Transmitter) drivers.] Universal Host Controller Interface (UHCI) universal serial bus [See USB (universal serial bus).] UNIX-domain sockets unlikely() function 2nd unregister_blkdev() function unregister_chrdev_region() function unregister_netdev() function unregister_netdevice_notifier() function up() function up_read() function up_write() function updating BIOS NVRAM drivers urandom char device URBs (USB Request Blocks) urb structure 2nd USB (universal serial bus) addressing Bluetooth 2nd bus speeds class drivers HIDs (human interface devices) mass storage overview USB-Serial compared to I2C and PCI data structures descriptors pipes tables of URBs (USB Request Blocks) usb_device structure embedded drivers on embedded systems endpoints enumeration gadget drivers host controllers illustration of Linux-USB subsystem kernel programming interfaces, table of Linux-USB subsystem architecture mice OTG controllers overview receptacles sources telemetry card example data transfer driver initialization pci_device_id structure probing and disconnecting register access register space transceivers transfer types URBs (USB Request Blocks) usbfs virtual filesystem USB Gadget project USB-Serial usb-serial.c driver usb_[control|interrupt|bulk]_msg() function usb_[rcv|snd][ctrl|int|bulk|isoc]pipe() function 2nd usb_alloc_urb() function 2nd usb_buffer_alloc() function usb_buffer_free() function usb_bulk_msg() function usb_bus structure usb_close() function usb_config_descriptor structure 2nd usb_control_msg() function 2nd 3rd usb_ctrlrequest structure usb_deregister() function usb_deregister_dev() function usb_dev_handle structure USB_DEVICE() macro usb_device_descriptor structure 2nd usb_device_id structure usb_device structure 2nd 3rd usb_driver structure usb_endpoint_descriptor structure 2nd usb_fill_bulk_urb() function 2nd usb_fill_control_urb() function 2nd 3rd usb_fill_int_urb() function 2nd usb_find_buses() function usb_find_devices() function usb_find_interface() function usb_free_urb() function 2nd usb_gadget_driver structure 2nd usb_gadget_register_driver() function 2nd usb_get_intfdata() function 2nd usb_init() function usb_interface_descriptor structure 2nd usb_open() function usb_register() function 2nd usb_register_dev() function usb_serial_deregister() function usb_serial_driver structure usb_serial_register() function 2nd usb_set_intfdata() function 2nd usb_submit_urb() function 2nd usb_tele_init() function USB_UART USB_UART driver code listing register layout USB_UART ports usb_uart_probe() function usb_uart_rxint() function usb_uart_start_tx() function usb_unlink_urb() function 2nd usbfs virtual filesystem 2nd USB Gadget project usbhid driver usbhid USB client driver USB keyboards usbmon command USB Request Blocks (URBs) usbserial drivers user mode drivers data structures I/O regions accessing dumping bytes from memory regions, accessing parallel port LED boards, controlling process scheduling CFS (Completely Fair Scheduler) O(1) scheduler original scheduler overview response times sg (SCSI Generic) sources UIO (Userspace IO) usbfs virtual filesystem user mode I2C user space library functions when to use user mode helpers User Mode Linux (UML) User Modules block device emulation char device emulation definition JFFS (Journaling Flash File System) MTD-utils overview YAFFS (Yet Another Flash File System) user space drivers [See user mode drivers.] userspace governor Userspace IO (UIO) user space library functions usr directory UU_READ_DATA_REGISTER UU_STATUS_REGISTER UU_WRITE_DATA_REGISTER Index [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] V2IP (Video-and-Voice over IP) variables loops_per_jiffy 2nd 3rd xtime VCI (virtual circuit identifier) verify checksum command (ioctl) version control Very high speed integrated circuit Hardware Description Language (VHDL) vesafb (video frame buffer driver) VFS (Virtual File System) 2nd vfs_readdir() function VGA (Video Graphics Array) VHDL (Very high speed integrated circuit Hardware Description Language video cabling standards controllers embedded drivers VGA (Video Graphics Array) video frame buffer driver [See vesafb (video frame buffer driver).] Video-and-Voice over IP (V2IP) video1394 driver virtual addresses virtual circuit identifier (VCI) Virtual File System (VFS) 2nd virtual mouse device example gpm (general-purpose mouse) simulating mouse movements vms.c input driver Virtual Network Computing (VNC) virtual path identifier (VPI) virtual terminals (VTs) Vital Product Data (VPD) vmalloc() function 2nd vmlinux kernel image vms.c application vms_init() function VNC (Virtual Network Computing) VoIP (Voice over Internet Protocol) VOLUME_REGISTER VPD (Vital Product Data) VPI (virtual path identifier) vt.c driver VTs (virtual terminals) Index [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] w1 bus w1_family_ops structure w1_family structure wait_event_timeout() function 2nd wait_for_completion() function 2nd wait_queue_t structure wait queues [See queues.] wake_up_interruptible() function 2nd 3rd wall time watchdog timeout watchdog timer watchpoints wd33c93_init() function wear leveling WiFi 2nd 3rd WiMax wireless trade-offs for WiFi 2nd 3rd Wireless Extensions wmb() function 2nd work, submitting to be executed later work_struct structure 2nd worker thread workqueue_struct structure work queues 2nd 3rd write() method write_lock() function write_lock_irqrestore() function 2nd write_lock_irqsave() function 2nd write_seqlock() function write_sequnlock() function write_unlock() function write_vms() function write_wakeup() function writev() function writing CMOS driver input event drivers Index [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] x86 bootloaders xf86SIGIO() function Xf86WaitForInput() function XGA (eXtended Graphics Array) XIP (eXecute In Place) xtime variable X Windows Index [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] YAFFS (Yet Another Flash File System) Index [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] zero-page.txt file zero char device zero page Zigbee zombie processes zombie state (threads) ZONE_DMA ZONE_HIGH ZONE_NORMAL ... • Includes reference appendixes covering Linux assembly, BIOS calls, and Seq files Essential Linux Device Drivers by Sreekrishnan Venkateswaran Publisher: Prentice Hall Pub Date: March 27, 2008 Print ISBN- 10: 0-13-239655-6 Print ISBN- 13: 978-0-13-239655-4... Venkateswaran, Sreekrishnan, 1972 Essential Linux device drivers / Sreekrishnan Venkateswaran.- 1st ed p cm ISBN 0-13-239655- 6 (hardback : alk paper) 1 Linux device drivers (Computer programs) I Title QA76.76.D49V35 2008. .. • Introduces the Inter-Integrated Circuit Protocol for embedded Linux drivers • Covers multimedia device drivers using the Linux- Video subsystem and Linux- Audio framework • Shows how Linux implements support for wireless