From: jitubhai a. <jit...@re...> - 2008-01-15 11:03:16
|
Hi,=0AI use colinux version 0.8.0 on linux as a host.=0AI was able to inser= t a simplistic kernel module in the guest.=0A=0AHowever, when I include lin= ux/cooperative_internal.h it gives me errors. following is a simple kernel= module that dosen't work =0A=0A#include <linux/kernel.h> /* Needed for KER= N_ALERT */=0A#include <linux/module.h> /* Needed by all modules */=0A#inclu= de <linux/unistd.h>=0A#include <linux/cooperative_internal.h>=0A#include <l= inux/string.h>=0A=0A=0Aint init_module(void)=0A{=0A unsigned long flags;= =0A co_passage_page_assert_valid();=0A co_passage_page_acquire(&flags= );=0A co_passage_page->operation =3D CO_OPERATION_PRINTK;=0A co_passa= ge_page->params[0] =3D strlen("We did this!");=0A strcpy(co_passage_page= ->params[1], "We did this!");=0A co_switch_wrapper();=0A co_passage_p= age_release(flags);=0A printk("Hello world 1.\n");=0A return 0;=0A}= =0Avoid cleanup_module(void)=0A{=0A printk("Goodbye world 1.\n");=0A}=0A= =0A=0Athe errors we get are as follows :=0A=0Amake -C /lib/modules/2.6.15-= co-0.8.0/build M=3D/root modules=0Amake[1]: Entering directory `/root/linux= -2.6.15'=0A CC [M] /root/hello.o=0A/root/hello.c: In function `init_modul= e':=0A/root/hello.c:18: warning: passing arg 1 of `strcpy' makes pointer fr= om integer without a cast=0A Building modules, stage 2.=0A MODPOST=0A*** = Warning: "co_passage_page_release" [/root/hello.ko] undefined!=0A*** Warnin= g: "co_switch_wrapper" [/root/hello.ko] undefined!=0A*** Warning: "co_passa= ge_page_acquire" [/root/hello.ko] undefined!=0A*** Warning: "co_passage_pag= e_held" [/root/hello.ko] undefined!=0A CC /root/hello.mod.o=0A LD [M= ] /root/hello.ko=0Amake[1]: Leaving directory `/root/linux-2.6.15'=0A=0A= =0AWhy can't it find the functions if linux/cooperative_internal.h is inclu= ded?... do i have to insert this module in the host kernel??=0A(Another obs= ervation.. don't know how relevant it is in the context.. but anyways, all = symbols NOT defined extern in cooperative_internal.h work fine.. all declar= ed extern don't) |
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. |