finished the kernel module and documentation
This commit is contained in:
parent
9a161636da
commit
14ec32b1bd
9
Makefile
Normal file
9
Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
obj-m += hello.o
|
||||
|
||||
PWD := $(CURDIR)
|
||||
|
||||
all:
|
||||
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
|
||||
|
||||
clean:
|
||||
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
|
12
README.md
12
README.md
@ -1,2 +1,14 @@
|
||||
# Hello_World_Kernel_Module
|
||||
|
||||
## Prerequisits
|
||||
- requires the correct linux headers to be installed
|
||||
- root access is needed
|
||||
|
||||
## how to run the kernel module
|
||||
- `make` to build the module
|
||||
- `sudo insmod hello` to run the module
|
||||
- `sudo rmmod hello` to stop the module
|
||||
|
||||
## viewing the log
|
||||
on systems that run systemd:
|
||||
``` journalctl -f -k ```
|
28
hello.c
Normal file
28
hello.c
Normal file
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* @file hello.c
|
||||
* @author Paul Lödige (ploedige@g.ecc.u-tokyo.ac.jp)
|
||||
* @brief prints "Hello World" from the Kernel
|
||||
* @version 0.1
|
||||
* @date 2022-10-17
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*/
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
|
||||
static int __init hello_init(void) {
|
||||
printk("Hello World!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit hello_exit(void){
|
||||
printk("Goodbye!");
|
||||
}
|
||||
|
||||
module_init(hello_init);
|
||||
module_exit(hello_exit);
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION("Hello World Module");
|
||||
MODULE_AUTHOR("ploedige");
|
Loading…
x
Reference in New Issue
Block a user