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