LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Loadind a kernel module during system startup (https://www.linuxquestions.org/questions/linux-kernel-70/loadind-a-kernel-module-during-system-startup-452730/)

maheshstms 06-08-2006 06:52 AM

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

jineshkj 06-08-2006 07:02 AM

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.

maheshstms 06-08-2006 08:56 AM

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

ghatamos 06-08-2006 10:24 AM

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

Tell me if that works or does not work...

jineshkj 06-08-2006 10:38 PM

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.

maheshstms 06-12-2006 07:00 AM

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

ghatamos 06-12-2006 08:57 AM

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.

maheshstms 06-12-2006 10:20 AM

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

maheshstms 06-15-2006 09:26 AM

I was able to interact to other module with
filp_open()
filp_close()
f_op->ioctl()
these functions


All times are GMT -5. The time now is 12:23 PM.