Transferred from: http://blog.csdn.net/lufeiop02/article/details/6448497
About the Linux driver (application) Program header file Use Favorites
Drivers:
#include <linux/***.h> is looking for source files under Linux-2.6.29/include/linux.
#include <asm/***.h> is looking for source files under Linux-2.6.29/arch/arm/include/asm.
#include <mach/***.h> is looking for source files under Linux-2.6.29/arch/arm/mach-s3c2410/include/mach.
#include <plat/regs-adc.h> in linux-2.6.31_tx2440a20100510/linux-2.6.31_tx2440a/arch/arm/plat-s3c/include/ Plat
#include <linux/module.h>//most basic files, support dynamic Add and unload modules . Hello World Driver wants this one file on it
#include <linux/fs.h>//contains definitions of file operations related structs , such as the famous struct file_operations
Contains the definition of struct inode , MINOR, major header file.
#include <linux/errno.h>//contains a macro definition of the return value so that the user program can output the error message with Perror.
#include <linux/types.h>// definitions for some special types , such as dev_t, off_t, pid_t. Most of these types are unsigned The int is changed through a series of TypeDef, just to facilitate reading.
#include <linux/cdev.h>//CDEV The structure of the character device and the definition of a series of operation functions . Contains the definitions of the CDEV structure and related functions.
#include <linux/wait.h>// wait Queue related header file //kernel wait queue, it contains the spin lock header file
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/slab.h>//includesKcalloc, Kzalloc memory allocation functionThe definition.
#include <linux/uaccess.h>//Includes Copy_to_user, Copy_from_user, etc.function definition for kernel Access user process memory address。
#include <linux/device.h>//includesdevice, class, and other structuresThe definition
#include <linux/io.h>//includesfunctions such as Ioremap, Iowrite and other kernel access IO memoryThe definition.
#include <linux/miscdevice.h>//includesthe definition of miscdevice structure and its related operation function。
#include <linux/interrupt.h>//UseInterruptsThe required header file
#include <mach/irqs.h>//UseInterruptsThe required header file
#include <asm/bitops.h>//including set_bit, etc.bit Operation LetterInput subsystem can be implemented.
#include <linux/semaphore.h>//UseSignal VolumeThe required header file
#include <linux/spinlock.h>//Spin lock
#include <linux/sched.h>// kernel wait queue to use the Task_normal, task_interruptible contained in this header file
#include <linux/kfifo.h>/FIFO ring queue
#include <linux/timer.h>// Core Timers
#include <linux/input.h>// Interrupt handling
Header file home directory include
There are a total of 32. h header files in the header file directory. There are 13 in the main directory, 4 in the ASM subdirectory, 10 in the Linux subdirectory, and 5 in the SYS subdirectory . The respective functions of these header files are as follows, the specific functions and the information contained in the 14th chapter.
<a.out.h>:a.out header file that defines the a.out execution file format and some macros.
<CONST.H>: constant symbol header file, currently only defines the flag bits of the I_mode field in the I node.
<ctype.h>: A character type header file that defines some macros about character type judgments and conversions.
<ERRNO.H>: Error xwould file containing various error numbers in the system. (Linus introduced from the Minix).
<fcntl.h>: The file control header file, which is used for the operation of the file and its descriptor to control the definition of the constant symbol.
<signal.h>: Signal header file, define signal symbol constants, signal structure and signal operation function prototype.
<STDARG.H>: A standard parameter header file that defines a variable parameter list as a macro. The main description is a type (va_list) and 3 macros (Va_start, Va_arg, and Va_end) for vsprintf, vprintf, vfprintf functions.
<STDDEF.H>: standard definition header file, defines null, Offsetof (TYPE, MEMBER).
<string.h>: string header file that defines some embedded functions for string manipulation.
<TERMIOS.H>: terminal input and Output function header file, mainly defines the terminal interface to control the asynchronous communication port.
<time.h>: The time type header file, mainly defines the TM structure and some time-related function prototype.
<unistd.h>:linux a standard header file that defines various symbol constants and types, and declares various functions. For example, __library__ is defined, and the system call number and inline assembler _syscall0 () are included.
<utime.h>: User Time header file, defines the access and modification time structure, and the Utime () prototype.
(1) Architecture related header file subdirectory include/asm
These header files primarily define data structures, macro functions, and variables that are closely related to the CPU architecture. A total of 4 files.
A <ASM/IO.H>:I/O header file that defines functions for I/O port operations in the form of an embedded assembler of macros.
<asm/memory.h>: Memory copy header file containing memcpy () embedded assembly macro function.
<asm/segment.h>: Segment operation header file, defines the embedded assembler function for the segment register operation.
<asm/system.h>: System header file, which defines the embedded assembly macros for setting or modifying descriptors/break gates, etc.
(2) Linux kernel dedicated header file subdirectory Include/linux
<linux/config.h>: Kernel configuration header file, define keyboard language and hard disk type (Hd_type) options.
<linux/fdreg.h>: Floppy drive header file containing some definitions of the floppy disk controller parameters.
<linux/fs.h>: File system header file, definition file table structure (File,buffer_head,m_inode, etc.).
<LINUX/HDREG.H>: Hard disk parameter header file, which defines information such as access to the hard disk register port, status code, and partition table.
The <linux/head.h>:head header file defines the simple structure of the segment descriptor, and several selection constants.
<linux/kernel.h>: Kernel header file, contains some of the kernel common functions of the prototype definition.
<LINUX/MM.H>: Memory management header file containing page size definitions and some page release function prototypes.
<linux/sched.h>: Scheduler header file that defines the data for the task structure task_struct, initial task 0,
As well as some embedded assembler function macro statements about descriptor parameter setting and getting.
<LINUX/SYS.H>: The system calls the header file, which contains 72 system calls to the C function handler, beginning with "Sys_".
The <linux/tty.h>:tty header file defines the parameters and constants for Tty_io, serial communication.
(3) System-specific data structure subdirectory Include/sys
<sys/stat.h>: File status header file, containing file or file system state structure stat{} and constants.
<SYS/TIMES.H>: Defines a process run time structure TMS and The Times () function prototype.
<sys/types.h>: A type header file that defines the basic system data type.
<sys/utsname.h>: System name Structure header file.
<sys/wait.h>: Wait for the calling header file to define the system call Wait () and Waitpid () and the associated constant symbol.
Write the header files used by the Linux driver (GO)