Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the initialization process of the Linux kernel module

Shulou Source: shulou.com Published: 2022-06-03 05:30:04 09月28日 Update

Linux kernel module initialization process is how, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

I. Code

Module 1 derives the function void output (void), and module 2 calls the functions in module 1. (load module 1 first, then module 2)

Module 1:

# include # include / / static int int_var = 0 default modulekeeper param (int_var, int, 0644); MODULE_PARM_DESC (int_var, "An integer variable"); static char* str_var = "default"; module_param_named (str_var_alias, str_var, charp, 0644); MODULE_PARM_DESC (str_var_alias, "A string variable"); static char str_var2 [10]; module_param_string (str_var2_alias, str_var2, 10, 0644) MODULE_PARM_DESC (str_var2_alias, "A string variable"); static int int_arr [10]; int narr;module_param_array (int_arr, int, & narr, 0644); MODULE_PARM_DESC (int_arr, "An integer array"); static int int_arr2 [10]; int narr2;module_param_array_named (int_arr2_alias, int_arr2, int, & narr2, 0644); MODULE_PARM_DESC (int_arr2_alias, "An integer array") / / static void output (void) {printk ("hello world!\ n");} EXPORT_SYMBOL_GPL (output); static int_ _ init init_marker (void) {int i; printk ("init marker.\ n"); / / printk ("int_var:%d\ n", int_var); printk ("str_var:%s\ n", str_var); printk ("str_var2:%s\ n", str_var2); for (iTun0) I

Tags: Modules parameters functions memory name kernel variables characters permissions symbols types allocation loading different information strings copies pointers arrays files Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Tech Info Docker Redmi Linux