The Linux Kernel API

c or linux 2006. 2. 14. 04:14
The Linux Kernel API

 

http://kernelnewbies.org/documents/kdoc/kernel-api/linuxkernelapi.html

 

Table of Contents
1. Driver Basics
Driver Entry and Exit points
module_init — driver initialization entry point
module_exit — driver exit entry point
Atomic and pointer manipulation
atomic_read — read atomic variable
atomic_set — set atomic variable
atomic_add — add integer to atomic variable
atomic_sub — subtract the atomic variable
atomic_sub_and_test — subtract value from variable and test result
atomic_inc — increment atomic variable
atomic_dec — decrement atomic variable
atomic_dec_and_test — decrement and test
atomic_inc_and_test — increment and test
atomic_add_negative — add and test if negative
get_unaligned — get value from possibly mis-aligned location
put_unaligned — put value to a possibly mis-aligned location
Delaying, scheduling, and timer routines
schedule_timeout — sleep until timeout
2. Data Types
Doubly Linked Lists
list_add — add a new entry
list_add_tail — add a new entry
list_del — deletes entry from list.
list_del_init — deletes entry from list and reinitialize it.
list_empty — tests whether a list is empty
list_splice — join two lists
list_entry — get the struct for this entry
list_for_each — iterate over a list
list_for_each_safe — iterate over a list safe against removal of list entry
3. Basic C Library Functions
String Conversions
simple_strtol — convert a string to a signed long
simple_strtoll — convert a string to a signed long long
simple_strtoul — convert a string to an unsigned long
simple_strtoull — convert a string to an unsigned long long
vsnprintf — Format a string and place it in a buffer
snprintf — Format a string and place it in a buffer
vsprintf — Format a string and place it in a buffer
sprintf — Format a string and place it in a buffer
String Manipulation
strcpy — Copy a NUL terminated string
strncpy — Copy a length-limited, NUL-terminated string
strcat — Append one NUL-terminated string to another
strncat — Append a length-limited, NUL-terminated string to another
strcmp — Compare two strings
strncmp — Compare two length-limited strings
strchr — Find the first occurrence of a character in a string
strrchr — Find the last occurrence of a character in a string
strlen — Find the length of a string
strnlen — Find the length of a length-limited string
strpbrk — Find the first occurrence of a set of characters
strtok — Split a string into tokens
memset — Fill a region of memory with the given value
bcopy — Copy one area of memory to another
memcpy — Copy one area of memory to another
memmove — Copy one area of memory to another
memcmp — Compare two areas of memory
memscan — Find a character in an area of memory.
strstr — Find the first substring in a NUL terminated string
memchr — Find a character in an area of memory.
Bit Operations
set_bit — Atomically set a bit in memory
__set_bit — Set a bit in memory
clear_bit — Clears a bit in memory
__change_bit — Toggle a bit in memory
change_bit — Toggle a bit in memory
test_and_set_bit — Set a bit and return its old value
__test_and_set_bit — Set a bit and return its old value
test_and_clear_bit — Clear a bit and return its old value
__test_and_clear_bit — Clear a bit and return its old value
test_and_change_bit — Change a bit and return its new value
test_bit — Determine whether a bit is set
find_first_zero_bit — find the first zero bit in a memory region
find_next_zero_bit — find the first zero bit in a memory region
ffz — find first zero in word.
ffs — find first bit set
hweight32 — returns the hamming weight of a N-bit word
4. Memory Management in Linux
The Slab Cache
kmem_cache_create — Create a cache.
kmem_cache_shrink — Shrink a cache.
kmem_cache_destroy — delete a cache
kmem_cache_alloc — Allocate an object
kmalloc — allocate memory
kmem_cache_free — Deallocate an object
kfree — free previously allocated memory
5. The proc filesystem
sysctl interface
register_sysctl_table — register a sysctl heirarchy
unregister_sysctl_table — unregister a sysctl table heirarchy
proc_dostring — read a string sysctl
proc_dointvec — read a vector of integers
proc_dointvec_minmax — read a vector of integers with min/max values
proc_doulongvec_minmax — read a vector of long integers with min/max values
proc_doulongvec_ms_jiffies_minmax — read a vector of millisecond values with min/max values
proc_dointvec_jiffies — read a vector of integers as seconds
6. The Linux VFS
The Directory Cache
d_invalidate — invalidate a dentry
d_find_alias — grab a hashed alias of inode
prune_dcache — shrink the dcache
shrink_dcache_sb — shrink dcache for a superblock
have_submounts — check for mounts over a dentry
shrink_dcache_parent — prune dcache
d_alloc — allocate a dcache entry
d_instantiate — fill in inode information for a dentry
d_alloc_root — allocate root dentry
d_lookup — search for a dentry
d_validate — verify dentry provided from insecure source
d_delete — delete a dentry
d_rehash — add an entry back to the hash
d_move — move a dentry
__d_path — return the path of a dentry
is_subdir — is new dentry a subdirectory of old_dentry
find_inode_number — check for dentry with name
d_drop — drop a dentry
d_add — add dentry to hash queues
dget — get a reference to a dentry
d_unhashed — is dentry hashed
Inode Handling
__mark_inode_dirty — internal function
write_inode_now — write an inode to disk
clear_inode — clear an inode
invalidate_inodes — discard the inodes on a device
get_empty_inode — obtain an inode
iunique — get a unique inode number
insert_inode_hash — hash an inode
remove_inode_hash — remove an inode from the hash
iput — put an inode
bmap — find a block number in a file
update_atime — update the access time
make_bad_inode — mark an inode bad due to an I/O error
is_bad_inode — is an inode errored
Registration and Superblocks
register_filesystem — register a new filesystem
unregister_filesystem — unregister a file system
get_super — get the superblock of a device
File Locks
posix_lock_file
__get_lease — revoke all outstanding leases on file
lease_get_mtime
posix_block_lock — blocks waiting for a file lock
posix_unblock_lock — stop waiting for a file lock
lock_may_read — checks that the region is free of locks
lock_may_write — checks that the region is free of locks
fcntl_getlease — Enquire what lease is currently active
fcntl_setlease — sets a lease on an open file
sys_flockflock system call.
get_locks_status — reports lock usage in /proc/locks
7. Linux Networking
Socket Buffer Functions
skb_queue_empty — check if a queue is empty
skb_get — reference buffer
kfree_skb — free an sk_buff
skb_cloned — is the buffer a clone
skb_shared — is the buffer shared
skb_share_check — check if buffer is shared and if so clone it
skb_unshare — make a copy of a shared buffer
skb_peek
skb_peek_tail
skb_queue_len — get queue length
__skb_queue_head — queue a buffer at the list head
skb_queue_head — queue a buffer at the list head
__skb_queue_tail — queue a buffer at the list tail
skb_queue_tail — queue a buffer at the list tail
__skb_dequeue — remove from the head of the queue
skb_dequeue — remove from the head of the queue
skb_insert — insert a buffer
skb_append — append a buffer
skb_unlink — remove a buffer from a list
__skb_dequeue_tail — remove from the tail of the queue
skb_dequeue_tail — remove from the head of the queue
skb_put — add data to a buffer
skb_push — add data to the start of a buffer
skb_pull — remove data from the start of a buffer
skb_headroom — bytes at buffer head
skb_tailroom — bytes at buffer end
skb_reserve — adjust headroom
skb_trim — remove end from a buffer
skb_orphan — orphan a buffer
skb_queue_purge — empty a list
__skb_queue_purge — empty a list
__dev_alloc_skb — allocate an skbuff for sending
dev_alloc_skb — allocate an skbuff for sending
skb_cow — copy header of skb when it is required
skb_over_panic — private function
skb_under_panic — private function
alloc_skb — allocate a network buffer
__kfree_skb — private function
skb_clone — duplicate an sk_buff
skb_copy — create private copy of an sk_buff
pskb_copy — create copy of an sk_buff with private head.
pskb_expand_head — reallocate header of sk_buff
skb_copy_expand — copy and expand sk_buff
__pskb_pull_tail — advance tail of skb header
Socket Filter
sk_run_filter — run a filter on a socket
sk_chk_filter — verify socket filter code
8. Network device support
Driver Support
init_etherdev — Register ethernet device
alloc_etherdev — Allocates and sets up an ethernet device
init_fddidev — Register FDDI device
alloc_fddidev — Register FDDI device
init_hippi_dev — Register HIPPI device
alloc_hippi_dev — Register HIPPI device
init_trdev — Register token ring device
alloc_trdev — Register token ring device
init_fcdev — Register fibre channel device
alloc_fcdev — Register fibre channel device
dev_add_pack — add packet handler
dev_remove_pack — remove packet handler
__dev_get_by_name — find a device by its name
dev_get_by_name — find a device by its name
dev_get — test if a device exists
__dev_get_by_index — find a device by its ifindex
dev_get_by_index — find a device by its ifindex
dev_alloc_name — allocate a name for a device
dev_alloc — allocate a network device and name
netdev_state_change — device changes state
dev_load — load a network module
dev_open — prepare an interface for use.
dev_close — shutdown an interface.
register_netdevice_notifier — register a network notifier block
unregister_netdevice_notifier — unregister a network notifier block
dev_queue_xmit — transmit a buffer
netif_rx — post buffer to the network code
net_call_rx_atomic
register_gifconf — register a SIOCGIF handler
netdev_set_master — set up master/slave pair
dev_set_promiscuity — update promiscuity count on a device
dev_set_allmulti — update allmulti count on a device
dev_ioctl — network device ioctl
dev_new_index — allocate an ifindex
netdev_finish_unregister — complete unregistration
unregister_netdevice — remove device from the kernel
8390 Based Network Cards
ei_open — Open/initialize the board.
ei_close — shut down network device
ei_tx_timeout — handle transmit time out condition
ei_interrupt — handle the interrupts from an 8390
ethdev_init — init rest of 8390 device struct
NS8390_init — initialize 8390 hardware
Synchronous PPP
sppp_input — receive and process a WAN PPP frame
sppp_close — close down a synchronous PPP or Cisco HDLC link
sppp_open — open a synchronous PPP or Cisco HDLC link
sppp_reopen — notify of physical link loss
sppp_change_mtu — Change the link MTU
sppp_do_ioctl — Ioctl handler for ppp/hdlc
sppp_attach — attach synchronous PPP/HDLC to a device
sppp_detach — release PPP resources from a device
9. Module Support
Module Loading
request_module — try to load a kernel module
call_usermodehelper — start a usermode application
Inter Module support
inter_module_register — register a new set of inter module data.
inter_module_unregister — unregister a set of inter module data.
inter_module_get — return arbitrary userdata from another module.
inter_module_get_request — im get with automatic request_module.
inter_module_put — release use of data from another module.
10. Hardware Interfaces
Interrupt Handling
disable_irq_nosync — disable an irq without waiting
disable_irq — disable an irq and wait for completion
enable_irq — enable handling of an irq
probe_irq_mask — scan a bitmap of interrupt lines
MTRR Handling
mtrr_add — Add a memory type region
mtrr_del — delete a memory type region
PCI Support Library
pci_find_slot — locate PCI device from a given PCI slot
pci_find_subsys — begin or continue searching for a PCI device by vendor/subvendor/device/subdevice id
pci_find_device — begin or continue searching for a PCI device by vendor/device id
pci_find_class — begin or continue searching for a PCI device by class
pci_find_capability — query for devices' capabilities
pci_find_parent_resource — return resource region of parent bus of given region
pci_set_power_state — Set the power state of a PCI device
pci_save_state — save the PCI configuration space of a device before suspending
pci_restore_state — Restore the saved state of a PCI device
pci_enable_device — Initialize device before it's used by a driver.
pci_disable_device — Disable PCI device after use
pci_enable_wake — enable device to generate PME# when suspended
pci_release_regions — Release reserved PCI I/O and memory resources
pci_request_regions — Reserved PCI I/O and memory resources
pci_match_device — Tell if a PCI device structure has a matching PCI device id structure
pci_register_driver — register a new pci driver
pci_unregister_driver — unregister a pci driver
pci_insert_device — insert a hotplug device
pci_remove_device — remove a hotplug device
pci_dev_driver — get the pci_driver of a device
pci_set_master — enables bus-mastering for device dev
pci_setup_device — fill in class and map information of a device
pci_pool_create — Creates a pool of pci consistent memory blocks, for dma.
pci_pool_destroy — destroys a pool of pci memory blocks.
pci_pool_alloc — get a block of consistent memory
pci_pool_free — put block back into pci pool
MCA Architecture
MCA Device Functions
MCA Bus DMA
11. The Device File System
devfs_register — Register a device entry.
devfs_unregister — Unregister a device entry.
devfs_mk_symlink
devfs_mk_dir — Create a directory in the devfs namespace.
devfs_find_handle — Find the handle of a devfs entry.
devfs_get_flags — Get the flags for a devfs entry.
devfs_get_maj_min — Get the major and minor numbers for a devfs entry.
devfs_get_handle_from_inode — Get the devfs handle for a VFS inode.
devfs_generate_path — Generate a pathname for an entry, relative to the devfs root.
devfs_get_ops — Get the device operations for a devfs entry.
devfs_set_file_size — Set the file size for a devfs regular file.
devfs_get_info — Get the info pointer written to private_data of de upon open.
devfs_set_info — Set the info pointer written to private_data upon open.
devfs_get_parent — Get the parent device entry.
devfs_get_first_child — Get the first leaf node in a directory.
devfs_get_next_sibling — Get the next sibling leaf node. for a device entry.
devfs_auto_unregister — Configure a devfs entry to be automatically unregistered.
devfs_get_unregister_slave — Get the slave entry which will be automatically unregistered.
devfs_get_name — Get the name for a device entry in its parent directory.
devfs_register_chrdev — Optionally register a conventional character driver.
devfs_register_blkdev — Optionally register a conventional block driver.
devfs_unregister_chrdev — Optionally unregister a conventional character driver.
devfs_unregister_blkdev — Optionally unregister a conventional block driver.
12. Power Management
pm_register — register a device with power management
pm_unregister — unregister a device with power management
pm_unregister_all — unregister all devices with matching callback
pm_send — send request to a single device
pm_send_all — send request to all managed devices
pm_find — find a device
13. Block Devices
blk_cleanup_queue — release a request_queue_t when it is no longer needed
blk_queue_headactive — indicate whether head of request queue may be active
blk_queue_make_request — define an alternate make_request function for a device
blk_init_queue — prepare a request queue for use with a block device
generic_make_request
submit_bh
ll_rw_block — level access to block devices
end_that_request_first — end I/O on one buffer.
14. Miscellaneous Devices
misc_register — register a miscellaneous device
misc_deregister — unregister a miscellaneous device
15. Video4Linux
video_unregister_device — unregister a video4linux device
16. Sound Devices
register_sound_special — 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
17. USB Devices
usb_register — register a USB driver
usb_scan_devices — scans all unclaimed USB interfaces
usb_deregister — unregister a USB driver
usb_alloc_bus — creates a new USB host controller structure
usb_free_bus — frees the memory used by a bus structure
usb_register_bus — registers the USB host controller with the usb core
usb_deregister_bus — deregisters the USB host controller
usb_match_id — find first usb_device_id matching device or interface
usb_alloc_urb — creates a new urb for a USB driver to use
usb_free_urb — frees the memory used by a urb
usb_control_msg — Builds a control urb, sends it off and waits for completion
usb_bulk_msg — Builds a bulk urb, sends it off and waits for completion
18. 16x50 UART Driver
register_serial — configure a 16x50 serial port at runtime
unregister_serial — deconfigure a 16x50 serial port
19. 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
20. Frame Buffer Library
Frame Buffer Memory
register_framebuffer — registers a frame buffer device
unregister_framebuffer — releases a frame buffer device
Frame Buffer Console
fbcon_redraw_clear — clear area of the screen
fbcon_redraw_bmove — copy area of screen to another area
Frame Buffer Colormap
fb_alloc_cmap — allocate a colormap
fb_copy_cmap — copy a colormap
fb_get_cmap — get a colormap
fb_set_cmap — set the colormap
fb_default_cmap — get default colormap
fb_invert_cmaps — invert all defaults colormaps
Frame Buffer Generic Functions
fbgen_get_fix — get fixed part of display
fbgen_get_var — get user defined part of display
fbgen_set_var — set the user defined part of display
fbgen_get_cmap — get the colormap
fbgen_set_cmap — set the colormap
fbgen_pan_display — pan or wrap the display
fbgen_do_set_var — change the video mode
fbgen_set_disp — set generic display
fbgen_install_cmap — install the current colormap
fbgen_update_var — update user defined part of display
fbgen_switch — switch to a different virtual console.
fbgen_blank — blank the screen
Frame Buffer Video Mode Database
fb_find_mode — finds a valid video mode
__fb_try_mode — test a video mode
Frame Buffer Macintosh Video Mode Database
console_getmode — get current mode
console_setmode — sets current console mode
console_setcmap — sets palette color map for console
console_powermode — sets monitor power mode
mac_vmode_to_var — converts vmode/cmode pair to var structure
mac_var_to_vmode — convert var structure to MacOS vmode/cmode pair
mac_map_monitor_sense — Convert monitor sense to vmode
mac_find_mode — find a video mode
Frame Buffer Fonts
fbcon_find_font — find a font
fbcon_get_default_font — get default font
Posted by '김용환'
,