xref: /linux/Documentation/core-api/kernel-api.rst (revision e1789d7c752ed001cf1a4bbbd624f70a7dd3c6db)
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
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
124Arithmetic Overflow Checking
125----------------------------
126
127.. kernel-doc:: include/linux/overflow.h
128   :internal:
129
130CRC Functions
131-------------
132
133.. kernel-doc:: lib/crc4.c
134   :export:
135
136.. kernel-doc:: lib/crc7.c
137   :export:
138
139.. kernel-doc:: lib/crc8.c
140   :export:
141
142.. kernel-doc:: lib/crc16.c
143   :export:
144
145.. kernel-doc:: lib/crc32.c
146
147.. kernel-doc:: lib/crc-ccitt.c
148   :export:
149
150.. kernel-doc:: lib/crc-itu-t.c
151   :export:
152
153Base 2 log and power Functions
154------------------------------
155
156.. kernel-doc:: include/linux/log2.h
157   :internal:
158
159Integer power Functions
160-----------------------
161
162.. kernel-doc:: lib/math/int_pow.c
163   :export:
164
165.. kernel-doc:: lib/math/int_sqrt.c
166   :export:
167
168Division Functions
169------------------
170
171.. kernel-doc:: include/asm-generic/div64.h
172   :functions: do_div
173
174.. kernel-doc:: include/linux/math64.h
175   :internal:
176
177.. kernel-doc:: lib/math/div64.c
178   :functions: div_s64_rem div64_u64_rem div64_u64 div64_s64
179
180.. kernel-doc:: lib/math/gcd.c
181   :export:
182
183UUID/GUID
184---------
185
186.. kernel-doc:: lib/uuid.c
187   :export:
188
189Kernel IPC facilities
190=====================
191
192IPC utilities
193-------------
194
195.. kernel-doc:: ipc/util.c
196   :internal:
197
198FIFO Buffer
199===========
200
201kfifo interface
202---------------
203
204.. kernel-doc:: include/linux/kfifo.h
205   :internal:
206
207relay interface support
208=======================
209
210Relay interface support is designed to provide an efficient mechanism
211for tools and facilities to relay large amounts of data from kernel
212space to user space.
213
214relay interface
215---------------
216
217.. kernel-doc:: kernel/relay.c
218   :export:
219
220.. kernel-doc:: kernel/relay.c
221   :internal:
222
223Module Support
224==============
225
226Module Loading
227--------------
228
229.. kernel-doc:: kernel/kmod.c
230   :export:
231
232Inter Module support
233--------------------
234
235Refer to the files in kernel/module/ for more information.
236
237Hardware Interfaces
238===================
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:: include/linux/bio.h
292.. kernel-doc:: block/blk-core.c
293   :export:
294
295.. kernel-doc:: block/blk-core.c
296   :internal:
297
298.. kernel-doc:: block/blk-map.c
299   :export:
300
301.. kernel-doc:: block/blk-sysfs.c
302   :internal:
303
304.. kernel-doc:: block/blk-settings.c
305   :export:
306
307.. kernel-doc:: block/blk-flush.c
308   :export:
309
310.. kernel-doc:: block/blk-lib.c
311   :export:
312
313.. kernel-doc:: block/blk-integrity.c
314   :export:
315
316.. kernel-doc:: kernel/trace/blktrace.c
317   :internal:
318
319.. kernel-doc:: block/genhd.c
320   :internal:
321
322.. kernel-doc:: block/genhd.c
323   :export:
324
325.. kernel-doc:: block/bdev.c
326   :export:
327
328Char devices
329============
330
331.. kernel-doc:: fs/char_dev.c
332   :export:
333
334Clock Framework
335===============
336
337The clock framework defines programming interfaces to support software
338management of the system clock tree. This framework is widely used with
339System-On-Chip (SOC) platforms to support power management and various
340devices which may need custom clock rates. Note that these "clocks"
341don't relate to timekeeping or real time clocks (RTCs), each of which
342have separate frameworks. These :c:type:`struct clk <clk>`
343instances may be used to manage for example a 96 MHz signal that is used
344to shift bits into and out of peripherals or busses, or otherwise
345trigger synchronous state machine transitions in system hardware.
346
347Power management is supported by explicit software clock gating: unused
348clocks are disabled, so the system doesn't waste power changing the
349state of transistors that aren't in active use. On some systems this may
350be backed by hardware clock gating, where clocks are gated without being
351disabled in software. Sections of chips that are powered but not clocked
352may be able to retain their last state. This low power state is often
353called a *retention mode*. This mode still incurs leakage currents,
354especially with finer circuit geometries, but for CMOS circuits power is
355mostly used by clocked state changes.
356
357Power-aware drivers only enable their clocks when the device they manage
358is in active use. Also, system sleep states often differ according to
359which clock domains are active: while a "standby" state may allow wakeup
360from several active domains, a "mem" (suspend-to-RAM) state may require
361a more wholesale shutdown of clocks derived from higher speed PLLs and
362oscillators, limiting the number of possible wakeup event sources. A
363driver's suspend method may need to be aware of system-specific clock
364constraints on the target sleep state.
365
366Some platforms support programmable clock generators. These can be used
367by external chips of various kinds, such as other CPUs, multimedia
368codecs, and devices with strict requirements for interface clocking.
369
370.. kernel-doc:: include/linux/clk.h
371   :internal:
372
373Synchronization Primitives
374==========================
375
376Read-Copy Update (RCU)
377----------------------
378
379.. kernel-doc:: include/linux/rcupdate.h
380
381.. kernel-doc:: kernel/rcu/tree.c
382
383.. kernel-doc:: kernel/rcu/tree_exp.h
384
385.. kernel-doc:: kernel/rcu/update.c
386
387.. kernel-doc:: include/linux/srcu.h
388
389.. kernel-doc:: kernel/rcu/srcutree.c
390
391.. kernel-doc:: include/linux/rculist_bl.h
392
393.. kernel-doc:: include/linux/rculist.h
394
395.. kernel-doc:: include/linux/rculist_nulls.h
396
397.. kernel-doc:: include/linux/rcu_sync.h
398
399.. kernel-doc:: kernel/rcu/sync.c
400