LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
 
Search this Thread
Old 06-08-2006, 06:52 AM   #1
maheshstms
LQ Newbie
 
Registered: Jun 2006
Posts: 10

Rep: Reputation: 0
Loadind a kernel module during system startup


Hello all
I am currently working for a Linux module that needs to get loaded when
the system starts up, How to do this?

I am not into any particular device number, I don't replace any
driver.
My driver needs to be a filter driver for other driver or can be a
separate driver that interacts to the an other driver with some
duration.

The purpose it that, I need to make a Linux module that gets loaded for
a particular IDE device (or could be during system startup). If the
media is available in the IDE device I will have to print a message in
the log (This is for now, maybe I will have to mount it later). The
media's presence is identified by sending a task file to the IDE
driver of the device (hda through d, any one).

I am new to driver development please do suggest me as to how my
requirement could be fulfilled.

Thanks


Mahesh
 
Old 06-08-2006, 07:02 AM   #2
jineshkj
Member
 
Registered: Apr 2006
Distribution: Fedora
Posts: 33

Rep: Reputation: 15
hi,

to load the module, i think it'll be easy to add an insmod line in /etc/rc.local. this file will be executed after ur init scripts. or, u can even write ur own system init script so that it'll be easy to enable/disable this process or even load/unload the module.
 
Old 06-08-2006, 08:56 AM   #3
maheshstms
LQ Newbie
 
Registered: Jun 2006
Posts: 10

Original Poster
Rep: Reputation: 0
Thanks, that worked
I am now able to load my driver when system start up

Is there any possibility to load my driver only when my device is connected to the IDE interface?
and I want the default Linux driver to load along with my driver or the vice versa case.
Is there any possibility of doing this?

Thanks

Mahesh
 
Old 06-08-2006, 10:24 AM   #4
ghatamos
Member
 
Registered: Nov 2003
Posts: 35

Rep: Reputation: 15
you can copy your loadable module to /lib/modules/[kernelversion]/ and perform a depmod -ae

Tell me if that works or does not work...
 
Old 06-08-2006, 10:38 PM   #5
jineshkj
Member
 
Registered: Apr 2006
Distribution: Fedora
Posts: 33

Rep: Reputation: 15
Quote:
Originally Posted by maheshstms
Is there any possibility to load my driver only when my device is connected to the IDE interface?
I think its better to check it while init_module() itself.

Quote:
Originally Posted by maheshstms
and I want the default Linux driver to load along with my driver or the vice versa case.
Is there any possibility of doing this?
if the kernel has loadable module support, u can try loading a module using the request_module() function.
 
Old 06-12-2006, 07:00 AM   #6
maheshstms
LQ Newbie
 
Registered: Jun 2006
Posts: 10

Original Poster
Rep: Reputation: 0
sorry I was held up in an other problem, which i didn't expect to happen.
The problem is I am unable to create a file to an other driver (hdb in my case, the device is in primary slave)
How to use open, ioctl, close functions
working in kernel Module

I am using 2.4 kernel
i get warnings saying
Implicit declaration of function 'open'
Implicit declaration of function 'ioctl'
Implicit declaration of function 'close'

I saw the web and found sys_open, sys_close in linux/fs.h
but they dont have sys_ioctl which 2.6 kernel has

what are the ways to communicate to an other module?
which is the best ruite that you people prefer

thank you
Mahesh
 
Old 06-12-2006, 08:57 AM   #7
ghatamos
Member
 
Registered: Nov 2003
Posts: 35

Rep: Reputation: 15
Sockets comes to mind but i am not that familiar with it so i can't give you much detail.

i just know that it is how the blueZ layers communicate with each other.

i hope this helps.
 
Old 06-12-2006, 10:20 AM   #8
maheshstms
LQ Newbie
 
Registered: Jun 2006
Posts: 10

Original Poster
Rep: Reputation: 0
Quote:
Sockets comes to mind but i am not that familiar with it so i can't give you much detail.

i just know that it is how the blueZ layers communicate with each other.
Socket communication is not for hardware device drivers. They are only for communication between network layers (I guess I am right).

My problem is how do I pass ioctl to other driver from being a driver,

My driver works this way, (works for 2.4 kernel)

1. a. It will get loaded with a entry of 'insmod <driverpath>' in /etc/rc.d/locals'
b. Will have a major number of 254 and being a character driver.
c. It has no dependencies. (Incase it loads this way, later on may subject to change if driver load has to be done for my device in particular, I don’t know how to do this).

2. In init_module, (device detection will happen)
a. Creates handle to hda, hdb, hdc, hdd one by one
b. Check the device is my device by issuing inquiry command (an ioctl)
c. If the device is found create a thread (using pthread) that will pass series of other commands to the driver. else continue with hdb or hdc or hdd.

3. The thread will not stop, It will look in for media change periodically, if media change has happened it will print a log.

The device can be accessed through ports but may get hang-up, when the device driver(had, hdb, hdc, or hdd) tries to perform something on the device.

I need to implement things using taskfile please do suggest me a way
Please do suggest how things in the flow can be modified, any flaws too are welcomed. (Getting rid of the issue too is a must)

Thanks

Mahesh
 
Old 06-15-2006, 09:26 AM   #9
maheshstms
LQ Newbie
 
Registered: Jun 2006
Posts: 10

Original Poster
Rep: Reputation: 0
I was able to interact to other module with
filp_open()
filp_close()
f_op->ioctl()
these functions
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Error] Kernel Module : No kernel module build environment saman007uk Debian 7 09-09-2006 06:34 PM
add new kernel module/file system blackzone Linux - General 1 11-07-2004 11:14 PM
kernel module ignorant newbie looking for any one with kernel module knowledge cpoet Slackware 4 11-24-2003 09:37 PM
startup module loading by kernel, need help asc3ndant Linux - General 1 07-10-2003 07:38 AM
Loadind Windows as default djhipflask Linux - Newbie 2 04-25-2002 01:27 AM


All times are GMT -5. The time now is 05:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration