Re: problem accessing /dev/port

From: Paul Mackerras (paulus@samba.org)
Date: Thu Nov 22 2001 - 22:55:29 EST


Christopher Friesen writes:

> To begin, I'm running 2.2.17 with some patches.
>
> I'm attempting to have a userspace app read and write I/O ports on a powerpc
> machine. The obvious method (iopl()) doesn't seem to be available (using glibc,
> but sys/io.h doesn't exist).
>
> When I try and access /dev/port with a small utility that works fine on my PIII,
> I get the error message "Device not configured". The file exists in /dev and
> has the same permissions on both machines.

If you look in drivers/char/mem.c you will see an #if that eliminates
the statement filp->f_op = &port_fops if CONFIG_PPC is defined. The
reason for this is that accessing a non-existent I/O port on powermacs
generates a machine check interrupt which, in 2.2.x kernels, causes a
panic. The situation is better in 2.4 because we catch the machine
check and arrange for inb/w/l to return ~0.

> Do I need to enable something in the kernel to support this? Where is this
> configured?

Change the #if line to take out the defined(CONFIG_PPC) part.

The other way to access I/O from userspace is to mmap /dev/mem at the
offset that corresponds to the physical address where your PCI host
bridge maps PCI I/O space, e.g. you would use an offset of 0xfe000000
for an MPC106 (grackle) bridge. Once again the situation is better in
2.4 since you can mmap the /proc/bus/pci/bb/dd.f file corresponding to
your pci device and access its memory and I/O regions that way.

Paul.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Nov 23 2001 - 21:00:32 EST