2008-09-18 20:25:37 cosine function in driver
w w (CHINA)
Message: 62412
hi, all
I am writing a driver with consine function.
my source file is :
cos.c
#include<linux/init.h>
#include<linux/module.h>
//#include<math.h>
static int hello_init(void)
{
int a;
int b;
a = 0;
b = cos(a);
printk(KERN_ALERT"Hello,world!\n");
printk("a = %d, b = %d\n", a, b);
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT"Goodbye, world!\n");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL");
my Makefile is :
Makefile
KERNELDIR=/uClinux-dist/linux-2.6.x
CC=bfin-uclinux-gcc
CFLAGS=-I. -Wall
LDFLAGS=-lm
MODULES=cos
MODULESO=$(shell for x in $(MODULES); do echo "$$x.o "; done)
MODULESKO=$(shell for x in $(MODULES); do echo "$$x.ko "; done)
PWD=$(shell pwd)
obj-m := $(MODULESO)
all:
make -C $(KERNELDIR) SUBDIRS=$(PWD) modules
clean:
make -C $(KERNELDIR) SUBDIRS=$(PWD) clean
rm -f *.gdb
when I run make, the warning is :
Building modules, stage 2.
MODPOST
*** Warning: "cos" [/cos_test/cos.ko] undefined!
*** Warning: "__fixdfsi" [/cos_test/cos.ko] undefined!
*** Warning: "__floatsidf" [/cos_test/cos.ko] undefined!
CC /cos_test/cos.mod.o
LD [M] /cos_test/cos.ko
I can get cos.ko, but I can not insmod it because of the cos() function. I can not include <math.h>, what should I do? thank you!
QuoteReplyEditDelete
2008-09-18 20:37:37 Re: cosine function in driver
Mike Frysinger (UNITED STATES)
Message: 62413
you cannot use math functions in the kernel. do it in userspace.