驱动代码hello.c
#include#include static int hello_init(void){ printk(KERN_ALERT "Hello, world\n"); return 0;}static void hello_exit(void){ printk(KERN_ALERT "Goodbye, cruel world\n");}module_init(hello_init);module_exit(hello_exit);
Makefile内容
文件名必须保存为Makefile,开头大写!
ifneq ($(KERNELRELEASE),) obj-m := hello.oelsePWD := $(shell pwd)KVER := $(shell uname -r)KDIR := /lib/modules/$(KVER)/buildall: $(MAKE) -C $(KDIR) M=$(PWD) modulesclean: rm -rf .*.cmd *.o *.mod.c *.ko .tmp_versionsendif