The Linux Kernel API

This documentation is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

For more details see the file COPYING in the source distribution of Linux.


Table of Contents

1. Driver Basics
Driver Entry and Exit points
Atomic and pointer manipulation
Delaying, scheduling, and timer routines
High-resolution timers
Workqueues and Kevents
Internal Functions
Kernel objects manipulation
Kernel utility functions
2. Data Types
Doubly Linked Lists
3. Basic C Library Functions
String Conversions
String Manipulation
Bit Operations
4. Basic Kernel Library Functions
Bitmap Operations
Command-line Parsing
CRC Functions
5. Memory Management in Linux
The Slab Cache
User Space Memory Access
More Memory Management Functions
6. Kernel IPC facilities
IPC utilities
7. FIFO Buffer
kfifo interface
8. The proc filesystem
sysctl interface
proc filesystem interface
9. The debugfs filesystem
debugfs interface
10. The Linux VFS
The Filesystem types
The Directory Cache
Inode Handling
Registration and Superblocks
File Locks
Other Functions
11. Linux Networking
Networking Base Types
Socket Buffer Functions
Socket Filter
Generic Network Statistics
SUN RPC subsystem
12. Network device support
Driver Support
Synchronous PPP
13. Module Support
Module Loading
Inter Module support
14. Hardware Interfaces
Interrupt Handling
Resources Management
MTRR Handling
PCI Support Library
PCI Hotplug Support Library
MCA Architecture
MCA Device Functions
MCA Bus DMA
15. Firmware Interfaces
DMI Interfaces
16. The Filesystem for Exporting Kernel Objects
sysfs_create_file — create an attribute file for an object.
sysfs_update_file — update the modified timestamp on an object attribute.
sysfs_chmod_file — update the modified mode value on an object attribute.
sysfs_remove_file — remove an object attribute.
sysfs_create_link — create symlink between two objects.
sysfs_remove_link — remove symlink in object's directory.
sysfs_create_bin_file — create binary file for object.
sysfs_remove_bin_file — remove binary file for object.
17. Security Framework
register_security — registers a security framework with the kernel
unregister_security — unregisters a security framework with the kernel
mod_reg_security — allows security modules to be “stacked
mod_unreg_security — allows a security module registered with mod_reg_security to be unloaded
18. Audit Interfaces
audit_log_start — obtain an audit buffer
audit_log_format — format a message into the audit buffer.
audit_log_end — end one audit record
audit_log — Log an audit record
audit_alloc — allocate an audit context block for a task
audit_free — free a per-task audit context
audit_syscall_entry — fill in an audit record at syscall entry
audit_syscall_exit — deallocate audit context after a system call
__audit_getname — add a name to the list
__audit_inode — store the inode and device from a lookup
__audit_inode_child — collect inode info for created/removed objects
__audit_inode_update — update inode info for last collected name
auditsc_get_stamp — get local copies of audit_context values
audit_set_loginuid — set a task's audit_context loginuid
audit_get_loginuid — get the loginuid for an audit_context
__audit_mq_open — record audit data for a POSIX MQ open
__audit_mq_timedsend — record audit data for a POSIX MQ timed send
__audit_mq_timedreceive — record audit data for a POSIX MQ timed receive
__audit_mq_notify — record audit data for a POSIX MQ notify
__audit_mq_getsetattr — record audit data for a POSIX MQ get/set attribute
__audit_ipc_obj — record audit data for ipc object
__audit_ipc_set_perm — record audit data for new ipc permissions
audit_socketcall — record audit data for sys_socketcall
audit_sockaddr — record audit data for sys_bind, sys_connect, sys_sendto
audit_avc_path — record the granting or denial of permissions
__audit_signal_info — record signal info for shutting down audit subsystem
audit_receive_filter — apply all rules to the specified message type
19. Accounting Framework
sys_acct — enable/disable process accounting
acct_auto_close_mnt — turn off a filesystem's accounting if it is on
acct_auto_close — turn off a filesystem's accounting if it is on
acct_init_pacct — initialize a new pacct_struct
acct_collect — collect accounting information into pacct_struct
acct_process — now just a wrapper around do_acct_process
acct_update_integrals — update mm integral fields in task_struct
acct_clear_integrals — clear the mm integral fields in task_struct
20. Power Management
pm_register — register a device with power management
pm_send_all — send request to all managed devices
21. Device drivers infrastructure
Device Drivers Base
Device Drivers Power Management
Device Drivers ACPI Support
Device drivers PnP support
22. Block Devices
blk_get_backing_dev_info — get the address of a queue's backing_dev_info
blk_queue_prep_rq — set a prepare_request function for queue
blk_queue_merge_bvec — set a merge_bvec function for queue
blk_queue_make_request — define an alternate make_request function for a device
blk_queue_ordered — does this queue support ordered writes
blk_queue_issue_flush_fn — set function for issuing a flush
blk_queue_bounce_limit — set bounce buffer limit for queue
blk_queue_max_sectors — set max sectors for a request for this queue
blk_queue_max_phys_segments — set max phys segments for a request for this queue
blk_queue_max_hw_segments — set max hw segments for a request for this queue
blk_queue_max_segment_size — set max segment size for blk_rq_map_sg
blk_queue_hardsect_size — set hardware sector size for the queue
blk_queue_stack_limits — inherit underlying queue limits for stacked drivers
blk_queue_segment_boundary — set boundary rules for segment merging
blk_queue_dma_alignment — set dma length and memory alignment
blk_queue_find_tag — find a request by its tag and queue
blk_queue_free_tags — release tag maintenance info
blk_queue_init_tags — initialize the queue tag info
blk_queue_resize_tags — change the queueing depth
blk_queue_end_tag — end tag operations for a request
blk_queue_start_tag — find a free tag and assign it
blk_queue_invalidate_tags — invalidate all pending tags
generic_unplug_device — fire a request queue
blk_start_queue — restart a previously stopped queue
blk_stop_queue — stop a queue
blk_sync_queue — cancel any pending callbacks on a queue
blk_run_queue — run a single device queue
blk_init_queue — prepare a request queue for use with a block device
blk_requeue_request — put a request back on queue
blk_insert_request — insert a special request in to a request queue
blk_rq_map_user — map user data to a request, for REQ_BLOCK_PC usage
blk_rq_map_user_iov — map user data to a request, for REQ_BLOCK_PC usage
blk_rq_unmap_user — unmap a request with user data
blk_rq_map_kern — map kernel data to a request, for REQ_BLOCK_PC usage
blk_execute_rq_nowait — insert a request into queue for execution
blk_execute_rq — insert a request into queue for execution
blkdev_issue_flush — queue a flush
blk_end_sync_rq — executes a completion event on a request
blk_congestion_wait — wait for a queue to become uncongested
generic_make_request
submit_bio
end_that_request_first — end I/O on a request
end_that_request_chunk — end I/O on a request
blk_complete_request — end I/O on a request
23. Miscellaneous Devices
misc_register — register a miscellaneous device
misc_deregister — unregister a miscellaneous device
24. Parallel Port Devices
parport_yield — relinquish a parallel port temporarily
parport_yield_blocking — relinquish a parallel port temporarily
parport_wait_event — wait for an event on a parallel port
parport_wait_peripheral — wait for status lines to change in 35ms
parport_negotiate — negotiate an IEEE 1284 mode
parport_write — write a block of data to a parallel port
parport_read — read a block of data from a parallel port
parport_set_timeout — set the inactivity timeout for a device
parport_register_driver — register a parallel port device driver
parport_unregister_driver — deregister a parallel port device driver
parport_get_port — increment a port's reference count
parport_put_port — decrement a port's reference count
parport_register_port — register a parallel port
parport_announce_port — tell device drivers about a parallel port
parport_remove_port — deregister a parallel port
parport_register_device — register a device on a parallel port
parport_unregister_device — deregister a device on a parallel port
parport_find_number — find a parallel port by number
parport_find_base — find a parallel port by base address
parport_claim — claim access to a parallel port device
parport_claim_or_block — claim access to a parallel port device
parport_release — give up access to a parallel port device
parport_open — find a device by canonical device number
parport_close — close a device opened with parport_open
parport_device_num — convert device coordinates
25. Video4Linux
video_register_device — register video4linux devices
video_unregister_device — unregister a video4linux device
26. Sound Devices
snd_printk — printk wrapper
snd_printd — debug printk
snd_assert — run-time assertion macro
snd_printdd — debug printk
register_sound_special_device — register a special sound node
register_sound_mixer — register a mixer device
register_sound_midi — register a midi device
register_sound_dsp — register a DSP device
register_sound_synth — register a synth device
unregister_sound_special — unregister a special sound device
unregister_sound_mixer — unregister a mixer
unregister_sound_midi — unregister a midi device
unregister_sound_dsp — unregister a DSP device
unregister_sound_synth — unregister a synth device
snd_pcm_playback_ready — check whether the playback buffer is available
snd_pcm_capture_ready — check whether the capture buffer is available
snd_pcm_playback_data — check whether any data exists on the playback buffer
snd_pcm_playback_empty — check whether the playback buffer is empty
snd_pcm_capture_empty — check whether the capture buffer is empty
snd_pcm_format_cpu_endian — Check the PCM format is CPU-endian
snd_pcm_new_stream — create a new PCM stream
snd_pcm_new — create a new PCM instance
snd_device_new — create an ALSA device component
snd_device_free — release the device from the card
snd_device_register — register the device
snd_iprintf — printf on the procfs buffer
snd_info_get_line — read one line from the procfs buffer
snd_info_get_str — parse a string token
snd_info_create_module_entry — create an info entry for the given module
snd_info_create_card_entry — create an info entry for the given card
snd_card_proc_new — create an info entry for the given card
snd_info_free_entry — release the info entry
snd_info_register — register the info entry
snd_info_unregister — de-register the info entry
snd_rawmidi_receive — receive the input data from the device
snd_rawmidi_transmit_empty — check whether the output buffer is empty
snd_rawmidi_transmit_peek — copy data from the internal buffer
snd_rawmidi_transmit_ack — acknowledge the transmission
snd_rawmidi_transmit — copy from the buffer to the device
snd_rawmidi_new — create a rawmidi instance
snd_rawmidi_set_ops — set the rawmidi operators
snd_request_card — try to load the card module
snd_lookup_minor_data — get user data of a registered device
snd_register_device — Register the ALSA device file for the card
snd_unregister_device — unregister the device on the given card
copy_to_user_fromio — copy data from mmio-space to user-space
copy_from_user_toio — copy data from user-space to mmio-space
snd_pcm_lib_preallocate_free_for_all — release all pre-allocated buffers on the pcm
snd_pcm_lib_preallocate_pages — pre-allocation for the given DMA type
snd_pcm_lib_preallocate_pages_for_all — pre-allocation for continous memory type (all substreams)
snd_pcm_sgbuf_ops_page — get the page struct at the given offset
snd_pcm_lib_malloc_pages — allocate the DMA buffer
snd_pcm_lib_free_pages — release the allocated DMA buffer.
snd_card_new — create and initialize a soundcard structure
snd_card_disconnect — disconnect all APIs from the file-operations (user space)
snd_card_free — frees given soundcard structure
snd_card_free_in_thread — call snd_card_free in thread
snd_card_register — register the soundcard
snd_component_add — add a component string
snd_card_file_add — add the file to the file list of the card
snd_card_file_remove — remove the file from the file list
snd_power_wait — wait until the power-state is changed.
snd_dma_program — program an ISA DMA transfer
snd_dma_disable — stop the ISA DMA transfer
snd_dma_pointer — return the current pointer to DMA transfer buffer in bytes
snd_ctl_new — create a control instance from the template
snd_ctl_new1 — create a control instance from the template
snd_ctl_free_one — release the control instance
snd_ctl_add — add the control instance to the card
snd_ctl_remove — remove the control from the card and release it
snd_ctl_remove_id — remove the control of the given id and release it
snd_ctl_rename_id — replace the id of a control on the card
snd_ctl_find_numid — find the control instance with the given number-id
snd_ctl_find_id — find the control instance with the given id
snd_pcm_set_ops — set the PCM operators
snd_pcm_set_sync — set the PCM sync id
snd_interval_refine — refine the interval value of configurator
snd_interval_ratnum — refine the interval value
snd_interval_list — refine the interval value from the list
snd_pcm_hw_rule_add — add the hw-constraint rule
snd_pcm_hw_constraint_integer
snd_pcm_hw_constraint_minmax
snd_pcm_hw_constraint_list
snd_pcm_hw_constraint_ratnums
snd_pcm_hw_constraint_ratdens
snd_pcm_hw_constraint_msbits
snd_pcm_hw_constraint_step
snd_pcm_hw_constraint_pow2
snd_pcm_hw_param_value
snd_pcm_hw_param_first
snd_pcm_hw_param_last
snd_pcm_lib_ioctl — a generic PCM ioctl callback
snd_pcm_period_elapsed — update the pcm status for the next period
snd_hwdep_new — create a new hwdep instance
snd_pcm_stop
snd_pcm_suspend
snd_pcm_suspend_all
snd_malloc_pages — allocate pages with the given size
snd_free_pages — release the pages
snd_dma_alloc_pages — allocate the buffer area according to the given type
snd_dma_alloc_pages_fallback — allocate the buffer area according to the given type with fallback
snd_dma_free_pages — release the allocated buffer
snd_dma_get_reserved_buf — get the reserved buffer for the given device
snd_dma_reserve_buf — reserve the buffer
27. 16x50 UART Driver
uart_handle_dcd_change — handle a change of carrier detect state
uart_handle_cts_change — handle a change of clear-to-send state
uart_update_timeout — update per-port FIFO timeout.
uart_get_baud_rate — return baud rate for a particular port
uart_get_divisor — return uart clock divisor
uart_register_driver — register a driver with the uart core layer
uart_unregister_driver — remove a driver from the uart core layer
uart_add_one_port — attach a driver-defined port structure
uart_remove_one_port — detach a driver defined port structure
serial8250_suspend_port — suspend one serial port
serial8250_resume_port — resume one serial port
serial8250_register_port — register a serial port
serial8250_unregister_port — remove a 16x50 serial port at runtime
28. Z85230 Support Library
z8530_interrupt — Handle an interrupt from a Z8530
z8530_sync_open — Open a Z8530 channel for PIO
z8530_sync_close — Close a PIO Z8530 channel
z8530_sync_dma_open — Open a Z8530 for DMA I/O
z8530_sync_dma_close — Close down DMA I/O
z8530_sync_txdma_open — Open a Z8530 for TX driven DMA
z8530_sync_txdma_close — Close down a TX driven DMA channel
z8530_describe — Uniformly describe a Z8530 port
z8530_init — Initialise a Z8530 device
z8530_shutdown — Shutdown a Z8530 device
z8530_channel_load — Load channel data
z8530_null_rx — Discard a packet
z8530_queue_xmit — Queue a packet
z8530_get_stats — Get network statistics
29. Frame Buffer Library
Frame Buffer Memory
Frame Buffer Colormap
Frame Buffer Video Mode Database
Frame Buffer Macintosh Video Mode Database
Frame Buffer Fonts