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
Uninstall the installed version on Ubuntu: sudo a...
Remove the dotted box on the link Copy code The co...
Professional web design is complex and time-consu...
Table of contents 1 Introduction 2 Basic usage 2....
Preface In Windows, you can start multiple MySQL ...
VMware Workstation is a powerful desktop virtual ...
Table of contents 01 JavaScript (abbreviated as: ...
If you want the path following the domain name to...
MySQL database is widely used, especially for JAV...
Perfect solution to the scalable column problem o...
I was bored and suddenly thought of the implementa...
Table of contents 1. typeof 2. instanceof 3. Diff...
Flexible layout (Flexbox) is becoming increasingl...
Table of contents Preface How does antd encapsula...
Scrcpy Installation snap install scrcpy adb servi...