blob: 8c9c6704e85bab5e26b6f28b2240e96346cc5660 [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>
115 </chapter>
116
117 <chapter id="mm">
118 <title>Memory Management in Linux</title>
119 <sect1><title>The Slab Cache</title>
120!Emm/slab.c
121 </sect1>
122 <sect1><title>User Space Memory Access</title>
123!Iinclude/asm-i386/uaccess.h
Randy Dunlap8f2709b2005-11-07 01:01:05 -0800124!Earch/i386/lib/usercopy.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700126 <sect1><title>More Memory Management Functions</title>
127!Iinclude/linux/rmap.h
128!Emm/readahead.c
129!Emm/filemap.c
130!Emm/memory.c
131!Emm/vmalloc.c
132!Emm/mempool.c
133!Emm/page-writeback.c
134!Emm/truncate.c
135 </sect1>
136 </chapter>
137
138
139 <chapter id="ipc">
140 <title>Kernel IPC facilities</title>
141
142 <sect1><title>IPC utilities</title>
143!Iipc/util.c
144 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 </chapter>
146
147 <chapter id="kfifo">
148 <title>FIFO Buffer</title>
149 <sect1><title>kfifo interface</title>
150!Iinclude/linux/kfifo.h
151!Ekernel/kfifo.c
152 </sect1>
153 </chapter>
154
155 <chapter id="proc">
156 <title>The proc filesystem</title>
157
158 <sect1><title>sysctl interface</title>
159!Ekernel/sysctl.c
160 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700161
162 <sect1><title>proc filesystem interface</title>
163!Ifs/proc/base.c
164 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 </chapter>
166
167 <chapter id="debugfs">
168 <title>The debugfs filesystem</title>
169
170 <sect1><title>debugfs interface</title>
171!Efs/debugfs/inode.c
172!Efs/debugfs/file.c
173 </sect1>
174 </chapter>
175
176 <chapter id="vfs">
177 <title>The Linux VFS</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700178 <sect1><title>The Filesystem types</title>
179!Iinclude/linux/fs.h
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700180 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181 <sect1><title>The Directory Cache</title>
182!Efs/dcache.c
183!Iinclude/linux/dcache.h
184 </sect1>
185 <sect1><title>Inode Handling</title>
186!Efs/inode.c
187!Efs/bad_inode.c
188 </sect1>
189 <sect1><title>Registration and Superblocks</title>
190!Efs/super.c
191 </sect1>
192 <sect1><title>File Locks</title>
193!Efs/locks.c
194!Ifs/locks.c
195 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700196 <sect1><title>Other Functions</title>
197!Efs/mpage.c
198!Efs/namei.c
199!Efs/buffer.c
200!Efs/bio.c
201!Efs/seq_file.c
202!Efs/filesystems.c
203!Efs/fs-writeback.c
204!Efs/block_dev.c
205 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206 </chapter>
207
208 <chapter id="netcore">
209 <title>Linux Networking</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700210 <sect1><title>Networking Base Types</title>
211!Iinclude/linux/net.h
212 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 <sect1><title>Socket Buffer Functions</title>
214!Iinclude/linux/skbuff.h
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700215!Iinclude/net/sock.h
216!Enet/socket.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217!Enet/core/skbuff.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700218!Enet/core/sock.c
219!Enet/core/datagram.c
220!Enet/core/stream.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 </sect1>
222 <sect1><title>Socket Filter</title>
223!Enet/core/filter.c
224 </sect1>
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
229 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700230 <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
233-->
234!Enet/sunrpc/xdr.c
235!Enet/sunrpc/svcsock.c
236!Enet/sunrpc/sched.c
237 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238 </chapter>
239
240 <chapter id="netdev">
241 <title>Network device support</title>
242 <sect1><title>Driver Support</title>
243!Enet/core/dev.c
Stephen Hemmingerc2da8ac2005-11-01 17:05:09 -0800244!Enet/ethernet/eth.c
Randy Dunlap461ddf32005-11-20 21:25:15 -0800245!Iinclude/linux/etherdevice.h
246<!-- FIXME: Removed for now since no structured comments in source
247X!Enet/core/wireless.c
248-->
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 </sect1>
250 <sect1><title>Synchronous PPP</title>
251!Edrivers/net/wan/syncppp.c
252 </sect1>
253 </chapter>
254
255 <chapter id="modload">
256 <title>Module Support</title>
257 <sect1><title>Module Loading</title>
258!Ekernel/kmod.c
259 </sect1>
260 <sect1><title>Inter Module support</title>
261 <para>
262 Refer to the file kernel/module.c for more information.
263 </para>
264<!-- FIXME: Removed for now since no structured comments in source
265X!Ekernel/module.c
266-->
267 </sect1>
268 </chapter>
269
270 <chapter id="hardware">
271 <title>Hardware Interfaces</title>
272 <sect1><title>Interrupt Handling</title>
Randy Dunlap8f2709b2005-11-07 01:01:05 -0800273!Ekernel/irq/manage.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274 </sect1>
275
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700276 <sect1><title>Resources Management</title>
277!Ekernel/resource.c
278 </sect1>
279
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280 <sect1><title>MTRR Handling</title>
281!Earch/i386/kernel/cpu/mtrr/main.c
282 </sect1>
283 <sect1><title>PCI Support Library</title>
284!Edrivers/pci/pci.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700285!Edrivers/pci/pci-driver.c
286!Edrivers/pci/remove.c
287!Edrivers/pci/pci-acpi.c
288<!-- kerneldoc does not understand to __devinit
289X!Edrivers/pci/search.c
290 -->
291!Edrivers/pci/msi.c
292!Edrivers/pci/bus.c
Randy Dunlapf05aab82005-10-23 11:58:19 -0700293<!-- FIXME: Removed for now since no structured comments in source
294X!Edrivers/pci/hotplug.c
295-->
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700296!Edrivers/pci/probe.c
297!Edrivers/pci/rom.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 </sect1>
299 <sect1><title>PCI Hotplug Support Library</title>
300!Edrivers/pci/hotplug/pci_hotplug_core.c
301 </sect1>
302 <sect1><title>MCA Architecture</title>
303 <sect2><title>MCA Device Functions</title>
304 <para>
305 Refer to the file arch/i386/kernel/mca.c for more information.
306 </para>
307<!-- FIXME: Removed for now since no structured comments in source
308X!Earch/i386/kernel/mca.c
309-->
310 </sect2>
311 <sect2><title>MCA Bus DMA</title>
312!Iinclude/asm-i386/mca_dma.h
313 </sect2>
314 </sect1>
315 </chapter>
316
317 <chapter id="devfs">
318 <title>The Device File System</title>
319!Efs/devfs/base.c
320 </chapter>
321
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700322 <chapter id="sysfs">
323 <title>The Filesystem for Exporting Kernel Objects</title>
324!Efs/sysfs/file.c
325!Efs/sysfs/dir.c
326!Efs/sysfs/symlink.c
327!Efs/sysfs/bin.c
328 </chapter>
329
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 <chapter id="security">
331 <title>Security Framework</title>
332!Esecurity/security.c
333 </chapter>
334
335 <chapter id="pmfuncs">
336 <title>Power Management</title>
337!Ekernel/power/pm.c
338 </chapter>
339
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700340 <chapter id="devdrivers">
341 <title>Device drivers infrastructure</title>
342 <sect1><title>Device Drivers Base</title>
343<!--
344X!Iinclude/linux/device.h
345-->
346!Edrivers/base/driver.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700347!Edrivers/base/core.c
348!Edrivers/base/firmware_class.c
349!Edrivers/base/transport_class.c
350!Edrivers/base/dmapool.c
351<!-- Cannot be included, because
352 attribute_container_add_class_device_adapter
353 and attribute_container_classdev_to_container
354 exceed allowed 44 characters maximum
355X!Edrivers/base/attribute_container.c
356-->
357!Edrivers/base/sys.c
358<!--
359X!Edrivers/base/interface.c
360-->
361!Edrivers/base/platform.c
362!Edrivers/base/bus.c
363 </sect1>
364 <sect1><title>Device Drivers Power Management</title>
365!Edrivers/base/power/main.c
366!Edrivers/base/power/resume.c
367!Edrivers/base/power/suspend.c
368 </sect1>
369 <sect1><title>Device Drivers ACPI Support</title>
370<!-- Internal functions only
371X!Edrivers/acpi/sleep/main.c
372X!Edrivers/acpi/sleep/wakeup.c
373X!Edrivers/acpi/motherboard.c
374X!Edrivers/acpi/bus.c
375-->
376!Edrivers/acpi/scan.c
Randy Dunlapd758a8f2006-01-06 01:31:00 -0500377!Idrivers/acpi/scan.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700378<!-- No correct structured comments
379X!Edrivers/acpi/pci_bind.c
380-->
381 </sect1>
382 <sect1><title>Device drivers PnP support</title>
383!Edrivers/pnp/core.c
384<!-- No correct structured comments
385X!Edrivers/pnp/system.c
386 -->
387!Edrivers/pnp/card.c
388!Edrivers/pnp/driver.c
389!Edrivers/pnp/manager.c
390!Edrivers/pnp/support.c
391 </sect1>
392 </chapter>
393
394
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395 <chapter id="blkdev">
396 <title>Block Devices</title>
Ben Collins1d193f42005-11-15 00:09:21 -0800397!Eblock/ll_rw_blk.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398 </chapter>
399
400 <chapter id="miscdev">
401 <title>Miscellaneous Devices</title>
402!Edrivers/char/misc.c
403 </chapter>
404
405 <chapter id="viddev">
406 <title>Video4Linux</title>
407!Edrivers/media/video/videodev.c
408 </chapter>
409
410 <chapter id="snddev">
411 <title>Sound Devices</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700412!Iinclude/sound/core.h
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413!Esound/sound_core.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700414!Iinclude/sound/pcm.h
415!Esound/core/pcm.c
416!Esound/core/device.c
417!Esound/core/info.c
418!Esound/core/rawmidi.c
419!Esound/core/sound.c
420!Esound/core/memory.c
421!Esound/core/pcm_memory.c
422!Esound/core/init.c
423!Esound/core/isadma.c
424!Esound/core/control.c
425!Esound/core/pcm_lib.c
426!Esound/core/hwdep.c
427!Esound/core/pcm_native.c
428!Esound/core/memalloc.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429<!-- FIXME: Removed for now since no structured comments in source
430X!Isound/sound_firmware.c
431-->
432 </chapter>
433
434 <chapter id="uart16x50">
435 <title>16x50 UART Driver</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700436!Iinclude/linux/serial_core.h
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437!Edrivers/serial/serial_core.c
438!Edrivers/serial/8250.c
439 </chapter>
440
441 <chapter id="z85230">
442 <title>Z85230 Support Library</title>
443!Edrivers/net/wan/z85230.c
444 </chapter>
445
446 <chapter id="fbdev">
447 <title>Frame Buffer Library</title>
448
449 <para>
450 The frame buffer drivers depend heavily on four data structures.
451 These structures are declared in include/linux/fb.h. They are
452 fb_info, fb_var_screeninfo, fb_fix_screeninfo and fb_monospecs.
453 The last three can be made available to and from userland.
454 </para>
455
456 <para>
457 fb_info defines the current state of a particular video card.
458 Inside fb_info, there exists a fb_ops structure which is a
459 collection of needed functions to make fbdev and fbcon work.
460 fb_info is only visible to the kernel.
461 </para>
462
463 <para>
464 fb_var_screeninfo is used to describe the features of a video card
465 that are user defined. With fb_var_screeninfo, things such as
466 depth and the resolution may be defined.
467 </para>
468
469 <para>
470 The next structure is fb_fix_screeninfo. This defines the
471 properties of a card that are created when a mode is set and can't
472 be changed otherwise. A good example of this is the start of the
473 frame buffer memory. This "locks" the address of the frame buffer
474 memory, so that it cannot be changed or moved.
475 </para>
476
477 <para>
478 The last structure is fb_monospecs. In the old API, there was
479 little importance for fb_monospecs. This allowed for forbidden things
480 such as setting a mode of 800x600 on a fix frequency monitor. With
481 the new API, fb_monospecs prevents such things, and if used
482 correctly, can prevent a monitor from being cooked. fb_monospecs
483 will not be useful until kernels 2.5.x.
484 </para>
485
486 <sect1><title>Frame Buffer Memory</title>
487!Edrivers/video/fbmem.c
488 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700489<!--
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 <sect1><title>Frame Buffer Console</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700491X!Edrivers/video/console/fbcon.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700493-->
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 <sect1><title>Frame Buffer Colormap</title>
495!Edrivers/video/fbcmap.c
496 </sect1>
497<!-- FIXME:
498 drivers/video/fbgen.c has no docs, which stuffs up the sgml. Comment
499 out until somebody adds docs. KAO
500 <sect1><title>Frame Buffer Generic Functions</title>
501X!Idrivers/video/fbgen.c
502 </sect1>
503KAO -->
504 <sect1><title>Frame Buffer Video Mode Database</title>
505!Idrivers/video/modedb.c
506!Edrivers/video/modedb.c
507 </sect1>
508 <sect1><title>Frame Buffer Macintosh Video Mode Database</title>
Randy Dunlap8f2709b2005-11-07 01:01:05 -0800509!Edrivers/video/macmodes.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 </sect1>
511 <sect1><title>Frame Buffer Fonts</title>
512 <para>
513 Refer to the file drivers/video/console/fonts.c for more information.
514 </para>
515<!-- FIXME: Removed for now since no structured comments in source
516X!Idrivers/video/console/fonts.c
517-->
518 </sect1>
519 </chapter>
520</book>