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>
67 <sect1><title>Kernel objects manipulation</title>
69 X!Iinclude/linux/kobject.h
74 <sect1><title>Kernel utility functions</title>
75 !Iinclude/linux/kernel.h
85 <title>Data Types</title>
86 <sect1><title>Doubly Linked Lists</title>
87 !Iinclude/linux/list.h
92 <title>Basic C Library Functions</title>
95 When writing drivers, you cannot in general use routines which are
96 from the C Library. Some of the functions have been found generally
97 useful and they are listed below. The behaviour of these functions
98 may vary slightly from those defined by ANSI, and these deviations
99 are noted in the text.
102 <sect1><title>String Conversions</title>
106 <sect1><title>String Manipulation</title>
107 <!-- All functions are exported at now
112 <sect1><title>Bit Operations</title>
113 !Iinclude/asm-i386/bitops.h
118 <title>Memory Management in Linux</title>
119 <sect1><title>The Slab Cache</title>
122 <sect1><title>User Space Memory Access</title>
123 !Iinclude/asm-i386/uaccess.h
124 !Earch/i386/lib/usercopy.c
126 <sect1><title>More Memory Management Functions</title>
127 !Iinclude/linux/rmap.h
133 !Emm/page-writeback.c
140 <title>Kernel IPC facilities</title>
142 <sect1><title>IPC utilities</title>
148 <title>FIFO Buffer</title>
149 <sect1><title>kfifo interface</title>
150 !Iinclude/linux/kfifo.h
156 <title>The proc filesystem</title>
158 <sect1><title>sysctl interface</title>
162 <sect1><title>proc filesystem interface</title>
167 <chapter id="debugfs">
168 <title>The debugfs filesystem</title>
170 <sect1><title>debugfs interface</title>
177 <title>The Linux VFS</title>
178 <sect1><title>The Filesystem types</title>
181 <sect1><title>The Directory Cache</title>
183 !Iinclude/linux/dcache.h
185 <sect1><title>Inode Handling</title>
189 <sect1><title>Registration and Superblocks</title>
192 <sect1><title>File Locks</title>
196 <sect1><title>Other Functions</title>
208 <chapter id="netcore">
209 <title>Linux Networking</title>
210 <sect1><title>Networking Base Types</title>
211 !Iinclude/linux/net.h
213 <sect1><title>Socket Buffer Functions</title>
214 !Iinclude/linux/skbuff.h
219 !Enet/core/datagram.c
222 <sect1><title>Socket Filter</title>
225 <sect1><title>Generic Network Statistics</title>
226 !Iinclude/linux/gen_stats.h
227 !Enet/core/gen_stats.c
228 !Enet/core/gen_estimator.c
230 <sect1><title>SUN RPC subsystem</title>
231 <!-- The !D functionality is not perfect, garbage has to be protected by comments
232 !Dnet/sunrpc/sunrpc_syms.c
235 !Enet/sunrpc/svcsock.c
240 <chapter id="netdev">
241 <title>Network device support</title>
242 <sect1><title>Driver Support</title>
245 !Iinclude/linux/etherdevice.h
246 <!-- FIXME: Removed for now since no structured comments in source
247 X!Enet/core/wireless.c
250 <sect1><title>Synchronous PPP</title>
251 !Edrivers/net/wan/syncppp.c
255 <chapter id="modload">
256 <title>Module Support</title>
257 <sect1><title>Module Loading</title>
260 <sect1><title>Inter Module support</title>
262 Refer to the file kernel/module.c for more information.
264 <!-- FIXME: Removed for now since no structured comments in source
270 <chapter id="hardware">
271 <title>Hardware Interfaces</title>
272 <sect1><title>Interrupt Handling</title>
273 !Ekernel/irq/manage.c
276 <sect1><title>Resources Management</title>
280 <sect1><title>MTRR Handling</title>
281 !Earch/i386/kernel/cpu/mtrr/main.c
283 <sect1><title>PCI Support Library</title>
285 !Edrivers/pci/pci-driver.c
286 !Edrivers/pci/remove.c
287 !Edrivers/pci/pci-acpi.c
288 <!-- kerneldoc does not understand to __devinit
289 X!Edrivers/pci/search.c
293 <!-- FIXME: Removed for now since no structured comments in source
294 X!Edrivers/pci/hotplug.c
296 !Edrivers/pci/probe.c
299 <sect1><title>PCI Hotplug Support Library</title>
300 !Edrivers/pci/hotplug/pci_hotplug_core.c
302 <sect1><title>MCA Architecture</title>
303 <sect2><title>MCA Device Functions</title>
305 Refer to the file arch/i386/kernel/mca.c for more information.
307 <!-- FIXME: Removed for now since no structured comments in source
308 X!Earch/i386/kernel/mca.c
311 <sect2><title>MCA Bus DMA</title>
312 !Iinclude/asm-i386/mca_dma.h
318 <title>The Device File System</title>
323 <title>The Filesystem for Exporting Kernel Objects</title>
329 <chapter id="security">
330 <title>Security Framework</title>
331 !Esecurity/security.c
334 <chapter id="pmfuncs">
335 <title>Power Management</title>
339 <chapter id="devdrivers">
340 <title>Device drivers infrastructure</title>
341 <sect1><title>Device Drivers Base</title>
343 X!Iinclude/linux/device.h
345 !Edrivers/base/driver.c
346 !Edrivers/base/core.c
347 !Edrivers/base/firmware_class.c
348 !Edrivers/base/transport_class.c
349 !Edrivers/base/dmapool.c
350 <!-- Cannot be included, because
351 attribute_container_add_class_device_adapter
352 and attribute_container_classdev_to_container
353 exceed allowed 44 characters maximum
354 X!Edrivers/base/attribute_container.c
358 X!Edrivers/base/interface.c
360 !Edrivers/base/platform.c
363 <sect1><title>Device Drivers Power Management</title>
364 !Edrivers/base/power/main.c
365 !Edrivers/base/power/resume.c
366 !Edrivers/base/power/suspend.c
368 <sect1><title>Device Drivers ACPI Support</title>
369 <!-- Internal functions only
370 X!Edrivers/acpi/sleep/main.c
371 X!Edrivers/acpi/sleep/wakeup.c
372 X!Edrivers/acpi/motherboard.c
373 X!Edrivers/acpi/bus.c
375 !Edrivers/acpi/scan.c
376 !Idrivers/acpi/scan.c
377 <!-- No correct structured comments
378 X!Edrivers/acpi/pci_bind.c
381 <sect1><title>Device drivers PnP support</title>
383 <!-- No correct structured comments
384 X!Edrivers/pnp/system.c
387 !Edrivers/pnp/driver.c
388 !Edrivers/pnp/manager.c
389 !Edrivers/pnp/support.c
394 <chapter id="blkdev">
395 <title>Block Devices</title>
399 <chapter id="miscdev">
400 <title>Miscellaneous Devices</title>
401 !Edrivers/char/misc.c
404 <chapter id="viddev">
405 <title>Video4Linux</title>
406 !Edrivers/media/video/videodev.c
409 <chapter id="snddev">
410 <title>Sound Devices</title>
411 !Iinclude/sound/core.h
413 !Iinclude/sound/pcm.h
415 !Esound/core/device.c
417 !Esound/core/rawmidi.c
419 !Esound/core/memory.c
420 !Esound/core/pcm_memory.c
422 !Esound/core/isadma.c
423 !Esound/core/control.c
424 !Esound/core/pcm_lib.c
426 !Esound/core/pcm_native.c
427 !Esound/core/memalloc.c
428 <!-- FIXME: Removed for now since no structured comments in source
429 X!Isound/sound_firmware.c
433 <chapter id="uart16x50">
434 <title>16x50 UART Driver</title>
435 !Iinclude/linux/serial_core.h
436 !Edrivers/serial/serial_core.c
437 !Edrivers/serial/8250.c
440 <chapter id="z85230">
441 <title>Z85230 Support Library</title>
442 !Edrivers/net/wan/z85230.c
446 <title>Frame Buffer Library</title>
449 The frame buffer drivers depend heavily on four data structures.
450 These structures are declared in include/linux/fb.h. They are
451 fb_info, fb_var_screeninfo, fb_fix_screeninfo and fb_monospecs.
452 The last three can be made available to and from userland.
456 fb_info defines the current state of a particular video card.
457 Inside fb_info, there exists a fb_ops structure which is a
458 collection of needed functions to make fbdev and fbcon work.
459 fb_info is only visible to the kernel.
463 fb_var_screeninfo is used to describe the features of a video card
464 that are user defined. With fb_var_screeninfo, things such as
465 depth and the resolution may be defined.
469 The next structure is fb_fix_screeninfo. This defines the
470 properties of a card that are created when a mode is set and can't
471 be changed otherwise. A good example of this is the start of the
472 frame buffer memory. This "locks" the address of the frame buffer
473 memory, so that it cannot be changed or moved.
477 The last structure is fb_monospecs. In the old API, there was
478 little importance for fb_monospecs. This allowed for forbidden things
479 such as setting a mode of 800x600 on a fix frequency monitor. With
480 the new API, fb_monospecs prevents such things, and if used
481 correctly, can prevent a monitor from being cooked. fb_monospecs
482 will not be useful until kernels 2.5.x.
485 <sect1><title>Frame Buffer Memory</title>
486 !Edrivers/video/fbmem.c
489 <sect1><title>Frame Buffer Console</title>
490 X!Edrivers/video/console/fbcon.c
493 <sect1><title>Frame Buffer Colormap</title>
494 !Edrivers/video/fbcmap.c
497 drivers/video/fbgen.c has no docs, which stuffs up the sgml. Comment
498 out until somebody adds docs. KAO
499 <sect1><title>Frame Buffer Generic Functions</title>
500 X!Idrivers/video/fbgen.c
503 <sect1><title>Frame Buffer Video Mode Database</title>
504 !Idrivers/video/modedb.c
505 !Edrivers/video/modedb.c
507 <sect1><title>Frame Buffer Macintosh Video Mode Database</title>
508 !Edrivers/video/macmodes.c
510 <sect1><title>Frame Buffer Fonts</title>
512 Refer to the file drivers/video/console/fonts.c for more information.
514 <!-- FIXME: Removed for now since no structured comments in source
515 X!Idrivers/video/console/fonts.c