RE: information between kernel and device driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I think this shared variable is defined by you in memory.c (kernel file) and now you have exported it as well as using it in you driver by declaring it as extern. Am I right ?

If it is like that, I would like to know, did you compile the kernel and booted you machine from new kernel before loading your driver.

Actually you need to compile your kernel and boot your machine from that new kernel. After booting from new kernel then try to load your driver.

When we load our module, 'insmod' links our module with running kernel. If you have not compiled and booted your machine from new kernel, your machine is still running on old kernel (which do not know anything about our shared variable), so trying to link our module with old kernel will definitely give an error.

Regards,
Gaurav



-----Original Message-----
From: Cristina Rivera [mailto:cris_apricot@xxxxxxxxxxx] 
Sent: Tuesday, July 27, 2004 2:23 AM
To: Dhiman, Gaurav
Subject: RE: information between kernel and device driver


Hi again,

I've tested what you say and :-( it's not working, when I try to load the 
module, I get an error message
"mmap_mod.o: unresolved symbol pid_fault"
where pid_fault is the shared variable between the driver and the kernel, 
defined and exported in memory.c and put as extern in the source of the 
driver.
Suggestions?

Thanks in advance,
Cristina.



>From: "Dhiman, Gaurav" <Gaurav.Dhiman@xxxxxx>
>To: "Cristina Rivera" <cris_apricot@xxxxxxxxxxx>
>CC: <kernelnewbies@xxxxxxxxxxxx>
>Subject: RE: information between kernel and device driver
>Date: Mon, 26 Jul 2004 11:40:25 +0530
>
>
>If you want to define the variable in kernel and use it in your driver,
>that variable should be exported, so that modules (like ur driver) can
>use it.
>
>Another thing is, never define a variable in header file, as header file
>will be included by number of .c files, so compiler will give "Multiple
>Definition" error. If a variable is going to be referred in number of .c
>files, the best practice is to define it in one .c file (it can be
>memory.c for your case, as you mentioned in your last mail) and declare
>the same variable in header file as extern. Now include this header file
>in all .c file where you want to refer that variable.
>
>Declaration of variable as extern, do not allocate a memory to variable.
>It is just a compiler directive statement, which tells the compiler that
>the variable has been defined in some other .c file so no need to give
>an error on finding reference to that variable.
>
>In your case, you can do following:
>
>	memory.c:
>	int bitmap = 0;
>	EXPORT_SYMBOL(bitmap);
>
>	something.h:
>	extern int bitmap;
>
>	your_driver.c
>	#include <something.h>
>	/*Any manipulation of bitmap*/
>	Bitmap += 1;
>
>
>I hope thing work like this, if I am wrong somewhere please correct me.
>
>Regards,
>Gaurav
>
>
>
>-----Original Message-----
>From: kernelnewbies-bounce@xxxxxxxxxxxx
>[mailto:kernelnewbies-bounce@xxxxxxxxxxxx] On Behalf Of Cristina Rivera
>Sent: Sunday, July 25, 2004 8:18 PM
>To: kernelnewbies@xxxxxxxxxxxx
>Subject: information between kernel and device driver
>
>Hi there,
>
>3rd stage of my fight with the kernel.
>
>Problem: I have a char device which has to use information of a kernel
>variable (created for me) called bitmapped, this variable has to be used
>by
>the kernel to get information from user, I have thought about defining
>this
>variable in a header file for including it in the kernel, but...if my
>driver
>has to use it, can I define this variable in the code of my driver as
>extern
>if it's only defined at memory.c, for example?
>
>Which is the best way for defining this variable at the kernel and use
>it
>from either the kernel or the user?
>
>_________________________________________________________________
>Descarga gratis la Barra de Herramientas de MSN
>http://www.msn.es/usuario/busqueda/barra?XAPID=2031&DI=1055&SU=http%3A//
>www.hotmail.com&HL=LINKTAG1OPENINGTEXT_MSNBH
>
>
>--
>Kernelnewbies: Help each other learn about the Linux kernel.
>Archive:       http://mail.nl.linux.org/kernelnewbies/
>FAQ:           http://kernelnewbies.org/faq/
>
>

_________________________________________________________________
Reserva desde ahora tus vacaciones en MSN Viajes. Más cómodo, más barato y 
más opciones. http://www.msn.es/Viajes/



--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux