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>Internal Functions</title>
65 !Iinclude/linux/kthread.h
69 <sect1><title>Kernel objects manipulation</title>
71 X!Iinclude/linux/kobject.h
76 <sect1><title>Kernel utility functions</title>
77 !Iinclude/linux/kernel.h
87 <title>Data Types</title>
88 <sect1><title>Doubly Linked Lists</title>
89 !Iinclude/linux/list.h
94 <title>Basic C Library Functions</title>
97 When writing drivers, you cannot in general use routines which are
98 from the C Library. Some of the functions have been found generally
99 useful and they are listed below. The behaviour of these functions
100 may vary slightly from those defined by ANSI, and these deviations
101 are noted in the text.
104 <sect1><title>String Conversions</title>
108 <sect1><title>String Manipulation</title>
109 <!-- All functions are exported at now
114 <sect1><title>Bit Operations</title>
115 !Iinclude/asm-i386/bitops.h
119 <chapter id="kernel-lib">
120 <title>Basic Kernel Library Functions</title>
123 The Linux kernel provides more basic utility functions.
126 <sect1><title>Bitmap Operations</title>
131 <sect1><title>Command-line Parsing</title>
135 <sect1><title>CRC Functions</title>
143 <title>Memory Management in Linux</title>
144 <sect1><title>The Slab Cache</title>
145 !Iinclude/linux/slab.h
148 <sect1><title>User Space Memory Access</title>
149 !Iinclude/asm-i386/uaccess.h
150 !Earch/i386/lib/usercopy.c
152 <sect1><title>More Memory Management Functions</title>
153 !Iinclude/linux/rmap.h
159 !Emm/page-writeback.c
166 <title>Kernel IPC facilities</title>
168 <sect1><title>IPC utilities</title>
174 <title>FIFO Buffer</title>
175 <sect1><title>kfifo interface</title>
176 !Iinclude/linux/kfifo.h
182 <title>The proc filesystem</title>
184 <sect1><title>sysctl interface</title>
188 <sect1><title>proc filesystem interface</title>
193 <chapter id="debugfs">
194 <title>The debugfs filesystem</title>
196 <sect1><title>debugfs interface</title>
203 <title>The Linux VFS</title>
204 <sect1><title>The Filesystem types</title>
207 <sect1><title>The Directory Cache</title>
209 !Iinclude/linux/dcache.h
211 <sect1><title>Inode Handling</title>
215 <sect1><title>Registration and Superblocks</title>
218 <sect1><title>File Locks</title>
222 <sect1><title>Other Functions</title>
234 <chapter id="netcore">
235 <title>Linux Networking</title>
236 <sect1><title>Networking Base Types</title>
237 !Iinclude/linux/net.h
239 <sect1><title>Socket Buffer Functions</title>
240 !Iinclude/linux/skbuff.h
245 !Enet/core/datagram.c
248 <sect1><title>Socket Filter</title>
251 <sect1><title>Generic Network Statistics</title>
252 !Iinclude/linux/gen_stats.h
253 !Enet/core/gen_stats.c
254 !Enet/core/gen_estimator.c
256 <sect1><title>SUN RPC subsystem</title>
257 <!-- The !D functionality is not perfect, garbage has to be protected by comments
258 !Dnet/sunrpc/sunrpc_syms.c
261 !Enet/sunrpc/svcsock.c
266 <chapter id="netdev">
267 <title>Network device support</title>
268 <sect1><title>Driver Support</title>
271 !Iinclude/linux/etherdevice.h
272 <!-- FIXME: Removed for now since no structured comments in source
273 X!Enet/core/wireless.c
276 <sect1><title>Synchronous PPP</title>
277 !Edrivers/net/wan/syncppp.c
281 <chapter id="modload">
282 <title>Module Support</title>
283 <sect1><title>Module Loading</title>
286 <sect1><title>Inter Module support</title>
288 Refer to the file kernel/module.c for more information.
290 <!-- FIXME: Removed for now since no structured comments in source
296 <chapter id="hardware">
297 <title>Hardware Interfaces</title>
298 <sect1><title>Interrupt Handling</title>
299 !Ekernel/irq/manage.c
302 <sect1><title>Resources Management</title>
306 <sect1><title>MTRR Handling</title>
307 !Earch/i386/kernel/cpu/mtrr/main.c
310 <sect1><title>PCI Support Library</title>
312 !Edrivers/pci/pci-driver.c
313 !Edrivers/pci/remove.c
314 !Edrivers/pci/pci-acpi.c
315 <!-- kerneldoc does not understand __devinit
316 X!Edrivers/pci/search.c
320 <!-- FIXME: Removed for now since no structured comments in source
321 X!Edrivers/pci/hotplug.c
323 !Edrivers/pci/probe.c
326 <sect1><title>PCI Hotplug Support Library</title>
327 !Edrivers/pci/hotplug/pci_hotplug_core.c
329 <sect1><title>MCA Architecture</title>
330 <sect2><title>MCA Device Functions</title>
332 Refer to the file arch/i386/kernel/mca.c for more information.
334 <!-- FIXME: Removed for now since no structured comments in source
335 X!Earch/i386/kernel/mca.c
338 <sect2><title>MCA Bus DMA</title>
339 !Iinclude/asm-i386/mca_dma.h
344 <chapter id="firmware">
345 <title>Firmware Interfaces</title>
346 <sect1><title>DMI Interfaces</title>
347 !Edrivers/firmware/dmi_scan.c
352 <title>The Device File System</title>
357 <title>The Filesystem for Exporting Kernel Objects</title>
363 <chapter id="security">
364 <title>Security Framework</title>
365 !Esecurity/security.c
369 <title>Audit Interfaces</title>
372 !Ikernel/auditfilter.c
375 <chapter id="accounting">
376 <title>Accounting Framework</title>
380 <chapter id="pmfuncs">
381 <title>Power Management</title>
385 <chapter id="devdrivers">
386 <title>Device drivers infrastructure</title>
387 <sect1><title>Device Drivers Base</title>
389 X!Iinclude/linux/device.h
391 !Edrivers/base/driver.c
392 !Edrivers/base/core.c
393 !Edrivers/base/firmware_class.c
394 !Edrivers/base/transport_class.c
395 !Edrivers/base/dmapool.c
396 <!-- Cannot be included, because
397 attribute_container_add_class_device_adapter
398 and attribute_container_classdev_to_container
399 exceed allowed 44 characters maximum
400 X!Edrivers/base/attribute_container.c
404 X!Edrivers/base/interface.c
406 !Edrivers/base/platform.c
409 <sect1><title>Device Drivers Power Management</title>
410 !Edrivers/base/power/main.c
411 !Edrivers/base/power/resume.c
412 !Edrivers/base/power/suspend.c
414 <sect1><title>Device Drivers ACPI Support</title>
415 <!-- Internal functions only
416 X!Edrivers/acpi/sleep/main.c
417 X!Edrivers/acpi/sleep/wakeup.c
418 X!Edrivers/acpi/motherboard.c
419 X!Edrivers/acpi/bus.c
421 !Edrivers/acpi/scan.c
422 !Idrivers/acpi/scan.c
423 <!-- No correct structured comments
424 X!Edrivers/acpi/pci_bind.c
427 <sect1><title>Device drivers PnP support</title>
429 <!-- No correct structured comments
430 X!Edrivers/pnp/system.c
433 !Edrivers/pnp/driver.c
434 !Edrivers/pnp/manager.c
435 !Edrivers/pnp/support.c
440 <chapter id="blkdev">
441 <title>Block Devices</title>
445 <chapter id="miscdev">
446 <title>Miscellaneous Devices</title>
447 !Edrivers/char/misc.c
450 <chapter id="viddev">
451 <title>Video4Linux</title>
452 !Edrivers/media/video/videodev.c
455 <chapter id="snddev">
456 <title>Sound Devices</title>
457 !Iinclude/sound/core.h
459 !Iinclude/sound/pcm.h
461 !Esound/core/device.c
463 !Esound/core/rawmidi.c
465 !Esound/core/memory.c
466 !Esound/core/pcm_memory.c
468 !Esound/core/isadma.c
469 !Esound/core/control.c
470 !Esound/core/pcm_lib.c
472 !Esound/core/pcm_native.c
473 !Esound/core/memalloc.c
474 <!-- FIXME: Removed for now since no structured comments in source
475 X!Isound/sound_firmware.c
479 <chapter id="uart16x50">
480 <title>16x50 UART Driver</title>
481 !Iinclude/linux/serial_core.h
482 !Edrivers/serial/serial_core.c
483 !Edrivers/serial/8250.c
486 <chapter id="z85230">
487 <title>Z85230 Support Library</title>
488 !Edrivers/net/wan/z85230.c
492 <title>Frame Buffer Library</title>
495 The frame buffer drivers depend heavily on four data structures.
496 These structures are declared in include/linux/fb.h. They are
497 fb_info, fb_var_screeninfo, fb_fix_screeninfo and fb_monospecs.
498 The last three can be made available to and from userland.
502 fb_info defines the current state of a particular video card.
503 Inside fb_info, there exists a fb_ops structure which is a
504 collection of needed functions to make fbdev and fbcon work.
505 fb_info is only visible to the kernel.
509 fb_var_screeninfo is used to describe the features of a video card
510 that are user defined. With fb_var_screeninfo, things such as
511 depth and the resolution may be defined.
515 The next structure is fb_fix_screeninfo. This defines the
516 properties of a card that are created when a mode is set and can't
517 be changed otherwise. A good example of this is the start of the
518 frame buffer memory. This "locks" the address of the frame buffer
519 memory, so that it cannot be changed or moved.
523 The last structure is fb_monospecs. In the old API, there was
524 little importance for fb_monospecs. This allowed for forbidden things
525 such as setting a mode of 800x600 on a fix frequency monitor. With
526 the new API, fb_monospecs prevents such things, and if used
527 correctly, can prevent a monitor from being cooked. fb_monospecs
528 will not be useful until kernels 2.5.x.
531 <sect1><title>Frame Buffer Memory</title>
532 !Edrivers/video/fbmem.c
535 <sect1><title>Frame Buffer Console</title>
536 X!Edrivers/video/console/fbcon.c
539 <sect1><title>Frame Buffer Colormap</title>
540 !Edrivers/video/fbcmap.c
543 drivers/video/fbgen.c has no docs, which stuffs up the sgml. Comment
544 out until somebody adds docs. KAO
545 <sect1><title>Frame Buffer Generic Functions</title>
546 X!Idrivers/video/fbgen.c
549 <sect1><title>Frame Buffer Video Mode Database</title>
550 !Idrivers/video/modedb.c
551 !Edrivers/video/modedb.c
553 <sect1><title>Frame Buffer Macintosh Video Mode Database</title>
554 !Edrivers/video/macmodes.c
556 <sect1><title>Frame Buffer Fonts</title>
558 Refer to the file drivers/video/console/fonts.c for more information.
560 <!-- FIXME: Removed for now since no structured comments in source
561 X!Idrivers/video/console/fonts.c