blob: ca02e04a906c219acfd21b8a72c827bd7f0b31e4 [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
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700325!Efs/sysfs/symlink.c
326!Efs/sysfs/bin.c
327 </chapter>
328
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329 <chapter id="security">
330 <title>Security Framework</title>
331!Esecurity/security.c
332 </chapter>
333
334 <chapter id="pmfuncs">
335 <title>Power Management</title>
336!Ekernel/power/pm.c
337 </chapter>
338
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700339 <chapter id="devdrivers">
340 <title>Device drivers infrastructure</title>
341 <sect1><title>Device Drivers Base</title>
342<!--
343X!Iinclude/linux/device.h
344-->
345!Edrivers/base/driver.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700346!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
354X!Edrivers/base/attribute_container.c
355-->
356!Edrivers/base/sys.c
357<!--
358X!Edrivers/base/interface.c
359-->
360!Edrivers/base/platform.c
361!Edrivers/base/bus.c
362 </sect1>
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
367 </sect1>
368 <sect1><title>Device Drivers ACPI Support</title>
369<!-- Internal functions only
370X!Edrivers/acpi/sleep/main.c
371X!Edrivers/acpi/sleep/wakeup.c
372X!Edrivers/acpi/motherboard.c
373X!Edrivers/acpi/bus.c
374-->
375!Edrivers/acpi/scan.c
Randy Dunlapd758a8f2006-01-06 01:31:00 -0500376!Idrivers/acpi/scan.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700377<!-- No correct structured comments
378X!Edrivers/acpi/pci_bind.c
379-->
380 </sect1>
381 <sect1><title>Device drivers PnP support</title>
382!Edrivers/pnp/core.c
383<!-- No correct structured comments
384X!Edrivers/pnp/system.c
385 -->
386!Edrivers/pnp/card.c
387!Edrivers/pnp/driver.c
388!Edrivers/pnp/manager.c
389!Edrivers/pnp/support.c
390 </sect1>
391 </chapter>
392
393
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394 <chapter id="blkdev">
395 <title>Block Devices</title>
Ben Collins1d193f42005-11-15 00:09:21 -0800396!Eblock/ll_rw_blk.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397 </chapter>
398
399 <chapter id="miscdev">
400 <title>Miscellaneous Devices</title>
401!Edrivers/char/misc.c
402 </chapter>
403
404 <chapter id="viddev">
405 <title>Video4Linux</title>
406!Edrivers/media/video/videodev.c
407 </chapter>
408
409 <chapter id="snddev">
410 <title>Sound Devices</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700411!Iinclude/sound/core.h
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412!Esound/sound_core.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700413!Iinclude/sound/pcm.h
414!Esound/core/pcm.c
415!Esound/core/device.c
416!Esound/core/info.c
417!Esound/core/rawmidi.c
418!Esound/core/sound.c
419!Esound/core/memory.c
420!Esound/core/pcm_memory.c
421!Esound/core/init.c
422!Esound/core/isadma.c
423!Esound/core/control.c
424!Esound/core/pcm_lib.c
425!Esound/core/hwdep.c
426!Esound/core/pcm_native.c
427!Esound/core/memalloc.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428<!-- FIXME: Removed for now since no structured comments in source
429X!Isound/sound_firmware.c
430-->
431 </chapter>
432
433 <chapter id="uart16x50">
434 <title>16x50 UART Driver</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700435!Iinclude/linux/serial_core.h
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436!Edrivers/serial/serial_core.c
437!Edrivers/serial/8250.c
438 </chapter>
439
440 <chapter id="z85230">
441 <title>Z85230 Support Library</title>
442!Edrivers/net/wan/z85230.c
443 </chapter>
444
445 <chapter id="fbdev">
446 <title>Frame Buffer Library</title>
447
448 <para>
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.
453 </para>
454
455 <para>
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.
460 </para>
461
462 <para>
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.
466 </para>
467
468 <para>
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.
474 </para>
475
476 <para>
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.
483 </para>
484
485 <sect1><title>Frame Buffer Memory</title>
486!Edrivers/video/fbmem.c
487 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700488<!--
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489 <sect1><title>Frame Buffer Console</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700490X!Edrivers/video/console/fbcon.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700492-->
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 <sect1><title>Frame Buffer Colormap</title>
494!Edrivers/video/fbcmap.c
495 </sect1>
496<!-- FIXME:
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>
500X!Idrivers/video/fbgen.c
501 </sect1>
502KAO -->
503 <sect1><title>Frame Buffer Video Mode Database</title>
504!Idrivers/video/modedb.c
505!Edrivers/video/modedb.c
506 </sect1>
507 <sect1><title>Frame Buffer Macintosh Video Mode Database</title>
Randy Dunlap8f2709b2005-11-07 01:01:05 -0800508!Edrivers/video/macmodes.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509 </sect1>
510 <sect1><title>Frame Buffer Fonts</title>
511 <para>
512 Refer to the file drivers/video/console/fonts.c for more information.
513 </para>
514<!-- FIXME: Removed for now since no structured comments in source
515X!Idrivers/video/console/fonts.c
516-->
517 </sect1>
518 </chapter>
519</book>