Create helloworld.c file under our helloworld directory and add the C code below, this is a simple Hello World Kernel Module
user@workstation:~/helloworld$helloworld.c
#include <linux/init.h>#include <linux/kernel.h>#include <linux/module.h>staticintmodule_init_function(void){printk(KERN_INFO"Module? Hello!\n");return0;}staticvoidmodule_exit_function(void){printk(KERN_INFO"Module? Bye!\n");}MODULE_LICENSE("GPL");MODULE_AUTHOR("xe1gyq");MODULE_DESCRIPTION("My First Linux Kernel Module");module_init(module_init_function);module_exit(module_exit_function);
Hello World Module Makefile
Create the Makefile under helloworld directory and add the code below