1.\" $NetBSD: intro.9,v 1.16 2015/03/23 13:40:34 riastradh 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 December 2, 2010 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 52Machine-dependent swap interface. 53See 54.Xr cpu_swapout 9 . 55.Pp 56Introduction to kernel memory allocators. 57See 58.Xr memoryallocators 9 . 59.Pp 60Machine-dependent portion of the virtual memory system. 61See 62.Xr pmap 9 . 63.Pp 64Virtual memory system external interface. 65See 66.Xr uvm 9 . 67.Sh I/O SUBSYSTEM 68Buffer cache interfaces. 69See 70.Xr buffercache 9 . 71.Pp 72Device buffer queues. 73See 74.Xr bufq 9 . 75.Pp 76Initiate I/O on raw devices. 77See 78.Xr physio 9 . 79.Pp 80I/O descriptor allocation interface. 81See 82.Xr getiobuf 9 . 83.Sh PROCESS CONTROL 84Machine-dependent process exit. 85See 86.Xr cpu_exit 9 . 87.Pp 88Idle CPU while waiting for work. 89See 90.Xr cpu_idle 9 . 91.Pp 92Finish a fork operation. 93See 94.Xr cpu_lwp_fork 9 . 95.Pp 96Switch to another light weight process. 97See 98.Xr mi_switch 9 . 99.Pp 100Current process and processor. 101See 102.Xr curproc 9 . 103.Pp 104Set process uid and gid. 105See 106.Xr do_setresuid 9 . 107.Pp 108New processes and kernel threads. 109See 110.Xr fork1 9 , 111.Xr kthread 9 . 112.Pp 113Context switch notification. 114See 115.Xr cpu_need_resched 9 . 116.Pp 117Common scheduler framework. 118See 119.Xr csf 9 . 120.Pp 121Software signal facilities. 122See 123.Xr signal 9 . 124.Pp 125Suspend the scheduler. 126See 127.Xr suspendsched 9 . 128.Pp 129Return path to user-mode execution. 130See 131.Xr userret 9 . 132.Sh FILE SYSTEM 133High-level file operations. 134See 135.Xr dofileread 9 . 136.Pp 137Convert an extended attribute namespace identifier to a string and 138vice versa. 139See 140.Xr extattr 9 . 141.Pp 142Operations on file entries. 143See 144.Xr file 9 . 145.Pp 146In-kernel, file-system independent, file-meta data association. 147See 148.Xr fileassoc 9 . 149.Pp 150File descriptor tables and operations. 151See 152.Xr filedesc 9 . 153.Pp 154File descriptor owner handling functions. 155See 156.Xr fsetown 9 . 157.Pp 158File system suspension helper subsystem. 159See 160.Xr fstrans 9 . 161.Pp 162Pathname lookup, cache and management. 163See 164.Xr namei 9 , 165.Xr namecache 9 , 166.Xr pathname 9 . 167.Pp 168Kernel interface to file systems. 169See 170.Xr vfs 9 . 171.Pp 172Kernel representation of a file or directory and vnode attributes. 173See 174.Xr vnode 9 , 175.Xr vattr 9 . 176.Sh NETWORKING 177Kernel interfaces for manipulating output queues on network interfaces. 178See 179.Xr altq 9 . 180.Pp 181Externally visible ARP functions. 182See 183.Xr arp 9 . 184.Pp 185Ethernet and FDDI driver support functions and macros. 186See 187.Xr ethersubr 9 . 188.Pp 189Core 802.11 network stack functions and rate adaptation based on 190received signal strength. 191See 192.Xr ieee80211 9 , 193.Xr rssadapt 9 . 194.Pp 195Compute Internet checksum. 196See 197.Xr in_cksum 9 . 198.Pp 199Look up the IPv4 source address best matching an IPv4 destination. 200See 201.Xr in_getifa 9 . 202.Pp 203Functions and macros for managing memory used by networking code. 204See 205.Xr mbuf 9 . 206.Pp 207Packet filter interface. 208See 209.Xr pfil 9 . 210.Pp 211Route callout functions. 212See 213.Xr rt_timer 9 . 214.Pp 215TCP congestion control API. 216See 217.Xr tcp_congctl 9 . 218.Sh LOCKING AND INTERRUPT CONTROL 219Condition variables. 220See 221.Xr condvar 9 . 222.Pp 223Kernel lock functions. 224See 225.Xr lock 9 . 226.Pp 227Memory barriers. 228See 229.Xr mb 9 . 230.Pp 231Mutual exclusion primitives. 232See 233.Xr mutex 9 . 234.Pp 235Restartable atomic sequences. 236See 237.Xr ras 9 . 238.Pp 239Reader / writer lock primitives. 240See 241.Xr rwlock 9 . 242.Pp 243Machine-independent software interrupt framework. 244See 245.Xr softint 9 . 246.Pp 247Functions to modify system interrupt priority level. 248See 249.Xr spl 9 . 250.Pp 251Functions to raise the system priority level. 252See 253.Xr splraiseipl 9 . 254.Sh SECURITY 255Kernel authorization framework. 256See 257.Xr kauth 9 . 258.Pp 259API for cryptographic services in the kernel. 260See 261.Xr opencrypto 9 . 262.Pp 263Security model development guidelines. 264See 265.Xr secmodel 9 . 266.Sh SYSTEM TIME CONTROL 267Execute a function after a specified length of time. 268See 269.Xr callout 9 . 270.Pp 271Microsecond delay. 272See 273.Xr delay 9 . 274.Pp 275Real-time timer. 276See 277.Xr hardclock 9 . 278.Pp 279System clock frequency. 280See 281.Xr hz 9 . 282.Pp 283Initialization of system time and time-of-day clock support. 284See 285.Xr inittodr 9 , 286.Xr todr 9 . 287.Pp 288Check that a timeval value is valid, and correct. 289See 290.Xr itimerfix 9 . 291.Pp 292System time variables. 293See 294.Xr timecounter 9 . 295.Pp 296Realtime system clock. 297See 298.Xr microtime 9 . 299.Pp 300Get the time elapsed since boot. 301See 302.Xr microuptime 9 . 303.Pp 304Convert milliseconds to system clock ticks. 305See 306.Xr mstohz 9 . 307.Pp 308Function to help implement rate-limited actions. 309See 310.Xr ppsratecheck 9 . 311.Pp 312Function to help implement rate-limited actions. 313See 314.Xr ratecheck 9 . 315.Pp 316Set battery-backed clock from system time. 317See 318.Xr resettodr 9 . 319.Pp 320System time variables. 321See 322.Xr time_second 9 . 323.Sh KERNEL AND USER SPACE DATA COPY FUNCTIONS 324Kernel space to/from user space copy functions. 325See 326.Xr copy 9 . 327.Pp 328Store data to user-space. 329See 330.Xr store 9 . 331.Pp 332Fetch data from user-space. 333See 334.Xr fetch 9 . 335.Pp 336Move data described by a struct uio. 337See 338.Xr uiomove 9 . 339.Sh MACHINE DEPENDENT KERNEL FUNCTIONS 340Machine-dependent clock setup interface. 341See 342.Xr cpu_initclocks 9 . 343.Pp 344Machine-dependent process core dump interface. 345See 346.Xr cpu_coredump 9 . 347.Pp 348Machine-dependent kernel core dumps. 349See 350.Xr cpu_dumpconf 9 . 351.Pp 352Unique CPU identification number 353See 354.Xr cpu_number 9 . 355.Pp 356Halt or reboot the system 357See 358.Xr cpu_reboot 9 . 359.Pp 360Machine-dependent root file system setup 361See 362.Xr cpu_rootconf 9 . 363.Pp 364Machine-dependent CPU startup 365See 366.Xr cpu_startup 9 . 367.Pp 368Disk label management routines. 369See 370.Xr disklabel 9 . 371.Sh DEVICE CONFIGURATION 372Autoconfiguration frame-work. 373See 374.Xr autoconf 9 . 375.Pp 376Description of a device driver. 377See 378.Xr driver 9 . 379.Pp 380The autoconfiguration framework ``device definition'' language. 381See 382.Xr config 9 . 383.Pp 384Machine-dependent device autoconfiguration. 385See 386.Xr cpu_configure 9 . 387.Sh MI DEVICE DRIVER API 388Bus and Machine Independent DMA Mapping Interface. 389See 390.Xr bus_dma 9 . 391.Pp 392Bus space manipulation functions. 393See 394.Xr bus_space 9 . 395.Pp 396Generic disk framework. 397See 398.Xr disk 9 . 399.Pp 400Hardware-assisted data mover interface. 401See 402.Xr dmover 9 . 403Generic event counter framework. 404See 405.Xr evcnt 9 . 406.Pp 407Firmware loader API for device drivers. 408See 409.Xr firmload 9 . 410.Pp 411How to implement a new ioctl call to access device drivers. 412See 413.Xr ioctl 9 . 414.Pp 415Extensible line discipline framework. 416See 417.Xr linedisc 9 . 418.Sh CONSOLE DEVICES 419Console magic key sequence management. 420See 421.Xr cnmagic 9 . 422.Pp 423Console access interface. 424See 425.Xr cons 9 . 426.Pp 427Raster display operations. 428See 429.Xr rasops 9 . 430.Pp 431Generic virtual console framework. 432See 433.Xr vcons 9 . 434.Pp 435Machine-independent console support. 436See 437.Xr wscons 9 . 438.Sh DEVICE SPECIFIC IMPLEMENTATION 439Interface between low and high level audio drivers. 440See 441.Xr audio 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 619Machine-dependent interface to ipkdb. 620See 621.Xr ipkdb 9 . 622.Pp 623Options string management. 624See 625.Xr optstr 9 . 626.Pp 627Performs pattern matching on strings. 628See 629.Xr pmatch 9 . 630.Pp 631Hardware Performance Monitoring Interface. 632See 633.Xr pmc 9 . 634.Pp 635Add or remove a shutdown hook. 636See 637.Xr pmf 9 . 638.Pp 639Non-local jumps. 640See 641.Xr setjmp 9 . 642.Pp 643System variable control interfaces. 644See 645.Xr sysctl 9 . 646.Sh HISTORY 647The 648.Nx 649kernel internals section first appeared in 650.Nx 1.2 . 651