Skip to contentSkip to conversation

problem accessing /dev/port

DISCUSSION Christopher Friesen 2 participants 2 messages Nov 22, 2001 – Nov 23, 2001

lore
Share & tools
lore
#0 lore raw

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.

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

Thanks,

Chris

Signature · 4 lines
Chris Friesen                    | MailStop: 043/33/F10  
Nortel Networks                  | work: (613) 765-0557
3500 Carling Avenue              | fax:  (613) 765-2986
Nepean, ON K2H 8E9 Canada        | email: [email protected]
#1 lore raw
Quoted 9 lines · Christopher Friesen

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.

Quoted 2 lines

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.