Merge branch 'stable/for-linus-5.2' of git://git.kernel.org/pub/scm/linux/kernel...
[sfrench/cifs-2.6.git] / Documentation / core-api / kernel-api.rst
1 ====================
2 The Linux Kernel API
3 ====================
4
5
6 List Management Functions
7 =========================
8
9 .. kernel-doc:: include/linux/list.h
10    :internal:
11
12 Basic C Library Functions
13 =========================
14
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.
20
21 String Conversions
22 ------------------
23
24 .. kernel-doc:: lib/vsprintf.c
25    :export:
26
27 .. kernel-doc:: include/linux/kernel.h
28    :functions: kstrtol
29
30 .. kernel-doc:: include/linux/kernel.h
31    :functions: kstrtoul
32
33 .. kernel-doc:: lib/kstrtox.c
34    :export:
35
36 String Manipulation
37 -------------------
38
39 .. kernel-doc:: lib/string.c
40    :export:
41
42 .. kernel-doc:: mm/util.c
43    :functions: kstrdup kstrdup_const kstrndup kmemdup kmemdup_nul memdup_user
44                vmemdup_user strndup_user memdup_user_nul
45
46 Basic Kernel Library Functions
47 ==============================
48
49 The Linux kernel provides more basic utility functions.
50
51 Bit Operations
52 --------------
53
54 .. kernel-doc:: arch/x86/include/asm/bitops.h
55    :internal:
56
57 Bitmap Operations
58 -----------------
59
60 .. kernel-doc:: lib/bitmap.c
61    :doc: bitmap introduction
62
63 .. kernel-doc:: include/linux/bitmap.h
64    :doc: declare bitmap
65
66 .. kernel-doc:: include/linux/bitmap.h
67    :doc: bitmap overview
68
69 .. kernel-doc:: include/linux/bitmap.h
70    :doc: bitmap bitops
71
72 .. kernel-doc:: lib/bitmap.c
73    :export:
74
75 .. kernel-doc:: lib/bitmap.c
76    :internal:
77
78 .. kernel-doc:: include/linux/bitmap.h
79    :internal:
80
81 Command-line Parsing
82 --------------------
83
84 .. kernel-doc:: lib/cmdline.c
85    :export:
86
87 Sorting
88 -------
89
90 .. kernel-doc:: lib/sort.c
91    :export:
92
93 .. kernel-doc:: lib/list_sort.c
94    :export:
95
96 Text Searching
97 --------------
98
99 .. kernel-doc:: lib/textsearch.c
100    :doc: ts_intro
101
102 .. kernel-doc:: lib/textsearch.c
103    :export:
104
105 .. kernel-doc:: include/linux/textsearch.h
106    :functions: textsearch_find textsearch_next \
107                textsearch_get_pattern textsearch_get_pattern_len
108
109 CRC and Math Functions in Linux
110 ===============================
111
112 CRC Functions
113 -------------
114
115 .. kernel-doc:: lib/crc4.c
116    :export:
117
118 .. kernel-doc:: lib/crc7.c
119    :export:
120
121 .. kernel-doc:: lib/crc8.c
122    :export:
123
124 .. kernel-doc:: lib/crc16.c
125    :export:
126
127 .. kernel-doc:: lib/crc32.c
128
129 .. kernel-doc:: lib/crc-ccitt.c
130    :export:
131
132 .. kernel-doc:: lib/crc-itu-t.c
133    :export:
134
135 Base 2 log and power Functions
136 ------------------------------
137
138 .. kernel-doc:: include/linux/log2.h
139    :internal:
140
141 Division Functions
142 ------------------
143
144 .. kernel-doc:: include/asm-generic/div64.h
145    :functions: do_div
146
147 .. kernel-doc:: include/linux/math64.h
148    :internal:
149
150 .. kernel-doc:: lib/div64.c
151    :functions: div_s64_rem div64_u64_rem div64_u64 div64_s64
152
153 .. kernel-doc:: lib/gcd.c
154    :export:
155
156 UUID/GUID
157 ---------
158
159 .. kernel-doc:: lib/uuid.c
160    :export:
161
162 Kernel IPC facilities
163 =====================
164
165 IPC utilities
166 -------------
167
168 .. kernel-doc:: ipc/util.c
169    :internal:
170
171 FIFO Buffer
172 ===========
173
174 kfifo interface
175 ---------------
176
177 .. kernel-doc:: include/linux/kfifo.h
178    :internal:
179
180 relay interface support
181 =======================
182
183 Relay interface support is designed to provide an efficient mechanism
184 for tools and facilities to relay large amounts of data from kernel
185 space to user space.
186
187 relay interface
188 ---------------
189
190 .. kernel-doc:: kernel/relay.c
191    :export:
192
193 .. kernel-doc:: kernel/relay.c
194    :internal:
195
196 Module Support
197 ==============
198
199 Module Loading
200 --------------
201
202 .. kernel-doc:: kernel/kmod.c
203    :export:
204
205 Inter Module support
206 --------------------
207
208 Refer to the file kernel/module.c for more information.
209
210 Hardware Interfaces
211 ===================
212
213 Interrupt Handling
214 ------------------
215
216 .. kernel-doc:: kernel/irq/manage.c
217    :export:
218
219 DMA Channels
220 ------------
221
222 .. kernel-doc:: kernel/dma.c
223    :export:
224
225 Resources Management
226 --------------------
227
228 .. kernel-doc:: kernel/resource.c
229    :internal:
230
231 .. kernel-doc:: kernel/resource.c
232    :export:
233
234 MTRR Handling
235 -------------
236
237 .. kernel-doc:: arch/x86/kernel/cpu/mtrr/mtrr.c
238    :export:
239
240 Security Framework
241 ==================
242
243 .. kernel-doc:: security/security.c
244    :internal:
245
246 .. kernel-doc:: security/inode.c
247    :export:
248
249 Audit Interfaces
250 ================
251
252 .. kernel-doc:: kernel/audit.c
253    :export:
254
255 .. kernel-doc:: kernel/auditsc.c
256    :internal:
257
258 .. kernel-doc:: kernel/auditfilter.c
259    :internal:
260
261 Accounting Framework
262 ====================
263
264 .. kernel-doc:: kernel/acct.c
265    :internal:
266
267 Block Devices
268 =============
269
270 .. kernel-doc:: block/blk-core.c
271    :export:
272
273 .. kernel-doc:: block/blk-core.c
274    :internal:
275
276 .. kernel-doc:: block/blk-map.c
277    :export:
278
279 .. kernel-doc:: block/blk-sysfs.c
280    :internal:
281
282 .. kernel-doc:: block/blk-settings.c
283    :export:
284
285 .. kernel-doc:: block/blk-exec.c
286    :export:
287
288 .. kernel-doc:: block/blk-flush.c
289    :export:
290
291 .. kernel-doc:: block/blk-lib.c
292    :export:
293
294 .. kernel-doc:: block/blk-integrity.c
295    :export:
296
297 .. kernel-doc:: kernel/trace/blktrace.c
298    :internal:
299
300 .. kernel-doc:: block/genhd.c
301    :internal:
302
303 .. kernel-doc:: block/genhd.c
304    :export:
305
306 Char devices
307 ============
308
309 .. kernel-doc:: fs/char_dev.c
310    :export:
311
312 Clock Framework
313 ===============
314
315 The clock framework defines programming interfaces to support software
316 management of the system clock tree. This framework is widely used with
317 System-On-Chip (SOC) platforms to support power management and various
318 devices which may need custom clock rates. Note that these "clocks"
319 don't relate to timekeeping or real time clocks (RTCs), each of which
320 have separate frameworks. These :c:type:`struct clk <clk>`
321 instances may be used to manage for example a 96 MHz signal that is used
322 to shift bits into and out of peripherals or busses, or otherwise
323 trigger synchronous state machine transitions in system hardware.
324
325 Power management is supported by explicit software clock gating: unused
326 clocks are disabled, so the system doesn't waste power changing the
327 state of transistors that aren't in active use. On some systems this may
328 be backed by hardware clock gating, where clocks are gated without being
329 disabled in software. Sections of chips that are powered but not clocked
330 may be able to retain their last state. This low power state is often
331 called a *retention mode*. This mode still incurs leakage currents,
332 especially with finer circuit geometries, but for CMOS circuits power is
333 mostly used by clocked state changes.
334
335 Power-aware drivers only enable their clocks when the device they manage
336 is in active use. Also, system sleep states often differ according to
337 which clock domains are active: while a "standby" state may allow wakeup
338 from several active domains, a "mem" (suspend-to-RAM) state may require
339 a more wholesale shutdown of clocks derived from higher speed PLLs and
340 oscillators, limiting the number of possible wakeup event sources. A
341 driver's suspend method may need to be aware of system-specific clock
342 constraints on the target sleep state.
343
344 Some platforms support programmable clock generators. These can be used
345 by external chips of various kinds, such as other CPUs, multimedia
346 codecs, and devices with strict requirements for interface clocking.
347
348 .. kernel-doc:: include/linux/clk.h
349    :internal:
350
351 Synchronization Primitives
352 ==========================
353
354 Read-Copy Update (RCU)
355 ----------------------
356
357 .. kernel-doc:: include/linux/rcupdate.h
358
359 .. kernel-doc:: kernel/rcu/tree.c
360
361 .. kernel-doc:: kernel/rcu/tree_plugin.h
362
363 .. kernel-doc:: kernel/rcu/tree_exp.h
364
365 .. kernel-doc:: kernel/rcu/update.c
366
367 .. kernel-doc:: include/linux/srcu.h
368
369 .. kernel-doc:: kernel/rcu/srcutree.c
370
371 .. kernel-doc:: include/linux/rculist_bl.h
372
373 .. kernel-doc:: include/linux/rculist.h
374
375 .. kernel-doc:: include/linux/rculist_nulls.h
376
377 .. kernel-doc:: include/linux/rcu_sync.h
378
379 .. kernel-doc:: kernel/rcu/sync.c