Re: Best way to get a pointer to kernel space from user space

Chris Hirsch (chris@symsystems.com)
Tue, 21 Jul 1998 15:38:50 -0600 (MDT)


On Tue, 21 Jul 1998, Zachary Amsden wrote:
> I'm guessing now this is for a character device.

Yep

>
> If your device can't do memory mapped I/O, you'll have to grab enough free
> pages to hold all the data and map the pages into the processes address
> space.
The device is a PCI prototype card. It has 1024 bytes of memory on the
card but I'm copying that into a struct that has a bunch of stuff inside
and doing stuff to
the data I've received. I'd like to pass a ptr directly to a user program
so that they can directly read/write/modify the stuff in the struct and
then call an ioctl function with whatever they have to to write the stuff
back to the card.

> mmap-able device, and let your program mmap your device. To do the you'll
> need to write a mmap function for your block device that sets up a
> vm_operations_struct that has a nopage operation (and wppage if you need to
> write to the device). Then your nopage operation just translates the PTE
> missed address to the device address.
I understand the theory but how can I do this? I have a struct set up for
the ioctl stuff but when where and how do I set up the
vm_operations_struct? Since its a module I need to do

static struct vm_operations_struct vm_ops = {
vma_open,
vma_close,
};

and what else?? When I call mmmap how does it pass back and address to my
struct in kernel space so that I can use it in user space...also what does
offset mean in the mmap system call?

>
> If the device does DMA, you have a major headache on your hands, but not
> unresolvable.
Fortunatly no :-)

>
> Write me with more details about your driver and I can give sample code.
>
Please let me know if you need more specifics...

I really appreicate your help!!

Chris

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html