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