hello.c
#include#includemodule_license("gpl");
//module_author("cfc");
//module_description("hello linux");
//module_alias("a ****** module");
extern int add(int a,int b);
extern int sub(int a,int b);
static int __init hello_init()
static void __exit hello_exit()
module_init(hello_init);
module_exit(hello_exit);
calculate.c
#include#includemodule_license("gpl");
//module_author("cfc");
//module_description("hello linux");
//module_alias("a ****** module");
int add(int a,int b)
int sub(int a,int b)
static int __init sym_init()
static void __exit sym_exit()
module_init(sym_init);
module_exit(sym_exit);
export_symbol(add);
export_symbol(sub);
makefile
ifneq ($(kernelrelease),)
obj-m := hello.o calculate.o
else
kdir := /lib/modules/2.6.28/build
all:
make -c $(kdir) m=$(pwd) modules
clean:
rm -f *.ko *.o *.mod.o *.mod.c *.symvers
endif
核心模組Makefile
前些天寫乙個驅動模組。竟然寫核心模組makefile時出了問題,於是將其總結下來,下次再用時拿過來改下就行了。general purpose makefile for linux kernel module by guoqingbo kern dir home gqb development lin...
核心模組Makefile
ifneq kernelrelease obj m hello.o else kdir lib modules shell uname r build pwd shell pwd all make c kdir m pwd modules clean make c kdir m pwd clean ...
核心模組 Makefile
寫乙個核心模組的makefile模板記錄 ifneq kernelrelease obj m abc.o else kdir lib modules shell uname r build pwd shell pwd all make c kdir m pwd modules clean rm o ...