Created
January 21, 2015 06:03
-
-
Save zhustec/370ff7ad0cc3572f692d to your computer and use it in GitHub Desktop.
Linux 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> | |
| #include <linux/kernel.h> | |
| #include <linux/init.h> | |
| MODULE_AUTHOR("sloger"); | |
| MODULE_LICENSE("GPLv3"); | |
| MODULE_DESCRIPTION("Hello Kernel"); | |
| static int __init printk_init(void) | |
| { | |
| printk(KERN_ALERT "Hello Kernel!\n"); | |
| return 0; | |
| } | |
| static void __exit printk_exit(void) | |
| { | |
| printk(KERN_ALERT "Good Bye!\n"); | |
| } | |
| module_init(printk_init); | |
| module_exit(printk_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
| ifneq ($(KERNELRELEASE),) | |
| obj-m := hello.o | |
| else | |
| KERNELDIR ?= /lib/modules/$(shell uname -r)/build | |
| PWD := $(shell pwd) | |
| all: | |
| $(MAKE) -C $(KERNELDIR) M=$(PWD) modules | |
| clean: | |
| $(MAKE) -C $(KERNELDIR) M=$(PWD) clean | |
| endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment