1.\" $NetBSD: intro.9,v 1.26 2019/09/01 19:09:00 wiz 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 ustore 9 . 326.Pp 327Fetch data from user-space. 328See 329.Xr ufetch 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 438Bluetooth Device/Protocol API. 439See 440.Xr bluetooth 9 . 441.Pp 442Support for CardBus PC-Card devices. 443See 444.Xr cardbus 9 . 445.Pp 446VESA Display Data Channel V2. 447See 448.Xr ddc 9 . 449.Pp 450VESA Extended Display Identification Data. 451See 452.Xr edid 9 . 453.Pp 454Inter IC (I2C) bus. 455See 456.Xr iic 9 . 457.Pp 458Baseboard I/O control ASIC for DEC TURBOchannel systems. 459See 460.Xr ioasic 9 . 461.Pp 462Industry-standard Architecture. 463See 464.Xr isa 9 . 465.Pp 466Introduction to ISA Plug-and-Play support. 467See 468.Xr isapnp 9 . 469.Pp 470MicroChannel Architecture bus. 471See 472.Xr mca 9 . 473.Pp 474PPBUS microseqencer developer's guide. 475See 476.Xr microseq 9 . 477.Pp 478Peripheral Component Interconnect. 479See 480.Xr pci 9 . 481.Pp 482Perform PCI bus configuration. 483See 484.Xr pci_configure_bus 9 . 485.Pp 486PCI bus interrupt manipulation functions. 487See 488.Xr pci_intr 9 . 489.Pp 490PC keyboard port interface. 491See 492.Xr pckbport 9 . 493.Pp 494Support for PCMCIA PC-Card devices. 495See 496.Xr pcmcia 9 . 497.Pp 498Interface between low and high level radio drivers. 499See 500.Xr radio 9 . 501.Pp 502Functions to make a device available for entropy collection. 503See 504.Xr rnd 9 . 505.Pp 506SCSI/ATAPI middle-layer interface. 507See 508.Xr scsipi 9 . 509.Pp 510TURBOchannel bus. 511See 512.Xr tc 9 . 513.Pp 514USB tty support. 515See 516.Xr ucom 9 . 517.Pp 518USB device drivers interface. 519See 520.Xr usbdi 9 . 521.Pp 522Versa Module Euroboard bus. 523See 524.Xr vme 9 . 525.Pp 526Machine-independent IDE/ATAPI driver. 527See 528.Xr wdc 9 . 529.Sh KERNEL EVENT 530Functions to add or remove kernel event filters. 531See 532.Xr kfilter_register 9 . 533.Pp 534Functions to raise kernel event. 535See 536.Xr knote 9 . 537.Pp 538Record and wakeup select requests. 539See 540.Xr selrecord 9 . 541.Pp 542Simple do-it-in-thread-context framework. 543See 544.Xr workqueue 9 . 545.Sh KERNEL HELPER FUNCTIONS 546Kernel expression verification macros. 547See 548.Xr KASSERT 9 . 549.Pp 550Convert a single byte between (unsigned) packed bcd and binary. 551See 552.Xr bcdtobin 9 . 553.Pp 554Bitmask output conversion. 555See 556.Xr snprintb 3 . 557.Pp 558General purpose extent manager. 559See 560.Xr extent 9 . 561.Pp 562Compare integers. 563See 564.Xr imax 9 . 565.Pp 566Kernel formatted output conversion. 567See 568.Xr kprintf 9 . 569.Pp 570Data comparing, moving, copying, setting and cleaning. 571See 572.Xr memcmp 9 , 573.Xr memmove 9 , 574.Xr memcpy 9 , 575.Xr memset 9 , 576.Xr bcmp 9 , 577.Xr bcopy 9 , 578.Xr bzero 9 , 579.Xr kcopy 9 . 580.Pp 581Log a message from the kernel through the /dev/klog device. 582See 583.Xr log 9 . 584.Pp 585Bring down system on fatal error. 586See 587.Xr panic 9 . 588.Sh MISC 589Power management and inter-driver messaging. 590See 591.Xr pmf 9 . 592.Pp 593Run all shutdown hooks. 594See 595.Xr pmf_system_shutdown 9 . 596.Pp 597Kernel internal error numbers. 598See 599.Xr errno 9 . 600.Pp 601Kernel hash functions, hash table construction and destruction. 602See 603.Xr hash 9 , 604.Xr hashinit 9 . 605.Pp 606Format a number into a human readable form. 607See 608.Xr humanize_number 9 . 609.Pp 610Options string management. 611See 612.Xr optstr 9 . 613.Pp 614Performs pattern matching on strings. 615See 616.Xr pmatch 9 . 617.Pp 618Add or remove a shutdown hook. 619See 620.Xr pmf 9 . 621.Pp 622Non-local jumps. 623See 624.Xr setjmp 9 . 625.Pp 626System variable control interfaces. 627See 628.Xr sysctl 9 . 629.Sh HISTORY 630The 631.Nx 632kernel internals section first appeared in 633.Nx 1.2 . 634