blob: 920aed8465a875cc309d5432f722053a84598c9c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001<?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
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 <sect1><title>Delaying, scheduling, and timer routines</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -070053!Iinclude/linux/sched.h
54!Ekernel/sched.c
55!Ekernel/timer.c
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 </sect1>
Thomas Gleixnerdf784882006-01-09 20:52:33 -080057 <sect1><title>High-resolution timers</title>
58!Iinclude/linux/ktime.h
59!Iinclude/linux/hrtimer.h
60!Ekernel/hrtimer.c
61 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -070062 <sect1><title>Internal Functions</title>
63!Ikernel/exit.c
64!Ikernel/signal.c
65 </sect1>
66
67 <sect1><title>Kernel objects manipulation</title>
68<!--
69X!Iinclude/linux/kobject.h
70-->
71!Elib/kobject.c
72 </sect1>
73
74 <sect1><title>Kernel utility functions</title>
75!Iinclude/linux/kernel.h
Martin Waitzddad86c2005-11-13 16:08:14 -080076!Ekernel/printk.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -070077!Ekernel/panic.c
78!Ekernel/sys.c
79!Ekernel/rcupdate.c
80 </sect1>
81
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 </chapter>
83
84 <chapter id="adt">
85 <title>Data Types</title>
86 <sect1><title>Doubly Linked Lists</title>
87!Iinclude/linux/list.h
88 </sect1>
89 </chapter>
90
91 <chapter id="libc">
92 <title>Basic C Library Functions</title>
93
94 <para>
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.
100 </para>
101
102 <sect1><title>String Conversions</title>
103!Ilib/vsprintf.c
104!Elib/vsprintf.c
105 </sect1>
106 <sect1><title>String Manipulation</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700107<!-- All functions are exported at now
108X!Ilib/string.c
109 -->
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110!Elib/string.c
111 </sect1>
112 <sect1><title>Bit Operations</title>
113!Iinclude/asm-i386/bitops.h
114 </sect1>
Randy Dunlap6e1907ff2006-06-25 05:48:57 -0700115 <sect1><title>Bitmap Operations</title>
116!Elib/bitmap.c
117!Ilib/bitmap.c
118 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 </chapter>
120
121 <chapter id="mm">
122 <title>Memory Management in Linux</title>
123 <sect1><title>The Slab Cache</title>
Paul Drynoff800590f2006-06-23 02:03:48 -0700124!Iinclude/linux/slab.h
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125!Emm/slab.c
126 </sect1>
127 <sect1><title>User Space Memory Access</title>
128!Iinclude/asm-i386/uaccess.h
Randy Dunlap8f2709b2005-11-07 01:01:05 -0800129!Earch/i386/lib/usercopy.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700131 <sect1><title>More Memory Management Functions</title>
132!Iinclude/linux/rmap.h
133!Emm/readahead.c
134!Emm/filemap.c
135!Emm/memory.c
136!Emm/vmalloc.c
137!Emm/mempool.c
138!Emm/page-writeback.c
139!Emm/truncate.c
140 </sect1>
141 </chapter>
142
143
144 <chapter id="ipc">
145 <title>Kernel IPC facilities</title>
146
147 <sect1><title>IPC utilities</title>
148!Iipc/util.c
149 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 </chapter>
151
152 <chapter id="kfifo">
153 <title>FIFO Buffer</title>
154 <sect1><title>kfifo interface</title>
155!Iinclude/linux/kfifo.h
156!Ekernel/kfifo.c
157 </sect1>
158 </chapter>
159
160 <chapter id="proc">
161 <title>The proc filesystem</title>
162
163 <sect1><title>sysctl interface</title>
164!Ekernel/sysctl.c
165 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700166
167 <sect1><title>proc filesystem interface</title>
168!Ifs/proc/base.c
169 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 </chapter>
171
172 <chapter id="debugfs">
173 <title>The debugfs filesystem</title>
174
175 <sect1><title>debugfs interface</title>
176!Efs/debugfs/inode.c
177!Efs/debugfs/file.c
178 </sect1>
179 </chapter>
180
181 <chapter id="vfs">
182 <title>The Linux VFS</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700183 <sect1><title>The Filesystem types</title>
184!Iinclude/linux/fs.h
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700185 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186 <sect1><title>The Directory Cache</title>
187!Efs/dcache.c
188!Iinclude/linux/dcache.h
189 </sect1>
190 <sect1><title>Inode Handling</title>
191!Efs/inode.c
192!Efs/bad_inode.c
193 </sect1>
194 <sect1><title>Registration and Superblocks</title>
195!Efs/super.c
196 </sect1>
197 <sect1><title>File Locks</title>
198!Efs/locks.c
199!Ifs/locks.c
200 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700201 <sect1><title>Other Functions</title>
202!Efs/mpage.c
203!Efs/namei.c
204!Efs/buffer.c
205!Efs/bio.c
206!Efs/seq_file.c
207!Efs/filesystems.c
208!Efs/fs-writeback.c
209!Efs/block_dev.c
210 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211 </chapter>
212
213 <chapter id="netcore">
214 <title>Linux Networking</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700215 <sect1><title>Networking Base Types</title>
216!Iinclude/linux/net.h
217 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 <sect1><title>Socket Buffer Functions</title>
219!Iinclude/linux/skbuff.h
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700220!Iinclude/net/sock.h
221!Enet/socket.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222!Enet/core/skbuff.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700223!Enet/core/sock.c
224!Enet/core/datagram.c
225!Enet/core/stream.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226 </sect1>
227 <sect1><title>Socket Filter</title>
228!Enet/core/filter.c
229 </sect1>
230 <sect1><title>Generic Network Statistics</title>
231!Iinclude/linux/gen_stats.h
232!Enet/core/gen_stats.c
233!Enet/core/gen_estimator.c
234 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700235 <sect1><title>SUN RPC subsystem</title>
236<!-- The !D functionality is not perfect, garbage has to be protected by comments
237!Dnet/sunrpc/sunrpc_syms.c
238-->
239!Enet/sunrpc/xdr.c
240!Enet/sunrpc/svcsock.c
241!Enet/sunrpc/sched.c
242 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 </chapter>
244
245 <chapter id="netdev">
246 <title>Network device support</title>
247 <sect1><title>Driver Support</title>
248!Enet/core/dev.c
Stephen Hemmingerc2da8ac2005-11-01 17:05:09 -0800249!Enet/ethernet/eth.c
Randy Dunlap461ddf32005-11-20 21:25:15 -0800250!Iinclude/linux/etherdevice.h
251<!-- FIXME: Removed for now since no structured comments in source
252X!Enet/core/wireless.c
253-->
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 </sect1>
255 <sect1><title>Synchronous PPP</title>
256!Edrivers/net/wan/syncppp.c
257 </sect1>
258 </chapter>
259
260 <chapter id="modload">
261 <title>Module Support</title>
262 <sect1><title>Module Loading</title>
263!Ekernel/kmod.c
264 </sect1>
265 <sect1><title>Inter Module support</title>
266 <para>
267 Refer to the file kernel/module.c for more information.
268 </para>
269<!-- FIXME: Removed for now since no structured comments in source
270X!Ekernel/module.c
271-->
272 </sect1>
273 </chapter>
274
275 <chapter id="hardware">
276 <title>Hardware Interfaces</title>
277 <sect1><title>Interrupt Handling</title>
Randy Dunlap8f2709b2005-11-07 01:01:05 -0800278!Ekernel/irq/manage.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279 </sect1>
280
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700281 <sect1><title>Resources Management</title>
282!Ekernel/resource.c
283 </sect1>
284
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285 <sect1><title>MTRR Handling</title>
286!Earch/i386/kernel/cpu/mtrr/main.c
287 </sect1>
288 <sect1><title>PCI Support Library</title>
289!Edrivers/pci/pci.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700290!Edrivers/pci/pci-driver.c
291!Edrivers/pci/remove.c
292!Edrivers/pci/pci-acpi.c
293<!-- kerneldoc does not understand to __devinit
294X!Edrivers/pci/search.c
295 -->
296!Edrivers/pci/msi.c
297!Edrivers/pci/bus.c
Randy Dunlapf05aab82005-10-23 11:58:19 -0700298<!-- FIXME: Removed for now since no structured comments in source
299X!Edrivers/pci/hotplug.c
300-->
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700301!Edrivers/pci/probe.c
302!Edrivers/pci/rom.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303 </sect1>
304 <sect1><title>PCI Hotplug Support Library</title>
305!Edrivers/pci/hotplug/pci_hotplug_core.c
306 </sect1>
307 <sect1><title>MCA Architecture</title>
308 <sect2><title>MCA Device Functions</title>
309 <para>
310 Refer to the file arch/i386/kernel/mca.c for more information.
311 </para>
312<!-- FIXME: Removed for now since no structured comments in source
313X!Earch/i386/kernel/mca.c
314-->
315 </sect2>
316 <sect2><title>MCA Bus DMA</title>
317!Iinclude/asm-i386/mca_dma.h
318 </sect2>
319 </sect1>
320 </chapter>
321
322 <chapter id="devfs">
323 <title>The Device File System</title>
324!Efs/devfs/base.c
325 </chapter>
326
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700327 <chapter id="sysfs">
328 <title>The Filesystem for Exporting Kernel Objects</title>
329!Efs/sysfs/file.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700330!Efs/sysfs/symlink.c
331!Efs/sysfs/bin.c
332 </chapter>
333
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 <chapter id="security">
335 <title>Security Framework</title>
336!Esecurity/security.c
337 </chapter>
338
Randy Dunlap862f5f02006-06-23 02:05:52 -0700339 <chapter id="audit">
340 <title>Audit Interfaces</title>
341!Ekernel/audit.c
342!Ikernel/auditsc.c
343!Ikernel/auditfilter.c
344 </chapter>
345
346 <chapter id="accounting">
347 <title>Accounting Framework</title>
348!Ikernel/acct.c
349 </chapter>
350
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351 <chapter id="pmfuncs">
352 <title>Power Management</title>
353!Ekernel/power/pm.c
354 </chapter>
355
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700356 <chapter id="devdrivers">
357 <title>Device drivers infrastructure</title>
358 <sect1><title>Device Drivers Base</title>
359<!--
360X!Iinclude/linux/device.h
361-->
362!Edrivers/base/driver.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700363!Edrivers/base/core.c
364!Edrivers/base/firmware_class.c
365!Edrivers/base/transport_class.c
366!Edrivers/base/dmapool.c
367<!-- Cannot be included, because
368 attribute_container_add_class_device_adapter
369 and attribute_container_classdev_to_container
370 exceed allowed 44 characters maximum
371X!Edrivers/base/attribute_container.c
372-->
373!Edrivers/base/sys.c
374<!--
375X!Edrivers/base/interface.c
376-->
377!Edrivers/base/platform.c
378!Edrivers/base/bus.c
379 </sect1>
380 <sect1><title>Device Drivers Power Management</title>
381!Edrivers/base/power/main.c
382!Edrivers/base/power/resume.c
383!Edrivers/base/power/suspend.c
384 </sect1>
385 <sect1><title>Device Drivers ACPI Support</title>
386<!-- Internal functions only
387X!Edrivers/acpi/sleep/main.c
388X!Edrivers/acpi/sleep/wakeup.c
389X!Edrivers/acpi/motherboard.c
390X!Edrivers/acpi/bus.c
391-->
392!Edrivers/acpi/scan.c
Randy Dunlapd758a8f2006-01-06 01:31:00 -0500393!Idrivers/acpi/scan.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700394<!-- No correct structured comments
395X!Edrivers/acpi/pci_bind.c
396-->
397 </sect1>
398 <sect1><title>Device drivers PnP support</title>
399!Edrivers/pnp/core.c
400<!-- No correct structured comments
401X!Edrivers/pnp/system.c
402 -->
403!Edrivers/pnp/card.c
404!Edrivers/pnp/driver.c
405!Edrivers/pnp/manager.c
406!Edrivers/pnp/support.c
407 </sect1>
408 </chapter>
409
410
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 <chapter id="blkdev">
412 <title>Block Devices</title>
Ben Collins1d193f42005-11-15 00:09:21 -0800413!Eblock/ll_rw_blk.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414 </chapter>
415
416 <chapter id="miscdev">
417 <title>Miscellaneous Devices</title>
418!Edrivers/char/misc.c
419 </chapter>
420
421 <chapter id="viddev">
422 <title>Video4Linux</title>
423!Edrivers/media/video/videodev.c
424 </chapter>
425
426 <chapter id="snddev">
427 <title>Sound Devices</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700428!Iinclude/sound/core.h
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429!Esound/sound_core.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700430!Iinclude/sound/pcm.h
431!Esound/core/pcm.c
432!Esound/core/device.c
433!Esound/core/info.c
434!Esound/core/rawmidi.c
435!Esound/core/sound.c
436!Esound/core/memory.c
437!Esound/core/pcm_memory.c
438!Esound/core/init.c
439!Esound/core/isadma.c
440!Esound/core/control.c
441!Esound/core/pcm_lib.c
442!Esound/core/hwdep.c
443!Esound/core/pcm_native.c
444!Esound/core/memalloc.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445<!-- FIXME: Removed for now since no structured comments in source
446X!Isound/sound_firmware.c
447-->
448 </chapter>
449
450 <chapter id="uart16x50">
451 <title>16x50 UART Driver</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700452!Iinclude/linux/serial_core.h
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453!Edrivers/serial/serial_core.c
454!Edrivers/serial/8250.c
455 </chapter>
456
457 <chapter id="z85230">
458 <title>Z85230 Support Library</title>
459!Edrivers/net/wan/z85230.c
460 </chapter>
461
462 <chapter id="fbdev">
463 <title>Frame Buffer Library</title>
464
465 <para>
466 The frame buffer drivers depend heavily on four data structures.
467 These structures are declared in include/linux/fb.h. They are
468 fb_info, fb_var_screeninfo, fb_fix_screeninfo and fb_monospecs.
469 The last three can be made available to and from userland.
470 </para>
471
472 <para>
473 fb_info defines the current state of a particular video card.
474 Inside fb_info, there exists a fb_ops structure which is a
475 collection of needed functions to make fbdev and fbcon work.
476 fb_info is only visible to the kernel.
477 </para>
478
479 <para>
480 fb_var_screeninfo is used to describe the features of a video card
481 that are user defined. With fb_var_screeninfo, things such as
482 depth and the resolution may be defined.
483 </para>
484
485 <para>
486 The next structure is fb_fix_screeninfo. This defines the
487 properties of a card that are created when a mode is set and can't
488 be changed otherwise. A good example of this is the start of the
489 frame buffer memory. This "locks" the address of the frame buffer
490 memory, so that it cannot be changed or moved.
491 </para>
492
493 <para>
494 The last structure is fb_monospecs. In the old API, there was
495 little importance for fb_monospecs. This allowed for forbidden things
496 such as setting a mode of 800x600 on a fix frequency monitor. With
497 the new API, fb_monospecs prevents such things, and if used
498 correctly, can prevent a monitor from being cooked. fb_monospecs
499 will not be useful until kernels 2.5.x.
500 </para>
501
502 <sect1><title>Frame Buffer Memory</title>
503!Edrivers/video/fbmem.c
504 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700505<!--
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 <sect1><title>Frame Buffer Console</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700507X!Edrivers/video/console/fbcon.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700509-->
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 <sect1><title>Frame Buffer Colormap</title>
511!Edrivers/video/fbcmap.c
512 </sect1>
513<!-- FIXME:
514 drivers/video/fbgen.c has no docs, which stuffs up the sgml. Comment
515 out until somebody adds docs. KAO
516 <sect1><title>Frame Buffer Generic Functions</title>
517X!Idrivers/video/fbgen.c
518 </sect1>
519KAO -->
520 <sect1><title>Frame Buffer Video Mode Database</title>
521!Idrivers/video/modedb.c
522!Edrivers/video/modedb.c
523 </sect1>
524 <sect1><title>Frame Buffer Macintosh Video Mode Database</title>
Randy Dunlap8f2709b2005-11-07 01:01:05 -0800525!Edrivers/video/macmodes.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 </sect1>
527 <sect1><title>Frame Buffer Fonts</title>
528 <para>
529 Refer to the file drivers/video/console/fonts.c for more information.
530 </para>
531<!-- FIXME: Removed for now since no structured comments in source
532X!Idrivers/video/console/fonts.c
533-->
534 </sect1>
535 </chapter>
536</book>