blob: 31b727ceb127b109838464b9137474c90a4355f6 [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>
Paul Drynoff800590f2006-06-23 02:03:48 -0700120!Iinclude/linux/slab.h
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121!Emm/slab.c
122 </sect1>
123 <sect1><title>User Space Memory Access</title>
124!Iinclude/asm-i386/uaccess.h
Randy Dunlap8f2709b2005-11-07 01:01:05 -0800125!Earch/i386/lib/usercopy.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700127 <sect1><title>More Memory Management Functions</title>
128!Iinclude/linux/rmap.h
129!Emm/readahead.c
130!Emm/filemap.c
131!Emm/memory.c
132!Emm/vmalloc.c
133!Emm/mempool.c
134!Emm/page-writeback.c
135!Emm/truncate.c
136 </sect1>
137 </chapter>
138
139
140 <chapter id="ipc">
141 <title>Kernel IPC facilities</title>
142
143 <sect1><title>IPC utilities</title>
144!Iipc/util.c
145 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 </chapter>
147
148 <chapter id="kfifo">
149 <title>FIFO Buffer</title>
150 <sect1><title>kfifo interface</title>
151!Iinclude/linux/kfifo.h
152!Ekernel/kfifo.c
153 </sect1>
154 </chapter>
155
156 <chapter id="proc">
157 <title>The proc filesystem</title>
158
159 <sect1><title>sysctl interface</title>
160!Ekernel/sysctl.c
161 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700162
163 <sect1><title>proc filesystem interface</title>
164!Ifs/proc/base.c
165 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166 </chapter>
167
168 <chapter id="debugfs">
169 <title>The debugfs filesystem</title>
170
171 <sect1><title>debugfs interface</title>
172!Efs/debugfs/inode.c
173!Efs/debugfs/file.c
174 </sect1>
175 </chapter>
176
177 <chapter id="vfs">
178 <title>The Linux VFS</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700179 <sect1><title>The Filesystem types</title>
180!Iinclude/linux/fs.h
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700181 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182 <sect1><title>The Directory Cache</title>
183!Efs/dcache.c
184!Iinclude/linux/dcache.h
185 </sect1>
186 <sect1><title>Inode Handling</title>
187!Efs/inode.c
188!Efs/bad_inode.c
189 </sect1>
190 <sect1><title>Registration and Superblocks</title>
191!Efs/super.c
192 </sect1>
193 <sect1><title>File Locks</title>
194!Efs/locks.c
195!Ifs/locks.c
196 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700197 <sect1><title>Other Functions</title>
198!Efs/mpage.c
199!Efs/namei.c
200!Efs/buffer.c
201!Efs/bio.c
202!Efs/seq_file.c
203!Efs/filesystems.c
204!Efs/fs-writeback.c
205!Efs/block_dev.c
206 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 </chapter>
208
209 <chapter id="netcore">
210 <title>Linux Networking</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700211 <sect1><title>Networking Base Types</title>
212!Iinclude/linux/net.h
213 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 <sect1><title>Socket Buffer Functions</title>
215!Iinclude/linux/skbuff.h
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700216!Iinclude/net/sock.h
217!Enet/socket.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218!Enet/core/skbuff.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700219!Enet/core/sock.c
220!Enet/core/datagram.c
221!Enet/core/stream.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222 </sect1>
223 <sect1><title>Socket Filter</title>
224!Enet/core/filter.c
225 </sect1>
226 <sect1><title>Generic Network Statistics</title>
227!Iinclude/linux/gen_stats.h
228!Enet/core/gen_stats.c
229!Enet/core/gen_estimator.c
230 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700231 <sect1><title>SUN RPC subsystem</title>
232<!-- The !D functionality is not perfect, garbage has to be protected by comments
233!Dnet/sunrpc/sunrpc_syms.c
234-->
235!Enet/sunrpc/xdr.c
236!Enet/sunrpc/svcsock.c
237!Enet/sunrpc/sched.c
238 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 </chapter>
240
241 <chapter id="netdev">
242 <title>Network device support</title>
243 <sect1><title>Driver Support</title>
244!Enet/core/dev.c
Stephen Hemmingerc2da8ac2005-11-01 17:05:09 -0800245!Enet/ethernet/eth.c
Randy Dunlap461ddf32005-11-20 21:25:15 -0800246!Iinclude/linux/etherdevice.h
247<!-- FIXME: Removed for now since no structured comments in source
248X!Enet/core/wireless.c
249-->
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 </sect1>
251 <sect1><title>Synchronous PPP</title>
252!Edrivers/net/wan/syncppp.c
253 </sect1>
254 </chapter>
255
256 <chapter id="modload">
257 <title>Module Support</title>
258 <sect1><title>Module Loading</title>
259!Ekernel/kmod.c
260 </sect1>
261 <sect1><title>Inter Module support</title>
262 <para>
263 Refer to the file kernel/module.c for more information.
264 </para>
265<!-- FIXME: Removed for now since no structured comments in source
266X!Ekernel/module.c
267-->
268 </sect1>
269 </chapter>
270
271 <chapter id="hardware">
272 <title>Hardware Interfaces</title>
273 <sect1><title>Interrupt Handling</title>
Randy Dunlap8f2709b2005-11-07 01:01:05 -0800274!Ekernel/irq/manage.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275 </sect1>
276
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700277 <sect1><title>Resources Management</title>
278!Ekernel/resource.c
279 </sect1>
280
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281 <sect1><title>MTRR Handling</title>
282!Earch/i386/kernel/cpu/mtrr/main.c
283 </sect1>
284 <sect1><title>PCI Support Library</title>
285!Edrivers/pci/pci.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700286!Edrivers/pci/pci-driver.c
287!Edrivers/pci/remove.c
288!Edrivers/pci/pci-acpi.c
289<!-- kerneldoc does not understand to __devinit
290X!Edrivers/pci/search.c
291 -->
292!Edrivers/pci/msi.c
293!Edrivers/pci/bus.c
Randy Dunlapf05aab82005-10-23 11:58:19 -0700294<!-- FIXME: Removed for now since no structured comments in source
295X!Edrivers/pci/hotplug.c
296-->
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700297!Edrivers/pci/probe.c
298!Edrivers/pci/rom.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299 </sect1>
300 <sect1><title>PCI Hotplug Support Library</title>
301!Edrivers/pci/hotplug/pci_hotplug_core.c
302 </sect1>
303 <sect1><title>MCA Architecture</title>
304 <sect2><title>MCA Device Functions</title>
305 <para>
306 Refer to the file arch/i386/kernel/mca.c for more information.
307 </para>
308<!-- FIXME: Removed for now since no structured comments in source
309X!Earch/i386/kernel/mca.c
310-->
311 </sect2>
312 <sect2><title>MCA Bus DMA</title>
313!Iinclude/asm-i386/mca_dma.h
314 </sect2>
315 </sect1>
316 </chapter>
317
318 <chapter id="devfs">
319 <title>The Device File System</title>
320!Efs/devfs/base.c
321 </chapter>
322
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700323 <chapter id="sysfs">
324 <title>The Filesystem for Exporting Kernel Objects</title>
325!Efs/sysfs/file.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700326!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
Randy Dunlap862f5f02006-06-23 02:05:52 -0700335 <chapter id="audit">
336 <title>Audit Interfaces</title>
337!Ekernel/audit.c
338!Ikernel/auditsc.c
339!Ikernel/auditfilter.c
340 </chapter>
341
342 <chapter id="accounting">
343 <title>Accounting Framework</title>
344!Ikernel/acct.c
345 </chapter>
346
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347 <chapter id="pmfuncs">
348 <title>Power Management</title>
349!Ekernel/power/pm.c
350 </chapter>
351
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700352 <chapter id="devdrivers">
353 <title>Device drivers infrastructure</title>
354 <sect1><title>Device Drivers Base</title>
355<!--
356X!Iinclude/linux/device.h
357-->
358!Edrivers/base/driver.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700359!Edrivers/base/core.c
360!Edrivers/base/firmware_class.c
361!Edrivers/base/transport_class.c
362!Edrivers/base/dmapool.c
363<!-- Cannot be included, because
364 attribute_container_add_class_device_adapter
365 and attribute_container_classdev_to_container
366 exceed allowed 44 characters maximum
367X!Edrivers/base/attribute_container.c
368-->
369!Edrivers/base/sys.c
370<!--
371X!Edrivers/base/interface.c
372-->
373!Edrivers/base/platform.c
374!Edrivers/base/bus.c
375 </sect1>
376 <sect1><title>Device Drivers Power Management</title>
377!Edrivers/base/power/main.c
378!Edrivers/base/power/resume.c
379!Edrivers/base/power/suspend.c
380 </sect1>
381 <sect1><title>Device Drivers ACPI Support</title>
382<!-- Internal functions only
383X!Edrivers/acpi/sleep/main.c
384X!Edrivers/acpi/sleep/wakeup.c
385X!Edrivers/acpi/motherboard.c
386X!Edrivers/acpi/bus.c
387-->
388!Edrivers/acpi/scan.c
Randy Dunlapd758a8f2006-01-06 01:31:00 -0500389!Idrivers/acpi/scan.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700390<!-- No correct structured comments
391X!Edrivers/acpi/pci_bind.c
392-->
393 </sect1>
394 <sect1><title>Device drivers PnP support</title>
395!Edrivers/pnp/core.c
396<!-- No correct structured comments
397X!Edrivers/pnp/system.c
398 -->
399!Edrivers/pnp/card.c
400!Edrivers/pnp/driver.c
401!Edrivers/pnp/manager.c
402!Edrivers/pnp/support.c
403 </sect1>
404 </chapter>
405
406
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 <chapter id="blkdev">
408 <title>Block Devices</title>
Ben Collins1d193f42005-11-15 00:09:21 -0800409!Eblock/ll_rw_blk.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 </chapter>
411
412 <chapter id="miscdev">
413 <title>Miscellaneous Devices</title>
414!Edrivers/char/misc.c
415 </chapter>
416
417 <chapter id="viddev">
418 <title>Video4Linux</title>
419!Edrivers/media/video/videodev.c
420 </chapter>
421
422 <chapter id="snddev">
423 <title>Sound Devices</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700424!Iinclude/sound/core.h
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425!Esound/sound_core.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700426!Iinclude/sound/pcm.h
427!Esound/core/pcm.c
428!Esound/core/device.c
429!Esound/core/info.c
430!Esound/core/rawmidi.c
431!Esound/core/sound.c
432!Esound/core/memory.c
433!Esound/core/pcm_memory.c
434!Esound/core/init.c
435!Esound/core/isadma.c
436!Esound/core/control.c
437!Esound/core/pcm_lib.c
438!Esound/core/hwdep.c
439!Esound/core/pcm_native.c
440!Esound/core/memalloc.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441<!-- FIXME: Removed for now since no structured comments in source
442X!Isound/sound_firmware.c
443-->
444 </chapter>
445
446 <chapter id="uart16x50">
447 <title>16x50 UART Driver</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700448!Iinclude/linux/serial_core.h
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449!Edrivers/serial/serial_core.c
450!Edrivers/serial/8250.c
451 </chapter>
452
453 <chapter id="z85230">
454 <title>Z85230 Support Library</title>
455!Edrivers/net/wan/z85230.c
456 </chapter>
457
458 <chapter id="fbdev">
459 <title>Frame Buffer Library</title>
460
461 <para>
462 The frame buffer drivers depend heavily on four data structures.
463 These structures are declared in include/linux/fb.h. They are
464 fb_info, fb_var_screeninfo, fb_fix_screeninfo and fb_monospecs.
465 The last three can be made available to and from userland.
466 </para>
467
468 <para>
469 fb_info defines the current state of a particular video card.
470 Inside fb_info, there exists a fb_ops structure which is a
471 collection of needed functions to make fbdev and fbcon work.
472 fb_info is only visible to the kernel.
473 </para>
474
475 <para>
476 fb_var_screeninfo is used to describe the features of a video card
477 that are user defined. With fb_var_screeninfo, things such as
478 depth and the resolution may be defined.
479 </para>
480
481 <para>
482 The next structure is fb_fix_screeninfo. This defines the
483 properties of a card that are created when a mode is set and can't
484 be changed otherwise. A good example of this is the start of the
485 frame buffer memory. This "locks" the address of the frame buffer
486 memory, so that it cannot be changed or moved.
487 </para>
488
489 <para>
490 The last structure is fb_monospecs. In the old API, there was
491 little importance for fb_monospecs. This allowed for forbidden things
492 such as setting a mode of 800x600 on a fix frequency monitor. With
493 the new API, fb_monospecs prevents such things, and if used
494 correctly, can prevent a monitor from being cooked. fb_monospecs
495 will not be useful until kernels 2.5.x.
496 </para>
497
498 <sect1><title>Frame Buffer Memory</title>
499!Edrivers/video/fbmem.c
500 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700501<!--
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 <sect1><title>Frame Buffer Console</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700503X!Edrivers/video/console/fbcon.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700505-->
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 <sect1><title>Frame Buffer Colormap</title>
507!Edrivers/video/fbcmap.c
508 </sect1>
509<!-- FIXME:
510 drivers/video/fbgen.c has no docs, which stuffs up the sgml. Comment
511 out until somebody adds docs. KAO
512 <sect1><title>Frame Buffer Generic Functions</title>
513X!Idrivers/video/fbgen.c
514 </sect1>
515KAO -->
516 <sect1><title>Frame Buffer Video Mode Database</title>
517!Idrivers/video/modedb.c
518!Edrivers/video/modedb.c
519 </sect1>
520 <sect1><title>Frame Buffer Macintosh Video Mode Database</title>
Randy Dunlap8f2709b2005-11-07 01:01:05 -0800521!Edrivers/video/macmodes.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 </sect1>
523 <sect1><title>Frame Buffer Fonts</title>
524 <para>
525 Refer to the file drivers/video/console/fonts.c for more information.
526 </para>
527<!-- FIXME: Removed for now since no structured comments in source
528X!Idrivers/video/console/fonts.c
529-->
530 </sect1>
531 </chapter>
532</book>