Subject: Equivalent of ioperm / iopl in linux mips ?

From: Wayne Gowcher <[email-masked]>
Date: Fri, 19 Apr 2002 10:06:05 -0700 (PDT)

Hi,

I would like to access Io ports from a user land
application. I found a MINI HOWTO giving an exmaple
using ioperm / iopl and then outb, inb. Searching the
mips source code I see that sys_ioperm returns
"ENOSYS" function not implemented.

Does anyone know how to implement ioperm / iopl type
functionality on a mips system. Any example code would
be appreciated.

Wayne.

__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/

---

From: Geert Uytterhoeven <[email-masked]>
Date: Sat, 20 Apr 2002 11:03:26 +0200 (MEST)

> functionality on a mips system. Any example code would

Like on most architectures that use memory mapped I/O: mmap() the relevant
portion of /dev/mem and read/write to/from the mapped area.

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email-masked]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

---

From: "Maciej W. Rozycki" <[email-masked]>
Date: Mon, 22 Apr 2002 13:35:23 +0200 (MET DST)

> portion of /dev/mem and read/write to/from the mapped area.

 Hmm, I admit I haven't looked at this matter, but aren't
in/out/ioperm/iopl implemented as library functions in glibc like for
other architectures doing MMIO?  E.g. Alpha does this an it makes porting
programs like XFree86 and SVGATextMode much more straightforward and less
processor-specific.  That makes sense as they are not processor specific
but rather bus-specific.  If we don't do that, we should.  For platforms
without an (E)ISA or a PCI bus ioperm/iopl would simply return an error.

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: [email-masked], PGP key available        +

---

From: Geert Uytterhoeven <[email-masked]>
Date: Mon, 22 Apr 2002 16:55:07 +0200 (MEST)

> other architectures doing MMIO?  E.g. Alpha does this an it makes porting

Perhaps. Note that you still need some /proc magic to find out the correct
address to map. Or you can use /dev/ports.

> without an (E)ISA or a PCI bus ioperm/iopl would simply return an error.

Yes indeed.

Gr{oetje,eeting}s,

						Geert

---

From: "Maciej W. Rozycki" <[email-masked]>
Date: Mon, 22 Apr 2002 17:30:08 +0200 (MET DST)

> address to map. Or you can use /dev/ports.

 Well, for Alpha ioperm/iopl functions check the system type in
/proc/cpuinfo (we seem to have enough information there as well) and
failing this they check a result of readlink of /etc/alpha_systype.  Then
an appropriate region of /dev/mem is mmapped with per-page permissions set
up as requested if ioperm is used (with a worse granularity, though) and
subsequent in/out function invocations access the area as appropriate. 
See sysdeps/unix/sysv/linux/alpha/ioperm.c in glibc for details -- it's a
pretty clever solution with good performance and only a few trade-offs.

---

From: Geert Uytterhoeven <[email-masked]>
Date: Mon, 22 Apr 2002 17:33:30 +0200 (MEST)

> pretty clever solution with good performance and only a few trade-offs.

I think PPC has syscalls to find the I/O bases, too.

Gr{oetje,eeting}s,

						Geert

---

From: Ralf Baechle <[email-masked]>
Date: Mon, 22 Apr 2002 10:44:17 -0700

> pretty clever solution with good performance and only a few trade-offs.

Thanks for volunteering ;)

  Ralf

---

From: "Maciej W. Rozycki" <[email-masked]>
Date: Mon, 22 Apr 2002 20:01:38 +0200 (MET DST)

> Thanks for volunteering ;)

 Sure, but I have too many tasks on my to-do list now and no ISA/PCI MIPS
system to test code.  So anyone impatient enough, please do not hesitate
coding changes yourself.  Surely if you can afford waiting three years or
so, you probably need not worry as I shall have done it by then.  Also I'd
appreciate if someone sent me a system for testing.  This could actually
save you a year or two of waiting. ;-)