blob: 428c217d9e87cd2844ef176f4fb634d285ec8979 [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 Dunlap28e83ba2006-06-25 05:48:58 -0700115 </chapter>
116
117 <chapter id="kernel-lib">
118 <title>Basic Kernel Library Functions</title>
119
120 <para>
121 The Linux kernel provides more basic utility functions.
122 </para>
123
Randy Dunlap6e1907ff2006-06-25 05:48:57 -0700124 <sect1><title>Bitmap Operations</title>
125!Elib/bitmap.c
126!Ilib/bitmap.c
127 </sect1>
Randy Dunlap28e83ba2006-06-25 05:48:58 -0700128
129 <sect1><title>Command-line Parsing</title>
130!Elib/cmdline.c
131 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 </chapter>
133
134 <chapter id="mm">
135 <title>Memory Management in Linux</title>
136 <sect1><title>The Slab Cache</title>
Paul Drynoff800590f2006-06-23 02:03:48 -0700137!Iinclude/linux/slab.h
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138!Emm/slab.c
139 </sect1>
140 <sect1><title>User Space Memory Access</title>
141!Iinclude/asm-i386/uaccess.h
Randy Dunlap8f2709b2005-11-07 01:01:05 -0800142!Earch/i386/lib/usercopy.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700144 <sect1><title>More Memory Management Functions</title>
145!Iinclude/linux/rmap.h
146!Emm/readahead.c
147!Emm/filemap.c
148!Emm/memory.c
149!Emm/vmalloc.c
150!Emm/mempool.c
151!Emm/page-writeback.c
152!Emm/truncate.c
153 </sect1>
154 </chapter>
155
156
157 <chapter id="ipc">
158 <title>Kernel IPC facilities</title>
159
160 <sect1><title>IPC utilities</title>
161!Iipc/util.c
162 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163 </chapter>
164
165 <chapter id="kfifo">
166 <title>FIFO Buffer</title>
167 <sect1><title>kfifo interface</title>
168!Iinclude/linux/kfifo.h
169!Ekernel/kfifo.c
170 </sect1>
171 </chapter>
172
173 <chapter id="proc">
174 <title>The proc filesystem</title>
175
176 <sect1><title>sysctl interface</title>
177!Ekernel/sysctl.c
178 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700179
180 <sect1><title>proc filesystem interface</title>
181!Ifs/proc/base.c
182 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183 </chapter>
184
185 <chapter id="debugfs">
186 <title>The debugfs filesystem</title>
187
188 <sect1><title>debugfs interface</title>
189!Efs/debugfs/inode.c
190!Efs/debugfs/file.c
191 </sect1>
192 </chapter>
193
194 <chapter id="vfs">
195 <title>The Linux VFS</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700196 <sect1><title>The Filesystem types</title>
197!Iinclude/linux/fs.h
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700198 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199 <sect1><title>The Directory Cache</title>
200!Efs/dcache.c
201!Iinclude/linux/dcache.h
202 </sect1>
203 <sect1><title>Inode Handling</title>
204!Efs/inode.c
205!Efs/bad_inode.c
206 </sect1>
207 <sect1><title>Registration and Superblocks</title>
208!Efs/super.c
209 </sect1>
210 <sect1><title>File Locks</title>
211!Efs/locks.c
212!Ifs/locks.c
213 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700214 <sect1><title>Other Functions</title>
215!Efs/mpage.c
216!Efs/namei.c
217!Efs/buffer.c
218!Efs/bio.c
219!Efs/seq_file.c
220!Efs/filesystems.c
221!Efs/fs-writeback.c
222!Efs/block_dev.c
223 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224 </chapter>
225
226 <chapter id="netcore">
227 <title>Linux Networking</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700228 <sect1><title>Networking Base Types</title>
229!Iinclude/linux/net.h
230 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 <sect1><title>Socket Buffer Functions</title>
232!Iinclude/linux/skbuff.h
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700233!Iinclude/net/sock.h
234!Enet/socket.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235!Enet/core/skbuff.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700236!Enet/core/sock.c
237!Enet/core/datagram.c
238!Enet/core/stream.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 </sect1>
240 <sect1><title>Socket Filter</title>
241!Enet/core/filter.c
242 </sect1>
243 <sect1><title>Generic Network Statistics</title>
244!Iinclude/linux/gen_stats.h
245!Enet/core/gen_stats.c
246!Enet/core/gen_estimator.c
247 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700248 <sect1><title>SUN RPC subsystem</title>
249<!-- The !D functionality is not perfect, garbage has to be protected by comments
250!Dnet/sunrpc/sunrpc_syms.c
251-->
252!Enet/sunrpc/xdr.c
253!Enet/sunrpc/svcsock.c
254!Enet/sunrpc/sched.c
255 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 </chapter>
257
258 <chapter id="netdev">
259 <title>Network device support</title>
260 <sect1><title>Driver Support</title>
261!Enet/core/dev.c
Stephen Hemmingerc2da8ac2005-11-01 17:05:09 -0800262!Enet/ethernet/eth.c
Randy Dunlap461ddf32005-11-20 21:25:15 -0800263!Iinclude/linux/etherdevice.h
264<!-- FIXME: Removed for now since no structured comments in source
265X!Enet/core/wireless.c
266-->
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267 </sect1>
268 <sect1><title>Synchronous PPP</title>
269!Edrivers/net/wan/syncppp.c
270 </sect1>
271 </chapter>
272
273 <chapter id="modload">
274 <title>Module Support</title>
275 <sect1><title>Module Loading</title>
276!Ekernel/kmod.c
277 </sect1>
278 <sect1><title>Inter Module support</title>
279 <para>
280 Refer to the file kernel/module.c for more information.
281 </para>
282<!-- FIXME: Removed for now since no structured comments in source
283X!Ekernel/module.c
284-->
285 </sect1>
286 </chapter>
287
288 <chapter id="hardware">
289 <title>Hardware Interfaces</title>
290 <sect1><title>Interrupt Handling</title>
Randy Dunlap8f2709b2005-11-07 01:01:05 -0800291!Ekernel/irq/manage.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292 </sect1>
293
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700294 <sect1><title>Resources Management</title>
295!Ekernel/resource.c
296 </sect1>
297
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 <sect1><title>MTRR Handling</title>
299!Earch/i386/kernel/cpu/mtrr/main.c
300 </sect1>
301 <sect1><title>PCI Support Library</title>
302!Edrivers/pci/pci.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700303!Edrivers/pci/pci-driver.c
304!Edrivers/pci/remove.c
305!Edrivers/pci/pci-acpi.c
306<!-- kerneldoc does not understand to __devinit
307X!Edrivers/pci/search.c
308 -->
309!Edrivers/pci/msi.c
310!Edrivers/pci/bus.c
Randy Dunlapf05aab82005-10-23 11:58:19 -0700311<!-- FIXME: Removed for now since no structured comments in source
312X!Edrivers/pci/hotplug.c
313-->
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700314!Edrivers/pci/probe.c
315!Edrivers/pci/rom.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 </sect1>
317 <sect1><title>PCI Hotplug Support Library</title>
318!Edrivers/pci/hotplug/pci_hotplug_core.c
319 </sect1>
320 <sect1><title>MCA Architecture</title>
321 <sect2><title>MCA Device Functions</title>
322 <para>
323 Refer to the file arch/i386/kernel/mca.c for more information.
324 </para>
325<!-- FIXME: Removed for now since no structured comments in source
326X!Earch/i386/kernel/mca.c
327-->
328 </sect2>
329 <sect2><title>MCA Bus DMA</title>
330!Iinclude/asm-i386/mca_dma.h
331 </sect2>
332 </sect1>
333 </chapter>
334
335 <chapter id="devfs">
336 <title>The Device File System</title>
337!Efs/devfs/base.c
338 </chapter>
339
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700340 <chapter id="sysfs">
341 <title>The Filesystem for Exporting Kernel Objects</title>
342!Efs/sysfs/file.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700343!Efs/sysfs/symlink.c
344!Efs/sysfs/bin.c
345 </chapter>
346
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347 <chapter id="security">
348 <title>Security Framework</title>
349!Esecurity/security.c
350 </chapter>
351
Randy Dunlap862f5f02006-06-23 02:05:52 -0700352 <chapter id="audit">
353 <title>Audit Interfaces</title>
354!Ekernel/audit.c
355!Ikernel/auditsc.c
356!Ikernel/auditfilter.c
357 </chapter>
358
359 <chapter id="accounting">
360 <title>Accounting Framework</title>
361!Ikernel/acct.c
362 </chapter>
363
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364 <chapter id="pmfuncs">
365 <title>Power Management</title>
366!Ekernel/power/pm.c
367 </chapter>
368
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700369 <chapter id="devdrivers">
370 <title>Device drivers infrastructure</title>
371 <sect1><title>Device Drivers Base</title>
372<!--
373X!Iinclude/linux/device.h
374-->
375!Edrivers/base/driver.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700376!Edrivers/base/core.c
377!Edrivers/base/firmware_class.c
378!Edrivers/base/transport_class.c
379!Edrivers/base/dmapool.c
380<!-- Cannot be included, because
381 attribute_container_add_class_device_adapter
382 and attribute_container_classdev_to_container
383 exceed allowed 44 characters maximum
384X!Edrivers/base/attribute_container.c
385-->
386!Edrivers/base/sys.c
387<!--
388X!Edrivers/base/interface.c
389-->
390!Edrivers/base/platform.c
391!Edrivers/base/bus.c
392 </sect1>
393 <sect1><title>Device Drivers Power Management</title>
394!Edrivers/base/power/main.c
395!Edrivers/base/power/resume.c
396!Edrivers/base/power/suspend.c
397 </sect1>
398 <sect1><title>Device Drivers ACPI Support</title>
399<!-- Internal functions only
400X!Edrivers/acpi/sleep/main.c
401X!Edrivers/acpi/sleep/wakeup.c
402X!Edrivers/acpi/motherboard.c
403X!Edrivers/acpi/bus.c
404-->
405!Edrivers/acpi/scan.c
Randy Dunlapd758a8f2006-01-06 01:31:00 -0500406!Idrivers/acpi/scan.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700407<!-- No correct structured comments
408X!Edrivers/acpi/pci_bind.c
409-->
410 </sect1>
411 <sect1><title>Device drivers PnP support</title>
412!Edrivers/pnp/core.c
413<!-- No correct structured comments
414X!Edrivers/pnp/system.c
415 -->
416!Edrivers/pnp/card.c
417!Edrivers/pnp/driver.c
418!Edrivers/pnp/manager.c
419!Edrivers/pnp/support.c
420 </sect1>
421 </chapter>
422
423
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424 <chapter id="blkdev">
425 <title>Block Devices</title>
Ben Collins1d193f42005-11-15 00:09:21 -0800426!Eblock/ll_rw_blk.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427 </chapter>
428
429 <chapter id="miscdev">
430 <title>Miscellaneous Devices</title>
431!Edrivers/char/misc.c
432 </chapter>
433
434 <chapter id="viddev">
435 <title>Video4Linux</title>
436!Edrivers/media/video/videodev.c
437 </chapter>
438
439 <chapter id="snddev">
440 <title>Sound Devices</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700441!Iinclude/sound/core.h
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442!Esound/sound_core.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700443!Iinclude/sound/pcm.h
444!Esound/core/pcm.c
445!Esound/core/device.c
446!Esound/core/info.c
447!Esound/core/rawmidi.c
448!Esound/core/sound.c
449!Esound/core/memory.c
450!Esound/core/pcm_memory.c
451!Esound/core/init.c
452!Esound/core/isadma.c
453!Esound/core/control.c
454!Esound/core/pcm_lib.c
455!Esound/core/hwdep.c
456!Esound/core/pcm_native.c
457!Esound/core/memalloc.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458<!-- FIXME: Removed for now since no structured comments in source
459X!Isound/sound_firmware.c
460-->
461 </chapter>
462
463 <chapter id="uart16x50">
464 <title>16x50 UART Driver</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700465!Iinclude/linux/serial_core.h
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466!Edrivers/serial/serial_core.c
467!Edrivers/serial/8250.c
468 </chapter>
469
470 <chapter id="z85230">
471 <title>Z85230 Support Library</title>
472!Edrivers/net/wan/z85230.c
473 </chapter>
474
475 <chapter id="fbdev">
476 <title>Frame Buffer Library</title>
477
478 <para>
479 The frame buffer drivers depend heavily on four data structures.
480 These structures are declared in include/linux/fb.h. They are
481 fb_info, fb_var_screeninfo, fb_fix_screeninfo and fb_monospecs.
482 The last three can be made available to and from userland.
483 </para>
484
485 <para>
486 fb_info defines the current state of a particular video card.
487 Inside fb_info, there exists a fb_ops structure which is a
488 collection of needed functions to make fbdev and fbcon work.
489 fb_info is only visible to the kernel.
490 </para>
491
492 <para>
493 fb_var_screeninfo is used to describe the features of a video card
494 that are user defined. With fb_var_screeninfo, things such as
495 depth and the resolution may be defined.
496 </para>
497
498 <para>
499 The next structure is fb_fix_screeninfo. This defines the
500 properties of a card that are created when a mode is set and can't
501 be changed otherwise. A good example of this is the start of the
502 frame buffer memory. This "locks" the address of the frame buffer
503 memory, so that it cannot be changed or moved.
504 </para>
505
506 <para>
507 The last structure is fb_monospecs. In the old API, there was
508 little importance for fb_monospecs. This allowed for forbidden things
509 such as setting a mode of 800x600 on a fix frequency monitor. With
510 the new API, fb_monospecs prevents such things, and if used
511 correctly, can prevent a monitor from being cooked. fb_monospecs
512 will not be useful until kernels 2.5.x.
513 </para>
514
515 <sect1><title>Frame Buffer Memory</title>
516!Edrivers/video/fbmem.c
517 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700518<!--
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519 <sect1><title>Frame Buffer Console</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700520X!Edrivers/video/console/fbcon.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700522-->
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 <sect1><title>Frame Buffer Colormap</title>
524!Edrivers/video/fbcmap.c
525 </sect1>
526<!-- FIXME:
527 drivers/video/fbgen.c has no docs, which stuffs up the sgml. Comment
528 out until somebody adds docs. KAO
529 <sect1><title>Frame Buffer Generic Functions</title>
530X!Idrivers/video/fbgen.c
531 </sect1>
532KAO -->
533 <sect1><title>Frame Buffer Video Mode Database</title>
534!Idrivers/video/modedb.c
535!Edrivers/video/modedb.c
536 </sect1>
537 <sect1><title>Frame Buffer Macintosh Video Mode Database</title>
Randy Dunlap8f2709b2005-11-07 01:01:05 -0800538!Edrivers/video/macmodes.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539 </sect1>
540 <sect1><title>Frame Buffer Fonts</title>
541 <para>
542 Refer to the file drivers/video/console/fonts.c for more information.
543 </para>
544<!-- FIXME: Removed for now since no structured comments in source
545X!Idrivers/video/console/fonts.c
546-->
547 </sect1>
548 </chapter>
549</book>