LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-13-2010, 08:16 AM   #1
bkankru
LQ Newbie
 
Registered: Nov 2009
Posts: 10

Rep: Reputation: 0
How can we access driver function using system call ?


Dear Friends,

As per my knowledge, one can use systemcall to call the driver functions for example using open, close... Now is there any way to call driver functions directly from application without using system call?

Have a Good Day,
Thank you,
Ankur.
 
Old 04-13-2010, 11:27 PM   #2
archieval
Member
 
Registered: Apr 2007
Location: Philippines
Distribution: Kubuntu, Ubuntu, CentOS
Posts: 289

Rep: Reputation: 41
Using system call is the conventional way to call driver functionalities such as the driver open, close, and ioctls. If your application or program is running in kernel space, then you can directly call your driver functions by exporting them in the driver. But if your program is running in user space, then you have to go through system calls.
 
Old 04-14-2010, 07:30 AM   #3
bkankru
LQ Newbie
 
Registered: Nov 2009
Posts: 10

Original Poster
Rep: Reputation: 0
Dear Friend Archieval,

Thank you for the response. I had one question pertaining to it, Is there any reason why we can access the kernel space device driver function from user space through system call only ?

In my opinion, as devices are treated as file, thats why its must to use systemcall to access device driver present in kernel space?

Have a Good Day,
Thank you,
Ankur
 
Old 04-15-2010, 06:14 AM   #4
archieval
Member
 
Registered: Apr 2007
Location: Philippines
Distribution: Kubuntu, Ubuntu, CentOS
Posts: 289

Rep: Reputation: 41
Hi Ankur,

Because you really cannot access them. Kernel space driver functions are only visible on kernel space. This is important to ensure the stability of the system. Kernel space functions do not share their process address space with the user space programs. So an address of variable being used in a kernel space, cannot be accessed, used, or supplied by a user space program, because if it is possible to do that, it would be easy to destroy the kernel by passing invalid addresses. This separation of user and kernel space is to prevent invalid executions in the kernel space. Kernel space modules or drivers are designed (ideally) to always work, never fail. Because any failure of kernel space functions such as segmentation fault are not recoverable and will cause kernel panic or kernel oops. It is not safe to fail in the kernel space, whereas in the user space it is ok since it does not control the whole system.

So by providing a way or means of accessing the kernel space modules or drivers through system calls, the possible errors that can be committed are reduced or restricted. System calls return proper error codes and the driver also do proper error handling in cases of invalid arguments.

Sorry for the messy explanation, but to summarize it, you cannot afford to fail in the kernel space, so you should go through the proper way of accessing the kernel space driver functionality.

By the way, device files are not ordinary files like text files which can be accessed by fopen, fprintf, etc.

Regards,
archieval
 
Old 04-16-2010, 03:39 AM   #5
bkankru
LQ Newbie
 
Registered: Nov 2009
Posts: 10

Original Poster
Rep: Reputation: 0
Dear Friend Archieval,

I appreciate your kind response. Thank you for wonderful and detailed explanation. My doubts are clear.

Have a Blessed Day,
Thank you,
Ankur
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
IOCTL function call to access the Secure Digital(SD) cards ranju* Programming 0 06-13-2009 01:04 AM
Gnumeric function call to system pppaaarrrkkk Linux - Software 0 03-08-2008 02:05 PM
USB driver won't call probe function linux=future Linux - Kernel 2 01-13-2007 04:47 PM
poepn or system function call executed by a background process kshkid Programming 1 08-24-2006 03:04 AM
access() function call does not work rafiqul Linux - Newbie 1 01-26-2005 02:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:46 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
Open Source Consulting | Domain Registration