1*f17620a4SRobert Mustacchi.\" 2*f17620a4SRobert Mustacchi.\" This file and its contents are supplied under the terms of the 3*f17620a4SRobert Mustacchi.\" Common Development and Distribution License ("CDDL"), version 1.0. 4*f17620a4SRobert Mustacchi.\" You may only use this file in accordance with the terms of version 5*f17620a4SRobert Mustacchi.\" 1.0 of the CDDL. 6*f17620a4SRobert Mustacchi.\" 7*f17620a4SRobert Mustacchi.\" A full copy of the text of the CDDL should have accompanied this 8*f17620a4SRobert Mustacchi.\" source. A copy of the CDDL is also available via the Internet at 9*f17620a4SRobert Mustacchi.\" http://www.illumos.org/license/CDDL. 10*f17620a4SRobert Mustacchi.\" 11*f17620a4SRobert Mustacchi.\" 12*f17620a4SRobert Mustacchi.\" Copyright 2024 Oxide Computer Company 13*f17620a4SRobert Mustacchi.\" 14*f17620a4SRobert Mustacchi.Dd April 28, 2024 155a342f14SRichard Lowe.Dt INTRO 9 165a342f14SRichard Lowe.Os 175a342f14SRichard Lowe.Sh NAME 18*f17620a4SRobert Mustacchi.Nm Intro 19*f17620a4SRobert Mustacchi.Nd introduction to kernel concepts, device drivers, functions, and structures 205a342f14SRichard Lowe.Sh DESCRIPTION 21*f17620a4SRobert MustacchiSection 9 of the manual is documentation for concepts in the broader kernel, 22*f17620a4SRobert Mustacchiincluding writing device drivers. 23*f17620a4SRobert MustacchiThe manual is organized into different sections, each of which focuses on a 24*f17620a4SRobert Mustacchiparticular area such as chapter 9E which covers device driver entry points. 25*f17620a4SRobert MustacchiThe following chapters of section 9 exist: 265a342f14SRichard Lowe.Bl -tag -width Ds 27*f17620a4SRobert Mustacchi.It Section 9 28*f17620a4SRobert MustacchiThe base section 9 29*f17620a4SRobert Mustacchi.Pq no chapter suffix 30*f17620a4SRobert Mustacchicontains various high-level concepts about the kernel. 31*f17620a4SRobert MustacchiIn addition to this page, there are manuals that cover: 32*f17620a4SRobert Mustacchi.Bl -tag -width Ds 33*f17620a4SRobert Mustacchi.It iports, phymaps, and tgtmaps 34*f17620a4SRobert Mustacchi.Xr iport 9 35*f17620a4SRobert Mustacchidiscusses the design of abstractions that are used for host bus adapter 36*f17620a4SRobert Mustacchi.Pq HBA 37*f17620a4SRobert Mustacchidrivers to aid in the enumeration of devices. 38*f17620a4SRobert Mustacchi.It vmem 39*f17620a4SRobert Mustacchi.Xr vmem 9 40*f17620a4SRobert Mustacchidiscusses the design of the virtual memory allocator that is used throughout the 41*f17620a4SRobert Mustacchisystem. 425a342f14SRichard Lowe.El 43*f17620a4SRobert Mustacchi.It Section 9E 44*f17620a4SRobert MustacchiSection 9E, driver entry points, describes the interfaces that a loadable kernel 45*f17620a4SRobert Mustacchimodule and device driver need to implement to interface with the broader kernel. 46*f17620a4SRobert MustacchiThere are discussions of specific frameworks for different classes of drivers, 47*f17620a4SRobert Mustacchisuch as 48*f17620a4SRobert Mustacchi.Xr mac 9E 49*f17620a4SRobert Mustacchifor networking device drivers, discussions of specific functions that a given 50*f17620a4SRobert Mustacchidevice might implement like 51*f17620a4SRobert Mustacchi.Xr open 9E 52*f17620a4SRobert Mustacchiwhich correspond to performing a traditional operation on the device, and 53*f17620a4SRobert Mustacchirequired entry points for all modules like 54*f17620a4SRobert Mustacchi.Xr _init 9E . 55*f17620a4SRobert Mustacchi.Pp 56*f17620a4SRobert Mustacchi.Xr Intro 9E 57*f17620a4SRobert Mustacchiprovides an overview of loadable kernel modules, device drivers, and which 58*f17620a4SRobert Mustacchifunction families are used for which types of devices. 59*f17620a4SRobert Mustacchi.It Section 9F 60*f17620a4SRobert MustacchiSection 9F, kernel functions, describes the various kernel functions that are 61*f17620a4SRobert Mustacchiavailable. 62*f17620a4SRobert MustacchiThe majority of these functions are part of the device driver interface and have 63*f17620a4SRobert MustacchiAPI and ABI guarantees associated with them. 64*f17620a4SRobert MustacchiEntry points run the gamut from dealing with memory allocation, to common data 65*f17620a4SRobert Mustacchistructures, to device driver frameworks 66*f17620a4SRobert Mustacchi.Pq e.g. functions specific to Networking, USB, SCSI, etc. drivers , 67*f17620a4SRobert Mustacchito common C functions around strings, atomics, and memory copying. 68*f17620a4SRobert Mustacchi.Pp 69*f17620a4SRobert Mustacchi.Xr Intro 9F 70*f17620a4SRobert Mustacchidiscusses the different groups of functions that are available and how they are 71*f17620a4SRobert Mustacchioften used. 72*f17620a4SRobert Mustacchi.It Section 9P 73*f17620a4SRobert MustacchiSection 9P, properties, are used to document various properties that a device 74*f17620a4SRobert Mustacchidriver may set on themselves. 75*f17620a4SRobert MustacchiThese properties are generally used in tandem with a driver's 76*f17620a4SRobert Mustacchi.Xr driver.conf 5 77*f17620a4SRobert Mustacchior set while the driver is executing. 78*f17620a4SRobert Mustacchi.It Section 9S 79*f17620a4SRobert MustacchiSection 9S, structures, describes various structures that are filled out, their 80*f17620a4SRobert Mustacchimembers, and their meanings that are used throughout the kernel. 81*f17620a4SRobert MustacchiThis includes various types like the 82*f17620a4SRobert Mustacchi.Vt mblk_t 83*f17620a4SRobert Mustacchiwhich is used to transfer data in the networking and USB stacks, the 84*f17620a4SRobert Mustacchi.Vt uio_t 85*f17620a4SRobert Mustacchiwhich is used to describe an I/O request, and the 86*f17620a4SRobert Mustacchi.Vt cb_ops 87*f17620a4SRobert Mustacchiwhich all character device drivers fill out to indicate which operations they 88*f17620a4SRobert Mustacchisupport. 89*f17620a4SRobert Mustacchi.Pp 90*f17620a4SRobert Mustacchi.Xr Intro 9S 91*f17620a4SRobert Mustacchidescribes the organization of the different structure types that exist. 92*f17620a4SRobert MustacchiIf exploring a subsystem, it is generally better to start with the corresponding 93*f17620a4SRobert Mustacchi9E and 9F discussions which often have more context for how these structures are 94*f17620a4SRobert Mustacchiused. 95*f17620a4SRobert Mustacchi.El 96*f17620a4SRobert Mustacchi.Pp 97*f17620a4SRobert MustacchiThroughout the manuals you may see reference to the term 98*f17620a4SRobert Mustacchi.Dq DDI 99*f17620a4SRobert Mustacchiwhich is the Device Driver Interface, which represents the committed interfaces 100*f17620a4SRobert Mustacchithat the operating system exports for such purposes. 101*f17620a4SRobert MustacchiNote, not everything documented is classified as a committed interface. 102*f17620a4SRobert MustacchiSome uncommitted interfaces are documented to aid developers. 103*f17620a4SRobert MustacchiIn addition to these manuals, there is additional documentation in the form of 104*f17620a4SRobert Mustacchivarious books available at 105*f17620a4SRobert Mustacchi.Lk https://illumos.org/books . 106*f17620a4SRobert MustacchiIn particular, the following books can be useful for writing software and 107*f17620a4SRobert Mustacchidebugging: 108*f17620a4SRobert Mustacchi.Bl -tag -width Ds 109*f17620a4SRobert Mustacchi.It Dynamic Tracing Guide 110*f17620a4SRobert MustacchiThis introduces and discusses how to use DTrace, the dynamic tracing facility 111*f17620a4SRobert Mustacchibuilt into the operating system. 112*f17620a4SRobert MustacchiDTrace is used with the 113*f17620a4SRobert Mustacchi.Xr dtrace 8 114*f17620a4SRobert Mustacchiutility. 115*f17620a4SRobert Mustacchi.It Modular Debugger Guide 116*f17620a4SRobert MustacchiThis introduces and discusses how to use the modular debugger, which provides 117*f17620a4SRobert Mustacchithe ability to debug not only user processes, but both the kernel and crash 118*f17620a4SRobert Mustacchidumps. 119*f17620a4SRobert MustacchiTo start debugging the kernel, use the 120*f17620a4SRobert Mustacchi.Fl k 121*f17620a4SRobert Mustacchiflag to 122*f17620a4SRobert Mustacchi.Xr mdb 1 . 123*f17620a4SRobert Mustacchi.It Writing Device Drivers 124*f17620a4SRobert MustacchiThis introduces how to write device drivers in the system and provides 125*f17620a4SRobert Mustacchiadditional background and more guided tours of various types of devices and 126*f17620a4SRobert Mustacchiconcepts such as DMA allocation. 127*f17620a4SRobert Mustacchi.El 128*f17620a4SRobert Mustacchi.Sh SEE ALSO 129*f17620a4SRobert Mustacchi.Xr iport 9 , 130*f17620a4SRobert Mustacchi.Xr vmem 9 , 131*f17620a4SRobert Mustacchi.Xr Intro 9E , 132*f17620a4SRobert Mustacchi.Xr Intro 9F , 133*f17620a4SRobert Mustacchi.Xr Intro 9P , 134*f17620a4SRobert Mustacchi.Xr Intro 9S 135