1.\" $NetBSD: intro.9,v 1.23 2018/07/15 05:16:41 maxv Exp $ 2.\" 3.\" Copyright (c) 1997, 2007 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Jeremy Cooper, and Mindaugas Rasiukevicius. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE 22.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28.\" POSSIBILITY OF SUCH DAMAGE. 29.\" 30.Dd July 14, 2018 31.Dt INTRO 9 32.Os 33.Sh NAME 34.Nm intro 35.Nd introduction to kernel internals 36.Sh DESCRIPTION 37This section contains information related to the internal operation of the 38system kernel. 39It describes function interfaces and variables of use to the systems and device 40driver programmer. 41.Pp 42In addition to the normal man page format, the kernel pages include an 43additional section: 44.Bl -tag -width "CODE REFERENCES" 45.It "CODE REFERENCES" 46Contains the pathname(s) of the source file(s) which contain the definition 47and/or source code of the variables or functions being documented. 48Any paths are relative to the top level of the source tree (traditionally 49.Pa /usr/src ) . 50.El 51.Sh MEMORY MANAGEMENT 52Introduction to kernel memory allocators. 53See 54.Xr memoryallocators 9 . 55.Pp 56Machine-dependent portion of the virtual memory system. 57See 58.Xr pmap 9 . 59.Pp 60Virtual memory system external interface. 61See 62.Xr uvm 9 . 63.Sh I/O SUBSYSTEM 64Buffer cache interfaces. 65See 66.Xr buffercache 9 . 67.Pp 68Device buffer queues. 69See 70.Xr bufq 9 . 71.Pp 72Initiate I/O on raw devices. 73See 74.Xr physio 9 . 75.Pp 76I/O descriptor allocation interface. 77See 78.Xr getiobuf 9 . 79.Sh PROCESS CONTROL 80Idle CPU while waiting for work. 81See 82.Xr cpu_idle 9 . 83.Pp 84Finish a fork operation. 85See 86.Xr cpu_lwp_fork 9 . 87.Pp 88Switch to another light weight process. 89See 90.Xr mi_switch 9 . 91.Pp 92Current process and processor. 93See 94.Xr curproc 9 . 95.Pp 96Set process uid and gid. 97See 98.Xr do_setresuid 9 . 99.Pp 100New processes and kernel threads. 101See 102.Xr fork1 9 , 103.Xr kthread 9 . 104.Pp 105Context switch notification. 106See 107.Xr cpu_need_resched 9 . 108.Pp 109Common scheduler framework. 110See 111.Xr csf 9 . 112.Pp 113Software signal facilities. 114See 115.Xr signal 9 . 116.Pp 117Suspend the scheduler. 118See 119.Xr suspendsched 9 . 120.Pp 121Return path to user-mode execution. 122See 123.Xr userret 9 . 124.Sh FILE SYSTEM 125High-level file operations. 126See 127.Xr dofileread 9 . 128.Pp 129Convert an extended attribute namespace identifier to a string and 130vice versa. 131See 132.Xr extattr 9 . 133.Pp 134Operations on file entries. 135See 136.Xr file 9 . 137.Pp 138In-kernel, file system independent, file-meta data association. 139See 140.Xr fileassoc 9 . 141.Pp 142File descriptor tables and operations. 143See 144.Xr filedesc 9 . 145.Pp 146File descriptor owner handling functions. 147See 148.Xr fsetown 9 . 149.Pp 150File system suspension helper subsystem. 151See 152.Xr fstrans 9 . 153.Pp 154Pathname lookup, cache and management. 155See 156.Xr namei 9 , 157.Xr namecache 9 . 158.Pp 159Kernel interface to file systems. 160See 161.Xr vfs 9 . 162.Pp 163Kernel representation of a file or directory and vnode attributes. 164See 165.Xr vnode 9 , 166.Xr vattr 9 . 167.Sh NETWORKING 168Kernel interfaces for manipulating output queues on network interfaces. 169See 170.Xr altq 9 . 171.Pp 172Externally visible ARP functions. 173See 174.Xr arp 9 . 175.Pp 176Ethernet and FDDI driver support functions and macros. 177See 178.Xr ethersubr 9 . 179.Pp 180Core 802.11 network stack functions and rate adaptation based on 181received signal strength. 182See 183.Xr ieee80211 9 , 184.Xr rssadapt 9 . 185.Pp 186Compute Internet checksum. 187See 188.Xr in_cksum 9 . 189.Pp 190Look up the IPv4 source address best matching an IPv4 destination. 191See 192.Xr in_getifa 9 . 193.Pp 194Functions and macros for managing memory used by networking code. 195See 196.Xr mbuf 9 . 197.Pp 198Packet filter interface. 199See 200.Xr pfil 9 . 201.Pp 202Route callout functions. 203See 204.Xr rt_timer 9 . 205.Pp 206TCP congestion control API. 207See 208.Xr tcp_congctl 9 . 209.Sh LOCKING AND INTERRUPT CONTROL 210See 211.Xr locking 9 212for an overview. 213.Pp 214Condition variables. 215See 216.Xr condvar 9 . 217.Pp 218Kernel lock functions. 219See 220.Xr lock 9 . 221.Pp 222Memory barriers. 223See 224.Xr membar_ops 3 . 225.Pp 226Mutual exclusion primitives. 227See 228.Xr mutex 9 . 229.Pp 230Restartable atomic sequences. 231See 232.Xr ras 9 . 233.Pp 234Reader / writer lock primitives. 235See 236.Xr rwlock 9 . 237.Pp 238Machine-independent software interrupt framework. 239See 240.Xr softint 9 . 241.Pp 242Functions to modify system interrupt priority level. 243See 244.Xr spl 9 . 245.Pp 246Functions to raise the system priority level. 247See 248.Xr splraiseipl 9 . 249.Sh SECURITY 250Kernel authorization framework. 251See 252.Xr kauth 9 . 253.Pp 254API for cryptographic services in the kernel. 255See 256.Xr opencrypto 9 . 257.Pp 258Security model development guidelines. 259See 260.Xr secmodel 9 . 261.Sh SYSTEM TIME CONTROL 262Execute a function after a specified length of time. 263See 264.Xr callout 9 . 265.Pp 266Microsecond delay. 267See 268.Xr delay 9 . 269.Pp 270Real-time timer. 271See 272.Xr hardclock 9 . 273.Pp 274System clock frequency. 275See 276.Xr hz 9 . 277.Pp 278Initialization of system time and time-of-day clock support. 279See 280.Xr inittodr 9 , 281.Xr todr 9 . 282.Pp 283Check that a timeval value is valid, and correct. 284See 285.Xr itimerfix 9 . 286.Pp 287System time variables. 288See 289.Xr timecounter 9 . 290.Pp 291Realtime system clock. 292See 293.Xr microtime 9 . 294.Pp 295Get the time elapsed since boot. 296See 297.Xr microuptime 9 . 298.Pp 299Convert milliseconds to system clock ticks. 300See 301.Xr mstohz 9 . 302.Pp 303Function to help implement rate-limited actions. 304See 305.Xr ppsratecheck 9 . 306.Pp 307Function to help implement rate-limited actions. 308See 309.Xr ratecheck 9 . 310.Pp 311Set battery-backed clock from system time. 312See 313.Xr resettodr 9 . 314.Pp 315System time variables. 316See 317.Xr time_second 9 . 318.Sh KERNEL AND USER SPACE DATA COPY FUNCTIONS 319Kernel space to/from user space copy functions. 320See 321.Xr copy 9 . 322.Pp 323Store data to user-space. 324See 325.Xr store 9 . 326.Pp 327Fetch data from user-space. 328See 329.Xr fetch 9 . 330.Pp 331Move data described by a struct uio. 332See 333.Xr uiomove 9 . 334.Sh MACHINE DEPENDENT KERNEL FUNCTIONS 335Machine-dependent clock setup interface. 336See 337.Xr cpu_initclocks 9 . 338.Pp 339Machine-dependent process core dump interface. 340See 341.Xr cpu_coredump 9 . 342.Pp 343Machine-dependent kernel core dumps. 344See 345.Xr cpu_dumpconf 9 . 346.Pp 347Unique CPU identification number 348See 349.Xr cpu_number 9 . 350.Pp 351Halt or reboot the system 352See 353.Xr cpu_reboot 9 . 354.Pp 355Machine-dependent root file system setup 356See 357.Xr cpu_rootconf 9 . 358.Pp 359Machine-dependent CPU startup 360See 361.Xr cpu_startup 9 . 362.Pp 363Disk label management routines. 364See 365.Xr disklabel 9 . 366.Sh DEVICE CONFIGURATION 367Autoconfiguration frame-work. 368See 369.Xr autoconf 9 . 370.Pp 371Description of a device driver. 372See 373.Xr driver 9 . 374.Pp 375The autoconfiguration framework ``device definition'' language. 376See 377.Xr config 9 . 378.Pp 379Machine-dependent device autoconfiguration. 380See 381.Xr cpu_configure 9 . 382.Sh MI DEVICE DRIVER API 383Bus and Machine Independent DMA Mapping Interface. 384See 385.Xr bus_dma 9 . 386.Pp 387Bus space manipulation functions. 388See 389.Xr bus_space 9 . 390.Pp 391Generic disk framework. 392See 393.Xr disk 9 . 394.Pp 395Hardware-assisted data mover interface. 396See 397.Xr dmover 9 . 398Generic event counter framework. 399See 400.Xr evcnt 9 . 401.Pp 402Firmware loader API for device drivers. 403See 404.Xr firmload 9 . 405.Pp 406How to implement a new ioctl call to access device drivers. 407See 408.Xr ioctl 9 . 409.Pp 410Extensible line discipline framework. 411See 412.Xr linedisc 9 . 413.Sh CONSOLE DEVICES 414Console magic key sequence management. 415See 416.Xr cnmagic 9 . 417.Pp 418Console access interface. 419See 420.Xr cons 9 . 421.Pp 422Raster display operations. 423See 424.Xr rasops 9 . 425.Pp 426Generic virtual console framework. 427See 428.Xr vcons 9 . 429.Pp 430Machine-independent console support. 431See 432.Xr wscons 9 . 433.Sh DEVICE SPECIFIC IMPLEMENTATION 434Interface between low and high level audio drivers. 435See 436.Xr audio 9 . 437.Pp 438The 439.Nx audio specification. 440See 441.Xr audio_system 9 . 442.Pp 443Bluetooth Device/Protocol API. 444See 445.Xr bluetooth 9 . 446.Pp 447Support for CardBus PC-Card devices. 448See 449.Xr cardbus 9 . 450.Pp 451VESA Display Data Channel V2. 452See 453.Xr ddc 9 . 454.Pp 455VESA Extended Display Identification Data. 456See 457.Xr edid 9 . 458.Pp 459Inter IC (I2C) bus. 460See 461.Xr iic 9 . 462.Pp 463Baseboard I/O control ASIC for DEC TURBOchannel systems. 464See 465.Xr ioasic 9 . 466.Pp 467Industry-standard Architecture. 468See 469.Xr isa 9 . 470.Pp 471Introduction to ISA Plug-and-Play support. 472See 473.Xr isapnp 9 . 474.Pp 475MicroChannel Architecture bus. 476See 477.Xr mca 9 . 478.Pp 479PPBUS microseqencer developer's guide. 480See 481.Xr microseq 9 . 482.Pp 483Peripheral Component Interconnect. 484See 485.Xr pci 9 . 486.Pp 487Perform PCI bus configuration. 488See 489.Xr pci_configure_bus 9 . 490.Pp 491PCI bus interrupt manipulation functions. 492See 493.Xr pci_intr 9 . 494.Pp 495PC keyboard port interface. 496See 497.Xr pckbport 9 . 498.Pp 499Support for PCMCIA PC-Card devices. 500See 501.Xr pcmcia 9 . 502.Pp 503User-space interface to ppbus parallel port. 504See 505.Xr ppi 9 . 506.Pp 507Interface between low and high level radio drivers. 508See 509.Xr radio 9 . 510.Pp 511Functions to make a device available for entropy collection. 512See 513.Xr rnd 9 . 514.Pp 515SCSI/ATAPI middle-layer interface. 516See 517.Xr scsipi 9 . 518.Pp 519TURBOchannel bus. 520See 521.Xr tc 9 . 522.Pp 523USB tty support. 524See 525.Xr ucom 9 . 526.Pp 527USB device drivers interface. 528See 529.Xr usbdi 9 . 530.Pp 531Versa Module Euroboard bus. 532See 533.Xr vme 9 . 534.Pp 535Machine-independent IDE/ATAPI driver. 536See 537.Xr wdc 9 . 538.Sh KERNEL EVENT 539Functions to add or remove kernel event filters. 540See 541.Xr kfilter_register 9 . 542.Pp 543Functions to raise kernel event. 544See 545.Xr knote 9 . 546.Pp 547Record and wakeup select requests. 548See 549.Xr selrecord 9 . 550.Pp 551Simple do-it-in-thread-context framework. 552See 553.Xr workqueue 9 . 554.Sh KERNEL HELPER FUNCTIONS 555Kernel expression verification macros. 556See 557.Xr KASSERT 9 . 558.Pp 559Convert a single byte between (unsigned) packed bcd and binary. 560See 561.Xr bcdtobin 9 . 562.Pp 563Bitmask output conversion. 564See 565.Xr snprintb 3 . 566.Pp 567General purpose extent manager. 568See 569.Xr extent 9 . 570.Pp 571Compare integers. 572See 573.Xr imax 9 . 574.Pp 575Kernel formatted output conversion. 576See 577.Xr kprintf 9 . 578.Pp 579Data comparing, moving, copying, setting and cleaning. 580See 581.Xr memcmp 9 , 582.Xr memmove 9 , 583.Xr memcpy 9 , 584.Xr memset 9 , 585.Xr bcmp 9 , 586.Xr bcopy 9 , 587.Xr bzero 9 , 588.Xr kcopy 9 . 589.Pp 590Log a message from the kernel through the /dev/klog device. 591See 592.Xr log 9 . 593.Pp 594Bring down system on fatal error. 595See 596.Xr panic 9 . 597.Sh MISC 598Power management and inter-driver messaging. 599See 600.Xr pmf 9 . 601.Pp 602Run all shutdown hooks. 603See 604.Xr pmf_system_shutdown 9 . 605.Pp 606Kernel internal error numbers. 607See 608.Xr errno 9 . 609.Pp 610Kernel hash functions, hash table construction and destruction. 611See 612.Xr hash 9 , 613.Xr hashinit 9 . 614.Pp 615Format a number into a human readable form. 616See 617.Xr humanize_number 9 . 618.Pp 619Options string management. 620See 621.Xr optstr 9 . 622.Pp 623Performs pattern matching on strings. 624See 625.Xr pmatch 9 . 626.Pp 627Add or remove a shutdown hook. 628See 629.Xr pmf 9 . 630.Pp 631Non-local jumps. 632See 633.Xr setjmp 9 . 634.Pp 635System variable control interfaces. 636See 637.Xr sysctl 9 . 638.Sh HISTORY 639The 640.Nx 641kernel internals section first appeared in 642.Nx 1.2 . 643