Re: call user function from kernel module?

From: Jeff Heath (jheath1_at_optonline.net)
Date: 10/18/03


Date: 18 Oct 2003 06:12:16 -0700

Yanick Poirier <y.poirier_NOSPAM_@yanickpoirier.com> wrote in message news:<gC0kb.64080$Lo.1093668@news.chello.at>...
> Jeff Heath wrote:
> > I'm trying to pass incoming packet data (selected contents from struct
> > sk_buffs) from the kernel to user space at *very* high data rates.
> >
> > I'll create a buffer in user space along with functions to allocate
> > and de-allocate. I will also create a fifo in user space along with
> > functions to enqueue an dequeue.
> >
> > What I'd like to do is write a kernel module that does the following:
> > - calls the user space buffer allocate function that returns a memory
> > location to write into
> > - copy data to the user space buffer (fairly certain I can do this
> > using put_user() once I have a memory location to write to).
> > - call the user space fifo enqueue function
> >
> > I tried a "proof of concept" kernel module that called a user function
> > in a "hello world" like user program. When I inserted the module I got
> > an "unresolved symbole message" which is about what I expected.
> >
> > Is there a way to do this?
>
> I'm actually messing with a similar issue and the way I found to do it
> is the following:
>
> In userland:
> 1) Allocate a data buffer
> 2) Use an IOCTL call to the driver using MYSET or MYGET commmand
> 5) If MYGET, deal with the data received.
>
> In the driver (if MYGET):
>
> 3) Call __copy_to_user()
>
> In the driver (if MYSET):
>
> 3) Allocate a memory block using kmalloc() or get_free_pages()
> 4) Call __copy_from_user()
> 5) Deal with the data
>
> Note that I haven't implemented this yet, as I'm only in early
> development, but theorically it should work.
>
> Anyone?
>
> Regards,
>
> YP.

thanks, I'll research it further and give it a try...



Relevant Pages

  • Re: How to return required buffer size when it changes all the time?
    ... If it is too small, free it, then allocate the new one that is ... after the buffer grows above some ... The common approach is to call the driver twice; ... Suppose the app goes thru these standard motions - and the ...
    (microsoft.public.development.device.drivers)
  • Re: Logical Address To Physical Address
    ... I'm starting developing a very simple Windows CE 5.0 driver in the ... My first question is: how can i get a physical address from a ... If you need to allocate a buffer for which you need to know both the ...
    (microsoft.public.windowsce.platbuilder)
  • Access violation when device plugged out
    ... I have allocated using ExAllocatePoolWithTag to allocate buffer from non ... paged pool for reading data through the USB AV streaming device. ... driver to the next device object. ...
    (microsoft.public.development.device.drivers)
  • Re: Getting Kernel Shared section object name in Appln
    ... To use data buffer between application and driver you can either allocate ... I need to allocate memory in kernel mode, fill it and then user mode ...
    (microsoft.public.development.device.drivers)
  • Re: call user function from kernel module?
    ... > I'll create a buffer in user space along with functions to allocate ... > - calls the user space buffer allocate function that returns a memory ... If MYGET, ...
    (comp.os.linux.development.system)