xref: /linux/Documentation/core-api/kernel-api.rst (revision 1ad6e3b2652b310e4ab1a544894c79d4f7cb39d3)
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   :export:
58
59.. kernel-doc:: lib/bitmap.c
60   :internal:
61
62.. kernel-doc:: include/linux/bitmap.h
63   :internal:
64
65Command-line Parsing
66--------------------
67
68.. kernel-doc:: lib/cmdline.c
69   :export:
70
71CRC Functions
72-------------
73
74.. kernel-doc:: lib/crc4.c
75   :export:
76
77.. kernel-doc:: lib/crc7.c
78   :export:
79
80.. kernel-doc:: lib/crc8.c
81   :export:
82
83.. kernel-doc:: lib/crc16.c
84   :export:
85
86.. kernel-doc:: lib/crc32.c
87
88.. kernel-doc:: lib/crc-ccitt.c
89   :export:
90
91.. kernel-doc:: lib/crc-itu-t.c
92   :export:
93
94idr/ida Functions
95-----------------
96
97.. kernel-doc:: include/linux/idr.h
98   :doc: idr sync
99
100.. kernel-doc:: lib/idr.c
101   :doc: IDA description
102
103.. kernel-doc:: lib/idr.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
130Memory Management in Linux
131==========================
132
133The Slab Cache
134--------------
135
136.. kernel-doc:: include/linux/slab.h
137   :internal:
138
139.. kernel-doc:: mm/slab.c
140   :export:
141
142.. kernel-doc:: mm/util.c
143   :export:
144
145User Space Memory Access
146------------------------
147
148.. kernel-doc:: arch/x86/include/asm/uaccess.h
149   :internal:
150
151.. kernel-doc:: arch/x86/lib/usercopy_32.c
152   :export:
153
154More Memory Management Functions
155--------------------------------
156
157.. kernel-doc:: mm/readahead.c
158   :export:
159
160.. kernel-doc:: mm/filemap.c
161   :export:
162
163.. kernel-doc:: mm/memory.c
164   :export:
165
166.. kernel-doc:: mm/vmalloc.c
167   :export:
168
169.. kernel-doc:: mm/page_alloc.c
170   :internal:
171
172.. kernel-doc:: mm/mempool.c
173   :export:
174
175.. kernel-doc:: mm/dmapool.c
176   :export:
177
178.. kernel-doc:: mm/page-writeback.c
179   :export:
180
181.. kernel-doc:: mm/truncate.c
182   :export:
183
184Kernel IPC facilities
185=====================
186
187IPC utilities
188-------------
189
190.. kernel-doc:: ipc/util.c
191   :internal:
192
193FIFO Buffer
194===========
195
196kfifo interface
197---------------
198
199.. kernel-doc:: include/linux/kfifo.h
200   :internal:
201
202relay interface support
203=======================
204
205Relay interface support is designed to provide an efficient mechanism
206for tools and facilities to relay large amounts of data from kernel
207space to user space.
208
209relay interface
210---------------
211
212.. kernel-doc:: kernel/relay.c
213   :export:
214
215.. kernel-doc:: kernel/relay.c
216   :internal:
217
218Module Support
219==============
220
221Module Loading
222--------------
223
224.. kernel-doc:: kernel/kmod.c
225   :export:
226
227Inter Module support
228--------------------
229
230Refer to the file kernel/module.c for more information.
231
232Hardware Interfaces
233===================
234
235Interrupt Handling
236------------------
237
238.. kernel-doc:: kernel/irq/manage.c
239   :export:
240
241DMA Channels
242------------
243
244.. kernel-doc:: kernel/dma.c
245   :export:
246
247Resources Management
248--------------------
249
250.. kernel-doc:: kernel/resource.c
251   :internal:
252
253.. kernel-doc:: kernel/resource.c
254   :export:
255
256MTRR Handling
257-------------
258
259.. kernel-doc:: arch/x86/kernel/cpu/mtrr/main.c
260   :export:
261
262Security Framework
263==================
264
265.. kernel-doc:: security/security.c
266   :internal:
267
268.. kernel-doc:: security/inode.c
269   :export:
270
271Audit Interfaces
272================
273
274.. kernel-doc:: kernel/audit.c
275   :export:
276
277.. kernel-doc:: kernel/auditsc.c
278   :internal:
279
280.. kernel-doc:: kernel/auditfilter.c
281   :internal:
282
283Accounting Framework
284====================
285
286.. kernel-doc:: kernel/acct.c
287   :internal:
288
289Block Devices
290=============
291
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-exec.c
308   :export:
309
310.. kernel-doc:: block/blk-flush.c
311   :export:
312
313.. kernel-doc:: block/blk-lib.c
314   :export:
315
316.. kernel-doc:: block/blk-tag.c
317   :export:
318
319.. kernel-doc:: block/blk-tag.c
320   :internal:
321
322.. kernel-doc:: block/blk-integrity.c
323   :export:
324
325.. kernel-doc:: kernel/trace/blktrace.c
326   :internal:
327
328.. kernel-doc:: block/genhd.c
329   :internal:
330
331.. kernel-doc:: block/genhd.c
332   :export:
333
334Char devices
335============
336
337.. kernel-doc:: fs/char_dev.c
338   :export:
339
340Clock Framework
341===============
342
343The clock framework defines programming interfaces to support software
344management of the system clock tree. This framework is widely used with
345System-On-Chip (SOC) platforms to support power management and various
346devices which may need custom clock rates. Note that these "clocks"
347don't relate to timekeeping or real time clocks (RTCs), each of which
348have separate frameworks. These :c:type:`struct clk <clk>`
349instances may be used to manage for example a 96 MHz signal that is used
350to shift bits into and out of peripherals or busses, or otherwise
351trigger synchronous state machine transitions in system hardware.
352
353Power management is supported by explicit software clock gating: unused
354clocks are disabled, so the system doesn't waste power changing the
355state of transistors that aren't in active use. On some systems this may
356be backed by hardware clock gating, where clocks are gated without being
357disabled in software. Sections of chips that are powered but not clocked
358may be able to retain their last state. This low power state is often
359called a *retention mode*. This mode still incurs leakage currents,
360especially with finer circuit geometries, but for CMOS circuits power is
361mostly used by clocked state changes.
362
363Power-aware drivers only enable their clocks when the device they manage
364is in active use. Also, system sleep states often differ according to
365which clock domains are active: while a "standby" state may allow wakeup
366from several active domains, a "mem" (suspend-to-RAM) state may require
367a more wholesale shutdown of clocks derived from higher speed PLLs and
368oscillators, limiting the number of possible wakeup event sources. A
369driver's suspend method may need to be aware of system-specific clock
370constraints on the target sleep state.
371
372Some platforms support programmable clock generators. These can be used
373by external chips of various kinds, such as other CPUs, multimedia
374codecs, and devices with strict requirements for interface clocking.
375
376.. kernel-doc:: include/linux/clk.h
377   :internal:
378
379Synchronization Primitives
380==========================
381
382Read-Copy Update (RCU)
383----------------------
384
385.. kernel-doc:: include/linux/rcupdate.h
386   :external:
387
388.. kernel-doc:: include/linux/rcupdate_wait.h
389   :external:
390
391.. kernel-doc:: include/linux/rcutree.h
392   :external:
393
394.. kernel-doc:: kernel/rcu/tree.c
395   :external:
396
397.. kernel-doc:: kernel/rcu/tree_plugin.h
398   :external:
399
400.. kernel-doc:: kernel/rcu/tree_exp.h
401   :external:
402
403.. kernel-doc:: kernel/rcu/update.c
404   :external:
405
406.. kernel-doc:: include/linux/srcu.h
407   :external:
408
409.. kernel-doc:: kernel/rcu/srcutree.c
410   :external:
411
412.. kernel-doc:: include/linux/rculist_bl.h
413   :external:
414
415.. kernel-doc:: include/linux/rculist.h
416   :external:
417
418.. kernel-doc:: include/linux/rculist_nulls.h
419   :external:
420
421.. kernel-doc:: include/linux/rcu_sync.h
422   :external:
423
424.. kernel-doc:: kernel/rcu/sync.c
425   :external:
426
427