30 lines
911 B
C
30 lines
911 B
C
#include <linux/init.h> /* Needed for the __init, __initdata and __exit macros. */
|
|
#include <linux/module.h> /* for all kernel modules */
|
|
#include <linux/kernel.h> /* for KERN_INFO */
|
|
#include <linux/printk.h> /* Needed for pr_info() */
|
|
#include <linux/moduleparam.h> /* Needed for module_param() */
|
|
|
|
static int intInitData __initdata = 3;
|
|
static int intParameter = 420;
|
|
|
|
module_param(intParameter, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
|
MODULE_PARM_DESC(intParameter, "An integer");
|
|
|
|
static int __init start_module(void) /* module entry point */
|
|
{
|
|
pr_info("Hello , user %d !\n", intInitData);
|
|
return 0;
|
|
}
|
|
|
|
static void __exit exit_module(void) /* module exit point */
|
|
{
|
|
printk(KERN_INFO "Goodbye , user param %d!\n", intParameter);
|
|
return;
|
|
}
|
|
|
|
module_init(start_module);
|
|
module_exit(exit_module);
|
|
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_DESCRIPTION("My first cool kernel module");
|
|
MODULE_AUTHOR("user"); |