| 1 | ====================
|
| 2 | The Linux Kernel API
|
| 3 | ====================
|
| 4 |
|
| 5 |
|
| 6 | Basic C Library Functions
|
| 7 | =========================
|
| 8 |
|
| 9 | When writing drivers, you cannot in general use routines which are from
|
| 10 | the C Library. Some of the functions have been found generally useful
|
| 11 | and they are listed below. The behaviour of these functions may vary
|
| 12 | slightly from those defined by ANSI, and these deviations are noted in
|
| 13 | the text.
|
| 14 |
|
| 15 | String Conversions
|
| 16 | ------------------
|
| 17 |
|
| 18 | .. kernel-doc:: lib/vsprintf.c
|
| 19 | :export:
|
| 20 |
|
| 21 | .. kernel-doc:: include/linux/kstrtox.h
|
| 22 | :functions: kstrtol kstrtoul
|
| 23 |
|
| 24 | .. kernel-doc:: lib/kstrtox.c
|
| 25 | :export:
|
| 26 |
|
| 27 | .. kernel-doc:: lib/string_helpers.c
|
| 28 | :export:
|
| 29 |
|
| 30 | String Manipulation
|
| 31 | -------------------
|
| 32 |
|
| 33 | .. kernel-doc:: include/linux/fortify-string.h
|
| 34 | :internal:
|
| 35 |
|
| 36 | .. kernel-doc:: lib/string.c
|
| 37 | :export:
|
| 38 |
|
| 39 | .. kernel-doc:: include/linux/string.h
|
| 40 | :internal:
|
| 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 |
|
| 46 | Basic Kernel Library Functions
|
| 47 | ==============================
|
| 48 |
|
| 49 | The Linux kernel provides more basic utility functions.
|
| 50 |
|
| 51 | Bit Operations
|
| 52 | --------------
|
| 53 |
|
| 54 | .. kernel-doc:: include/asm-generic/bitops/instrumented-atomic.h
|
| 55 | :internal:
|
| 56 |
|
| 57 | .. kernel-doc:: include/asm-generic/bitops/instrumented-non-atomic.h
|
| 58 | :internal:
|
| 59 |
|
| 60 | .. kernel-doc:: include/asm-generic/bitops/instrumented-lock.h
|
| 61 | :internal:
|
| 62 |
|
| 63 | Bitmap Operations
|
| 64 | -----------------
|
| 65 |
|
| 66 | .. kernel-doc:: lib/bitmap.c
|
| 67 | :doc: bitmap introduction
|
| 68 |
|
| 69 | .. kernel-doc:: include/linux/bitmap.h
|
| 70 | :doc: declare bitmap
|
| 71 |
|
| 72 | .. kernel-doc:: include/linux/bitmap.h
|
| 73 | :doc: bitmap overview
|
| 74 |
|
| 75 | .. kernel-doc:: include/linux/bitmap.h
|
| 76 | :doc: bitmap bitops
|
| 77 |
|
| 78 | .. kernel-doc:: lib/bitmap.c
|
| 79 | :export:
|
| 80 |
|
| 81 | .. kernel-doc:: lib/bitmap.c
|
| 82 | :internal:
|
| 83 |
|
| 84 | .. kernel-doc:: include/linux/bitmap.h
|
| 85 | :internal:
|
| 86 |
|
| 87 | Command-line Parsing
|
| 88 | --------------------
|
| 89 |
|
| 90 | .. kernel-doc:: lib/cmdline.c
|
| 91 | :export:
|
| 92 |
|
| 93 | Error Pointers
|
| 94 | --------------
|
| 95 |
|
| 96 | .. kernel-doc:: include/linux/err.h
|
| 97 | :internal:
|
| 98 |
|
| 99 | Sorting
|
| 100 | -------
|
| 101 |
|
| 102 | .. kernel-doc:: lib/sort.c
|
| 103 | :export:
|
| 104 |
|
| 105 | .. kernel-doc:: lib/list_sort.c
|
| 106 | :export:
|
| 107 |
|
| 108 | Text 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 |
|
| 121 | CRC and Math Functions in Linux
|
| 122 | ===============================
|
| 123 |
|
| 124 | Arithmetic Overflow Checking
|
| 125 | ----------------------------
|
| 126 |
|
| 127 | .. kernel-doc:: include/linux/overflow.h
|
| 128 | :internal:
|
| 129 |
|
| 130 | CRC Functions
|
| 131 | -------------
|
| 132 |
|
| 133 | .. kernel-doc:: lib/crc/crc4.c
|
| 134 | :export:
|
| 135 |
|
| 136 | .. kernel-doc:: lib/crc/crc7.c
|
| 137 | :export:
|
| 138 |
|
| 139 | .. kernel-doc:: lib/crc/crc8.c
|
| 140 | :export:
|
| 141 |
|
| 142 | .. kernel-doc:: lib/crc/crc16.c
|
| 143 | :export:
|
| 144 |
|
| 145 | .. kernel-doc:: lib/crc/crc-ccitt.c
|
| 146 | :export:
|
| 147 |
|
| 148 | .. kernel-doc:: lib/crc/crc-itu-t.c
|
| 149 | :export:
|
| 150 |
|
| 151 | .. kernel-doc:: include/linux/crc32.h
|
| 152 |
|
| 153 | .. kernel-doc:: include/linux/crc64.h
|
| 154 |
|
| 155 | Base 2 log and power Functions
|
| 156 | ------------------------------
|
| 157 |
|
| 158 | .. kernel-doc:: include/linux/log2.h
|
| 159 | :internal:
|
| 160 |
|
| 161 | Integer log and power Functions
|
| 162 | -------------------------------
|
| 163 |
|
| 164 | .. kernel-doc:: include/linux/int_log.h
|
| 165 |
|
| 166 | .. kernel-doc:: lib/math/int_pow.c
|
| 167 | :export:
|
| 168 |
|
| 169 | .. kernel-doc:: lib/math/int_sqrt.c
|
| 170 | :export:
|
| 171 |
|
| 172 | Division Functions
|
| 173 | ------------------
|
| 174 |
|
| 175 | .. kernel-doc:: include/asm-generic/div64.h
|
| 176 | :functions: do_div
|
| 177 |
|
| 178 | .. kernel-doc:: include/linux/math64.h
|
| 179 | :internal:
|
| 180 |
|
| 181 | .. kernel-doc:: lib/math/gcd.c
|
| 182 | :export:
|
| 183 |
|
| 184 | UUID/GUID
|
| 185 | ---------
|
| 186 |
|
| 187 | .. kernel-doc:: lib/uuid.c
|
| 188 | :export:
|
| 189 |
|
| 190 | Kernel IPC facilities
|
| 191 | =====================
|
| 192 |
|
| 193 | IPC utilities
|
| 194 | -------------
|
| 195 |
|
| 196 | .. kernel-doc:: ipc/util.c
|
| 197 | :internal:
|
| 198 |
|
| 199 | FIFO Buffer
|
| 200 | ===========
|
| 201 |
|
| 202 | kfifo interface
|
| 203 | ---------------
|
| 204 |
|
| 205 | .. kernel-doc:: include/linux/kfifo.h
|
| 206 | :internal:
|
| 207 |
|
| 208 | relay interface support
|
| 209 | =======================
|
| 210 |
|
| 211 | Relay interface support is designed to provide an efficient mechanism
|
| 212 | for tools and facilities to relay large amounts of data from kernel
|
| 213 | space to user space.
|
| 214 |
|
| 215 | relay interface
|
| 216 | ---------------
|
| 217 |
|
| 218 | .. kernel-doc:: kernel/relay.c
|
| 219 | :export:
|
| 220 |
|
| 221 | .. kernel-doc:: kernel/relay.c
|
| 222 | :internal:
|
| 223 |
|
| 224 | Module Support
|
| 225 | ==============
|
| 226 |
|
| 227 | Kernel module auto-loading
|
| 228 | --------------------------
|
| 229 |
|
| 230 | .. kernel-doc:: kernel/module/kmod.c
|
| 231 | :export:
|
| 232 |
|
| 233 | Module debugging
|
| 234 | ----------------
|
| 235 |
|
| 236 | .. kernel-doc:: kernel/module/stats.c
|
| 237 | :doc: module debugging statistics overview
|
| 238 |
|
| 239 | dup_failed_modules - tracks duplicate failed modules
|
| 240 | ****************************************************
|
| 241 |
|
| 242 | .. kernel-doc:: kernel/module/stats.c
|
| 243 | :doc: dup_failed_modules - tracks duplicate failed modules
|
| 244 |
|
| 245 | module statistics debugfs counters
|
| 246 | **********************************
|
| 247 |
|
| 248 | .. kernel-doc:: kernel/module/stats.c
|
| 249 | :doc: module statistics debugfs counters
|
| 250 |
|
| 251 | Inter Module support
|
| 252 | --------------------
|
| 253 |
|
| 254 | Refer to the files in kernel/module/ for more information.
|
| 255 |
|
| 256 | Hardware Interfaces
|
| 257 | ===================
|
| 258 |
|
| 259 | DMA Channels
|
| 260 | ------------
|
| 261 |
|
| 262 | .. kernel-doc:: kernel/dma.c
|
| 263 | :export:
|
| 264 |
|
| 265 | Resources Management
|
| 266 | --------------------
|
| 267 |
|
| 268 | .. kernel-doc:: kernel/resource.c
|
| 269 | :internal:
|
| 270 |
|
| 271 | .. kernel-doc:: kernel/resource.c
|
| 272 | :export:
|
| 273 |
|
| 274 | MTRR Handling
|
| 275 | -------------
|
| 276 |
|
| 277 | .. kernel-doc:: arch/x86/kernel/cpu/mtrr/mtrr.c
|
| 278 | :export:
|
| 279 |
|
| 280 | Security Framework
|
| 281 | ==================
|
| 282 |
|
| 283 | .. kernel-doc:: security/security.c
|
| 284 | :internal:
|
| 285 |
|
| 286 | .. kernel-doc:: security/inode.c
|
| 287 | :export:
|
| 288 |
|
| 289 | Audit Interfaces
|
| 290 | ================
|
| 291 |
|
| 292 | .. kernel-doc:: kernel/audit.c
|
| 293 | :export:
|
| 294 |
|
| 295 | .. kernel-doc:: kernel/auditsc.c
|
| 296 | :internal:
|
| 297 |
|
| 298 | .. kernel-doc:: kernel/auditfilter.c
|
| 299 | :internal:
|
| 300 |
|
| 301 | Accounting Framework
|
| 302 | ====================
|
| 303 |
|
| 304 | .. kernel-doc:: kernel/acct.c
|
| 305 | :internal:
|
| 306 |
|
| 307 | Block Devices
|
| 308 | =============
|
| 309 |
|
| 310 | .. kernel-doc:: include/linux/bvec.h
|
| 311 | .. kernel-doc:: include/linux/bio.h
|
| 312 | .. kernel-doc:: block/blk-core.c
|
| 313 | :export:
|
| 314 |
|
| 315 | .. kernel-doc:: block/blk-core.c
|
| 316 | :internal:
|
| 317 |
|
| 318 | .. kernel-doc:: block/blk-map.c
|
| 319 | :export:
|
| 320 |
|
| 321 | .. kernel-doc:: block/blk-sysfs.c
|
| 322 | :internal:
|
| 323 |
|
| 324 | .. kernel-doc:: block/blk-settings.c
|
| 325 | :export:
|
| 326 |
|
| 327 | .. kernel-doc:: block/blk-flush.c
|
| 328 | :export:
|
| 329 |
|
| 330 | .. kernel-doc:: block/blk-lib.c
|
| 331 | :export:
|
| 332 |
|
| 333 | .. kernel-doc:: block/blk-integrity.c
|
| 334 | :export:
|
| 335 |
|
| 336 | .. kernel-doc:: kernel/trace/blktrace.c
|
| 337 | :internal:
|
| 338 |
|
| 339 | .. kernel-doc:: block/genhd.c
|
| 340 | :internal:
|
| 341 |
|
| 342 | .. kernel-doc:: block/genhd.c
|
| 343 | :export:
|
| 344 |
|
| 345 | .. kernel-doc:: block/bdev.c
|
| 346 | :export:
|
| 347 |
|
| 348 | Char devices
|
| 349 | ============
|
| 350 |
|
| 351 | .. kernel-doc:: fs/char_dev.c
|
| 352 | :export:
|
| 353 |
|
| 354 | Clock Framework
|
| 355 | ===============
|
| 356 |
|
| 357 | The clock framework defines programming interfaces to support software
|
| 358 | management of the system clock tree. This framework is widely used with
|
| 359 | System-On-Chip (SOC) platforms to support power management and various
|
| 360 | devices which may need custom clock rates. Note that these "clocks"
|
| 361 | don't relate to timekeeping or real time clocks (RTCs), each of which
|
| 362 | have separate frameworks. These :c:type:`struct clk <clk>`
|
| 363 | instances may be used to manage for example a 96 MHz signal that is used
|
| 364 | to shift bits into and out of peripherals or busses, or otherwise
|
| 365 | trigger synchronous state machine transitions in system hardware.
|
| 366 |
|
| 367 | Power management is supported by explicit software clock gating: unused
|
| 368 | clocks are disabled, so the system doesn't waste power changing the
|
| 369 | state of transistors that aren't in active use. On some systems this may
|
| 370 | be backed by hardware clock gating, where clocks are gated without being
|
| 371 | disabled in software. Sections of chips that are powered but not clocked
|
| 372 | may be able to retain their last state. This low power state is often
|
| 373 | called a *retention mode*. This mode still incurs leakage currents,
|
| 374 | especially with finer circuit geometries, but for CMOS circuits power is
|
| 375 | mostly used by clocked state changes.
|
| 376 |
|
| 377 | Power-aware drivers only enable their clocks when the device they manage
|
| 378 | is in active use. Also, system sleep states often differ according to
|
| 379 | which clock domains are active: while a "standby" state may allow wakeup
|
| 380 | from several active domains, a "mem" (suspend-to-RAM) state may require
|
| 381 | a more wholesale shutdown of clocks derived from higher speed PLLs and
|
| 382 | oscillators, limiting the number of possible wakeup event sources. A
|
| 383 | driver's suspend method may need to be aware of system-specific clock
|
| 384 | constraints on the target sleep state.
|
| 385 |
|
| 386 | Some platforms support programmable clock generators. These can be used
|
| 387 | by external chips of various kinds, such as other CPUs, multimedia
|
| 388 | codecs, and devices with strict requirements for interface clocking.
|
| 389 |
|
| 390 | .. kernel-doc:: include/linux/clk.h
|
| 391 | :internal:
|
| 392 |
|
| 393 | Synchronization Primitives
|
| 394 | ==========================
|
| 395 |
|
| 396 | Read-Copy Update (RCU)
|
| 397 | ----------------------
|
| 398 |
|
| 399 | .. kernel-doc:: include/linux/rcupdate.h
|
| 400 |
|
| 401 | .. kernel-doc:: kernel/rcu/tree.c
|
| 402 |
|
| 403 | .. kernel-doc:: kernel/rcu/tree_exp.h
|
| 404 |
|
| 405 | .. kernel-doc:: kernel/rcu/update.c
|
| 406 |
|
| 407 | .. kernel-doc:: include/linux/srcu.h
|
| 408 |
|
| 409 | .. kernel-doc:: kernel/rcu/srcutree.c
|
| 410 |
|
| 411 | .. kernel-doc:: include/linux/rculist_bl.h
|
| 412 |
|
| 413 | .. kernel-doc:: include/linux/rculist.h
|
| 414 |
|
| 415 | .. kernel-doc:: include/linux/rculist_nulls.h
|
| 416 |
|
| 417 | .. kernel-doc:: include/linux/rcu_sync.h
|
| 418 |
|
| 419 | .. kernel-doc:: kernel/rcu/sync.c
|
| 420 |
|
| 421 | .. kernel-doc:: kernel/rcu/tasks.h
|
| 422 |
|
| 423 | .. kernel-doc:: kernel/rcu/tree_stall.h
|
| 424 |
|
| 425 | .. kernel-doc:: include/linux/rcupdate_trace.h
|
| 426 |
|
| 427 | .. kernel-doc:: include/linux/rcupdate_wait.h
|
| 428 |
|
| 429 | .. kernel-doc:: include/linux/rcuref.h
|
| 430 |
|
| 431 | .. kernel-doc:: include/linux/rcutree.h
|