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