linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* userland port io - how do we do it on PReP?
@ 2000-03-06  6:55 David Monro
  2000-03-06  7:25 ` Geert Uytterhoeven
  0 siblings, 1 reply; 2+ messages in thread
From: David Monro @ 2000-03-06  6:55 UTC (permalink / raw)
  To: Linux/ppc Dev List


Hi,

Hope this isn't an FAQ.

I've struck a problem in the X server world - I can't seem to get port
IO (ie inb()) to work.

There are two problems - one is that there doesn't seem to be an
equivalent to ioperm() or iopl() to enable access to the IO ports.
Second is that for MBX and APUS machines the offset to the io port space
appear to be constants, but for other systems we seem to have an
external variables isa_io_base, isa_mem_base and pci_dram_offset. Does
that really mean that programs which do port IO on these systems must
declare and initialize these varibles before doing port IO? And that
MBX, APUS and other systems need different binaries as a result? And
that if /usr/include/linux/autoconfig.h doesn't match the target system
bad things will happen?

The following program doesn't work on my IBM 850:

#include <stdio.h>
#include <asm/io.h>

unsigned long isa_io_base = PREP_ISA_IO_BASE;

main()
{
        int x;

        x = inb(0x3CC);

        printf("x = 0x%02x\n");
}

It just dumps core.

Help?

Cheers,

        David

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: userland port io - how do we do it on PReP?
  2000-03-06  6:55 userland port io - how do we do it on PReP? David Monro
@ 2000-03-06  7:25 ` Geert Uytterhoeven
  0 siblings, 0 replies; 2+ messages in thread
From: Geert Uytterhoeven @ 2000-03-06  7:25 UTC (permalink / raw)
  To: David Monro; +Cc: Linux/ppc Dev List


On Mon, 6 Mar 2000, David Monro wrote:
> Hope this isn't an FAQ.

Yes it is :-)

> I've struck a problem in the X server world - I can't seem to get port
> IO (ie inb()) to work.
>
> There are two problems - one is that there doesn't seem to be an
> equivalent to ioperm() or iopl() to enable access to the IO ports.
> Second is that for MBX and APUS machines the offset to the io port space
> appear to be constants, but for other systems we seem to have an
> external variables isa_io_base, isa_mem_base and pci_dram_offset. Does
> that really mean that programs which do port IO on these systems must
> declare and initialize these varibles before doing port IO? And that
> MBX, APUS and other systems need different binaries as a result? And
> that if /usr/include/linux/autoconfig.h doesn't match the target system
> bad things will happen?

That's all true, unfortunately.

> The following program doesn't work on my IBM 850:
>
> #include <stdio.h>
> #include <asm/io.h>
>
> unsigned long isa_io_base = PREP_ISA_IO_BASE;
>
> main()
> {
>         int x;
>
>         x = inb(0x3CC);
>
>         printf("x = 0x%02x\n");
> }
>
> It just dumps core.

It's even more complicated. You don't have to say

    unsigned long isa_io_base = PREP_ISA_IO_BASE;

only, you have to mmap the I/O port region at offset PREP_ISA_IO_BASE in
/dev/mem and store the resulting virtual addres in isa_io_base. After that
it'll work.

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- Linux/{m68k~Amiga,PPC~CHRP} -- geert@linux-m68k.org

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


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2000-03-06  7:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-03-06  6:55 userland port io - how do we do it on PReP? David Monro
2000-03-06  7:25 ` Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).