Linux 5.2
[linux-2.6/linux-2.6-arm.git] / Documentation / core-api / kernel-api.rst
bloba29c99d1333190677c6717d0f1d04bb7104b75b2
1 ====================
2 The Linux Kernel API
3 ====================
6 List Management Functions
7 =========================
9 .. kernel-doc:: include/linux/list.h
10    :internal:
12 Basic C Library Functions
13 =========================
15 When writing drivers, you cannot in general use routines which are from
16 the C Library. Some of the functions have been found generally useful
17 and they are listed below. The behaviour of these functions may vary
18 slightly from those defined by ANSI, and these deviations are noted in
19 the text.
21 String Conversions
22 ------------------
24 .. kernel-doc:: lib/vsprintf.c
25    :export:
27 .. kernel-doc:: include/linux/kernel.h
28    :functions: kstrtol
30 .. kernel-doc:: include/linux/kernel.h
31    :functions: kstrtoul
33 .. kernel-doc:: lib/kstrtox.c
34    :export:
36 String Manipulation
37 -------------------
39 .. kernel-doc:: lib/string.c
40    :export:
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
46 Basic Kernel Library Functions
47 ==============================
49 The Linux kernel provides more basic utility functions.
51 Bit Operations
52 --------------
54 .. kernel-doc:: arch/x86/include/asm/bitops.h
55    :internal:
57 Bitmap Operations
58 -----------------
60 .. kernel-doc:: lib/bitmap.c
61    :doc: bitmap introduction
63 .. kernel-doc:: include/linux/bitmap.h
64    :doc: declare bitmap
66 .. kernel-doc:: include/linux/bitmap.h
67    :doc: bitmap overview
69 .. kernel-doc:: include/linux/bitmap.h
70    :doc: bitmap bitops
72 .. kernel-doc:: lib/bitmap.c
73    :export:
75 .. kernel-doc:: lib/bitmap.c
76    :internal:
78 .. kernel-doc:: include/linux/bitmap.h
79    :internal:
81 Command-line Parsing
82 --------------------
84 .. kernel-doc:: lib/cmdline.c
85    :export:
87 Sorting
88 -------
90 .. kernel-doc:: lib/sort.c
91    :export:
93 .. kernel-doc:: lib/list_sort.c
94    :export:
96 Text Searching
97 --------------
99 .. kernel-doc:: lib/textsearch.c
100    :doc: ts_intro
102 .. kernel-doc:: lib/textsearch.c
103    :export:
105 .. kernel-doc:: include/linux/textsearch.h
106    :functions: textsearch_find textsearch_next \
107                textsearch_get_pattern textsearch_get_pattern_len
109 CRC and Math Functions in Linux
110 ===============================
112 CRC Functions
113 -------------
115 .. kernel-doc:: lib/crc4.c
116    :export:
118 .. kernel-doc:: lib/crc7.c
119    :export:
121 .. kernel-doc:: lib/crc8.c
122    :export:
124 .. kernel-doc:: lib/crc16.c
125    :export:
127 .. kernel-doc:: lib/crc32.c
129 .. kernel-doc:: lib/crc-ccitt.c
130    :export:
132 .. kernel-doc:: lib/crc-itu-t.c
133    :export:
135 Base 2 log and power Functions
136 ------------------------------
138 .. kernel-doc:: include/linux/log2.h
139    :internal:
141 Division Functions
142 ------------------
144 .. kernel-doc:: include/asm-generic/div64.h
145    :functions: do_div
147 .. kernel-doc:: include/linux/math64.h
148    :internal:
150 .. kernel-doc:: lib/math/div64.c
151    :functions: div_s64_rem div64_u64_rem div64_u64 div64_s64
153 .. kernel-doc:: lib/math/gcd.c
154    :export:
156 UUID/GUID
157 ---------
159 .. kernel-doc:: lib/uuid.c
160    :export:
162 Kernel IPC facilities
163 =====================
165 IPC utilities
166 -------------
168 .. kernel-doc:: ipc/util.c
169    :internal:
171 FIFO Buffer
172 ===========
174 kfifo interface
175 ---------------
177 .. kernel-doc:: include/linux/kfifo.h
178    :internal:
180 relay interface support
181 =======================
183 Relay interface support is designed to provide an efficient mechanism
184 for tools and facilities to relay large amounts of data from kernel
185 space to user space.
187 relay interface
188 ---------------
190 .. kernel-doc:: kernel/relay.c
191    :export:
193 .. kernel-doc:: kernel/relay.c
194    :internal:
196 Module Support
197 ==============
199 Module Loading
200 --------------
202 .. kernel-doc:: kernel/kmod.c
203    :export:
205 Inter Module support
206 --------------------
208 Refer to the file kernel/module.c for more information.
210 Hardware Interfaces
211 ===================
213 Interrupt Handling
214 ------------------
216 .. kernel-doc:: kernel/irq/manage.c
217    :export:
219 DMA Channels
220 ------------
222 .. kernel-doc:: kernel/dma.c
223    :export:
225 Resources Management
226 --------------------
228 .. kernel-doc:: kernel/resource.c
229    :internal:
231 .. kernel-doc:: kernel/resource.c
232    :export:
234 MTRR Handling
235 -------------
237 .. kernel-doc:: arch/x86/kernel/cpu/mtrr/mtrr.c
238    :export:
240 Security Framework
241 ==================
243 .. kernel-doc:: security/security.c
244    :internal:
246 .. kernel-doc:: security/inode.c
247    :export:
249 Audit Interfaces
250 ================
252 .. kernel-doc:: kernel/audit.c
253    :export:
255 .. kernel-doc:: kernel/auditsc.c
256    :internal:
258 .. kernel-doc:: kernel/auditfilter.c
259    :internal:
261 Accounting Framework
262 ====================
264 .. kernel-doc:: kernel/acct.c
265    :internal:
267 Block Devices
268 =============
270 .. kernel-doc:: block/blk-core.c
271    :export:
273 .. kernel-doc:: block/blk-core.c
274    :internal:
276 .. kernel-doc:: block/blk-map.c
277    :export:
279 .. kernel-doc:: block/blk-sysfs.c
280    :internal:
282 .. kernel-doc:: block/blk-settings.c
283    :export:
285 .. kernel-doc:: block/blk-exec.c
286    :export:
288 .. kernel-doc:: block/blk-flush.c
289    :export:
291 .. kernel-doc:: block/blk-lib.c
292    :export:
294 .. kernel-doc:: block/blk-integrity.c
295    :export:
297 .. kernel-doc:: kernel/trace/blktrace.c
298    :internal:
300 .. kernel-doc:: block/genhd.c
301    :internal:
303 .. kernel-doc:: block/genhd.c
304    :export:
306 Char devices
307 ============
309 .. kernel-doc:: fs/char_dev.c
310    :export:
312 Clock Framework
313 ===============
315 The clock framework defines programming interfaces to support software
316 management of the system clock tree. This framework is widely used with
317 System-On-Chip (SOC) platforms to support power management and various
318 devices which may need custom clock rates. Note that these "clocks"
319 don't relate to timekeeping or real time clocks (RTCs), each of which
320 have separate frameworks. These :c:type:`struct clk <clk>`
321 instances may be used to manage for example a 96 MHz signal that is used
322 to shift bits into and out of peripherals or busses, or otherwise
323 trigger synchronous state machine transitions in system hardware.
325 Power management is supported by explicit software clock gating: unused
326 clocks are disabled, so the system doesn't waste power changing the
327 state of transistors that aren't in active use. On some systems this may
328 be backed by hardware clock gating, where clocks are gated without being
329 disabled in software. Sections of chips that are powered but not clocked
330 may be able to retain their last state. This low power state is often
331 called a *retention mode*. This mode still incurs leakage currents,
332 especially with finer circuit geometries, but for CMOS circuits power is
333 mostly used by clocked state changes.
335 Power-aware drivers only enable their clocks when the device they manage
336 is in active use. Also, system sleep states often differ according to
337 which clock domains are active: while a "standby" state may allow wakeup
338 from several active domains, a "mem" (suspend-to-RAM) state may require
339 a more wholesale shutdown of clocks derived from higher speed PLLs and
340 oscillators, limiting the number of possible wakeup event sources. A
341 driver's suspend method may need to be aware of system-specific clock
342 constraints on the target sleep state.
344 Some platforms support programmable clock generators. These can be used
345 by external chips of various kinds, such as other CPUs, multimedia
346 codecs, and devices with strict requirements for interface clocking.
348 .. kernel-doc:: include/linux/clk.h
349    :internal:
351 Synchronization Primitives
352 ==========================
354 Read-Copy Update (RCU)
355 ----------------------
357 .. kernel-doc:: include/linux/rcupdate.h
359 .. kernel-doc:: kernel/rcu/tree.c
361 .. kernel-doc:: kernel/rcu/tree_plugin.h
363 .. kernel-doc:: kernel/rcu/tree_exp.h
365 .. kernel-doc:: kernel/rcu/update.c
367 .. kernel-doc:: include/linux/srcu.h
369 .. kernel-doc:: kernel/rcu/srcutree.c
371 .. kernel-doc:: include/linux/rculist_bl.h
373 .. kernel-doc:: include/linux/rculist.h
375 .. kernel-doc:: include/linux/rculist_nulls.h
377 .. kernel-doc:: include/linux/rcu_sync.h
379 .. kernel-doc:: kernel/rcu/sync.c