docs: core-api: add circular-buffers documentation
[linux-2.6/btrfs-unstable.git] / Documentation / core-api / kernel-api.rst
blob8e44aea366c262068900cddaabd240d8615ac552
1 ====================
2 The Linux Kernel API
3 ====================
6 List Management Functions
7 =========================
9 .. kernel-doc:: include/linux/list.h
10    :internal:
12 Basic C Library Functions
13 =========================
15 When writing drivers, you cannot in general use routines which are from
16 the C Library. Some of the functions have been found generally useful
17 and they are listed below. The behaviour of these functions may vary
18 slightly from those defined by ANSI, and these deviations are noted in
19 the text.
21 String Conversions
22 ------------------
24 .. kernel-doc:: lib/vsprintf.c
25    :export:
27 .. kernel-doc:: include/linux/kernel.h
28    :functions: kstrtol
30 .. kernel-doc:: include/linux/kernel.h
31    :functions: kstrtoul
33 .. kernel-doc:: lib/kstrtox.c
34    :export:
36 String Manipulation
37 -------------------
39 .. kernel-doc:: lib/string.c
40    :export:
42 Basic Kernel Library Functions
43 ==============================
45 The Linux kernel provides more basic utility functions.
47 Bit Operations
48 --------------
50 .. kernel-doc:: arch/x86/include/asm/bitops.h
51    :internal:
53 Bitmap Operations
54 -----------------
56 .. kernel-doc:: lib/bitmap.c
57    :doc: bitmap introduction
59 .. kernel-doc:: include/linux/bitmap.h
60    :doc: declare bitmap
62 .. kernel-doc:: include/linux/bitmap.h
63    :doc: bitmap overview
65 .. kernel-doc:: include/linux/bitmap.h
66    :doc: bitmap bitops
68 .. kernel-doc:: lib/bitmap.c
69    :export:
71 .. kernel-doc:: lib/bitmap.c
72    :internal:
74 .. kernel-doc:: include/linux/bitmap.h
75    :internal:
77 Command-line Parsing
78 --------------------
80 .. kernel-doc:: lib/cmdline.c
81    :export:
83 Sorting
84 -------
86 .. kernel-doc:: lib/sort.c
87    :export:
89 .. kernel-doc:: lib/list_sort.c
90    :export:
92 Text Searching
93 --------------
95 .. kernel-doc:: lib/textsearch.c
96    :doc: ts_intro
98 .. kernel-doc:: lib/textsearch.c
99    :export:
101 .. kernel-doc:: include/linux/textsearch.h
102    :functions: textsearch_find textsearch_next \
103                textsearch_get_pattern textsearch_get_pattern_len
105 CRC and Math Functions in Linux
106 ===============================
108 CRC Functions
109 -------------
111 .. kernel-doc:: lib/crc4.c
112    :export:
114 .. kernel-doc:: lib/crc7.c
115    :export:
117 .. kernel-doc:: lib/crc8.c
118    :export:
120 .. kernel-doc:: lib/crc16.c
121    :export:
123 .. kernel-doc:: lib/crc32.c
125 .. kernel-doc:: lib/crc-ccitt.c
126    :export:
128 .. kernel-doc:: lib/crc-itu-t.c
129    :export:
131 Base 2 log and power Functions
132 ------------------------------
134 .. kernel-doc:: include/linux/log2.h
135    :internal:
137 Division Functions
138 ------------------
140 .. kernel-doc:: include/asm-generic/div64.h
141    :functions: do_div
143 .. kernel-doc:: include/linux/math64.h
144    :internal:
146 .. kernel-doc:: lib/div64.c
147    :functions: div_s64_rem div64_u64_rem div64_u64 div64_s64
149 .. kernel-doc:: lib/gcd.c
150    :export:
152 UUID/GUID
153 ---------
155 .. kernel-doc:: lib/uuid.c
156    :export:
158 Memory Management in Linux
159 ==========================
161 The Slab Cache
162 --------------
164 .. kernel-doc:: include/linux/slab.h
165    :internal:
167 .. kernel-doc:: mm/slab.c
168    :export:
170 .. kernel-doc:: mm/util.c
171    :export:
173 User Space Memory Access
174 ------------------------
176 .. kernel-doc:: arch/x86/include/asm/uaccess.h
177    :internal:
179 .. kernel-doc:: arch/x86/lib/usercopy_32.c
180    :export:
182 More Memory Management Functions
183 --------------------------------
185 .. kernel-doc:: mm/readahead.c
186    :export:
188 .. kernel-doc:: mm/filemap.c
189    :export:
191 .. kernel-doc:: mm/memory.c
192    :export:
194 .. kernel-doc:: mm/vmalloc.c
195    :export:
197 .. kernel-doc:: mm/page_alloc.c
198    :internal:
200 .. kernel-doc:: mm/mempool.c
201    :export:
203 .. kernel-doc:: mm/dmapool.c
204    :export:
206 .. kernel-doc:: mm/page-writeback.c
207    :export:
209 .. kernel-doc:: mm/truncate.c
210    :export:
212 Kernel IPC facilities
213 =====================
215 IPC utilities
216 -------------
218 .. kernel-doc:: ipc/util.c
219    :internal:
221 FIFO Buffer
222 ===========
224 kfifo interface
225 ---------------
227 .. kernel-doc:: include/linux/kfifo.h
228    :internal:
230 relay interface support
231 =======================
233 Relay interface support is designed to provide an efficient mechanism
234 for tools and facilities to relay large amounts of data from kernel
235 space to user space.
237 relay interface
238 ---------------
240 .. kernel-doc:: kernel/relay.c
241    :export:
243 .. kernel-doc:: kernel/relay.c
244    :internal:
246 Module Support
247 ==============
249 Module Loading
250 --------------
252 .. kernel-doc:: kernel/kmod.c
253    :export:
255 Inter Module support
256 --------------------
258 Refer to the file kernel/module.c for more information.
260 Hardware Interfaces
261 ===================
263 Interrupt Handling
264 ------------------
266 .. kernel-doc:: kernel/irq/manage.c
267    :export:
269 DMA Channels
270 ------------
272 .. kernel-doc:: kernel/dma.c
273    :export:
275 Resources Management
276 --------------------
278 .. kernel-doc:: kernel/resource.c
279    :internal:
281 .. kernel-doc:: kernel/resource.c
282    :export:
284 MTRR Handling
285 -------------
287 .. kernel-doc:: arch/x86/kernel/cpu/mtrr/main.c
288    :export:
290 Security Framework
291 ==================
293 .. kernel-doc:: security/security.c
294    :internal:
296 .. kernel-doc:: security/inode.c
297    :export:
299 Audit Interfaces
300 ================
302 .. kernel-doc:: kernel/audit.c
303    :export:
305 .. kernel-doc:: kernel/auditsc.c
306    :internal:
308 .. kernel-doc:: kernel/auditfilter.c
309    :internal:
311 Accounting Framework
312 ====================
314 .. kernel-doc:: kernel/acct.c
315    :internal:
317 Block Devices
318 =============
320 .. kernel-doc:: block/blk-core.c
321    :export:
323 .. kernel-doc:: block/blk-core.c
324    :internal:
326 .. kernel-doc:: block/blk-map.c
327    :export:
329 .. kernel-doc:: block/blk-sysfs.c
330    :internal:
332 .. kernel-doc:: block/blk-settings.c
333    :export:
335 .. kernel-doc:: block/blk-exec.c
336    :export:
338 .. kernel-doc:: block/blk-flush.c
339    :export:
341 .. kernel-doc:: block/blk-lib.c
342    :export:
344 .. kernel-doc:: block/blk-tag.c
345    :export:
347 .. kernel-doc:: block/blk-tag.c
348    :internal:
350 .. kernel-doc:: block/blk-integrity.c
351    :export:
353 .. kernel-doc:: kernel/trace/blktrace.c
354    :internal:
356 .. kernel-doc:: block/genhd.c
357    :internal:
359 .. kernel-doc:: block/genhd.c
360    :export:
362 Char devices
363 ============
365 .. kernel-doc:: fs/char_dev.c
366    :export:
368 Clock Framework
369 ===============
371 The clock framework defines programming interfaces to support software
372 management of the system clock tree. This framework is widely used with
373 System-On-Chip (SOC) platforms to support power management and various
374 devices which may need custom clock rates. Note that these "clocks"
375 don't relate to timekeeping or real time clocks (RTCs), each of which
376 have separate frameworks. These :c:type:`struct clk <clk>`
377 instances may be used to manage for example a 96 MHz signal that is used
378 to shift bits into and out of peripherals or busses, or otherwise
379 trigger synchronous state machine transitions in system hardware.
381 Power management is supported by explicit software clock gating: unused
382 clocks are disabled, so the system doesn't waste power changing the
383 state of transistors that aren't in active use. On some systems this may
384 be backed by hardware clock gating, where clocks are gated without being
385 disabled in software. Sections of chips that are powered but not clocked
386 may be able to retain their last state. This low power state is often
387 called a *retention mode*. This mode still incurs leakage currents,
388 especially with finer circuit geometries, but for CMOS circuits power is
389 mostly used by clocked state changes.
391 Power-aware drivers only enable their clocks when the device they manage
392 is in active use. Also, system sleep states often differ according to
393 which clock domains are active: while a "standby" state may allow wakeup
394 from several active domains, a "mem" (suspend-to-RAM) state may require
395 a more wholesale shutdown of clocks derived from higher speed PLLs and
396 oscillators, limiting the number of possible wakeup event sources. A
397 driver's suspend method may need to be aware of system-specific clock
398 constraints on the target sleep state.
400 Some platforms support programmable clock generators. These can be used
401 by external chips of various kinds, such as other CPUs, multimedia
402 codecs, and devices with strict requirements for interface clocking.
404 .. kernel-doc:: include/linux/clk.h
405    :internal:
407 Synchronization Primitives
408 ==========================
410 Read-Copy Update (RCU)
411 ----------------------
413 .. kernel-doc:: include/linux/rcupdate.h
415 .. kernel-doc:: include/linux/rcupdate_wait.h
417 .. kernel-doc:: include/linux/rcutree.h
419 .. kernel-doc:: kernel/rcu/tree.c
421 .. kernel-doc:: kernel/rcu/tree_plugin.h
423 .. kernel-doc:: kernel/rcu/tree_exp.h
425 .. kernel-doc:: kernel/rcu/update.c
427 .. kernel-doc:: include/linux/srcu.h
429 .. kernel-doc:: kernel/rcu/srcutree.c
431 .. kernel-doc:: include/linux/rculist_bl.h
433 .. kernel-doc:: include/linux/rculist.h
435 .. kernel-doc:: include/linux/rculist_nulls.h
437 .. kernel-doc:: include/linux/rcu_sync.h
439 .. kernel-doc:: kernel/rcu/sync.c