FreeBSD Architecture Handbook

The FreeBSD Documentation Project

Welcome to the FreeBSD Architecture Handbook. This manual is a work in progress and is the work of many individuals. Many sections do not yet exist and some of those that do exist need to be updated. If you are interested in helping with this project, send email to the FreeBSD documentation project mailing list.

The latest version of this document is always available from the FreeBSD World Wide Web server. It may also be downloaded in a variety of formats and compression options from the FreeBSD FTP server or one of the numerous mirror sites.


Table of Contents
I. Kernel
1 Bootstrapping and Kernel Initialization
1.1 Synopsis
1.2 Overview
1.3 BIOS POST
1.4 boot0 Stage
1.5 boot2 Stage
1.6 loader Stage
1.7 Kernel Initialization
2 Locking Notes
2.1 Mutexes
2.2 Shared Exclusive Locks
2.3 Atomically Protected Variables
3 Kernel Objects
3.1 Terminology
3.2 Kobj Operation
3.3 Using Kobj
4 The Jail Subsystem
4.1 Architecture
4.2 Restrictions
5 The SYSINIT Framework
5.1 Terminology
5.2 SYSINIT Operation
5.3 Using SYSINIT
6 The TrustedBSD MAC Framework
6.1 MAC Documentation Copyright
6.2 Synopsis
6.3 Introduction
6.4 Policy Background
6.5 MAC Framework Kernel Architecture
6.6 MAC Policy Architecture
6.7 MAC Policy Entry Point Reference
6.8 Userland Architecture
6.9 Conclusion
7 Virtual Memory System
7.1 Management of Physical Memory—vm_page_t
7.2 The Unified Buffer Cache—vm_object_t
7.3 Filesystem I/O—struct buf
7.4 Mapping Page Tables—vm_map_t, vm_entry_t
7.5 KVM Memory Mapping
7.6 Tuning the FreeBSD VM System
8 SMPng Design Document
8.1 Introduction
8.2 Basic Tools and Locking Fundamentals
8.3 General Architecture and Design
8.4 Specific Locking Strategies
8.5 Implementation Notes
8.6 Miscellaneous Topics
Glossary
II. Device Drivers
9 Writing FreeBSD Device Drivers
9.1 Introduction
9.2 Dynamic Kernel Linker Facility - KLD
9.3 Character Devices
9.4 Block Devices (Are Gone)
9.5 Network Drivers
10 ISA Device Drivers
10.1 Synopsis
10.2 Basic Information
10.3 device_t Pointer
10.4 Configuration File and the Order of Identifying and Probing During Auto-Configuration
10.5 Resources
10.6 Bus Memory Mapping
10.7 DMA
10.8 xxx_isa_probe
10.9 xxx_isa_attach
10.10 xxx_isa_detach
10.11 xxx_isa_shutdown
10.12 xxx_intr
11 PCI Devices
11.1 Probe and Attach
11.2 Bus Resources
12 Common Access Method SCSI Controllers
12.1 Synopsis
12.2 General Architecture
12.3 Polling
12.4 Asynchronous Events
12.5 Interrupts
12.6 Errors Summary
12.7 Timeout Handling
13 USB Devices
13.1 Introduction
13.2 Host Controllers
13.3 USB Device Information
13.4 Device Probe and Attach
13.5 USB Drivers Protocol Information
14 Newbus
14.1 Device Drivers
14.2 Overview of Newbus
14.3 Newbus API
15 Sound Subsystem
15.1 Introduction
15.2 Files
15.3 Probing, Attaching, etc.
15.4 Interfaces
16 PC Card
16.1 Adding a Device
III. Appendices
Bibliography
Index
List of Tables
2-1. Mutex List
2-2. Shared Exclusive Lock List
List of Figures
14-1. driver_t Implementation
14-2. Device States device_state_t
List of Examples
5-1. Example of a SYSINIT()
5-2. Example of Adjusting SYSINIT() Order
5-3. Example of a SYSUNINIT()
9-1. Example of a Sample Echo Pseudo-Device Driver for FreeBSD 10.X
14-1. Newbus Methods