资 源 简 介
以一个hello word程序为例,展示最简单的linux设备驱动程序。hello.c#include #include MODULE_LICENSE("Dual BSD/GPL");static int hello_init(void){ printk(KERN_ERR "hello world!
"); return 0;}static void hello_exit(void){ printk(KERN_ERR "goodbye cruel world
");}module_init(hello_init);module_exit(hello_exit);hello.h:无makefile:ifneq ($(KERNELRELEASE),)obj-m := hello.oelseKERNELDIR ?= /root/rpmbuild/BUILD/kernel-3.10.0-693.21.1.el7/linux-3.10.0-693.21.1.el7.x86_64PWD := $(shell pwd)default:$(MAKE) -C $(KERNELDIR) M=$(PWD) modulesendif