blob: f75ab4c1b281119672df234624f1ae7aa80919c2 [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
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 <chapter id="adt">
42 <title>Data Types</title>
43 <sect1><title>Doubly Linked Lists</title>
44!Iinclude/linux/list.h
45 </sect1>
46 </chapter>
47
48 <chapter id="libc">
49 <title>Basic C Library Functions</title>
50
51 <para>
52 When writing drivers, you cannot in general use routines which are
53 from the C Library. Some of the functions have been found generally
54 useful and they are listed below. The behaviour of these functions
55 may vary slightly from those defined by ANSI, and these deviations
56 are noted in the text.
57 </para>
58
59 <sect1><title>String Conversions</title>
Linus Torvalds1da177e2005-04-16 15:20:36 -070060!Elib/vsprintf.c
Eldad Zack4c925d62012-12-17 16:03:04 -080061!Finclude/linux/kernel.h kstrtol
62!Finclude/linux/kernel.h kstrtoul
63!Elib/kstrtox.c
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 </sect1>
65 <sect1><title>String Manipulation</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -070066<!-- All functions are exported at now
67X!Ilib/string.c
68 -->
Linus Torvalds1da177e2005-04-16 15:20:36 -070069!Elib/string.c
70 </sect1>
71 <sect1><title>Bit Operations</title>
Randy Dunlapa1a739c2008-10-25 17:24:36 -070072!Iarch/x86/include/asm/bitops.h
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 </sect1>
Randy Dunlap28e83ba2006-06-25 05:48:58 -070074 </chapter>
75
76 <chapter id="kernel-lib">
77 <title>Basic Kernel Library Functions</title>
78
79 <para>
80 The Linux kernel provides more basic utility functions.
81 </para>
82
Randy Dunlap6e1907ff2006-06-25 05:48:57 -070083 <sect1><title>Bitmap Operations</title>
84!Elib/bitmap.c
85!Ilib/bitmap.c
86 </sect1>
Randy Dunlap28e83ba2006-06-25 05:48:58 -070087
88 <sect1><title>Command-line Parsing</title>
89!Elib/cmdline.c
90 </sect1>
Randy Dunlap2f721002006-06-25 05:48:59 -070091
Jan Nikitenkoad241522007-07-17 04:04:03 -070092 <sect1 id="crc"><title>CRC Functions</title>
93!Elib/crc7.c
Randy Dunlap2f721002006-06-25 05:48:59 -070094!Elib/crc16.c
Jan Nikitenkoad241522007-07-17 04:04:03 -070095!Elib/crc-itu-t.c
Randy Dunlap2f721002006-06-25 05:48:59 -070096!Elib/crc32.c
97!Elib/crc-ccitt.c
98 </sect1>
Randy Dunlap56083ab2010-10-26 14:19:08 -070099
100 <sect1 id="idr"><title>idr/ida Functions</title>
101!Pinclude/linux/idr.h idr sync
102!Plib/idr.c IDA description
103!Elib/idr.c
104 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 </chapter>
106
107 <chapter id="mm">
108 <title>Memory Management in Linux</title>
109 <sect1><title>The Slab Cache</title>
Paul Drynoff800590f2006-06-23 02:03:48 -0700110!Iinclude/linux/slab.h
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111!Emm/slab.c
112 </sect1>
113 <sect1><title>User Space Memory Access</title>
Randy Dunlapa1a739c2008-10-25 17:24:36 -0700114!Iarch/x86/include/asm/uaccess_32.h
Randy Dunlapf3cf31a2007-10-12 21:17:23 -0700115!Earch/x86/lib/usercopy_32.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 </sect1>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700117 <sect1><title>More Memory Management Functions</title>
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700118!Emm/readahead.c
119!Emm/filemap.c
120!Emm/memory.c
121!Emm/vmalloc.c
Randy Dunlap88ca3b92006-10-04 02:15:25 -0700122!Imm/page_alloc.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700123!Emm/mempool.c
Randy Dunlapa80a438b2008-02-06 16:29:55 -0800124!Emm/dmapool.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700125!Emm/page-writeback.c
126!Emm/truncate.c
127 </sect1>
128 </chapter>
129
130
131 <chapter id="ipc">
132 <title>Kernel IPC facilities</title>
133
134 <sect1><title>IPC utilities</title>
135!Iipc/util.c
136 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 </chapter>
138
139 <chapter id="kfifo">
140 <title>FIFO Buffer</title>
141 <sect1><title>kfifo interface</title>
142!Iinclude/linux/kfifo.h
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 </sect1>
144 </chapter>
145
Randy Dunlap5b217fa2006-09-29 01:59:10 -0700146 <chapter id="relayfs">
147 <title>relay interface support</title>
148
149 <para>
150 Relay interface support
151 is designed to provide an efficient mechanism for tools and
152 facilities to relay large amounts of data from kernel space to
153 user space.
154 </para>
155
156 <sect1><title>relay interface</title>
157!Ekernel/relay.c
158!Ikernel/relay.c
159 </sect1>
160 </chapter>
161
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162 <chapter id="modload">
163 <title>Module Support</title>
164 <sect1><title>Module Loading</title>
165!Ekernel/kmod.c
166 </sect1>
167 <sect1><title>Inter Module support</title>
168 <para>
169 Refer to the file kernel/module.c for more information.
170 </para>
171<!-- FIXME: Removed for now since no structured comments in source
172X!Ekernel/module.c
173-->
174 </sect1>
175 </chapter>
176
177 <chapter id="hardware">
178 <title>Hardware Interfaces</title>
179 <sect1><title>Interrupt Handling</title>
Randy Dunlap8f2709b2005-11-07 01:01:05 -0800180!Ekernel/irq/manage.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181 </sect1>
182
Randy Dunlapeed34d02006-10-03 01:13:50 -0700183 <sect1><title>DMA Channels</title>
184!Ekernel/dma.c
185 </sect1>
186
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700187 <sect1><title>Resources Management</title>
Randy Dunlap2b549602006-07-30 03:03:40 -0700188!Ikernel/resource.c
Randy Dunlape1ca66d2006-10-03 01:13:51 -0700189!Ekernel/resource.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700190 </sect1>
191
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 <sect1><title>MTRR Handling</title>
Randy Dunlapf3cf31a2007-10-12 21:17:23 -0700193!Earch/x86/kernel/cpu/mtrr/main.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194 </sect1>
Randy Dunlapb0ef3712006-06-25 05:49:18 -0700195
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 <sect1><title>PCI Support Library</title>
197!Edrivers/pci/pci.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700198!Edrivers/pci/pci-driver.c
199!Edrivers/pci/remove.c
Randy Dunlapd75763d2006-07-30 03:03:41 -0700200!Edrivers/pci/search.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700201!Edrivers/pci/msi.c
202!Edrivers/pci/bus.c
Randy Dunlapcffb2fa2009-04-10 15:17:50 -0700203!Edrivers/pci/access.c
204!Edrivers/pci/irq.c
205!Edrivers/pci/htirq.c
Randy Dunlapf05aab82005-10-23 11:58:19 -0700206<!-- FIXME: Removed for now since no structured comments in source
207X!Edrivers/pci/hotplug.c
208-->
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700209!Edrivers/pci/probe.c
Randy Dunlapcffb2fa2009-04-10 15:17:50 -0700210!Edrivers/pci/slot.c
Pavel Pisa4dc3b162005-05-01 08:59:25 -0700211!Edrivers/pci/rom.c
Yu Zhao15b49be2009-03-20 11:25:18 +0800212!Edrivers/pci/iov.c
Randy Dunlapcffb2fa2009-04-10 15:17:50 -0700213!Idrivers/pci/pci-sysfs.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 </sect1>
215 <sect1><title>PCI Hotplug Support Library</title>
216!Edrivers/pci/hotplug/pci_hotplug_core.c
217 </sect1>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 </chapter>
219
Randy Dunlapb0ef3712006-06-25 05:49:18 -0700220 <chapter id="firmware">
221 <title>Firmware Interfaces</title>
222 <sect1><title>DMI Interfaces</title>
223!Edrivers/firmware/dmi_scan.c
224 </sect1>
Randy Dunlap6e8c8182007-02-10 01:46:03 -0800225 <sect1><title>EDD Interfaces</title>
226!Idrivers/firmware/edd.c
227 </sect1>
Randy Dunlapb0ef3712006-06-25 05:49:18 -0700228 </chapter>
229
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230 <chapter id="security">
231 <title>Security Framework</title>
James Morris20510f22007-10-16 23:31:32 -0700232!Isecurity/security.c
Randy Dunlap3f23d812008-08-17 21:44:22 -0700233!Esecurity/inode.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234 </chapter>
235
Randy Dunlap862f5f02006-06-23 02:05:52 -0700236 <chapter id="audit">
237 <title>Audit Interfaces</title>
238!Ekernel/audit.c
239!Ikernel/auditsc.c
240!Ikernel/auditfilter.c
241 </chapter>
242
243 <chapter id="accounting">
244 <title>Accounting Framework</title>
245!Ikernel/acct.c
246 </chapter>
247
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 <chapter id="blkdev">
249 <title>Block Devices</title>
Randy Dunlapcaf03fe2008-01-30 11:51:00 -0800250!Eblock/blk-core.c
Randy Dunlap5d87a052008-02-20 09:01:22 +0100251!Iblock/blk-core.c
Randy Dunlapcaf03fe2008-01-30 11:51:00 -0800252!Eblock/blk-map.c
253!Iblock/blk-sysfs.c
254!Eblock/blk-settings.c
255!Eblock/blk-exec.c
Mike Snitzer4d152902010-10-21 14:54:19 +0200256!Eblock/blk-flush.c
257!Eblock/blk-lib.c
Randy Dunlapcaf03fe2008-01-30 11:51:00 -0800258!Eblock/blk-tag.c
Randy Dunlap5d87a052008-02-20 09:01:22 +0100259!Iblock/blk-tag.c
Randy Dunlap710027a2008-08-19 20:13:11 +0200260!Eblock/blk-integrity.c
Randy Dunlap88cacbb2009-04-05 15:45:34 -0700261!Ikernel/trace/blktrace.c
Randy Dunlap710027a2008-08-19 20:13:11 +0200262!Iblock/genhd.c
263!Eblock/genhd.c
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264 </chapter>
265
Jonathan Corbetcf3e43d2006-09-29 02:00:44 -0700266 <chapter id="chrdev">
267 <title>Char devices</title>
268!Efs/char_dev.c
269 </chapter>
270
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271 <chapter id="miscdev">
272 <title>Miscellaneous Devices</title>
273!Edrivers/char/misc.c
274 </chapter>
275
David Brownelle275ac42008-04-28 02:11:56 -0700276 <chapter id="clk">
277 <title>Clock Framework</title>
278
279 <para>
280 The clock framework defines programming interfaces to support
281 software management of the system clock tree.
282 This framework is widely used with System-On-Chip (SOC) platforms
283 to support power management and various devices which may need
284 custom clock rates.
285 Note that these "clocks" don't relate to timekeeping or real
286 time clocks (RTCs), each of which have separate frameworks.
287 These <structname>struct clk</structname> instances may be used
288 to manage for example a 96 MHz signal that is used to shift bits
289 into and out of peripherals or busses, or otherwise trigger
290 synchronous state machine transitions in system hardware.
291 </para>
292
293 <para>
294 Power management is supported by explicit software clock gating:
295 unused clocks are disabled, so the system doesn't waste power
296 changing the state of transistors that aren't in active use.
297 On some systems this may be backed by hardware clock gating,
298 where clocks are gated without being disabled in software.
299 Sections of chips that are powered but not clocked may be able
300 to retain their last state.
301 This low power state is often called a <emphasis>retention
302 mode</emphasis>.
303 This mode still incurs leakage currents, especially with finer
304 circuit geometries, but for CMOS circuits power is mostly used
305 by clocked state changes.
306 </para>
307
308 <para>
309 Power-aware drivers only enable their clocks when the device
310 they manage is in active use. Also, system sleep states often
311 differ according to which clock domains are active: while a
312 "standby" state may allow wakeup from several active domains, a
313 "mem" (suspend-to-RAM) state may require a more wholesale shutdown
314 of clocks derived from higher speed PLLs and oscillators, limiting
315 the number of possible wakeup event sources. A driver's suspend
316 method may need to be aware of system-specific clock constraints
317 on the target sleep state.
318 </para>
319
320 <para>
321 Some platforms support programmable clock generators. These
322 can be used by external chips of various kinds, such as other
323 CPUs, multimedia codecs, and devices with strict requirements
324 for interface clocking.
325 </para>
326
327!Iinclude/linux/clk.h
328 </chapter>
329
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330</book>