Teen Programmers Unite  
 

 

Return to forum top

Linux: module beginner issue

Posted by 142857 [send private reply] at January 09, 2003, 08:59:34 PM

I am starting to read a book on device drivers, and an example given to get started is:

#define MODULE
#include <linux/module.h>
//some stuff here

It gives errors for module.h. But how could module.h have errors if it's worked for everybody else? What do I need to do to make it so those errors don't happen? If you need me to list the errors, tell me. Thanks

Posted by taubz [send private reply] at January 09, 2003, 09:03:57 PM

Yeah, some errors would help! (Not that I've ever tried to make a module.)

- taubz

Posted by gian [send private reply] at January 09, 2003, 10:15:01 PM

That code compiled fine for me. I'm guessing that you are trying to compile this with something like gcc -o module module.c. This won't work, because the program has no entry point. Use gcc -c module.c (to compile module.o) or perhaps someone will contribute information about building a DSO.

Posted by unknown_lamer [send private reply] at January 10, 2003, 01:29:41 PM

Or maybe you forgot to -I/usr/src/linux/include .

Posted by 142857 [send private reply] at January 11, 2003, 10:01:17 PM

thanks for your help. never mind about the errors now; that's all taken care of. but it says that the kernel's version is wrong. how can i fix this--turn some checking off? the book said i have to compile my own kernel. what is that? thanks

Posted by AnyoneEB [send private reply] at January 12, 2003, 11:01:17 AM

The kernal is the main part of an OS. In Linux device drivers are moduals that are called by the kernal. You have to recompile the kernal to get it to use a new modual. You can get kernal sources here: http://www.kernel.org/ or if you have Debian you can apt-get the kernal source. Note that the newest version is usually not a stable release.

Posted by Psion [send private reply] at January 12, 2003, 03:21:57 PM

I can't resist:

kernel

module

Posted by taubz [send private reply] at January 12, 2003, 05:56:36 PM

/me thinks we need a Quickstart guide on spelling :)

Posted by mop [send private reply] at January 12, 2003, 09:46:09 PM

That spelling made even me wince.

Posted by gian [send private reply] at January 13, 2003, 02:47:39 AM

"You can get kernal sources here: http://www.kernel.org/"

How is it that you can have two different spellings in one sentence?

Posted by regretfuldaydreamer [send private reply] at January 13, 2003, 12:04:29 PM

Perhaps his finger slipped.

Posted by SkizZ [send private reply] at January 13, 2003, 03:36:03 PM

His finger slipped everywhere outside the URL???
To code a module you'll need to implement some entry point that are not standard (like the well known 'main()'). I don't remember the exact symbols for now, i'll post it a bit later. You'll need to use some macros (i don't believe #define MODULE will be enougth).
But, why do you want to code a kernal modual ???

Posted by 142857 [send private reply] at January 13, 2003, 07:57:50 PM

why? well, i'd like to get into writing device drivers, and the book that teaches this introduces them. maybe i don't know enough yet, but it's good to learn anyway...

Posted by SkizZ [send private reply] at January 15, 2003, 12:20:26 PM

quite good idea...
I will retake at home some data i have got on a CD (he lays in my office). I have quickly read some parts of the document and i'am sure that your coding style is quite good with a 2.2 kernal ( :) ) but obsolete with a 2.4, as the entry points init_module() and cleanup_module()... sorry but if am right, your book too :( ...

Posted by 142857 [send private reply] at January 15, 2003, 05:21:30 PM

thank you

You must be logged in to post messages and see which you have already read.

Log on
Username:
Password:
Save for later automatic logon

Register as a new user
 
Copyright TPU 2002. See the Credits and About TPU for more information.