From: Henry N. <Hen...@Ar...> - 2008-01-15 18:57:01
|
jitubhai ambani wrote: > Hi, > I use colinux version 0.8.0 on linux as a host. > I was able to insert a simplistic kernel module in the guest. > > However, when I include linux/cooperative_internal.h it gives me > errors. following is a simple kernel module that dosen't work > > #include <linux/kernel.h> /* Needed for KERN_ALERT */ > #include <linux/module.h> /* Needed by all modules */ > #include <linux/unistd.h> > #include <linux/cooperative_internal.h> > #include <linux/string.h> > > > int init_module(void) > { > unsigned long flags; > co_passage_page_assert_valid(); > co_passage_page_acquire(&flags); > co_passage_page->operation = CO_OPERATION_PRINTK; > co_passage_page->params[0] = strlen("We did this!"); > strcpy(co_passage_page->params[1], "We did this!"); > co_switch_wrapper(); > co_passage_page_release(flags); > printk("Hello world 1.\n"); > return 0; > } > void cleanup_module(void) > { > printk("Goodbye world 1.\n"); > } > > > the errors we get are as follows : > > make -C /lib/modules/2.6.15-co-0.8.0/build M=/root modules > make[1]: Entering directory `/root/linux-2.6.15' > CC [M] /root/hello.o > /root/hello.c: In function `init_module': > /root/hello.c:18: warning: passing arg 1 of `strcpy' makes pointer from > integer without a cast > Building modules, stage 2. > MODPOST > *** Warning: "co_passage_page_release" [/root/hello.ko] undefined! > *** Warning: "co_switch_wrapper" [/root/hello.ko] undefined! > *** Warning: "co_passage_page_acquire" [/root/hello.ko] undefined! > *** Warning: "co_passage_page_held" [/root/hello.ko] undefined! > CC /root/hello.mod.o > LD [M] /root/hello.ko > make[1]: Leaving directory `/root/linux-2.6.15' > > > Why can't it find the functions if linux/cooperative_internal.h is > included?... do i have to insert this module in the host kernel?? > (Another observation.. don't know how relevant it is in the context.. > but anyways, all symbols NOT defined extern in cooperative_internal.h > work fine.. all declared extern don't) All colinux internal functions and variables are not exported. They would be very sensitive for using in any other way. You risk crashing your host with smalles typofixies there! For example your strcpy to wrong Pointer, that you have ;-) -strcpy(co_passage_page->params[1], "We did this!"); +strcpy(&co_passage_page->params[1], "We did this!"); External modues should never use colinux_internal header. That's why is named "internal". To have access to variables or functions from an external mudule, you needs to "EXPORT_SYMBOL" every variable or function *ones* in the file, where the variable or function was declared, mostly of they are in arch/i386/kernel/cooperative.c. -- Henry N. |