Re: 16-bit read/write operations on ISA bus

Michael Weller (
Fri, 21 Jul 1995 11:46:08 +0200 (MSZ)

[note: You return address(es) are bogus! Fix that!]

> To:
> From: friebe@xvnews.unconfigured.domain (Bernhard Friebe Student (SV S.N J.L))
> Subject: 16-bit read/write operations on ISA bus
> Date: 19 Jul 1995 15:34:58 GMT

> Hi folks,
> I'm new to this newsgroup (and Linux), and not shure if this question really belongs here, but anyway here it comes:
> I am trying to comunicate with a custom pc board with help of the linux provided
> device /dev/port and the open/write/read operations. However these are 8-bits (char) only (that's what I think) and I need to perform 16-bit operations.
> I'm aware that there are existing operations like outb, inb, ... for direct ISA-bus
> comunication, but unfortunately I have no information which file I have to include
> in my C source or in which files these operations are defined (if I include io.h,
> where a definition of inb, outb, ... is given, the internal functions __outb, __inb, ... are unknown on compilation).

One version can be found in the kernel header. #include<asm/io.h> might
do it. But it will include many other stuff or require you to
include/define other stuff to work. Better just copy the definitions from
there (should be /usr/src/linux/asm(-i386)/io.h, if not just use grep in
that directory) into your sources.

However be aware that inb and friends are ONLY defined as inline functs,
that is you have to compile with optimization such that they are inlined
otherwise the linker won't find them. (In theory you could write an
additional seperate inb, etc.. function for your case to make the linker
happy, but making a function call for such a tiny operation is really

Apart from that you have to acquire sufficient rights to access the ports
from the kernel first. Call either ioperm to get specific ports
(unfortunately works only for ports with low addresses) or iopl(3) to get
access to ALL ports (and the interrupt enable bit).

If you need examples how these things work have a look at some svgalib
version. It uses ioperm as well as iopl and also contains own inb etc macro
defs (though with reversed parameters than the kernel).

> I'm aware that this is a really unprecise question, but I would be very happy if
> anyone could give me some help.
I've read worse already. However I'm not sure if my answer will ever
reach you, next time please use correct return addresses.

( or
Please do not use my vm or de0hrz1a accounts anymore. In case of real
problems reaching me try instead.)