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