linuxドライバ開発--カーネルシンボルをエクスポート
1862 ワード
カーネルシンボルテンプレートコードをエクスポートし、インスタンスを検証します.
/**
*Copyright (c) 2013.TianYuan
*All rights reserved.
*
* : Esdexp.c
* : , Esdimp.c
*
* :1.0
* :wuyq
*
* :xxx
* :xxx
* :2013-11-18
*/
#include <linux/init.h>
#include <linux/module.h>
// , LISCENSE, (kernel tainted)
MODULE_LICENSE("GPL");
int esdexp_mult(int x, int y)
{
printk("enter esdexp_mult!
");
return (x*y);
}
int esdexp_divd(int x, int y)
{
printk("enter esdexp_divd!
");
return (x/y);
}
/* , */
EXPORT_SYMBOL(esdexp_mult);
EXPORT_SYMBOL(esdexp_divd);
/**
*Copyright (c) 2013.TianYuan
*All rights reserved.
*
* : Esdimp.c
* : Esdexp.c
*
* :1.0
* :wuyq
*
* :xxx
* :xxx
* :2013-11-18
*/
#include <linux/init.h>
#include <linux/module.h>
/* ko , modprob*/
// , LISCENSE, (kernel tainted)
MODULE_LICENSE("GPL");
extern int esdexp_mult(int ,int );
extern int esdexp_divd(int ,int );
static int __init esdimp_init(void)
{
int result = 0;
/* 、 、 */
printk("enter esdimp_init!
");
/* , 。 0*/
/* , 。 。 : , 。*/
result = esdexp_mult(10, 17);
printk("result = %d
", result);
return 0;
}
static void __exit esdimp_exit(void)
{
int result = 0;
printk("enter esdimp_exit!
");
result = esdexp_mult(1000, 60);
printk("result = %d
", result);
}
module_init(esdimp_init);
module_exit(esdimp_exit);
KERNELDIR ?=/root/Desktop/work/ldd3/linux-2.6.31_TX2440A
PWD := $(shell pwd)
obj-m += Esdimp.o Esdexp.o
#obj-m += Esdexp.o
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
clean:
@rm -f *.o *.ord* *.sy* *.mod.* *.ko