shithub: 9ferno

ref: b502a62da2ec6058923db94f87ecc2d29db2fa77
dir: /man/3/arch/

View raw version
.TH ARCH 3 x86
arch \- x86 architecture-specific information and control
.B bind -a #P /dev

.B /dev/cputype
.B /dev/ioalloc
.B /dev/iob
.B /dev/iol
.B /dev/iow
.B /dev/irqalloc
This device presents textual information about PC hardware and allows
user-level control of the I/O ports on x86-class machines.
Reads from
.I cputype
recover the processor type and clock rate.
Reads from
.I ioalloc
return I/O ranges used by each device, one line
per range.  Each line contains three fields separated by white space: first address
in hexadecimal,
last address, name of device.
Reads from
.I irqalloc
return the enabled interrupts, one line per
interrupt.  Each line contains three fields separated by white space:
the trap number, the IRQ it is assigned to, and the name of
the device using it.
Reads and writes to
.IR iob ,
.IR iow ,
.I iol
cause 8-bit wide, 16-bit wide, and 32-bit wide requests to
I/O ports.
The port accessed is determined by the byte offset of the
file descriptor.
The following Limbo code reads from an x86 byte I/O port.
inportb(port: int): byte
    data := array[1] of byte;

    if(iobfd == nil)
        iobfd = sys->open("#P/iob", Sys->ORDWR);

    sys->seek(iobfd, port, 0);
    if(sys->read(iobfd, data, len data) != len data)
        fatal(sys->sprint("inportb(16r%4.4x): %r\en", port));
    return data[0];
.B /os/pc/devarch.c