Franklin

FreeBSD Device Drivers : A Guide for the Intrepid.

Author/Creator:
Kong, Joseph.
Publication:
San Francisco : No Starch Press, Incorporated, 2012.
Format/Description:
Book
1 online resource (354 pages)
Edition:
1st ed.
Status/Location:
Loading...

Options
Location Notes Your Loan Policy

Details

Other records:
Subjects:
FreeBSD.
Free computer software.
Device drivers (Computer programs).
Form/Genre:
Electronic books.
Summary:
FreeBSD Device Drivers is the first and only book to teach readers how to develop device drivers for the FreeBSD operating system. A one-stop reference for FreeBSD device driver writers of all levels of expertise, FreeBSD Device Drivers begins with the nuts and bolts of device drivers, including explanations of the different driver components and building blocks. You will then learn how to build and run modules, allocate memory, control device communication, deal with concurrency issues, manage hardware resources, handle interrupts, support direct memory access, write PCI, SCSI, and USB device drivers, and more. With case study chapters that dissect various drivers and a liberal use of examples—from simple "hello, world" drivers to full-blown, hardware-controlling drivers—you will walk away with a full understanding of how device drivers work on FreeBSD. This book is for anyone writing device drivers, but also for any FreeBSD enthusiast who would appreciate its hands-on approach to understanding the device driver subsystem, kernel internals, and key design choices made by the FreeBSD developers.
Contents:
Intro
About the Author and the Technical Reviewer
Foreword
Acknowledgments
Introduction
Who Is This Book For?
Prerequisites
Contents at a Glance
Welcome Aboard!
1: Building and Running Modules
Types of Device Drivers
Loadable Kernel Modules
Module Event Handler
DECLARE_MODULE Macro
Hello, world!
Compiling and Loading
Character Drivers
d_foo Functions
Character Device Switch Table
make_dev and destroy_dev Functions
Mostly Harmless
echo_write Function
echo_read Function
echo_modevent Function
DEV_MODULE Macro
Don't Panic
Block Drivers Are Gone
Conclusion
2: Allocating Memory
Memory Management Routines
malloc_type Structures
MALLOC_DEFINE Macro
MALLOC_DECLARE Macro
Tying Everything Together
Contiguous Physical Memory Management Routines
A Straightforward Example
Conclusion
3: Device Communication and Control
ioctl
Defining ioctl Commands
Implementing ioctl
echo_write Function
echo_set_buffer_size Function
echo_ioctl Function
echo_modevent Function
Don't Panic
Invoking ioctl
sysctl
Implementing sysctls, Part 1
sysctl Context Management Routines
Creating Dynamic sysctls
SYSCTL_STATIC_CHILDREN Macro
SYSCTL_CHILDREN Macro
Implementing sysctls, Part 2
sysctl_set_buffer_size Function
Don't Panic
Conclusion
4: Thread Synchronization
A Simple Synchronization Problem
A More Complex Synchronization Problem
race_new Function
race_find Function
race_destroy Function
race_ioctl Function
race_modevent Function
The Root of the Problem
Preventing Race Conditions
Mutexes
Spin Mutexes
Sleep Mutexes
Mutex Management Routines
Implementing Mutexes
race_modevent Function
Don't Panic
Shared/Exclusive Locks
Shared/Exclusive Lock Management Routines.
Implementing Shared/Exclusive Locks
Reader/Writer Locks
Reader/Writer Lock Management Routines
Condition Variables
Condition Variable Management Routines
General Guidelines
Avoid Recursing on Exclusive Locks
Avoid Holding Exclusive Locks for Long Periods of Time
Conclusion
5: Delaying Execution
Voluntary Context Switching, or Sleeping
Implementing Sleeps and Condition Variables
sleep_modevent Function
load Function
sleep_thread Function
sysctl_debug_sleep_test Function
unload Function
Don't Panic
Kernel Event Handlers
Callouts
Callouts and Race Conditions
Taskqueues
Global Taskqueues
Taskqueue Management Routines
Conclusion
6: Case Study: Virtual Null Modem
Prerequisites
Code Analysis
nmdm_modevent Function
nmdm_clone Function
nmdm_alloc Function
nmdm_outwakeup Function
nmdm_task_tty Function
nmdm_inwakeup Function
nmdm_modem Function
nmdm_param Function
nmdm_timeout Function
bits_per_char Function
Don't Panic
Conclusion
7: Newbus and Resource Allocation
Autoconfiguration and Newbus Drivers
device_foo Functions
Device Method Table
DRIVER_MODULE Macro
Tying Everything Together
foo_pci_probe Function
foo_pci_attach Function
d_foo Functions
foo_pci_detach Function
Don't Panic
Hardware Resource Management
Conclusion
8: Interrupt Handling
Registering an Interrupt Handler
Interrupt Handlers in FreeBSD
Implementing an Interrupt Handler
pint_identify Function
pint_probe Function
pint_attach Function
pint_detach Function
pint_open Function
pint_close Function
pint_write Function
pint_read Function
pint_intr Function
Don't Panic
Generating Interrupts on the Parallel Port
Conclusion
9: Case Study: Parallel Port Printer Driver
Code Analysis.
lpt_identify Function
lpt_probe Function
lpt_detect Function
lpt_port_test Function
lpt_attach Function
lpt_detach Function
lpt_open Function
lpt_read Function
lpt_write Function
lpt_intr Function
lpt_timeout Function
lpt_push_bytes Function
lpt_close Function
lpt_ioctl Function
lpt_request_ppbus Function
lpt_release_ppbus Function
Conclusion
10: Managing and Using Resources
I/O Ports and I/O Memory
Reading from I/O Ports and I/O Memory
Writing to I/O Ports and I/O Memory
Stream Operations
Memory Barriers
Tying Everything Together
led_identify Function
led_probe Function
led_attach Function
led_detach Function
led_open Function
led_close Function
led_read Function
led_write Function
Conclusion
11: Case Study: Intelligent Platform Management Interface Driver
Code Analysis
ipmi_pci_probe Function
ipmi_pci_match Function
ipmi_pci_attach Function
ipmi2_pci_probe Function
ipmi2_pci_attach Function
Conclusion
12: Direct Memory Access
Implementing DMA
Initiating a DMA Data Transfer
Dismantling DMA
Creating DMA Tags
Tearing Down DMA Tags
DMA Map Management Routines, Part 1
Loading (DMA) Buffers into DMA Maps
bus_dma_segment Structures
bus_dmamap_load Function
bus_dmamap_load_mbuf Function
bus_dmamap_load_mbuf_sg Function
bus_dmamap_load_uio Function
bus_dmamap_unload Function
DMA Map Management Routines, Part 2
A Straightforward Example
Synchronizing DMA Buffers
Conclusion
13: Storage Drivers
disk Structures
Descriptive Fields
Storage Device Methods
Mandatory Media Properties
Optional Media Properties
Driver Private Data
disk Structure Management Routines
Block I/O Structures
Block I/O Queues
Tying Everything Together
at45d_attach Function.
at45d_delayed_attach Function
at45d_get_info Function
at45d_wait_for_device_ready Function
at45d_get_status Function
at45d_strategy Function
at45d_task Function
Block I/O Completion Routines
Conclusion
14: Common Access Method
How CAM Works
A (Somewhat) Simple Example
mfip_attach Function
mfip_detach Function
mfip_action Function
mfip_poll Function
mfip_start Function
mfip_done Function
SIM Registration Routines
cam_simq_alloc Function
cam_sim_alloc Function
xpt_bus_register Function
Action Routines
XPT_PATH_INQ
XPT_RESET_BUS
XPT_GET_TRAN_SETTINGS
XPT_SET_TRAN_SETTINGS
XPT_SCSI_IO
XPT_RESET_DEV
Conclusion
15: USB Drivers
About USB Devices
More About USB Devices
USB Configuration Structures
Mandatory Fields
Optional Fields
USB Transfer Flags
USB Transfers (in FreeBSD)
USB Configuration Structure Management Routines
USB Methods Structure
Tying Everything Together
ulpt_probe Function
ulpt_attach Function
ulpt_detach Function
ulpt_open Function
ulpt_reset Function
unlpt_open Function
ulpt_close Function
ulpt_ioctl Function
ulpt_watchdog Function
ulpt_start_read Function
ulpt_stop_read Function
ulpt_start_write Function
ulpt_stop_write Function
ulpt_write_callback Function
ulpt_read_callback Function
ulpt_status_callback Function
Conclusion
16: Network Drivers, Part 1: Data Structures
Network Interface Structures
Network Interface Structure Management Routines
ether_ifattach Function
ether_ifdetach Function
Network Interface Media Structures
Network Interface Media Structure Management Routines
Hello, world!
mbuf Structures
Message Signaled Interrupts
Implementing MSI
MSI Management Routines
Conclusion.
17: Network Drivers, Part 2: Packet Reception and Transmission
Packet Reception
em_rxeof Function
em_handle_rx Function
Packet Transmission
em_start_locked Function
em_txeof Function
Post Packet Transmission
Conclusion
References
Index.
Notes:
Description based on publisher supplied metadata and other sources.
Local notes:
Electronic reproduction. Ann Arbor, Michigan : ProQuest Ebook Central, 2021. Available via World Wide Web. Access may be limited to ProQuest Ebook Central affiliated libraries.
Other format:
Print version: Kong, Joseph FreeBSD Device Drivers
ISBN:
9781593274368
9781593272043
OCLC:
830164433