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

/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

 * <[email protected]>. All Rights Reserved.

 */



#include 

#include 



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 <[email protected]>");

MODULE_LICENSE("Dual BSD/GPL");

MODULE_DESCRIPTION("A simple Hello World Module");

MODULE_ALIAS("a simplest module");

< Makefile >

KVERS = $(shell uname -r)

# Kernel modules
obj-m += hello.o

# Specify flags for the module compilation.
#EXTRA_CFLAGS=-g -O0

build: kernel_modules

kernel_modules:
	make -C /lib/modules/$(KVERS)/build M=$(CURDIR) modules

clean:
	make -C /lib/modules/$(KVERS)/build M=$(CURDIR) clean




你可能感兴趣的:(驱动程序,Linux设备驱动开发详解)