[wdmaudiodev] Re: [wdmaudiodev]: Calling a user defined function from kernel space

  • From: Tim Roberts <timr@xxxxxxxxx>
  • To: wdmaudiodev@xxxxxxxxxxxxx
  • Date: Mon, 09 Apr 2007 10:44:24 -0700

AsHwAtH wrote:
> Exactly, This is what i wanted to do. So i was thinking of User space
> call from the driver through a function pointer. (my first mail)

The problem is context.  When an event happens in your driver, such as
an interrupt, the odds are very strong that your process is not the
"current process".  Because of that, your user-mode addresses point into
random space.  Remember that when there is a switch to a thread in a new
process, all of the user-mode page tables get changed out.  When process
7 is running, no part of process 2 is accessible.  The addresses do not
exist.

The right way to do what you ask is to spin off a separate thread in
your application and send an ioctl to the driver, and have your driver
hold on to it (by returning STATUS_PENDING).  Your application thread
will block.  Then, when the event happens, your driver completes the
ioctl.  The application thread gets control back, knowing that something
happened.

You have to handle cancellation and process shutdown, but they are
well-documented.

-- 
Tim Roberts, timr@xxxxxxxxx
Providenza & Boekelheide, Inc.

******************

WDMAUDIODEV addresses:
Post message: mailto:wdmaudiodev@xxxxxxxxxxxxx
Subscribe:    mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=subscribe
Unsubscribe:  mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=unsubscribe
Moderator:    mailto:wdmaudiodev-moderators@xxxxxxxxxxxxx

URL to WDMAUDIODEV page:
http://www.wdmaudiodev.com/

Other related posts: