Re: Writing to a device at a known physical address



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

.



Relevant Pages

  • [opensuse] openSUSE 10.3 not detecting SATA HD
    ... the sata_sis driver. ... I've tried turning off ACPI in bios and acpi=off which ... openSUSE 10.2 and all my hardware is working fine. ... info.product = 'USB Raw Device Access' ...
    (SuSE)
  • Re: Linux, X, ld, gcc, linking, shared libraries and stuff
    ... >> because, originally, video cards / system RAM could NOT afford to have ... > GL actually "copies" everything, but it's done by the graphics card, so ... > anyway if it's not hardware accelerated. ... installed the proper driver, then it zooms around the screen... ...
    (alt.lang.asm)
  • RE: After Reboot Get an error message "Seriours Error" Help Please
    ... have not added any hardware to my HP Pavilion a450n system or software. ... OCA either reports a failure in a device driver or video card. ... drivers are up to date and Windows certified. ... For additional details see the link to error code ...
    (microsoft.public.windowsxp.help_and_support)
  • Telecom Clock driver for MPCBL0010 ATCA compute blade.
    ... The following is a driver I would like to see included in the base kernel. ... It allows OS controll of a device that synchronizes signaling hardware across a ATCA chassis. ... The telecom clock hardware doesn't interact much with the operating system, ... struct file *filp, unsigned int cmd, unsigned long arg) ...
    (Linux-Kernel)
  • Re: "Generic USB Input Device Support" for keydisks?
    ... > Do you know how Compatible IDs get in to the registry? ... In most cases value is read directly from hardware. ... Only difference is when PnP tries to match driver to install them from inf ... If inf file with Hardware Id is found it will be always used instead of inf ...
    (microsoft.public.windowsxp.embedded)