Kernel demo /* * hello.c -- the example of printf "hello world!" in the screen of driver program */ #include <linux/init.h> #include <linux/module.h> MODULE_LICENSE("Dual BSD/GPL"); /* declare the license of the module ,it is necessary */ static int hello_init(void) { printk(KERN_ALERT "Hello World enter!/n"); return 0; } static int hello_exit(void) { printk(KERN_ALERT "Hello world exit!/n"); } module_init(hello_init); /* load the module */ module_exit(hello_exit); /* unload the module */ /* before is some decription of the model,not necessary */ MODULE_AUTHOR("qu jianhua "); MODULE_DESCRIPTION("This is an example of programming driver!"); MODULE_ALIAS("a simplest module"); Makefile demo #filename: Makefile ifneq ($(KERNELRELEASE),) # kbuild part of makefile obj-m := test.o #8123-y := 8123_if.o 8123_pci.o 8123_bin.o else # Normal Makefile #KERNELDIR := /lib/modules/`uname -r`/build KERNELDIR := $(shell pwd)/../Kernel modules: $(MAKE) -C $(KERNELDIR) M=`pwd` modules # Module specific targets #echo "X" > 8123_bin.o_shipped endif clean: rm *.ko *.o