xref: /linux/Documentation/core-api/kernel-api.rst (revision a594533df0f6ca391da003f43d53b336a2d23ffa)
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
121Arithmetic Overflow Checking
122----------------------------
123
124.. kernel-doc:: include/linux/overflow.h
125   :internal:
126
127CRC Functions
128-------------
129
130.. kernel-doc:: lib/crc4.c
131   :export:
132
133.. kernel-doc:: lib/crc7.c
134   :export:
135
136.. kernel-doc:: lib/crc8.c
137   :export:
138
139.. kernel-doc:: lib/crc16.c
140   :export:
141
142.. kernel-doc:: lib/crc32.c
143
144.. kernel-doc:: lib/crc-ccitt.c
145   :export:
146
147.. kernel-doc:: lib/crc-itu-t.c
148   :export:
149
150Base 2 log and power Functions
151------------------------------
152
153.. kernel-doc:: include/linux/log2.h
154   :internal:
155
156Integer power Functions
157-----------------------
158
159.. kernel-doc:: lib/math/int_pow.c
160   :export:
161
162.. kernel-doc:: lib/math/int_sqrt.c
163   :export:
164
165Division Functions
166------------------
167
168.. kernel-doc:: include/asm-generic/div64.h
169   :functions: do_div
170
171.. kernel-doc:: include/linux/math64.h
172   :internal:
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 files in kernel/module/ for more information.
230
231Hardware Interfaces
232===================
233
234DMA Channels
235------------
236
237.. kernel-doc:: kernel/dma.c
238   :export:
239
240Resources Management
241--------------------
242
243.. kernel-doc:: kernel/resource.c
244   :internal:
245
246.. kernel-doc:: kernel/resource.c
247   :export:
248
249MTRR Handling
250-------------
251
252.. kernel-doc:: arch/x86/kernel/cpu/mtrr/mtrr.c
253   :export:
254
255Security Framework
256==================
257
258.. kernel-doc:: security/security.c
259   :internal:
260
261.. kernel-doc:: security/inode.c
262   :export:
263
264Audit Interfaces
265================
266
267.. kernel-doc:: kernel/audit.c
268   :export:
269
270.. kernel-doc:: kernel/auditsc.c
271   :internal:
272
273.. kernel-doc:: kernel/auditfilter.c
274   :internal:
275
276Accounting Framework
277====================
278
279.. kernel-doc:: kernel/acct.c
280   :internal:
281
282Block Devices
283=============
284
285.. kernel-doc:: include/linux/bio.h
286.. kernel-doc:: block/blk-core.c
287   :export:
288
289.. kernel-doc:: block/blk-core.c
290   :internal:
291
292.. kernel-doc:: block/blk-map.c
293   :export:
294
295.. kernel-doc:: block/blk-sysfs.c
296   :internal:
297
298.. kernel-doc:: block/blk-settings.c
299   :export:
300
301.. kernel-doc:: block/blk-flush.c
302   :export:
303
304.. kernel-doc:: block/blk-lib.c
305   :export:
306
307.. kernel-doc:: block/blk-integrity.c
308   :export:
309
310.. kernel-doc:: kernel/trace/blktrace.c
311   :internal:
312
313.. kernel-doc:: block/genhd.c
314   :internal:
315
316.. kernel-doc:: block/genhd.c
317   :export:
318
319.. kernel-doc:: block/bdev.c
320   :export:
321
322Char devices
323============
324
325.. kernel-doc:: fs/char_dev.c
326   :export:
327
328Clock Framework
329===============
330
331The clock framework defines programming interfaces to support software
332management of the system clock tree. This framework is widely used with
333System-On-Chip (SOC) platforms to support power management and various
334devices which may need custom clock rates. Note that these "clocks"
335don't relate to timekeeping or real time clocks (RTCs), each of which
336have separate frameworks. These :c:type:`struct clk <clk>`
337instances may be used to manage for example a 96 MHz signal that is used
338to shift bits into and out of peripherals or busses, or otherwise
339trigger synchronous state machine transitions in system hardware.
340
341Power management is supported by explicit software clock gating: unused
342clocks are disabled, so the system doesn't waste power changing the
343state of transistors that aren't in active use. On some systems this may
344be backed by hardware clock gating, where clocks are gated without being
345disabled in software. Sections of chips that are powered but not clocked
346may be able to retain their last state. This low power state is often
347called a *retention mode*. This mode still incurs leakage currents,
348especially with finer circuit geometries, but for CMOS circuits power is
349mostly used by clocked state changes.
350
351Power-aware drivers only enable their clocks when the device they manage
352is in active use. Also, system sleep states often differ according to
353which clock domains are active: while a "standby" state may allow wakeup
354from several active domains, a "mem" (suspend-to-RAM) state may require
355a more wholesale shutdown of clocks derived from higher speed PLLs and
356oscillators, limiting the number of possible wakeup event sources. A
357driver's suspend method may need to be aware of system-specific clock
358constraints on the target sleep state.
359
360Some platforms support programmable clock generators. These can be used
361by external chips of various kinds, such as other CPUs, multimedia
362codecs, and devices with strict requirements for interface clocking.
363
364.. kernel-doc:: include/linux/clk.h
365   :internal:
366
367Synchronization Primitives
368==========================
369
370Read-Copy Update (RCU)
371----------------------
372
373.. kernel-doc:: include/linux/rcupdate.h
374
375.. kernel-doc:: kernel/rcu/tree.c
376
377.. kernel-doc:: kernel/rcu/tree_exp.h
378
379.. kernel-doc:: kernel/rcu/update.c
380
381.. kernel-doc:: include/linux/srcu.h
382
383.. kernel-doc:: kernel/rcu/srcutree.c
384
385.. kernel-doc:: include/linux/rculist_bl.h
386
387.. kernel-doc:: include/linux/rculist.h
388
389.. kernel-doc:: include/linux/rculist_nulls.h
390
391.. kernel-doc:: include/linux/rcu_sync.h
392
393.. kernel-doc:: kernel/rcu/sync.c
394