1.\" $NetBSD: intro.9,v 1.18 2017/05/30 13:49:01 abhinav 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 May 30, 2017 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 210Condition variables. 211See 212.Xr condvar 9 . 213.Pp 214Kernel lock functions. 215See 216.Xr lock 9 . 217.Pp 218Memory barriers. 219See 220.Xr mb 9 . 221.Pp 222Mutual exclusion primitives. 223See 224.Xr mutex 9 . 225.Pp 226Restartable atomic sequences. 227See 228.Xr ras 9 . 229.Pp 230Reader / writer lock primitives. 231See 232.Xr rwlock 9 . 233.Pp 234Machine-independent software interrupt framework. 235See 236.Xr softint 9 . 237.Pp 238Functions to modify system interrupt priority level. 239See 240.Xr spl 9 . 241.Pp 242Functions to raise the system priority level. 243See 244.Xr splraiseipl 9 . 245.Sh SECURITY 246Kernel authorization framework. 247See 248.Xr kauth 9 . 249.Pp 250API for cryptographic services in the kernel. 251See 252.Xr opencrypto 9 . 253.Pp 254Security model development guidelines. 255See 256.Xr secmodel 9 . 257.Sh SYSTEM TIME CONTROL 258Execute a function after a specified length of time. 259See 260.Xr callout 9 . 261.Pp 262Microsecond delay. 263See 264.Xr delay 9 . 265.Pp 266Real-time timer. 267See 268.Xr hardclock 9 . 269.Pp 270System clock frequency. 271See 272.Xr hz 9 . 273.Pp 274Initialization of system time and time-of-day clock support. 275See 276.Xr inittodr 9 , 277.Xr todr 9 . 278.Pp 279Check that a timeval value is valid, and correct. 280See 281.Xr itimerfix 9 . 282.Pp 283System time variables. 284See 285.Xr timecounter 9 . 286.Pp 287Realtime system clock. 288See 289.Xr microtime 9 . 290.Pp 291Get the time elapsed since boot. 292See 293.Xr microuptime 9 . 294.Pp 295Convert milliseconds to system clock ticks. 296See 297.Xr mstohz 9 . 298.Pp 299Function to help implement rate-limited actions. 300See 301.Xr ppsratecheck 9 . 302.Pp 303Function to help implement rate-limited actions. 304See 305.Xr ratecheck 9 . 306.Pp 307Set battery-backed clock from system time. 308See 309.Xr resettodr 9 . 310.Pp 311System time variables. 312See 313.Xr time_second 9 . 314.Sh KERNEL AND USER SPACE DATA COPY FUNCTIONS 315Kernel space to/from user space copy functions. 316See 317.Xr copy 9 . 318.Pp 319Store data to user-space. 320See 321.Xr store 9 . 322.Pp 323Fetch data from user-space. 324See 325.Xr fetch 9 . 326.Pp 327Move data described by a struct uio. 328See 329.Xr uiomove 9 . 330.Sh MACHINE DEPENDENT KERNEL FUNCTIONS 331Machine-dependent clock setup interface. 332See 333.Xr cpu_initclocks 9 . 334.Pp 335Machine-dependent process core dump interface. 336See 337.Xr cpu_coredump 9 . 338.Pp 339Machine-dependent kernel core dumps. 340See 341.Xr cpu_dumpconf 9 . 342.Pp 343Unique CPU identification number 344See 345.Xr cpu_number 9 . 346.Pp 347Halt or reboot the system 348See 349.Xr cpu_reboot 9 . 350.Pp 351Machine-dependent root file system setup 352See 353.Xr cpu_rootconf 9 . 354.Pp 355Machine-dependent CPU startup 356See 357.Xr cpu_startup 9 . 358.Pp 359Disk label management routines. 360See 361.Xr disklabel 9 . 362.Sh DEVICE CONFIGURATION 363Autoconfiguration frame-work. 364See 365.Xr autoconf 9 . 366.Pp 367Description of a device driver. 368See 369.Xr driver 9 . 370.Pp 371The autoconfiguration framework ``device definition'' language. 372See 373.Xr config 9 . 374.Pp 375Machine-dependent device autoconfiguration. 376See 377.Xr cpu_configure 9 . 378.Sh MI DEVICE DRIVER API 379Bus and Machine Independent DMA Mapping Interface. 380See 381.Xr bus_dma 9 . 382.Pp 383Bus space manipulation functions. 384See 385.Xr bus_space 9 . 386.Pp 387Generic disk framework. 388See 389.Xr disk 9 . 390.Pp 391Hardware-assisted data mover interface. 392See 393.Xr dmover 9 . 394Generic event counter framework. 395See 396.Xr evcnt 9 . 397.Pp 398Firmware loader API for device drivers. 399See 400.Xr firmload 9 . 401.Pp 402How to implement a new ioctl call to access device drivers. 403See 404.Xr ioctl 9 . 405.Pp 406Extensible line discipline framework. 407See 408.Xr linedisc 9 . 409.Sh CONSOLE DEVICES 410Console magic key sequence management. 411See 412.Xr cnmagic 9 . 413.Pp 414Console access interface. 415See 416.Xr cons 9 . 417.Pp 418Raster display operations. 419See 420.Xr rasops 9 . 421.Pp 422Generic virtual console framework. 423See 424.Xr vcons 9 . 425.Pp 426Machine-independent console support. 427See 428.Xr wscons 9 . 429.Sh DEVICE SPECIFIC IMPLEMENTATION 430Interface between low and high level audio drivers. 431See 432.Xr audio 9 . 433.Pp 434Bluetooth Device/Protocol API. 435See 436.Xr bluetooth 9 . 437.Pp 438Support for CardBus PC-Card devices. 439See 440.Xr cardbus 9 . 441.Pp 442VESA Display Data Channel V2. 443See 444.Xr ddc 9 . 445.Pp 446VESA Extended Display Identification Data. 447See 448.Xr edid 9 . 449.Pp 450Inter IC (I2C) bus. 451See 452.Xr iic 9 . 453.Pp 454Baseboard I/O control ASIC for DEC TURBOchannel systems. 455See 456.Xr ioasic 9 . 457.Pp 458Industry-standard Architecture. 459See 460.Xr isa 9 . 461.Pp 462Introduction to ISA Plug-and-Play support. 463See 464.Xr isapnp 9 . 465.Pp 466MicroChannel Architecture bus. 467See 468.Xr mca 9 . 469.Pp 470PPBUS microseqencer developer's guide. 471See 472.Xr microseq 9 . 473.Pp 474Peripheral Component Interconnect. 475See 476.Xr pci 9 . 477.Pp 478Perform PCI bus configuration. 479See 480.Xr pci_configure_bus 9 . 481.Pp 482PCI bus interrupt manipulation functions. 483See 484.Xr pci_intr 9 . 485.Pp 486PC keyboard port interface. 487See 488.Xr pckbport 9 . 489.Pp 490Support for PCMCIA PC-Card devices. 491See 492.Xr pcmcia 9 . 493.Pp 494User-space interface to ppbus parallel port. 495See 496.Xr ppi 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 610Machine-dependent interface to ipkdb. 611See 612.Xr ipkdb 9 . 613.Pp 614Options string management. 615See 616.Xr optstr 9 . 617.Pp 618Performs pattern matching on strings. 619See 620.Xr pmatch 9 . 621.Pp 622Hardware Performance Monitoring Interface. 623See 624.Xr pmc 9 . 625.Pp 626Add or remove a shutdown hook. 627See 628.Xr pmf 9 . 629.Pp 630Non-local jumps. 631See 632.Xr setjmp 9 . 633.Pp 634System variable control interfaces. 635See 636.Xr sysctl 9 . 637.Sh HISTORY 638The 639.Nx 640kernel internals section first appeared in 641.Nx 1.2 . 642