Linux kernel driver module loading mode

Source: Internet
Author: User

In the Unix-like operating system, the driving load mode is generally divided into: dynamic loading and static loading, which are discussed in detail below.
First, dynamic loading
Dynamic loading is to load the driver module into the kernel and not into the/lib/modules/.
In the 2.4 kernel, the Load Driver command is: Insmod, delete module: rmmod;
In more than 2.6 cores, in addition to Insmod and rmmod, loading commands and modprobe;
The difference between Insmod and modprobe:
Insmod Absolute Path/XX.O, and Modprobexx can be, do not add. ko or. o suffix, or add path; The most important point is that the modprobe will also load the other modules that the current module depends on;
Lsmod View all the driver modules currently loaded into the kernel and provide additional information, such as whether other modules are using another module.
Second, static loading
(i) Concept
When executing the make Menuconfig command for kernel configuration cropping, you can choose whether to compile into the kernel in the window, or to put it in the appropriate kernel version directory under/lib/modules/, or not.
(ii) Operating procedures
Linux devices are generally divided into: character devices, block devices and network equipment, each device in the kernel source code directory tree drivers/has a corresponding directory, its loading method is similar, the following is a character device static loading as an example, assuming that the driver source code named LEDC.C, the following steps:
The first step: the LEDC.C source program into the kernel source code drivers/char/;
The second step: Modify the Drivers/char/config.in file, specifically modified as follows:
According to the format of the open file can be added;
In the appropriate location of the file (this location is optional, but this position determines where it is located in the Make Menuconfig window), add any of the following code:

TriState ' Leddriver ' Config_ledc
If ["$CONFIG _ledc" = "Y"];then
BOOL ' support for LEDs on h9200 Board ' config_ledc_console
Fi
Description: The above code uses TriState to define a macro, indicating that the driver can be compiled directly to the kernel (with * selection), or can be programmed to/lib/modules/(with M selected), or not compiled (not selected).

BOOL ' Leddriver ' Config_ledc
If ["$CONFIG _ledc" = "Y"];then
BOOL ' support for LEDs on h9200 Board ' config_ledc_console
Fi
Description: The above code uses TriState to define a macro, indicating that the driver can only be compiled directly to the kernel (with * selection) or not compiled (not selected), can not be compiled to/lib/modules/(with M selection).

Step three: Modify the Drivers/char/makefile file
Add the following line of code where appropriate:
obj-$ (CONFIG_LEDC) + = LEDC.O
Or add LEDC.O to the obj-y line, such as:
Obj-y + = LEDC.O mem.o back unchanged;

OK, after the settings above, you can select configuration in the character devices---> in the window after the make Menuconfig command is executed. After the selection, recompile is OK.

Limited to my level, if not to do, also please advise!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.