1. Module parameters Defining variables in the driver static int num = 0; //When the loading module does not specify the value of num, it is 0
The calling relationship of module_param is as follows: #define module_param(name, type, perm) \ module_param_named(name, name, type, perm) #define module_param_named(name, value, type, perm) \ param_check_##type(name, &(value)); \ module_param_call(name, param_set_##type, param_get_##type, &value, perm); \ __MODULE_PARM_TYPE(name, #type) #define module_param_call(name, set, get, arg, perm) \ __module_param_call(MODULE_PARAM_PREFIX, \ name, set, get, arg, \ __same_type(*(arg), bool), perm) #define __module_param_call(prefix, name, set, get, arg, isbool, perm) \ static int __param_perm_check_##name __attribute__((unused)) = \ BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)) \ + BUILD_BUG_ON_ZERO(sizeof(""prefix) > MAX_PARAM_PREFIX_LEN); \ static const char __param_str_##name[] = prefix #name; \ static struct kernel_param __moduleparam_const __param_##name \ __used \ __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \ = { __param_str_##name, perm, isbool ? KPARAM_ISBOOL : 0, \ set, get, { arg } } Multiple c files can be compiled into a module, which can be achieved using the instructions in the Makefile xxx-objs, as follows: test-objs := ao bo //Compile into test.ko from ac and bc. Note that there cannot be a .o file with the same name as the target ko file obj-m += test.o You can view the module information in the system under /sys/module/module name/ 1. View the information of the elf file Ko file composition
2. EXPORT_SYMBOL(function name/variable address) //Export the address of the function/or variable to the kernel symbol table EXPORT_SYMBOL_GPL(function name) /////////// /proc/kallsyms View the symbol table of the current system Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links You may also be interested in:
|
<<: Example of adding and deleting range partitions in MySQL 5.5
>>: JavaScript implements the protocol example in which the user must check the box
1. Best left prefix principle - If multiple colum...
How to view files in a docker image 1. If it is a...
This story starts with an unexpected discovery tod...
For example, there is an input box <el-input r...
The spread operator allows an expression to be ex...
Table of contents 0. Background 1. Installation 2...
Table of contents What is cgroup Composition of c...
FileReader is an important API for front-end file...
In daily work, we sometimes run slow queries to r...
First and foremost, I am a web designer. To be mor...
Today I will talk about a CSS special effect of h...
The link-in style is to put all the styles in one...
webpack loads css files and its configuration Aft...
Ubuntu 15.04 opens MySQL remote port 3306. All th...