Discussion:
Using inb/outb from userspace
b***@blackstar.nl
2002-11-19 16:08:31 UTC
Permalink
Hi all,

I'm trying to get XFree86 working on an NMI uEngine with a Silicon
Motion Lynx3DM+ PCI graphics card.
XFree86 sees the card, and tries to talk to port 0x3c4 with outb,
but fails, with a sig11 (probably because it can't access it
from userspace).

I've written a small module in kernelspace, which does the same,
and that _does_ work.
Does anyone know how to solve this? Pointing me to available
documentation is fine, and I'm perfectly capable of writing
a module to do it if needed, but X needs to be able to write
certain ports.

Thanks in advance,

Bas Vermeulen




-------------------------------------------------------------------
Subscription options: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm
FAQ/Etiquette: http://www.arm.linux.org.uk/armlinux/mailinglists.php
Russell King - ARM Linux
2002-11-19 16:14:48 UTC
Permalink
Post by b***@blackstar.nl
Hi all,
I'm trying to get XFree86 working on an NMI uEngine with a Silicon
Motion Lynx3DM+ PCI graphics card.
XFree86 sees the card, and tries to talk to port 0x3c4 with outb,
but fails, with a sig11 (probably because it can't access it
from userspace).
I've written a small module in kernelspace, which does the same,
and that _does_ work.
Does anyone know how to solve this? Pointing me to available
documentation is fine, and I'm perfectly capable of writing
a module to do it if needed, but X needs to be able to write
certain ports.
There is a defined interface to tell glibc where to get hold of the
info it needs to be able to access IO ports - its in arch/arm/kernel/isa.c.
I'd guess that the uEngine code isn't using it.

-------------------------------------------------------------------
Subscription options: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm
FAQ/Etiquette: http://www.arm.linux.org.uk/armlinux/mailinglists.php
b***@blackstar.nl
2002-11-19 16:35:54 UTC
Permalink
Post by b***@blackstar.nl
Hi all,
I'm trying to get XFree86 working on an NMI uEngine with a Silicon
Motion Lynx3DM+ PCI graphics card.
XFree86 sees the card, and tries to talk to port 0x3c4 with outb, but
fails, with a sig11 (probably because it can't access it
from userspace).
I've written a small module in kernelspace, which does the same, and
that _does_ work.
Does anyone know how to solve this? Pointing me to available
documentation is fine, and I'm perfectly capable of writing
a module to do it if needed, but X needs to be able to write
certain ports.
There is a defined interface to tell glibc where to get hold of the info
it needs to be able to access IO ports - its in arch/arm/kernel/isa.c.
I'd guess that the uEngine code isn't using it.
I can't seem to find anything else that is either, except some code in
arch/arm/kernel/dec21285.c
Is it normal to be able to access the IO ports normally from kernel space?
Like I said, I've written a kernel module which reads and writes port
0x3c4 with outb(X, 0x3c4), and that works as expected.
How would I go about exporting these ports to userspace?
The card itself doesn't use any IO ports (at least, it doesn't export any
in it's PCI headers), but if I write to the necessary ports it works.

Would the following code work?

{
register_isa_ports(0, 0x3c0, 0xf);
}

I can easily put something like that into my module.

Thanks for any help you can give,

Bas Vermeulen



-------------------------------------------------------------------
Subscription options: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm
FAQ/Etiquette: http://www.arm.linux.org.uk/armlinux/mailinglists.php
Russell King - ARM Linux
2002-11-19 16:56:10 UTC
Permalink
Post by b***@blackstar.nl
I can't seem to find anything else that is either, except some code in
arch/arm/kernel/dec21285.c
Is it normal to be able to access the IO ports normally from kernel space?
Yes. The kernel uses its own internal code for outb(). glibc has
a separate chunk of code that deals with it.
Post by b***@blackstar.nl
Would the following code work?
No, because you're telling that code that your IO port space starts at
physical address 0x3c0, and to multiply the port value with 2^15.
Post by b***@blackstar.nl
{
register_isa_ports(0, 0x3c0, 0xf);
}
I can easily put something like that into my module.
It should be in the code that initialises the PCI host bridge.

register_isa_ports(physical_base_of_PCI_memory_address_0,
physical_base_of_PCI_io_address_0,
log_2_of_PCI_address_shift);

glibc should *effectively* do:

static void outb(int val, int port)
{
base = physical_base_of_PCI_io_address_0 +
port << log_2_of_PCI_address_shift;
virtual = map(base);
*virtual = val;
unmap(virtual);
}

obviously, it should be doing something more efficient than this.

-------------------------------------------------------------------
Subscription options: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm
FAQ/Etiquette: http://www.arm.linux.org.uk/armlinux/mailinglists.php
Rojhalat Ibrahim
2002-11-22 11:55:51 UTC
Permalink
Post by b***@blackstar.nl
Hi all,
I'm trying to get XFree86 working on an NMI uEngine with a Silicon
Motion Lynx3DM+ PCI graphics card.
XFree86 sees the card, and tries to talk to port 0x3c4 with outb,
but fails, with a sig11 (probably because it can't access it
from userspace).
I've written a small module in kernelspace, which does the same,
and that _does_ work.
Does anyone know how to solve this? Pointing me to available
documentation is fine, and I'm perfectly capable of writing
a module to do it if needed, but X needs to be able to write
certain ports.
You can set the port access permissions using the ioperm function.

-------------------------------------------------------------------
Subscription options: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm
FAQ/Etiquette: http://www.arm.linux.org.uk/armlinux/mailinglists.php
Russell King - ARM Linux
2002-11-22 12:50:50 UTC
Permalink
Post by Rojhalat Ibrahim
You can set the port access permissions using the ioperm function.
which is not implemented on ARM, because it is an x86-ism.

-------------------------------------------------------------------
Subscription options: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm
FAQ/Etiquette: http://www.arm.linux.org.uk/armlinux/mailinglists.php
Bas Vermeulen
2002-11-22 13:03:21 UTC
Permalink
Post by Russell King - ARM Linux
Post by Rojhalat Ibrahim
You can set the port access permissions using the ioperm function.
which is not implemented on ARM, because it is an x86-ism.
I'm rewriting the new bridge code for that board, and will try to get the
register_isa_ports call correctly for it.
Would anyone be willing to take a look at it when it's finished?
This is the first time I've tried taking on a beast like this, and a
little feedback would be appreciated.

Thanks in advance,

Bas Vermeulen
--
"God, root, what is difference?"
-- Pitr, User Friendly

"God is more forgiving."
-- Dave Aronson


-------------------------------------------------------------------
Subscription options: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm
FAQ/Etiquette: http://www.arm.linux.org.uk/armlinux/mailinglists.php
Loading...