INTRODUCTION
xviii
Book Structure
The following is a brief description of each chapter in this book:
Chapter 1, Operating System Fundamentals. Details the functionality of an operating system and
its role in managing the computer’s hardware resources. We describe the purpose of device drivers and
when they are needed, and introduce the differences between programming in the kernel environment
as compared to standard application development.
Chapter 2, Mac OS X and iOS. Provides a brief overview of the technical structure of XNU, the kernel
used by Mac OS X and iOS.
Chapter 3, Xcode and the Kernel Development Environment. Provides an overview of the
development tools provided by Apple for Mac OS X and iOS development. The chapter ends with a short
“Hello world” kernel extension.
Chapter 4, The I/O Kit Framework. Introduces the I/O Kit framework that provides the driver model
for Mac OS X and its object-oriented architecture. We explain how the I/O Kit finds the appropriate
device driver to manage a hardware device. We demonstrate a generic device driver to illustrate the basic
structure of any I/O Kit driver.
Chapter 5, Interacting with Drivers from Applications. Explains how application code can access a
kernel driver. We demonstrate how to search and match against a specific driver as well as how to install
a notification to wait for the arrival of a driver or a particular device. We will show how an application
can send commands to a driver and watch for events sent by the driver.
Chapter 6, Memory Management. Provides an overview of kernel memory management and the
different types of memory that a driver needs to work with. We describe the differences between physical
and kernel virtual addresses and user-space memory. We also introduce the reader to the concepts such
as memory descriptors and memory mapping.
Chapter 7, Synchronization and Threading. Describes the fundamentals of synchronization and
why it is a necessity for every kernel driver. We discuss the usage of kernel locking mechanisms such as
IOLock and IOCommandGate and their appropriate use. We explain how a typical driver requires
synchronization between its own threads, user-space threads, and hardware interrupts. We discuss the
kernel facilities for creating kernel threads and asynchronous timers.
Chapter 8, USB Drivers. Introduces the reader to the architecture of USB and how a driver
interfaces with them. We provide an overview of the I/O Kit USB API and the classes it provides for
enumerating devices and transferring data to or from a USB device. We also discuss steps needed to
support device removal and provide an example to show how a driver can enumerate resources such as
pipes.
Chapter 9, PCI and Thunderbolt. Provides an overview of the PCI architecture. We also describe the
concepts that are unique to PCI drivers, such as memory-mapped I/O, high-speed data transfer through
Direct Memory Access (DMA), and handling of device interrupts. We give an overview of the IOPCIDevice
class that the I/O Kit provides for accessing and configuring PCI devices. We also discuss the related and
more recent Thunderbolt technology.
Chapter 10, Power Management. Describes the methods that drivers need to implement in order to
allow the system to enter low power states such as machine sleep. We also describe advanced power
management that a driver can implement if it wishes to place its hardware into a low power state after a
period of inactivity.
Chapter 11, Serial Port Drivers. Describes how to implement a serial port driver on Mac OS X. We
introduce relevant data structures such as circular queues and techniques for managing data flow
through blocking I/O and notification events. We show how a user application can enumerate and
access a serial port driver.
www.allitebooks.com