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" []>
5 <book id="LinuxKernelAPI">
7 <title>The Linux Kernel API</title>
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
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.
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,
33 For more details see the file COPYING in the source
34 distribution of Linux.
42 <title>Driver Basics</title>
43 <sect1><title>Driver Entry and Exit points</title>
44 !Iinclude/linux/init.h
47 <sect1><title>Atomic and pointer manipulation</title>
48 !Iinclude/asm-i386/atomic.h
49 !Iinclude/asm-i386/unaligned.h
52 <sect1><title>Delaying, scheduling, and timer routines</title>
53 !Iinclude/linux/sched.h
57 <sect1><title>High-resolution timers</title>
58 !Iinclude/linux/ktime.h
59 !Iinclude/linux/hrtimer.h
62 <sect1><title>Workqueues and Kevents</title>
65 <sect1><title>Internal Functions</title>
68 !Iinclude/linux/kthread.h
72 <sect1><title>Kernel objects manipulation</title>
74 X!Iinclude/linux/kobject.h
79 <sect1><title>Kernel utility functions</title>
80 !Iinclude/linux/kernel.h
90 <title>Data Types</title>
91 <sect1><title>Doubly Linked Lists</title>
92 !Iinclude/linux/list.h
97 <title>Basic C Library Functions</title>
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.
107 <sect1><title>String Conversions</title>
111 <sect1><title>String Manipulation</title>
112 <!-- All functions are exported at now
117 <sect1><title>Bit Operations</title>
118 !Iinclude/asm-i386/bitops.h
122 <chapter id="kernel-lib">
123 <title>Basic Kernel Library Functions</title>
126 The Linux kernel provides more basic utility functions.
129 <sect1><title>Bitmap Operations</title>
134 <sect1><title>Command-line Parsing</title>
138 <sect1><title>CRC Functions</title>
146 <title>Memory Management in Linux</title>
147 <sect1><title>The Slab Cache</title>
148 !Iinclude/linux/slab.h
151 <sect1><title>User Space Memory Access</title>
152 !Iinclude/asm-i386/uaccess.h
153 !Earch/i386/lib/usercopy.c
155 <sect1><title>More Memory Management Functions</title>
156 !Iinclude/linux/rmap.h
162 !Emm/page-writeback.c
169 <title>Kernel IPC facilities</title>
171 <sect1><title>IPC utilities</title>
177 <title>FIFO Buffer</title>
178 <sect1><title>kfifo interface</title>
179 !Iinclude/linux/kfifo.h
185 <title>The Linux VFS</title>
186 <sect1><title>The Filesystem types</title>
189 <sect1><title>The Directory Cache</title>
191 !Iinclude/linux/dcache.h
193 <sect1><title>Inode Handling</title>
197 <sect1><title>Registration and Superblocks</title>
200 <sect1><title>File Locks</title>
204 <sect1><title>Other Functions</title>
217 <title>The proc filesystem</title>
219 <sect1><title>sysctl interface</title>
223 <sect1><title>proc filesystem interface</title>
229 <title>The Filesystem for Exporting Kernel Objects</title>
235 <chapter id="debugfs">
236 <title>The debugfs filesystem</title>
238 <sect1><title>debugfs interface</title>
244 <chapter id="relayfs">
245 <title>relay interface support</title>
248 Relay interface support
249 is designed to provide an efficient mechanism for tools and
250 facilities to relay large amounts of data from kernel space to
254 <sect1><title>relay interface</title>
260 <chapter id="netcore">
261 <title>Linux Networking</title>
262 <sect1><title>Networking Base Types</title>
263 !Iinclude/linux/net.h
265 <sect1><title>Socket Buffer Functions</title>
266 !Iinclude/linux/skbuff.h
271 !Enet/core/datagram.c
274 <sect1><title>Socket Filter</title>
277 <sect1><title>Generic Network Statistics</title>
278 !Iinclude/linux/gen_stats.h
279 !Enet/core/gen_stats.c
280 !Enet/core/gen_estimator.c
282 <sect1><title>SUN RPC subsystem</title>
283 <!-- The !D functionality is not perfect, garbage has to be protected by comments
284 !Dnet/sunrpc/sunrpc_syms.c
287 !Enet/sunrpc/svcsock.c
292 <chapter id="netdev">
293 <title>Network device support</title>
294 <sect1><title>Driver Support</title>
297 !Iinclude/linux/etherdevice.h
298 <!-- FIXME: Removed for now since no structured comments in source
299 X!Enet/core/wireless.c
302 <sect1><title>Synchronous PPP</title>
303 !Edrivers/net/wan/syncppp.c
307 <chapter id="modload">
308 <title>Module Support</title>
309 <sect1><title>Module Loading</title>
312 <sect1><title>Inter Module support</title>
314 Refer to the file kernel/module.c for more information.
316 <!-- FIXME: Removed for now since no structured comments in source
322 <chapter id="hardware">
323 <title>Hardware Interfaces</title>
324 <sect1><title>Interrupt Handling</title>
325 !Ekernel/irq/manage.c
328 <sect1><title>Resources Management</title>
332 <sect1><title>MTRR Handling</title>
333 !Earch/i386/kernel/cpu/mtrr/main.c
336 <sect1><title>PCI Support Library</title>
338 !Edrivers/pci/pci-driver.c
339 !Edrivers/pci/remove.c
340 !Edrivers/pci/pci-acpi.c
341 !Edrivers/pci/search.c
344 <!-- FIXME: Removed for now since no structured comments in source
345 X!Edrivers/pci/hotplug.c
347 !Edrivers/pci/probe.c
350 <sect1><title>PCI Hotplug Support Library</title>
351 !Edrivers/pci/hotplug/pci_hotplug_core.c
353 <sect1><title>MCA Architecture</title>
354 <sect2><title>MCA Device Functions</title>
356 Refer to the file arch/i386/kernel/mca.c for more information.
358 <!-- FIXME: Removed for now since no structured comments in source
359 X!Earch/i386/kernel/mca.c
362 <sect2><title>MCA Bus DMA</title>
363 !Iinclude/asm-i386/mca_dma.h
368 <chapter id="firmware">
369 <title>Firmware Interfaces</title>
370 <sect1><title>DMI Interfaces</title>
371 !Edrivers/firmware/dmi_scan.c
375 <chapter id="security">
376 <title>Security Framework</title>
377 !Esecurity/security.c
381 <title>Audit Interfaces</title>
384 !Ikernel/auditfilter.c
387 <chapter id="accounting">
388 <title>Accounting Framework</title>
392 <chapter id="pmfuncs">
393 <title>Power Management</title>
397 <chapter id="devdrivers">
398 <title>Device drivers infrastructure</title>
399 <sect1><title>Device Drivers Base</title>
401 X!Iinclude/linux/device.h
403 !Edrivers/base/driver.c
404 !Edrivers/base/core.c
405 !Edrivers/base/class.c
406 !Edrivers/base/firmware_class.c
407 !Edrivers/base/transport_class.c
408 !Edrivers/base/dmapool.c
409 <!-- Cannot be included, because
410 attribute_container_add_class_device_adapter
411 and attribute_container_classdev_to_container
412 exceed allowed 44 characters maximum
413 X!Edrivers/base/attribute_container.c
417 X!Edrivers/base/interface.c
419 !Edrivers/base/platform.c
422 <sect1><title>Device Drivers Power Management</title>
423 !Edrivers/base/power/main.c
424 !Edrivers/base/power/resume.c
425 !Edrivers/base/power/suspend.c
427 <sect1><title>Device Drivers ACPI Support</title>
428 <!-- Internal functions only
429 X!Edrivers/acpi/sleep/main.c
430 X!Edrivers/acpi/sleep/wakeup.c
431 X!Edrivers/acpi/motherboard.c
432 X!Edrivers/acpi/bus.c
434 !Edrivers/acpi/scan.c
435 !Idrivers/acpi/scan.c
436 <!-- No correct structured comments
437 X!Edrivers/acpi/pci_bind.c
440 <sect1><title>Device drivers PnP support</title>
442 <!-- No correct structured comments
443 X!Edrivers/pnp/system.c
446 !Edrivers/pnp/driver.c
447 !Edrivers/pnp/manager.c
448 !Edrivers/pnp/support.c
452 <chapter id="blkdev">
453 <title>Block Devices</title>
457 <chapter id="chrdev">
458 <title>Char devices</title>
462 <chapter id="miscdev">
463 <title>Miscellaneous Devices</title>
464 !Edrivers/char/misc.c
467 <chapter id="parportdev">
468 <title>Parallel Port Devices</title>
469 !Iinclude/linux/parport.h
470 !Edrivers/parport/ieee1284.c
471 !Edrivers/parport/share.c
472 !Idrivers/parport/daisy.c
475 <chapter id="viddev">
476 <title>Video4Linux</title>
477 !Edrivers/media/video/videodev.c
480 <chapter id="snddev">
481 <title>Sound Devices</title>
482 !Iinclude/sound/core.h
484 !Iinclude/sound/pcm.h
486 !Esound/core/device.c
488 !Esound/core/rawmidi.c
490 !Esound/core/memory.c
491 !Esound/core/pcm_memory.c
493 !Esound/core/isadma.c
494 !Esound/core/control.c
495 !Esound/core/pcm_lib.c
497 !Esound/core/pcm_native.c
498 !Esound/core/memalloc.c
499 <!-- FIXME: Removed for now since no structured comments in source
500 X!Isound/sound_firmware.c
504 <chapter id="uart16x50">
505 <title>16x50 UART Driver</title>
506 !Iinclude/linux/serial_core.h
507 !Edrivers/serial/serial_core.c
508 !Edrivers/serial/8250.c
511 <chapter id="z85230">
512 <title>Z85230 Support Library</title>
513 !Edrivers/net/wan/z85230.c
517 <title>Frame Buffer Library</title>
520 The frame buffer drivers depend heavily on four data structures.
521 These structures are declared in include/linux/fb.h. They are
522 fb_info, fb_var_screeninfo, fb_fix_screeninfo and fb_monospecs.
523 The last three can be made available to and from userland.
527 fb_info defines the current state of a particular video card.
528 Inside fb_info, there exists a fb_ops structure which is a
529 collection of needed functions to make fbdev and fbcon work.
530 fb_info is only visible to the kernel.
534 fb_var_screeninfo is used to describe the features of a video card
535 that are user defined. With fb_var_screeninfo, things such as
536 depth and the resolution may be defined.
540 The next structure is fb_fix_screeninfo. This defines the
541 properties of a card that are created when a mode is set and can't
542 be changed otherwise. A good example of this is the start of the
543 frame buffer memory. This "locks" the address of the frame buffer
544 memory, so that it cannot be changed or moved.
548 The last structure is fb_monospecs. In the old API, there was
549 little importance for fb_monospecs. This allowed for forbidden things
550 such as setting a mode of 800x600 on a fix frequency monitor. With
551 the new API, fb_monospecs prevents such things, and if used
552 correctly, can prevent a monitor from being cooked. fb_monospecs
553 will not be useful until kernels 2.5.x.
556 <sect1><title>Frame Buffer Memory</title>
557 !Edrivers/video/fbmem.c
560 <sect1><title>Frame Buffer Console</title>
561 X!Edrivers/video/console/fbcon.c
564 <sect1><title>Frame Buffer Colormap</title>
565 !Edrivers/video/fbcmap.c
568 drivers/video/fbgen.c has no docs, which stuffs up the sgml. Comment
569 out until somebody adds docs. KAO
570 <sect1><title>Frame Buffer Generic Functions</title>
571 X!Idrivers/video/fbgen.c
574 <sect1><title>Frame Buffer Video Mode Database</title>
575 !Idrivers/video/modedb.c
576 !Edrivers/video/modedb.c
578 <sect1><title>Frame Buffer Macintosh Video Mode Database</title>
579 !Edrivers/video/macmodes.c
581 <sect1><title>Frame Buffer Fonts</title>
583 Refer to the file drivers/video/console/fonts.c for more information.
585 <!-- FIXME: Removed for now since no structured comments in source
586 X!Idrivers/video/console/fonts.c