xref: /linux/Documentation/core-api/kernel-api.rst (revision 260f6f4fda93c8485c8037865c941b42b9cba5d2)
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/crc/crc4.c
140   :export:
141
142.. kernel-doc:: lib/crc/crc7.c
143   :export:
144
145.. kernel-doc:: lib/crc/crc8.c
146   :export:
147
148.. kernel-doc:: lib/crc/crc16.c
149   :export:
150
151.. kernel-doc:: lib/crc/crc-ccitt.c
152   :export:
153
154.. kernel-doc:: lib/crc/crc-itu-t.c
155   :export:
156
157.. kernel-doc:: include/linux/crc32.h
158
159.. kernel-doc:: include/linux/crc64.h
160
161Base 2 log and power Functions
162------------------------------
163
164.. kernel-doc:: include/linux/log2.h
165   :internal:
166
167Integer log and power Functions
168-------------------------------
169
170.. kernel-doc:: include/linux/int_log.h
171
172.. kernel-doc:: lib/math/int_pow.c
173   :export:
174
175.. kernel-doc:: lib/math/int_sqrt.c
176   :export:
177
178Division Functions
179------------------
180
181.. kernel-doc:: include/asm-generic/div64.h
182   :functions: do_div
183
184.. kernel-doc:: include/linux/math64.h
185   :internal:
186
187.. kernel-doc:: lib/math/gcd.c
188   :export:
189
190UUID/GUID
191---------
192
193.. kernel-doc:: lib/uuid.c
194   :export:
195
196Kernel IPC facilities
197=====================
198
199IPC utilities
200-------------
201
202.. kernel-doc:: ipc/util.c
203   :internal:
204
205FIFO Buffer
206===========
207
208kfifo interface
209---------------
210
211.. kernel-doc:: include/linux/kfifo.h
212   :internal:
213
214relay interface support
215=======================
216
217Relay interface support is designed to provide an efficient mechanism
218for tools and facilities to relay large amounts of data from kernel
219space to user space.
220
221relay interface
222---------------
223
224.. kernel-doc:: kernel/relay.c
225   :export:
226
227.. kernel-doc:: kernel/relay.c
228   :internal:
229
230Module Support
231==============
232
233Kernel module auto-loading
234--------------------------
235
236.. kernel-doc:: kernel/module/kmod.c
237   :export:
238
239Module debugging
240----------------
241
242.. kernel-doc:: kernel/module/stats.c
243   :doc: module debugging statistics overview
244
245dup_failed_modules - tracks duplicate failed modules
246****************************************************
247
248.. kernel-doc:: kernel/module/stats.c
249   :doc: dup_failed_modules - tracks duplicate failed modules
250
251module statistics debugfs counters
252**********************************
253
254.. kernel-doc:: kernel/module/stats.c
255   :doc: module statistics debugfs counters
256
257Inter Module support
258--------------------
259
260Refer to the files in kernel/module/ for more information.
261
262Hardware Interfaces
263===================
264
265DMA Channels
266------------
267
268.. kernel-doc:: kernel/dma.c
269   :export:
270
271Resources Management
272--------------------
273
274.. kernel-doc:: kernel/resource.c
275   :internal:
276
277.. kernel-doc:: kernel/resource.c
278   :export:
279
280MTRR Handling
281-------------
282
283.. kernel-doc:: arch/x86/kernel/cpu/mtrr/mtrr.c
284   :export:
285
286Security Framework
287==================
288
289.. kernel-doc:: security/security.c
290   :internal:
291
292.. kernel-doc:: security/inode.c
293   :export:
294
295Audit Interfaces
296================
297
298.. kernel-doc:: kernel/audit.c
299   :export:
300
301.. kernel-doc:: kernel/auditsc.c
302   :internal:
303
304.. kernel-doc:: kernel/auditfilter.c
305   :internal:
306
307Accounting Framework
308====================
309
310.. kernel-doc:: kernel/acct.c
311   :internal:
312
313Block Devices
314=============
315
316.. kernel-doc:: include/linux/bio.h
317.. kernel-doc:: block/blk-core.c
318   :export:
319
320.. kernel-doc:: block/blk-core.c
321   :internal:
322
323.. kernel-doc:: block/blk-map.c
324   :export:
325
326.. kernel-doc:: block/blk-sysfs.c
327   :internal:
328
329.. kernel-doc:: block/blk-settings.c
330   :export:
331
332.. kernel-doc:: block/blk-flush.c
333   :export:
334
335.. kernel-doc:: block/blk-lib.c
336   :export:
337
338.. kernel-doc:: block/blk-integrity.c
339   :export:
340
341.. kernel-doc:: kernel/trace/blktrace.c
342   :internal:
343
344.. kernel-doc:: block/genhd.c
345   :internal:
346
347.. kernel-doc:: block/genhd.c
348   :export:
349
350.. kernel-doc:: block/bdev.c
351   :export:
352
353Char devices
354============
355
356.. kernel-doc:: fs/char_dev.c
357   :export:
358
359Clock Framework
360===============
361
362The clock framework defines programming interfaces to support software
363management of the system clock tree. This framework is widely used with
364System-On-Chip (SOC) platforms to support power management and various
365devices which may need custom clock rates. Note that these "clocks"
366don't relate to timekeeping or real time clocks (RTCs), each of which
367have separate frameworks. These :c:type:`struct clk <clk>`
368instances may be used to manage for example a 96 MHz signal that is used
369to shift bits into and out of peripherals or busses, or otherwise
370trigger synchronous state machine transitions in system hardware.
371
372Power management is supported by explicit software clock gating: unused
373clocks are disabled, so the system doesn't waste power changing the
374state of transistors that aren't in active use. On some systems this may
375be backed by hardware clock gating, where clocks are gated without being
376disabled in software. Sections of chips that are powered but not clocked
377may be able to retain their last state. This low power state is often
378called a *retention mode*. This mode still incurs leakage currents,
379especially with finer circuit geometries, but for CMOS circuits power is
380mostly used by clocked state changes.
381
382Power-aware drivers only enable their clocks when the device they manage
383is in active use. Also, system sleep states often differ according to
384which clock domains are active: while a "standby" state may allow wakeup
385from several active domains, a "mem" (suspend-to-RAM) state may require
386a more wholesale shutdown of clocks derived from higher speed PLLs and
387oscillators, limiting the number of possible wakeup event sources. A
388driver's suspend method may need to be aware of system-specific clock
389constraints on the target sleep state.
390
391Some platforms support programmable clock generators. These can be used
392by external chips of various kinds, such as other CPUs, multimedia
393codecs, and devices with strict requirements for interface clocking.
394
395.. kernel-doc:: include/linux/clk.h
396   :internal:
397
398Synchronization Primitives
399==========================
400
401Read-Copy Update (RCU)
402----------------------
403
404.. kernel-doc:: include/linux/rcupdate.h
405
406.. kernel-doc:: kernel/rcu/tree.c
407
408.. kernel-doc:: kernel/rcu/tree_exp.h
409
410.. kernel-doc:: kernel/rcu/update.c
411
412.. kernel-doc:: include/linux/srcu.h
413
414.. kernel-doc:: kernel/rcu/srcutree.c
415
416.. kernel-doc:: include/linux/rculist_bl.h
417
418.. kernel-doc:: include/linux/rculist.h
419
420.. kernel-doc:: include/linux/rculist_nulls.h
421
422.. kernel-doc:: include/linux/rcu_sync.h
423
424.. kernel-doc:: kernel/rcu/sync.c
425
426.. kernel-doc:: kernel/rcu/tasks.h
427
428.. kernel-doc:: kernel/rcu/tree_stall.h
429
430.. kernel-doc:: include/linux/rcupdate_trace.h
431
432.. kernel-doc:: include/linux/rcupdate_wait.h
433
434.. kernel-doc:: include/linux/rcuref.h
435
436.. kernel-doc:: include/linux/rcutree.h
437