《Linux设备驱动开发详解》源码(4.1)——hello

来源:互联网 发布:ue4 2d 编程 编辑:程序博客网 时间:2024/05/16 12:11

/home/lihacker/develop/svn/ldd6410-read-only/training/kernel/drivers/hello


< hello.c >/* * A simple kernel module: "hello world" * * The initial developer of the original code is Barry Song * <21cnbao@gmail.com>. All Rights Reserved. */#include <linux/init.h>#include <linux/module.h>static int hello_init(void){printk(KERN_INFO " Hello World enter\n");return 0;}static void hello_exit(void){printk(KERN_INFO " Hello World exit\n ");}module_init(hello_init);module_exit(hello_exit);MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");MODULE_LICENSE("Dual BSD/GPL");MODULE_DESCRIPTION("A simple Hello World Module");MODULE_ALIAS("a simplest module");

< Makefile >KVERS = $(shell uname -r)# Kernel modulesobj-m += hello.o# Specify flags for the module compilation.#EXTRA_CFLAGS=-g -O0build: kernel_moduleskernel_modules:make -C /lib/modules/$(KVERS)/build M=$(CURDIR) modulesclean:make -C /lib/modules/$(KVERS)/build M=$(CURDIR) clean




0 0
原创粉丝点击