Re: Writing to a device at a known physical address
- From: Juergen Beisert <jbeisert@xxxxxxxxxxxx>
- Date: Fri, 14 Dec 2007 20:31:59 +0100
James,
James Kimble wrote:
Of course because I'm working directly with hardware this should be
done as a driver.
This is not always true. Hardware abstraction is always a good idea. But if
you only need to set some bits at startup or when the system is already up
and running it could make sense to use this userspace way.
My question is how do I access /dev/mem from user space?
?
man open mmap close ?
Every example driver I've seen requires the user space program to open the
device in order to call the driver functions on that device.
But a normal user cannot open /dev/mem. Do I need a device pointer (sort
of like / dev/modem and /dev/Stty) that has general user access?
Yes, you need to be root to open /dev/mem. As you have access to almost
everything in your system this device is restricted to root only. Note: You
can destroy everything in your system, when you are using /dev/mem in a
wrong way!
I'm really looking for the best way to approach this. I've never
written anything but a trivial driver and I want this to be as efficient
as possible. (Yes, I've got the Rubini book on order....).
Take a look into the UIO (=user I/O) framework, coming with the fresh 2.6.23
kernel. With the help of this framework you can write your own trivial
(=very small) kernel driver that restrict access to a specific piece of
hardware (it works like /dev/mem but for the specific piece of hardware
only).
The advantage is, you can continue to handle this piece of hardware from
userland, but any misuse is restricted to this piece of hardware instead of
the whole system. And with the help of "udev" you can create the
permissions for this device as you need it in your application.
Refer Documentation/DocBook/uio-howto.tmpl for the UI framework.
JB
.
- References:
- Writing to a device at a known physical address
- From: James Kimble
- Re: Writing to a device at a known physical address
- From: Juergen Beisert
- Re: Writing to a device at a known physical address
- From: James Kimble
- Re: Writing to a device at a known physical address
- From: Janaka
- Re: Writing to a device at a known physical address
- From: Juergen Beisert
- Re: Writing to a device at a known physical address
- From: Janaka
- Re: Writing to a device at a known physical address
- From: Juergen Beisert
- Re: Writing to a device at a known physical address
- From: James Kimble
- Writing to a device at a known physical address
- Prev by Date: Re: Writing to a device at a known physical address
- Next by Date: slow USB HD with linux (busybox)
- Previous by thread: Re: Writing to a device at a known physical address
- Next by thread: Re: Writing to a device at a known physical address
- Index(es):
Relevant Pages
|
|