at v2.6.18 568 lines 14 kB view raw
1<?xml version="1.0" encoding="UTF-8"?> 2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" 3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []> 4 5<book id="LinuxKernelAPI"> 6 <bookinfo> 7 <title>The Linux Kernel API</title> 8 9 <legalnotice> 10 <para> 11 This documentation is free software; you can redistribute 12 it and/or modify it under the terms of the GNU General Public 13 License as published by the Free Software Foundation; either 14 version 2 of the License, or (at your option) any later 15 version. 16 </para> 17 18 <para> 19 This program is distributed in the hope that it will be 20 useful, but WITHOUT ANY WARRANTY; without even the implied 21 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 See the GNU General Public License for more details. 23 </para> 24 25 <para> 26 You should have received a copy of the GNU General Public 27 License along with this program; if not, write to the Free 28 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 29 MA 02111-1307 USA 30 </para> 31 32 <para> 33 For more details see the file COPYING in the source 34 distribution of Linux. 35 </para> 36 </legalnotice> 37 </bookinfo> 38 39<toc></toc> 40 41 <chapter id="Basics"> 42 <title>Driver Basics</title> 43 <sect1><title>Driver Entry and Exit points</title> 44!Iinclude/linux/init.h 45 </sect1> 46 47 <sect1><title>Atomic and pointer manipulation</title> 48!Iinclude/asm-i386/atomic.h 49!Iinclude/asm-i386/unaligned.h 50 </sect1> 51 52 <sect1><title>Delaying, scheduling, and timer routines</title> 53!Iinclude/linux/sched.h 54!Ekernel/sched.c 55!Ekernel/timer.c 56 </sect1> 57 <sect1><title>High-resolution timers</title> 58!Iinclude/linux/ktime.h 59!Iinclude/linux/hrtimer.h 60!Ekernel/hrtimer.c 61 </sect1> 62 <sect1><title>Workqueues and Kevents</title> 63!Ekernel/workqueue.c 64 </sect1> 65 <sect1><title>Internal Functions</title> 66!Ikernel/exit.c 67!Ikernel/signal.c 68!Iinclude/linux/kthread.h 69!Ekernel/kthread.c 70 </sect1> 71 72 <sect1><title>Kernel objects manipulation</title> 73<!-- 74X!Iinclude/linux/kobject.h 75--> 76!Elib/kobject.c 77 </sect1> 78 79 <sect1><title>Kernel utility functions</title> 80!Iinclude/linux/kernel.h 81!Ekernel/printk.c 82!Ekernel/panic.c 83!Ekernel/sys.c 84!Ekernel/rcupdate.c 85 </sect1> 86 87 </chapter> 88 89 <chapter id="adt"> 90 <title>Data Types</title> 91 <sect1><title>Doubly Linked Lists</title> 92!Iinclude/linux/list.h 93 </sect1> 94 </chapter> 95 96 <chapter id="libc"> 97 <title>Basic C Library Functions</title> 98 99 <para> 100 When writing drivers, you cannot in general use routines which are 101 from the C Library. Some of the functions have been found generally 102 useful and they are listed below. The behaviour of these functions 103 may vary slightly from those defined by ANSI, and these deviations 104 are noted in the text. 105 </para> 106 107 <sect1><title>String Conversions</title> 108!Ilib/vsprintf.c 109!Elib/vsprintf.c 110 </sect1> 111 <sect1><title>String Manipulation</title> 112<!-- All functions are exported at now 113X!Ilib/string.c 114 --> 115!Elib/string.c 116 </sect1> 117 <sect1><title>Bit Operations</title> 118!Iinclude/asm-i386/bitops.h 119 </sect1> 120 </chapter> 121 122 <chapter id="kernel-lib"> 123 <title>Basic Kernel Library Functions</title> 124 125 <para> 126 The Linux kernel provides more basic utility functions. 127 </para> 128 129 <sect1><title>Bitmap Operations</title> 130!Elib/bitmap.c 131!Ilib/bitmap.c 132 </sect1> 133 134 <sect1><title>Command-line Parsing</title> 135!Elib/cmdline.c 136 </sect1> 137 138 <sect1><title>CRC Functions</title> 139!Elib/crc16.c 140!Elib/crc32.c 141!Elib/crc-ccitt.c 142 </sect1> 143 </chapter> 144 145 <chapter id="mm"> 146 <title>Memory Management in Linux</title> 147 <sect1><title>The Slab Cache</title> 148!Iinclude/linux/slab.h 149!Emm/slab.c 150 </sect1> 151 <sect1><title>User Space Memory Access</title> 152!Iinclude/asm-i386/uaccess.h 153!Earch/i386/lib/usercopy.c 154 </sect1> 155 <sect1><title>More Memory Management Functions</title> 156!Iinclude/linux/rmap.h 157!Emm/readahead.c 158!Emm/filemap.c 159!Emm/memory.c 160!Emm/vmalloc.c 161!Emm/mempool.c 162!Emm/page-writeback.c 163!Emm/truncate.c 164 </sect1> 165 </chapter> 166 167 168 <chapter id="ipc"> 169 <title>Kernel IPC facilities</title> 170 171 <sect1><title>IPC utilities</title> 172!Iipc/util.c 173 </sect1> 174 </chapter> 175 176 <chapter id="kfifo"> 177 <title>FIFO Buffer</title> 178 <sect1><title>kfifo interface</title> 179!Iinclude/linux/kfifo.h 180!Ekernel/kfifo.c 181 </sect1> 182 </chapter> 183 184 <chapter id="proc"> 185 <title>The proc filesystem</title> 186 187 <sect1><title>sysctl interface</title> 188!Ekernel/sysctl.c 189 </sect1> 190 191 <sect1><title>proc filesystem interface</title> 192!Ifs/proc/base.c 193 </sect1> 194 </chapter> 195 196 <chapter id="debugfs"> 197 <title>The debugfs filesystem</title> 198 199 <sect1><title>debugfs interface</title> 200!Efs/debugfs/inode.c 201!Efs/debugfs/file.c 202 </sect1> 203 </chapter> 204 205 <chapter id="vfs"> 206 <title>The Linux VFS</title> 207 <sect1><title>The Filesystem types</title> 208!Iinclude/linux/fs.h 209 </sect1> 210 <sect1><title>The Directory Cache</title> 211!Efs/dcache.c 212!Iinclude/linux/dcache.h 213 </sect1> 214 <sect1><title>Inode Handling</title> 215!Efs/inode.c 216!Efs/bad_inode.c 217 </sect1> 218 <sect1><title>Registration and Superblocks</title> 219!Efs/super.c 220 </sect1> 221 <sect1><title>File Locks</title> 222!Efs/locks.c 223!Ifs/locks.c 224 </sect1> 225 <sect1><title>Other Functions</title> 226!Efs/mpage.c 227!Efs/namei.c 228!Efs/buffer.c 229!Efs/bio.c 230!Efs/seq_file.c 231!Efs/filesystems.c 232!Efs/fs-writeback.c 233!Efs/block_dev.c 234 </sect1> 235 </chapter> 236 237 <chapter id="netcore"> 238 <title>Linux Networking</title> 239 <sect1><title>Networking Base Types</title> 240!Iinclude/linux/net.h 241 </sect1> 242 <sect1><title>Socket Buffer Functions</title> 243!Iinclude/linux/skbuff.h 244!Iinclude/net/sock.h 245!Enet/socket.c 246!Enet/core/skbuff.c 247!Enet/core/sock.c 248!Enet/core/datagram.c 249!Enet/core/stream.c 250 </sect1> 251 <sect1><title>Socket Filter</title> 252!Enet/core/filter.c 253 </sect1> 254 <sect1><title>Generic Network Statistics</title> 255!Iinclude/linux/gen_stats.h 256!Enet/core/gen_stats.c 257!Enet/core/gen_estimator.c 258 </sect1> 259 <sect1><title>SUN RPC subsystem</title> 260<!-- The !D functionality is not perfect, garbage has to be protected by comments 261!Dnet/sunrpc/sunrpc_syms.c 262--> 263!Enet/sunrpc/xdr.c 264!Enet/sunrpc/svcsock.c 265!Enet/sunrpc/sched.c 266 </sect1> 267 </chapter> 268 269 <chapter id="netdev"> 270 <title>Network device support</title> 271 <sect1><title>Driver Support</title> 272!Enet/core/dev.c 273!Enet/ethernet/eth.c 274!Iinclude/linux/etherdevice.h 275<!-- FIXME: Removed for now since no structured comments in source 276X!Enet/core/wireless.c 277--> 278 </sect1> 279 <sect1><title>Synchronous PPP</title> 280!Edrivers/net/wan/syncppp.c 281 </sect1> 282 </chapter> 283 284 <chapter id="modload"> 285 <title>Module Support</title> 286 <sect1><title>Module Loading</title> 287!Ekernel/kmod.c 288 </sect1> 289 <sect1><title>Inter Module support</title> 290 <para> 291 Refer to the file kernel/module.c for more information. 292 </para> 293<!-- FIXME: Removed for now since no structured comments in source 294X!Ekernel/module.c 295--> 296 </sect1> 297 </chapter> 298 299 <chapter id="hardware"> 300 <title>Hardware Interfaces</title> 301 <sect1><title>Interrupt Handling</title> 302!Ekernel/irq/manage.c 303 </sect1> 304 305 <sect1><title>Resources Management</title> 306!Ikernel/resource.c 307 </sect1> 308 309 <sect1><title>MTRR Handling</title> 310!Earch/i386/kernel/cpu/mtrr/main.c 311 </sect1> 312 313 <sect1><title>PCI Support Library</title> 314!Edrivers/pci/pci.c 315!Edrivers/pci/pci-driver.c 316!Edrivers/pci/remove.c 317!Edrivers/pci/pci-acpi.c 318!Edrivers/pci/search.c 319!Edrivers/pci/msi.c 320!Edrivers/pci/bus.c 321<!-- FIXME: Removed for now since no structured comments in source 322X!Edrivers/pci/hotplug.c 323--> 324!Edrivers/pci/probe.c 325!Edrivers/pci/rom.c 326 </sect1> 327 <sect1><title>PCI Hotplug Support Library</title> 328!Edrivers/pci/hotplug/pci_hotplug_core.c 329 </sect1> 330 <sect1><title>MCA Architecture</title> 331 <sect2><title>MCA Device Functions</title> 332 <para> 333 Refer to the file arch/i386/kernel/mca.c for more information. 334 </para> 335<!-- FIXME: Removed for now since no structured comments in source 336X!Earch/i386/kernel/mca.c 337--> 338 </sect2> 339 <sect2><title>MCA Bus DMA</title> 340!Iinclude/asm-i386/mca_dma.h 341 </sect2> 342 </sect1> 343 </chapter> 344 345 <chapter id="firmware"> 346 <title>Firmware Interfaces</title> 347 <sect1><title>DMI Interfaces</title> 348!Edrivers/firmware/dmi_scan.c 349 </sect1> 350 </chapter> 351 352 <chapter id="sysfs"> 353 <title>The Filesystem for Exporting Kernel Objects</title> 354!Efs/sysfs/file.c 355!Efs/sysfs/symlink.c 356!Efs/sysfs/bin.c 357 </chapter> 358 359 <chapter id="security"> 360 <title>Security Framework</title> 361!Esecurity/security.c 362 </chapter> 363 364 <chapter id="audit"> 365 <title>Audit Interfaces</title> 366!Ekernel/audit.c 367!Ikernel/auditsc.c 368!Ikernel/auditfilter.c 369 </chapter> 370 371 <chapter id="accounting"> 372 <title>Accounting Framework</title> 373!Ikernel/acct.c 374 </chapter> 375 376 <chapter id="pmfuncs"> 377 <title>Power Management</title> 378!Ekernel/power/pm.c 379 </chapter> 380 381 <chapter id="devdrivers"> 382 <title>Device drivers infrastructure</title> 383 <sect1><title>Device Drivers Base</title> 384<!-- 385X!Iinclude/linux/device.h 386--> 387!Edrivers/base/driver.c 388!Edrivers/base/core.c 389!Edrivers/base/firmware_class.c 390!Edrivers/base/transport_class.c 391!Edrivers/base/dmapool.c 392<!-- Cannot be included, because 393 attribute_container_add_class_device_adapter 394 and attribute_container_classdev_to_container 395 exceed allowed 44 characters maximum 396X!Edrivers/base/attribute_container.c 397--> 398!Edrivers/base/sys.c 399<!-- 400X!Edrivers/base/interface.c 401--> 402!Edrivers/base/platform.c 403!Edrivers/base/bus.c 404 </sect1> 405 <sect1><title>Device Drivers Power Management</title> 406!Edrivers/base/power/main.c 407!Edrivers/base/power/resume.c 408!Edrivers/base/power/suspend.c 409 </sect1> 410 <sect1><title>Device Drivers ACPI Support</title> 411<!-- Internal functions only 412X!Edrivers/acpi/sleep/main.c 413X!Edrivers/acpi/sleep/wakeup.c 414X!Edrivers/acpi/motherboard.c 415X!Edrivers/acpi/bus.c 416--> 417!Edrivers/acpi/scan.c 418!Idrivers/acpi/scan.c 419<!-- No correct structured comments 420X!Edrivers/acpi/pci_bind.c 421--> 422 </sect1> 423 <sect1><title>Device drivers PnP support</title> 424!Edrivers/pnp/core.c 425<!-- No correct structured comments 426X!Edrivers/pnp/system.c 427 --> 428!Edrivers/pnp/card.c 429!Edrivers/pnp/driver.c 430!Edrivers/pnp/manager.c 431!Edrivers/pnp/support.c 432 </sect1> 433 </chapter> 434 435 <chapter id="blkdev"> 436 <title>Block Devices</title> 437!Eblock/ll_rw_blk.c 438 </chapter> 439 440 <chapter id="miscdev"> 441 <title>Miscellaneous Devices</title> 442!Edrivers/char/misc.c 443 </chapter> 444 445 <chapter id="parportdev"> 446 <title>Parallel Port Devices</title> 447!Iinclude/linux/parport.h 448!Edrivers/parport/ieee1284.c 449!Edrivers/parport/share.c 450!Idrivers/parport/daisy.c 451 </chapter> 452 453 <chapter id="viddev"> 454 <title>Video4Linux</title> 455!Edrivers/media/video/videodev.c 456 </chapter> 457 458 <chapter id="snddev"> 459 <title>Sound Devices</title> 460!Iinclude/sound/core.h 461!Esound/sound_core.c 462!Iinclude/sound/pcm.h 463!Esound/core/pcm.c 464!Esound/core/device.c 465!Esound/core/info.c 466!Esound/core/rawmidi.c 467!Esound/core/sound.c 468!Esound/core/memory.c 469!Esound/core/pcm_memory.c 470!Esound/core/init.c 471!Esound/core/isadma.c 472!Esound/core/control.c 473!Esound/core/pcm_lib.c 474!Esound/core/hwdep.c 475!Esound/core/pcm_native.c 476!Esound/core/memalloc.c 477<!-- FIXME: Removed for now since no structured comments in source 478X!Isound/sound_firmware.c 479--> 480 </chapter> 481 482 <chapter id="uart16x50"> 483 <title>16x50 UART Driver</title> 484!Iinclude/linux/serial_core.h 485!Edrivers/serial/serial_core.c 486!Edrivers/serial/8250.c 487 </chapter> 488 489 <chapter id="z85230"> 490 <title>Z85230 Support Library</title> 491!Edrivers/net/wan/z85230.c 492 </chapter> 493 494 <chapter id="fbdev"> 495 <title>Frame Buffer Library</title> 496 497 <para> 498 The frame buffer drivers depend heavily on four data structures. 499 These structures are declared in include/linux/fb.h. They are 500 fb_info, fb_var_screeninfo, fb_fix_screeninfo and fb_monospecs. 501 The last three can be made available to and from userland. 502 </para> 503 504 <para> 505 fb_info defines the current state of a particular video card. 506 Inside fb_info, there exists a fb_ops structure which is a 507 collection of needed functions to make fbdev and fbcon work. 508 fb_info is only visible to the kernel. 509 </para> 510 511 <para> 512 fb_var_screeninfo is used to describe the features of a video card 513 that are user defined. With fb_var_screeninfo, things such as 514 depth and the resolution may be defined. 515 </para> 516 517 <para> 518 The next structure is fb_fix_screeninfo. This defines the 519 properties of a card that are created when a mode is set and can't 520 be changed otherwise. A good example of this is the start of the 521 frame buffer memory. This "locks" the address of the frame buffer 522 memory, so that it cannot be changed or moved. 523 </para> 524 525 <para> 526 The last structure is fb_monospecs. In the old API, there was 527 little importance for fb_monospecs. This allowed for forbidden things 528 such as setting a mode of 800x600 on a fix frequency monitor. With 529 the new API, fb_monospecs prevents such things, and if used 530 correctly, can prevent a monitor from being cooked. fb_monospecs 531 will not be useful until kernels 2.5.x. 532 </para> 533 534 <sect1><title>Frame Buffer Memory</title> 535!Edrivers/video/fbmem.c 536 </sect1> 537<!-- 538 <sect1><title>Frame Buffer Console</title> 539X!Edrivers/video/console/fbcon.c 540 </sect1> 541--> 542 <sect1><title>Frame Buffer Colormap</title> 543!Edrivers/video/fbcmap.c 544 </sect1> 545<!-- FIXME: 546 drivers/video/fbgen.c has no docs, which stuffs up the sgml. Comment 547 out until somebody adds docs. KAO 548 <sect1><title>Frame Buffer Generic Functions</title> 549X!Idrivers/video/fbgen.c 550 </sect1> 551KAO --> 552 <sect1><title>Frame Buffer Video Mode Database</title> 553!Idrivers/video/modedb.c 554!Edrivers/video/modedb.c 555 </sect1> 556 <sect1><title>Frame Buffer Macintosh Video Mode Database</title> 557!Edrivers/video/macmodes.c 558 </sect1> 559 <sect1><title>Frame Buffer Fonts</title> 560 <para> 561 Refer to the file drivers/video/console/fonts.c for more information. 562 </para> 563<!-- FIXME: Removed for now since no structured comments in source 564X!Idrivers/video/console/fonts.c 565--> 566 </sect1> 567 </chapter> 568</book>