What directory is the default module.h in #include <linux/module.h>? I didn't find the file under the/usr/include/linux.
Also want to ask, different kernel version of Linux header file is not the same. For example: I am on the 2.6.20 kernel system, use 2.6.10 header file will not have the problem.
User reply:
1
My module.h is in the kernel-compiled directory, not under/usr/include/linux,
2
On the 2.6.20 kernel system, the header file with 2.6.10 should be problematic, and the kernel's header file is inconsistent with the kernel running on the current system.
Users reply: You refer to the kernel under the header file.
Not under/usr/include.
Under:/usr/src/kernels/2.6.18-8.el5-x86_64/include/linux/module.h ... The middle version number is not the same ... You can choose your own.
Netizen reply: Excuse me the upstairs why is in/usr/src/kernels/2.6.18-8.el5-x86_64/include/linux/module.h. I checked the environment variables and didn't see the environment variables for the header file. How GCC knows the location of the header file.
Netizen reply: This question is very good,
You need to look at the Linux kernel makefile file. It's in the final place to change the file. :)
User reply: Your program is driven by the kernel layer of the bar.
The header file it calls should be included in the kernel source code. The general system is the kernel source placed under the/USR/SRC, if it is the core of their own compilation, can also be placed elsewhere. As for GCC where to change the file, see Makefile, or directly with the GCC command, add-I to specify the directory.
Netizen replies: Upstairs, but my makefile did not specify include Yes, GCC is how to find the head file.
Users reply: gcc is how to find the head file.
================================
Answer this question, LZ will understand everything, gcc change file has three kinds of strategy:
1. will be specified by default to the/usr/include folder (the deeper is a relative path, the GCC executable path is/usr/bin, then it is the actual work of the specified header file header path is a method of relative paths, conversion to absolute path is/usr/include)
2.GCC also uses the way of the-i-Specify path, which we all know
3. You can also use a parameter to indicate that GCC does not search the system default path, this parameter I forgot, you'll find out when you search.
When compiling the drive module, due to the extraordinary requirements must force GCC not to search the system default path, that is, do not search/usr/include, to use the-I parameter to specify the kernel header file path, this time must be specified in makefile two parameters, one is the kernel header file path, One is to force GCC not to search the system default path. When compiling the kernel, you must use an argument (forcing GCC not to search the system default path), or it can cause confusion.
Another, under the driver is not. The following is the path of the driver: (note that the ARM platform has been predefined here, so it will automatically go to arm-related search)
Driver:
#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 <linux/module.h>//most basic files, support dynamic add and unload modules. Hello World Drive to this one file is OK
#include <linux/fs.h>//contains definitions of struct related to file operations, such as the famous struct file_operations
#include <linux/errno.h>//contains a macro definition of the return value so that the user program can output the error message using Perror.
#include <linux/types.h>//For some specific types of definitions, such as dev_t, off_t, pid_t. In fact, most of these types are unsigned int, which is changed by a series of TypeDef, Just for the convenience of reading.
#include <linux/cdev.h>//The definition of character device structure Cdev and a series of operation functions.
#include <linux/wait.h>//equal generation queue related header file
Application:
#include <fcntl.h>//contains a macro definition for the Flags,mode parameter of the open () function.
Driver:
#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 Drive to this one file is OK
#include <linux/fs.h>//contains definitions of struct related to file operations, such as the famous struct file_operations
Contains the definition of the 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 using Perror.
#include <linux/types.h>//For some specific types of definitions, such as dev_t, off_t, pid_t. In fact, most of these types are unsigned int, which is changed by a series of TypeDef, Just for the convenience of reading.
#include <linux/cdev.h>//The definition of character device structure Cdev and a series of operation functions. Contains the definition of CDEV structure and related functions.
#include <linux/wait.h>//equal generation queue Related header file//kernel wait queue, which contains a spin lock header file
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/slab.h>//contains the definition of the Kcalloc, Kzalloc memory allocation function.
#include <linux/uaccess.h>//contains function definitions for kernel access to user process memory addresses Copy_to_user, Copy_from_user, and so on.
#include <linux/device.h>//contains definitions of device, class, etc.
#include <linux/io.h>//contains definitions of functions such as Ioremap, Iowrite, and other kernel access IO memory.
The #include <linux/miscdevice.h>//contains the definition of miscdevice structure and related operation functions.
#include <linux/interrupt.h>//Use interrupt required header file
#include <mach/irqs.h>//Use interrupt required header file
#include <asm/bitops.h>//contains the set_bit operation function, which is available when implementing the input subsystem.
#include <linux/semaphore.h>//use of Semaphore required header file
#include <linux/spinlock.h>/Spin lock
#include <linux/sched.h>//kernel wait queue to be used Task_normal, task_interruptible included in this header file
#include <linux/kfifo.h>//fifo ring queue
#include <linux/timer.h>//kernel timer
#include <linux/input.h>//Interrupt Handling
Header file home directory include
A total of 32. h header files in the header file directory. There are 13 in the home directory, 4 in the ASM subdirectory, 10 in the Linux subdirectory, and 5 in the SYS subdirectory. The respective functions of these headers are as follows, with specific effects and information contained in chapter 14th.
<a.out.h>:a.out header file, defines the a.out execution file format and some macros.
<const.h>: Constant symbol header file, which currently defines only the flags for 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 number file containing various error numbers in the system. (introduced by Linus from 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 constant, signal structure and signal operation function prototype.
<STDARG.H>: A standard parameter header file that defines a variable argument list as a macro. It mainly describes a type (va_list) and 3 macros (Va_start, Va_arg, and Va_end) for vsprintf, vprintf, and vfprintf functions.
<STDDEF.H>: A standard definition header file that defines null, Offsetof (TYPE, member).
<string.h>: A string header file that primarily defines an embedded function for string manipulation.
<TERMIOS.H>: Terminal Input Output function header file, which mainly defines the terminal interface to control the asynchronous communication port.
<time.h>: The time Type header file, which mainly defines the TM structure and some function prototypes about time.
<unistd.h>:linux Standard header files, defines various symbolic constants and types, and declares various functions. For example, the __library__ is defined, and the system call number and the inline assembler _syscall0 () are included.
<utime.h>: User Time header file that 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 a function for an I/O port operation in the form of a macro embedded assembler.
<asm/memory.h>: Memory Copy header file, containing memcpy () embedded assembly macro function.
<asm/segment.h>: Segment operation header file, defines the embedded assembly function for segment register operation.
<asm/system.h>: The system header file, which defines an embedded assembly macro that sets or modifies the descriptor/interrupt door.
(2) Linux kernel dedicated header file subdirectory Include/linux
<linux/config.h>: Kernel configuration header file, which defines keyboard language and hard disk type (Hd_type) options.
<linux/fdreg.h>: Floppy header file with some definitions of floppy disk controller parameters.
<linux/fs.h>: File system header file, define File table structure (File,buffer_head,m_inode, etc.).
<LINUX/HDREG.H>: Hard disk parameter header file, define access to the hard disk register port, status code and partition table information.
The <linux/head.h>:head header file defines the simple structure of the segment descriptor, and several select constants quantities.
<linux/kernel.h>: Kernel header file, containing some of the kernel common functions of the prototype definition.
<LINUX/MM.H>: Memory Management header file that contains the page size definition and some page release function prototypes.
<linux/sched.h>: Scheduler header file, which defines the task structure task_struct, initial task 0 data,
And some embedded assembler function macro statements about descriptor parameter setting and getting.
<linux/sys.h>: System call header file, containing 72 system call C function handler, begin with "Sys_".
The <linux/tty.h>:tty header file defines the parameters and constants for the TTY_IO, serial communication.
(3) System-specific data structure subdirectory Include/sys
<sys/stat.h>: File state header file, containing file or file system state structure stat{} and constants.
<sys/times.h>: Defines the run-time structure TMS and The Times () function prototype in the process.
<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>: Waits for the call header file to define system call wait () and waitpid () and associated constant notation.