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