Created
February 11, 2019 14:40
-
-
Save aita/0eab60e682f7d9ca7c6c787ea1060ef7 to your computer and use it in GitHub Desktop.
Hello World Kernel Module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <linux/module.h> | |
| MODULE_LICENSE("GPL v2"); | |
| MODULE_DESCRIPTION("Hello world kernel module"); | |
| static int mymodule_init(void) { | |
| printk(KERN_ALERT "Hello world!\n"); | |
| return 0; | |
| } | |
| static void mymodule_exit(void) { | |
| printk(KERN_ALERT "Good Bye world!\n"); | |
| } | |
| module_init(mymodule_init); | |
| module_exit(mymodule_exit); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| obj-m := hello.o | |
| KDIR := /lib/modules/$(shell uname -r)/build | |
| PWD := $(shell pwd) | |
| VERBOSE = 0 | |
| default: | |
| $(MAKE) -C $(KDIR) M=$(PWD) KBUILD_VERBOSE=$(VERBOSE) modules | |
| clean: | |
| rm -f *.o *.ko *.mod.c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment