OS X and iOS Kernel Programming

Book description

OS X and iOS Kernel Programming combines essential operating system and kernel architecture knowledge with a highly practical approach that will help you write effective kernel-level code. You'll learn fundamental concepts such as memory management and thread synchronization, as well as the I/O Kit framework. You'll also learn how to write your own kernel-level extensions, such as device drivers for USB and Thunderbolt devices, including networking, storage and audio drivers.

OS X and iOS Kernel Programming provides an incisive and complete introduction to the XNU kernel, which runs iPhones, iPads, iPods, and Mac OS X servers and clients. Then, you'll expand your horizons to examine Mac OS X and iOS system architecture. Understanding Apple's operating systems will allow you to write efficient device drivers, such as those covered in the book, using I/O Kit.

With OS X and iOS Kernel Programming, you'll:

  • Discover classical kernel architecture topics such as memory management and thread synchronization

  • Become well-versed in the intricacies of the kernel development process by applying kernel debugging and profiling tools

  • Learn how to deploy your kernel-level projects and how to successfully package them

  • Write code that interacts with hardware devices

  • Examine easy to understand example code that can also be used in your own projects

  • Create network filters

Whether you're a hobbyist, student, or professional engineer, turn to OS X andiOS Kernel Programming and find the knowledge you need to start developing

What you'll learn

  • OS X and iOS common core architecture

  • How to write extremely efficient code by exploiting kernel details

  • Coding kernel-level extensions

  • How to write device drivers

  • How to program the I/O Kit framework

  • Key mobile device topics like power management drivers and video capture modules

  • To understand OS X memory management and threads

  • To parse kernel debug messages and package projects ready for deployment

Who this book is for

This book is suited for:

  • Intermediate and advanced iPhone and OS X programmers ready for the next step

  • Kernel-level programmers interested in how OS X and iOS function

  • Open source programmers with a background in Linux or BSD, OS X and iOS

  • Programmers interested in application performance

  • System administrators running OS X clusters

Table of contents

  1. Title
  2. Dedication
  3. Contents at a Glance
  4. Contents
  5. About the Authors
  6. About the Technical Reviewers
  7. Acknowledgments
  8. Introduction
  9. Chapter 1: Operating System Fundamentals
    1. The Role of the Operating System
    2. Process Management
    3. Process Address Spaces
    4. Operating System Services
    5. Virtual Memory
    6. Scheduling
    7. Hardware and Drivers
    8. Summary
  10. Chapter 2: Mac OS X and iOS
    1. The XNU Kernel
    2. Summary
  11. Chapter 3: Xcode and the Kernel Development Environment
    1. Summary
  12. Chapter 4: The I/O Kit Framework
    1. The I/O Kit Model
    2. Object Relationship
    3. The Info.plist File
    4. The Kernel Library: libkern
    5. Summary
  13. Chapter 5: Interacting with Drivers from Applications
    1. The I/O Kit Framework
    2. Finding a Driver
    3. Observing Device Removal
    4. Modifying Driver Properties
    5. State-Based Interaction
    6. Notifications from the Driver
    7. Summary
  14. Chapter 6: Memory Management
    1. Types of Memory
    2. Memory Allocation
    3. Memory Descriptors
    4. Mapping Memory
    5. Summary
  15. Chapter 7: Synchronization and Threading
    1. Synchronization Primitives
    2. Atomic Operations
    3. Locking
    4. Synchronizing Asynchronous Events: Work Loops
    5. Kernel Threads
    6. Summary
  16. Chapter 8: Universal Serial Bus
    1. USB Architecture
    2. I/O Kit USB Support
    3. Summary
  17. Chapter 9: PCI Express and Thunderbolt
    1. PCI in I/O Kit
    2. Interrupts
    3. Direct Memory Access
    4. Summary
  18. Chapter 10: Power Management
    1. Responding to Power State Changes
    2. Requesting Power State Changes
    3. Handling Device Idle
    4. Observing Device Power State Changes
    5. Putting It All Together
    6. Summary
  19. Chapter 11: Serial Port Drivers
    1. Mac OS X Serial Port Architecture Overview
    2. Serial Port Drivers
    3. Implementing the IOSerialDriverSync Class
    4. Serial Port State
    5. Serial Port Events
    6. Serial Data Transfer
    7. Accessing a Serial Port from User Space
    8. Summary
  20. Chapter 12: Audio Drivers
    1. An Introduction to Digital Audio and Audio Devices
    2. Core Audio
    3. I/O Kit Audio Support
    4. Implementing an Audio Driver
    5. Summary
  21. Chapter 13: Networking
    1. Network Kernel Extensions
    2. Debugging and Testing Network Extensions
    3. Networking in the I/O Kit
    4. Summary
  22. Chapter 14: Storage Systems
    1. Transport Layer Drivers
    2. The IOBlockStorageDevice Interface
    3. Building a RAM Disk Device
    4. Partition Schemes
    5. Media Filter Drivers
    6. Summary
  23. Chapter 15: User-Space USB Drivers
    1. Behind the Scenes
    2. The IOUSBLib Framework
    3. Handling Asynchronous Operations
    4. The IOUSBDeviceInterface Class
    5. The IOUSBInterfaceInterface Class
    6. Summary
  24. Chapter 16: Debugging
    1. Common Types of Problems
    2. Kernel Panics
    3. Debugging Mechanisms
    4. Summary
  25. Chapter 17: Advanced Kernel Programming
    1. SSE and Floating Point in the Kernel
    2. Multi-Function Drivers
    3. Writing I/O Kit Families
    4. Kernel Control KPI
    5. Working with Processes in the Kernel
    6. Loading Resources
    7. Beyond KEXT Resources
    8. Notifications from Kernel Drivers
    9. Summary
  26. Chapter 18: Deployment
    1. Installing and Loading Kernel Extensions
    2. Loading Preferences and Settings
    3. Versioning Kernel Extensions
    4. Testing and Quality Assurance
    5. Packaging KEXTs and Software
    6. Summary
  27. Index

Product information

  • Title: OS X and iOS Kernel Programming
  • Author(s):
  • Release date: December 2011
  • Publisher(s): Apress
  • ISBN: 9781430235361