blob: f8fe882e33dccfc50f6e5add6ca89a53389d649f [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>
Rolf Eike Beer0fcb78c2006-07-30 03:03:42 -070062 <sect1><title>Workqueues and Kevents</title>
63!Ekernel/workqueue.c
64 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -070065 <sect1><title>Internal Functions</title>
66!Ikernel/exit.c
67!Ikernel/signal.c
Randy Dunlap9e37bd32006-06-25 05:49:19 -070068!Iinclude/linux/kthread.h
69!Ekernel/kthread.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -070070 </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
Martin Waitzddad86c2005-11-13 16:08:14 -080081!Ekernel/printk.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -070082!Ekernel/panic.c
83!Ekernel/sys.c
84!Ekernel/rcupdate.c
85 </sect1>
86
Linus Torvalds1da177e2005-04-16 15:20:36 -070087 </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>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700112<!-- All functions are exported at now
113X!Ilib/string.c
114 -->
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115!Elib/string.c
116 </sect1>
117 <sect1><title>Bit Operations</title>
118!Iinclude/asm-i386/bitops.h
119 </sect1>
Randy Dunlap28e83ba2006-06-25 05:48:58 -0700120 </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
Randy Dunlap6e1907ff2006-06-25 05:48:57 -0700129 <sect1><title>Bitmap Operations</title>
130!Elib/bitmap.c
131!Ilib/bitmap.c
132 </sect1>
Randy Dunlap28e83ba2006-06-25 05:48:58 -0700133
134 <sect1><title>Command-line Parsing</title>
135!Elib/cmdline.c
136 </sect1>
Randy Dunlap2f721002006-06-25 05:48:59 -0700137
138 <sect1><title>CRC Functions</title>
139!Elib/crc16.c
140!Elib/crc32.c
141!Elib/crc-ccitt.c
142 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 </chapter>
144
145 <chapter id="mm">
146 <title>Memory Management in Linux</title>
147 <sect1><title>The Slab Cache</title>
Paul Drynoff800590f2006-06-23 02:03:48 -0700148!Iinclude/linux/slab.h
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149!Emm/slab.c
150 </sect1>
151 <sect1><title>User Space Memory Access</title>
152!Iinclude/asm-i386/uaccess.h
Randy Dunlap8f2709b2005-11-07 01:01:05 -0800153!Earch/i386/lib/usercopy.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700155 <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>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174 </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>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700190
191 <sect1><title>proc filesystem interface</title>
192!Ifs/proc/base.c
193 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194 </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>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700207 <sect1><title>The Filesystem types</title>
208!Iinclude/linux/fs.h
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700209 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 <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>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700225 <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>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235 </chapter>
236
237 <chapter id="netcore">
238 <title>Linux Networking</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700239 <sect1><title>Networking Base Types</title>
240!Iinclude/linux/net.h
241 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 <sect1><title>Socket Buffer Functions</title>
243!Iinclude/linux/skbuff.h
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700244!Iinclude/net/sock.h
245!Enet/socket.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246!Enet/core/skbuff.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700247!Enet/core/sock.c
248!Enet/core/datagram.c
249!Enet/core/stream.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 </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>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700259 <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>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267 </chapter>
268
269 <chapter id="netdev">
270 <title>Network device support</title>
271 <sect1><title>Driver Support</title>
272!Enet/core/dev.c
Stephen Hemmingerc2da8ac2005-11-01 17:05:09 -0800273!Enet/ethernet/eth.c
Randy Dunlap461ddf32005-11-20 21:25:15 -0800274!Iinclude/linux/etherdevice.h
275<!-- FIXME: Removed for now since no structured comments in source
276X!Enet/core/wireless.c
277-->
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278 </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>
Randy Dunlap8f2709b2005-11-07 01:01:05 -0800302!Ekernel/irq/manage.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303 </sect1>
304
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700305 <sect1><title>Resources Management</title>
Randy Dunlap2b549602006-07-30 03:03:40 -0700306!Ikernel/resource.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700307 </sect1>
308
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 <sect1><title>MTRR Handling</title>
310!Earch/i386/kernel/cpu/mtrr/main.c
311 </sect1>
Randy Dunlapb0ef3712006-06-25 05:49:18 -0700312
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313 <sect1><title>PCI Support Library</title>
314!Edrivers/pci/pci.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700315!Edrivers/pci/pci-driver.c
316!Edrivers/pci/remove.c
317!Edrivers/pci/pci-acpi.c
Randy Dunlapd75763d2006-07-30 03:03:41 -0700318!Edrivers/pci/search.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700319!Edrivers/pci/msi.c
320!Edrivers/pci/bus.c
Randy Dunlapf05aab82005-10-23 11:58:19 -0700321<!-- FIXME: Removed for now since no structured comments in source
322X!Edrivers/pci/hotplug.c
323-->
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700324!Edrivers/pci/probe.c
325!Edrivers/pci/rom.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 </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
Randy Dunlapb0ef3712006-06-25 05:49:18 -0700345 <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
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700352 <chapter id="sysfs">
353 <title>The Filesystem for Exporting Kernel Objects</title>
354!Efs/sysfs/file.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700355!Efs/sysfs/symlink.c
356!Efs/sysfs/bin.c
357 </chapter>
358
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 <chapter id="security">
360 <title>Security Framework</title>
361!Esecurity/security.c
362 </chapter>
363
Randy Dunlap862f5f02006-06-23 02:05:52 -0700364 <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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376 <chapter id="pmfuncs">
377 <title>Power Management</title>
378!Ekernel/power/pm.c
379 </chapter>
380
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700381 <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
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700388!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
Randy Dunlapd758a8f2006-01-06 01:31:00 -0500418!Idrivers/acpi/scan.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700419<!-- 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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 <chapter id="blkdev">
436 <title>Block Devices</title>
Ben Collins1d193f42005-11-15 00:09:21 -0800437!Eblock/ll_rw_blk.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438 </chapter>
439
440 <chapter id="miscdev">
441 <title>Miscellaneous Devices</title>
442!Edrivers/char/misc.c
443 </chapter>
444
Randy Dunlap7d469722006-06-25 05:49:29 -0700445 <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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453 <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>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700460!Iinclude/sound/core.h
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461!Esound/sound_core.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700462!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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477<!-- 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>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700484!Iinclude/linux/serial_core.h
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485!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>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700537<!--
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 <sect1><title>Frame Buffer Console</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700539X!Edrivers/video/console/fbcon.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700541-->
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542 <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>
Randy Dunlap8f2709b2005-11-07 01:01:05 -0800557!Edrivers/video/macmodes.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 </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>