The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Kernel Mode palash2k UNIX for Dummies Questions & Answers 2 04-23-2008 03:53 AM
How to restrict a user group to access the kernel harishankar HP-UX 0 08-08-2007 11:09 PM
single user mode - user accounts passwords orestis UNIX for Dummies Questions & Answers 2 03-09-2005 06:54 AM
unexpected trap in kernel mode kayode SCO 1 07-07-2004 07:06 AM
k_trap - kernel mode trap type 0x0000000E alex_slb Filesystems, Disks and Memory 3 09-22-2002 03:04 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-27-2007
Registered User
 

Join Date: May 2007
Posts: 7
Aplication user and kernel mode (data access)

Hi all,

I am trying to setup a program to use a device driver and am confusing buffer access between User and Kernel mode. I think all applications running in User space have to communicate with the device drivers using io control calls and then have some functions called back from the driver app.

In this model, I guess the User app passes buffer pointer values to the driver
using the ioctl calls. Is that what happens? For example, I have a session
context struct created by the user app using malloc. Would that data have to
be copied to the driver for it to be used, or could I just pass a pointer to
the struct?

Is using ioctl calls the only way to 'switch to kernel mode'??
Also, am I right in saying the process running on the device driver is
separate from the one running in the application? how does that work in
relation to a threaded application? must a new thread be created with each
function call back?

You can probably tell I am very confused here, so any help is greatly
apreciated!

Regards,
Brendan
Reply With Quote
Forum Sponsor
  #2  
Old 05-27-2007
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,658
Consider the line:
/usr/bin/echo "hello world" > /dev/tty

The shell will open /dev/tty and invoke /usr/bin/echo which will basicly simply execute a write() system call of fd 0. /dev/tty is a special file, so by opening it, we are communicating with the tty driver. Yes, we can then do ioctl() calls and quite a few of them exist for tty's. Most mostly we communicate with driver via the read() and write() system calls. Most character drivers have read, write, and ioctl entry points. Most versions of unix will have something like an init entry point that gets invokes during boot. But user code will communicate with character driver via read, write, and ioctl. There is only one process involved and it is the user process.

I over-simplify a bit here and my biggest lie is claiming that read and write still exist. Most kernels scatter-gather i/o with systems calls like readv() and writev(). The old read and write is reduced to a special case and most drivers simply have readv and writev entry points which are invoked for read() and write().

Not all drivers have all entry points and you can generally write a screwball driver with only an ioctl entry point. This is an underhanded way to add a pseudo system call to a version of unix to which you have no source code license. I have not seen this done in quite a while though. (These days people add screwball filesystems as an underhanded way to pseudo system calls. )
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:31 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0